ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/src/MCProcessSelectionMod.cc
Revision: 1.2
Committed: Tue Apr 12 15:18:28 2011 UTC (14 years ago) by bendavid
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, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, HEAD
Branch point for: Mit_025c_branch
Changes since 1.1: +6 -1 lines
Log Message:
add process id histogram

File Contents

# Content
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 hProcessId(0)
23 {
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 hProcessId->Fill(processid);
58
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 hProcessId = new TH1F("hProcessId","hProcessId",501,-0.5,500.5);
103 AddOutput(hProcessId);
104
105 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 }