ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/src/RunLumiSelectionMod.cc
Revision: 1.5
Committed: Wed Jul 27 21:26:42 2011 UTC (13 years, 9 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, HEAD
Branch point for: Mit_025c_branch
Changes since 1.4: +3 -2 lines
Log Message:
add option to accept all events

File Contents

# Content
1 // $Id: RunLumiSelectionMod.cc,v 1.4 2010/06/29 15:51:53 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 fAcceptAll(kFALSE),
17 fNEvents(0),
18 fNAcceped(0),
19 fNFailed(0),
20 fAcceptCurrentRunLumi(kFALSE),
21 fRunLumiGraph(0)
22 {
23 // Constructor.
24 }
25
26 //--------------------------------------------------------------------------------------------------
27 RunLumiSelectionMod::~RunLumiSelectionMod()
28 {
29 // Destructor.
30 }
31
32
33 //--------------------------------------------------------------------------------------------------
34 void RunLumiSelectionMod::BeginRun()
35 {
36
37 }
38
39 //--------------------------------------------------------------------------------------------------
40 void RunLumiSelectionMod::Process()
41 {
42 // Increment counters and stop further processing of an event if current run is excluded
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 (!fAcceptCurrentRunLumi) {
69 ++fNFailed;
70 OnFailed();
71 if (fAbort) {
72 SkipEvent(); // abort processing of this event by sub-modules
73 }
74 return;
75 }
76
77 // take action if accepted
78 ++fNAcceped;
79 IncNEventsProcessed();
80 OnAccepted();
81 }
82
83 //--------------------------------------------------------------------------------------------------
84 void RunLumiSelectionMod::SlaveBegin()
85 {
86
87 // fRunLumiVector = new RunLumiVector;
88 // fRunLumiVector->SetName("ProcessedRunsLumis");
89 // AddOutput(fRunLumiVector);
90
91 }
92
93 //--------------------------------------------------------------------------------------------------
94 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 }