CMS 3D CMS Logo

L1ABCDebugger.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripTools
4 // Class: L1ABCDebugger
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Tue Jul 19 11:56:00 CEST 2009
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
23 #include "TH2F.h"
24 #include "TProfile.h"
26 
27 #include <vector>
28 #include <string>
29 
32 
36 
39 
41 
43 //
44 // class decleration
45 //
46 
47 class L1ABCDebugger : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
48 public:
49  explicit L1ABCDebugger(const edm::ParameterSet&);
50  ~L1ABCDebugger() override;
51 
52 private:
53  void beginJob() override;
54  void analyze(const edm::Event&, const edm::EventSetup&) override;
55  void beginRun(const edm::Run&, const edm::EventSetup&) override;
56  void endRun(const edm::Run&, const edm::EventSetup&) override {}
57  void endJob() override;
58 
59  // ----------member data ---------------------------
60 
62  const unsigned int m_maxLS;
63  const unsigned int m_LSfrac;
64 
66 
67  TH2F** m_hoffsets;
68  TProfile** m_horboffvsorb;
69  TProfile** m_hbxoffvsorb;
70 };
71 
72 //
73 // constants, enums and typedefs
74 //
75 
76 //
77 // static data member definitions
78 //
79 
80 //
81 // constructors and destructor
82 //
84  : m_l1abccollectionToken(
85  consumes<L1AcceptBunchCrossingCollection>(iConfig.getParameter<edm::InputTag>("l1ABCCollection"))),
86  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin", 250)),
87  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction", 16)),
88  m_rhm(consumesCollector()) {
89  //now do what ever initialization is needed
90 
92  "offsets", "Orbit vs BX offsets between SCAL and Event", 2 * 3564 + 1, -3564.5, 3564.5, 201, -100.5, 100.5);
94  m_rhm.makeTProfile("orboffvsorb", "SCAL Orbit offset vs orbit number", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
96  m_rhm.makeTProfile("bxoffvsorb", "SCAL BX offset vs orbit number", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
97 }
98 
100  // do anything here that needs to be done at desctruction time
101  // (e.g. close files, deallocate resources etc.)
102 }
103 
104 //
105 // member functions
106 //
107 
108 // ------------ method called to for each event ------------
110  using namespace edm;
111 
113  iEvent.getByToken(m_l1abccollectionToken, pIn);
114 
115  // offset computation
116  for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
117  if (l1abc->l1AcceptOffset() == 0) {
118  if (m_hoffsets && *m_hoffsets)
119  (*m_hoffsets)
120  ->Fill((int)l1abc->bunchCrossing() - (int)iEvent.bunchCrossing(),
121  (long long)l1abc->orbitNumber() - (long long)iEvent.orbitNumber());
123  (*m_horboffvsorb)->Fill(iEvent.orbitNumber(), (long long)l1abc->orbitNumber() - (long long)iEvent.orbitNumber());
125  (*m_hbxoffvsorb)->Fill(iEvent.orbitNumber(), (int)l1abc->bunchCrossing() - (int)iEvent.bunchCrossing());
126  }
127  }
128 
129  // dump of L1ABC collection
130 
131  edm::LogInfo("L1ABCDebug") << "Dump of L1AcceptBunchCrossing Collection for event in orbit " << iEvent.orbitNumber()
132  << " and BX " << iEvent.bunchCrossing();
133 
134  for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
135  edm::LogVerbatim("L1ABCDebug") << *l1abc;
136  }
137 }
138 
139 void L1ABCDebugger::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
140  m_rhm.beginRun(iRun);
141 
142  if (m_hoffsets && *m_hoffsets) {
143  (*m_hoffsets)->GetXaxis()->SetTitle("#Delta BX (SCAL-Event)");
144  (*m_hoffsets)->GetYaxis()->SetTitle("#Delta orbit (SCAL-Event)");
145  }
146  if (m_horboffvsorb && *m_horboffvsorb) {
147  (*m_horboffvsorb)->GetXaxis()->SetTitle("Orbit");
148  (*m_horboffvsorb)->GetYaxis()->SetTitle("#Delta orbit (SCAL-Event)");
149  (*m_horboffvsorb)->SetCanExtend(TH1::kXaxis);
150  }
151  if (m_hbxoffvsorb && *m_hbxoffvsorb) {
152  (*m_hbxoffvsorb)->GetXaxis()->SetTitle("Orbit");
153  (*m_hbxoffvsorb)->GetYaxis()->SetTitle("#Delta BX (SCAL-Event)");
154  (*m_hbxoffvsorb)->SetCanExtend(TH1::kXaxis);
155  }
156 }
157 // ------------ method called once each job just before starting event loop ------------
159 
160 // ------------ method called once each job just after ending the event loop ------------
162 
163 //define this as a plug-in
Log< level::Info, true > LogVerbatim
TH2F ** m_hoffsets
const unsigned int m_maxLS
~L1ABCDebugger() override
RunHistogramManager m_rhm
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > m_l1abccollectionToken
void analyze(const edm::Event &, const edm::EventSetup &) override
const unsigned int m_LSfrac
int iEvent
Definition: GenABIO.cc:224
void endRun(const edm::Run &, const edm::EventSetup &) override
TProfile ** m_hbxoffvsorb
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
L1ABCDebugger(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< L1AcceptBunchCrossing > L1AcceptBunchCrossingCollection
void endJob() override
Log< level::Info, false > LogInfo
void beginJob() override
void beginRun(const edm::Run &iRun)
HLT enums.
TProfile ** m_horboffvsorb
TH2F ** makeTH2F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax, const unsigned int nbiny, const double ymin, const double ymax)
Definition: Run.h:45
void beginRun(const edm::Run &, const edm::EventSetup &) override