CMS 3D CMS Logo

APVCyclePhaseDebuggerFromL1TS.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripTools
4 // Class: APVCyclePhaseDebuggerFromL1TS
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Mon Jan 12 09:05:45 CET 2009
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
29 
31 
33 
35 
39 
41 
42 #include <map>
43 #include <vector>
44 #include <utility>
45 #include <string>
46 #include <iostream>
47 
48 #include "TH1F.h"
49 #include "TProfile.h"
50 
52 
54 
55 //
56 // class decleration
57 //
58 
59 class APVCyclePhaseDebuggerFromL1TS : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
60 public:
63 
64  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
65 
66 private:
67  void beginRun(const edm::Run&, const edm::EventSetup&) override;
68  void analyze(const edm::Event&, const edm::EventSetup&) override;
69  void endRun(const edm::Run&, const edm::EventSetup&) override {}
70 
71  // ----------member data ---------------------------
72 
74  const unsigned int m_maxLS;
75  const unsigned int m_LSfrac;
76 
78 
79  TH1F** _hsize;
80  TH1F** _hlresync;
81  TH1F** _hlOC0;
82  TH1F** _hlTE;
83  TH1F** _hlstart;
84  TH1F** _hlEC0;
85  TH1F** _hlHR;
86 
88  TH1F** _hdlresynclHR;
89 
90  long long _lastResync;
91  long long _lastHardReset;
92  long long _lastStart;
93  long long _lastEventCounter0;
94  long long _lastOrbitCounter0;
95  long long _lastTestEnable;
96 };
97 
98 //
99 // constants, enums and typedefs
100 //
101 
102 //
103 // static data member definitions
104 //
105 
106 //
107 // constructors and destructor
108 //
110  : _l1tscollectionToken(
111  consumes<Level1TriggerScalersCollection>(iConfig.getParameter<edm::InputTag>("l1TSCollection"))),
112  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin", 250)),
113  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction", 16)),
114  m_rhm(consumesCollector()),
115  _hsize(nullptr),
116  _hlresync(nullptr),
117  _hlOC0(nullptr),
118  _hlTE(nullptr),
119  _hlstart(nullptr),
120  _hlEC0(nullptr),
121  _hlHR(nullptr),
122  _hdlec0lresync(nullptr),
123  _hdlresynclHR(nullptr),
124  _lastResync(-1),
125  _lastHardReset(-1),
126  _lastStart(-1),
127  _lastEventCounter0(-1),
128  _lastOrbitCounter0(-1),
129  _lastTestEnable(-1) {
130  //now do what ever other initialization is needed
131 
132  _hsize = m_rhm.makeTH1F("size", "Level1TriggerScalers Collection size", 20, -0.5, 19.5);
133 
134  _hlresync = m_rhm.makeTH1F("lresync", "Orbit of last resync", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
135  _hlOC0 = m_rhm.makeTH1F("lOC0", "Orbit of last OC0", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
136  _hlTE = m_rhm.makeTH1F("lTE", "Orbit of last TestEnable", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
137  _hlstart = m_rhm.makeTH1F("lstart", "Orbit of last Start", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
138  _hlEC0 = m_rhm.makeTH1F("lEC0", "Orbit of last EC0", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
139  _hlHR = m_rhm.makeTH1F("lHR", "Orbit of last HardReset", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
140  _hdlec0lresync = m_rhm.makeTH1F("dlec0lresync", "Orbit difference EC0-Resync", 4000, -1999.5, 2000.5);
141  _hdlresynclHR = m_rhm.makeTH1F("dlresynclHR", "Orbit difference Resync-HR", 4000, -1999.5, 2000.5);
142 }
143 
145  // do anything here that needs to be done at desctruction time
146  // (e.g. close files, deallocate resources etc.)
147 }
148 
149 //
150 // member functions
151 //
152 
153 // ------------ method called to produce the data ------------
155 
156 {
157  // update the parameters from DB
158 
159  m_rhm.beginRun(iRun);
160 
161  if (_hlresync && *_hlresync) {
162  (*_hlresync)->GetXaxis()->SetTitle("Orbit");
163  (*_hlresync)->GetYaxis()->SetTitle("Events");
164  (*_hlresync)->SetCanExtend(TH1::kXaxis);
165  }
166 
167  if (_hlOC0 && *_hlOC0) {
168  (*_hlOC0)->GetXaxis()->SetTitle("Orbit");
169  (*_hlOC0)->GetYaxis()->SetTitle("Events");
170  (*_hlOC0)->SetCanExtend(TH1::kXaxis);
171  }
172 
173  if (_hlTE && *_hlTE) {
174  (*_hlTE)->GetXaxis()->SetTitle("Orbit");
175  (*_hlTE)->GetYaxis()->SetTitle("Events");
176  (*_hlTE)->SetCanExtend(TH1::kXaxis);
177  }
178 
179  if (_hlstart && *_hlstart) {
180  (*_hlstart)->GetXaxis()->SetTitle("Orbit");
181  (*_hlstart)->GetYaxis()->SetTitle("Events");
182  (*_hlstart)->SetCanExtend(TH1::kXaxis);
183  }
184 
185  if (_hlEC0 && *_hlEC0) {
186  (*_hlEC0)->GetXaxis()->SetTitle("Orbit");
187  (*_hlEC0)->GetYaxis()->SetTitle("Events");
188  (*_hlEC0)->SetCanExtend(TH1::kXaxis);
189  }
190 
191  if (_hlHR && *_hlHR) {
192  (*_hlHR)->GetXaxis()->SetTitle("Orbit");
193  (*_hlHR)->GetYaxis()->SetTitle("Events");
194  (*_hlHR)->SetCanExtend(TH1::kXaxis);
195  }
196 
197  if (_hdlec0lresync && *_hdlec0lresync) {
198  (*_hdlec0lresync)->GetXaxis()->SetTitle("lastEC0-lastResync");
199  }
200 
201  if (_hdlresynclHR && *_hdlresynclHR) {
202  (*_hdlresynclHR)->GetXaxis()->SetTitle("lastEC0-lastResync");
203  }
204 }
205 
207  using namespace edm;
208 
210  iEvent.getByToken(_l1tscollectionToken, l1ts);
211 
212  if (_hsize && *_hsize)
213  (*_hsize)->Fill(l1ts->size());
214 
215  // offset computation
216 
217  if (!l1ts->empty()) {
218  if (_hlresync && *_hlresync)
219  (*_hlresync)->Fill((*l1ts)[0].lastResync());
220  if (_hlOC0 && *_hlOC0)
221  (*_hlOC0)->Fill((*l1ts)[0].lastOrbitCounter0());
222  if (_hlTE && *_hlTE)
223  (*_hlTE)->Fill((*l1ts)[0].lastTestEnable());
224  if (_hlstart && *_hlstart)
225  (*_hlstart)->Fill((*l1ts)[0].lastStart());
226  if (_hlEC0 && *_hlEC0)
227  (*_hlEC0)->Fill((*l1ts)[0].lastEventCounter0());
228  if (_hlHR && *_hlHR)
229  (*_hlHR)->Fill((*l1ts)[0].lastHardReset());
230 
231  if (_lastResync != (*l1ts)[0].lastResync()) {
232  _lastResync = (*l1ts)[0].lastResync();
234  (*_hdlec0lresync)->Fill((*l1ts)[0].lastEventCounter0() - (*l1ts)[0].lastResync());
235  LogDebug("TTCSignalReceived") << "New Resync at orbit " << _lastResync;
236  }
237  if (_lastHardReset != (*l1ts)[0].lastHardReset()) {
238  _lastHardReset = (*l1ts)[0].lastHardReset();
240  (*_hdlresynclHR)->Fill((*l1ts)[0].lastResync() - (*l1ts)[0].lastHardReset());
241  LogDebug("TTCSignalReceived") << "New HardReset at orbit " << _lastHardReset;
242  }
243  if (_lastTestEnable != (*l1ts)[0].lastTestEnable()) {
244  _lastTestEnable = (*l1ts)[0].lastTestEnable();
245  // LogDebug("TTCSignalReceived") << "New TestEnable at orbit " << _lastTestEnable ;
246  }
247  if (_lastOrbitCounter0 != (*l1ts)[0].lastOrbitCounter0()) {
248  _lastOrbitCounter0 = (*l1ts)[0].lastOrbitCounter0();
249  LogDebug("TTCSignalReceived") << "New OrbitCounter0 at orbit " << _lastOrbitCounter0;
250  }
251  if (_lastEventCounter0 != (*l1ts)[0].lastEventCounter0()) {
252  _lastEventCounter0 = (*l1ts)[0].lastEventCounter0();
253  LogDebug("TTCSignalReceived") << "New EventCounter0 at orbit " << _lastEventCounter0;
254  }
255  if (_lastStart != (*l1ts)[0].lastStart()) {
256  _lastStart = (*l1ts)[0].lastStart();
257  LogDebug("TTCSignalReceived") << "New Start at orbit " << _lastStart;
258  }
259  }
260 }
261 
264  desc.add<edm::InputTag>("l1TSCollection", edm::InputTag("scalersRawToDigi"));
265  descriptions.add("l1TSDebugger", desc);
266 }
267 
268 //define this as a plug-in
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void endRun(const edm::Run &, const edm::EventSetup &) override
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< Level1TriggerScalersCollection > _l1tscollectionToken
void beginRun(const edm::Run &, const edm::EventSetup &) override
void beginRun(const edm::Run &iRun)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< Level1TriggerScalers > Level1TriggerScalersCollection
HLT enums.
APVCyclePhaseDebuggerFromL1TS(const edm::ParameterSet &)
Definition: Run.h:45
#define LogDebug(id)