CMS 3D CMS Logo

L1TGlobalAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1TGloba
4 // Class: L1TGlobalAnalyzer
5 //
13 //
14 // Original Author: James Brooke
15 // Created: Tue, 11 Mar 2014 14:55:45 GMT
16 //
17 // Modifying Author: Brian Winer
18 // Created: Tue, 10 Mar 2015 based off L1TCaloAnalyzer
19 //
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 
35 
43 
44 #include "TH1F.h"
45 #include "TH2F.h"
46 
47 //
48 // class declaration
49 //
50 
51 namespace l1t {
52 
54  public:
55  explicit L1TGlobalAnalyzer(const edm::ParameterSet&);
56 
57  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
58 
59  private:
60  void beginJob() override;
61  void analyze(const edm::Event&, const edm::EventSetup&) override;
62 
63  // ----------member data ---------------------------
74 
78 
79  bool m_dogMUs;
80  bool m_doDmxEGs;
84  bool m_doMUs;
85  bool m_doEGs;
86  bool m_doTaus;
87  bool m_doJets;
88  bool m_doSums;
89 
90  bool m_doGtAlg;
93 
94  bool doText_;
95  bool doHistos_;
96 
97  enum ObjectType {
98  MU = 0x1,
99  EG = 0x2,
100  Tau = 0x3,
101  Jet = 0x4,
102  Sum = 0x5,
103  DmxEG = 0x6,
104  DmxTau = 0x7,
105  DmxJet = 0x8,
106  DmxSum = 0x9,
107  GtAlg = 0xA,
108  EmulGtAlg = 0xB,
109  gMU = 0xC
110  };
111 
112  std::vector<ObjectType> types_;
113  std::vector<std::string> typeStr_;
114 
115  std::map<ObjectType, TFileDirectory> dirs_;
116  std::map<ObjectType, TH1F*> het_;
117  std::map<ObjectType, TH1F*> heta_;
118  std::map<ObjectType, TH1F*> hphi_;
119  std::map<ObjectType, TH1F*> hbx_;
120  std::map<ObjectType, TH2F*> hetaphi_;
121 
125  TH1F* hAlgoBits_;
155  };
156 
157  //
158  // constants, enums and typedefs
159  //
160 
161  //
162  // static data member definitions
163  //
164 
165  //
166  // constructors and destructor
167  //
169  : doText_(iConfig.getUntrackedParameter<bool>("doText", true)),
170  doHistos_(iConfig.getUntrackedParameter<bool>("doHistos", true)) {
171  //now do what ever initialization is needed
172 
173  // register what you consume and keep token for later access:
174  edm::InputTag nullTag("None");
175 
176  edm::InputTag gmuTag = iConfig.getParameter<edm::InputTag>("gmuToken");
177  m_gmuToken = consumes<l1t::MuonBxCollection>(gmuTag);
178  m_dogMUs = !(gmuTag == nullTag);
179 
180  edm::InputTag dmxEGTag = iConfig.getParameter<edm::InputTag>("dmxEGToken");
181  m_dmxEGToken = consumes<l1t::EGammaBxCollection>(dmxEGTag);
182  m_doDmxEGs = !(dmxEGTag == nullTag);
183 
184  edm::InputTag dmxTauTag = iConfig.getParameter<edm::InputTag>("dmxTauToken");
185  m_dmxTauToken = consumes<l1t::TauBxCollection>(dmxTauTag);
186  m_doDmxTaus = !(dmxTauTag == nullTag);
187 
188  edm::InputTag dmxJetTag = iConfig.getParameter<edm::InputTag>("dmxJetToken");
189  m_dmxJetToken = consumes<l1t::JetBxCollection>(dmxJetTag);
190  m_doDmxJets = !(dmxJetTag == nullTag);
191 
192  edm::InputTag dmxSumTag = iConfig.getParameter<edm::InputTag>("dmxEtSumToken");
193  m_dmxSumToken = consumes<l1t::EtSumBxCollection>(dmxSumTag);
194  m_doDmxSums = !(dmxSumTag == nullTag);
195 
196  edm::InputTag muTag = iConfig.getParameter<edm::InputTag>("muToken");
197  m_muToken = consumes<l1t::MuonBxCollection>(muTag);
198  m_doMUs = !(muTag == nullTag);
199 
200  edm::InputTag egTag = iConfig.getParameter<edm::InputTag>("egToken");
201  m_egToken = consumes<l1t::EGammaBxCollection>(egTag);
202  m_doEGs = !(egTag == nullTag);
203 
204  edm::InputTag tauTag = iConfig.getParameter<edm::InputTag>("tauToken");
205  m_tauToken = consumes<l1t::TauBxCollection>(tauTag);
206  m_doTaus = !(tauTag == nullTag);
207 
208  edm::InputTag jetTag = iConfig.getParameter<edm::InputTag>("jetToken");
209  m_jetToken = consumes<l1t::JetBxCollection>(jetTag);
210  m_doJets = !(jetTag == nullTag);
211 
212  edm::InputTag sumTag = iConfig.getParameter<edm::InputTag>("etSumToken");
213  m_sumToken = consumes<l1t::EtSumBxCollection>(sumTag);
214  m_doSums = !(sumTag == nullTag);
215 
216  edm::InputTag gtAlgTag = iConfig.getParameter<edm::InputTag>("gtAlgToken");
217  m_gtAlgToken = consumes<GlobalAlgBlkBxCollection>(gtAlgTag);
218  m_doGtAlg = !(gtAlgTag == nullTag);
219 
220  edm::InputTag emulGtAlgTag = iConfig.getParameter<edm::InputTag>("emulGtAlgToken");
221  m_emulGtAlgToken = consumes<GlobalAlgBlkBxCollection>(emulGtAlgTag);
222  m_doEmulGtAlg = !(emulGtAlgTag == nullTag);
223 
224  edm::InputTag emulDxAlgTag = iConfig.getParameter<edm::InputTag>("emulDxAlgToken");
225  m_emulDxAlgToken = consumes<GlobalAlgBlkBxCollection>(emulDxAlgTag);
226  m_doEmulDxAlg = !(emulDxAlgTag == nullTag);
227 
228  types_.push_back(gMU);
229  types_.push_back(DmxEG);
230  types_.push_back(DmxTau);
231  types_.push_back(DmxJet);
232  types_.push_back(DmxSum);
233  types_.push_back(MU);
234  types_.push_back(EG);
235  types_.push_back(Tau);
236  types_.push_back(Jet);
237  types_.push_back(Sum);
238 
239  typeStr_.push_back("gmtmu");
240  typeStr_.push_back("dmxeg");
241  typeStr_.push_back("dmxtau");
242  typeStr_.push_back("dmxjet");
243  typeStr_.push_back("dmxsum");
244  typeStr_.push_back("mu");
245  typeStr_.push_back("eg");
246  typeStr_.push_back("tau");
247  typeStr_.push_back("jet");
248  typeStr_.push_back("sum");
249  }
250 
251  //
252  // member functions
253  //
254 
255  // ------------ method called for each event ------------
257  using namespace edm;
258 
259  std::stringstream text;
260 
261  // get gmt Muons
262  if (m_dogMUs) {
264  iEvent.getByToken(m_gmuToken, gmuons);
265 
266  for (int ibx = gmuons->getFirstBX(); ibx <= gmuons->getLastBX(); ++ibx) {
267  for (auto itr = gmuons->begin(ibx); itr != gmuons->end(ibx); ++itr) {
268  hbx_.at(gMU)->Fill(ibx);
269  het_.at(gMU)->Fill(itr->hwPt());
270  heta_.at(gMU)->Fill(itr->hwEtaAtVtx());
271  hphi_.at(gMU)->Fill(itr->hwPhiAtVtx());
272  hetaphi_.at(gMU)->Fill(itr->hwEtaAtVtx(), itr->hwPhiAtVtx(), itr->hwPt());
273 
274  text << "Muon : "
275  << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEtaAtVtx()
276  << " iphi=" << itr->hwPhiAtVtx() << std::endl;
277  }
278  }
279  }
280 
281  // get EG
282  if (m_doDmxEGs) {
284  iEvent.getByToken(m_dmxEGToken, dmxegs);
285 
286  for (int ibx = dmxegs->getFirstBX(); ibx <= dmxegs->getLastBX(); ++ibx) {
287  for (auto itr = dmxegs->begin(ibx); itr != dmxegs->end(ibx); ++itr) {
288  hbx_.at(DmxEG)->Fill(ibx);
289  het_.at(DmxEG)->Fill(itr->hwPt());
290  heta_.at(DmxEG)->Fill(itr->hwEta());
291  hphi_.at(DmxEG)->Fill(itr->hwPhi());
292  hetaphi_.at(DmxEG)->Fill(itr->hwEta(), itr->hwPhi(), itr->hwPt());
293 
294  text << "Dmx EG : "
295  << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEta() << " iphi=" << itr->hwPhi()
296  << std::endl;
297  }
298  }
299  }
300 
301  // get tau
302  if (m_doDmxTaus) {
303  Handle<BXVector<l1t::Tau> > dmxtaus;
304  iEvent.getByToken(m_dmxTauToken, dmxtaus);
305 
306  for (int ibx = dmxtaus->getFirstBX(); ibx <= dmxtaus->getLastBX(); ++ibx) {
307  for (auto itr = dmxtaus->begin(ibx); itr != dmxtaus->end(ibx); ++itr) {
308  hbx_.at(DmxTau)->Fill(ibx);
309  het_.at(DmxTau)->Fill(itr->hwPt());
310  heta_.at(DmxTau)->Fill(itr->hwEta());
311  hphi_.at(DmxTau)->Fill(itr->hwPhi());
312  hetaphi_.at(DmxTau)->Fill(itr->hwEta(), itr->hwPhi(), itr->hwPt());
313 
314  text << "Dmx Tau : "
315  << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEta() << " iphi=" << itr->hwPhi()
316  << std::endl;
317  }
318  }
319  }
320 
321  // get jet
322  if (m_doDmxJets) {
323  Handle<BXVector<l1t::Jet> > dmxjets;
324  iEvent.getByToken(m_dmxJetToken, dmxjets);
325 
326  for (int ibx = dmxjets->getFirstBX(); ibx <= dmxjets->getLastBX(); ++ibx) {
327  for (auto itr = dmxjets->begin(ibx); itr != dmxjets->end(ibx); ++itr) {
328  hbx_.at(DmxJet)->Fill(ibx);
329  het_.at(DmxJet)->Fill(itr->hwPt());
330  heta_.at(DmxJet)->Fill(itr->hwEta());
331  hphi_.at(DmxJet)->Fill(itr->hwPhi());
332  hetaphi_.at(DmxJet)->Fill(itr->hwEta(), itr->hwPhi(), itr->hwPt());
333 
334  text << "Dmx Jet : "
335  << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEta() << " iphi=" << itr->hwPhi()
336  << std::endl;
337  }
338  }
339  }
340 
341  // get sums
342  if (m_doDmxSums) {
343  Handle<BXVector<l1t::EtSum> > dmxsums;
344  iEvent.getByToken(m_dmxSumToken, dmxsums);
345 
346  for (int ibx = dmxsums->getFirstBX(); ibx <= dmxsums->getLastBX(); ++ibx) {
347  for (auto itr = dmxsums->begin(ibx); itr != dmxsums->end(ibx); ++itr) {
348  hbx_.at(DmxSum)->Fill(ibx);
349  het_.at(DmxSum)->Fill(itr->hwPt());
350  heta_.at(DmxSum)->Fill(itr->hwEta());
351  hphi_.at(DmxSum)->Fill(itr->hwPhi());
352  hetaphi_.at(DmxSum)->Fill(itr->hwEta(), itr->hwPhi(), itr->hwPt());
353 
354  text << "Dmx Sum : "
355  << " type=" << itr->getType() << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEta()
356  << " iphi=" << itr->hwPhi() << std::endl;
357  }
358  }
359  }
360 
361  // get Muons
362  if (m_doMUs) {
364  iEvent.getByToken(m_muToken, muons);
365 
366  for (int ibx = muons->getFirstBX(); ibx <= muons->getLastBX(); ++ibx) {
367  for (auto itr = muons->begin(ibx); itr != muons->end(ibx); ++itr) {
368  hbx_.at(MU)->Fill(ibx);
369  het_.at(MU)->Fill(itr->hwPt());
370  heta_.at(MU)->Fill(itr->hwEtaAtVtx());
371  hphi_.at(MU)->Fill(itr->hwPhiAtVtx());
372  hetaphi_.at(MU)->Fill(itr->hwEtaAtVtx(), itr->hwPhiAtVtx(), itr->hwPt());
373 
374  text << "Muon : "
375  << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEtaAtVtx()
376  << " iphi=" << itr->hwPhiAtVtx() << std::endl;
377  }
378  }
379  }
380 
381  // get EG
382  if (m_doEGs) {
384  iEvent.getByToken(m_egToken, egs);
385 
386  for (int ibx = egs->getFirstBX(); ibx <= egs->getLastBX(); ++ibx) {
387  for (auto itr = egs->begin(ibx); itr != egs->end(ibx); ++itr) {
388  hbx_.at(EG)->Fill(ibx);
389  het_.at(EG)->Fill(itr->hwPt());
390  heta_.at(EG)->Fill(itr->hwEta());
391  hphi_.at(EG)->Fill(itr->hwPhi());
392  hetaphi_.at(EG)->Fill(itr->hwEta(), itr->hwPhi(), itr->hwPt());
393 
394  text << "EG : "
395  << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEta() << " iphi=" << itr->hwPhi()
396  << std::endl;
397  }
398  }
399  }
400 
401  // get tau
402  if (m_doTaus) {
404  iEvent.getByToken(m_tauToken, taus);
405 
406  for (int ibx = taus->getFirstBX(); ibx <= taus->getLastBX(); ++ibx) {
407  for (auto itr = taus->begin(ibx); itr != taus->end(ibx); ++itr) {
408  hbx_.at(Tau)->Fill(ibx);
409  het_.at(Tau)->Fill(itr->hwPt());
410  heta_.at(Tau)->Fill(itr->hwEta());
411  hphi_.at(Tau)->Fill(itr->hwPhi());
412  hetaphi_.at(Tau)->Fill(itr->hwEta(), itr->hwPhi(), itr->hwPt());
413 
414  text << "Tau : "
415  << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEta() << " iphi=" << itr->hwPhi()
416  << std::endl;
417  }
418  }
419  }
420 
421  // get jet
422  if (m_doJets) {
424  iEvent.getByToken(m_jetToken, jets);
425 
426  for (int ibx = jets->getFirstBX(); ibx <= jets->getLastBX(); ++ibx) {
427  for (auto itr = jets->begin(ibx); itr != jets->end(ibx); ++itr) {
428  hbx_.at(Jet)->Fill(ibx);
429  het_.at(Jet)->Fill(itr->hwPt());
430  heta_.at(Jet)->Fill(itr->hwEta());
431  hphi_.at(Jet)->Fill(itr->hwPhi());
432  hetaphi_.at(Jet)->Fill(itr->hwEta(), itr->hwPhi(), itr->hwPt());
433 
434  text << "Jet : "
435  << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEta() << " iphi=" << itr->hwPhi()
436  << std::endl;
437  }
438  }
439  }
440 
441  // get sums
442  if (m_doSums) {
444  iEvent.getByToken(m_sumToken, sums);
445 
446  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
447  for (auto itr = sums->begin(ibx); itr != sums->end(ibx); ++itr) {
448  hbx_.at(Sum)->Fill(ibx);
449  het_.at(Sum)->Fill(itr->hwPt());
450  heta_.at(Sum)->Fill(itr->hwEta());
451  hphi_.at(Sum)->Fill(itr->hwPhi());
452  hetaphi_.at(Sum)->Fill(itr->hwEta(), itr->hwPhi(), itr->hwPt());
453  text << "Sum : "
454  << " type=" << itr->getType() << " BX=" << ibx << " ipt=" << itr->hwPt() << " ieta=" << itr->hwEta()
455  << " iphi=" << itr->hwPhi() << std::endl;
456  }
457  }
458  }
459 
460  //Algorithm Bits
461  if (m_doGtAlg) {
463  iEvent.getByToken(m_gtAlgToken, algs);
464 
465  for (int ibx = algs->getFirstBX(); ibx <= algs->getLastBX(); ++ibx) {
466  for (auto itr = algs->begin(ibx); itr != algs->end(ibx); ++itr) {
467  for (int algBit = 0; algBit < 128;
468  algBit++) { //Fix Me: Should access size of algo vector...need method in GlobalAlgBlk class
469  if (itr->getAlgoDecisionFinal(algBit)) {
470  hAlgoBits_->Fill(algBit);
471  text << "HW Fired Alg Bit : " << algBit << std::endl;
472  }
473  }
474  }
475  }
476  }
477 
478  //Algorithm Bits (Emulation seeded by GT input)
479  if (m_doEmulGtAlg) {
480  Handle<BXVector<GlobalAlgBlk> > emulGtAlgs;
481  iEvent.getByToken(m_emulGtAlgToken, emulGtAlgs);
482 
483  for (int ibx = emulGtAlgs->getFirstBX(); ibx <= emulGtAlgs->getLastBX(); ++ibx) {
484  for (auto itr = emulGtAlgs->begin(ibx); itr != emulGtAlgs->end(ibx); ++itr) {
485  for (int algBit = 0; algBit < 128;
486  algBit++) { //Fix Me: Should access size of algo vector...need method in GlobalAlgBlk class
487  if (itr->getAlgoDecisionFinal(algBit)) {
488  hEmulGtAlgoBits_->Fill(algBit);
489  text << "Emul w/ GTInput Fired Alg Bit : " << algBit << std::endl;
490  }
491  }
492  }
493  }
494  }
495 
496  //Algorithm Bits (Emulation seeded by Demux Output)
497  if (m_doEmulDxAlg) {
498  Handle<BXVector<GlobalAlgBlk> > emulDxAlgs;
499  iEvent.getByToken(m_emulDxAlgToken, emulDxAlgs);
500 
501  for (int ibx = emulDxAlgs->getFirstBX(); ibx <= emulDxAlgs->getLastBX(); ++ibx) {
502  for (auto itr = emulDxAlgs->begin(ibx); itr != emulDxAlgs->end(ibx); ++itr) {
503  for (int algBit = 0; algBit < 128;
504  algBit++) { //Fix Me: Should access size of algo vector...need method in GlobalAlgBlk class
505  if (itr->getAlgoDecisionFinal(algBit)) {
506  hEmulDxAlgoBits_->Fill(algBit);
507  text << "Emul w/ Demux output Fired Alg Bit : " << algBit << std::endl;
508  }
509  }
510  }
511  }
512  }
513 
514  // Mu (gmt vs GT)
515  if (m_doMUs & m_dogMUs) {
517  iEvent.getByToken(m_muToken, mus);
518 
520  iEvent.getByToken(m_gmuToken, gmtmus);
521 
522  for (int ibx = mus->getFirstBX(); ibx <= mus->getLastBX(); ++ibx) {
523  // Cycle through all GT MUs
524  for (unsigned int igtMU = 0; igtMU < mus->size(ibx); igtMU++) {
525  double gtMUEt = mus->at(ibx, igtMU).hwPt();
526  double gmtMUEt = 0.0;
527  if (gmtmus->size(ibx) > igtMU)
528  gmtMUEt = gmtmus->at(ibx, igtMU).hwPt();
529  hGmtVsGTMUEt_->Fill(gtMUEt, gmtMUEt);
530 
531  double gtMUEta = mus->at(ibx, igtMU).hwEtaAtVtx();
532  double gmtMUEta = 0.0;
533  if (gmtmus->size(ibx) > igtMU)
534  gmtMUEta = gmtmus->at(ibx, igtMU).hwEtaAtVtx();
535  hGmtVsGTMUEta_->Fill(gtMUEta, gmtMUEta);
536 
537  double gtMUPhi = mus->at(ibx, igtMU).hwPhiAtVtx();
538  double gmtMUPhi = 0.0;
539  if (gmtmus->size(ibx) > igtMU)
540  gmtMUPhi = gmtmus->at(ibx, igtMU).hwPhiAtVtx();
541  hGmtVsGTMUPhi_->Fill(gtMUPhi, gmtMUPhi);
542  }
543  // if there are extra MUs in the dmx record them
544  for (unsigned int igmtMU = mus->size(ibx); igmtMU < gmtmus->size(ibx); igmtMU++) {
545  double gtMUEt = 0.0; //no GT jet exists
546  double gmtMUEt = gmtmus->at(ibx, igmtMU).hwPt();
547  hGmtVsGTMUEt_->Fill(gtMUEt, gmtMUEt);
548 
549  double gtMUEta = 0.0;
550  double gmtMUEta = gmtmus->at(ibx, igmtMU).hwEtaAtVtx();
551  hGmtVsGTMUEta_->Fill(gtMUEta, gmtMUEta);
552 
553  double gtMUPhi = 0.0;
554  double gmtMUPhi = gmtmus->at(ibx, igmtMU).hwPhiAtVtx();
555  hGmtVsGTMUPhi_->Fill(gtMUPhi, gmtMUPhi);
556  }
557  }
558  }
559 
560  // EG (Dmx vs GT)
561  if (m_doEGs & m_doDmxEGs) {
563  iEvent.getByToken(m_egToken, egs);
564 
566  iEvent.getByToken(m_dmxEGToken, dmxegs);
567 
568  for (int ibx = egs->getFirstBX(); ibx <= egs->getLastBX(); ++ibx) {
569  // Cycle through all GT egs
570  for (unsigned int igtEG = 0; igtEG < egs->size(ibx); igtEG++) {
571  double gtEGEt = egs->at(ibx, igtEG).hwPt();
572  double dmxEGEt = 0.0;
573  if (dmxegs->size(ibx) > igtEG)
574  dmxEGEt = dmxegs->at(ibx, igtEG).hwPt();
575  hDmxVsGTEGEt_->Fill(gtEGEt, dmxEGEt);
576 
577  double gtEGEta = egs->at(ibx, igtEG).hwEta();
578  double dmxEGEta = 0.0;
579  if (dmxegs->size(ibx) > igtEG)
580  dmxEGEta = dmxegs->at(ibx, igtEG).hwEta();
581  hDmxVsGTEGEta_->Fill(gtEGEta, dmxEGEta);
582 
583  double gtEGPhi = egs->at(ibx, igtEG).hwPhi();
584  double dmxEGPhi = 0.0;
585  if (dmxegs->size(ibx) > igtEG)
586  dmxEGPhi = dmxegs->at(ibx, igtEG).hwPhi();
587  hDmxVsGTEGPhi_->Fill(gtEGPhi, dmxEGPhi);
588  }
589  // if there are extra egs in the dmx record them
590  for (unsigned int idmEG = egs->size(ibx); idmEG < dmxegs->size(ibx); idmEG++) {
591  double gtEGEt = 0.0; //no GT jet exists
592  double dmxEGEt = dmxegs->at(ibx, idmEG).hwPt();
593  hDmxVsGTEGEt_->Fill(gtEGEt, dmxEGEt);
594 
595  double gtEGEta = 0.0;
596  double dmxEGEta = dmxegs->at(ibx, idmEG).hwEta();
597  hDmxVsGTEGEta_->Fill(gtEGEta, dmxEGEta);
598 
599  double gtEGPhi = 0.0;
600  double dmxEGPhi = dmxegs->at(ibx, idmEG).hwPhi();
601  hDmxVsGTEGPhi_->Fill(gtEGPhi, dmxEGPhi);
602  }
603  }
604  }
605 
606  // Tau (Dmx vs GT)
607  if (m_doTaus & m_doDmxTaus) {
609  iEvent.getByToken(m_tauToken, taus);
610 
611  Handle<BXVector<l1t::Tau> > dmxtaus;
612  iEvent.getByToken(m_dmxTauToken, dmxtaus);
613 
614  for (int ibx = taus->getFirstBX(); ibx <= taus->getLastBX(); ++ibx) {
615  // Cycle through all GT taus
616  for (unsigned int igtTau = 0; igtTau < taus->size(ibx); igtTau++) {
617  double gtTauEt = taus->at(ibx, igtTau).hwPt();
618  double dmxTauEt = 0.0;
619  if (dmxtaus->size(ibx) > igtTau)
620  dmxTauEt = dmxtaus->at(ibx, igtTau).hwPt();
621  hDmxVsGTTauEt_->Fill(gtTauEt, dmxTauEt);
622 
623  double gtTauEta = taus->at(ibx, igtTau).hwEta();
624  double dmxTauEta = 0.0;
625  if (dmxtaus->size(ibx) > igtTau)
626  dmxTauEta = dmxtaus->at(ibx, igtTau).hwEta();
627  hDmxVsGTTauEta_->Fill(gtTauEta, dmxTauEta);
628 
629  double gtTauPhi = taus->at(ibx, igtTau).hwPhi();
630  double dmxTauPhi = 0.0;
631  if (dmxtaus->size(ibx) > igtTau)
632  dmxTauPhi = dmxtaus->at(ibx, igtTau).hwPhi();
633  hDmxVsGTTauPhi_->Fill(gtTauPhi, dmxTauPhi);
634  }
635  // if there are extra taus in the dmx record them
636  for (unsigned int idmTau = taus->size(ibx); idmTau < dmxtaus->size(ibx); idmTau++) {
637  double gtTauEt = 0.0; //no GT jet exists
638  double dmxTauEt = dmxtaus->at(ibx, idmTau).hwPt();
639  hDmxVsGTTauEt_->Fill(gtTauEt, dmxTauEt);
640 
641  double gtTauEta = 0.0;
642  double dmxTauEta = dmxtaus->at(ibx, idmTau).hwEta();
643  hDmxVsGTTauEta_->Fill(gtTauEta, dmxTauEta);
644 
645  double gtTauPhi = 0.0;
646  double dmxTauPhi = dmxtaus->at(ibx, idmTau).hwPhi();
647  hDmxVsGTTauPhi_->Fill(gtTauPhi, dmxTauPhi);
648  }
649  }
650  }
651 
652  // Jets (Dmx vs GT)
653  if (m_doJets & m_doDmxJets) {
655  iEvent.getByToken(m_jetToken, jets);
656 
657  Handle<BXVector<l1t::Jet> > dmxjets;
658  iEvent.getByToken(m_dmxJetToken, dmxjets);
659 
660  for (int ibx = jets->getFirstBX(); ibx <= jets->getLastBX(); ++ibx) {
661  // Cycle through all GT jets
662  for (unsigned int igtJ = 0; igtJ < jets->size(ibx); igtJ++) {
663  double gtJetEt = jets->at(ibx, igtJ).hwPt();
664  double dmxJetEt = 0.0;
665  if (dmxjets->size(ibx) > igtJ)
666  dmxJetEt = dmxjets->at(ibx, igtJ).hwPt();
667  hDmxVsGTJetEt_->Fill(gtJetEt, dmxJetEt);
668 
669  double gtJetEta = jets->at(ibx, igtJ).hwEta();
670  double dmxJetEta = 0.0;
671  if (dmxjets->size(ibx) > igtJ)
672  dmxJetEta = dmxjets->at(ibx, igtJ).hwEta();
673  hDmxVsGTJetEta_->Fill(gtJetEta, dmxJetEta);
674 
675  double gtJetPhi = jets->at(ibx, igtJ).hwPhi();
676  double dmxJetPhi = 0.0;
677  if (dmxjets->size(ibx) > igtJ)
678  dmxJetPhi = dmxjets->at(ibx, igtJ).hwPhi();
679  hDmxVsGTJetPhi_->Fill(gtJetPhi, dmxJetPhi);
680  }
681  // if there are extra jets in the dmx record them
682  for (unsigned int idmJ = jets->size(ibx); idmJ < dmxjets->size(ibx); idmJ++) {
683  double gtJetEt = 0.0; //no GT jet exists
684  double dmxJetEt = dmxjets->at(ibx, idmJ).hwPt();
685  hDmxVsGTJetEt_->Fill(gtJetEt, dmxJetEt);
686 
687  double gtJetEta = 0.0;
688  double dmxJetEta = dmxjets->at(ibx, idmJ).hwEta();
689  hDmxVsGTJetEta_->Fill(gtJetEta, dmxJetEta);
690 
691  double gtJetPhi = 0.0;
692  double dmxJetPhi = dmxjets->at(ibx, idmJ).hwPhi();
693  hDmxVsGTJetPhi_->Fill(gtJetPhi, dmxJetPhi);
694  }
695  }
696  }
697 
698  // Sums (Dmx vs GT)
699  if (m_doSums & m_doDmxSums) {
701  iEvent.getByToken(m_sumToken, sums);
702 
703  Handle<BXVector<l1t::EtSum> > dmxSums;
704  iEvent.getByToken(m_dmxSumToken, dmxSums);
705 
706  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
707  // Cycle through all GT sums
708  for (unsigned int igtS = 0; igtS < sums->size(ibx); igtS++) {
709  double gtSumEt = sums->at(ibx, igtS).hwPt();
710  double dmxSumEt = 0.0;
711  if (dmxSums->size(ibx) > igtS)
712  dmxSumEt = dmxSums->at(ibx, igtS).hwPt();
713 
714  double gtSumPhi = sums->at(ibx, igtS).hwPhi();
715  double dmxSumPhi = 0.0;
716  if (dmxSums->size(ibx) > igtS)
717  dmxSumPhi = dmxSums->at(ibx, igtS).hwPhi();
718 
719  if (sums->at(ibx, igtS).getType() == dmxSums->at(ibx, igtS).getType()) {
720  switch (sums->at(ibx, igtS).getType()) {
722  hDmxVsGTSumEt_ETT_->Fill(gtSumEt, dmxSumEt);
723 
724  break;
726  hDmxVsGTSumEt_ETTem_->Fill(gtSumEt, dmxSumEt);
727 
728  break;
730  hDmxVsGTSumEt_HTT_->Fill(gtSumEt, dmxSumEt);
731 
732  break;
734  hDmxVsGTSumEt_ETM_->Fill(gtSumEt, dmxSumEt);
735  hDmxVsGTSumPhi_ETM_->Fill(gtSumPhi, dmxSumPhi);
736  break;
738  hDmxVsGTSumEt_ETMHF_->Fill(gtSumEt, dmxSumEt);
739  hDmxVsGTSumPhi_ETMHF_->Fill(gtSumPhi, dmxSumPhi);
740  break;
742  hDmxVsGTSumEt_HTM_->Fill(gtSumEt, dmxSumEt);
743  hDmxVsGTSumPhi_HTM_->Fill(gtSumPhi, dmxSumPhi);
744  break;
746  hDmxVsGTSumEt_HFP0_->Fill(gtSumEt, dmxSumEt);
747  break;
749  hDmxVsGTSumEt_HFM0_->Fill(gtSumEt, dmxSumEt);
750  break;
752  hDmxVsGTSumEt_HFP1_->Fill(gtSumEt, dmxSumEt);
753  break;
755  hDmxVsGTSumEt_HFM1_->Fill(gtSumEt, dmxSumEt);
756  break;
757  default:
758  break;
759  }
760  } else {
761  text << "WARNING: EtSum Types do not line up between DeMux and uGT " << std::endl;
762  }
763  }
764  // if there are extra sumss in the dmx record them...should not be any...but let's check
765  for (unsigned int idmS = sums->size(ibx); idmS < dmxSums->size(ibx); idmS++) {
766  double gtSumEt = -1.0; //no GT jet exists
767  double dmxSumEt = dmxSums->at(ibx, idmS).hwPt();
768 
769  double gtSumPhi = -1.0;
770  double dmxSumPhi = dmxSums->at(ibx, idmS).hwPhi();
771 
772  switch (dmxSums->at(ibx, idmS).getType()) {
774  hDmxVsGTSumEt_ETT_->Fill(gtSumEt, dmxSumEt);
775 
776  break;
778  hDmxVsGTSumEt_ETTem_->Fill(gtSumEt, dmxSumEt);
779 
780  break;
782  hDmxVsGTSumEt_HTT_->Fill(gtSumEt, dmxSumEt);
783 
784  break;
786  hDmxVsGTSumEt_ETM_->Fill(gtSumEt, dmxSumEt);
787  hDmxVsGTSumPhi_ETM_->Fill(gtSumPhi, dmxSumPhi);
788  break;
790  hDmxVsGTSumEt_ETMHF_->Fill(gtSumEt, dmxSumEt);
791  hDmxVsGTSumPhi_ETMHF_->Fill(gtSumPhi, dmxSumPhi);
792  break;
794  hDmxVsGTSumEt_HTM_->Fill(gtSumEt, dmxSumEt);
795  hDmxVsGTSumPhi_HTM_->Fill(gtSumPhi, dmxSumPhi);
796  break;
797  default:
798  break;
799  }
800  }
801  }
802  }
803 
804  //Algorithm Bits (Emulation vs HW)
805  if (m_doGtAlg && m_doEmulGtAlg) {
807  iEvent.getByToken(m_gtAlgToken, hwalgs);
808 
810  iEvent.getByToken(m_emulGtAlgToken, emulAlgs);
811 
812  //for ( int ibx=hwalgs->getFirstBX(); ibx<=hwalgs->getLastBX(); ++ibx) {
813  int ibx = 0;
814 
815  auto itr = hwalgs->begin(ibx);
816  auto itr_emul = emulAlgs->begin(ibx);
817 
818  for (int algBit = 0; algBit < 128;
819  algBit++) { //Fix Me: Should access size of algo vector...need method in GlobalAlgBlk class
820  bool hw = itr->getAlgoDecisionFinal(algBit);
821  bool em = itr_emul->getAlgoDecisionFinal(algBit);
822  if (hw & em) {
823  hAlgoBitsEmulGtVsHw_->Fill(algBit, algBit);
824  } else if (hw & !em) {
825  hAlgoBitsEmulGtVsHw_->Fill(algBit, -1.0);
826  text << "WARNING: HW Fnd Alg Bit " << algBit << " but emulation did not " << std::endl;
827  } else if (!hw & em) {
828  hAlgoBitsEmulGtVsHw_->Fill(-1.0, algBit);
829  text << "WARNING: Emul. Fnd Alg Bit " << algBit << " but hardware did not " << std::endl;
830  }
831  }
832 
833  // }
834  }
835 
836  //Algorithm Bits (Emulation vs HW)
837  if (m_doGtAlg && m_doEmulDxAlg) {
839  iEvent.getByToken(m_gtAlgToken, hwalgs);
840 
842  iEvent.getByToken(m_emulDxAlgToken, emulAlgs);
843 
844  //for ( int ibx=hwalgs->getFirstBX(); ibx<=hwalgs->getLastBX(); ++ibx) {
845  int ibx = 0;
846 
847  auto itr = hwalgs->begin(ibx);
848  auto itr_emul = emulAlgs->begin(ibx);
849 
850  for (int algBit = 0; algBit < 128;
851  algBit++) { //Fix Me: Should access size of algo vector...need method in GlobalAlgBlk class
852  bool hw = itr->getAlgoDecisionFinal(algBit);
853  bool em = itr_emul->getAlgoDecisionFinal(algBit);
854  if (hw & em) {
855  hAlgoBitsEmulDxVsHw_->Fill(algBit, algBit);
856  } else if (hw & !em) {
857  hAlgoBitsEmulDxVsHw_->Fill(algBit, -1.0);
858  } else if (!hw & em) {
859  hAlgoBitsEmulDxVsHw_->Fill(-1.0, algBit);
860  }
861  }
862 
863  // }
864  }
865 
866  if (doText_)
867  edm::LogInfo("L1TGlobalEvents") << text.str();
868  }
869 
870  // ------------ method called once each job just before starting event loop ------------
873 
874  auto itr = types_.cbegin();
875  auto str = typeStr_.cbegin();
876 
877  for (; itr != types_.end(); ++itr, ++str) {
878  if (*itr == Jet || *itr == DmxJet || *itr == Sum || *itr == DmxSum || *itr == DmxEG || *itr == EG ||
879  *itr == DmxTau || *itr == Tau) {
880  double etmax = 99.5;
881  if (*itr == Jet || *itr == DmxJet || *itr == Sum || *itr == DmxSum)
882  etmax = 499.5;
883 
884  dirs_.insert(std::pair<ObjectType, TFileDirectory>(*itr, fs->mkdir(*str)));
885 
886  het_.insert(std::pair<ObjectType, TH1F*>(*itr, dirs_.at(*itr).make<TH1F>("et", "", 500, -0.5, etmax)));
887 
888  hbx_.insert(std::pair<ObjectType, TH1F*>(*itr, dirs_.at(*itr).make<TH1F>("bx", "", 11, -5.5, 5.5)));
889 
890  heta_.insert(std::pair<ObjectType, TH1F*>(*itr, dirs_.at(*itr).make<TH1F>("eta", "", 229, -114.5, 114.5)));
891  hphi_.insert(std::pair<ObjectType, TH1F*>(*itr, dirs_.at(*itr).make<TH1F>("phi", "", 144, -0.5, 143.5)));
892  hetaphi_.insert(std::pair<ObjectType, TH2F*>(
893  *itr, dirs_.at(*itr).make<TH2F>("etaphi", "", 229, -114.5, 114.5, 144, -0.5, 143.5)));
894  } else if (*itr == MU || *itr == gMU) {
895  double etmax = 511.5;
896  dirs_.insert(std::pair<ObjectType, TFileDirectory>(*itr, fs->mkdir(*str)));
897 
898  het_.insert(std::pair<ObjectType, TH1F*>(*itr, dirs_.at(*itr).make<TH1F>("et", "", 512, -0.5, etmax)));
899 
900  hbx_.insert(std::pair<ObjectType, TH1F*>(*itr, dirs_.at(*itr).make<TH1F>("bx", "", 11, -5.5, 5.5)));
901 
902  heta_.insert(std::pair<ObjectType, TH1F*>(*itr, dirs_.at(*itr).make<TH1F>("eta", "", 549, -224.5, 224.5)));
903  hphi_.insert(std::pair<ObjectType, TH1F*>(*itr, dirs_.at(*itr).make<TH1F>("phi", "", 576, -0.5, 575.5)));
904  hetaphi_.insert(std::pair<ObjectType, TH2F*>(
905  *itr, dirs_.at(*itr).make<TH2F>("etaphi", "", 549, -224.5, 224.5, 576, -0.5, 575.5)));
906  }
907  }
908 
909  algDir_ = fs->mkdir("Algorithms");
910  hAlgoBits_ = algDir_.make<TH1F>("hAlgoBits", "Algorithm Bits", 100, -0.5, 99.5);
911  hEmulGtAlgoBits_ = algDir_.make<TH1F>("hEmulGtAlgoBits", "GT Emulated Algorithm Bits", 100, -0.5, 99.5);
913  "hAlgoBitsEmulGtVsHw", "Algorithm Bits (GT) Emulation vs Hardware", 129, -1.5, 127.5, 129, -1.5, 127.5);
914  hEmulDxAlgoBits_ = algDir_.make<TH1F>("hEmulDxAlgoBits", "Dx Emulated Algorithm Bits", 100, -0.5, 99.5);
916  "hAlgoBitsEmulDxVsHw", "Algorithm Bits (Dx) Emulation vs Hardware", 129, -1.5, 127.5, 129, -1.5, 127.5);
917 
918  dmxVGtDir_ = fs->mkdir("SourceVsGT");
919 
920  hGmtVsGTMUEt_ =
921  dmxVGtDir_.make<TH2F>("hGmtVsGTMUEt", "Gmt MU Et versus GT MU Et", 512, -0.5, 511.5, 512, -0.5, 511.5);
923  dmxVGtDir_.make<TH2F>("hGmtVsGTMUEta", "Gmt MU Eta versus GT MU Eta", 549, -224.5, 224.5, 549, -224.5, 224.5);
925  dmxVGtDir_.make<TH2F>("hGmtVsGTMUPhi", "Gmt MU Phi versus GT MU Phi", 576, -0.5, 575.5, 576, -0.5, 575.5);
926 
927  hDmxVsGTEGEt_ =
928  dmxVGtDir_.make<TH2F>("hDmxVsGTEGEt", "Dmx EG Et versus GT EG Et", 500, -0.5, 499.5, 500, -0.5, 499.5);
930  dmxVGtDir_.make<TH2F>("hDmxVsGTEGEta", "Dmx EG Eta versus GT EG Eta", 229, -114.5, 114.5, 229, -114.5, 114.5);
932  dmxVGtDir_.make<TH2F>("hDmxVsGTEGPhi", "Dmx EG Phi versus GT EG Phi", 144, -0.5, 143.5, 144, -0.5, 143.5);
933 
935  dmxVGtDir_.make<TH2F>("hDmxVsGTTauEt", "Dmx Tau Et versus GT Tau Et", 500, -0.5, 499.5, 500, -0.5, 499.5);
937  "hDmxVsGTTauEta", "Dmx Tau Eta versus GT Tau Eta", 229, -114.5, 114.5, 229, -114.5, 114.5);
939  dmxVGtDir_.make<TH2F>("hDmxVsGTTauPhi", "Dmx Tau Phi versus GT Tau Phi", 144, -0.5, 143.5, 144, -0.5, 143.5);
940 
942  dmxVGtDir_.make<TH2F>("hDmxVsGTJetEt", "Dmx Jet Et versus GT Jet Et", 500, -0.5, 499.5, 500, -0.5, 499.5);
944  "hDmxVsGTJetEta", "Dmx Jet Eta versus GT Jet Eta", 229, -114.5, 114.5, 229, -114.5, 114.5);
946  dmxVGtDir_.make<TH2F>("hDmxVsGTJetPhi", "Dmx Jet Phi versus GT Jet Phi", 144, -0.5, 143.5, 144, -0.5, 143.5);
947 
949  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_ETT", "Dmx ETT versus GT ETT", 256, -0.5, 2047.5, 256, -0.5, 2047.5);
951  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_ETTem", "Dmx ETTem versus GT ETTem", 256, -0.5, 2047.5, 256, -0.5, 2047.5);
953  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_HTT", "Dmx HTT versus GT HTT", 256, -0.5, 2047.5, 256, -0.5, 2047.5);
955  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_ETM", "Dmx ETM versus GT ETM", 500, -0.5, 499.5, 500, -0.5, 499.5);
957  "hDmxVsGTSumPhi_ETM", "Dmx ETM Phi versus GT ETM Phi", 144, -0.5, 143.5, 144, -0.5, 143.5);
959  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_ETMHF", "Dmx ETMHF versus GT ETMHF", 500, -0.5, 499.5, 500, -0.5, 499.5);
961  "hDmxVsGTSumPhi_ETMHF", "Dmx ETMHF Phi versus GT ETMHF Phi", 144, -0.5, 143.5, 144, -0.5, 143.5);
963  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_HTM", "Dmx HTM versus GT HTM", 500, -0.5, 499.5, 500, -0.5, 499.5);
965  "hDmxVsGTSumPhi_HTM", "Dmx HTM Phi versus GT HTM Phi", 144, -0.5, 143.5, 144, -0.5, 143.5);
966 
968  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_HFP0", "Dmx versus GT HFP0", 16, -0.5, 15.5, 16, -0.5, 15.5);
970  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_HFM0", "Dmx versus GT HFM0", 16, -0.5, 15.5, 16, -0.5, 15.5);
972  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_HFP1", "Dmx versus GT HFP1", 16, -0.5, 15.5, 16, -0.5, 15.5);
974  dmxVGtDir_.make<TH2F>("hDmxVsGTSumEt_HFM1", "Dmx versus GT HFM1", 16, -0.5, 15.5, 16, -0.5, 15.5);
975  }
976 
977  // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
979  //The following says we do not know what parameters are allowed so do no validation
980  // Please change this to state exactly what you do use, even if it is no parameters
982  desc.setUnknown();
983  descriptions.addDefault(desc);
984  }
985 
986 } // namespace l1t
987 
988 using namespace l1t;
989 
990 //define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetToken m_emulDxAlgToken
std::map< ObjectType, TH1F * > het_
edm::EDGetToken m_dmxEGToken
std::vector< std::string > typeStr_
std::map< ObjectType, TH1F * > hphi_
delete x;
Definition: CaloConfig.h:22
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:212
edm::EDGetToken m_emulGtAlgToken
void analyze(const edm::Event &, const edm::EventSetup &) override
T * make(const Args &...args) const
make new ROOT object
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
Definition: Jet.py:1
edm::EDGetToken m_gmuToken
edm::EDGetToken m_dmxTauToken
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetToken m_gtAlgToken
L1TGlobalAnalyzer(const edm::ParameterSet &)
edm::EDGetToken m_sumToken
std::map< ObjectType, TH1F * > hbx_
Log< level::Info, false > LogInfo
std::map< ObjectType, TH2F * > hetaphi_
Definition: Tau.py:1
edm::EDGetToken m_dmxSumToken
edm::EDGetToken m_tauToken
std::map< ObjectType, TFileDirectory > dirs_
HLT enums.
edm::EDGetToken m_jetToken
edm::EDGetToken m_dmxJetToken
std::vector< ObjectType > types_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define str(s)
std::map< ObjectType, TH1F * > heta_