CMS 3D CMS Logo

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  m_cacheID_(0) {
35  // Create MessageSender
36  edm::LogInfo( "SiStripCertificationInfo") << "SiStripCertificationInfo::Deleting SiStripCertificationInfo ";
37  // 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 
85 
86 }
87 //
88 // -- Book MEs for SiStrip Sertification fractions
89 //
92  dqmStore_->cd();
93  std::string strip_dir = "";
94  SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
95  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
96  else dqmStore_->setCurrentFolder("SiStrip/EventInfo");
97 
98  SiStripCertification = dqmStore_->bookFloat("CertificationSummary");
99 
100  std::string hname = "CertificationReportMap";
101  std::string htitle = "SiStrip Certification for Good Detector Fraction";
102  SiStripCertificationSummaryMap = dqmStore_->book2D(hname, htitle, 6,0.5,6.5,9,0.5,9.5);
103  SiStripCertificationSummaryMap->setAxisTitle("Sub Detector Type", 1);
104  SiStripCertificationSummaryMap->setAxisTitle("Layer/Disc Number", 2);
105  int ibin = 0;
106  for (std::map<std::string, SubDetMEs>::const_iterator it = SubDetMEsMap.begin();
107  it != SubDetMEsMap.end(); it++) {
108  ibin++;
109  std::string det = it->first;
111  }
112 
113  SubDetMEs local_mes;
115  dqmStore_->cd();
116  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo/CertificationContents");
117  else dqmStore_->setCurrentFolder("SiStrip/EventInfo/CertificationContents");
118  tag = "TIB";
119 
120  local_mes.folder_name = "TIB";
121  local_mes.subdet_tag = "TIB";
122  local_mes.n_layer = 4;
123  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
124  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
125 
126  tag = "TOB";
127  local_mes.folder_name = "TOB";
128  local_mes.subdet_tag = "TOB";
129  local_mes.n_layer = 6;
130  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
131  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
132 
133  tag = "TECF";
134  local_mes.folder_name = "TEC/PLUS";
135  local_mes.subdet_tag = "TEC+";
136  local_mes.n_layer = 9;
137  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
138  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
139 
140  tag = "TECB";
141  local_mes.folder_name = "TEC/MINUS";
142  local_mes.subdet_tag = "TEC-";
143  local_mes.n_layer = 9;
144  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
145  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
146 
147  tag = "TIDF";
148  local_mes.folder_name = "TID/PLUS";
149  local_mes.subdet_tag = "TID+";
150  local_mes.n_layer = 3;
151  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
152  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
153 
154  tag = "TIDB";
155  local_mes.folder_name = "TID/MINUS";
156  local_mes.subdet_tag = "TID-";
157  local_mes.n_layer = 3;
158  local_mes.det_fractionME = dqmStore_->bookFloat("SiStrip_"+tag);
159  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
160 
161  dqmStore_->cd();
162  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
163 
165  dqmStore_->cd();
166  }
167 }
168 //
169 // -- Analyze
170 //
172 }
173 //
174 // -- End Luminosity Block
175 //
177  edm::LogInfo( "SiStripDaqInfo") << "SiStripDaqInfo::endLuminosityBlock";
178 
179  if (nFEDConnected_ > 0) {
181  }
182 }
183 
184 //
185 // -- End of Run
186 //
188  edm::LogInfo ("SiStripCertificationInfo") <<"SiStripCertificationInfo:: End Run";
189 
190  if (nFEDConnected_ > 0) {
192  }
193 }
194 //
195 // --Fill SiStrip Certification
196 //
199  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillSiStripCertificationMEs : MEs missing ";
200  return;
201  }
202 
203  //Retrieve tracker topology from geometry
204  edm::ESHandle<TrackerTopology> tTopoHandle;
205  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
206  const TrackerTopology* const tTopo = tTopoHandle.product();
207 
209  std::string mdir = "MechanicalView";
210  dqmStore_->cd();
211  if (!SiStripUtility::goToDir(dqmStore_, mdir)) return;
212  std::string mechanical_dir = dqmStore_->pwd();
213  uint16_t nDetTot = 0;
214  uint16_t nFaultyTot = 0;
215  uint16_t nSToNTot = 0;
216  float sToNTot = 0.0;
217  SiStripFolderOrganizer folder_organizer;
218  int xbin = 0;
219  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
220  it != SubDetMEsMap.end(); it++) {
221  xbin++;
222  std::string name = it->first;
223  std::string tag = it->second.subdet_tag;
224  MonitorElement* me = it->second.det_fractionME;
225  if (!me) continue;
226  std::string bad_module_folder = mechanical_dir+"/"+it->second.folder_name+"/"+"BadModuleList";
227  std::vector<MonitorElement *> faulty_detMEs = dqmStore_->getContents(bad_module_folder);
228 
229  uint16_t ndet_subdet = 0;
230  uint16_t nfaulty_subdet = 0;
231  int nlayer = it->second.n_layer;
232  int ybin = 0;
233  for (int ilayer = 0; ilayer < nlayer; ilayer++) {
234  uint16_t ndet_layer = detCabling_->connectedNumber(tag, ilayer+1);
235  ndet_subdet += ndet_layer;
236  ybin++;
237  uint16_t nfaulty_layer = 0;
238  for (std::vector<MonitorElement *>::iterator im = faulty_detMEs.begin(); im != faulty_detMEs.end(); im++) {
239  if ((*im)->kind() != MonitorElement::DQM_KIND_INT ) continue;
240  if ((*im)->getIntValue() == 0) continue;
241  uint32_t detId = atoi((*im)->getName().c_str());
242  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detId, tTopo, false);
243  if (abs(det_layer_pair.second) == ilayer+1) nfaulty_layer++;
244  }
245 
246  nfaulty_subdet += nfaulty_layer;
247  float fraction_layer = -1.0;
248  if ( ndet_layer > 0) fraction_layer = 1 - ((nfaulty_layer*1.0)/ndet_layer);
249  if (SiStripCertificationSummaryMap) SiStripCertificationSummaryMap->Fill(xbin, ilayer+1,fraction_layer);
250  }
251  if (ybin <= SiStripCertificationSummaryMap->getNbinsY()) {
252  for (int k = ybin+1; k <= SiStripCertificationSummaryMap->getNbinsY(); k++) SiStripCertificationSummaryMap->Fill(xbin, k, -1.0);
253  }
254  float fraction_subdet = -1.0;
255  if (ndet_subdet > 0) fraction_subdet = 1 - ((nfaulty_subdet*1.0)/ndet_subdet);
256  // Check S/N status flag and use the minimum between the two
257  std::string full_path = mechanical_dir.substr(0, mechanical_dir.find_last_of("/"))
258  + "/EventInfo/reportSummaryContents/SiStrip_SToNFlag_"+name;
259  MonitorElement* me_ston = dqmStore_->get(full_path);
260  me->Reset();
261  if (me_ston && me_ston->kind()==MonitorElement::DQM_KIND_REAL) {
262  float ston_flg = me_ston->getFloatValue();
263  sToNTot += ston_flg;
264  nSToNTot++;
265  me->Fill(fminf(fraction_subdet,ston_flg));
266  } else me->Fill(fraction_subdet);
267  nDetTot += ndet_subdet ;
268  nFaultyTot += nfaulty_subdet;
269  }
270  float fraction_global = -1.0;
271  if (nDetTot > 0) fraction_global = 1.0 - ((nFaultyTot*1.0)/nDetTot);
272  float ston_frac_global = 1.0;
273  if (nSToNTot > 0) ston_frac_global = sToNTot/nSToNTot;
274  SiStripCertification->Fill(fminf(fraction_global,ston_frac_global));
275 }
276 //
277 // --Fill SiStrip Certification
278 //
283  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
284  it != SubDetMEsMap.end(); it++) {
285  it->second.det_fractionME->Reset();
286  }
288  }
289 }
290 //
291 // -- Fill Dummy SiStrip Certification
292 //
296  SiStripCertification->Fill(-1.0);
297  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
298  it != SubDetMEsMap.end(); it++) {
299  it->second.det_fractionME->Reset();
300  it->second.det_fractionME->Fill(-1.0);
301  }
302 
303  for (int xbin = 1; xbin < SiStripCertificationSummaryMap->getNbinsX()+1; xbin++) {
304  for (int ybin = 1; ybin < SiStripCertificationSummaryMap->getNbinsY()+1; ybin++) {
305  SiStripCertificationSummaryMap->Fill(xbin, ybin, -1.0);
306  }
307  }
308  }
309 }
310 //
311 // --Fill SiStrip Certification
312 //
315  edm::LogError("SiStripCertificationInfo") << " SiStripCertificationInfo::fillSiStripCertificationMEsAtLumi : MEs missing ";
316  return;
317  }
319  dqmStore_->cd();
320  std::string strip_dir = "";
321  SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
322  if (strip_dir.size() == 0) strip_dir = "SiStrip";
323 
324  std::string full_path;
325  float dcs_flag = 1.0;
326  float dqm_flag = 1.0;
327  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
328  it != SubDetMEsMap.end(); it++) {
329  std::string type = it->first;
330  full_path = strip_dir + "/EventInfo/DCSContents/SiStrip_" + type;
331  MonitorElement* me_dcs = dqmStore_->get(full_path);
332  if (me_dcs && me_dcs->kind() == MonitorElement::DQM_KIND_REAL) dcs_flag = me_dcs->getFloatValue();
333  full_path = strip_dir + "/EventInfo/reportSummaryContents/SiStrip_" + type;
334  MonitorElement* me_dqm = dqmStore_->get(full_path);
335  if (me_dqm && me_dqm->kind() == MonitorElement::DQM_KIND_REAL) dqm_flag = me_dqm->getFloatValue();
336  it->second.det_fractionME->Reset();
337  it->second.det_fractionME->Fill(fminf(dqm_flag,dcs_flag));
338  }
339  dcs_flag = 1.0;
340  dqm_flag = 1.0;
341  full_path = strip_dir + "/EventInfo/reportSummary";
342  MonitorElement* me_dqm = dqmStore_->get(full_path);
343  if (me_dqm && me_dqm->kind() == MonitorElement::DQM_KIND_REAL) dqm_flag = me_dqm->getFloatValue();
344  full_path = strip_dir + "/EventInfo/DCSSummary";
345  MonitorElement* me_dcs = dqmStore_->get(full_path);
346  if (me_dcs && me_dcs->kind() == MonitorElement::DQM_KIND_REAL) dcs_flag = me_dcs->getFloatValue();
348  SiStripCertification->Fill(fminf(dqm_flag,dcs_flag));
349 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:718
#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)
void analyze(edm::Event const &, edm::EventSetup const &)
Analyze.
void fillSiStripCertificationMEs(edm::EventSetup const &eSetup)
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=0)
uint32_t connectedNumber(const std::string &subDet, const uint16_t layer) const
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:972
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:91
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
std::vector< int > m_fed_in
Definition: RunInfo.h:26
double getFloatValue(void) const
SiStripCertificationInfo(const edm::ParameterSet &ps)
Constructor.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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. "my/long/dir/my_histo")
Definition: DQMStore.cc:1807
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1836
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:56
MonitorElement * SiStripCertificationSummaryMap
int getNbinsX(void) const
get # of bins in X-axis
edm::ESHandle< SiStripDetCabling > detCabling_
bool isValid() const
Definition: ESHandle.h:47
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:1163
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)
T const * product() const
Definition: ESHandle.h:86
static void getTopFolderPath(DQMStore *dqm_store, std::string top_dir, std::string &path)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:741
Definition: event.py:1
Definition: Run.h:42
const std::string & pwd(void) const
Definition: DQMStore.cc:713