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  * $Date: 2012/04/27 13:46:03 $
5  * $Revision: 1.37 $
6  * \author G. Della Ricca
7  *
8 */
9 
10 #include <iostream>
11 #include <fstream>
12 #include <vector>
13 
16 
18 
20 
22 
24 
26 
28 
29  init_ = false;
30 
32 
33  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
34 
35  subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
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 < 36; 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_ + "/EBStatusFlagsTask");
65  if(subfolder_.size())
66  dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask/" + subfolder_);
67  dqmStore_->rmdir(prefixME_ + "/EBStatusFlagsTask");
68  }
69 
70 }
71 
73 
75 
76 }
77 
79 }
80 
82 
83  Numbers::initGeometry(c, false);
84 
85  if ( ! mergeRuns_ ) this->reset();
86 
87 }
88 
90 
91 }
92 
94 
95  for (int i = 0; i < 36; i++) {
96  if ( meEvtType_[i] ) meEvtType_[i]->Reset();
97 
98  if ( meFEchErrors_[i][0] ) meFEchErrors_[i][0]->Reset();
99  if ( meFEchErrors_[i][1] ) meFEchErrors_[i][1]->Reset();
100  if ( meFEchErrors_[i][2] ) meFEchErrors_[i][2]->Reset();
101  }
103 }
104 
106 
107  init_ = true;
108 
109  std::string name;
110  std::string dir;
111 
112  if ( dqmStore_ ) {
113  dir = prefixME_ + "/EBStatusFlagsTask";
114  if(subfolder_.size())
115  dir = prefixME_ + "/EBStatusFlagsTask/" + subfolder_;
116 
118 
119  dqmStore_->setCurrentFolder(dir + "/EvtType");
120  for (int i = 0; i < 36; i++) {
121  name = "EBSFT EVTTYPE " + Numbers::sEB(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 < 36; i++) {
152  name = "EBSFT front-end status " + Numbers::sEB(i+1);
153  meFEchErrors_[i][0] = dqmStore_->book2D(name, name, 17, 0., 17., 4, 0., 4.);
154  meFEchErrors_[i][0]->setAxisTitle("ieta'", 1);
155  meFEchErrors_[i][0]->setAxisTitle("iphi'", 2);
156  dqmStore_->tag(meFEchErrors_[i][0], i+1);
157 
158  name = "EBSFT MEM front-end status " + Numbers::sEB(i+1);
159  meFEchErrors_[i][1] = dqmStore_->book2D(name, name, 2, 0., 2., 1, 0., 1.);
160  meFEchErrors_[i][1]->setAxisTitle("pseudo-strip", 1);
161  meFEchErrors_[i][1]->setAxisTitle("channel", 2);
162  dqmStore_->tag(meFEchErrors_[i][1], i+1);
163 
164  name = "EBSFT front-end status bits " + Numbers::sEB(i+1);
165  meFEchErrors_[i][2] = dqmStore_->book1D(name, name, 16, 0., 16.);
166  meFEchErrors_[i][2]->setBinLabel(1+0, "ACTIVE", 1);
167  meFEchErrors_[i][2]->setBinLabel(1+1, "DISABLED", 1);
168  meFEchErrors_[i][2]->setBinLabel(1+2, "TIMEOUT", 1);
169  meFEchErrors_[i][2]->setBinLabel(1+3, "HEADER", 1);
170  meFEchErrors_[i][2]->setBinLabel(1+4, "CHANNEL ID", 1);
171  meFEchErrors_[i][2]->setBinLabel(1+5, "LINK", 1);
172  meFEchErrors_[i][2]->setBinLabel(1+6, "BLOCKSIZE", 1);
173  meFEchErrors_[i][2]->setBinLabel(1+7, "SUPPRESSED", 1);
174  meFEchErrors_[i][2]->setBinLabel(1+8, "FORCED FS", 1);
175  meFEchErrors_[i][2]->setBinLabel(1+9, "L1A SYNC", 1);
176  meFEchErrors_[i][2]->setBinLabel(1+10, "BX SYNC", 1);
177  meFEchErrors_[i][2]->setBinLabel(1+11, "L1A+BX SYNC", 1);
178  meFEchErrors_[i][2]->setBinLabel(1+12, "FIFO FULL+L1A", 1);
179  meFEchErrors_[i][2]->setBinLabel(1+13, "H PARITY", 1);
180  meFEchErrors_[i][2]->setBinLabel(1+14, "V PARITY", 1);
181  meFEchErrors_[i][2]->setBinLabel(1+15, "FORCED ZS", 1);
182  dqmStore_->tag(meFEchErrors_[i][2], i+1);
183  }
184 
185  // checking the number of front-end errors in each DCC for each lumi
186  // tower error is weighted by 1/68
187  // bin 0 contains the number of processed events in the lumi (for normalization)
188  name = "EBSFT weighted frontend errors by lumi";
189  meFEchErrorsByLumi_ = dqmStore_->book1D(name, name, 36, 1., 37.);
191  for (int i = 0; i < 36; i++) {
193  }
194 
195  }
196 
197 }
198 
200 
201  if ( ! init_ ) return;
202 
203  if ( dqmStore_ ) {
204 
205  std::string dir = prefixME_ + "/EBStatusFlagsTask";
206  if(subfolder_.size())
207  dir = prefixME_ + "/EBStatusFlagsTask/" + subfolder_;
208 
209  dqmStore_->setCurrentFolder(dir + "");
210 
211  dqmStore_->setCurrentFolder(dir + "/EvtType");
212  for (int i = 0; i < 36; i++) {
214  meEvtType_[i] = 0;
215  }
216 
217  dqmStore_->setCurrentFolder(dir + "/FEStatus");
218  for (int i = 0; i < 36; i++) {
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("EBStatusFlagsTask") << "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.getByLabel(EcalRawDataCollection_, dcchs) ) {
256 
257  for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
258 
259  if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
260 
261  int ism = Numbers::iSM( *dcchItr, EcalBarrel );
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 >= 1 && itt <= 68 ) {
273 
274  int iet = (itt-1)/4 + 1;
275  int ipt = (itt-1)%4 + 1;
276 
277  float xiet = iet - 0.5;
278  float xipt = ipt - 0.5;
279 
280  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 ) ) {
281  if ( meFEchErrors_[ism-1][0] ) meFEchErrors_[ism-1][0]->Fill(xiet, xipt);
282  if ( meFEchErrorsByLumi_ ) meFEchErrorsByLumi_->Fill(xism, 1./68.);
283  }
284 
285  } else if ( itt == 69 || itt == 70 ) {
286 
287  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 ) ) {
288  if ( meFEchErrors_[ism-1][1] ) meFEchErrors_[ism-1][1]->Fill(itt-68-0.5, 0);
289  }
290 
291  }
292 
293  if ( meFEchErrors_[ism-1][2] ) meFEchErrors_[ism-1][2]->Fill(status[itt-1]+0.5);
294 
295  }
296 
297  }
298 
299  } else {
300 
301  edm::LogWarning("EBStatusFlagsTask") << EcalRawDataCollection_ << " not available";
302 
303  }
304 
305 }
306 
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:717
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
edm::InputTag EcalRawDataCollection_
Some &quot;id&quot; conversions.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:94
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
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.
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:1354
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
MonitorElement * meFEchErrorsByLumi_
virtual ~EBStatusFlagsTask()
Destructor.
void beginJob(void)
BeginJob.
void endJob(void)
EndJob.
std::string getName(Reflex::Type &cc)
Definition: ClassFiller.cc:18
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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:50
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: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
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)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33