1 |
bendavid |
1.1 |
// $Id: MCProcessSelectionMod.cc,v 1.1 2010/01/18 14:35:43 bendavid Exp $
|
2 |
|
|
|
3 |
|
|
#include "MitAna/PhysicsMod/interface/MCProcessSelectionMod.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::MCProcessSelectionMod)
|
11 |
|
|
|
12 |
|
|
//--------------------------------------------------------------------------------------------------
|
13 |
|
|
MCProcessSelectionMod::MCProcessSelectionMod(const char *name, const char *title) :
|
14 |
|
|
BaseMod(name,title),
|
15 |
|
|
fMCEventInfoName(Names::gkMCEvtInfoBrn),
|
16 |
|
|
fAbort(kTRUE),
|
17 |
|
|
fDefaultAccept(kTRUE),
|
18 |
|
|
fNEvents(0),
|
19 |
|
|
fNAcceped(0),
|
20 |
|
|
fNFailed(0),
|
21 |
|
|
fMCEventInfo(0)
|
22 |
|
|
{
|
23 |
|
|
// Constructor.
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
//--------------------------------------------------------------------------------------------------
|
27 |
|
|
MCProcessSelectionMod::~MCProcessSelectionMod()
|
28 |
|
|
{
|
29 |
|
|
// Destructor.
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
//--------------------------------------------------------------------------------------------------
|
34 |
|
|
void MCProcessSelectionMod::BeginRun()
|
35 |
|
|
{
|
36 |
|
|
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
//--------------------------------------------------------------------------------------------------
|
40 |
|
|
void MCProcessSelectionMod::Process()
|
41 |
|
|
{
|
42 |
|
|
// Increment counters and stop further processing of an event if current run is excluded
|
43 |
|
|
|
44 |
|
|
++fNEvents;
|
45 |
|
|
|
46 |
|
|
//accept by default
|
47 |
|
|
if ( (fDefaultAccept && fExcludedProcessIds.size()==0) ) {
|
48 |
|
|
++fNAcceped;
|
49 |
|
|
IncNEventsProcessed();
|
50 |
|
|
OnAccepted();
|
51 |
|
|
return;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
LoadBranch(fMCEventInfoName);
|
55 |
|
|
Int_t processid = fMCEventInfo->ProcessId();
|
56 |
|
|
|
57 |
|
|
Bool_t accepted = kFALSE;
|
58 |
|
|
Bool_t excluded = kFALSE;
|
59 |
|
|
|
60 |
|
|
//check if process is explicitly accepted
|
61 |
|
|
for (std::vector<Int_t>::const_iterator it = fAcceptedProcessIds.begin(); it!=fAcceptedProcessIds.end(); ++it) {
|
62 |
|
|
if (processid == *it) {
|
63 |
|
|
accepted = kTRUE;
|
64 |
|
|
break;
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
//check if process is explicitly excluded
|
69 |
|
|
for (std::vector<Int_t>::const_iterator it = fExcludedProcessIds.begin(); it!=fExcludedProcessIds.end(); ++it) {
|
70 |
|
|
if (processid == *it) {
|
71 |
|
|
excluded = kTRUE;
|
72 |
|
|
break;
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
//construct final decision
|
77 |
|
|
Bool_t fAcceptCurrentEvent = (fDefaultAccept || accepted) && !excluded;
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
// take action if failed
|
81 |
|
|
if (!fAcceptCurrentEvent) {
|
82 |
|
|
++fNFailed;
|
83 |
|
|
OnFailed();
|
84 |
|
|
if (fAbort) {
|
85 |
|
|
SkipEvent(); // abort processing of this event by sub-modules
|
86 |
|
|
}
|
87 |
|
|
return;
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
// take action if accepted
|
91 |
|
|
++fNAcceped;
|
92 |
|
|
IncNEventsProcessed();
|
93 |
|
|
OnAccepted();
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
//--------------------------------------------------------------------------------------------------
|
97 |
|
|
void MCProcessSelectionMod::SlaveBegin()
|
98 |
|
|
{
|
99 |
|
|
|
100 |
|
|
if (! (fDefaultAccept && fExcludedProcessIds.size()==0) )
|
101 |
|
|
ReqBranch(fMCEventInfoName,fMCEventInfo);
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
//--------------------------------------------------------------------------------------------------
|
105 |
|
|
void MCProcessSelectionMod::SlaveTerminate()
|
106 |
|
|
{
|
107 |
|
|
// Save number of accepted events.
|
108 |
|
|
|
109 |
|
|
SaveNEventsProcessed();
|
110 |
|
|
}
|