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