CMS 3D CMS Logo

SiStripPopConNoisesDQM.cc
Go to the documentation of this file.
10 {
11 public:
14  // interface methods: implemented in template
15  void dqmEndJob(DQMStore::IBooker& booker, DQMStore::IGetter& getter) override;
16  SiStripNoises* getObj() const override;
17 private:
21 };
22 
25 
28  , fp_{iConfig.getUntrackedParameter<edm::FileInPath>("file", edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))}
29  , MEDir_{iConfig.getUntrackedParameter<std::string>("ME_DIR", "DQMData")}
30 {
31  edm::LogInfo("SiStripNoisesDQMService") << "[SiStripNoisesDQMService::SiStripNoisesDQMService]";
32 }
33 
35 {
36  edm::LogInfo("SiStripNoisesDQMService") << "[SiStripNoisesDQMService::~SiStripNoisesDQMService]";
37 }
38 
40 {
41  std::cout << "SiStripNoisesDQMService::readNoises" << std::endl;
42 
43  m_obj = SiStripNoises();
44 
46 
47  // getter.cd(iConfig_.getUntrackedParameter<std::string>("ME_DIR"));
48  getter.cd();
49 
50  uint32_t stripsPerApv = 128;
51 
52  // Get the full list of monitoring elements
53  // const std::vector<MonitorElement*>& MEs = getter.getAllContents(iConfig_.getUntrackedParameter<std::string>("ME_DIR","DQMData"));
54 
55  // Take a copy of the vector
56  std::vector<MonitorElement*> MEs = getter.getAllContents(MEDir_);
57  // Remove all but the MEs we are using
58  MEs.erase(std::remove_if(MEs.begin(), MEs.end(),
59  [] ( const MonitorElement* ME ) -> bool {
60  return std::string::npos == ME->getName().find("CMSubNoisePerStrip__det__");
61  }), MEs.end());
62 
63  // The histograms are one per DetId, loop on all the DetIds and extract the corresponding histogram
64  for ( const auto& detInfo : reader.getAllData() ) {
65 
66  SiStripNoises::InputVector theSiStripVector;
67 
68  // Take the path for each DetId and build the complete path + histogram name
69 
70 
71  // MonitorElement * mE = getModuleHistogram(detInfo.first, "PedsPerStrip");
72  const MonitorElement * mE{nullptr};
73  std::string MEname("CMSubNoisePerStrip__det__"+std::to_string(detInfo.first));
74  for ( const MonitorElement* ime : MEs ) {
75  if( ime->getName() == MEname ) {
76  mE = ime;
77  break;
78  }
79  }
80 
81  // find( MEs.begin(), MEs.end(), "PedsPerStrip__det__"+std::to_string(detInfo.first), findMEbyName() );
82  // MonitorElement * mE = *(find( MEs.begin(), MEs.end(), findMEbyName("PedsPerStrip__det__"+std::to_string(detInfo.first)) ));
83  if ( mE ) {
84  TH1F* histo = mE->getTH1F();
85  if( histo != nullptr ) {
86  // Read the noise 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 50 (we want a high noise to avoid these modules being considered good by mistake)
106  if( theSiStripVector.empty() ) {
107  for(unsigned short j=0; j<128*detInfo.second.nApvs; ++j){
108  m_obj.setData(50, theSiStripVector);
109  }
110  }
111 
112  if ( ! m_obj.put(detInfo.first, theSiStripVector) )
113  edm::LogError("SiStripNoisesFakeESSource::produce ")<<" detid already exists"<<std::endl;
114  }
115  getter.cd();
116 }
117 
119 {
120  return new SiStripNoises(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
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:51
Definition: ME.h:11
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
bool put(const uint32_t &detID, const InputVector &input)
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0)
Definition: DQMStore.cc:299
SiStripPopConNoisesHandlerFromDQM(const edm::ParameterSet &iConfig)
MonitorElement ME
std::string fullPath() const
Definition: FileInPath.cc:184
SiStripNoises * getObj() const override
void setData(float noise_, InputVector &vped)