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 FEDNumbering numbering;
67  const int siStripFedIdMin = numbering.MINSiStripFEDID;
68  const int siStripFedIdMax = numbering.MAXSiStripFEDID;
69 
71  if( eSetup.find( recordKey ) != 0) {
72 
74  eSetup.get<RunInfoRcd>().get(sumFED);
75 
76  if ( sumFED.isValid() ) {
77  std::vector<int> FedsInIds= sumFED->m_fed_in;
78  for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
79  int fedID = FedsInIds[it];
80  if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDConnected_;
81  }
82  LogDebug ("SiStripDcsInfo") << " SiStripDcsInfo :: Connected FEDs " << nFEDConnected_;
83  }
84  }
85 
90 
91 }
92 //
93 // -- Book MEs for SiStrip Sertification fractions
94 //
97  dqmStore_->cd();
98  std::string strip_dir = "";
99  SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
100  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
101  else dqmStore_->setCurrentFolder("SiStrip/EventInfo");
102 
103  SiStripCertification = dqmStore_->bookFloat("CertificationSummary");
104 
105  std::string hname = "CertificationReportMap";
106  std::string htitle = "SiStrip Certification for Good Detector Fraction";
107  SiStripCertificationSummaryMap = dqmStore_->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
108  SiStripCertificationSummaryMap->setAxisTitle("Sub Detector Type", 1);
109  SiStripCertificationSummaryMap->setAxisTitle("Layer/Disc Number", 2);
110  int ibin = 0;
111  for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
112  it != SubDetMEsMap.end(); it++) {
113  ibin++;
114  std::string det = it->first;
116  }
117 
118  SubDetMEs local_mes;
119  std::string tag;
120  dqmStore_->cd();
121  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo/CertificationContents");
122  else dqmStore_->setCurrentFolder("SiStrip/EventInfo/CertificationContents");
123  tag = "TIB";
124 
125  local_mes.folder_name = "TIB";
126  local_mes.subdet_tag = "TIB";
127  local_mes.n_layer = 4;
128  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
129  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
130 
131  tag = "TOB";
132  local_mes.folder_name = "TOB";
133  local_mes.subdet_tag = "TOB";
134  local_mes.n_layer = 6;
135  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
136  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
137 
138  tag = "TECF";
139  local_mes.folder_name = "TEC/side_2";
140  local_mes.subdet_tag = "TEC+";
141  local_mes.n_layer = 9;
142  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
143  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
144 
145  tag = "TECB";
146  local_mes.folder_name = "TEC/side_1";
147  local_mes.subdet_tag = "TEC-";
148  local_mes.n_layer = 9;
149  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
150  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
151 
152  tag = "TIDF";
153  local_mes.folder_name = "TID/side_2";
154  local_mes.subdet_tag = "TID+";
155  local_mes.n_layer = 3;
156  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
157  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
158 
159  tag = "TIDB";
160  local_mes.folder_name = "TID/side_1";
161  local_mes.subdet_tag = "TID-";
162  local_mes.n_layer = 3;
163  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
164  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
165 
166  dqmStore_->cd();
167  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
168 
170  dqmStore_->cd();
171  }
172 }
173 //
174 // -- Book MEs for SiStrip Sertification fractions
175 //
178  std::string tracking_dir = "";
179  SiStripUtility::getTopFolderPath(dqmStore_, "Tracking", tracking_dir);
180  if (tracking_dir.size() > 0) {
181  dqmStore_->setCurrentFolder(tracking_dir+"/EventInfo");
182  TrackingCertification = dqmStore_->bookFloat("CertificationSummary");
183 
184  dqmStore_->setCurrentFolder(tracking_dir+"/EventInfo/CertificationContents");
185 
186  std::string type;
187  MonitorElement* me;
188  type = "Rate";
189  me = dqmStore_->bookFloat("Track"+type);
190  TrackingMEsMap.insert(std::pair<std::string,MonitorElement*>(type,me));
191 
192  type = "Chi2";
193  me = dqmStore_->bookFloat("Track"+type);
194  TrackingMEsMap.insert(std::pair<std::string,MonitorElement*>(type,me));
195 
196  type = "RecHits";
197  me = dqmStore_->bookFloat("Track"+type);
198  TrackingMEsMap.insert(std::pair<std::string,MonitorElement*>(type,me));
199 
201  dqmStore_->cd();
202  }
203  }
204 }
205 //
206 // -- Analyze
207 //
209 }
210 //
211 // -- End Luminosity Block
212 //
214  edm::LogInfo( "SiStripDaqInfo") << "SiStripDaqInfo::endLuminosityBlock";
215 
216  if (nFEDConnected_ > 0) {
219  }
220 }
221 
222 //
223 // -- End of Run
224 //
226  edm::LogInfo ("SiStripCertificationInfo") <<"SiStripCertificationInfo:: End Run";
227 
228  if (nFEDConnected_ > 0) {
231  }
232 }
233 //
234 // --Fill Tracking Certification
235 //
238  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillTrackingCertificationMEs : MEs missing ";
239  return;
240  }
241  std::string tk_dir = "";
242  SiStripUtility::getTopFolderPath(dqmStore_, "Tracking", tk_dir);
243  if (tk_dir.size() == 0) {
245  return;
246  }
247 
248  std::vector<MonitorElement*> all_mes = dqmStore_->getContents(tk_dir+"/EventInfo/reportSummaryContents");
249  float fval = 1.0;
250  for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin();
251  it!= all_mes.end(); it++) {
252  MonitorElement * me = (*it);
253  if (!me) continue;
254  if (me->kind() == MonitorElement::DQM_KIND_REAL) {
255  std::string name = me->getName();
256  float val = me->getFloatValue();
257  for (std::map<std::string, MonitorElement*>::const_iterator it = TrackingMEsMap.begin();
258  it != TrackingMEsMap.end(); it++) {
259  std::string type = it->first;
260  if (name.find(type) != std::string::npos) {
261  it->second->Fill(val);
262  break;
263  }
264  }
265  fval *= val;
266  }
267  }
268  TrackingCertification->Fill(fval);
269 }
270 //
271 // --Fill SiStrip Certification
272 //
275  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillSiStripCertificationMEs : MEs missing ";
276  return;
277  }
279  std::string mdir = "MechanicalView";
280  dqmStore_->cd();
281  if (!SiStripUtility::goToDir(dqmStore_, mdir)) return;
282  std::string mechanical_dir = dqmStore_->pwd();
283  uint16_t nDetTot = 0;
284  uint16_t nFaultyTot = 0;
285  uint16_t nSToNTot = 0;
286  float sToNTot = 0.0;
287  SiStripFolderOrganizer folder_organizer;
288  int xbin = 0;
289  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
290  it != SubDetMEsMap.end(); it++) {
291  xbin++;
292  std::string name = it->first;
293  std::string tag = it->second.subdet_tag;
294  MonitorElement* me = it->second.det_fractionME;
295  if (!me) continue;
296  std::string bad_module_folder = mechanical_dir+"/"+it->second.folder_name+"/"+"BadModuleList";
297  std::vector<MonitorElement *> faulty_detMEs = dqmStore_->getContents(bad_module_folder);
298 
299  uint16_t ndet_subdet = 0;
300  uint16_t nfaulty_subdet = 0;
301  int nlayer = it->second.n_layer;
302  int ybin = 0;
303  for (int ilayer = 0; ilayer < nlayer; ilayer++) {
304  uint16_t ndet_layer = detCabling_->connectedNumber(tag, ilayer+1);
305  ndet_subdet += ndet_layer;
306  ybin++;
307  uint16_t nfaulty_layer = 0;
308  for (std::vector<MonitorElement *>::iterator im = faulty_detMEs.begin(); im != faulty_detMEs.end(); im++) {
309  if ((*im)->kind() != MonitorElement::DQM_KIND_INT ) continue;
310  if ((*im)->getIntValue() == 0) continue;
311  uint32_t detId = atoi((*im)->getName().c_str());
312  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detId, false);
313  if (abs(det_layer_pair.second) == ilayer+1) nfaulty_layer++;
314  }
315 
316  nfaulty_subdet += nfaulty_layer;
317  float fraction_layer = -1.0;
318  if ( ndet_layer > 0) fraction_layer = 1 - ((nfaulty_layer*1.0)/ndet_layer);
319  if (SiStripCertificationSummaryMap) SiStripCertificationSummaryMap->Fill(xbin, ilayer+1,fraction_layer);
320  }
321  if (ybin <= SiStripCertificationSummaryMap->getNbinsY()) {
322  for (int k = ybin+1; k <= SiStripCertificationSummaryMap->getNbinsY(); k++) SiStripCertificationSummaryMap->Fill(xbin, k, -1.0);
323  }
324  float fraction_subdet = -1.0;
325  if (ndet_subdet > 0) fraction_subdet = 1 - ((nfaulty_subdet*1.0)/ndet_subdet);
326  // Check S/N status flag and use the minimum between the two
327  std::string full_path = mechanical_dir.substr(0, mechanical_dir.find_last_of("/"))
328  + "/EventInfo/reportSummaryContents/SiStrip_SToNFlag_"+name;
329  MonitorElement* me_ston = dqmStore_->get(full_path);
330  me->Reset();
331  if (me_ston && me_ston->kind()==MonitorElement::DQM_KIND_REAL) {
332  float ston_flg = me_ston->getFloatValue();
333  sToNTot += ston_flg;
334  nSToNTot++;
335  me->Fill(fminf(fraction_subdet,ston_flg));
336  } else me->Fill(fraction_subdet);
337  nDetTot += ndet_subdet ;
338  nFaultyTot += nfaulty_subdet;
339  }
340  float fraction_global = -1.0;
341  if (nDetTot > 0) fraction_global = 1.0 - ((nFaultyTot*1.0)/nDetTot);
342  float ston_frac_global = 1.0;
343  if (nSToNTot > 0) ston_frac_global = sToNTot/nSToNTot;
344  SiStripCertification->Fill(fminf(fraction_global,ston_frac_global));
345 }
346 //
347 // --Reset Tracking Certification
348 //
353  for (std::map<std::string, MonitorElement*>::const_iterator it = TrackingMEsMap.begin();
354  it != TrackingMEsMap.end(); it++) {
355  it->second->Reset();
356  }
357  }
358 }
359 //
360 // --Fill SiStrip Certification
361 //
366  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
367  it != SubDetMEsMap.end(); it++) {
368  it->second.det_fractionME->Reset();
369  }
371  }
372 }
373 //
374 // -- Fill Dummy SiStrip Certification
375 //
379  SiStripCertification->Fill(-1.0);
380  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
381  it != SubDetMEsMap.end(); it++) {
382  it->second.det_fractionME->Reset();
383  it->second.det_fractionME->Fill(-1.0);
384  }
385 
386  for (int xbin = 1; xbin < SiStripCertificationSummaryMap->getNbinsX()+1; xbin++) {
387  for (int ybin = 1; ybin < SiStripCertificationSummaryMap->getNbinsY()+1; ybin++) {
388  SiStripCertificationSummaryMap->Fill(xbin, ybin, -1.0);
389  }
390  }
391  }
392 }
393 //
394 // -- Fill Dummy Tracking Certification
395 //
400  for (std::map<std::string, MonitorElement*>::const_iterator it = TrackingMEsMap.begin();
401  it != TrackingMEsMap.end(); it++) {
402  it->second->Fill(-1.0);
403  }
404 
405  }
406 }
407 //
408 // --Fill SiStrip Certification
409 //
412  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillSiStripCertificationMEsAtLumi : MEs missing ";
413  return;
414  }
416  dqmStore_->cd();
417  std::string strip_dir = "";
418  SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
419  if (strip_dir.size() == 0) strip_dir = "SiStrip";
420 
421  std::string full_path;
422  float dcs_flag = 1.0;
423  float dqm_flag = 1.0;
424  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
425  it != SubDetMEsMap.end(); it++) {
426  std::string type = it->first;
427  full_path = strip_dir + "/EventInfo/DCSContents/SiStrip_" + type;
428  MonitorElement* me_dcs = dqmStore_->get(full_path);
429  if (me_dcs && me_dcs->kind() == MonitorElement::DQM_KIND_REAL) dcs_flag = me_dcs->getFloatValue();
430  full_path = strip_dir + "/EventInfo/reportSummaryContents/SiStrip_" + type;
431  MonitorElement* me_dqm = dqmStore_->get(full_path);
432  if (me_dqm && me_dqm->kind() == MonitorElement::DQM_KIND_REAL) dqm_flag = me_dqm->getFloatValue();
433  it->second.det_fractionME->Reset();
434  it->second.det_fractionME->Fill(fminf(dqm_flag,dcs_flag));
435  }
436  dcs_flag = 1.0;
437  dqm_flag = 1.0;
438  full_path = strip_dir + "/EventInfo/reportSummary";
439  MonitorElement* me_dqm = dqmStore_->get(full_path);
440  if (me_dqm && me_dqm->kind() == MonitorElement::DQM_KIND_REAL) dqm_flag = me_dqm->getFloatValue();
441  full_path = strip_dir + "/EventInfo/DCSSummary";
442  MonitorElement* me_dcs = dqmStore_->get(full_path);
443  if (me_dcs && me_dcs->kind() == MonitorElement::DQM_KIND_REAL) dcs_flag = me_dcs->getFloatValue();
445  SiStripCertification->Fill(fminf(dqm_flag,dcs_flag));
446 }
#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:209
#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:451
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:1265
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:1294
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:642
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:232
Definition: Run.h:32
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:126
const std::string & pwd(void) const
Definition: DQMStore.cc:204
static void getTopFolderPath(DQMStore *dqm_store, std::string type, std::string &path)