8 |
|
#include "MitAna/DataTree/interface/TriggerMask.h" |
9 |
|
#include "MitAna/DataTree/interface/TriggerObject.h" |
10 |
|
#include "MitAna/DataTree/interface/TriggerObjectCol.h" |
11 |
+ |
#include "MitAna/DataTree/interface/TriggerObjectsTable.h" |
12 |
|
|
13 |
|
using namespace mithep; |
14 |
|
|
19 |
|
BaseMod(name,title), |
20 |
|
fAbort(kTRUE), |
21 |
|
fPrintTable(kFALSE), |
22 |
+ |
fIgnoreBits(kFALSE), |
23 |
+ |
fObjMode(kHlt), |
24 |
|
fBitsName(Names::gkHltBitBrn), |
25 |
|
fMyObjsNamePub(Form("%sTrigObjs", name)), |
26 |
|
fBits(0), |
41 |
|
} |
42 |
|
|
43 |
|
//-------------------------------------------------------------------------------------------------- |
44 |
< |
void HLTMod::AddTrigger(const char *expr) |
44 |
> |
void HLTMod::AddTrigger(const char *expr, UInt_t firstRun, UInt_t lastRun) |
45 |
|
{ |
46 |
|
// Add trigger search pattern to the list of patters. Each element of the list is logically |
47 |
|
// "ored". The given expression can contain several trigger names logically "anded" (using "&"). |
49 |
|
// "A", "!A", "A&B", "A&!B" or "A&B&C" |
50 |
|
|
51 |
|
string tname(expr); |
52 |
< |
fTrigNames.push_back(tname); |
52 |
> |
std::pair<std::string,std::pair<UInt_t,UInt_t> > element(tname,std::pair<UInt_t,UInt_t>(firstRun,lastRun)); |
53 |
> |
fTrigNames.push_back(element); |
54 |
|
} |
55 |
|
|
56 |
|
//-------------------------------------------------------------------------------------------------- |
61 |
|
const BitMask256 &ba = fTrigBitsAnd.at(tid); |
62 |
|
const BitMask256 &bm = fTrigBitsCmp.at(tid); |
63 |
|
for (UInt_t i=0; i<bm.Size(); ++i) { |
64 |
< |
if (ba.TestBit(i)==0) |
64 |
> |
if (ba.TestBit(i)==0 && !fIgnoreBits) |
65 |
|
continue; // not an active trigger bit |
66 |
|
if (fBitsDone.TestBit(i)) |
67 |
|
continue; // objects for this bit are already obtained |
69 |
|
continue; // excluded trigger bit (ie a !trgname) |
70 |
|
|
71 |
|
const TList *list = fTrigObjs->GetList(i); |
72 |
< |
fMyTrgObjs->Add(list); |
72 |
> |
if (list) { |
73 |
> |
TIter iter(list->MakeIterator()); |
74 |
> |
const TriggerObject *to = dynamic_cast<const TriggerObject*>(iter.Next()); |
75 |
> |
while (to) { |
76 |
> |
if ( (fObjMode == kAll) || |
77 |
> |
((fObjMode==kHlt) && (to->IsHLT())) || |
78 |
> |
((fObjMode==kL1) && (to->IsL1())) ) |
79 |
> |
fMyTrgObjs->Add(to); |
80 |
> |
to = dynamic_cast<const TriggerObject*>(iter.Next()); |
81 |
> |
} |
82 |
> |
} |
83 |
|
fBitsDone.SetBit(i); |
84 |
|
} |
85 |
|
} |
92 |
|
fTrigBitsAnd.clear(); |
93 |
|
fTrigBitsCmp.clear(); |
94 |
|
|
95 |
< |
if (fPrintTable) |
95 |
> |
if (fPrintTable) { |
96 |
> |
Info("BeginRun", "Get trigger table for run %d", GetEventHeader()->RunNum()); |
97 |
|
fTriggers->Print(); |
98 |
+ |
} |
99 |
+ |
|
100 |
+ |
UInt_t runNumber = GetEventHeader()->RunNum(); |
101 |
|
|
102 |
|
for (UInt_t i=0; i<fTrigNames.size(); ++i) { |
103 |
+ |
|
104 |
+ |
UInt_t firstRun = fTrigNames.at(i).second.first; |
105 |
+ |
UInt_t lastRun = fTrigNames.at(i).second.second; |
106 |
+ |
|
107 |
+ |
if ( (!(firstRun==0 && lastRun==0)) && ( runNumber<firstRun || runNumber>lastRun ) ) continue; |
108 |
+ |
|
109 |
|
BitMask256 tmask; //trigger mask |
110 |
|
BitMask256 amask; //bitand mask |
111 |
< |
TString names(fTrigNames.at(i).c_str()); |
111 |
> |
TString names(fTrigNames.at(i).first.c_str()); |
112 |
|
|
113 |
|
TObjArray *arr = names.Tokenize("&"); |
114 |
|
if (arr) { |
127 |
|
Warning("BeginRun", "Trigger %s not found.", sptr); |
128 |
|
continue; |
129 |
|
} |
130 |
+ |
|
131 |
|
UShort_t bit = tn->Id(); |
132 |
< |
amask.SetBit(bit); //always set and-mask bit |
133 |
< |
if (!invert) |
134 |
< |
tmask.SetBit(bit); //set trigger bit |
132 |
> |
if (amask.TestBit(bit)) { |
133 |
> |
if (tmask.TestBit(bit)==invert) { |
134 |
> |
amask.ClearBit(bit); |
135 |
> |
tmask.ClearBit(bit); |
136 |
> |
Warning("BeginRun", "Trigger expression %s always false.", names.Data()); |
137 |
> |
break; |
138 |
> |
} |
139 |
> |
} else { //always set and-mask bit |
140 |
> |
amask.SetBit(bit); |
141 |
> |
if (!invert) |
142 |
> |
tmask.SetBit(bit); //set trigger bit |
143 |
> |
} |
144 |
|
} |
145 |
|
delete arr; |
146 |
|
} |
147 |
< |
fTrigBitsAnd.push_back(amask); |
148 |
< |
fTrigBitsCmp.push_back(tmask); |
147 |
> |
if (amask.NBitsSet()) { |
148 |
> |
fTrigBitsAnd.push_back(amask); |
149 |
> |
fTrigBitsCmp.push_back(tmask); |
150 |
> |
} |
151 |
|
} |
152 |
|
} |
153 |
|
|