File indexing completed on 2024-04-06 11:59:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022 #include "SiPixelErrorsDigisToCalibDigis.h"
0023
0024
0025 #include "FWCore/Framework/interface/MakerMacros.h"
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 SiPixelErrorsDigisToCalibDigis::SiPixelErrorsDigisToCalibDigis(const edm::ParameterSet& iConfig)
0039
0040 {
0041 siPixelProducerLabel_ = iConfig.getParameter<edm::InputTag>("SiPixelProducerLabelTag");
0042 createOutputFile_ = iConfig.getUntrackedParameter<bool>("saveFile", false);
0043 outputFilename_ = iConfig.getParameter<std::string>("outputFilename");
0044 daqBE_ = &*edm::Service<DQMStore>();
0045 folderMaker_ = new SiPixelFolderOrganizer();
0046
0047 tPixelCalibDigiError = consumes<edm::DetSetVector<SiPixelCalibDigiError> >(siPixelProducerLabel_);
0048
0049 trackerGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
0050
0051
0052
0053
0054 }
0055
0056 SiPixelErrorsDigisToCalibDigis::~SiPixelErrorsDigisToCalibDigis() {
0057
0058
0059 }
0060
0061
0062
0063
0064
0065
0066 void SiPixelErrorsDigisToCalibDigis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0067 using namespace edm;
0068
0069 static int first(1);
0070 if (1 == first) {
0071 first = 0;
0072 geom_ = iSetup.getHandle(trackerGeomToken_);
0073 theHistogramIdWorker_ = new SiPixelHistogramId(siPixelProducerLabel_.label());
0074 }
0075
0076 Handle<DetSetVector<SiPixelCalibDigiError> > thePlaquettes;
0077 iEvent.getByToken(tPixelCalibDigiError, thePlaquettes);
0078
0079
0080 DetSetVector<SiPixelCalibDigiError>::const_iterator digiIter;
0081
0082 for (digiIter = thePlaquettes->begin(); digiIter != thePlaquettes->end(); digiIter++) {
0083 uint32_t detId = digiIter->id;
0084
0085 DetSet<SiPixelCalibDigiError>::const_iterator ipix;
0086
0087
0088 MonitorElement* temp_;
0089
0090 std::map<uint32_t, MonitorElement*>::iterator mapIterator =
0091 SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.find(detId);
0092
0093 if (digiIter->begin() != digiIter->end()) {
0094 if (mapIterator == SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.end()) {
0095
0096 setDQMDirectory(detId);
0097 temp_ = bookDQMHistoPlaquetteSummary2D(detId, "SiPixelErrorsCalibDigis", "SiPixelErrorsDigisToCalibDigis");
0098 SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.insert(std::make_pair(detId, temp_));
0099 } else {
0100
0101 temp_ = (*mapIterator).second;
0102 }
0103
0104 for (ipix = digiIter->begin(); ipix != digiIter->end(); ++ipix) {
0105 temp_->Fill(ipix->getCol(), ipix->getRow());
0106
0107 }
0108
0109 }
0110
0111 }
0112 }
0113
0114
0115 void SiPixelErrorsDigisToCalibDigis::endJob() {
0116 if (!outputFilename_.empty() && createOutputFile_) {
0117 edm::LogInfo("SiPixelErrorCalibDigis") << "Writing ROOT file to: " << outputFilename_ << std::endl;
0118 if (edm::Service<DQMStore>().isAvailable())
0119 edm::Service<DQMStore>()->save(outputFilename_);
0120 }
0121 }
0122
0123
0124
0125 SiPixelErrorsDigisToCalibDigis::MonitorElement* SiPixelErrorsDigisToCalibDigis::bookDQMHistogram2D(uint32_t detid,
0126 std::string name,
0127 std::string title,
0128 int nchX,
0129 double lowX,
0130 double highX,
0131 int nchY,
0132 double lowY,
0133 double highY) {
0134 std::string hid = theHistogramIdWorker_->setHistoId(name, detid);
0135 return daqBE_->book2D(hid, title, nchX, lowX, highX, nchY, lowY, highY);
0136 }
0137
0138 SiPixelErrorsDigisToCalibDigis::MonitorElement* SiPixelErrorsDigisToCalibDigis::bookDQMHistoPlaquetteSummary2D(
0139 uint32_t detid, std::string name, std::string title) {
0140 DetId detId(detid);
0141 const TrackerGeometry& theTracker(*geom_);
0142 const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(theTracker.idToDet(detId));
0143 int maxcol = theGeomDet->specificTopology().ncolumns();
0144 int maxrow = theGeomDet->specificTopology().nrows();
0145
0146 std::string hid = theHistogramIdWorker_->setHistoId(name, detid);
0147 return daqBE_->book2D(hid, title, maxcol, 0, maxcol, maxrow, 0, maxrow);
0148 }
0149
0150 bool SiPixelErrorsDigisToCalibDigis::setDQMDirectory(std::string dirName) {
0151 daqBE_->setCurrentFolder(dirName);
0152 return daqBE_->dirExists(dirName);
0153 }
0154
0155 bool SiPixelErrorsDigisToCalibDigis::setDQMDirectory(uint32_t detID) { return folderMaker_->setModuleFolder(detID, 0); }
0156
0157
0158 DEFINE_FWK_MODULE(SiPixelErrorsDigisToCalibDigis);