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.7 2008/07/04 12:42:50 fblekman Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
25 // user include files
28 
31 
33 
34 //
35 // constants, enums and typedefs
36 //
37 
38 //
39 // static data member definitions
40 //
41 
42 //
43 // constructors and destructor
44 //
46 
47 {
48 
49  siPixelProducerLabel_ = iConfig.getParameter<edm::InputTag>("SiPixelProducerLabelTag");
50  createOutputFile_ = iConfig.getUntrackedParameter<bool>("saveFile",false);
51  outputFilename_ = iConfig.getParameter<std::string>("outputFilename");
54 
55 // std::cout<<"siPixelProducerLabel_ = "<<siPixelProducerLabel_<<std::endl;
56 // std::cout<<"createOutputFile_= "<< createOutputFile_<<std::endl;
57 // std::cout<<"outpuFilename_= "<< outputFilename_<< std::endl;
58 }
59 
60 
62 {
63 
64  // do anything here that needs to be done at desctruction time
65  // (e.g. close files, deallocate resources etc.)
66 
67 }
68 
69 
70 //
71 // member functions
72 //
73 
74 // ------------ method called to for each event ------------
75 void
77 {
78  using namespace edm;
79 
80  static int first(1);
81  if (1 == first) {
82  first = 0;
83  iSetup.get<TrackerDigiGeometryRecord>().get( geom_ );
85  }
86 
88  iEvent.getByLabel(siPixelProducerLabel_, thePlaquettes);
89  // iEvent.getByLabel("siPixelCalibDigis", thePlaquettes);
90 
91 
93 
94 
95  for (digiIter=thePlaquettes->begin(); digiIter!=thePlaquettes->end(); digiIter++)
96  {
97  uint32_t detId = digiIter->id;
98 
100  //loop over pixel errors pulsed in the current plaquette
101 
102  MonitorElement* temp_;
103 
104  std::map<uint32_t, MonitorElement*>::iterator mapIterator = SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.find(detId);
105 
106  if (digiIter->begin() != digiIter->end()) {
107  if ( mapIterator == SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.end() )
108  {
109 // std::cout << "This is the beginning of an error 2d histo booking: "<<std::endl;
110  setDQMDirectory(detId);
111  temp_ = bookDQMHistoPlaquetteSummary2D(detId, "SiPixelErrorsCalibDigis", "SiPixelErrorsDigisToCalibDigis");
112  SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.insert( std::make_pair(detId,temp_));
113  }
114  else
115  {
116 // std::cout << "This one was already booked."<<std::endl;
117  temp_ = (*mapIterator).second;
118  }
119 
120  for(ipix=digiIter->begin(); ipix!=digiIter->end(); ++ipix)
121  {
122  temp_->Fill(ipix->getCol(), ipix->getRow());
123 // std::cout << "detId: " << detId << " " << ipix->getRow() << " " << ipix->getCol() << std::endl;
124  }
125 
126  } // end of the if statement asking if the plaquette in question has any errors in it
127 
128  }// end of the for loop that goes through all plaquettes
129 
130 }
131 
132 
133 // ------------ method called once each job just before starting event loop ------------
134 void
136 {
137 
138 }
139 
140 // ------------ method called once each job just after ending the event loop ------------
141 void
143 
144  if (!outputFilename_.empty() && createOutputFile_)
145  {
146  edm::LogInfo("SiPixelErrorCalibDigis") << "Writing ROOT file to: " << outputFilename_ << std::endl;
148  }
149 }
150 
151 // ------------ helper functions ---------------------------------------------------------
152 
153 MonitorElement* SiPixelErrorsDigisToCalibDigis::bookDQMHistogram2D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
154 {
155  std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
156  return daqBE_->book2D(hid, title, nchX, lowX, highX, nchY, lowY, highY);
157 }
158 
160 
161  DetId detId(detid);
162  const TrackerGeometry &theTracker(*geom_);
163  const PixelGeomDetUnit *theGeomDet = dynamic_cast<const PixelGeomDetUnit*> ( theTracker.idToDet(detId) );
164  int maxcol = theGeomDet->specificTopology().ncolumns();
165  int maxrow = theGeomDet->specificTopology().nrows();
166 
167  std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
168  return daqBE_->book2D(hid,title,maxcol,0,maxcol,maxrow,0,maxrow);
169 }
170 
172 {
173  daqBE_->setCurrentFolder(dirName);
174  return daqBE_->dirExists(dirName);
175 }
176 
178 {
179  return folderMaker_->setModuleFolder(detID,0);
180 }
iterator end()
Definition: DetSet.h:50
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual int ncolumns() const =0
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:79
virtual const GeomDet * idToDet(DetId) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
std::map< uint32_t, MonitorElement * > SiPixelErrorsDigisToCalibDigis_2DErrorInformation_
iterator begin()
Definition: DetSet.h:49
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:301
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:31
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:647
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:105
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0)
Set folder name for a module or plaquette.