/[PAMELA software]/PamCut/Collections/EffRigCollection/EffRigCollection.cpp
ViewVC logotype

Diff of /PamCut/Collections/EffRigCollection/EffRigCollection.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by pam-fi, Wed Aug 12 14:18:37 2009 UTC revision 1.2 by pam-fi, Thu Sep 24 18:17:26 2009 UTC
# Line 9  Line 9 
9    
10  #include "EffRigCollection.h"  #include "EffRigCollection.h"
11    
12    extern "C" {
13    bool efficiency_(Int_t*, Int_t*, Double_t*, Double_t*, Double_t*);
14    }
15    
16  EffRigCollection::EffRigCollection(const char *collectionName, TString outFileBase, TString rigBinsFile, bool absRig) :  EffRigCollection::EffRigCollection(const char *collectionName, TString outFileBase, TString rigBinsFile, bool absRig) :
17    EffCollection(collectionName, outFileBase), _bins(0), _selVector(0), _detVector(0), _outUp(0), _outDown(0) {    EffCollection(collectionName, outFileBase), _bins(0), _selVector(0), _detVector(0), _outUp(0), _outDown(0) {
18    
# Line 50  int EffRigCollection::ApplyCut(PamLevel2 Line 54  int EffRigCollection::ApplyCut(PamLevel2
54    
55        if (i < (int) (_selVector.size())) {        if (i < (int) (_selVector.size())) {
56          _selVector[i]++;          _selVector[i]++;
57            _sel++;
58          if (_detCollection.ApplyCut(event) == CUTOK) {          if (_detCollection.ApplyCut(event) == CUTOK) {
59            _detVector[i]++;            _detVector[i]++;
60              _det++;
61            _nGood++;            _nGood++;
62            return CUTOK;            return CUTOK;
63          }          }
# Line 71  int EffRigCollection::ApplyCut(PamLevel2 Line 77  int EffRigCollection::ApplyCut(PamLevel2
77    
78  void EffRigCollection::Finalize() {  void EffRigCollection::Finalize() {
79    
   // Correct the number of selected events by subtracting events outside the rigidity interval  
   _sel -= _outUp + _outDown;  
80    // Print the report    // Print the report
81    EffCollection::Finalize();    EffCollection::Finalize();
82    cout << "    Events below the minimum rigidity: " << _outDown << "\n";    cout << "    Events below the minimum rigidity: " << _outDown << "\n";
83    cout << "    Events above the maximum rigidity: " << _outUp << "\n";    cout << "    Events above the maximum rigidity: " << _outUp << "\n";
84    
85      // Compute the error
86      Int_t sel[_selVector.size()];
87      Int_t det[_detVector.size()];
88      Double_t eff[_selVector.size()];
89      Double_t errLow[_selVector.size()];
90      Double_t errHigh[_selVector.size()];
91      for (unsigned int i = 0; i < _selVector.size(); i++) {
92        sel[i] = (Int_t) _selVector[i];
93        det[i] = (Int_t) _detVector[i];
94        efficiency_(&(sel[i]), &(det[i]), &(eff[i]), &(errLow[i]), &(errHigh[i]));
95      }
96    // Write the output files    // Write the output files
97    if (_outFileBase != "") {    if (_outFileBase != "") {
98      ofstream outTextFile((_outFileBase + "-eff-rig.txt").Data(), ios_base::out);      ofstream outTextFile((_outFileBase + "-eff-rig.txt").Data(), ios_base::out);
99        streamsize newPrec = 4;
100        outTextFile.precision(newPrec);
101        outTextFile.setf(ios::fixed, ios::floatfield);
102      for (unsigned int i = 0; i < _selVector.size(); i++) {      for (unsigned int i = 0; i < _selVector.size(); i++) {
103        outTextFile << _detVector[i] << "    " << _selVector[i] << "    ";        outTextFile << setw(10) << _detVector[i] << setw(10) << _selVector[i];
104        if (_selVector[i] != 0)        if (_selVector[i] != 0)
105          outTextFile << (float) _detVector[i] / (float) _selVector[i] << "\n";          outTextFile << setw(10) << eff[i] << setw(10) << errLow[i] << setw(10) << errHigh[i] << "\n";
106        else        else
107          outTextFile << "0.\n";          outTextFile << setw(10) << 0. << setw(10) << 0. << setw(10) << 0. << endl;
108    
109      }      }
110      outTextFile.close();      outTextFile.close();

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.23