00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024 #include "CalibTracker/SiPixelTools/interface/SiPixelErrorsDigisToCalibDigis.h"
00025
00026 #include "FWCore/Framework/interface/Frameworkfwd.h"
00027 #include "FWCore/Framework/interface/EDAnalyzer.h"
00028
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "FWCore/Framework/interface/MakerMacros.h"
00031
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 SiPixelErrorsDigisToCalibDigis::SiPixelErrorsDigisToCalibDigis(const edm::ParameterSet& iConfig)
00046
00047 {
00048
00049 siPixelProducerLabel_ = iConfig.getParameter<edm::InputTag>("SiPixelProducerLabelTag");
00050 createOutputFile_ = iConfig.getUntrackedParameter<bool>("saveFile",false);
00051 outputFilename_ = iConfig.getParameter<std::string>("outputFilename");
00052 daqBE_ = &*edm::Service<DQMStore>();
00053 folderMaker_ = new SiPixelFolderOrganizer();
00054
00055
00056
00057
00058 }
00059
00060
00061 SiPixelErrorsDigisToCalibDigis::~SiPixelErrorsDigisToCalibDigis()
00062 {
00063
00064
00065
00066
00067 }
00068
00069
00070
00071
00072
00073
00074
00075 void
00076 SiPixelErrorsDigisToCalibDigis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00077 {
00078 using namespace edm;
00079
00080 Handle<DetSetVector<SiPixelCalibDigiError> > thePlaquettes;
00081 iEvent.getByLabel(siPixelProducerLabel_, thePlaquettes);
00082
00083
00084
00085 DetSetVector<SiPixelCalibDigiError>::const_iterator digiIter;
00086
00087
00088 for (digiIter=thePlaquettes->begin(); digiIter!=thePlaquettes->end(); digiIter++)
00089 {
00090 uint32_t detId = digiIter->id;
00091
00092 DetSet<SiPixelCalibDigiError>::const_iterator ipix;
00093
00094
00095 MonitorElement* temp_;
00096
00097 std::map<uint32_t, MonitorElement*>::iterator mapIterator = SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.find(detId);
00098
00099 if (digiIter->begin() != digiIter->end()) {
00100 if ( mapIterator == SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.end() )
00101 {
00102
00103 setDQMDirectory(detId);
00104 temp_ = bookDQMHistoPlaquetteSummary2D(detId, "SiPixelErrorsCalibDigis", "SiPixelErrorsDigisToCalibDigis");
00105 SiPixelErrorsDigisToCalibDigis_2DErrorInformation_.insert( std::make_pair(detId,temp_));
00106 }
00107 else
00108 {
00109
00110 temp_ = (*mapIterator).second;
00111 }
00112
00113 for(ipix=digiIter->begin(); ipix!=digiIter->end(); ++ipix)
00114 {
00115 temp_->Fill(ipix->getCol(), ipix->getRow());
00116
00117 }
00118
00119 }
00120
00121 }
00122
00123 }
00124
00125
00126
00127 void
00128 SiPixelErrorsDigisToCalibDigis::beginJob(const edm::EventSetup& iSetup)
00129 {
00130 iSetup.get<TrackerDigiGeometryRecord>().get( geom_ );
00131 theHistogramIdWorker_ = new SiPixelHistogramId(siPixelProducerLabel_.label());
00132
00133 }
00134
00135
00136 void
00137 SiPixelErrorsDigisToCalibDigis::endJob() {
00138
00139 if (!outputFilename_.empty() && createOutputFile_)
00140 {
00141 edm::LogInfo("SiPixelErrorCalibDigis") << "Writing ROOT file to: " << outputFilename_ << std::endl;
00142 if ( &*edm::Service<DQMStore>()) edm::Service<DQMStore>()->save (outputFilename_);
00143 }
00144 }
00145
00146
00147
00148 MonitorElement* SiPixelErrorsDigisToCalibDigis::bookDQMHistogram2D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
00149 {
00150 std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
00151 return daqBE_->book2D(hid, title, nchX, lowX, highX, nchY, lowY, highY);
00152 }
00153
00154 MonitorElement* SiPixelErrorsDigisToCalibDigis::bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name,std::string title){
00155
00156 DetId detId(detid);
00157 const TrackerGeometry &theTracker(*geom_);
00158 const PixelGeomDetUnit *theGeomDet = dynamic_cast<const PixelGeomDetUnit*> ( theTracker.idToDet(detId) );
00159 int maxcol = theGeomDet->specificTopology().ncolumns();
00160 int maxrow = theGeomDet->specificTopology().nrows();
00161
00162 std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
00163 return daqBE_->book2D(hid,title,maxcol,0,maxcol,maxrow,0,maxrow);
00164 }
00165
00166 bool SiPixelErrorsDigisToCalibDigis::setDQMDirectory(std::string dirName)
00167 {
00168 daqBE_->setCurrentFolder(dirName);
00169 return daqBE_->dirExists(dirName);
00170 }
00171
00172 bool SiPixelErrorsDigisToCalibDigis::setDQMDirectory(uint32_t detID)
00173 {
00174 return folderMaker_->setModuleFolder(detID,0);
00175 }