1 |
loizides |
1.37 |
// $Id: FillerMetaInfos.cc,v 1.36 2009/07/09 10:57:56 loizides Exp $
|
2 |
loizides |
1.1 |
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerMetaInfos.h"
|
4 |
loizides |
1.5 |
#include "FWCore/Framework/interface/TriggerNames.h"
|
5 |
loizides |
1.37 |
//#include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
|
6 |
|
|
//#include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
|
7 |
|
|
//#include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
|
8 |
loizides |
1.1 |
#include "DataFormats/Common/interface/Handle.h"
|
9 |
loizides |
1.37 |
//#include "FWCore/Framework/interface/ESHandle.h"
|
10 |
loizides |
1.5 |
#include "DataFormats/Common/interface/TriggerResults.h"
|
11 |
loizides |
1.37 |
//#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
|
12 |
loizides |
1.14 |
#include "DataFormats/HLTReco/interface/TriggerEvent.h"
|
13 |
loizides |
1.1 |
#include "MitAna/DataTree/interface/Names.h"
|
14 |
loizides |
1.5 |
#include "MitAna/DataTree/interface/EventHeader.h"
|
15 |
|
|
#include "MitAna/DataTree/interface/LAHeader.h"
|
16 |
loizides |
1.25 |
#include "MitAna/DataTree/interface/TriggerMask.h"
|
17 |
loizides |
1.16 |
#include "MitAna/DataTree/interface/TriggerName.h"
|
18 |
loizides |
1.5 |
#include "MitAna/DataTree/interface/RunInfo.h"
|
19 |
loizides |
1.34 |
#include "MitAna/DataTree/interface/TriggerObjectCol.h"
|
20 |
|
|
#include "MitProd/ObjectService/interface/ObjectService.h"
|
21 |
loizides |
1.8 |
#include <TObjectTable.h>
|
22 |
loizides |
1.14 |
#include <TIterator.h>
|
23 |
sixie |
1.13 |
|
24 |
loizides |
1.37 |
#if 0
|
25 |
|
|
#include "DataFormats/L1Trigger/interface/L1HFRingsFwd.h"
|
26 |
|
|
#include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h"
|
27 |
|
|
#include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
|
28 |
|
|
#include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"
|
29 |
|
|
#include "DataFormats/L1Trigger/interface/L1EtMissParticleFwd.h"
|
30 |
|
|
#include "DataFormats/L1Trigger/interface/L1HFRings.h"
|
31 |
|
|
#include "DataFormats/L1Trigger/interface/L1EmParticle.h"
|
32 |
|
|
#include "DataFormats/L1Trigger/interface/L1JetParticle.h"
|
33 |
|
|
#include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
|
34 |
|
|
#include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
|
35 |
|
|
#endif
|
36 |
|
|
|
37 |
loizides |
1.1 |
using namespace std;
|
38 |
|
|
using namespace edm;
|
39 |
|
|
using namespace mithep;
|
40 |
|
|
|
41 |
loizides |
1.12 |
bool mithep::FillerMetaInfos::instance_ = 0;
|
42 |
|
|
|
43 |
loizides |
1.8 |
//--------------------------------------------------------------------------------------------------
|
44 |
loizides |
1.26 |
FillerMetaInfos::FillerMetaInfos(const ParameterSet &cfg, const char *name, bool active) :
|
45 |
|
|
BaseFiller(cfg,name,(instance_==0||active?1:0)),
|
46 |
loizides |
1.30 |
evtName_(Conf().getUntrackedParameter<string>("evtMitName",Names::gkEvtHeaderBrn)),
|
47 |
|
|
runName_(Conf().getUntrackedParameter<string>("runMitName",Names::gkRunInfoBrn)),
|
48 |
|
|
lahName_(Conf().getUntrackedParameter<string>("lahMitName",Names::gkLAHeaderBrn)),
|
49 |
loizides |
1.37 |
// l1Active_(Conf().getUntrackedParameter<bool>("l1Active",true)),
|
50 |
|
|
// l1TableName_(Conf().getUntrackedParameter<string>("l1MitTableName",Names::gkL1TableBrn)),
|
51 |
|
|
// l1BitsName_(Conf().getUntrackedParameter<string>("l1MitBitsName",Names::gkL1BitBrn)),
|
52 |
|
|
// l1ObjsName_(Conf().getUntrackedParameter<string>("l1MitObjsName",Names::gkL1ObjBrn)),
|
53 |
loizides |
1.16 |
hltActive_(Conf().getUntrackedParameter<bool>("hltActive",true)),
|
54 |
loizides |
1.33 |
hltResName_(Conf().getUntrackedParameter<string>("hltResEdmName","TriggerResults")),
|
55 |
|
|
hltEvtName_(Conf().getUntrackedParameter<string>("hltEvtEdmName","hltTriggerSummaryAOD")),
|
56 |
loizides |
1.30 |
hltTableName_(Conf().getUntrackedParameter<string>("hltTableMitName",Names::gkHltTableBrn)),
|
57 |
|
|
hltLabelName_(Conf().getUntrackedParameter<string>("hltLabelMitName",Names::gkHltLabelBrn)),
|
58 |
|
|
hltBitsName_(Conf().getUntrackedParameter<string>("hltBitsMitName",Names::gkHltBitBrn)),
|
59 |
|
|
hltObjsName_(Conf().getUntrackedParameter<string>("hltObjsMitName",Names::gkHltObjBrn)),
|
60 |
loizides |
1.5 |
tws_(0),
|
61 |
loizides |
1.2 |
eventHeader_(new EventHeader()),
|
62 |
loizides |
1.3 |
evtLAHeader_(new LAHeader()),
|
63 |
loizides |
1.2 |
runInfo_(new RunInfo()),
|
64 |
|
|
runTree_(0),
|
65 |
loizides |
1.3 |
laTree_(0),
|
66 |
|
|
runEntries_(0),
|
67 |
loizides |
1.37 |
// l1Entries_(0),
|
68 |
|
|
// l1Table_(0),
|
69 |
|
|
// l1Tree_(0),
|
70 |
loizides |
1.25 |
hltBits_(new TriggerMask),
|
71 |
loizides |
1.22 |
hltTable_(new vector<string>),
|
72 |
loizides |
1.16 |
hltTabMap_(0),
|
73 |
loizides |
1.22 |
hltLabels_(new vector<string>),
|
74 |
loizides |
1.16 |
hltLabMap_(0),
|
75 |
|
|
hltObjs_(new TriggerObjectBaseArr),
|
76 |
|
|
hltRels_(new TriggerObjectRelArr),
|
77 |
|
|
hltTree_(0),
|
78 |
|
|
hltEntries_(0),
|
79 |
loizides |
1.3 |
fileNum_(0)
|
80 |
loizides |
1.1 |
{
|
81 |
loizides |
1.3 |
// Constructor.
|
82 |
loizides |
1.12 |
|
83 |
loizides |
1.37 |
instance_=1; //todo test if already 1..
|
84 |
loizides |
1.33 |
|
85 |
|
|
if (Conf().exists("hltProcNames"))
|
86 |
|
|
hltProcNames_ = Conf().getUntrackedParameter<vector<string> >("hltProcNames");
|
87 |
|
|
if (hltProcNames_.size()==0)
|
88 |
|
|
hltProcNames_.push_back("HLT");
|
89 |
loizides |
1.1 |
}
|
90 |
|
|
|
91 |
loizides |
1.8 |
//--------------------------------------------------------------------------------------------------
|
92 |
loizides |
1.1 |
FillerMetaInfos::~FillerMetaInfos()
|
93 |
|
|
{
|
94 |
loizides |
1.3 |
// Destructor.
|
95 |
|
|
|
96 |
loizides |
1.2 |
delete eventHeader_;
|
97 |
loizides |
1.8 |
delete evtLAHeader_;
|
98 |
loizides |
1.2 |
delete runInfo_;
|
99 |
loizides |
1.37 |
// delete l1Table_;
|
100 |
|
|
delete hltBits_;
|
101 |
loizides |
1.16 |
delete hltTable_;
|
102 |
|
|
delete hltLabels_;
|
103 |
|
|
delete hltObjs_;
|
104 |
|
|
delete hltRels_;
|
105 |
loizides |
1.3 |
eventHeader_ = 0;
|
106 |
loizides |
1.8 |
evtLAHeader_ = 0;
|
107 |
loizides |
1.3 |
runInfo_ = 0;
|
108 |
loizides |
1.37 |
// l1Table_ = 0;
|
109 |
loizides |
1.16 |
hltTable_ = 0;
|
110 |
|
|
hltLabels_ = 0;
|
111 |
|
|
hltObjs_ = 0;
|
112 |
|
|
hltRels_ = 0;
|
113 |
loizides |
1.3 |
runTree_ = 0;
|
114 |
|
|
laTree_ = 0;
|
115 |
loizides |
1.16 |
hltTree_ = 0;
|
116 |
loizides |
1.37 |
// l1Tree_ = 0;
|
117 |
loizides |
1.1 |
}
|
118 |
|
|
|
119 |
loizides |
1.8 |
//--------------------------------------------------------------------------------------------------
|
120 |
loizides |
1.2 |
void FillerMetaInfos::BookDataBlock(TreeWriter &tws)
|
121 |
loizides |
1.1 |
{
|
122 |
loizides |
1.30 |
// Create run info tree and book our branches.
|
123 |
loizides |
1.3 |
|
124 |
|
|
// add branches to main tree
|
125 |
loizides |
1.27 |
tws.AddBranch(evtName_,&eventHeader_);
|
126 |
|
|
OS()->add<mithep::EventHeader>(eventHeader_,evtName_);
|
127 |
|
|
tws.AddBranch(hltBitsName_,&hltBits_);
|
128 |
|
|
tws.AddBranch(hltObjsName_,&hltObjs_);
|
129 |
loizides |
1.16 |
tws.AddBranch(Form("%sRelation",hltObjsName_.c_str()),&hltRels_);
|
130 |
loizides |
1.20 |
tws.GetTree()->BranchRef();
|
131 |
loizides |
1.3 |
|
132 |
|
|
// add branches to run info tree
|
133 |
loizides |
1.27 |
tws.AddBranchToTree(Names::gkRunTreeName,runName_,
|
134 |
loizides |
1.25 |
TClass::GetClass(typeid(*runInfo_))->GetName(),&runInfo_);
|
135 |
loizides |
1.2 |
tws.SetAutoFill(Names::gkRunTreeName,0);
|
136 |
|
|
runTree_=tws.GetTree(Names::gkRunTreeName);
|
137 |
loizides |
1.3 |
|
138 |
|
|
// add branches to lookahead tree
|
139 |
loizides |
1.24 |
tws.AddBranchToTree(Names::gkLATreeName,Names::gkLAHeaderBrn,
|
140 |
loizides |
1.25 |
TClass::GetClass(typeid(*evtLAHeader_))->GetName(),&runInfo_);
|
141 |
loizides |
1.3 |
tws.SetAutoFill(Names::gkLATreeName,0);
|
142 |
|
|
laTree_=tws.GetTree(Names::gkLATreeName);
|
143 |
|
|
|
144 |
loizides |
1.16 |
// add branches to HLT trigger info tree
|
145 |
loizides |
1.27 |
tws.AddBranchToTree(Names::gkHltTreeName,hltTableName_,
|
146 |
loizides |
1.29 |
TClass::GetClass(typeid(*hltTable_))->GetName(),&hltTable_,32*1024,0);
|
147 |
loizides |
1.27 |
tws.AddBranchToTree(Names::gkHltTreeName,hltLabelName_,
|
148 |
loizides |
1.29 |
TClass::GetClass(typeid(*hltLabels_))->GetName(),&hltLabels_,32*1024,0);
|
149 |
loizides |
1.16 |
tws.SetAutoFill(Names::gkHltTreeName,0);
|
150 |
|
|
hltTree_=tws.GetTree(Names::gkHltTreeName);
|
151 |
|
|
|
152 |
loizides |
1.3 |
// store pointer to tree writer
|
153 |
|
|
tws_ = &tws;
|
154 |
loizides |
1.1 |
}
|
155 |
|
|
|
156 |
loizides |
1.8 |
//--------------------------------------------------------------------------------------------------
|
157 |
loizides |
1.36 |
void FillerMetaInfos::FillDataBlock(const edm::Event &event, const edm::EventSetup &setup)
|
158 |
loizides |
1.1 |
{
|
159 |
loizides |
1.3 |
// Fill our data structures.
|
160 |
|
|
|
161 |
|
|
// clear map if a new file was opened
|
162 |
|
|
if (tws_->GetFileNumber()!=fileNum_) {
|
163 |
|
|
runmap_.clear();
|
164 |
|
|
fileNum_ = tws_->GetFileNumber();
|
165 |
|
|
runEntries_ = 0;
|
166 |
loizides |
1.37 |
// l1Entries_ = -1;
|
167 |
loizides |
1.16 |
hltEntries_ = -1;
|
168 |
loizides |
1.3 |
}
|
169 |
|
|
|
170 |
|
|
UInt_t runnum = event.id().run();
|
171 |
|
|
|
172 |
|
|
// store look ahead information
|
173 |
|
|
if (runEntries_>0) {
|
174 |
|
|
evtLAHeader_->SetRunNum(runnum);
|
175 |
|
|
laTree_->Fill();
|
176 |
loizides |
1.21 |
if(0) { // check for memory leak in usage of ROOT objects
|
177 |
loizides |
1.14 |
if(laTree_->GetEntries() % 100==0)
|
178 |
|
|
gObjectTable->Print();
|
179 |
|
|
}
|
180 |
loizides |
1.3 |
}
|
181 |
|
|
|
182 |
loizides |
1.2 |
// fill event header
|
183 |
|
|
eventHeader_->SetEvtNum(event.id().event());
|
184 |
|
|
eventHeader_->SetLumiSec(event.luminosityBlock());
|
185 |
|
|
eventHeader_->SetRunNum(runnum);
|
186 |
loizides |
1.27 |
eventHeader_->SetIsMC(!event.isRealData());
|
187 |
loizides |
1.35 |
eventHeader_->SetBunchCrossing(event.bunchCrossing());
|
188 |
|
|
eventHeader_->SetExpType(event.experimentType());
|
189 |
|
|
eventHeader_->SetOrbitNumber(event.orbitNumber());
|
190 |
|
|
eventHeader_->SetStoreNumber(event.bunchCrossing());
|
191 |
|
|
eventHeader_->SetTimeStamp(event.time().value());
|
192 |
loizides |
1.2 |
|
193 |
loizides |
1.3 |
// look-up if entry is in map
|
194 |
loizides |
1.2 |
map<UInt_t,Int_t>::iterator riter = runmap_.find(runnum);
|
195 |
|
|
if (riter != runmap_.end()) {
|
196 |
|
|
Int_t runentry = riter->second;
|
197 |
|
|
eventHeader_->SetRunEntry(runentry);
|
198 |
loizides |
1.16 |
FillHltTrig(event,setup);
|
199 |
loizides |
1.2 |
return;
|
200 |
|
|
}
|
201 |
loizides |
1.1 |
|
202 |
loizides |
1.2 |
// fill new run info
|
203 |
|
|
Int_t runentry = runEntries_;
|
204 |
loizides |
1.16 |
++runEntries_;
|
205 |
loizides |
1.2 |
eventHeader_->SetRunEntry(runentry);
|
206 |
|
|
runmap_.insert(pair<UInt_t,Int_t>(runnum,runentry));
|
207 |
loizides |
1.16 |
runInfo_->SetRunNum(runnum);
|
208 |
|
|
|
209 |
loizides |
1.37 |
#if 0
|
210 |
loizides |
1.16 |
Int_t l1entry = l1Entries_;
|
211 |
loizides |
1.36 |
FillL1Info(event,setup);
|
212 |
|
|
FillL1Trig(event,setup);
|
213 |
loizides |
1.21 |
if (l1entry < l1Entries_) {
|
214 |
|
|
l1Tree_->Fill();
|
215 |
|
|
runInfo_->SetL1Entry(l1entry);
|
216 |
|
|
} else {
|
217 |
|
|
runInfo_->SetL1Entry(l1entry-1);
|
218 |
|
|
}
|
219 |
loizides |
1.37 |
#endif
|
220 |
loizides |
1.2 |
|
221 |
loizides |
1.16 |
Int_t hltentry = hltEntries_;
|
222 |
loizides |
1.14 |
FillHltInfo(event,setup);
|
223 |
loizides |
1.16 |
FillHltTrig(event,setup);
|
224 |
loizides |
1.21 |
if (hltentry < hltEntries_) {
|
225 |
|
|
runInfo_->SetHltEntry(hltentry);
|
226 |
loizides |
1.16 |
hltTree_->Fill();
|
227 |
loizides |
1.21 |
} else {
|
228 |
|
|
runInfo_->SetHltEntry(hltentry-1);
|
229 |
|
|
}
|
230 |
loizides |
1.14 |
|
231 |
loizides |
1.2 |
runTree_->Fill();
|
232 |
loizides |
1.1 |
}
|
233 |
loizides |
1.5 |
|
234 |
loizides |
1.8 |
//--------------------------------------------------------------------------------------------------
|
235 |
loizides |
1.36 |
void FillerMetaInfos::FillHltInfo(const edm::Event &event, const edm::EventSetup &setup)
|
236 |
loizides |
1.5 |
{
|
237 |
loizides |
1.16 |
// Fill HLT trigger table if it changed.
|
238 |
loizides |
1.5 |
|
239 |
loizides |
1.36 |
if (!hltActive_)
|
240 |
|
|
return;
|
241 |
loizides |
1.14 |
|
242 |
loizides |
1.21 |
// check if we can access the hlt config information
|
243 |
loizides |
1.33 |
if (hltProcName_.empty()) {
|
244 |
|
|
string teststr;
|
245 |
|
|
for(unsigned int i=0; i<hltProcNames_.size(); ++i) {
|
246 |
|
|
if (i>0)
|
247 |
|
|
teststr += ", ";
|
248 |
|
|
teststr += hltProcNames_.at(i);
|
249 |
|
|
edm::LogInfo("FillerMetaInfos") << "Trying to access hlt config using "
|
250 |
|
|
<< hltProcNames_.at(i) << std::endl;
|
251 |
|
|
|
252 |
|
|
if (hltConfig_.init(hltProcNames_.at(i))) {
|
253 |
|
|
hltProcName_ = hltProcNames_.at(i);
|
254 |
|
|
if (hltResName_.find(':')==string::npos)
|
255 |
|
|
hltResName_ += "::";
|
256 |
|
|
else
|
257 |
|
|
hltResName_ += ":";
|
258 |
|
|
hltResName_ += hltProcName_;
|
259 |
|
|
if (hltEvtName_.find(':')==string::npos)
|
260 |
|
|
hltEvtName_ += "::";
|
261 |
|
|
else
|
262 |
|
|
hltEvtName_ += ":";
|
263 |
|
|
hltEvtName_ += hltProcName_;
|
264 |
|
|
break;
|
265 |
|
|
}
|
266 |
|
|
}
|
267 |
|
|
if (hltProcName_.empty()) {
|
268 |
|
|
edm::LogError("FillerMetaInfos") << "Cannot access hlt config using "
|
269 |
|
|
<< teststr << std::endl;
|
270 |
|
|
throw edm::Exception(edm::errors::Configuration, "FillerMetaInfos::FillHltInfo()\n")
|
271 |
|
|
<< "Cannot access hlt config using " << teststr << std::endl;
|
272 |
|
|
return;
|
273 |
|
|
}
|
274 |
|
|
} else {
|
275 |
|
|
if (!hltConfig_.init(hltProcName_)) {
|
276 |
|
|
edm::LogError("FillerMetaInfos") << "Cannot access hlt config using "
|
277 |
|
|
<< hltProcName_ << std::endl;
|
278 |
|
|
throw edm::Exception(edm::errors::Configuration, "FillerMetaInfos::FillHltInfo()\n")
|
279 |
|
|
<< "Cannot access hlt config using " << hltProcName_ << std::endl;
|
280 |
|
|
return;
|
281 |
|
|
}
|
282 |
loizides |
1.16 |
}
|
283 |
loizides |
1.14 |
|
284 |
loizides |
1.21 |
// check size of menu... < 256
|
285 |
loizides |
1.16 |
if (hltConfig_.size()>hltBits_->Size()) {
|
286 |
loizides |
1.21 |
edm::LogError("FillerMetaInfos") << "HLT config contains too many paths "
|
287 |
loizides |
1.25 |
<< hltConfig_.size() << " > "
|
288 |
|
|
<< hltBits_->Size() << std::endl;
|
289 |
loizides |
1.16 |
return;
|
290 |
|
|
}
|
291 |
loizides |
1.14 |
|
292 |
loizides |
1.22 |
vector<string> *trigtable = new vector<string>;
|
293 |
loizides |
1.16 |
map<string,Short_t> *tabmap = new map<string,Short_t>;
|
294 |
loizides |
1.22 |
vector<string> *labels = new vector<string>;
|
295 |
loizides |
1.16 |
map<string,Short_t> *labmap = new map<string,Short_t>;
|
296 |
|
|
|
297 |
loizides |
1.28 |
if (0) {
|
298 |
|
|
if (!hltConfig_.tableName().empty())
|
299 |
|
|
trigtable->push_back(hltConfig_.tableName());
|
300 |
|
|
else
|
301 |
|
|
trigtable->push_back("unknown_hlt_config");
|
302 |
|
|
}
|
303 |
|
|
|
304 |
loizides |
1.21 |
// loop over hlt paths
|
305 |
loizides |
1.16 |
for(UInt_t i=0;i<hltConfig_.size();++i) {
|
306 |
|
|
|
307 |
|
|
tabmap->insert(pair<string,Short_t>(hltConfig_.triggerName(i),i));
|
308 |
loizides |
1.22 |
trigtable->push_back(hltConfig_.triggerName(i));
|
309 |
loizides |
1.16 |
const vector<string> &mLabels(hltConfig_.moduleLabels(i));
|
310 |
|
|
for (UInt_t j=0; j<mLabels.size(); ++j) {
|
311 |
loizides |
1.19 |
|
312 |
loizides |
1.16 |
const string& label(mLabels[j]);
|
313 |
|
|
|
314 |
loizides |
1.19 |
// remove characters which do not work: negation is included as !ModuleName
|
315 |
|
|
// (this might require a change in the underlying CMSSW HLT fwk, so watch out).
|
316 |
|
|
const char *lptr = &label[0];
|
317 |
|
|
if (label[0] == '!')
|
318 |
|
|
++lptr;
|
319 |
|
|
|
320 |
|
|
map<string,Short_t>::iterator riter = labmap->find(lptr);
|
321 |
loizides |
1.16 |
if (riter == labmap->end()) {
|
322 |
loizides |
1.22 |
labmap->insert(pair<string,Short_t>(lptr,labels->size()));
|
323 |
|
|
labels->push_back(lptr);
|
324 |
loizides |
1.16 |
}
|
325 |
loizides |
1.19 |
|
326 |
|
|
const string type(hltConfig_.moduleType(lptr));
|
327 |
loizides |
1.16 |
riter = labmap->find(type);
|
328 |
|
|
if (riter == labmap->end()) {
|
329 |
loizides |
1.22 |
labmap->insert(pair<string,Short_t>(type,labels->size()));
|
330 |
|
|
labels->push_back(type);
|
331 |
loizides |
1.14 |
}
|
332 |
|
|
}
|
333 |
|
|
}
|
334 |
|
|
|
335 |
loizides |
1.22 |
if (hltTable_->size()>=0) {
|
336 |
loizides |
1.32 |
// check if existing table is equal to new table:
|
337 |
|
|
// if so keep it, otherwise store the new one
|
338 |
loizides |
1.21 |
|
339 |
loizides |
1.32 |
if ((hltTable_->size()==trigtable->size()) &&
|
340 |
|
|
(hltLabels_->size()==labels->size())) {
|
341 |
loizides |
1.21 |
|
342 |
|
|
bool newEntryFound = false;
|
343 |
loizides |
1.22 |
for (UInt_t i=0; i<trigtable->size(); ++i) {
|
344 |
loizides |
1.32 |
if (trigtable->at(i) != hltTable_->at(i)) {
|
345 |
loizides |
1.21 |
newEntryFound = true;
|
346 |
|
|
break;
|
347 |
|
|
}
|
348 |
|
|
}
|
349 |
|
|
if (!newEntryFound) {
|
350 |
loizides |
1.22 |
for (UInt_t i=0; i<labels->size(); ++i) {
|
351 |
loizides |
1.32 |
if (labels->at(i) != hltLabels_->at(i)) {
|
352 |
loizides |
1.21 |
newEntryFound = true;
|
353 |
|
|
break;
|
354 |
|
|
}
|
355 |
|
|
}
|
356 |
|
|
}
|
357 |
|
|
|
358 |
|
|
if (!newEntryFound) {
|
359 |
|
|
if (verbose_>1)
|
360 |
|
|
cout << "FillHltInfo: Kept previous HLT information" << endl;
|
361 |
|
|
|
362 |
|
|
delete trigtable;
|
363 |
|
|
delete labels;
|
364 |
|
|
delete labmap;
|
365 |
|
|
delete tabmap;
|
366 |
|
|
return;
|
367 |
|
|
}
|
368 |
loizides |
1.16 |
}
|
369 |
loizides |
1.20 |
}
|
370 |
loizides |
1.16 |
|
371 |
loizides |
1.21 |
// new hlt entry
|
372 |
loizides |
1.16 |
delete hltTable_;
|
373 |
|
|
delete hltLabels_;
|
374 |
|
|
delete hltTabMap_;
|
375 |
|
|
delete hltLabMap_;
|
376 |
|
|
hltTable_ = trigtable;
|
377 |
|
|
hltLabels_ = labels;
|
378 |
|
|
hltTabMap_ = tabmap;
|
379 |
|
|
hltLabMap_ = labmap;
|
380 |
|
|
hltEntries_++;
|
381 |
|
|
}
|
382 |
|
|
|
383 |
|
|
//--------------------------------------------------------------------------------------------------
|
384 |
loizides |
1.36 |
void FillerMetaInfos::FillHltTrig(const edm::Event &event, const edm::EventSetup &setup)
|
385 |
loizides |
1.16 |
{
|
386 |
|
|
// Fill HLT trigger objects along triggered paths.
|
387 |
|
|
|
388 |
loizides |
1.36 |
if (!hltActive_)
|
389 |
|
|
return;
|
390 |
loizides |
1.16 |
|
391 |
|
|
// reset trigger objects
|
392 |
|
|
hltObjs_->Reset();
|
393 |
|
|
hltRels_->Reset();
|
394 |
loizides |
1.14 |
|
395 |
loizides |
1.16 |
// get HLT trigger information
|
396 |
loizides |
1.14 |
Handle<TriggerResults> triggerResultsHLT;
|
397 |
loizides |
1.16 |
GetProduct(hltResName_, triggerResultsHLT, event);
|
398 |
loizides |
1.5 |
|
399 |
loizides |
1.16 |
// get HLT trigger object information
|
400 |
|
|
Handle<trigger::TriggerEvent> triggerEventHLT;
|
401 |
|
|
GetProduct(hltEvtName_, triggerEventHLT, event);
|
402 |
|
|
|
403 |
|
|
if (verify_)
|
404 |
|
|
assert(triggerResultsHLT->size()==hltConfig_.size());
|
405 |
|
|
|
406 |
loizides |
1.25 |
// new bitmask
|
407 |
loizides |
1.37 |
BitMask256 maskhlt;
|
408 |
loizides |
1.16 |
|
409 |
loizides |
1.37 |
// loop over trigger objects and fill them
|
410 |
|
|
const trigger::TriggerObjectCollection &toc(triggerEventHLT->getObjects());
|
411 |
|
|
for (trigger::size_type i=0; i<toc.size(); ++i) {
|
412 |
|
|
const trigger::TriggerObject &tobj = toc[i];
|
413 |
|
|
TriggerObjectBase *trigObj = hltObjs_->Allocate();
|
414 |
|
|
new (trigObj) TriggerObjectBase(tobj.id(),tobj.pt(),tobj.eta(),tobj.phi(),tobj.mass());
|
415 |
|
|
}
|
416 |
loizides |
1.16 |
|
417 |
|
|
// loop over trigger paths
|
418 |
|
|
const UInt_t N = hltConfig_.size();
|
419 |
|
|
for(UInt_t i=0;i<N;++i) {
|
420 |
|
|
|
421 |
|
|
const string &name(hltConfig_.triggerName(i));
|
422 |
|
|
const UInt_t tind(hltConfig_.triggerIndex(name.c_str()));
|
423 |
|
|
if (verify_)
|
424 |
|
|
assert(tind==i);
|
425 |
|
|
|
426 |
|
|
if (verbose_>0)
|
427 |
|
|
cout << "Trigger: path " << name << " [" << i << "]" << endl;
|
428 |
|
|
|
429 |
|
|
// get our trigger bit
|
430 |
|
|
map<string,Short_t>::iterator riter = hltTabMap_->find(name);
|
431 |
|
|
if (riter == hltTabMap_->end()) {
|
432 |
|
|
PrintErrorAndExit(Form("Trigger %s not found\n", name.c_str()));
|
433 |
|
|
}
|
434 |
|
|
|
435 |
|
|
UInt_t mytind = riter->second;
|
436 |
|
|
if (verify_) {
|
437 |
|
|
if (mytind!=tind)
|
438 |
|
|
PrintErrorAndExit(Form("Trigger for %s index does not match: %ud %ud\n",
|
439 |
|
|
name.c_str(), mytind, tind));
|
440 |
|
|
}
|
441 |
|
|
|
442 |
|
|
// modules on this trigger path
|
443 |
|
|
const UInt_t M(hltConfig_.size(tind));
|
444 |
|
|
const UInt_t mind(triggerResultsHLT->index(tind));
|
445 |
|
|
assert (mind<M);
|
446 |
|
|
|
447 |
|
|
const vector<string> &mLabels(hltConfig_.moduleLabels(tind));
|
448 |
|
|
|
449 |
|
|
if (verbose_>1)
|
450 |
|
|
cout << " Last active module - label/type: "
|
451 |
|
|
<< mLabels[mind] << "/" << hltConfig_.moduleType(mLabels[mind])
|
452 |
|
|
<< " [" << mind << " out of 0-" << (M-1) << " on this path]" << endl;
|
453 |
|
|
|
454 |
|
|
// loop over modules on path
|
455 |
|
|
for (UInt_t j=0; j<=mind; ++j) {
|
456 |
|
|
const string &mLabel(mLabels[j]);
|
457 |
|
|
|
458 |
|
|
// check whether the module is packed up in TriggerEvent product
|
459 |
|
|
const UInt_t find(triggerEventHLT->filterIndex(InputTag(mLabel,"",hltProcName_)));
|
460 |
|
|
if (find>=triggerEventHLT->sizeFilters())
|
461 |
|
|
continue;
|
462 |
|
|
|
463 |
|
|
const string mType(hltConfig_.moduleType(mLabel));
|
464 |
loizides |
1.37 |
|
465 |
|
|
string tType = "L1";
|
466 |
|
|
if (mType != "HLTLevel1GTSeed")
|
467 |
|
|
tType = "L3";
|
468 |
|
|
|
469 |
loizides |
1.16 |
if (verbose_>1)
|
470 |
loizides |
1.37 |
cout << " '" << tType << "' filter in slot " << j
|
471 |
|
|
<< " - label/type " << mLabel << "/" << mType << endl;
|
472 |
loizides |
1.16 |
|
473 |
|
|
// find index for module label/type name
|
474 |
|
|
Short_t modind = -1;
|
475 |
|
|
map<string,Short_t>::iterator riter = hltLabMap_->find(mLabel);
|
476 |
|
|
if (riter != hltLabMap_->end()) {
|
477 |
|
|
modind = riter->second;
|
478 |
|
|
}
|
479 |
loizides |
1.17 |
assert(modind!=-1);
|
480 |
|
|
|
481 |
|
|
Short_t filind = -1;
|
482 |
loizides |
1.16 |
riter = hltLabMap_->find(mType);
|
483 |
|
|
if (riter != hltLabMap_->end()) {
|
484 |
loizides |
1.17 |
filind = riter->second;
|
485 |
loizides |
1.16 |
}
|
486 |
loizides |
1.17 |
assert(filind!=-1);
|
487 |
loizides |
1.14 |
|
488 |
loizides |
1.16 |
// find trigger objects
|
489 |
|
|
const trigger::Vids &vids(triggerEventHLT->filterIds(find));
|
490 |
|
|
const trigger::Keys &keys(triggerEventHLT->filterKeys(find));
|
491 |
|
|
const trigger::size_type nVids(vids.size());
|
492 |
|
|
const trigger::size_type nKeys(keys.size());
|
493 |
|
|
assert(nVids==nKeys);
|
494 |
|
|
|
495 |
|
|
if (verbose_>2)
|
496 |
loizides |
1.37 |
cout << " " << nVids << " accepted '" << tType << "' objects found: " << endl;
|
497 |
loizides |
1.16 |
|
498 |
|
|
// loop over trigger objects
|
499 |
|
|
const trigger::TriggerObjectCollection &toc(triggerEventHLT->getObjects());
|
500 |
|
|
for (trigger::size_type k=0; k<nVids; ++k) {
|
501 |
|
|
Int_t tocind = keys[k];
|
502 |
|
|
|
503 |
|
|
const trigger::TriggerObject &tobj(toc[tocind]);
|
504 |
loizides |
1.37 |
|
505 |
loizides |
1.16 |
if (verbose_>2)
|
506 |
|
|
cout << " " << k << " " << vids[k] << "/" << keys[k] << ": "
|
507 |
|
|
<< tobj.id() << " " << tobj.pt() << " " << tobj.eta()
|
508 |
|
|
<< " " << tobj.phi() << " " << tobj.mass() << endl;
|
509 |
|
|
|
510 |
|
|
TriggerObjectRel *trigRel = hltRels_->Allocate();
|
511 |
loizides |
1.37 |
new (trigRel) TriggerObjectRel(mytind,vids[k],tocind,modind,filind);
|
512 |
loizides |
1.16 |
}
|
513 |
|
|
}
|
514 |
loizides |
1.37 |
|
515 |
|
|
if (triggerResultsHLT->accept(tind))
|
516 |
|
|
maskhlt.SetBit(mytind);
|
517 |
loizides |
1.16 |
}
|
518 |
loizides |
1.25 |
|
519 |
loizides |
1.37 |
hltBits_->SetBits(maskhlt);
|
520 |
loizides |
1.16 |
hltObjs_->Trim();
|
521 |
|
|
hltRels_->Trim();
|
522 |
loizides |
1.5 |
}
|
523 |
loizides |
1.36 |
|
524 |
|
|
//--------------------------------------------------------------------------------------------------
|
525 |
|
|
void FillerMetaInfos::FillL1Info(const edm::Event &event, const edm::EventSetup &setup)
|
526 |
|
|
{
|
527 |
|
|
//
|
528 |
|
|
|
529 |
|
|
}
|
530 |
|
|
|
531 |
|
|
//--------------------------------------------------------------------------------------------------
|
532 |
|
|
void FillerMetaInfos::FillL1Trig(const edm::Event &event, const edm::EventSetup &setup)
|
533 |
|
|
{
|
534 |
|
|
//
|
535 |
|
|
|
536 |
loizides |
1.37 |
#if 0
|
537 |
loizides |
1.36 |
edm::ESHandle<L1GtTriggerMenu> l1GtMenu;
|
538 |
|
|
setup.get<L1GtTriggerMenuRcd>().get(l1GtMenu);
|
539 |
|
|
const AlgorithmMap &algorithmMap = l1GtMenu->gtAlgorithmMap();
|
540 |
|
|
|
541 |
|
|
for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
|
542 |
|
|
int bitNumber = (itAlgo->second).algoBitNumber();
|
543 |
|
|
string algoName = (itAlgo->second).algoName();
|
544 |
|
|
//algoBitToAlgo[bitNumber] = &(itAlgo->second);
|
545 |
|
|
cout << " " << bitNumber << algoName << endl;
|
546 |
|
|
}
|
547 |
|
|
|
548 |
loizides |
1.37 |
return ;
|
549 |
|
|
|
550 |
loizides |
1.36 |
edm::Handle<L1GlobalTriggerReadoutRecord> l1Handle;
|
551 |
|
|
GetProduct("gtDigis", l1Handle, event);
|
552 |
|
|
//l1Handle->print(cout);
|
553 |
loizides |
1.37 |
// l1Handle->printL1Objects(cout);
|
554 |
loizides |
1.36 |
|
555 |
|
|
const DecisionWord dWord = l1Handle->decisionWord();
|
556 |
|
|
for(int i = 0;i!=128;i++){
|
557 |
|
|
//std::string trig(algorithmMap[i]);
|
558 |
|
|
bool r=dWord.at(i);
|
559 |
|
|
//std::cout << trig << " " << r << std::endl;
|
560 |
|
|
}
|
561 |
loizides |
1.37 |
#endif
|
562 |
|
|
}
|
563 |
|
|
|
564 |
|
|
|
565 |
|
|
#if 0
|
566 |
|
|
if (0) {
|
567 |
|
|
const std::vector<std::string> &test = triggerEventHLT->collectionTags();
|
568 |
|
|
int iprev = 0;
|
569 |
|
|
for(int i=0; i<test.size();++i) {
|
570 |
|
|
cout << i << " " << test.at(i) << endl;
|
571 |
|
|
|
572 |
|
|
int inext(triggerEventHLT->collectionKey(i));
|
573 |
|
|
cout << "inext " << inext << " iprev " << iprev << endl;
|
574 |
|
|
|
575 |
|
|
TString tstr(test.at(i).c_str());
|
576 |
|
|
if (tstr.Contains("hltL1extraParticles")) {
|
577 |
|
|
testcount += (inext-iprev);
|
578 |
|
|
cout << "incremented by " << (inext-iprev) << " " << " have : " << testcount << endl;
|
579 |
|
|
}
|
580 |
|
|
// loop over trigger objects
|
581 |
|
|
const trigger::TriggerObjectCollection &toc(triggerEventHLT->getObjects());
|
582 |
|
|
for (trigger::size_type k=iprev; k<inext; ++k) {
|
583 |
|
|
|
584 |
|
|
// get trigger object
|
585 |
|
|
const trigger::TriggerObject &tobj = toc[k];
|
586 |
|
|
cout << " " << k << ": "
|
587 |
|
|
<< tobj.id() << " " << tobj.pt() << " " << tobj.eta()
|
588 |
|
|
<< " " << tobj.phi() << " " << tobj.mass() << endl;
|
589 |
|
|
}
|
590 |
|
|
|
591 |
|
|
iprev = inext;
|
592 |
|
|
}
|
593 |
|
|
cout << "TestCount " << testcount << endl;
|
594 |
loizides |
1.36 |
|
595 |
|
|
|
596 |
loizides |
1.37 |
using namespace l1extra;
|
597 |
|
|
Handle<L1EmParticleCollection> h1;
|
598 |
|
|
GetProduct("hltL1extraParticles:Isolated", h1 , event);
|
599 |
|
|
cout << "Isolated " << h1->size() << endl;
|
600 |
|
|
testcount2 += h1->size();
|
601 |
|
|
Handle<L1EmParticleCollection> h2;
|
602 |
|
|
GetProduct("hltL1extraParticles:NonIsolated", h2 , event);
|
603 |
|
|
cout << "Non-Isolated " << h2->size() << endl;
|
604 |
|
|
testcount2 += h2->size();
|
605 |
|
|
Handle<L1JetParticleCollection> h3;
|
606 |
|
|
GetProduct("hltL1extraParticles:Central", h3 , event);
|
607 |
|
|
cout << "Central " << h3->size() << endl;
|
608 |
|
|
testcount2 += h3->size();
|
609 |
|
|
Handle<L1JetParticleCollection> h4;
|
610 |
|
|
GetProduct("hltL1extraParticles:Forward", h4 , event);
|
611 |
|
|
cout << "Forward " << h4->size() << endl;
|
612 |
|
|
testcount2 += h4->size();
|
613 |
|
|
Handle<L1JetParticleCollection> h5;
|
614 |
|
|
GetProduct("hltL1extraParticles:Tau", h5 , event);
|
615 |
|
|
cout << "Tau " << h5->size() << endl;
|
616 |
|
|
testcount2 += h5->size();
|
617 |
|
|
Handle<L1MuonParticleCollection> h6;
|
618 |
|
|
GetProduct("hltL1extraParticles", h6 , event);
|
619 |
|
|
cout << "Extra " << h6->size() << endl;
|
620 |
|
|
testcount2 += h6->size();
|
621 |
|
|
Handle<L1EtMissParticleCollection> h7;
|
622 |
|
|
GetProduct("hltL1extraParticles:MET", h7 , event);
|
623 |
|
|
cout << "MET " << h7->size() << endl;
|
624 |
|
|
testcount2 += h7->size();
|
625 |
|
|
Handle<L1EtMissParticleCollection> h8;
|
626 |
|
|
GetProduct("hltL1extraParticles:MHT", h8 , event);
|
627 |
|
|
cout << "MHT " << h8->size() << endl;
|
628 |
|
|
testcount2 += h8->size();
|
629 |
|
|
Handle<L1HFRingsCollection> h9;
|
630 |
|
|
GetProduct("hltL1extraParticles", h9 , event);
|
631 |
|
|
cout << "Exra2 " << h9->size() << endl;
|
632 |
|
|
testcount2 += h9->size();
|
633 |
|
|
cout << "TestCount2 " << testcount2 << endl;
|
634 |
|
|
}
|
635 |
|
|
#endif
|