CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EEStatusFlagsTask.cc
Go to the documentation of this file.
1 /*
2  * \file EEStatusFlagsTask.cc
3  *
4  * $Date: 2012/04/27 13:46:16 $
5  * $Revision: 1.43 $
6  * \author G. Della Ricca
7  *
8 */
9 
10 #include <iostream>
11 #include <fstream>
12 #include <vector>
13 
16 
18 
20 
24 
26 
28 
30 
31  init_ = false;
32 
34 
35  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
36 
37  subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
38 
39  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
40 
41  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
42 
43  EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
44 
45  for (int i = 0; i < 18; i++) {
46  meEvtType_[i] = 0;
47 
48  meFEchErrors_[i][0] = 0;
49  meFEchErrors_[i][1] = 0;
50  meFEchErrors_[i][2] = 0;
51  }
52 
54 
55 }
56 
58 
59 }
60 
62 
63  ievt_ = 0;
64 
65  if ( dqmStore_ ) {
66  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask");
67  if(subfolder_.size())
68  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask/" + subfolder_);
69  dqmStore_->rmdir(prefixME_ + "/EEStatusFlagsTask");
70  }
71 
72 }
73 
75 
77 
78 }
79 
81 }
82 
84 
85  Numbers::initGeometry(c, false);
86 
87  if ( ! mergeRuns_ ) this->reset();
88 
89 }
90 
92 
93 }
94 
96 
97  for (int i = 0; i < 18; i++) {
98  if ( meEvtType_[i] ) meEvtType_[i]->Reset();
99 
100  if ( meFEchErrors_[i][0] ) meFEchErrors_[i][0]->Reset();
101  if ( meFEchErrors_[i][1] ) meFEchErrors_[i][1]->Reset();
102  if ( meFEchErrors_[i][2] ) meFEchErrors_[i][2]->Reset();
103  }
105 
106 }
107 
109 
110  init_ = true;
111 
112  std::string name;
113  std::string dir;
114 
115  if ( dqmStore_ ) {
116  dir = prefixME_ + "/EEStatusFlagsTask";
117  if(subfolder_.size())
118  dir = prefixME_ + "/EEStatusFlagsTask/" + subfolder_;
119 
121 
122  dqmStore_->setCurrentFolder(dir + "/EvtType");
123  for (int i = 0; i < 18; i++) {
124  name = "EESFT EVTTYPE " + Numbers::sEE(i+1);
125  meEvtType_[i] = dqmStore_->book1D(name, name, 31, -1., 30.);
126  meEvtType_[i]->setBinLabel(1, "UNKNOWN", 1);
132  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
133  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
134  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
137  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
138  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
150  dqmStore_->tag(meEvtType_[i], i+1);
151  }
152 
153  dqmStore_->setCurrentFolder(dir + "/FEStatus");
154  for (int i = 0; i < 18; i++) {
155  name = "EESFT front-end status " + Numbers::sEE(i+1);
156  meFEchErrors_[i][0] = dqmStore_->book2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50.);
157  meFEchErrors_[i][0]->setAxisTitle("ix", 1);
158  if ( i+1 >= 1 && i+1 <= 9 ) meFEchErrors_[i][0]->setAxisTitle("101-ix", 1);
159  meFEchErrors_[i][0]->setAxisTitle("iy", 2);
160  dqmStore_->tag(meFEchErrors_[i][0], i+1);
161 
162  name = "EESFT MEM front-end status " + Numbers::sEE(i+1);
163  meFEchErrors_[i][1] = dqmStore_->book2D(name, name, 2, 0., 2., 1, 0., 1.);
164  meFEchErrors_[i][1]->setAxisTitle("pseudo-strip", 1);
165  meFEchErrors_[i][1]->setAxisTitle("channel", 2);
166  dqmStore_->tag(meFEchErrors_[i][1], i+1);
167 
168  name = "EESFT front-end status bits " + Numbers::sEE(i+1);
169  meFEchErrors_[i][2] = dqmStore_->book1D(name, name, 16, 0., 16.);
170  meFEchErrors_[i][2]->setBinLabel(1+0, "ACTIVE", 1);
171  meFEchErrors_[i][2]->setBinLabel(1+1, "DISABLED", 1);
172  meFEchErrors_[i][2]->setBinLabel(1+2, "TIMEOUT", 1);
173  meFEchErrors_[i][2]->setBinLabel(1+3, "HEADER", 1);
174  meFEchErrors_[i][2]->setBinLabel(1+4, "CHANNEL ID", 1);
175  meFEchErrors_[i][2]->setBinLabel(1+5, "LINK", 1);
176  meFEchErrors_[i][2]->setBinLabel(1+6, "BLOCKSIZE", 1);
177  meFEchErrors_[i][2]->setBinLabel(1+7, "SUPPRESSED", 1);
178  meFEchErrors_[i][2]->setBinLabel(1+8, "FORCED FS", 1);
179  meFEchErrors_[i][2]->setBinLabel(1+9, "L1A SYNC", 1);
180  meFEchErrors_[i][2]->setBinLabel(1+10, "BX SYNC", 1);
181  meFEchErrors_[i][2]->setBinLabel(1+11, "L1A+BX SYNC", 1);
182  meFEchErrors_[i][2]->setBinLabel(1+12, "FIFO FULL+L1A", 1);
183  meFEchErrors_[i][2]->setBinLabel(1+13, "H PARITY", 1);
184  meFEchErrors_[i][2]->setBinLabel(1+14, "V PARITY", 1);
185  meFEchErrors_[i][2]->setBinLabel(1+15, "FORCED ZS", 1);
186  dqmStore_->tag(meFEchErrors_[i][2], i+1);
187  }
188 
189  // checking the number of front-end errors in each DCC for each lumi
190  // tower error is weighted by 1/34
191  // bin 0 contains the number of processed events in the lumi (for normalization)
192  name = "EESFT weighted frontend errors by lumi";
193  meFEchErrorsByLumi_ = dqmStore_->book1D(name, name, 18, 1., 19.);
195  for (int i = 0; i < 18; i++) {
196  meFEchErrorsByLumi_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
197  }
198 
199  }
200 
201 }
202 
204 
205  if ( ! init_ ) return;
206 
207  if ( dqmStore_ ) {
208  std::string dir = prefixME_ + "/EEStatusFlagsTask";
209  if(subfolder_.size())
210  dir = prefixME_ + "/EEStatusFlagsTask/" + subfolder_;
211 
212  dqmStore_->setCurrentFolder(dir + "");
213 
214  dqmStore_->setCurrentFolder(dir + "/EvtType");
215  for (int i = 0; i < 18; i++) {
217  meEvtType_[i] = 0;
218  }
219 
220  dqmStore_->setCurrentFolder(dir + "/FEStatus");
221  for (int i = 0; i < 18; i++) {
223  meFEchErrors_[i][0] = 0;
224  if ( meFEchErrors_[i][1] ) dqmStore_->removeElement( meFEchErrors_[i][1]->getName() );
225  meFEchErrors_[i][1] = 0;
226  if ( meFEchErrors_[i][2] ) dqmStore_->removeElement( meFEchErrors_[i][2]->getName() );
227  meFEchErrors_[i][2] = 0;
228  }
229 
232 
233  }
234 
235  init_ = false;
236 
237 }
238 
240 
241  edm::LogInfo("EEStatusFlagsTask") << "analyzed " << ievt_ << " events";
242 
243  if ( enableCleanup_ ) this->cleanup();
244 
245 }
246 
248 
249  if ( ! init_ ) this->setup();
250 
251  ievt_++;
252 
253  // fill bin 0 with number of events in the lumi
255 
257 
258  if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
259 
260  for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
261 
262  if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
263 
264  int ism = Numbers::iSM( *dcchItr, EcalEndcap );
265  float xism = ism + 0.5;
266 
267  if ( meEvtType_[ism-1] ) meEvtType_[ism-1]->Fill(dcchItr->getRunType()+0.5);
268 
269  const std::vector<short> status = dcchItr->getFEStatus();
270 
271  for ( unsigned int itt=1; itt<=status.size(); itt++ ) {
272 
273  if ( itt > 70 ) continue;
274 
275  if ( itt >= 42 && itt <= 68 ) continue;
276 
277  if ( ( ism == 8 || ism == 17 ) && ( itt >= 18 && itt <= 24 ) ) continue;
278 
279  if ( itt >= 1 && itt <= 41 ) {
280 
281  std::vector<DetId>* crystals = Numbers::crystals( dcchItr->id(), itt );
282 
283  for ( unsigned int i=0; i<crystals->size(); i++ ) {
284 
285  EEDetId id = (*crystals)[i];
286 
287  int ix = id.ix();
288  int iy = id.iy();
289 
290  if ( ism >= 1 && ism <= 9 ) ix = 101 - ix;
291 
292  float xix = ix - 0.5;
293  float xiy = iy - 0.5;
294 
295  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 ) ) {
296  if ( meFEchErrors_[ism-1][0] ) meFEchErrors_[ism-1][0]->Fill(xix, xiy);
297  if ( meFEchErrorsByLumi_ ) meFEchErrorsByLumi_->Fill(xism, 1./34./crystals->size());
298  }
299 
300  }
301 
302  } else if ( itt == 69 || itt == 70 ) {
303 
304  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 ) ) {
305  if ( meFEchErrors_[ism-1][1] ) meFEchErrors_[ism-1][1]->Fill(itt-68-0.5, 0);
306  }
307 
308  }
309 
310  if ( meFEchErrors_[ism-1][2] ) meFEchErrors_[ism-1][2]->Fill(status[itt-1]+0.5);
311 
312  }
313 
314  }
315 
316  } else {
317 
318  edm::LogWarning("EEStatusFlagsTask") << EcalRawDataCollection_ << " not available";
319 
320  }
321 
322 }
323 
void setup(void)
Setup.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:226
int i
Definition: DBlmapReader.cc:9
int ix() const
Definition: EEDetId.h:71
void endJob(void)
EndJob.
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
Some &quot;id&quot; conversions.
virtual ~EEStatusFlagsTask()
Destructor.
std::vector< T >::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.
MonitorElement * meFEchErrorsByLumi_
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
void beginJob(void)
BeginJob.
static int ix0EE(const unsigned ism)
Definition: Numbers.cc:773
MonitorElement * meEvtType_[18]
static int iy0EE(const unsigned ism)
Definition: Numbers.cc:812
void Fill(long long x)
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1354
static std::vector< DetId > * crystals(const EcalTrigTowerDetId &id)
Definition: Numbers.cc:585
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
void reset(void)
Reset.
std::string getName(Reflex::Type &cc)
Definition: ClassFiller.cc:18
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::string subfolder_
EEStatusFlagsTask(const edm::ParameterSet &ps)
Constructor.
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:50
edm::InputTag EcalRawDataCollection_
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:246
dbl *** dir
Definition: mlp_gen.cc:35
static EcalSubdetector subDet(const EBDetId &id)
Definition: Numbers.cc:145
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:845
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
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)
MonitorElement * meFEchErrors_[18][3]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.