CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripMonitorQuality.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripMonitorQuality
4 // Class: SiStripMonitorQuality
5 //
13 //
14 // Original Author: Suchandra Dutta
15 // Created: Fri Dec 7 20:50 CET 2007
16 // $Id: SiStripMonitorQuality.cc,v 1.8 2013/01/03 18:59:36 wmtan Exp $
17 //
18 //
19 
21 
24 
31 
32 
35 
37 
38 // std
39 #include <cstdlib>
40 #include <cmath>
41 #include <numeric>
42 #include <algorithm>
43 
45  dqmStore_(edm::Service<DQMStore>().operator->()),
46  conf_(iConfig),
47  m_cacheID_(0)
48 
49 
50 {
51  edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality "
52  << " Constructing....... ";
53 }
54 
55 
57 {
58  edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality "
59  << " Destructing....... ";
60 }
61 //
62 // -- Begin Job
63 //
65 }
66 //
67 // -- BeginRun
68 //
70 }
71 
72 
73 // ------------ method called to produce the data ------------
75 {
76  unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
77  if (m_cacheID_ == cacheID) return;
78 
79  //Retrieve tracker topology from geometry
81  eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
82  const TrackerTopology* const tTopo = tTopoHandle.product();
83 
84  m_cacheID_ = cacheID;
85 
86  std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
87  eSetup.get<SiStripQualityRcd>().get(quality_label,stripQuality_);
88  eSetup.get<SiStripDetCablingRcd>().get( detCabling_ );
89 
90  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "<<
91  " Reading SiStripQuality "<< std::endl;
92 
93  SiStripBadStrip::RegistryIterator rbegin = stripQuality_->getRegistryVectorBegin();
94  SiStripBadStrip::RegistryIterator rend = stripQuality_->getRegistryVectorEnd();
95  uint32_t detid;
96 
97  if (rbegin==rend) return;
98 
99  for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
100 
101  detid = rp->detid;
102  // Check consistency in DetId
103  if (detid == 0 || detid == 0xFFFFFFFF){
104  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::analyze : "
105  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
106  continue;
107  }
108  // check if the detid is connected in cabling
109  if (!detCabling_->IsConnected(detid)) {
110  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::analyze : "
111  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
112  continue;
113  }
114  MonitorElement* me = getQualityME(detid, tTopo);
115  SiStripBadStrip::Range range = SiStripBadStrip::Range( stripQuality_->getDataVectorBegin()+rp->ibegin ,
116  stripQuality_->getDataVectorBegin()+rp->iend );
117  SiStripBadStrip::ContainerIterator it=range.first;
118  for(;it!=range.second;++it){
119  unsigned int value=(*it);
120  short str_start = stripQuality_->decode(value).firstStrip;
121  short str_end = str_start + stripQuality_->decode(value).range;
122  for ( short isr = str_start; isr < str_end + 1; isr++) {
123  if (isr <= (me->getNbinsX()-1)) me->Fill(isr+1, 1.0);
124  }
125  }
126  }
127 }
128 //
129 // -- End Run
130 //
132  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
134  if (outputMEsInRootFile) {
136  dqmStore_->save(outputFileName);
137  }
138 }
139 //
140 // -- End Job
141 //
143  edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality::EndJob: "
144  << " Finishing!! ";
145 }
146 //
147 // -- End Job
148 //
150 
151  std::map<uint32_t, MonitorElement* >::iterator pos = QualityMEs.find(idet);
152  MonitorElement* det_me;
153  if (pos != QualityMEs.end()) {
154  det_me = pos->second;
155  det_me->Reset();
156  } else {
157  int nStrip = detCabling_->nApvPairs(idet) * 256;
158 
159  // use SistripHistoId for producing histogram id (and title)
160  SiStripHistoId hidmanager;
161  // create SiStripFolderOrganizer
162  SiStripFolderOrganizer folder_organizer;
163  // set appropriate folder using SiStripFolderOrganizer
164  folder_organizer.setDetectorFolder(idet, tTopo); // pass the detid to this method
165 
166  std::string hid;
167  hid = hidmanager.createHistoId("StripQualityFromCondDB","det", idet);
168 
169  det_me = dqmStore_->book1D(hid, hid, nStrip,0.5,nStrip+0.5);
170  dqmStore_->tag(det_me, idet);
171  det_me->setAxisTitle("Strip Number",1);
172  det_me->setAxisTitle("Quality Flag from CondDB ",2);
173  QualityMEs.insert( std::make_pair(idet, det_me));
174  }
175  return det_me;
176 }
178 
T getParameter(std::string const &) const
edm::ESHandle< SiStripDetCabling > detCabling_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< unsigned int >::const_iterator ContainerIterator
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
Registry::const_iterator RegistryIterator
void Fill(long long x)
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1359
int iEvent
Definition: GenABIO.cc:243
MonitorElement * getQualityME(uint32_t idet, const TrackerTopology *tTopo)
edm::ESHandle< SiStripQuality > stripQuality_
virtual void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
virtual void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
SiStripMonitorQuality(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::pair< ContainerIterator, ContainerIterator > Range
unsigned long long m_cacheID_
int getNbinsX(void) const
get # of bins in X-axis
void showDirStructure(void) const
Definition: DQMStore.cc:2766
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)
std::map< uint32_t, MonitorElement * > QualityMEs
Definition: Run.h:36