CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackingCertificationInfo.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  : pSet_(pSet)
35  , trackingCertificationBooked_(false)
36  , trackingLSCertificationBooked_(false)
37  , nFEDConnected_(0)
38  , allPixelFEDConnected_(true)
39 {
40  // Create MessageSender
41  edm::LogInfo( "TrackingCertificationInfo") << "TrackingCertificationInfo::Deleting TrackingCertificationInfo ";
42 
43  // get back-end interface
45 
46  TopFolderName_ = pSet_.getUntrackedParameter<std::string>("TopFolderName","Tracking");
47  // std::cout << "[TrackingCertificationInfo::TrackingCertificationInfo] TopFolderName_: " << TopFolderName_ << std::endl;
48 
49  TrackingMEs tracking_mes;
50  // load variables for Global certification
51 
52  checkPixelFEDs_ = pSet_.getParameter<bool>("checkPixelFEDs");
53  if ( checkPixelFEDs_ ) {
54  std::string QTname = "pixel";
55  tracking_mes.TrackingFlag = 0;
56  TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>(QTname, tracking_mes));
57  }
58 
59  std::vector<edm::ParameterSet> TrackingGlobalQualityMEs = pSet_.getParameter< std::vector<edm::ParameterSet> >("TrackingGlobalQualityPSets" );
60  for ( auto meQTset : TrackingGlobalQualityMEs ) {
61 
62  std::string QTname = meQTset.getParameter<std::string>("QT");
63  tracking_mes.TrackingFlag = 0;
64 
65  // std::cout << "[TrackingQualityChecker::TrackingCertificationInfo] inserting " << QTname << " in TrackingMEsMap" << std::endl;
66  TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>(QTname, tracking_mes));
67  }
68 
69  TrackingLSMEs tracking_ls_mes;
70  // load variables for LS certification
71  std::vector<edm::ParameterSet> TrackingLSQualityMEs = pSet_.getParameter< std::vector<edm::ParameterSet> >("TrackingLSQualityMEs" );
72  for ( auto meQTset : TrackingLSQualityMEs ) {
73 
74  std::string QTname = meQTset.getParameter<std::string>("QT");
75  tracking_ls_mes.TrackingFlag = 0;
76 
77  // std::cout << "[TrackingQualityChecker::TrackingCertificationInfo] inserting " << QTname << " in TrackingMEsMap" << std::endl;
78  TrackingLSMEsMap.insert(std::pair<std::string, TrackingLSMEs>(QTname, tracking_ls_mes));
79  }
80 
81 
82  // define sub-detectors which affect the quality
83  SubDetFolder.push_back("SiStrip");
84  SubDetFolder.push_back("Pixel");
85 
86 }
87 
89  edm::LogInfo("TrackingCertificationInfo") << "TrackingCertificationInfo::Deleting TrackingCertificationInfo ";
90 
91 }
92 //
93 // -- Begin Job
94 //
96 
97 }
98 //
99 // -- Begin Run
100 //
102 
103  // std::cout << "[TrackingCertificationInfo::beginRun] starting .." << std::endl;
104 
105  edm::LogInfo ("TrackingCertificationInfo") <<"TrackingCertificationInfo:: Begining of Run";
106  unsigned long long cacheID = eSetup.get<SiStripDetCablingRcd>().cacheIdentifier();
107  if (m_cacheID_ != cacheID) {
108  m_cacheID_ = cacheID;
109  }
110  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
111 
112  nFEDConnected_ = 0;
113  int nPixelFEDConnected_ = 0;
114  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
115  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
116  const int siPixelFedIdMin = FEDNumbering::MINSiPixelFEDID;
117  const int siPixelFedIdMax = FEDNumbering::MAXSiPixelFEDID;
118  const int siPixelFeds = (siPixelFedIdMax-siPixelFedIdMin+1);
119 
121  if( eSetup.find( recordKey ) != 0) {
122 
123  edm::ESHandle<RunInfo> sumFED;
124  eSetup.get<RunInfoRcd>().get(sumFED);
125 
126  if ( sumFED.isValid() ) {
127 
128  std::vector<int> FedsInIds= sumFED->m_fed_in;
129  for ( auto fedID : FedsInIds ) {
130  if ( fedID >= siPixelFedIdMin && fedID <= siPixelFedIdMax ) {
131  ++nFEDConnected_;
132  ++nPixelFEDConnected_;
133  }
134  else if ( fedID >= siStripFedIdMin && fedID <= siStripFedIdMax )
135  ++nFEDConnected_;
136  }
137  LogDebug ("TrackingDcsInfo") << " TrackingDcsInfo :: Connected FEDs " << nFEDConnected_;
138  }
139  }
140 
141  allPixelFEDConnected_ = ( nPixelFEDConnected_ == siPixelFeds );
142 
145 
148 
149 }
150 
151 //
152 // -- Book MEs for Tracking Certification fractions
153 //
155 
156  // std::cout << "[TrackingCertificationInfo::bookTrackingCertificationMEs] starting .. trackingCertificationBooked_: " << trackingCertificationBooked_ << std::endl;
157 
159 
160  dqmStore_->cd();
161  std::string tracking_dir = "";
163 
164  if (tracking_dir.size() > 0 ) dqmStore_->setCurrentFolder(tracking_dir+"/EventInfo");
165  else dqmStore_->setCurrentFolder(TopFolderName_+"/EventInfo");
166 
167  TrackingCertification = dqmStore_->bookFloat("CertificationSummary");
168 
169  std::string hname, htitle;
170  hname = "CertificationReportMap";
171  htitle = "Tracking Certification Summary Map";
172  size_t nQT = TrackingMEsMap.size();
173  TrackingCertificationSummaryMap = dqmStore_->book2D(hname, htitle, nQT,0.5,float(nQT)+0.5,1,0.5,1.5);
174  TrackingCertificationSummaryMap->setAxisTitle("Track Quality Type", 1);
176  size_t ibin =0;
177  for ( auto meQTset : TrackingMEsMap ) {
178  TrackingCertificationSummaryMap->setBinLabel(ibin+1,meQTset.first);
179  ibin++;
180  }
181 
182 
183  if (tracking_dir.size() > 0 ) dqmStore_->setCurrentFolder(TopFolderName_+"/EventInfo/CertificationContents");
184  else dqmStore_->setCurrentFolder(TopFolderName_+"/EventInfo/CertificationContents");
185 
186  for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin();
187  it != TrackingMEsMap.end(); it++) {
188  std::string meQTname = it->first;
189  // std::cout << "[TrackingCertificationInfo::bookStatus] meQTname: " << meQTname << std::endl;
190  it->second.TrackingFlag = dqmStore_->bookFloat("Track"+meQTname);
191  // std::cout << "[TrackingCertificationInfo::bookStatus] " << it->first << " exists ? " << it->second.TrackingFlag << std::endl;
192  }
193 
195  dqmStore_->cd();
196  }
197 
198  // std::cout << "[TrackingCertificationInfo::bookStatus] trackingCertificationBooked_: " << trackingCertificationBooked_ << std::endl;
199 }
200 
201 //
202 // -- Book MEs for Tracking Certification per LS
203 //
205 
206  // std::cout << "[TrackingCertificationInfo::bookTrackingCertificationMEs] starting .. trackingCertificationBooked_: " << trackingCertificationBooked_ << std::endl;
207 
209 
210  dqmStore_->cd();
211  std::string tracking_dir = "";
213 
214  if (tracking_dir.size() > 0 ) dqmStore_->setCurrentFolder(tracking_dir+"/EventInfo");
215  else dqmStore_->setCurrentFolder(TopFolderName_+"/EventInfo");
216 
217  TrackingLSCertification = dqmStore_->bookFloat("CertificationSummary");
218 
219  if (tracking_dir.size() > 0 ) dqmStore_->setCurrentFolder(TopFolderName_+"/EventInfo/CertificationContents");
220  else dqmStore_->setCurrentFolder(TopFolderName_+"/EventInfo/CertificationContents");
221 
222  for (std::map<std::string, TrackingLSMEs>::iterator it = TrackingLSMEsMap.begin();
223  it != TrackingLSMEsMap.end(); it++) {
224  std::string meQTname = it->first;
225  // std::cout << "[TrackingCertificationInfo::bookStatus] meQTname: " << meQTname << std::endl;
226  it->second.TrackingFlag = dqmStore_->bookFloat("Track"+meQTname);
227  // std::cout << "[TrackingCertificationInfo::bookStatus] " << it->first << " exists ? " << it->second.TrackingFlag << std::endl;
228  }
229 
231  dqmStore_->cd();
232  }
233 
234  // std::cout << "[TrackingCertificationInfo::bookStatus] trackingCertificationBooked_: " << trackingCertificationBooked_ << std::endl;
235 }
236 //
237 // -- Analyze
238 //
240 }
241 //
242 // -- End Luminosity Block
243 //
245  edm::LogInfo( "TrackingDaqInfo") << "TrackingDaqInfo::endLuminosityBlock";
246 
249 }
250 
251 //
252 // -- End of Run
253 //
255 
256  // std::cout << "[TrackingCertificationInfo::endRun]" << std::endl;
257 
258  edm::LogInfo ("TrackingCertificationInfo") <<"TrackingCertificationInfo:: End Run";
259 
260  if ( nFEDConnected_ > 0 ) fillTrackingCertificationMEs(eSetup);
262 
263  // std::cout << "[TrackingCertificationInfo::endRun] DONE" << std::endl;
264 
265 }
266 //
267 // --Fill Tracking Certification
268 //
271  // edm::LogError("TrackingCertificationInfo") << " TrackingCertificationInfo::fillTrackingCertificationMEs : MEs missing ";
272  return;
273  }
274 
275  dqmStore_->cd();
276  std::string tracking_dir = "";
278  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEs] tracking_dir: " << tracking_dir << std::endl;
279  std::vector<MonitorElement*> all_mes = dqmStore_->getContents(tracking_dir+"/EventInfo/reportSummaryContents");
280  float fval = 1.0;
281 
282  // std::cout << "all_mes: " << all_mes.size() << std::endl;
283 
284  if ( checkPixelFEDs_ ) {
285  float val = 1.;
286  if ( allPixelFEDConnected_ ) val = 0.;
287  int xbin = 0;
288  for (std::map<std::string, TrackingMEs>::const_iterator it = TrackingMEsMap.begin();
289  it != TrackingMEsMap.end(); it++) {
290  std::string type = it->first;
291  if ( type == "pixel" ) {
292  it->second.TrackingFlag->Fill(val);
294  std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEs] xbin: " << xbin << " val: " << val << std::endl;
295  th2d->SetBinContent(xbin+1,1,val);
296  }
297  xbin++;
298  }
299  fval = fminf(fval,val);
300  }
301 
302  int xbin = ( checkPixelFEDs_ ? 1 : 0);
303  for (std::vector<MonitorElement *>::const_iterator ime = all_mes.begin();
304  ime!= all_mes.end(); ime++) {
305  MonitorElement * me = (*ime);
306  if (!me) continue;
307  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEs] me: " << me->getName() << std::endl;
308  if (me->kind() == MonitorElement::DQM_KIND_REAL) {
309  std::string name = me->getName();
310  float val = me->getFloatValue();
311 
312  for (std::map<std::string, TrackingMEs>::const_iterator it = TrackingMEsMap.begin();
313  it != TrackingMEsMap.end(); it++) {
314 
315  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEs] ME: " << it->first << " [" << it->second.TrackingFlag->getFullname() << "] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
316 
317  std::string type = it->first;
318  if (name.find(type) != std::string::npos) {
319  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEs] type: " << type << " <---> name: " << name << std::endl;
320  it->second.TrackingFlag->Fill(val);
321  std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEs] xbin: " << xbin << " val: " << val << std::endl;
323  th2d->SetBinContent(xbin+1,1,val);
324  xbin++;
325  break;
326  }
327  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEs] ME: " << it->first << " [" << it->second.TrackingFlag->getFullname() << "] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
328 
329  }
330  fval = fminf(fval,val);
331  }
332  }
333  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEs] TrackingCertification: " << fval << std::endl;
334  TrackingCertification->Fill(fval);
335 }
336 
337 //
338 // --Reset Tracking Certification
339 //
343  for (std::map<std::string, TrackingMEs>::const_iterator it = TrackingMEsMap.begin();
344  it != TrackingMEsMap.end(); it++) {
345  it->second.TrackingFlag->Reset();
346  }
347 }
348 
349 //
350 // --Reset Tracking Certification per LS
351 //
355  for (std::map<std::string, TrackingLSMEs>::const_iterator it = TrackingLSMEsMap.begin();
356  it != TrackingLSMEsMap.end(); it++) {
357  it->second.TrackingFlag->Reset();
358  }
359 }
360 
361 //
362 // -- Fill Dummy Tracking Certification
363 //
368  for (std::map<std::string, TrackingMEs>::const_iterator it = TrackingMEsMap.begin();
369  it != TrackingMEsMap.end(); it++) {
370  it->second.TrackingFlag->Fill(-1.0);
371  }
372 
373  for (int xbin = 1; xbin < TrackingCertificationSummaryMap->getNbinsX()+1; xbin++ )
374  for (int ybin = 1; ybin < TrackingCertificationSummaryMap->getNbinsY()+1; ybin++ )
375  TrackingCertificationSummaryMap->Fill(xbin,ybin,-1);
376 
377 
378  }
379 }
380 
381 //
382 // -- Fill Dummy Tracking Certification per LS
383 //
388  for (std::map<std::string, TrackingLSMEs>::const_iterator it = TrackingLSMEsMap.begin();
389  it != TrackingLSMEsMap.end(); it++) {
390  it->second.TrackingFlag->Fill(-1.0);
391  }
392 
393  }
394 }
395 
396 //
397 // --Fill Tracking Certification per LS
398 //
400  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] starting .." << std::endl;
402  return;
403  }
405 
406  dqmStore_->cd();
407  std::string tracking_dir = "";
409  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] tracking_dir: " << tracking_dir << std::endl;
410 
411 
412  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] tracking_dir: " << tracking_dir << std::endl;
413  std::vector<MonitorElement*> all_mes = dqmStore_->getContents(tracking_dir+"/EventInfo/reportSummaryContents");
414 
415  // std::cout << "all_mes: " << all_mes.size() << std::endl;
416 
417  for (std::vector<MonitorElement *>::const_iterator ime = all_mes.begin();
418  ime!= all_mes.end(); ime++) {
419  MonitorElement * me = (*ime);
420  if (!me) continue;
421  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] me: " << me->getName() << std::endl;
422  if (me->kind() == MonitorElement::DQM_KIND_REAL) {
423  std::string name = me->getName();
424  float val = me->getFloatValue();
425  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] val: " << val << std::endl;
426 
427  for (std::map<std::string, TrackingLSMEs>::const_iterator it = TrackingLSMEsMap.begin();
428  it != TrackingLSMEsMap.end(); it++) {
429 
430  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] ME: " << it->first << " [" << it->second.TrackingFlag->getFullname() << "] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
431 
432  std::string type = it->first;
433  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] type: " << type << std::endl;
434  if (name.find(type) != std::string::npos) {
435  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] type: " << type << " <---> name: " << name << std::endl;
436  it->second.TrackingFlag->Fill(val);
437  break;
438  }
439  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] ME: " << it->first << " [" << it->second.TrackingFlag->getFullname() << "] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
440  }
441  }
442  }
443 
444  float global_dqm_flag = 1.0;
445  std::string full_path = tracking_dir + "/EventInfo/reportSummary";
446  MonitorElement* me_dqm = dqmStore_->get(full_path);
447  if (me_dqm && me_dqm->kind() == MonitorElement::DQM_KIND_REAL) global_dqm_flag = me_dqm->getFloatValue();
448  // std::cout << "[TrackingCertificationInfo::fillTrackingCertificationMEsAtLumi] global_dqm_flag: " << global_dqm_flag << std::endl;
449 
451  TrackingLSCertification->Fill(global_dqm_flag);
452 }
#define LogDebug(id)
std::map< std::string, TrackingLSMEs > TrackingLSMEsMap
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
Begin Run.
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:632
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
EndRun.
std::map< std::string, TrackingMEs > TrackingMEsMap
void fillTrackingCertificationMEs(edm::EventSetup const &eSetup)
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)
TrackingCertificationInfo(const edm::ParameterSet &ps)
Constructor.
std::vector< std::string > SubDetFolder
static void getTopFolderPath(DQMStore *dqm_store, std::string top_dir, std::string &path)
edm::ESHandle< SiStripDetCabling > detCabling_
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:879
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)
MonitorElement * TrackingCertificationSummaryMap
void analyze(edm::Event const &, edm::EventSetup const &)
Analyze.
double getFloatValue(void) const
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &iSetup)
End Of Luminosity.
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:1693
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:1722
const T & get() const
Definition: EventSetup.h:55
int getNbinsX(void) const
get # of bins in X-axis
virtual ~TrackingCertificationInfo()
Destructor.
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false
TH2F * getTH2F(void) const
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:1070
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:655
Definition: Run.h:41
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:125