/[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.9 by pam-fi, Tue Jul 12 17:36:03 2011 UTC
# Line 9  Line 9 
9    
10  #include "EffRigCollection.h"  #include "EffRigCollection.h"
11    
12  EffRigCollection::EffRigCollection(const char *collectionName, TString outFileBase, TString rigBinsFile, bool absRig) :  EffRigCollection::EffRigCollection(const char *collectionName, TString outFileBase, TString rigBinsFile, int errMethod,
13    EffCollection(collectionName, outFileBase), _bins(0), _selVector(0), _detVector(0), _outUp(0), _outDown(0) {      bool owns) :
14        BinnedEffCollection(collectionName, outFileBase, rigBinsFile, errMethod, owns) {
   ifstream rigBinListFile;  
   rigBinListFile.open(rigBinsFile);  
   
   TString auxString;  
   while (!rigBinListFile.eof()) {  
     rigBinListFile >> auxString;  
     if (auxString != "") {  
       _bins.push_back(auxString.Atof());  
     }  
   }  
   rigBinListFile.close();  
   
   _selVector.resize(_bins.size() - 1, 0);  
   _detVector.resize(_bins.size() - 1, 0);  
 }  
   
 int EffRigCollection::ApplyCut(PamLevel2 *event) {  
   
   _nEv++;  
   if (_selCollection.ApplyCut(event) == CUTOK) {  
     // Check if the event is inside the rigidity range  
     // NOTE: at this point a TrkPhSinCut should be already performed,  
     //       since we are going to retrieve rigidity.  
     float rig;  
     if (_absRig) {  
       rig = event->GetTrack(0)->GetTrkTrack()->GetRigidity();  
     }  
     else  
       rig = 1. / event->GetTrack(0)->GetTrkTrack()->GetDeflection();  
     if (rig >= _bins[0]) {  
       int i = 1;  
       while (rig >= _bins[i] && i < (int) _bins.size()) {  
         i++;  
       }  
       i--;  
   
       if (i < (int) (_selVector.size())) {  
         _selVector[i]++;  
         if (_detCollection.ApplyCut(event) == CUTOK) {  
           _detVector[i]++;  
           _nGood++;  
           return CUTOK;  
         }  
       }  
       else  
         _outUp++;  
   
     }  
     else {  
       _outDown++;  
       return 0;  
     }  
   }  
   
   return 0;  
15  }  }
16    
17  void EffRigCollection::Finalize() {  float EffRigCollection::GetBinValue(PamLevel2 *event) {
   
   // Correct the number of selected events by subtracting events outside the rigidity interval  
   _sel -= _outUp + _outDown;  
   // Print the report  
   EffCollection::Finalize();  
   cout << "    Events below the minimum rigidity: " << _outDown << "\n";  
   cout << "    Events above the maximum rigidity: " << _outUp << "\n";  
   
   // Write the output files  
   if (_outFileBase != "") {  
     ofstream outTextFile((_outFileBase + "-eff-rig.txt").Data(), ios_base::out);  
     for (unsigned int i = 0; i < _selVector.size(); i++) {  
       outTextFile << _detVector[i] << "    " << _selVector[i] << "    ";  
       if (_selVector[i] != 0)  
         outTextFile << (float) _detVector[i] / (float) _selVector[i] << "\n";  
       else  
         outTextFile << "0.\n";  
   
     }  
     outTextFile.close();  
   }  
18    
19      return 1. / event->GetTrack(0)->GetTrkTrack()->GetDeflection();
20  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.23