CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelErrorsDigisToCalibDigis.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelErrorsDigisToCalibDigis
4 // Class: SiPixelErrorsDigisToCalibDigis
5 //
13 //
14 // Original Author: Ricardo Vasquez Sierra
15 // Created: Wed Apr 9 12:43:02 CEST 2008
16 // $Id: SiPixelErrorsDigisToCalibDigis.cc,v 1.10 2010/08/10 09:06:13 ursl Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
25 
26 // user include files
29 
32 
34 
35 //
36 // constants, enums and typedefs
37 //
38 
39 //
40 // static data member definitions
41 //
42 
43 //
44 // constructors and destructor
45 //
47 
48 {
49 
50  siPixelProducerLabel_ = iConfig.getParameter<edm::InputTag>("SiPixelProducerLabelTag");
51  createOutputFile_ = iConfig.getUntrackedParameter<bool>("saveFile",false);
52  outputFilename_ = iConfig.getParameter<std::string>("outputFilename");
55 
56 // std::cout<<"siPixelProducerLabel_ = "<<siPixelProducerLabel_<<std::endl;
57 // std::cout<<"createOutputFile_= "<< createOutputFile_<<std::endl;
58 // std::cout<<"outpuFilename_= "<< outputFilename_<< std::endl;
59 }
60 
61 
63 {
64 
65  // do anything here that needs to be done at desctruction time
66  // (e.g. close files, deallocate resources etc.)
67 
68 }
69 
70 
71 //
72 // member functions
73 //
74 
75 // ------------ method called to for each event ------------
76 void
78 {
79  using namespace edm;
80 
81  static int first(1);
82  if (1 == first) {
83  first = 0;
84  iSetup.get<TrackerDigiGeometryRecord>().get( geom_ );
86  }
87 
89  iEvent.getByLabel(siPixelProducerLabel_, thePlaquettes);
90  // iEvent.getByLabel("siPixelCalibDigis", thePlaquettes);
91 
92 
94 
95 
96  for (digiIter=thePlaquettes->begin(); digiIter!=thePlaquettes->end(); digiIter++)
97  {
98  uint32_t detId = digiIter->id;
99 
101  //loop over pixel errors pulsed in the current plaquette
102 
103  MonitorElement* temp_;
104 
105  std::map<uint32_t, MonitorElement*>::iterator mapIterator = SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.find(detId);
106 
107  if (digiIter->begin() != digiIter->end()) {
108  if ( mapIterator == SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.end() )
109  {
110 // std::cout << "This is the beginning of an error 2d histo booking: "<<std::endl;
111  setDQMDirectory(detId);
112  temp_ = bookDQMHistoPlaquetteSummary2D(detId, "SiPixelErrorsCalibDigis", "SiPixelErrorsDigisToCalibDigis");
113  SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.insert( std::make_pair(detId,temp_));
114  }
115  else
116  {
117 // std::cout << "This one was already booked."<<std::endl;
118  temp_ = (*mapIterator).second;
119  }
120 
121  for(ipix=digiIter->begin(); ipix!=digiIter->end(); ++ipix)
122  {
123  temp_->Fill(ipix->getCol(), ipix->getRow());
124 // std::cout << "detId: " << detId << " " << ipix->getRow() << " " << ipix->getCol() << std::endl;
125  }
126 
127  } // end of the if statement asking if the plaquette in question has any errors in it
128 
129  }// end of the for loop that goes through all plaquettes
130 
131 }
132 
133 
134 // ------------ method called once each job just before starting event loop ------------
135 void
137 {
138 
139 }
140 
141 // ------------ method called once each job just after ending the event loop ------------
142 void
144 
145  if (!outputFilename_.empty() && createOutputFile_)
146  {
147  edm::LogInfo("SiPixelErrorCalibDigis") << "Writing ROOT file to: " << outputFilename_ << std::endl;
149  }
150 }
151 
152 // ------------ helper functions ---------------------------------------------------------
153 
154 MonitorElement* SiPixelErrorsDigisToCalibDigis::bookDQMHistogram2D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
155 {
156  std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
157  return daqBE_->book2D(hid, title, nchX, lowX, highX, nchY, lowY, highY);
158 }
159 
161 
162  DetId detId(detid);
163  const TrackerGeometry &theTracker(*geom_);
164  const PixelGeomDetUnit *theGeomDet = dynamic_cast<const PixelGeomDetUnit*> ( theTracker.idToDet(detId) );
165  int maxcol = theGeomDet->specificTopology().ncolumns();
166  int maxrow = theGeomDet->specificTopology().nrows();
167 
168  std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
169  return daqBE_->book2D(hid,title,maxcol,0,maxcol,maxrow,0,maxrow);
170 }
171 
173 {
174  daqBE_->setCurrentFolder(dirName);
175  return daqBE_->dirExists(dirName);
176 }
177 
179 {
180  return folderMaker_->setModuleFolder(detID,0);
181 }
182 
183 // -- define this as a plug-in
iterator end()
Definition: DetSet.h:61
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual int ncolumns() const =0
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual int nrows() const =0
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:243
MonitorElement * bookDQMHistogram2D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
bool first
Definition: L1TdeRCT.cc:94
virtual const GeomDet * idToDet(DetId) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::map< uint32_t, MonitorElement * > SiPixelErrorsDigisToCalibDigis_2DErrorInformation_
iterator begin()
Definition: DetSet.h:60
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:493
std::string setHistoId(std::string variable, uint32_t &rawId)
Set Histogram Id.
Definition: DetId.h:20
virtual void analyze(const edm::Event &, const edm::EventSetup &)
SiPixelErrorsDigisToCalibDigis(const edm::ParameterSet &)
const T & get() const
Definition: EventSetup.h:55
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
std::string const & label() const
Definition: InputTag.h:25
edm::ESHandle< TrackerGeometry > geom_
MonitorElement * bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name, std::string title)
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
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:845
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0)
Set folder name for a module or plaquette.