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.5 by sixie, Wed Jul 27 21:26:42 2011 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 >  fAcceptAll(kFALSE),
17    fNEvents(0),
18    fNAcceped(0),
19    fNFailed(0),
20 <  fAcceptCurrentRun(kFALSE)
20 >  fAcceptCurrentRunLumi(kFALSE),
21 >  fRunLumiGraph(0)
22   {
23    // Constructor.
24   }
# Line 32 | Line 33 | RunLumiSelectionMod::~RunLumiSelectionMo
33   //--------------------------------------------------------------------------------------------------
34   void RunLumiSelectionMod::BeginRun()
35   {
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;
36    
37   }
38  
# Line 65 | Line 43 | void RunLumiSelectionMod::Process()
43  
44    ++fNEvents;
45  
46 +  RunLumiPairType runLumi(GetEventHeader()->RunNum(),GetEventHeader()->LumiSec());
47 +
48 +  //check decision only if lumi section has changed
49 +  if (runLumi != fCurrentRunLumi) {
50 +    fAcceptCurrentRunLumi = kFALSE;
51 +    //check for MC default accept
52 +    if (fAcceptAll || (fAcceptMC && GetEventHeader()->IsMC())) {
53 +      fAcceptCurrentRunLumi = kTRUE;
54 +    }
55 +    else {
56 +      fAcceptCurrentRunLumi = fAcceptedRunsLumis.HasRunLumi(runLumi);
57 +    }
58 +    fCurrentRunLumi = runLumi;
59 +    if (fAcceptCurrentRunLumi) {
60 +      fRunLumiSet.Add(runLumi);
61 +    }
62 +    if (0) {
63 +      printf("Run %u, Lumi %u, accepted = %i\n",runLumi.first,runLumi.second,fAcceptCurrentRunLumi);
64 +    }
65 +  }
66 +
67    // take action if failed
68 <  if (!fAcceptCurrentRun) {
68 >  if (!fAcceptCurrentRunLumi) {
69      ++fNFailed;
70      OnFailed();
71      if (fAbort) {
# Line 85 | Line 84 | void RunLumiSelectionMod::Process()
84   void RunLumiSelectionMod::SlaveBegin()
85   {
86  
87 + //   fRunLumiVector = new RunLumiVector;
88 + //   fRunLumiVector->SetName("ProcessedRunsLumis");
89 + //   AddOutput(fRunLumiVector);
90 +
91   }
92  
93   //--------------------------------------------------------------------------------------------------
# Line 92 | Line 95 | void RunLumiSelectionMod::SlaveTerminate
95   {
96    // Save number of accepted events.
97  
98 +  const RunLumiSet::SetType &theset = fRunLumiSet.runLumiSet();
99 +
100 +  UInt_t setSize = theset.size();
101 +  Double_t *runArray = new Double_t[setSize];
102 +  Double_t *lumiArray = new Double_t[setSize];
103 +  
104 +  UInt_t arrayPos = 0;
105 +  for (RunLumiSet::SetType::const_iterator it = theset.begin(); it!=theset.end(); ++it) {
106 +    printf("first = %u, second = %u\n",it->first,it->second);
107 +    runArray[arrayPos] = it->first;
108 +    lumiArray[arrayPos] = it->second;
109 +    ++arrayPos;
110 +  }
111 +
112 +  fRunLumiGraph = new TGraph(setSize,runArray,lumiArray);
113 +  fRunLumiGraph->SetName("ProcessedRunsLumis");
114 +  AddOutput(fRunLumiGraph);
115 +  
116 +  delete runArray;
117 +  delete lumiArray;
118 +  
119    SaveNEventsProcessed();
120   }
121 +
122 + //--------------------------------------------------------------------------------------------------
123 + void RunLumiSelectionMod::AddJSONFile(const std::string &filepath)
124 + {
125 +  //pass JSON file to map object
126 +  fAcceptedRunsLumis.AddJSONFile(filepath);
127 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines