ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/src/RunLumiSelectionMod.cc
Revision: 1.4
Committed: Tue Jun 29 15:51:53 2010 UTC (14 years, 10 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c
Changes since 1.3: +31 -2 lines
Log Message:
Add machinery for processed lumi json files

File Contents

# Content
1 // $Id: RunLumiSelectionMod.cc,v 1.3 2010/05/29 18:10:15 bendavid Exp $
2
3 #include "MitAna/PhysicsMod/interface/RunLumiSelectionMod.h"
4 #include <TTree.h>
5 #include "MitAna/DataTree/interface/Names.h"
6
7 using namespace mithep;
8
9 ClassImp(mithep::RunLumiSelectionMod)
10
11 //--------------------------------------------------------------------------------------------------
12 RunLumiSelectionMod::RunLumiSelectionMod(const char *name, const char *title) :
13 BaseMod(name,title),
14 fAbort(kTRUE),
15 fAcceptMC(kFALSE),
16 fNEvents(0),
17 fNAcceped(0),
18 fNFailed(0),
19 fAcceptCurrentRunLumi(kFALSE),
20 fRunLumiGraph(0)
21 {
22 // Constructor.
23 }
24
25 //--------------------------------------------------------------------------------------------------
26 RunLumiSelectionMod::~RunLumiSelectionMod()
27 {
28 // Destructor.
29 }
30
31
32 //--------------------------------------------------------------------------------------------------
33 void RunLumiSelectionMod::BeginRun()
34 {
35
36 }
37
38 //--------------------------------------------------------------------------------------------------
39 void RunLumiSelectionMod::Process()
40 {
41 // Increment counters and stop further processing of an event if current run is excluded
42
43 ++fNEvents;
44
45 RunLumiPairType runLumi(GetEventHeader()->RunNum(),GetEventHeader()->LumiSec());
46
47 //check decision only if lumi section has changed
48 if (runLumi != fCurrentRunLumi) {
49 fAcceptCurrentRunLumi = kFALSE;
50 //check for MC default accept
51 if (fAcceptMC && GetEventHeader()->IsMC()) {
52 fAcceptCurrentRunLumi = kTRUE;
53 }
54 else {
55 fAcceptCurrentRunLumi = fAcceptedRunsLumis.HasRunLumi(runLumi);
56 }
57 fCurrentRunLumi = runLumi;
58 if (fAcceptCurrentRunLumi) {
59 fRunLumiSet.Add(runLumi);
60 }
61 if (0) {
62 printf("Run %u, Lumi %u, accepted = %i\n",runLumi.first,runLumi.second,fAcceptCurrentRunLumi);
63 }
64 }
65
66 // take action if failed
67 if (!fAcceptCurrentRunLumi) {
68 ++fNFailed;
69 OnFailed();
70 if (fAbort) {
71 SkipEvent(); // abort processing of this event by sub-modules
72 }
73 return;
74 }
75
76 // take action if accepted
77 ++fNAcceped;
78 IncNEventsProcessed();
79 OnAccepted();
80 }
81
82 //--------------------------------------------------------------------------------------------------
83 void RunLumiSelectionMod::SlaveBegin()
84 {
85
86 // fRunLumiVector = new RunLumiVector;
87 // fRunLumiVector->SetName("ProcessedRunsLumis");
88 // AddOutput(fRunLumiVector);
89
90 }
91
92 //--------------------------------------------------------------------------------------------------
93 void RunLumiSelectionMod::SlaveTerminate()
94 {
95 // Save number of accepted events.
96
97 const RunLumiSet::SetType &theset = fRunLumiSet.runLumiSet();
98
99 UInt_t setSize = theset.size();
100 Double_t *runArray = new Double_t[setSize];
101 Double_t *lumiArray = new Double_t[setSize];
102
103 UInt_t arrayPos = 0;
104 for (RunLumiSet::SetType::const_iterator it = theset.begin(); it!=theset.end(); ++it) {
105 printf("first = %u, second = %u\n",it->first,it->second);
106 runArray[arrayPos] = it->first;
107 lumiArray[arrayPos] = it->second;
108 ++arrayPos;
109 }
110
111 fRunLumiGraph = new TGraph(setSize,runArray,lumiArray);
112 fRunLumiGraph->SetName("ProcessedRunsLumis");
113 AddOutput(fRunLumiGraph);
114
115 delete runArray;
116 delete lumiArray;
117
118 SaveNEventsProcessed();
119 }
120
121 //--------------------------------------------------------------------------------------------------
122 void RunLumiSelectionMod::AddJSONFile(const std::string &filepath)
123 {
124 //pass JSON file to map object
125 fAcceptedRunsLumis.AddJSONFile(filepath);
126 }