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