1 |
bendavid |
1.1 |
// $Id: RunLumiSelectionMod.cc,v 1.1 2010/01/18 14:35:43 bendavid Exp $
|
2 |
|
|
|
3 |
|
|
#include "MitAna/PhysicsMod/interface/RunLumiSelectionMod.h"
|
4 |
|
|
#include <TFile.h>
|
5 |
|
|
#include <TTree.h>
|
6 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
7 |
|
|
|
8 |
|
|
using namespace mithep;
|
9 |
|
|
|
10 |
|
|
ClassImp(mithep::RunLumiSelectionMod)
|
11 |
|
|
|
12 |
|
|
//--------------------------------------------------------------------------------------------------
|
13 |
|
|
RunLumiSelectionMod::RunLumiSelectionMod(const char *name, const char *title) :
|
14 |
|
|
BaseMod(name,title),
|
15 |
|
|
fAbort(kTRUE),
|
16 |
|
|
fDefaultAccept(kFALSE),
|
17 |
|
|
fNEvents(0),
|
18 |
|
|
fNAcceped(0),
|
19 |
|
|
fNFailed(0),
|
20 |
|
|
fAcceptCurrentRun(kFALSE)
|
21 |
|
|
{
|
22 |
|
|
// Constructor.
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
//--------------------------------------------------------------------------------------------------
|
26 |
|
|
RunLumiSelectionMod::~RunLumiSelectionMod()
|
27 |
|
|
{
|
28 |
|
|
// Destructor.
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
//--------------------------------------------------------------------------------------------------
|
33 |
|
|
void RunLumiSelectionMod::BeginRun()
|
34 |
|
|
{
|
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;
|
58 |
|
|
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
//--------------------------------------------------------------------------------------------------
|
62 |
|
|
void RunLumiSelectionMod::Process()
|
63 |
|
|
{
|
64 |
|
|
// Increment counters and stop further processing of an event if current run is excluded
|
65 |
|
|
|
66 |
|
|
++fNEvents;
|
67 |
|
|
|
68 |
|
|
// take action if failed
|
69 |
|
|
if (!fAcceptCurrentRun) {
|
70 |
|
|
++fNFailed;
|
71 |
|
|
OnFailed();
|
72 |
|
|
if (fAbort) {
|
73 |
|
|
SkipEvent(); // abort processing of this event by sub-modules
|
74 |
|
|
}
|
75 |
|
|
return;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
// take action if accepted
|
79 |
|
|
++fNAcceped;
|
80 |
|
|
IncNEventsProcessed();
|
81 |
|
|
OnAccepted();
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
//--------------------------------------------------------------------------------------------------
|
85 |
|
|
void RunLumiSelectionMod::SlaveBegin()
|
86 |
|
|
{
|
87 |
|
|
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
//--------------------------------------------------------------------------------------------------
|
91 |
|
|
void RunLumiSelectionMod::SlaveTerminate()
|
92 |
|
|
{
|
93 |
|
|
// Save number of accepted events.
|
94 |
|
|
|
95 |
|
|
SaveNEventsProcessed();
|
96 |
|
|
}
|