ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/HLTMod.cc
(Generate patch)

Comparing UserCode/MitAna/TreeMod/src/HLTMod.cc (file contents):
Revision 1.11 by loizides, Mon Jun 15 15:00:17 2009 UTC vs.
Revision 1.23 by paus, Wed Mar 28 12:15:38 2012 UTC

# Line 8 | Line 8
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  
# Line 18 | Line 19 | HLTMod::HLTMod(const char *name, const c
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),
# Line 25 | Line 28 | HLTMod::HLTMod(const char *name, const c
28    fTriggers(0),
29    fTrigObjs(0),
30    fNEvents(0),
31 <  fNAcceped(0),
31 >  fNAccepted(0),
32    fNFailed(0)
33   {
34    // Constructor.
# Line 38 | Line 41 | HLTMod::~HLTMod()
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 "&").
# Line 46 | Line 49 | void HLTMod::AddTrigger(const char *expr
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> >
53 >    element(tname,std::pair<UInt_t,UInt_t>(firstRun,lastRun));
54 >  fTrigNames.push_back(element);
55   }
56  
57   //--------------------------------------------------------------------------------------------------
# Line 54 | Line 59 | void HLTMod::AddTrigObjs(UInt_t tid)
59   {
60    // Add trigger objects corresponding to trigger id.
61  
62 <  const BitMask256 &ba = fTrigBitsAnd.at(tid);
63 <  const BitMask256 &bm = fTrigBitsCmp.at(tid);
62 >  const BitMask1024 &ba = fTrigBitsAnd.at(tid);
63 >  const BitMask1024 &bm = fTrigBitsCmp.at(tid);
64    for (UInt_t i=0; i<bm.Size(); ++i) {
65 <    if (ba.TestBit(i)==0)
65 >    if (ba.TestBit(i)==0 && !fIgnoreBits)
66        continue; // not an active trigger bit
67      if (fBitsDone.TestBit(i))
68        continue; // objects for this bit are already obtained
# Line 65 | Line 70 | void HLTMod::AddTrigObjs(UInt_t tid)
70        continue; // excluded trigger bit (ie a !trgname)
71  
72      const TList *list = fTrigObjs->GetList(i);
73 <    fMyTrgObjs->Add(list);    
73 >    if (list) {
74 >      TIter iter(list->MakeIterator());
75 >      const TriggerObject *to = dynamic_cast<const TriggerObject*>(iter.Next());
76 >      while (to) {
77 >        if ( (fObjMode == kAll)  ||
78 >             ((fObjMode == kHlt) && (to->IsHLT())) ||
79 >             ((fObjMode == kL1)  && (to->IsL1())) )
80 >          fMyTrgObjs->Add(to);    
81 >        to = dynamic_cast<const TriggerObject*>(iter.Next());
82 >      }
83 >    }
84      fBitsDone.SetBit(i);
85    }
86   }
# Line 78 | Line 93 | void HLTMod::BeginRun()
93    fTrigBitsAnd.clear();
94    fTrigBitsCmp.clear();
95  
96 <  if (fPrintTable)
96 >  if (fPrintTable) {
97 >    Info("BeginRun", "Get trigger table for run %d", GetEventHeader()->RunNum());
98 >    printf(" Trigger table for run %d:\n",GetEventHeader()->RunNum());
99      fTriggers->Print();
100 +  }
101 +  
102 +  UInt_t runNumber = GetEventHeader()->RunNum();
103  
104    for (UInt_t i=0; i<fTrigNames.size(); ++i) {
105 <    BitMask256 tmask; //trigger mask
106 <    BitMask256 amask; //bitand mask
107 <    TString names(fTrigNames.at(i).c_str());
105 >    
106 >    UInt_t firstRun = fTrigNames.at(i).second.first;
107 >    UInt_t lastRun  = fTrigNames.at(i).second.second;
108 >    
109 >    // implement run dependence of the triggers
110 >    if ( (!(firstRun==0 && lastRun==0)) &&
111 >         ( runNumber<firstRun || runNumber>lastRun ) )
112 >      continue;
113 >    
114 >    BitMask1024 tmask; //trigger mask
115 >    BitMask1024 amask; //bitand mask
116 >    TString names(fTrigNames.at(i).first.c_str());
117  
118      TObjArray *arr = names.Tokenize("&");
119      if (arr) {
# Line 92 | Line 121 | void HLTMod::BeginRun()
121          TObjString *s = dynamic_cast<TObjString*>(arr->At(j));
122          if (!s)
123            continue;
124 <        const char *sptr = s->GetString().Data();
124 >        TString st = s->GetString();
125 >        bool wildcard = false;
126 >        if (st.EndsWith("*")) {
127 >          st.ReplaceAll("*","");
128 >          wildcard = true;
129 >        }
130 >        const char *sptr = st.Data();
131          Bool_t invert = kFALSE;
132          if (sptr[0] == '!') {
133            invert = kTRUE; //inverted bit set
134            ++sptr;
135          }
136 <        const TriggerName *tn = fTriggers->Get(sptr);
136 >        const TriggerName *tn = 0;
137 >        if (wildcard) {
138 >          tn = fTriggers->GetWildcard(sptr);
139 >        }
140 >        else {
141 >          tn = fTriggers->Get(sptr);
142 >        }
143          if (!tn) {
144            Warning("BeginRun", "Trigger %s not found.", sptr);
145            continue;
146          }
147 +
148          UShort_t bit = tn->Id();
149 <        amask.SetBit(bit); //always set and-mask bit
150 <        if (!invert)
151 <          tmask.SetBit(bit); //set trigger bit
149 >        if (amask.TestBit(bit)) {
150 >          if (tmask.TestBit(bit)==invert) {
151 >            amask.ClearBit(bit);
152 >            tmask.ClearBit(bit);
153 >            Warning("BeginRun", "Trigger expression %s always false.", names.Data());
154 >            break;
155 >          }
156 >        } else { //always set and-mask bit
157 >          amask.SetBit(bit);
158 >          if (!invert)
159 >            tmask.SetBit(bit); //set trigger bit
160 >        }
161        }
162        delete arr;
163      }
164 <    fTrigBitsAnd.push_back(amask);
165 <    fTrigBitsCmp.push_back(tmask);
164 >    if (amask.NBitsSet()) {
165 >      fTrigBitsAnd.push_back(amask);
166 >      fTrigBitsCmp.push_back(tmask);
167 >    }
168    }
169   }
170  
# Line 131 | Line 184 | void HLTMod::Process()
184    fBitsDone.Clear();
185    Bool_t accept = kFALSE;
186    for (UInt_t i = 0; i<fTrigBitsAnd.size(); ++i) {
187 <    BitMask256 bitmask(fBits->Get());
187 >    BitMask1024 bitmask(fBits->Get());
188      bitmask &= fTrigBitsAnd.at(i);
189      if (bitmask==fTrigBitsCmp.at(i)) {
190        accept = kTRUE;
# Line 151 | Line 204 | void HLTMod::Process()
204    }
205  
206    // take action if accepted
207 <  ++fNAcceped;
207 >  ++fNAccepted;
208    IncNEventsProcessed();
209    OnAccepted();
210    if (!AddObjThisEvt(fMyTrgObjs)) {
# Line 187 | Line 240 | void HLTMod::SlaveTerminate()
240   {
241    // Save number of accepted events.
242  
243 +  printf(" %s - Accepted events: %d (/%d)\n",GetName(),fNAccepted,fNEvents);
244    SaveNEventsProcessed("hDHLTEvents");
245   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines