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  * \author G. Della Ricca
5  *
6 */
7 
8 #include <iostream>
9 #include <fstream>
10 #include <vector>
11 
14 
16 
18 
21 
23 
25 
27 
28  init_ = false;
29 
31 
32  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
33 
34  subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
35 
36  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
37 
38  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
39 
40  EcalRawDataCollection_ = consumes<EcalRawDataCollection>(ps.getParameter<edm::InputTag>("EcalRawDataCollection"));
41 
42  for (int i = 0; i < 18; i++) {
43  meEvtType_[i] = 0;
44 
45  meFEchErrors_[i][0] = 0;
46  meFEchErrors_[i][1] = 0;
47  meFEchErrors_[i][2] = 0;
48  }
49 
51 
52 }
53 
55 
56 }
57 
59 
60  ievt_ = 0;
61 
62  if ( dqmStore_ ) {
63  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask");
64  if(subfolder_.size())
65  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask/" + subfolder_);
66  dqmStore_->rmdir(prefixME_ + "/EEStatusFlagsTask");
67  }
68 
69 }
70 
72 
74 
75 }
76 
78 }
79 
81 
82  Numbers::initGeometry(c, false);
83 
84  if ( ! mergeRuns_ ) this->reset();
85 
86 }
87 
89 
90 }
91 
93 
94  for (int i = 0; i < 18; i++) {
95  if ( meEvtType_[i] ) meEvtType_[i]->Reset();
96 
97  if ( meFEchErrors_[i][0] ) meFEchErrors_[i][0]->Reset();
98  if ( meFEchErrors_[i][1] ) meFEchErrors_[i][1]->Reset();
99  if ( meFEchErrors_[i][2] ) meFEchErrors_[i][2]->Reset();
100  }
102 
103 }
104 
106 
107  init_ = true;
108 
111 
112  if ( dqmStore_ ) {
113  dir = prefixME_ + "/EEStatusFlagsTask";
114  if(subfolder_.size())
115  dir = prefixME_ + "/EEStatusFlagsTask/" + subfolder_;
116 
118 
119  dqmStore_->setCurrentFolder(dir + "/EvtType");
120  for (int i = 0; i < 18; i++) {
121  name = "EESFT EVTTYPE " + Numbers::sEE(i+1);
122  meEvtType_[i] = dqmStore_->book1D(name, name, 31, -1., 30.);
123  meEvtType_[i]->setBinLabel(1, "UNKNOWN", 1);
129  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
130  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
131  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
134  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
135  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
147  dqmStore_->tag(meEvtType_[i], i+1);
148  }
149 
150  dqmStore_->setCurrentFolder(dir + "/FEStatus");
151  for (int i = 0; i < 18; i++) {
152  name = "EESFT front-end status " + Numbers::sEE(i+1);
153  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.);
154  meFEchErrors_[i][0]->setAxisTitle("ix", 1);
155  if ( i+1 >= 1 && i+1 <= 9 ) meFEchErrors_[i][0]->setAxisTitle("101-ix", 1);
156  meFEchErrors_[i][0]->setAxisTitle("iy", 2);
157  dqmStore_->tag(meFEchErrors_[i][0], i+1);
158 
159  name = "EESFT MEM front-end status " + Numbers::sEE(i+1);
160  meFEchErrors_[i][1] = dqmStore_->book2D(name, name, 2, 0., 2., 1, 0., 1.);
161  meFEchErrors_[i][1]->setAxisTitle("pseudo-strip", 1);
162  meFEchErrors_[i][1]->setAxisTitle("channel", 2);
163  dqmStore_->tag(meFEchErrors_[i][1], i+1);
164 
165  name = "EESFT front-end status bits " + Numbers::sEE(i+1);
166  meFEchErrors_[i][2] = dqmStore_->book1D(name, name, 16, 0., 16.);
167  meFEchErrors_[i][2]->setBinLabel(1+0, "ACTIVE", 1);
168  meFEchErrors_[i][2]->setBinLabel(1+1, "DISABLED", 1);
169  meFEchErrors_[i][2]->setBinLabel(1+2, "TIMEOUT", 1);
170  meFEchErrors_[i][2]->setBinLabel(1+3, "HEADER", 1);
171  meFEchErrors_[i][2]->setBinLabel(1+4, "CHANNEL ID", 1);
172  meFEchErrors_[i][2]->setBinLabel(1+5, "LINK", 1);
173  meFEchErrors_[i][2]->setBinLabel(1+6, "BLOCKSIZE", 1);
174  meFEchErrors_[i][2]->setBinLabel(1+7, "SUPPRESSED", 1);
175  meFEchErrors_[i][2]->setBinLabel(1+8, "FORCED FS", 1);
176  meFEchErrors_[i][2]->setBinLabel(1+9, "L1A SYNC", 1);
177  meFEchErrors_[i][2]->setBinLabel(1+10, "BX SYNC", 1);
178  meFEchErrors_[i][2]->setBinLabel(1+11, "L1A+BX SYNC", 1);
179  meFEchErrors_[i][2]->setBinLabel(1+12, "FIFO FULL+L1A", 1);
180  meFEchErrors_[i][2]->setBinLabel(1+13, "H PARITY", 1);
181  meFEchErrors_[i][2]->setBinLabel(1+14, "V PARITY", 1);
182  meFEchErrors_[i][2]->setBinLabel(1+15, "FORCED ZS", 1);
183  dqmStore_->tag(meFEchErrors_[i][2], i+1);
184  }
185 
186  // checking the number of front-end errors in each DCC for each lumi
187  // tower error is weighted by 1/34
188  // bin 0 contains the number of processed events in the lumi (for normalization)
189  name = "EESFT weighted frontend errors by lumi";
190  meFEchErrorsByLumi_ = dqmStore_->book1D(name, name, 18, 1., 19.);
192  for (int i = 0; i < 18; i++) {
193  meFEchErrorsByLumi_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
194  }
195 
196  }
197 
198 }
199 
201 
202  if ( ! init_ ) return;
203 
204  if ( dqmStore_ ) {
205  std::string dir = prefixME_ + "/EEStatusFlagsTask";
206  if(subfolder_.size())
207  dir = prefixME_ + "/EEStatusFlagsTask/" + subfolder_;
208 
209  dqmStore_->setCurrentFolder(dir + "");
210 
211  dqmStore_->setCurrentFolder(dir + "/EvtType");
212  for (int i = 0; i < 18; i++) {
213  if ( meEvtType_[i] ) dqmStore_->removeElement( meEvtType_[i]->getName() );
214  meEvtType_[i] = 0;
215  }
216 
217  dqmStore_->setCurrentFolder(dir + "/FEStatus");
218  for (int i = 0; i < 18; i++) {
219  if ( meFEchErrors_[i][0] ) dqmStore_->removeElement( meFEchErrors_[i][0]->getName() );
220  meFEchErrors_[i][0] = 0;
221  if ( meFEchErrors_[i][1] ) dqmStore_->removeElement( meFEchErrors_[i][1]->getName() );
222  meFEchErrors_[i][1] = 0;
223  if ( meFEchErrors_[i][2] ) dqmStore_->removeElement( meFEchErrors_[i][2]->getName() );
224  meFEchErrors_[i][2] = 0;
225  }
226 
229 
230  }
231 
232  init_ = false;
233 
234 }
235 
237 
238  edm::LogInfo("EEStatusFlagsTask") << "analyzed " << ievt_ << " events";
239 
240  if ( enableCleanup_ ) this->cleanup();
241 
242 }
243 
245 
246  if ( ! init_ ) this->setup();
247 
248  ievt_++;
249 
250  // fill bin 0 with number of events in the lumi
252 
254 
255  if ( e.getByToken(EcalRawDataCollection_, dcchs) ) {
256 
257  for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
258 
259  if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
260 
261  int ism = Numbers::iSM( *dcchItr, EcalEndcap );
262  float xism = ism + 0.5;
263 
264  if ( meEvtType_[ism-1] ) meEvtType_[ism-1]->Fill(dcchItr->getRunType()+0.5);
265 
266  const std::vector<short> status = dcchItr->getFEStatus();
267 
268  for ( unsigned int itt=1; itt<=status.size(); itt++ ) {
269 
270  if ( itt > 70 ) continue;
271 
272  if ( itt >= 42 && itt <= 68 ) continue;
273 
274  if ( ( ism == 8 || ism == 17 ) && ( itt >= 18 && itt <= 24 ) ) continue;
275 
276  if ( itt >= 1 && itt <= 41 ) {
277 
278  std::vector<DetId>* crystals = Numbers::crystals( dcchItr->id(), itt );
279 
280  for ( unsigned int i=0; i<crystals->size(); i++ ) {
281 
282  EEDetId id = (*crystals)[i];
283 
284  int ix = id.ix();
285  int iy = id.iy();
286 
287  if ( ism >= 1 && ism <= 9 ) ix = 101 - ix;
288 
289  float xix = ix - 0.5;
290  float xiy = iy - 0.5;
291 
292  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 ) ) {
293  if ( meFEchErrors_[ism-1][0] ) meFEchErrors_[ism-1][0]->Fill(xix, xiy);
294  if ( meFEchErrorsByLumi_ ) meFEchErrorsByLumi_->Fill(xism, 1./34./crystals->size());
295  }
296 
297  }
298 
299  } else if ( itt == 69 || itt == 70 ) {
300 
301  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 ) ) {
302  if ( meFEchErrors_[ism-1][1] ) meFEchErrors_[ism-1][1]->Fill(itt-68-0.5, 0);
303  }
304 
305  }
306 
307  if ( meFEchErrors_[ism-1][2] ) meFEchErrors_[ism-1][2]->Fill(status[itt-1]+0.5);
308 
309  }
310 
311  }
312 
313  } else {
314 
315  edm::LogWarning("EEStatusFlagsTask") << "EcalRawDataCollection not available";
316 
317  }
318 
319 }
320 
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:223
int i
Definition: DBlmapReader.cc:9
int ix() const
Definition: EEDetId.h:76
void endJob(void)
EndJob.
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
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.
virtual ~EEStatusFlagsTask()
Destructor.
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.
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:770
MonitorElement * meEvtType_[18]
static int iy0EE(const unsigned ism)
Definition: Numbers.cc:809
edm::EDGetTokenT< EcalRawDataCollection > EcalRawDataCollection_
void Fill(long long x)
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1509
static std::vector< DetId > * crystals(const EcalTrigTowerDetId &id)
Definition: Numbers.cc:582
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
void reset(void)
Reset.
std::string subfolder_
EEStatusFlagsTask(const edm::ParameterSet &ps)
Constructor.
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:47
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
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
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:584
Definition: Run.h:41
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.