CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
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 
70  // ----------member data ---------------------------
71 
73  const unsigned int m_maxLS;
74  const unsigned int m_LSfrac;
75 
77 
78  TH1F** _hsize;
79  TH1F** _hlresync;
80  TH1F** _hlOC0;
81  TH1F** _hlTE;
82  TH1F** _hlstart;
83  TH1F** _hlEC0;
84  TH1F** _hlHR;
85 
87  TH1F** _hdlresynclHR;
88 
89  long long _lastResync;
90  long long _lastHardReset;
91  long long _lastStart;
92  long long _lastEventCounter0;
93  long long _lastOrbitCounter0;
94  long long _lastTestEnable;
95 };
96 
97 //
98 // constants, enums and typedefs
99 //
100 
101 //
102 // static data member definitions
103 //
104 
105 //
106 // constructors and destructor
107 //
109  : _l1tscollectionToken(
110  consumes<Level1TriggerScalersCollection>(iConfig.getParameter<edm::InputTag>("l1TSCollection"))),
111  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin", 250)),
112  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction", 16)),
113  m_rhm(consumesCollector()),
114  _hsize(nullptr),
115  _hlresync(nullptr),
116  _hlOC0(nullptr),
117  _hlTE(nullptr),
118  _hlstart(nullptr),
119  _hlEC0(nullptr),
120  _hlHR(nullptr),
121  _hdlec0lresync(nullptr),
122  _hdlresynclHR(nullptr),
123  _lastResync(-1),
124  _lastHardReset(-1),
125  _lastStart(-1),
126  _lastEventCounter0(-1),
127  _lastOrbitCounter0(-1),
128  _lastTestEnable(-1) {
129  //now do what ever other initialization is needed
130 
131  _hsize = m_rhm.makeTH1F("size", "Level1TriggerScalers Collection size", 20, -0.5, 19.5);
132 
133  _hlresync = m_rhm.makeTH1F("lresync", "Orbit of last resync", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
134  _hlOC0 = m_rhm.makeTH1F("lOC0", "Orbit of last OC0", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
135  _hlTE = m_rhm.makeTH1F("lTE", "Orbit of last TestEnable", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
136  _hlstart = m_rhm.makeTH1F("lstart", "Orbit of last Start", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
137  _hlEC0 = m_rhm.makeTH1F("lEC0", "Orbit of last EC0", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
138  _hlHR = m_rhm.makeTH1F("lHR", "Orbit of last HardReset", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
139  _hdlec0lresync = m_rhm.makeTH1F("dlec0lresync", "Orbit difference EC0-Resync", 4000, -1999.5, 2000.5);
140  _hdlresynclHR = m_rhm.makeTH1F("dlresynclHR", "Orbit difference Resync-HR", 4000, -1999.5, 2000.5);
141 }
142 
144  // do anything here that needs to be done at desctruction time
145  // (e.g. close files, deallocate resources etc.)
146 }
147 
148 //
149 // member functions
150 //
151 
152 // ------------ method called to produce the data ------------
154 
155 {
156  // update the parameters from DB
157 
158  m_rhm.beginRun(iRun);
159 
160  if (_hlresync && *_hlresync) {
161  (*_hlresync)->GetXaxis()->SetTitle("Orbit");
162  (*_hlresync)->GetYaxis()->SetTitle("Events");
163  (*_hlresync)->SetCanExtend(TH1::kXaxis);
164  }
165 
166  if (_hlOC0 && *_hlOC0) {
167  (*_hlOC0)->GetXaxis()->SetTitle("Orbit");
168  (*_hlOC0)->GetYaxis()->SetTitle("Events");
169  (*_hlOC0)->SetCanExtend(TH1::kXaxis);
170  }
171 
172  if (_hlTE && *_hlTE) {
173  (*_hlTE)->GetXaxis()->SetTitle("Orbit");
174  (*_hlTE)->GetYaxis()->SetTitle("Events");
175  (*_hlTE)->SetCanExtend(TH1::kXaxis);
176  }
177 
178  if (_hlstart && *_hlstart) {
179  (*_hlstart)->GetXaxis()->SetTitle("Orbit");
180  (*_hlstart)->GetYaxis()->SetTitle("Events");
181  (*_hlstart)->SetCanExtend(TH1::kXaxis);
182  }
183 
184  if (_hlEC0 && *_hlEC0) {
185  (*_hlEC0)->GetXaxis()->SetTitle("Orbit");
186  (*_hlEC0)->GetYaxis()->SetTitle("Events");
187  (*_hlEC0)->SetCanExtend(TH1::kXaxis);
188  }
189 
190  if (_hlHR && *_hlHR) {
191  (*_hlHR)->GetXaxis()->SetTitle("Orbit");
192  (*_hlHR)->GetYaxis()->SetTitle("Events");
193  (*_hlHR)->SetCanExtend(TH1::kXaxis);
194  }
195 
196  if (_hdlec0lresync && *_hdlec0lresync) {
197  (*_hdlec0lresync)->GetXaxis()->SetTitle("lastEC0-lastResync");
198  }
199 
200  if (_hdlresynclHR && *_hdlresynclHR) {
201  (*_hdlresynclHR)->GetXaxis()->SetTitle("lastEC0-lastResync");
202  }
203 }
204 
206  using namespace edm;
207 
209  iEvent.getByToken(_l1tscollectionToken, l1ts);
210 
211  if (_hsize && *_hsize)
212  (*_hsize)->Fill(l1ts->size());
213 
214  // offset computation
215 
216  if (!l1ts->empty()) {
217  if (_hlresync && *_hlresync)
218  (*_hlresync)->Fill((*l1ts)[0].lastResync());
219  if (_hlOC0 && *_hlOC0)
220  (*_hlOC0)->Fill((*l1ts)[0].lastOrbitCounter0());
221  if (_hlTE && *_hlTE)
222  (*_hlTE)->Fill((*l1ts)[0].lastTestEnable());
223  if (_hlstart && *_hlstart)
224  (*_hlstart)->Fill((*l1ts)[0].lastStart());
225  if (_hlEC0 && *_hlEC0)
226  (*_hlEC0)->Fill((*l1ts)[0].lastEventCounter0());
227  if (_hlHR && *_hlHR)
228  (*_hlHR)->Fill((*l1ts)[0].lastHardReset());
229 
230  if (_lastResync != (*l1ts)[0].lastResync()) {
231  _lastResync = (*l1ts)[0].lastResync();
233  (*_hdlec0lresync)->Fill((*l1ts)[0].lastEventCounter0() - (*l1ts)[0].lastResync());
234  LogDebug("TTCSignalReceived") << "New Resync at orbit " << _lastResync;
235  }
236  if (_lastHardReset != (*l1ts)[0].lastHardReset()) {
237  _lastHardReset = (*l1ts)[0].lastHardReset();
239  (*_hdlresynclHR)->Fill((*l1ts)[0].lastResync() - (*l1ts)[0].lastHardReset());
240  LogDebug("TTCSignalReceived") << "New HardReset at orbit " << _lastHardReset;
241  }
242  if (_lastTestEnable != (*l1ts)[0].lastTestEnable()) {
243  _lastTestEnable = (*l1ts)[0].lastTestEnable();
244  // LogDebug("TTCSignalReceived") << "New TestEnable at orbit " << _lastTestEnable ;
245  }
246  if (_lastOrbitCounter0 != (*l1ts)[0].lastOrbitCounter0()) {
247  _lastOrbitCounter0 = (*l1ts)[0].lastOrbitCounter0();
248  LogDebug("TTCSignalReceived") << "New OrbitCounter0 at orbit " << _lastOrbitCounter0;
249  }
250  if (_lastEventCounter0 != (*l1ts)[0].lastEventCounter0()) {
251  _lastEventCounter0 = (*l1ts)[0].lastEventCounter0();
252  LogDebug("TTCSignalReceived") << "New EventCounter0 at orbit " << _lastEventCounter0;
253  }
254  if (_lastStart != (*l1ts)[0].lastStart()) {
255  _lastStart = (*l1ts)[0].lastStart();
256  LogDebug("TTCSignalReceived") << "New Start at orbit " << _lastStart;
257  }
258  }
259 }
260 
263  desc.add<edm::InputTag>("l1TSCollection", edm::InputTag("scalersRawToDigi"));
264  descriptions.add("l1TSDebugger", desc);
265 }
266 
267 //define this as a plug-in
_lastResync(-1)
_lastEventCounter0(-1)
void analyze(const edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
_lastHardReset(-1)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
_lastStart(-1)
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
int iEvent
Definition: GenABIO.cc:224
m_rhm(consumesCollector())
_lastOrbitCounter0(-1)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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
APVCyclePhaseDebuggerFromL1TS(const edm::ParameterSet &)
Definition: Run.h:45
#define LogDebug(id)