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.3 by loizides, Thu Oct 23 18:25:27 2008 UTC vs.
Revision 1.21 by bendavid, Sun May 15 20:40:30 2011 UTC

# Line 5 | Line 5
5   #include <TTree.h>
6   #include "MitAna/DataTree/interface/Names.h"
7   #include "MitAna/DataTree/interface/TriggerName.h"
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 15 | Line 18 | ClassImp(mithep::HLTMod)
18   HLTMod::HLTMod(const char *name, const char *title) :
19    BaseMod(name,title),
20    fAbort(kTRUE),
21 +  fPrintTable(kFALSE),
22 +  fIgnoreBits(kFALSE),
23 +  fObjMode(kHlt),
24    fBitsName(Names::gkHltBitBrn),
25 <  fMyObjsNamePub(Form("%sObjsadafafa", name)),
25 >  fMyObjsNamePub(Form("%sTrigObjs", name)),
26    fBits(0),
27    fMyTrgObjs(0),
28    fTriggers(0),
29    fTrigObjs(0),
30    fNEvents(0),
31 <  fNAcceped(0),
31 >  fNAccepted(0),
32    fNFailed(0)
33   {
34    // Constructor.
# Line 35 | 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 43 | 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.AddCopy(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   //--------------------------------------------------------------------------------------------------
# Line 51 | Line 58 | void HLTMod::AddTrigObjs(UInt_t tid)
58   {
59    // Add trigger objects corresponding to trigger id.
60  
61 <  const BitMask256 &ba = fTrigBitsAnd.Ref(tid);
62 <  const BitMask256 &bm = fTrigBitsCmp.Ref(tid);
61 >  const BitMask1024 &ba = fTrigBitsAnd.at(tid);
62 >  const BitMask1024 &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
# Line 62 | Line 69 | void HLTMod::AddTrigObjs(UInt_t tid)
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   }
# Line 72 | Line 89 | void HLTMod::BeginRun()
89   {
90    // Get HLT tree and set branches. Compute bitmasks to be used when comparing to the HLT bits.
91  
92 <  fTrigBitsAnd.Reset();
93 <  fTrigBitsCmp.Reset();
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 +    // implement run dependence of the triggers
108 +    if ( (!(firstRun==0 && lastRun==0)) &&
109 +         ( runNumber<firstRun || runNumber>lastRun ) )
110 +      continue;
111 +    
112 +    BitMask1024 tmask; //trigger mask
113 +    BitMask1024 amask; //bitand mask
114 +    TString names(fTrigNames.at(i).first.c_str());
115  
81  for (UInt_t i=0; i<fTrigNames.Entries(); ++i) {
82    BitMask256 tmask; //trigger mask
83    BitMask256 amask; //bitand mask
84    TString names(fTrigNames.At(i)->c_str());
116      TObjArray *arr = names.Tokenize("&");
117      if (arr) {
118        for(Int_t j=0; j<arr->GetEntries(); j++){
# Line 96 | Line 127 | void HLTMod::BeginRun()
127          }
128          const TriggerName *tn = fTriggers->Get(sptr);
129          if (!tn) {
130 <          Warning("BeginRun", "Trigger %s not found.", tn->Name());
130 >          Warning("BeginRun", "Trigger %s not found.", sptr);
131            continue;
132          }
133 +
134          UShort_t bit = tn->Id();
135 <        amask.SetBit(bit); //always set and-mask bit
136 <        if (!invert)
137 <          tmask.SetBit(bit); //set trigger bit
135 >        if (amask.TestBit(bit)) {
136 >          if (tmask.TestBit(bit)==invert) {
137 >            amask.ClearBit(bit);
138 >            tmask.ClearBit(bit);
139 >            Warning("BeginRun", "Trigger expression %s always false.", names.Data());
140 >            break;
141 >          }
142 >        } else { //always set and-mask bit
143 >          amask.SetBit(bit);
144 >          if (!invert)
145 >            tmask.SetBit(bit); //set trigger bit
146 >        }
147        }
148        delete arr;
149      }
150 <    fTrigBitsAnd.AddCopy(amask);
151 <    fTrigBitsCmp.AddCopy(tmask);
150 >    if (amask.NBitsSet()) {
151 >      fTrigBitsAnd.push_back(amask);
152 >      fTrigBitsCmp.push_back(tmask);
153 >    }
154    }
155   }
156  
# Line 119 | Line 162 | void HLTMod::Process()
162    // in a derived class, call it. Do not stop processing this event, if fAbort is kFALSE.
163  
164    ++fNEvents;
165 <  LoadBranch(fBitsName.Data());
165 >  LoadBranch(fBitsName);
166  
167    // match trigger bits to trigger mask and obtain trigger objects
168    fMyTrgObjs = new TriggerObjectOArr(0,fMyObjsNamePub);
169    fMyTrgObjs->SetOwner(kFALSE); // the objects are owned by the object table
170    fBitsDone.Clear();
171    Bool_t accept = kFALSE;
172 <  for (UInt_t i = 0; i<fTrigBitsAnd.Entries(); ++i) {
173 <    BitMask256 bitmask(*fBits);
174 <    bitmask &= fTrigBitsAnd.Ref(i);
175 <    if (bitmask==fTrigBitsCmp.Ref(i)) {
172 >  for (UInt_t i = 0; i<fTrigBitsAnd.size(); ++i) {
173 >    BitMask1024 bitmask(fBits->Get());
174 >    bitmask &= fTrigBitsAnd.at(i);
175 >    if (bitmask==fTrigBitsCmp.at(i)) {
176        accept = kTRUE;
177        AddTrigObjs(i);
178      }
# Line 147 | Line 190 | void HLTMod::Process()
190    }
191  
192    // take action if accepted
193 <  ++fNAcceped;
193 >  ++fNAccepted;
194 >  IncNEventsProcessed();
195    OnAccepted();
196    if (!AddObjThisEvt(fMyTrgObjs)) {
197      SendError(kAbortAnalysis, "Process",
# Line 163 | Line 207 | void HLTMod::SlaveBegin()
207   {
208    // Request trigger bit branch and obtain trigger table and objects.
209  
210 <  ReqBranch(fBitsName.Data(), fBits);
210 >  ReqBranch(fBitsName, fBits);
211    
212    fTriggers = GetHLTTable();
213    if (!fTriggers) {
# Line 176 | Line 220 | void HLTMod::SlaveBegin()
220      return;
221    }
222   }
223 +
224 + //--------------------------------------------------------------------------------------------------
225 + void HLTMod::SlaveTerminate()
226 + {
227 +  // Save number of accepted events.
228 +
229 +  printf(" %s - Accepted events: %d (/%d)\n",GetName(),fNAccepted,fNEvents);
230 +  SaveNEventsProcessed("hDHLTEvents");
231 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines