test
CMS 3D CMS Logo

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