CMS 3D CMS Logo

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 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
24 
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  tPixelCalibDigiError = consumes <edm::DetSetVector<SiPixelCalibDigiError> >(siPixelProducerLabel_);
56 
57 // std::cout<<"siPixelProducerLabel_ = "<<siPixelProducerLabel_<<std::endl;
58 // std::cout<<"createOutputFile_= "<< createOutputFile_<<std::endl;
59 // std::cout<<"outpuFilename_= "<< outputFilename_<< std::endl;
60 }
61 
62 
64 {
65 
66  // do anything here that needs to be done at desctruction time
67  // (e.g. close files, deallocate resources etc.)
68 
69 }
70 
71 
72 //
73 // member functions
74 //
75 
76 // ------------ method called to for each event ------------
77 void
79 {
80  using namespace edm;
81 
82  static int first(1);
83  if (1 == first) {
84  first = 0;
85  iSetup.get<TrackerDigiGeometryRecord>().get( geom_ );
87  }
88 
90  iEvent.getByToken(tPixelCalibDigiError, thePlaquettes);
91  // iEvent.getByLabel("siPixelCalibDigis", thePlaquettes);
92 
93 
95 
96 
97  for (digiIter=thePlaquettes->begin(); digiIter!=thePlaquettes->end(); digiIter++)
98  {
99  uint32_t detId = digiIter->id;
100 
102  //loop over pixel errors pulsed in the current plaquette
103 
104  MonitorElement* temp_;
105 
106  std::map<uint32_t, MonitorElement*>::iterator mapIterator = SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.find(detId);
107 
108  if (digiIter->begin() != digiIter->end()) {
109  if ( mapIterator == SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.end() )
110  {
111 // std::cout << "This is the beginning of an error 2d histo booking: "<<std::endl;
112  setDQMDirectory(detId);
113  temp_ = bookDQMHistoPlaquetteSummary2D(detId, "SiPixelErrorsCalibDigis", "SiPixelErrorsDigisToCalibDigis");
114  SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.insert( std::make_pair(detId,temp_));
115  }
116  else
117  {
118 // std::cout << "This one was already booked."<<std::endl;
119  temp_ = (*mapIterator).second;
120  }
121 
122  for(ipix=digiIter->begin(); ipix!=digiIter->end(); ++ipix)
123  {
124  temp_->Fill(ipix->getCol(), ipix->getRow());
125 // std::cout << "detId: " << detId << " " << ipix->getRow() << " " << ipix->getCol() << std::endl;
126  }
127 
128  } // end of the if statement asking if the plaquette in question has any errors in it
129 
130  }// end of the for loop that goes through all plaquettes
131 
132 }
133 
134 
135 // ------------ method called once each job just before starting event loop ------------
136 void
138 {
139 
140 }
141 
142 // ------------ method called once each job just after ending the event loop ------------
143 void
145 
146  if (!outputFilename_.empty() && createOutputFile_)
147  {
148  edm::LogInfo("SiPixelErrorCalibDigis") << "Writing ROOT file to: " << outputFilename_ << std::endl;
150  }
151 }
152 
153 // ------------ helper functions ---------------------------------------------------------
154 
155 MonitorElement* SiPixelErrorsDigisToCalibDigis::bookDQMHistogram2D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
156 {
157  std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
158  return daqBE_->book2D(hid, title, nchX, lowX, highX, nchY, lowY, highY);
159 }
160 
162 
163  DetId detId(detid);
164  const TrackerGeometry &theTracker(*geom_);
165  const PixelGeomDetUnit *theGeomDet = dynamic_cast<const PixelGeomDetUnit*> ( theTracker.idToDet(detId) );
166  int maxcol = theGeomDet->specificTopology().ncolumns();
167  int maxrow = theGeomDet->specificTopology().nrows();
168 
169  std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
170  return daqBE_->book2D(hid,title,maxcol,0,maxcol,maxrow,0,maxrow);
171 }
172 
174 {
175  daqBE_->setCurrentFolder(dirName);
176  return daqBE_->dirExists(dirName);
177 }
178 
180 {
181  return folderMaker_->setModuleFolder(detID,0);
182 }
183 
184 // -- define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual int nrows() const =0
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0, bool isUpgrade=false)
Set folder name for a module or plaquette.
MonitorElement * bookDQMHistogram2D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
void analyze(const edm::Event &, const edm::EventSetup &) override
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
std::map< uint32_t, MonitorElement * > SiPixelErrorsDigisToCalibDigis_2DErrorInformation_
std::string setHistoId(std::string variable, uint32_t &rawId)
Set Histogram Id.
Definition: DetId.h:18
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.
edm::EDGetTokenT< edm::DetSetVector< SiPixelCalibDigiError > > tPixelCalibDigiError
std::string const & label() const
Definition: InputTag.h:36
HLT enums.
virtual int ncolumns() const =0
const TrackerGeomDet * idToDet(DetId) const override
edm::ESHandle< TrackerGeometry > geom_
MonitorElement * bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name, std::string title)
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
save
Definition: cuy.py:1163