ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/src/RunLumiSelectionMod.cc
(Generate patch)

Comparing UserCode/MitAna/PhysicsMod/src/RunLumiSelectionMod.cc (file contents):
Revision 1.1 by bendavid, Mon May 3 11:36:01 2010 UTC vs.
Revision 1.3 by bendavid, Sat May 29 18:10:15 2010 UTC

# Line 1 | Line 1
1   // $Id$
2  
3   #include "MitAna/PhysicsMod/interface/RunLumiSelectionMod.h"
4 #include <TFile.h>
4   #include <TTree.h>
5   #include "MitAna/DataTree/interface/Names.h"
6  
# Line 13 | Line 12 | ClassImp(mithep::RunLumiSelectionMod)
12   RunLumiSelectionMod::RunLumiSelectionMod(const char *name, const char *title) :
13    BaseMod(name,title),
14    fAbort(kTRUE),
15 <  fDefaultAccept(kFALSE),
15 >  fAcceptMC(kFALSE),
16    fNEvents(0),
17    fNAcceped(0),
18    fNFailed(0),
19 <  fAcceptCurrentRun(kFALSE)
19 >  fAcceptCurrentRunLumi(kFALSE)
20   {
21    // Constructor.
22   }
# Line 32 | Line 31 | RunLumiSelectionMod::~RunLumiSelectionMo
31   //--------------------------------------------------------------------------------------------------
32   void RunLumiSelectionMod::BeginRun()
33   {
35  //Decide if this run should be accepted and cache decision.
36  UInt_t run = GetRunInfo()->RunNum();
37  Bool_t accepted = kFALSE;
38  Bool_t excluded = kFALSE;
39  
40  //check if run is explicitly accepted
41  for (UIntBounds::const_iterator it = fAcceptedRuns.begin(); it!=fAcceptedRuns.end(); ++it) {
42    if (run>=it->first && run<=it->second) {
43      accepted = kTRUE;
44      break;
45    }
46  }
47  
48  //check if run is explicitly excluded
49  for (UIntBounds::const_iterator it = fExcludedRuns.begin(); it!=fExcludedRuns.end(); ++it) {
50    if (run>=it->first && run<=it->second) {
51      excluded = kTRUE;
52      break;
53    }
54  }
55  
56  //construct final decision
57  fAcceptCurrentRun = (fDefaultAccept || accepted) && !excluded;
34    
35   }
36  
# Line 65 | Line 41 | void RunLumiSelectionMod::Process()
41  
42    ++fNEvents;
43  
44 +  RunLumiPairType runLumi(GetEventHeader()->RunNum(),GetEventHeader()->LumiSec());
45 +
46 +  //check decision only if lumi section has changed
47 +  if (runLumi != fCurrentRunLumi) {
48 +    fAcceptCurrentRunLumi = kFALSE;
49 +    //check for MC default accept
50 +    if (fAcceptMC && GetEventHeader()->IsMC()) {
51 +      fAcceptCurrentRunLumi = kTRUE;
52 +    }
53 +    else {
54 +      fAcceptCurrentRunLumi = fAcceptedRunsLumis.HasRunLumi(runLumi);
55 +    }
56 +    fCurrentRunLumi = runLumi;
57 +    if (0) {
58 +      printf("Run %u, Lumi %u, accepted = %i\n",runLumi.first,runLumi.second,fAcceptCurrentRunLumi);
59 +    }
60 +  }
61 +
62    // take action if failed
63 <  if (!fAcceptCurrentRun) {
63 >  if (!fAcceptCurrentRunLumi) {
64      ++fNFailed;
65      OnFailed();
66      if (fAbort) {
# Line 94 | Line 88 | void RunLumiSelectionMod::SlaveTerminate
88  
89    SaveNEventsProcessed();
90   }
91 +
92 + //--------------------------------------------------------------------------------------------------
93 + void RunLumiSelectionMod::AddJSONFile(const std::string &filepath)
94 + {
95 +  //pass JSON file to map object
96 +  fAcceptedRunsLumis.AddJSONFile(filepath);
97 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines