1 |
// $Id: RunLumiSelectionMod.cc,v 1.2 2010/05/06 17:30:17 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 |
{
|
21 |
// Constructor.
|
22 |
}
|
23 |
|
24 |
//--------------------------------------------------------------------------------------------------
|
25 |
RunLumiSelectionMod::~RunLumiSelectionMod()
|
26 |
{
|
27 |
// Destructor.
|
28 |
}
|
29 |
|
30 |
|
31 |
//--------------------------------------------------------------------------------------------------
|
32 |
void RunLumiSelectionMod::BeginRun()
|
33 |
{
|
34 |
|
35 |
}
|
36 |
|
37 |
//--------------------------------------------------------------------------------------------------
|
38 |
void RunLumiSelectionMod::Process()
|
39 |
{
|
40 |
// Increment counters and stop further processing of an event if current run is excluded
|
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 (!fAcceptCurrentRunLumi) {
|
64 |
++fNFailed;
|
65 |
OnFailed();
|
66 |
if (fAbort) {
|
67 |
SkipEvent(); // abort processing of this event by sub-modules
|
68 |
}
|
69 |
return;
|
70 |
}
|
71 |
|
72 |
// take action if accepted
|
73 |
++fNAcceped;
|
74 |
IncNEventsProcessed();
|
75 |
OnAccepted();
|
76 |
}
|
77 |
|
78 |
//--------------------------------------------------------------------------------------------------
|
79 |
void RunLumiSelectionMod::SlaveBegin()
|
80 |
{
|
81 |
|
82 |
}
|
83 |
|
84 |
//--------------------------------------------------------------------------------------------------
|
85 |
void RunLumiSelectionMod::SlaveTerminate()
|
86 |
{
|
87 |
// Save number of accepted events.
|
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 |
}
|