Revision: | 1.1 |
Committed: | Mon Jan 18 14:35:43 2010 UTC (15 years, 3 months 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, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, HEAD |
Branch point for: | Mit_025c_branch |
Log Message: | Add RunSelectionMod |
# | User | Rev | Content |
---|---|---|---|
1 | bendavid | 1.1 | // $Id: RunSelectionMod.cc,v 1.4 2009/12/02 20:27:42 loizides Exp $ |
2 | |||
3 | #include "MitAna/PhysicsMod/interface/RunSelectionMod.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::RunSelectionMod) | ||
11 | |||
12 | //-------------------------------------------------------------------------------------------------- | ||
13 | RunSelectionMod::RunSelectionMod(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 | RunSelectionMod::~RunSelectionMod() | ||
27 | { | ||
28 | // Destructor. | ||
29 | } | ||
30 | |||
31 | |||
32 | //-------------------------------------------------------------------------------------------------- | ||
33 | void RunSelectionMod::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 RunSelectionMod::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 RunSelectionMod::SlaveBegin() | ||
86 | { | ||
87 | |||
88 | } | ||
89 | |||
90 | //-------------------------------------------------------------------------------------------------- | ||
91 | void RunSelectionMod::SlaveTerminate() | ||
92 | { | ||
93 | // Save number of accepted events. | ||
94 | |||
95 | SaveNEventsProcessed(); | ||
96 | } |