CMS 3D CMS Logo

SiStripPopConPedestalsDQM.cc
Go to the documentation of this file.
3 
11 {
12 public:
15  // interface methods: implemented in template
16  void dqmEndJob(DQMStore::IBooker& booker, DQMStore::IGetter& getter) override;
17  SiStripPedestals* getObj() const override;
18 private:
22 };
23 
26 
29  , fp_{iConfig.getUntrackedParameter<edm::FileInPath>("file", edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))}
30  , MEDir_{iConfig.getUntrackedParameter<std::string>("ME_DIR", "DQMData")}
31 {
32  edm::LogInfo("SiStripPedestalsDQMService") << "[SiStripPedestalsDQMService::SiStripPedestalsDQMService]";
33 }
34 
36 {
37  edm::LogInfo("SiStripPedestalsDQMService") << "[SiStripPedestalsDQMService::~SiStripPedestalsDQMService]";
38 }
39 
41 {
42  std::cout << "SiStripPedestalsDQMService::readPedestals" << std::endl;
43 
45 
47 
48  // getter.cd(iConfig_.getUntrackedParameter<std::string>("ME_DIR"));
49  getter.cd();
50 
51  uint32_t stripsPerApv = 128;
52 
53  // Get the full list of monitoring elements
54  // const std::vector<MonitorElement*>& MEs = getter.getAllContents(iConfig_.getUntrackedParameter<std::string>("ME_DIR","DQMData"));
55 
56  // Take a copy of the vector
57  std::vector<MonitorElement*> MEs = getter.getAllContents(MEDir_);
58  // Remove all but the MEs we are using
59  MEs.erase(std::remove_if(MEs.begin(), MEs.end(),
60  [] ( const MonitorElement* ME ) -> bool {
61  return std::string::npos == ME->getName().find("PedsPerStrip__det__");
62  }), MEs.end());
63 
64  // The histograms are one per DetId, loop on all the DetIds and extract the corresponding histogram
65  for ( const auto& detInfo : reader.getAllData() ) {
66  SiStripPedestals::InputVector theSiStripVector;
67 
68  // Take the path for each DetId and build the complete path + histogram name
69 
70  // MonitorElement * mE = getModuleHistogram(detInfo.first, "PedsPerStrip");
71  const MonitorElement* mE{nullptr};
72  std::string MEname("PedsPerStrip__det__"+std::to_string(detInfo.first));
73  for ( const MonitorElement* ime : MEs ) {
74  if( ime->getName() == MEname ) {
75  mE = ime;
76  break;
77  }
78  }
79 
80  // find( MEs.begin(), MEs.end(), "PedsPerStrip__det__"+std::to_string(detInfo.first), findMEbyName() );
81  // MonitorElement * mE = *(find( MEs.begin(), MEs.end(), findMEbyName("PedsPerStrip__det__"+std::to_string(detInfo.first)) ));
82 
83  if ( mE ) {
84  TH1F* histo = mE->getTH1F();
85  if ( histo ) {
86  // Read the pedestals from the histograms
87  uint32_t nBinsX = histo->GetXaxis()->GetNbins();
88 
89  if ( nBinsX != stripsPerApv*(detInfo.second.nApvs) ) {
90  std::cout << "ERROR: number of bin = " << nBinsX << " != number of strips = " << stripsPerApv*(detInfo.second.nApvs) << std::endl;
91  }
92 
93  // std::cout << "Bin 0 = " << histo->GetBinContent(0) << std::endl;
94  // TH1 bins start from 1, 0 is the underflow, nBinsX+1 the overflow.
95  for ( uint32_t iBin = 1; iBin <= nBinsX; ++iBin ) {
96  // encode the pedestal value and put it in the vector (push_back)
97  m_obj.setData( histo->GetBinContent(iBin), theSiStripVector );
98  }
99  } else {
100  std::cout << "ERROR: histo = " << histo << std::endl;
101  }
102  } else {
103  std::cout << "ERROR: ME = " << mE << std::endl;
104  }
105  // If the ME was absent fill the vector with 0
106  if ( theSiStripVector.empty() ) {
107  for(unsigned short j=0; j<128*detInfo.second.nApvs; ++j){
108  m_obj.setData(0, theSiStripVector);
109  }
110  }
111 
112  if ( ! m_obj.put(detInfo.first, theSiStripVector) )
113  edm::LogError("SiStripPedestalsFakeESSource::produce ")<<" detid already exists"<<std::endl;
114  }
115  getter.cd();
116 }
117 
119 {
120  return new SiStripPedestals(m_obj);
121 }
122 
T getUntrackedParameter(std::string const &, T const &) const
void cd(void)
Definition: DQMStore.cc:339
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
SiStripPopConPedestalsHandlerFromDQM(const edm::ParameterSet &iConfig)
Definition: ME.h:11
std::vector< uint16_t > InputVector
bool put(const uint32_t &detID, InputVector &input)
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0)
Definition: DQMStore.cc:299
MonitorElement ME
void setData(float ped, InputVector &vped)
std::string fullPath() const
Definition: FileInPath.cc:184
SiStripPedestals * getObj() const override