CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripCertificationInfo.cc
Go to the documentation of this file.
4 
10 
14 
20 
21 //Run Info
25 
26 #include <iostream>
27 #include <iomanip>
28 #include <stdio.h>
29 #include <string>
30 #include <sstream>
31 #include <math.h>
32 //
33 // -- Contructor
34 //
36  // Create MessageSender
37  edm::LogInfo( "SiStripCertificationInfo") << "SiStripCertificationInfo::Deleting SiStripCertificationInfo ";
38  // get back-end interface
42 }
44  edm::LogInfo("SiStripCertificationInfo") << "SiStripCertificationInfo::Deleting SiStripCertificationInfo ";
45 
46 }
47 //
48 // -- Begin Job
49 //
51 
52 }
53 //
54 // -- Begin Run
55 //
57 
58  edm::LogInfo ("SiStripCertificationInfo") <<"SiStripCertificationInfo:: Begining of Run";
59  unsigned long long cacheID = eSetup.get<SiStripDetCablingRcd>().cacheIdentifier();
60  if (m_cacheID_ != cacheID) {
61  m_cacheID_ = cacheID;
62  }
63  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
64 
65  nFEDConnected_ = 0;
66  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
67  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
68 
70  if( eSetup.find( recordKey ) != 0) {
71 
73  eSetup.get<RunInfoRcd>().get(sumFED);
74 
75  if ( sumFED.isValid() ) {
76  std::vector<int> FedsInIds= sumFED->m_fed_in;
77  for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
78  int fedID = FedsInIds[it];
79  if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDConnected_;
80  }
81  LogDebug ("SiStripDcsInfo") << " SiStripDcsInfo :: Connected FEDs " << nFEDConnected_;
82  }
83  }
84 
89 
90 }
91 //
92 // -- Book MEs for SiStrip Sertification fractions
93 //
96  dqmStore_->cd();
97  std::string strip_dir = "";
98  SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
99  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
100  else dqmStore_->setCurrentFolder("SiStrip/EventInfo");
101 
102  SiStripCertification = dqmStore_->bookFloat("CertificationSummary");
103 
104  std::string hname = "CertificationReportMap";
105  std::string htitle = "SiStrip Certification for Good Detector Fraction";
106  SiStripCertificationSummaryMap = dqmStore_->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
107  SiStripCertificationSummaryMap->setAxisTitle("Sub Detector Type", 1);
108  SiStripCertificationSummaryMap->setAxisTitle("Layer/Disc Number", 2);
109  int ibin = 0;
110  for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
111  it != SubDetMEsMap.end(); it++) {
112  ibin++;
113  std::string det = it->first;
115  }
116 
117  SubDetMEs local_mes;
118  std::string tag;
119  dqmStore_->cd();
120  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo/CertificationContents");
121  else dqmStore_->setCurrentFolder("SiStrip/EventInfo/CertificationContents");
122  tag = "TIB";
123 
124  local_mes.folder_name = "TIB";
125  local_mes.subdet_tag = "TIB";
126  local_mes.n_layer = 4;
127  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
128  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
129 
130  tag = "TOB";
131  local_mes.folder_name = "TOB";
132  local_mes.subdet_tag = "TOB";
133  local_mes.n_layer = 6;
134  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
135  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
136 
137  tag = "TECF";
138  local_mes.folder_name = "TEC/side_2";
139  local_mes.subdet_tag = "TEC+";
140  local_mes.n_layer = 9;
141  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
142  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
143 
144  tag = "TECB";
145  local_mes.folder_name = "TEC/side_1";
146  local_mes.subdet_tag = "TEC-";
147  local_mes.n_layer = 9;
148  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
149  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
150 
151  tag = "TIDF";
152  local_mes.folder_name = "TID/side_2";
153  local_mes.subdet_tag = "TID+";
154  local_mes.n_layer = 3;
155  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
156  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
157 
158  tag = "TIDB";
159  local_mes.folder_name = "TID/side_1";
160  local_mes.subdet_tag = "TID-";
161  local_mes.n_layer = 3;
162  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
163  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
164 
165  dqmStore_->cd();
166  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
167 
169  dqmStore_->cd();
170  }
171 }
172 //
173 // -- Book MEs for SiStrip Sertification fractions
174 //
177  std::string tracking_dir = "";
178  SiStripUtility::getTopFolderPath(dqmStore_, "Tracking", tracking_dir);
179  if (tracking_dir.size() > 0) {
180  dqmStore_->setCurrentFolder(tracking_dir+"/EventInfo");
181  TrackingCertification = dqmStore_->bookFloat("CertificationSummary");
182 
183  dqmStore_->setCurrentFolder(tracking_dir+"/EventInfo/CertificationContents");
184 
185  std::string type;
186  MonitorElement* me;
187  type = "Rate";
188  me = dqmStore_->bookFloat("Track"+type);
189  TrackingMEsMap.insert(std::pair<std::string,MonitorElement*>(type,me));
190 
191  type = "Chi2";
192  me = dqmStore_->bookFloat("Track"+type);
193  TrackingMEsMap.insert(std::pair<std::string,MonitorElement*>(type,me));
194 
195  type = "RecHits";
196  me = dqmStore_->bookFloat("Track"+type);
197  TrackingMEsMap.insert(std::pair<std::string,MonitorElement*>(type,me));
198 
200  dqmStore_->cd();
201  }
202  }
203 }
204 //
205 // -- Analyze
206 //
208 }
209 //
210 // -- End Luminosity Block
211 //
213  edm::LogInfo( "SiStripDaqInfo") << "SiStripDaqInfo::endLuminosityBlock";
214 
215  if (nFEDConnected_ > 0) {
218  }
219 }
220 
221 //
222 // -- End of Run
223 //
225  edm::LogInfo ("SiStripCertificationInfo") <<"SiStripCertificationInfo:: End Run";
226 
227  if (nFEDConnected_ > 0) {
230  }
231 }
232 //
233 // --Fill Tracking Certification
234 //
237  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillTrackingCertificationMEs : MEs missing ";
238  return;
239  }
240  std::string tk_dir = "";
241  SiStripUtility::getTopFolderPath(dqmStore_, "Tracking", tk_dir);
242  if (tk_dir.size() == 0) {
244  return;
245  }
246 
247  std::vector<MonitorElement*> all_mes = dqmStore_->getContents(tk_dir+"/EventInfo/reportSummaryContents");
248  float fval = 1.0;
249  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
250  it!= all_mes.end(); it++) {
251  MonitorElement * me = (*it);
252  if (!me) continue;
253  if (me->kind() == MonitorElement::DQM_KIND_REAL) {
254  std::string name = me->getName();
255  float val = me->getFloatValue();
256  for (std::map<std::string, MonitorElement*>::const_iterator it = TrackingMEsMap.begin();
257  it != TrackingMEsMap.end(); it++) {
258  std::string type = it->first;
259  if (name.find(type) != std::string::npos) {
260  it->second->Fill(val);
261  break;
262  }
263  }
264  fval *= val;
265  }
266  }
267  TrackingCertification->Fill(fval);
268 }
269 //
270 // --Fill SiStrip Certification
271 //
274  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillSiStripCertificationMEs : MEs missing ";
275  return;
276  }
278  std::string mdir = "MechanicalView";
279  dqmStore_->cd();
280  if (!SiStripUtility::goToDir(dqmStore_, mdir)) return;
281  std::string mechanical_dir = dqmStore_->pwd();
282  uint16_t nDetTot = 0;
283  uint16_t nFaultyTot = 0;
284  uint16_t nSToNTot = 0;
285  float sToNTot = 0.0;
286  SiStripFolderOrganizer folder_organizer;
287  int xbin = 0;
288  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
289  it != SubDetMEsMap.end(); it++) {
290  xbin++;
291  std::string name = it->first;
292  std::string tag = it->second.subdet_tag;
293  MonitorElement* me = it->second.det_fractionME;
294  if (!me) continue;
295  std::string bad_module_folder = mechanical_dir+"/"+it->second.folder_name+"/"+"BadModuleList";
296  std::vector<MonitorElement *> faulty_detMEs = dqmStore_->getContents(bad_module_folder);
297 
298  uint16_t ndet_subdet = 0;
299  uint16_t nfaulty_subdet = 0;
300  int nlayer = it->second.n_layer;
301  int ybin = 0;
302  for (int ilayer = 0; ilayer < nlayer; ilayer++) {
303  uint16_t ndet_layer = detCabling_->connectedNumber(tag, ilayer+1);
304  ndet_subdet += ndet_layer;
305  ybin++;
306  uint16_t nfaulty_layer = 0;
307  for (std::vector<MonitorElement *>::iterator im = faulty_detMEs.begin(); im != faulty_detMEs.end(); im++) {
308  if ((*im)->kind() != MonitorElement::DQM_KIND_INT ) continue;
309  if ((*im)->getIntValue() == 0) continue;
310  uint32_t detId = atoi((*im)->getName().c_str());
311  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detId, false);
312  if (abs(det_layer_pair.second) == ilayer+1) nfaulty_layer++;
313  }
314 
315  nfaulty_subdet += nfaulty_layer;
316  float fraction_layer = -1.0;
317  if ( ndet_layer > 0) fraction_layer = 1 - ((nfaulty_layer*1.0)/ndet_layer);
318  if (SiStripCertificationSummaryMap) SiStripCertificationSummaryMap->Fill(xbin, ilayer+1,fraction_layer);
319  }
320  if (ybin <= SiStripCertificationSummaryMap->getNbinsY()) {
321  for (int k = ybin+1; k <= SiStripCertificationSummaryMap->getNbinsY(); k++) SiStripCertificationSummaryMap->Fill(xbin, k, -1.0);
322  }
323  float fraction_subdet = -1.0;
324  if (ndet_subdet > 0) fraction_subdet = 1 - ((nfaulty_subdet*1.0)/ndet_subdet);
325  // Check S/N status flag and use the minimum between the two
326  std::string full_path = mechanical_dir.substr(0, mechanical_dir.find_last_of("/"))
327  + "/EventInfo/reportSummaryContents/SiStrip_SToNFlag_"+name;
328  MonitorElement* me_ston = dqmStore_->get(full_path);
329  me->Reset();
330  if (me_ston && me_ston->kind()==MonitorElement::DQM_KIND_REAL) {
331  float ston_flg = me_ston->getFloatValue();
332  sToNTot += ston_flg;
333  nSToNTot++;
334  me->Fill(fminf(fraction_subdet,ston_flg));
335  } else me->Fill(fraction_subdet);
336  nDetTot += ndet_subdet ;
337  nFaultyTot += nfaulty_subdet;
338  }
339  float fraction_global = -1.0;
340  if (nDetTot > 0) fraction_global = 1.0 - ((nFaultyTot*1.0)/nDetTot);
341  float ston_frac_global = 1.0;
342  if (nSToNTot > 0) ston_frac_global = sToNTot/nSToNTot;
343  SiStripCertification->Fill(fminf(fraction_global,ston_frac_global));
344 }
345 //
346 // --Reset Tracking Certification
347 //
352  for (std::map<std::string, MonitorElement*>::const_iterator it = TrackingMEsMap.begin();
353  it != TrackingMEsMap.end(); it++) {
354  it->second->Reset();
355  }
356  }
357 }
358 //
359 // --Fill SiStrip Certification
360 //
365  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
366  it != SubDetMEsMap.end(); it++) {
367  it->second.det_fractionME->Reset();
368  }
370  }
371 }
372 //
373 // -- Fill Dummy SiStrip Certification
374 //
378  SiStripCertification->Fill(-1.0);
379  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
380  it != SubDetMEsMap.end(); it++) {
381  it->second.det_fractionME->Reset();
382  it->second.det_fractionME->Fill(-1.0);
383  }
384 
385  for (int xbin = 1; xbin < SiStripCertificationSummaryMap->getNbinsX()+1; xbin++) {
386  for (int ybin = 1; ybin < SiStripCertificationSummaryMap->getNbinsY()+1; ybin++) {
387  SiStripCertificationSummaryMap->Fill(xbin, ybin, -1.0);
388  }
389  }
390  }
391 }
392 //
393 // -- Fill Dummy Tracking Certification
394 //
399  for (std::map<std::string, MonitorElement*>::const_iterator it = TrackingMEsMap.begin();
400  it != TrackingMEsMap.end(); it++) {
401  it->second->Fill(-1.0);
402  }
403 
404  }
405 }
406 //
407 // --Fill SiStrip Certification
408 //
411  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillSiStripCertificationMEsAtLumi : MEs missing ";
412  return;
413  }
415  dqmStore_->cd();
416  std::string strip_dir = "";
417  SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
418  if (strip_dir.size() == 0) strip_dir = "SiStrip";
419 
420  std::string full_path;
421  float dcs_flag = 1.0;
422  float dqm_flag = 1.0;
423  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
424  it != SubDetMEsMap.end(); it++) {
425  std::string type = it->first;
426  full_path = strip_dir + "/EventInfo/DCSContents/SiStrip_" + type;
427  MonitorElement* me_dcs = dqmStore_->get(full_path);
428  if (me_dcs && me_dcs->kind() == MonitorElement::DQM_KIND_REAL) dcs_flag = me_dcs->getFloatValue();
429  full_path = strip_dir + "/EventInfo/reportSummaryContents/SiStrip_" + type;
430  MonitorElement* me_dqm = dqmStore_->get(full_path);
431  if (me_dqm && me_dqm->kind() == MonitorElement::DQM_KIND_REAL) dqm_flag = me_dqm->getFloatValue();
432  it->second.det_fractionME->Reset();
433  it->second.det_fractionME->Fill(fminf(dqm_flag,dcs_flag));
434  }
435  dcs_flag = 1.0;
436  dqm_flag = 1.0;
437  full_path = strip_dir + "/EventInfo/reportSummary";
438  MonitorElement* me_dqm = dqmStore_->get(full_path);
439  if (me_dqm && me_dqm->kind() == MonitorElement::DQM_KIND_REAL) dqm_flag = me_dqm->getFloatValue();
440  full_path = strip_dir + "/EventInfo/DCSSummary";
441  MonitorElement* me_dcs = dqmStore_->get(full_path);
442  if (me_dcs && me_dcs->kind() == MonitorElement::DQM_KIND_REAL) dcs_flag = me_dcs->getFloatValue();
444  SiStripCertification->Fill(fminf(dqm_flag,dcs_flag));
445 }
#define LogDebug(id)
type
Definition: HCALResponse.h:22
const std::string & getName(void) const
get name of ME
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:406
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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)
#define abs(x)
Definition: mlp_lapack.h:159
void analyze(edm::Event const &, edm::EventSetup const &)
Analyze.
std::map< std::string, MonitorElement * > TrackingMEsMap
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
int getNbinsY(void) const
get # of bins in Y-axis
void Fill(long long x)
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &iSetup)
End Of Luminosity.
std::map< std::string, SubDetMEs > SubDetMEsMap
double getFloatValue(void) const
SiStripCertificationInfo(const edm::ParameterSet &ps)
Constructor.
Kind kind(void) const
Get the type of the monitor element.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1497
virtual ~SiStripCertificationInfo()
Destructor.
int k[5][pyjets_maxn]
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
EndRun.
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
Begin Run.
const T & get() const
Definition: EventSetup.h:55
MonitorElement * SiStripCertificationSummaryMap
int getNbinsX(void) const
get # of bins in X-axis
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, bool ring_flag=0)
edm::ESHandle< SiStripDetCabling > detCabling_
bool isValid() const
Definition: ESHandle.h:37
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
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)
static bool goToDir(DQMStore *dqm_store, std::string name)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:129
const std::string & pwd(void) const
Definition: DQMStore.cc:401
static void getTopFolderPath(DQMStore *dqm_store, std::string type, std::string &path)