CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBStatusFlagsTask.cc
Go to the documentation of this file.
1 /*
2  * \file EBStatusFlagsTask.cc
3  *
4  * \author G. Della Ricca
5  *
6 */
7 
8 #include <iostream>
9 #include <fstream>
10 #include <vector>
11 
14 
16 
18 
20 
22 
24 
25  init_ = false;
26 
28 
29  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
30 
31  subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
32 
33  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
34 
35  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
36 
37  EcalRawDataCollection_ = consumes<EcalRawDataCollection>(ps.getParameter<edm::InputTag>("EcalRawDataCollection"));
38 
39  for (int i = 0; i < 36; i++) {
40  meEvtType_[i] = 0;
41 
42  meFEchErrors_[i][0] = 0;
43  meFEchErrors_[i][1] = 0;
44  meFEchErrors_[i][2] = 0;
45  }
46 
48 
49 }
50 
52 
53 }
54 
56 
57  ievt_ = 0;
58 
59  if ( dqmStore_ ) {
60  dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask");
61  if(subfolder_.size())
62  dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask/" + subfolder_);
63  dqmStore_->rmdir(prefixME_ + "/EBStatusFlagsTask");
64  }
65 
66 }
67 
69 
71 
72 }
73 
75 }
76 
78 
79  Numbers::initGeometry(c, false);
80 
81  if ( ! mergeRuns_ ) this->reset();
82 
83 }
84 
86 
87 }
88 
90 
91  for (int i = 0; i < 36; i++) {
92  if ( meEvtType_[i] ) meEvtType_[i]->Reset();
93 
94  if ( meFEchErrors_[i][0] ) meFEchErrors_[i][0]->Reset();
95  if ( meFEchErrors_[i][1] ) meFEchErrors_[i][1]->Reset();
96  if ( meFEchErrors_[i][2] ) meFEchErrors_[i][2]->Reset();
97  }
99 }
100 
102 
103  init_ = true;
104 
107 
108  if ( dqmStore_ ) {
109  dir = prefixME_ + "/EBStatusFlagsTask";
110  if(subfolder_.size())
111  dir = prefixME_ + "/EBStatusFlagsTask/" + subfolder_;
112 
114 
115  dqmStore_->setCurrentFolder(dir + "/EvtType");
116  for (int i = 0; i < 36; i++) {
117  name = "EBSFT EVTTYPE " + Numbers::sEB(i+1);
118  meEvtType_[i] = dqmStore_->book1D(name, name, 31, -1., 30.);
119  meEvtType_[i]->setBinLabel(1, "UNKNOWN", 1);
125  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
126  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
127  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
130  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
131  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
143  dqmStore_->tag(meEvtType_[i], i+1);
144  }
145 
146  dqmStore_->setCurrentFolder(dir + "/FEStatus");
147  for (int i = 0; i < 36; i++) {
148  name = "EBSFT front-end status " + Numbers::sEB(i+1);
149  meFEchErrors_[i][0] = dqmStore_->book2D(name, name, 17, 0., 17., 4, 0., 4.);
150  meFEchErrors_[i][0]->setAxisTitle("ieta'", 1);
151  meFEchErrors_[i][0]->setAxisTitle("iphi'", 2);
152  dqmStore_->tag(meFEchErrors_[i][0], i+1);
153 
154  name = "EBSFT MEM front-end status " + Numbers::sEB(i+1);
155  meFEchErrors_[i][1] = dqmStore_->book2D(name, name, 2, 0., 2., 1, 0., 1.);
156  meFEchErrors_[i][1]->setAxisTitle("pseudo-strip", 1);
157  meFEchErrors_[i][1]->setAxisTitle("channel", 2);
158  dqmStore_->tag(meFEchErrors_[i][1], i+1);
159 
160  name = "EBSFT front-end status bits " + Numbers::sEB(i+1);
161  meFEchErrors_[i][2] = dqmStore_->book1D(name, name, 16, 0., 16.);
162  meFEchErrors_[i][2]->setBinLabel(1+0, "ACTIVE", 1);
163  meFEchErrors_[i][2]->setBinLabel(1+1, "DISABLED", 1);
164  meFEchErrors_[i][2]->setBinLabel(1+2, "TIMEOUT", 1);
165  meFEchErrors_[i][2]->setBinLabel(1+3, "HEADER", 1);
166  meFEchErrors_[i][2]->setBinLabel(1+4, "CHANNEL ID", 1);
167  meFEchErrors_[i][2]->setBinLabel(1+5, "LINK", 1);
168  meFEchErrors_[i][2]->setBinLabel(1+6, "BLOCKSIZE", 1);
169  meFEchErrors_[i][2]->setBinLabel(1+7, "SUPPRESSED", 1);
170  meFEchErrors_[i][2]->setBinLabel(1+8, "FORCED FS", 1);
171  meFEchErrors_[i][2]->setBinLabel(1+9, "L1A SYNC", 1);
172  meFEchErrors_[i][2]->setBinLabel(1+10, "BX SYNC", 1);
173  meFEchErrors_[i][2]->setBinLabel(1+11, "L1A+BX SYNC", 1);
174  meFEchErrors_[i][2]->setBinLabel(1+12, "FIFO FULL+L1A", 1);
175  meFEchErrors_[i][2]->setBinLabel(1+13, "H PARITY", 1);
176  meFEchErrors_[i][2]->setBinLabel(1+14, "V PARITY", 1);
177  meFEchErrors_[i][2]->setBinLabel(1+15, "FORCED ZS", 1);
178  dqmStore_->tag(meFEchErrors_[i][2], i+1);
179  }
180 
181  // checking the number of front-end errors in each DCC for each lumi
182  // tower error is weighted by 1/68
183  // bin 0 contains the number of processed events in the lumi (for normalization)
184  name = "EBSFT weighted frontend errors by lumi";
185  meFEchErrorsByLumi_ = dqmStore_->book1D(name, name, 36, 1., 37.);
187  for (int i = 0; i < 36; i++) {
189  }
190 
191  }
192 
193 }
194 
196 
197  if ( ! init_ ) return;
198 
199  if ( dqmStore_ ) {
200 
201  std::string dir = prefixME_ + "/EBStatusFlagsTask";
202  if(subfolder_.size())
203  dir = prefixME_ + "/EBStatusFlagsTask/" + subfolder_;
204 
205  dqmStore_->setCurrentFolder(dir + "");
206 
207  dqmStore_->setCurrentFolder(dir + "/EvtType");
208  for (int i = 0; i < 36; i++) {
209  if ( meEvtType_[i] ) dqmStore_->removeElement( meEvtType_[i]->getName() );
210  meEvtType_[i] = 0;
211  }
212 
213  dqmStore_->setCurrentFolder(dir + "/FEStatus");
214  for (int i = 0; i < 36; i++) {
215  if ( meFEchErrors_[i][0] ) dqmStore_->removeElement( meFEchErrors_[i][0]->getName() );
216  meFEchErrors_[i][0] = 0;
217  if ( meFEchErrors_[i][1] ) dqmStore_->removeElement( meFEchErrors_[i][1]->getName() );
218  meFEchErrors_[i][1] = 0;
219  if ( meFEchErrors_[i][2] ) dqmStore_->removeElement( meFEchErrors_[i][2]->getName() );
220  meFEchErrors_[i][2] = 0;
221  }
222 
225 
226  }
227 
228  init_ = false;
229 
230 }
231 
233 
234  edm::LogInfo("EBStatusFlagsTask") << "analyzed " << ievt_ << " events";
235 
236  if ( enableCleanup_ ) this->cleanup();
237 
238 }
239 
241 
242  if ( ! init_ ) this->setup();
243 
244  ievt_++;
245 
246  // fill bin 0 with number of events in the lumi
248 
250 
251  if ( e.getByToken(EcalRawDataCollection_, dcchs) ) {
252 
253  for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
254 
255  if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
256 
257  int ism = Numbers::iSM( *dcchItr, EcalBarrel );
258  float xism = ism + 0.5;
259 
260  if ( meEvtType_[ism-1] ) meEvtType_[ism-1]->Fill(dcchItr->getRunType()+0.5);
261 
262  const std::vector<short> status = dcchItr->getFEStatus();
263 
264  for ( unsigned int itt=1; itt<=status.size(); itt++ ) {
265 
266  if ( itt > 70 ) continue;
267 
268  if ( itt >= 1 && itt <= 68 ) {
269 
270  int iet = (itt-1)/4 + 1;
271  int ipt = (itt-1)%4 + 1;
272 
273  float xiet = iet - 0.5;
274  float xipt = ipt - 0.5;
275 
276  if ( ! ( status[itt-1] == 0 || status[itt-1] == 1 || status[itt-1] == 7 || status[itt-1] == 8 || status[itt-1] == 12 || status[itt-1] == 15 ) ) {
277  if ( meFEchErrors_[ism-1][0] ) meFEchErrors_[ism-1][0]->Fill(xiet, xipt);
278  if ( meFEchErrorsByLumi_ ) meFEchErrorsByLumi_->Fill(xism, 1./68.);
279  }
280 
281  } else if ( itt == 69 || itt == 70 ) {
282 
283  if ( ! ( status[itt-1] == 0 || status[itt-1] == 1 || status[itt-1] == 7 || status[itt-1] == 8 || status[itt-1] == 12 || status[itt-1] == 15 ) ) {
284  if ( meFEchErrors_[ism-1][1] ) meFEchErrors_[ism-1][1]->Fill(itt-68-0.5, 0);
285  }
286 
287  }
288 
289  if ( meFEchErrors_[ism-1][2] ) meFEchErrors_[ism-1][2]->Fill(status[itt-1]+0.5);
290 
291  }
292 
293  }
294 
295  } else {
296 
297  edm::LogWarning("EBStatusFlagsTask") << "EcalRawDataCollection not available";
298 
299  }
300 
301 }
302 
MonitorElement * meFEchErrors_[36][3]
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
std::string subfolder_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2730
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
Some &quot;id&quot; conversions.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:91
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
std::vector< EcalDCCHeaderBlock >::const_iterator const_iterator
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
void cleanup(void)
Cleanup.
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
void Fill(long long x)
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1509
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
MonitorElement * meFEchErrorsByLumi_
virtual ~EBStatusFlagsTask()
Destructor.
void beginJob(void)
BeginJob.
void endJob(void)
EndJob.
MonitorElement * meEvtType_[36]
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:47
void setup(void)
Setup.
void reset(void)
Reset.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:243
dbl *** dir
Definition: mlp_gen.cc:35
static EcalSubdetector subDet(const EBDetId &id)
Definition: Numbers.cc:142
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
tuple status
Definition: ntuplemaker.py:245
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
EBStatusFlagsTask(const edm::ParameterSet &ps)
Constructor.
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
edm::EDGetTokenT< EcalRawDataCollection > EcalRawDataCollection_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
Definition: Run.h:41