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.13 by loizides, Mon Jul 13 13:45:30 2009 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),
# 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 >  fTrigNames.push_back(tname);
53   }
54  
55   //--------------------------------------------------------------------------------------------------
# Line 51 | Line 57 | void HLTMod::AddTrigObjs(UInt_t tid)
57   {
58    // Add trigger objects corresponding to trigger id.
59  
60 <  const BitMask256 &ba = fTrigBitsAnd.Ref(tid);
61 <  const BitMask256 &bm = fTrigBitsCmp.Ref(tid);
60 >  const BitMask256 &ba = fTrigBitsAnd.at(tid);
61 >  const BitMask256 &bm = fTrigBitsCmp.at(tid);
62    for (UInt_t i=0; i<bm.Size(); ++i) {
63 <    if (ba.TestBit(i)==0)
63 >    if (ba.TestBit(i)==0 && !fIgnoreBits)
64        continue; // not an active trigger bit
65      if (fBitsDone.TestBit(i))
66        continue; // objects for this bit are already obtained
# Line 62 | Line 68 | void HLTMod::AddTrigObjs(UInt_t tid)
68        continue; // excluded trigger bit (ie a !trgname)
69  
70      const TList *list = fTrigObjs->GetList(i);
71 <    fMyTrgObjs->Add(list);    
71 >
72 >    TIter iter(list->MakeIterator());
73 >    const TriggerObject *to = dynamic_cast<const TriggerObject*>(iter.Next());
74 >    while (to) {
75 >      if ( (fObjMode == kAll) ||
76 >           ((fObjMode==kHlt) && (to->IsHLT())) ||
77 >           ((fObjMode==kL1) && (to->IsL1())) )
78 >        fMyTrgObjs->Add(to);    
79 >      to = dynamic_cast<const TriggerObject*>(iter.Next());
80 >    }
81      fBitsDone.SetBit(i);
82    }
83   }
# Line 72 | Line 87 | void HLTMod::BeginRun()
87   {
88    // Get HLT tree and set branches. Compute bitmasks to be used when comparing to the HLT bits.
89  
90 <  fTrigBitsAnd.Reset();
91 <  fTrigBitsCmp.Reset();
90 >  fTrigBitsAnd.clear();
91 >  fTrigBitsCmp.clear();
92  
93    if (fPrintTable)
94      fTriggers->Print();
95  
96 <  for (UInt_t i=0; i<fTrigNames.Entries(); ++i) {
96 >  for (UInt_t i=0; i<fTrigNames.size(); ++i) {
97      BitMask256 tmask; //trigger mask
98      BitMask256 amask; //bitand mask
99 <    TString names(fTrigNames.At(i)->c_str());
99 >    TString names(fTrigNames.at(i).c_str());
100 >
101      TObjArray *arr = names.Tokenize("&");
102      if (arr) {
103        for(Int_t j=0; j<arr->GetEntries(); j++){
# Line 96 | Line 112 | void HLTMod::BeginRun()
112          }
113          const TriggerName *tn = fTriggers->Get(sptr);
114          if (!tn) {
115 <          Warning("BeginRun", "Trigger %s not found.", tn->Name());
115 >          Warning("BeginRun", "Trigger %s not found.", sptr);
116            continue;
117          }
118          UShort_t bit = tn->Id();
# Line 106 | Line 122 | void HLTMod::BeginRun()
122        }
123        delete arr;
124      }
125 <    fTrigBitsAnd.AddCopy(amask);
126 <    fTrigBitsCmp.AddCopy(tmask);
125 >    fTrigBitsAnd.push_back(amask);
126 >    fTrigBitsCmp.push_back(tmask);
127    }
128   }
129  
# Line 119 | Line 135 | void HLTMod::Process()
135    // in a derived class, call it. Do not stop processing this event, if fAbort is kFALSE.
136  
137    ++fNEvents;
138 <  LoadBranch(fBitsName.Data());
138 >  LoadBranch(fBitsName);
139  
140    // match trigger bits to trigger mask and obtain trigger objects
141    fMyTrgObjs = new TriggerObjectOArr(0,fMyObjsNamePub);
142    fMyTrgObjs->SetOwner(kFALSE); // the objects are owned by the object table
143    fBitsDone.Clear();
144    Bool_t accept = kFALSE;
145 <  for (UInt_t i = 0; i<fTrigBitsAnd.Entries(); ++i) {
146 <    BitMask256 bitmask(*fBits);
147 <    bitmask &= fTrigBitsAnd.Ref(i);
148 <    if (bitmask==fTrigBitsCmp.Ref(i)) {
145 >  for (UInt_t i = 0; i<fTrigBitsAnd.size(); ++i) {
146 >    BitMask256 bitmask(fBits->Get());
147 >    bitmask &= fTrigBitsAnd.at(i);
148 >    if (bitmask==fTrigBitsCmp.at(i)) {
149        accept = kTRUE;
150        AddTrigObjs(i);
151      }
# Line 148 | Line 164 | void HLTMod::Process()
164  
165    // take action if accepted
166    ++fNAcceped;
167 +  IncNEventsProcessed();
168    OnAccepted();
169    if (!AddObjThisEvt(fMyTrgObjs)) {
170      SendError(kAbortAnalysis, "Process",
# Line 163 | Line 180 | void HLTMod::SlaveBegin()
180   {
181    // Request trigger bit branch and obtain trigger table and objects.
182  
183 <  ReqBranch(fBitsName.Data(), fBits);
183 >  ReqBranch(fBitsName, fBits);
184    
185    fTriggers = GetHLTTable();
186    if (!fTriggers) {
# Line 176 | Line 193 | void HLTMod::SlaveBegin()
193      return;
194    }
195   }
196 +
197 + //--------------------------------------------------------------------------------------------------
198 + void HLTMod::SlaveTerminate()
199 + {
200 +  // Save number of accepted events.
201 +
202 +  SaveNEventsProcessed("hDHLTEvents");
203 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines