CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripNoisesDQMService.cc
Go to the documentation of this file.
5 #include <string>
6 #include <sstream>
7 #include <cctype>
8 #include <time.h>
9 #include <boost/cstdint.hpp>
10 
11 using namespace std;
12 
14  // SiStripCondObjBuilderBase<SiStripNoises>::SiStripCondObjBuilderBase(iConfig),
16  iConfig_(iConfig),
17  fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat")))
18 {
19  obj_ = 0;
20  edm::LogInfo("SiStripNoisesDQMService") << "[SiStripNoisesDQMService::SiStripNoisesDQMService]";
21 }
22 
24 {
25  edm::LogInfo("SiStripNoisesDQMService") << "[SiStripNoisesDQMService::~SiStripNoisesDQMService]";
26 }
27 
29 {
30  std::cout << "SiStripNoisesDQMService::readNoises" << std::endl;
31 
33 
34  std::cout << "[readBadComponents]: opened requested file" << std::endl;
35 
36  obj_= new SiStripNoises;
37 
39 
40  // dqmStore_->cd(iConfig_.getUntrackedParameter<std::string>("ME_DIR"));
41  dqmStore_->cd();
42 
43  uint32_t stripsPerApv = 128;
44 
45  // Get the full list of monitoring elements
46  // const std::vector<MonitorElement*>& MEs = dqmStore_->getAllContents(iConfig_.getUntrackedParameter<std::string>("ME_DIR","DQMData"));
47 
48  // Take a copy of the vector
49  std::vector<MonitorElement*> MEs = dqmStore_->getAllContents(iConfig_.getUntrackedParameter<std::string>("ME_DIR","DQMData"));
50  // Remove all but the MEs we are using
51  std::vector<MonitorElement*>::iterator newEnd = remove_if(MEs.begin(), MEs.end(), StringNotMatch("CMSubNoisePerStrip__det__"));
52  MEs.erase(newEnd, MEs.end());
53 
54  // The histograms are one per DetId, loop on all the DetIds and extract the corresponding histogram
55  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo> DetInfos = reader.getAllData();
56  for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>::const_iterator it = DetInfos.begin(); it != DetInfos.end(); ++it) {
57 
58 
59  SiStripNoises::InputVector theSiStripVector;
60 
61  // Take the path for each DetId and build the complete path + histogram name
62 
63 
64  // MonitorElement * mE = getModuleHistogram(it->first, "PedsPerStrip");
65 
66 
67  MonitorElement * mE = 0;
68  std::string MEname("CMSubNoisePerStrip__det__"+boost::lexical_cast<string>(it->first));
69  for( std::vector<MonitorElement*>::const_iterator MEit = MEs.begin();
70  MEit != MEs.end(); ++MEit ) {
71  if( (*MEit)->getName() == MEname ) {
72  mE = *MEit;
73  break;
74  }
75  }
76 
77  // find( MEs.begin(), MEs.end(), "PedsPerStrip__det__"+boost::lexical_cast<string>(it->first), findMEbyName() );
78  // MonitorElement * mE = *(find( MEs.begin(), MEs.end(), findMEbyName("PedsPerStrip__det__"+boost::lexical_cast<string>(it->first)) ));
79 
80  if( mE != 0 ) {
81  TH1F* histo = mE->getTH1F();
82 
83  if( histo != 0 ) {
84 
85  // Read the noise from the histograms
86  uint32_t nBinsX = histo->GetXaxis()->GetNbins();
87 
88  if( nBinsX != stripsPerApv*(it->second.nApvs) ) {
89  std::cout << "ERROR: number of bin = " << nBinsX << " != number of strips = " << stripsPerApv*(it->second.nApvs) << std::endl;
90  }
91 
92  // std::cout << "Bin 0 = " << histo->GetBinContent(0) << std::endl;
93 
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  obj_->setData( histo->GetBinContent(iBin), theSiStripVector );
98  }
99  }
100  else {
101  std::cout << "ERROR: histo = " << histo << std::endl;
102  }
103  }
104  else {
105  std::cout << "ERROR: ME = " << mE << std::endl;
106  }
107  // If the ME was absent fill the vector with 50 (we want a high noise to avoid these modules being considered good by mistake)
108  if( theSiStripVector.empty() ) {
109  for(unsigned short j=0; j<128*it->second.nApvs; ++j){
110  obj_->setData(50, theSiStripVector);
111  }
112  }
113 
114  if ( ! obj_->put(it->first, theSiStripVector) )
115  edm::LogError("SiStripNoisesFakeESSource::produce ")<<" detid already exists"<<std::endl;
116  }
117  dqmStore_->cd();
118 }
T getUntrackedParameter(std::string const &, T const &) const
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:561
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:47
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1836
SiStripNoisesDQMService(const edm::ParameterSet &, const edm::ActivityRegistry &)
int j
Definition: DBlmapReader.cc:9
bool put(const uint32_t &detID, const InputVector &input)
TH1F * getTH1F(void) const
tuple cout
Definition: gather_cfg.py:121
std::string fullPath() const
Definition: FileInPath.cc:171
void setData(float noise_, InputVector &vped)
void openRequestedFile()
Uses DQMStore to access the DQM file.