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: 2010/10/04 11:16:02 $
5  * $Revision: 1.38 $
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  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
38 
39  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
40 
41  EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
42 
43  for (int i = 0; i < 18; i++) {
44  meEvtType_[i] = 0;
45 
46  meFEchErrors_[i][0] = 0;
47  meFEchErrors_[i][1] = 0;
48  meFEchErrors_[i][2] = 0;
49  }
50 
52 
53 }
54 
56 
57 }
58 
60 
61  ievt_ = 0;
62 
63  if ( dqmStore_ ) {
64  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask");
65  dqmStore_->rmdir(prefixME_ + "/EEStatusFlagsTask");
66  }
67 
68 }
69 
71 
73 
74 }
75 
77 }
78 
80 
81  Numbers::initGeometry(c, false);
82 
83  if ( ! mergeRuns_ ) this->reset();
84 
85 }
86 
88 
89 }
90 
92 
93  for (int i = 0; i < 18; i++) {
94  if ( meEvtType_[i] ) meEvtType_[i]->Reset();
95 
96  if ( meFEchErrors_[i][0] ) meFEchErrors_[i][0]->Reset();
97  if ( meFEchErrors_[i][1] ) meFEchErrors_[i][1]->Reset();
98  if ( meFEchErrors_[i][2] ) meFEchErrors_[i][2]->Reset();
99  }
101 
102 }
103 
105 
106  init_ = true;
107 
108  std::string name;
109 
110  if ( dqmStore_ ) {
111  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask");
112 
113  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask/EvtType");
114  for (int i = 0; i < 18; i++) {
115  name = "EESFT EVTTYPE " + Numbers::sEE(i+1);
116  meEvtType_[i] = dqmStore_->book1D(name, name, 31, -1., 30.);
117  meEvtType_[i]->setBinLabel(1, "UNKNOWN", 1);
123  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
124  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
125  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
128  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
129  meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
141  dqmStore_->tag(meEvtType_[i], i+1);
142  }
143 
144  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask/FEStatus");
145  for (int i = 0; i < 18; i++) {
146  name = "EESFT front-end status " + Numbers::sEE(i+1);
147  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.);
148  meFEchErrors_[i][0]->setAxisTitle("ix", 1);
149  if ( i+1 >= 1 && i+1 <= 9 ) meFEchErrors_[i][0]->setAxisTitle("101-ix", 1);
150  meFEchErrors_[i][0]->setAxisTitle("iy", 2);
151  dqmStore_->tag(meFEchErrors_[i][0], i+1);
152 
153  name = "EESFT MEM front-end status " + Numbers::sEE(i+1);
154  meFEchErrors_[i][1] = dqmStore_->book2D(name, name, 2, 0., 2., 1, 0., 1.);
155  meFEchErrors_[i][1]->setAxisTitle("pseudo-strip", 1);
156  meFEchErrors_[i][1]->setAxisTitle("channel", 2);
157  dqmStore_->tag(meFEchErrors_[i][1], i+1);
158 
159  name = "EESFT front-end status bits " + Numbers::sEE(i+1);
160  meFEchErrors_[i][2] = dqmStore_->book1D(name, name, 16, 0., 16.);
161  meFEchErrors_[i][2]->setBinLabel(1+0, "ACTIVE", 1);
162  meFEchErrors_[i][2]->setBinLabel(1+1, "DISABLED", 1);
163  meFEchErrors_[i][2]->setBinLabel(1+2, "TIMEOUT", 1);
164  meFEchErrors_[i][2]->setBinLabel(1+3, "HEADER", 1);
165  meFEchErrors_[i][2]->setBinLabel(1+4, "CHANNEL ID", 1);
166  meFEchErrors_[i][2]->setBinLabel(1+5, "LINK", 1);
167  meFEchErrors_[i][2]->setBinLabel(1+6, "BLOCKSIZE", 1);
168  meFEchErrors_[i][2]->setBinLabel(1+7, "SUPPRESSED", 1);
169  meFEchErrors_[i][2]->setBinLabel(1+8, "FORCED FS", 1);
170  meFEchErrors_[i][2]->setBinLabel(1+9, "L1A SYNC", 1);
171  meFEchErrors_[i][2]->setBinLabel(1+10, "BX SYNC", 1);
172  meFEchErrors_[i][2]->setBinLabel(1+11, "L1A+BX SYNC", 1);
173  meFEchErrors_[i][2]->setBinLabel(1+12, "FIFO FULL+L1A", 1);
174  meFEchErrors_[i][2]->setBinLabel(1+13, "H PARITY", 1);
175  meFEchErrors_[i][2]->setBinLabel(1+14, "V PARITY", 1);
176  meFEchErrors_[i][2]->setBinLabel(1+15, "FORCED ZS", 1);
177  dqmStore_->tag(meFEchErrors_[i][2], i+1);
178  }
179 
180  // checking the number of front-end errors in each DCC for each lumi
181  // tower error is weighted by 1/34
182  // bin 0 contains the number of processed events in the lumi (for normalization)
183  name = "EESFT weighted frontend errors by lumi";
184  meFEchErrorsByLumi_ = dqmStore_->book1D(name, name, 18, 1., 19.);
186  for (int i = 0; i < 18; i++) {
187  meFEchErrorsByLumi_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
188  }
189 
190  }
191 
192 }
193 
195 
196  if ( ! init_ ) return;
197 
198  if ( dqmStore_ ) {
199  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask");
200 
201  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask/EvtType");
202  for (int i = 0; i < 18; i++) {
204  meEvtType_[i] = 0;
205  }
206 
207  dqmStore_->setCurrentFolder(prefixME_ + "/EEStatusFlagsTask/FEStatus");
208  for (int i = 0; i < 18; i++) {
210  meFEchErrors_[i][0] = 0;
211  if ( meFEchErrors_[i][1] ) dqmStore_->removeElement( meFEchErrors_[i][1]->getName() );
212  meFEchErrors_[i][1] = 0;
213  if ( meFEchErrors_[i][2] ) dqmStore_->removeElement( meFEchErrors_[i][2]->getName() );
214  meFEchErrors_[i][2] = 0;
215  }
216 
219 
220  }
221 
222  init_ = false;
223 
224 }
225 
227 
228  edm::LogInfo("EEStatusFlagsTask") << "analyzed " << ievt_ << " events";
229 
230  if ( enableCleanup_ ) this->cleanup();
231 
232 }
233 
235 
236  if ( ! init_ ) this->setup();
237 
238  ievt_++;
239 
240  // fill bin 0 with number of events in the lumi
242 
244 
245  if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
246 
247  for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
248 
249  if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
250 
251  int ism = Numbers::iSM( *dcchItr, EcalEndcap );
252  float xism = ism + 0.5;
253 
254  if ( meEvtType_[ism-1] ) meEvtType_[ism-1]->Fill(dcchItr->getRunType()+0.5);
255 
256  const std::vector<short> status = dcchItr->getFEStatus();
257 
258  for ( unsigned int itt=1; itt<=status.size(); itt++ ) {
259 
260  if ( itt > 70 ) continue;
261 
262  if ( itt >= 42 && itt <= 68 ) continue;
263 
264  if ( ( ism == 8 || ism == 17 ) && ( itt >= 18 && itt <= 24 ) ) continue;
265 
266  if ( itt >= 1 && itt <= 41 ) {
267 
268  std::vector<DetId>* crystals = Numbers::crystals( dcchItr->id(), itt );
269 
270  for ( unsigned int i=0; i<crystals->size(); i++ ) {
271 
272  EEDetId id = (*crystals)[i];
273 
274  int ix = id.ix();
275  int iy = id.iy();
276 
277  if ( ism >= 1 && ism <= 9 ) ix = 101 - ix;
278 
279  float xix = ix - 0.5;
280  float xiy = iy - 0.5;
281 
282  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 ) ) {
283  if ( meFEchErrors_[ism-1][0] ) meFEchErrors_[ism-1][0]->Fill(xix, xiy);
284  if ( meFEchErrorsByLumi_ ) meFEchErrorsByLumi_->Fill(xism, 1./34./crystals->size());
285  }
286 
287  }
288 
289  } else if ( itt == 69 || itt == 70 ) {
290 
291  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 ) ) {
292  if ( meFEchErrors_[ism-1][1] ) meFEchErrors_[ism-1][1]->Fill(itt-68-0.5, 0);
293  }
294 
295  }
296 
297  if ( meFEchErrors_[ism-1][2] ) meFEchErrors_[ism-1][2]->Fill(status[itt-1]+0.5);
298 
299  }
300 
301  }
302 
303  } else {
304 
305  edm::LogWarning("EEStatusFlagsTask") << EcalRawDataCollection_ << " not available";
306 
307  }
308 
309 }
310 
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
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:514
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2311
static int iy0EE(const int ism)
Definition: Numbers.cc:987
Some &quot;id&quot; conversions.
virtual ~EEStatusFlagsTask()
Destructor.
static std::string sEE(const int ism)
Definition: Numbers.cc:205
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.
MonitorElement * meEvtType_[18]
void Fill(long long x)
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1151
static std::vector< DetId > * crystals(const EcalTrigTowerDetId &id)
Definition: Numbers.cc:740
static int iSM(const int ism, const EcalSubdetector subdet)
Definition: Numbers.cc:222
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2353
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:355
EEStatusFlagsTask(const edm::ParameterSet &ps)
Constructor.
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:45
edm::InputTag EcalRawDataCollection_
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
static int ix0EE(const int ism)
Definition: Numbers.cc:952
static EcalSubdetector subDet(const EBDetId &id)
Definition: Numbers.cc:136
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:642
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:232
Definition: Run.h:32
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.