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 
18 
19 //Run Info
23 
24 #include <iostream>
25 #include <iomanip>
26 #include <stdio.h>
27 #include <string>
28 #include <sstream>
29 #include <math.h>
30 //
31 // -- Contructor
32 //
34  // Create MessageSender
35  edm::LogInfo( "SiStripCertificationInfo") << "SiStripCertificationInfo::Deleting SiStripCertificationInfo ";
36  // get back-end interface
40 }
42  edm::LogInfo("SiStripCertificationInfo") << "SiStripCertificationInfo::Deleting SiStripCertificationInfo ";
43 
44 }
45 //
46 // -- Begin Job
47 //
49 
50 }
51 //
52 // -- Begin Run
53 //
55 
56  edm::LogInfo ("SiStripCertificationInfo") <<"SiStripCertificationInfo:: Begining of Run";
57  unsigned long long cacheID = eSetup.get<SiStripDetCablingRcd>().cacheIdentifier();
58  if (m_cacheID_ != cacheID) {
59  m_cacheID_ = cacheID;
60  }
61  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
62 
63  nFEDConnected_ = 0;
64  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
65  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
66 
68  if( eSetup.find( recordKey ) != 0) {
69 
71  eSetup.get<RunInfoRcd>().get(sumFED);
72 
73  if ( sumFED.isValid() ) {
74  std::vector<int> FedsInIds= sumFED->m_fed_in;
75  for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
76  int fedID = FedsInIds[it];
77  if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDConnected_;
78  }
79  LogDebug ("SiStripDcsInfo") << " SiStripDcsInfo :: Connected FEDs " << nFEDConnected_;
80  }
81  }
82 
87 
88 }
89 //
90 // -- Book MEs for SiStrip Sertification fractions
91 //
94  dqmStore_->cd();
95  std::string strip_dir = "";
96  SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
97  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
98  else dqmStore_->setCurrentFolder("SiStrip/EventInfo");
99 
100  SiStripCertification = dqmStore_->bookFloat("CertificationSummary");
101 
102  std::string hname = "CertificationReportMap";
103  std::string htitle = "SiStrip Certification for Good Detector Fraction";
104  SiStripCertificationSummaryMap = dqmStore_->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
105  SiStripCertificationSummaryMap->setAxisTitle("Sub Detector Type", 1);
106  SiStripCertificationSummaryMap->setAxisTitle("Layer/Disc Number", 2);
107  int ibin = 0;
108  for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
109  it != SubDetMEsMap.end(); it++) {
110  ibin++;
111  std::string det = it->first;
113  }
114 
115  SubDetMEs local_mes;
117  dqmStore_->cd();
118  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo/CertificationContents");
119  else dqmStore_->setCurrentFolder("SiStrip/EventInfo/CertificationContents");
120  tag = "TIB";
121 
122  local_mes.folder_name = "TIB";
123  local_mes.subdet_tag = "TIB";
124  local_mes.n_layer = 4;
125  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
126  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
127 
128  tag = "TOB";
129  local_mes.folder_name = "TOB";
130  local_mes.subdet_tag = "TOB";
131  local_mes.n_layer = 6;
132  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
133  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
134 
135  tag = "TECF";
136  local_mes.folder_name = "TEC/side_2";
137  local_mes.subdet_tag = "TEC+";
138  local_mes.n_layer = 9;
139  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
140  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
141 
142  tag = "TECB";
143  local_mes.folder_name = "TEC/side_1";
144  local_mes.subdet_tag = "TEC-";
145  local_mes.n_layer = 9;
146  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
147  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
148 
149  tag = "TIDF";
150  local_mes.folder_name = "TID/side_2";
151  local_mes.subdet_tag = "TID+";
152  local_mes.n_layer = 3;
153  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
154  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
155 
156  tag = "TIDB";
157  local_mes.folder_name = "TID/side_1";
158  local_mes.subdet_tag = "TID-";
159  local_mes.n_layer = 3;
160  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
161  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
162 
163  dqmStore_->cd();
164  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
165 
167  dqmStore_->cd();
168  }
169 }
170 //
171 // -- Book MEs for SiStrip Sertification fractions
172 //
175  std::string tracking_dir = "";
176  SiStripUtility::getTopFolderPath(dqmStore_, "Tracking", tracking_dir);
177  if (tracking_dir.size() > 0) {
178  dqmStore_->setCurrentFolder(tracking_dir+"/EventInfo");
179  TrackingCertification = dqmStore_->bookFloat("CertificationSummary");
180 
181  dqmStore_->setCurrentFolder(tracking_dir+"/EventInfo/CertificationContents");
182 
184  MonitorElement* me;
185  type = "Rate";
186  me = dqmStore_->bookFloat("Track"+type);
187  TrackingMEsMap.insert(std::pair<std::string,MonitorElement*>(type,me));
188 
189  type = "Chi2";
190  me = dqmStore_->bookFloat("Track"+type);
191  TrackingMEsMap.insert(std::pair<std::string,MonitorElement*>(type,me));
192 
193  type = "RecHits";
194  me = dqmStore_->bookFloat("Track"+type);
195  TrackingMEsMap.insert(std::pair<std::string,MonitorElement*>(type,me));
196 
198  dqmStore_->cd();
199  }
200  }
201 }
202 //
203 // -- Analyze
204 //
206 }
207 //
208 // -- End Luminosity Block
209 //
211  edm::LogInfo( "SiStripDaqInfo") << "SiStripDaqInfo::endLuminosityBlock";
212 
213  if (nFEDConnected_ > 0) {
216  }
217 }
218 
219 //
220 // -- End of Run
221 //
223  edm::LogInfo ("SiStripCertificationInfo") <<"SiStripCertificationInfo:: End Run";
224 
225  if (nFEDConnected_ > 0) {
228  }
229 }
230 //
231 // --Fill Tracking Certification
232 //
235  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillTrackingCertificationMEs : MEs missing ";
236  return;
237  }
238  std::string tk_dir = "";
239  SiStripUtility::getTopFolderPath(dqmStore_, "Tracking", tk_dir);
240  if (tk_dir.size() == 0) {
242  return;
243  }
244 
245  std::vector<MonitorElement*> all_mes = dqmStore_->getContents(tk_dir+"/EventInfo/reportSummaryContents");
246  float fval = 1.0;
247  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
248  it!= all_mes.end(); it++) {
249  MonitorElement * me = (*it);
250  if (!me) continue;
251  if (me->kind() == MonitorElement::DQM_KIND_REAL) {
252  std::string name = me->getName();
253  float val = me->getFloatValue();
254  for (std::map<std::string, MonitorElement*>::const_iterator it = TrackingMEsMap.begin();
255  it != TrackingMEsMap.end(); it++) {
256  std::string type = it->first;
257  if (name.find(type) != std::string::npos) {
258  it->second->Fill(val);
259  break;
260  }
261  }
262  fval *= val;
263  }
264  }
265  TrackingCertification->Fill(fval);
266 }
267 //
268 // --Fill SiStrip Certification
269 //
272  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillSiStripCertificationMEs : MEs missing ";
273  return;
274  }
275 
276  //Retrieve tracker topology from geometry
277  edm::ESHandle<TrackerTopology> tTopoHandle;
278  eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
279  const TrackerTopology* const tTopo = tTopoHandle.product();
280 
282  std::string mdir = "MechanicalView";
283  dqmStore_->cd();
284  if (!SiStripUtility::goToDir(dqmStore_, mdir)) return;
285  std::string mechanical_dir = dqmStore_->pwd();
286  uint16_t nDetTot = 0;
287  uint16_t nFaultyTot = 0;
288  uint16_t nSToNTot = 0;
289  float sToNTot = 0.0;
290  SiStripFolderOrganizer folder_organizer;
291  int xbin = 0;
292  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
293  it != SubDetMEsMap.end(); it++) {
294  xbin++;
295  std::string name = it->first;
296  std::string tag = it->second.subdet_tag;
297  MonitorElement* me = it->second.det_fractionME;
298  if (!me) continue;
299  std::string bad_module_folder = mechanical_dir+"/"+it->second.folder_name+"/"+"BadModuleList";
300  std::vector<MonitorElement *> faulty_detMEs = dqmStore_->getContents(bad_module_folder);
301 
302  uint16_t ndet_subdet = 0;
303  uint16_t nfaulty_subdet = 0;
304  int nlayer = it->second.n_layer;
305  int ybin = 0;
306  for (int ilayer = 0; ilayer < nlayer; ilayer++) {
307  uint16_t ndet_layer = detCabling_->connectedNumber(tag, ilayer+1);
308  ndet_subdet += ndet_layer;
309  ybin++;
310  uint16_t nfaulty_layer = 0;
311  for (std::vector<MonitorElement *>::iterator im = faulty_detMEs.begin(); im != faulty_detMEs.end(); im++) {
312  if ((*im)->kind() != MonitorElement::DQM_KIND_INT ) continue;
313  if ((*im)->getIntValue() == 0) continue;
314  uint32_t detId = atoi((*im)->getName().c_str());
315  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detId, tTopo, false);
316  if (abs(det_layer_pair.second) == ilayer+1) nfaulty_layer++;
317  }
318 
319  nfaulty_subdet += nfaulty_layer;
320  float fraction_layer = -1.0;
321  if ( ndet_layer > 0) fraction_layer = 1 - ((nfaulty_layer*1.0)/ndet_layer);
322  if (SiStripCertificationSummaryMap) SiStripCertificationSummaryMap->Fill(xbin, ilayer+1,fraction_layer);
323  }
324  if (ybin <= SiStripCertificationSummaryMap->getNbinsY()) {
325  for (int k = ybin+1; k <= SiStripCertificationSummaryMap->getNbinsY(); k++) SiStripCertificationSummaryMap->Fill(xbin, k, -1.0);
326  }
327  float fraction_subdet = -1.0;
328  if (ndet_subdet > 0) fraction_subdet = 1 - ((nfaulty_subdet*1.0)/ndet_subdet);
329  // Check S/N status flag and use the minimum between the two
330  std::string full_path = mechanical_dir.substr(0, mechanical_dir.find_last_of("/"))
331  + "/EventInfo/reportSummaryContents/SiStrip_SToNFlag_"+name;
332  MonitorElement* me_ston = dqmStore_->get(full_path);
333  me->Reset();
334  if (me_ston && me_ston->kind()==MonitorElement::DQM_KIND_REAL) {
335  float ston_flg = me_ston->getFloatValue();
336  sToNTot += ston_flg;
337  nSToNTot++;
338  me->Fill(fminf(fraction_subdet,ston_flg));
339  } else me->Fill(fraction_subdet);
340  nDetTot += ndet_subdet ;
341  nFaultyTot += nfaulty_subdet;
342  }
343  float fraction_global = -1.0;
344  if (nDetTot > 0) fraction_global = 1.0 - ((nFaultyTot*1.0)/nDetTot);
345  float ston_frac_global = 1.0;
346  if (nSToNTot > 0) ston_frac_global = sToNTot/nSToNTot;
347  SiStripCertification->Fill(fminf(fraction_global,ston_frac_global));
348 }
349 //
350 // --Reset Tracking Certification
351 //
356  for (std::map<std::string, MonitorElement*>::const_iterator it = TrackingMEsMap.begin();
357  it != TrackingMEsMap.end(); it++) {
358  it->second->Reset();
359  }
360  }
361 }
362 //
363 // --Fill SiStrip Certification
364 //
369  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
370  it != SubDetMEsMap.end(); it++) {
371  it->second.det_fractionME->Reset();
372  }
374  }
375 }
376 //
377 // -- Fill Dummy SiStrip Certification
378 //
382  SiStripCertification->Fill(-1.0);
383  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
384  it != SubDetMEsMap.end(); it++) {
385  it->second.det_fractionME->Reset();
386  it->second.det_fractionME->Fill(-1.0);
387  }
388 
389  for (int xbin = 1; xbin < SiStripCertificationSummaryMap->getNbinsX()+1; xbin++) {
390  for (int ybin = 1; ybin < SiStripCertificationSummaryMap->getNbinsY()+1; ybin++) {
391  SiStripCertificationSummaryMap->Fill(xbin, ybin, -1.0);
392  }
393  }
394  }
395 }
396 //
397 // -- Fill Dummy Tracking Certification
398 //
403  for (std::map<std::string, MonitorElement*>::const_iterator it = TrackingMEsMap.begin();
404  it != TrackingMEsMap.end(); it++) {
405  it->second->Fill(-1.0);
406  }
407 
408  }
409 }
410 //
411 // --Fill SiStrip Certification
412 //
415  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillSiStripCertificationMEsAtLumi : MEs missing ";
416  return;
417  }
419  dqmStore_->cd();
420  std::string strip_dir = "";
421  SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
422  if (strip_dir.size() == 0) strip_dir = "SiStrip";
423 
424  std::string full_path;
425  float dcs_flag = 1.0;
426  float dqm_flag = 1.0;
427  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
428  it != SubDetMEsMap.end(); it++) {
429  std::string type = it->first;
430  full_path = strip_dir + "/EventInfo/DCSContents/SiStrip_" + type;
431  MonitorElement* me_dcs = dqmStore_->get(full_path);
432  if (me_dcs && me_dcs->kind() == MonitorElement::DQM_KIND_REAL) dcs_flag = me_dcs->getFloatValue();
433  full_path = strip_dir + "/EventInfo/reportSummaryContents/SiStrip_" + type;
434  MonitorElement* me_dqm = dqmStore_->get(full_path);
435  if (me_dqm && me_dqm->kind() == MonitorElement::DQM_KIND_REAL) dqm_flag = me_dqm->getFloatValue();
436  it->second.det_fractionME->Reset();
437  it->second.det_fractionME->Fill(fminf(dqm_flag,dcs_flag));
438  }
439  dcs_flag = 1.0;
440  dqm_flag = 1.0;
441  full_path = strip_dir + "/EventInfo/reportSummary";
442  MonitorElement* me_dqm = dqmStore_->get(full_path);
443  if (me_dqm && me_dqm->kind() == MonitorElement::DQM_KIND_REAL) dqm_flag = me_dqm->getFloatValue();
444  full_path = strip_dir + "/EventInfo/DCSSummary";
445  MonitorElement* me_dcs = dqmStore_->get(full_path);
446  if (me_dcs && me_dcs->kind() == MonitorElement::DQM_KIND_REAL) dcs_flag = me_dcs->getFloatValue();
448  SiStripCertification->Fill(fminf(dqm_flag,dcs_flag));
449 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
const std::string & getName(void) const
get name of ME
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:411
#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.
void fillSiStripCertificationMEs(edm::EventSetup const &eSetup)
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=0)
std::map< std::string, MonitorElement * > TrackingMEsMap
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:659
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
void fillTrackingCertificationMEs(edm::EventSetup const &eSetup)
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:1473
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:1502
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
T const * product() const
Definition: ESHandle.h:62
MonitorElement * SiStripCertificationSummaryMap
int getNbinsX(void) const
get # of bins in X-axis
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:850
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:434
Definition: Run.h:36
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:406
static void getTopFolderPath(DQMStore *dqm_store, std::string type, std::string &path)