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 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
30 
32 
34 
36 
40 
42 
43 #include <map>
44 #include <vector>
45 #include <utility>
46 #include <string>
47 #include <iostream>
48 
49 #include "TH1F.h"
50 #include "TProfile.h"
51 
53 
55 
56 //
57 // class decleration
58 //
59 
61 public:
64 
65  static void fillDescriptions( edm::ConfigurationDescriptions & descriptions );
66 
67 private:
68  void beginRun(const edm::Run&, const edm::EventSetup&) override;
69  void analyze(const edm::Event&, 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 
100 //
101 // constants, enums and typedefs
102 //
103 
104 
105 //
106 // static data member definitions
107 //
108 
109 //
110 // constructors and destructor
111 //
113  _l1tscollectionToken(consumes<Level1TriggerScalersCollection>(iConfig.getParameter<edm::InputTag>("l1TSCollection"))),
114  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin",250)),
115  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction",16)),
120 {
121 
122  //now do what ever other initialization is needed
123 
124  _hsize = m_rhm.makeTH1F("size","Level1TriggerScalers Collection size",20,-0.5,19.5);
125 
126  _hlresync = m_rhm.makeTH1F("lresync","Orbit of last resync",m_LSfrac*m_maxLS,0,m_maxLS*262144);
127  _hlOC0 = m_rhm.makeTH1F("lOC0","Orbit of last OC0",m_LSfrac*m_maxLS,0,m_maxLS*262144);
128  _hlTE = m_rhm.makeTH1F("lTE","Orbit of last TestEnable",m_LSfrac*m_maxLS,0,m_maxLS*262144);
129  _hlstart = m_rhm.makeTH1F("lstart","Orbit of last Start",m_LSfrac*m_maxLS,0,m_maxLS*262144);
130  _hlEC0 = m_rhm.makeTH1F("lEC0","Orbit of last EC0",m_LSfrac*m_maxLS,0,m_maxLS*262144);
131  _hlHR = m_rhm.makeTH1F("lHR","Orbit of last HardReset",m_LSfrac*m_maxLS,0,m_maxLS*262144);
132  _hdlec0lresync = m_rhm.makeTH1F("dlec0lresync","Orbit difference EC0-Resync",4000,-1999.5,2000.5);
133  _hdlresynclHR = m_rhm.makeTH1F("dlresynclHR","Orbit difference Resync-HR",4000,-1999.5,2000.5);
134 
135 }
136 
137 
139 {
140 
141  // do anything here that needs to be done at desctruction time
142  // (e.g. close files, deallocate resources etc.)
143 
144 }
145 
146 
147 //
148 // member functions
149 //
150 
151 // ------------ method called to produce the data ------------
152 void
154 
155 {
156 
157  // update the parameters from DB
158 
159 
160  m_rhm.beginRun(iRun);
161 
162  if(_hlresync && *_hlresync) {
163  (*_hlresync)->GetXaxis()->SetTitle("Orbit"); (*_hlresync)->GetYaxis()->SetTitle("Events");
164  (*_hlresync)->SetCanExtend(TH1::kXaxis);
165  }
166 
167  if(_hlOC0 && *_hlOC0) {
168  (*_hlOC0)->GetXaxis()->SetTitle("Orbit"); (*_hlOC0)->GetYaxis()->SetTitle("Events");
169  (*_hlOC0)->SetCanExtend(TH1::kXaxis);
170  }
171 
172  if(_hlTE && *_hlTE) {
173  (*_hlTE)->GetXaxis()->SetTitle("Orbit"); (*_hlTE)->GetYaxis()->SetTitle("Events");
174  (*_hlTE)->SetCanExtend(TH1::kXaxis);
175  }
176 
177  if(_hlstart && *_hlstart) {
178  (*_hlstart)->GetXaxis()->SetTitle("Orbit"); (*_hlstart)->GetYaxis()->SetTitle("Events");
179  (*_hlstart)->SetCanExtend(TH1::kXaxis);
180  }
181 
182  if(_hlEC0 && *_hlEC0) {
183  (*_hlEC0)->GetXaxis()->SetTitle("Orbit"); (*_hlEC0)->GetYaxis()->SetTitle("Events");
184  (*_hlEC0)->SetCanExtend(TH1::kXaxis);
185  }
186 
187  if(_hlHR && *_hlHR) {
188  (*_hlHR)->GetXaxis()->SetTitle("Orbit"); (*_hlHR)->GetYaxis()->SetTitle("Events");
189  (*_hlHR)->SetCanExtend(TH1::kXaxis);
190  }
191 
193  (*_hdlec0lresync)->GetXaxis()->SetTitle("lastEC0-lastResync");
194  }
195 
196  if(_hdlresynclHR && *_hdlresynclHR) {
197  (*_hdlresynclHR)->GetXaxis()->SetTitle("lastEC0-lastResync");
198  }
199 
200 }
201 
202 
203 void
205 
206  using namespace edm;
207 
208 
210  iEvent.getByToken(_l1tscollectionToken,l1ts);
211 
212  if(_hsize && *_hsize) (*_hsize)->Fill(l1ts->size());
213 
214  // offset computation
215 
216  if(!l1ts->empty()) {
217 
218  if(_hlresync && *_hlresync) (*_hlresync)->Fill((*l1ts)[0].lastResync());
219  if(_hlOC0 && *_hlOC0) (*_hlOC0)->Fill((*l1ts)[0].lastOrbitCounter0());
220  if(_hlTE && *_hlTE) (*_hlTE)->Fill((*l1ts)[0].lastTestEnable());
221  if(_hlstart && *_hlstart) (*_hlstart)->Fill((*l1ts)[0].lastStart());
222  if(_hlEC0 && *_hlEC0) (*_hlEC0)->Fill((*l1ts)[0].lastEventCounter0());
223  if(_hlHR && *_hlHR) (*_hlHR)->Fill((*l1ts)[0].lastHardReset());
224 
225  if(_lastResync != (*l1ts)[0].lastResync()) {
226  _lastResync = (*l1ts)[0].lastResync();
227  if(_hdlec0lresync && *_hdlec0lresync) (*_hdlec0lresync)->Fill((*l1ts)[0].lastEventCounter0()-(*l1ts)[0].lastResync());
228  LogDebug("TTCSignalReceived") << "New Resync at orbit " << _lastResync ;
229  }
230  if(_lastHardReset != (*l1ts)[0].lastHardReset()) {
231  _lastHardReset = (*l1ts)[0].lastHardReset();
232  if(_hdlresynclHR && *_hdlresynclHR) (*_hdlresynclHR)->Fill((*l1ts)[0].lastResync()-(*l1ts)[0].lastHardReset());
233  LogDebug("TTCSignalReceived") << "New HardReset at orbit " << _lastHardReset ;
234  }
235  if(_lastTestEnable != (*l1ts)[0].lastTestEnable()) {
236  _lastTestEnable = (*l1ts)[0].lastTestEnable();
237  // LogDebug("TTCSignalReceived") << "New TestEnable at orbit " << _lastTestEnable ;
238  }
239  if(_lastOrbitCounter0 != (*l1ts)[0].lastOrbitCounter0()) {
240  _lastOrbitCounter0 = (*l1ts)[0].lastOrbitCounter0();
241  LogDebug("TTCSignalReceived") << "New OrbitCounter0 at orbit " << _lastOrbitCounter0 ;
242  }
243  if(_lastEventCounter0 != (*l1ts)[0].lastEventCounter0()) {
244  _lastEventCounter0 = (*l1ts)[0].lastEventCounter0();
245  LogDebug("TTCSignalReceived") << "New EventCounter0 at orbit " << _lastEventCounter0 ;
246  }
247  if(_lastStart != (*l1ts)[0].lastStart()) {
248  _lastStart = (*l1ts)[0].lastStart();
249  LogDebug("TTCSignalReceived") << "New Start at orbit " << _lastStart ;
250  }
251 
252  }
253 
254 
255 }
256 
257 void
260  desc.add<edm::InputTag>("l1TSCollection",edm::InputTag("scalersRawToDigi"));
261  descriptions.add("l1TSDebugger",desc);
262 }
263 
264 //define this as a plug-in
#define LogDebug(id)
void analyze(const edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
#define nullptr
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
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
HLT enums.
APVCyclePhaseDebuggerFromL1TS(const edm::ParameterSet &)
Definition: Run.h:45