CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripPedestalsDQMService.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<SiStripPedestals>::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("SiStripPedestalsDQMService") << "[SiStripPedestalsDQMService::SiStripPedestalsDQMService]";
21 }
22 
24 {
25  edm::LogInfo("SiStripPedestalsDQMService") << "[SiStripPedestalsDQMService::~SiStripPedestalsDQMService]";
26 }
27 
29 {
30  std::cout << "SiStripPedestalsDQMService::readPedestals" << std::endl;
31 
33 
34  std::cout << "[readBadComponents]: opened requested file" << std::endl;
35 
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("PedsPerStrip__det__"));
52  MEs.erase(newEnd, MEs.end());
53 
54 
55  // The histograms are one per DetId, loop on all the DetIds and extract the corresponding histogram
56  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo> DetInfos = reader.getAllData();
57  for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>::const_iterator it = DetInfos.begin(); it != DetInfos.end(); ++it) {
58 
59 
60  SiStripPedestals::InputVector theSiStripVector;
61 
62  // Take the path for each DetId and build the complete path + histogram name
63 
64 
65  // MonitorElement * mE = getModuleHistogram(it->first, "PedsPerStrip");
66 
67 
68  MonitorElement * mE = 0;
69  std::string MEname("PedsPerStrip__det__"+boost::lexical_cast<string>(it->first));
70  for( std::vector<MonitorElement*>::const_iterator MEit = MEs.begin();
71  MEit != MEs.end(); ++MEit ) {
72  if( (*MEit)->getName() == MEname ) {
73  mE = *MEit;
74  break;
75  }
76  }
77 
78  // find( MEs.begin(), MEs.end(), "PedsPerStrip__det__"+boost::lexical_cast<string>(it->first), findMEbyName() );
79  // MonitorElement * mE = *(find( MEs.begin(), MEs.end(), findMEbyName("PedsPerStrip__det__"+boost::lexical_cast<string>(it->first)) ));
80 
81  if( mE != 0 ) {
82  TH1F* histo = mE->getTH1F();
83 
84  if( histo != 0 ) {
85 
86  // Read the pedestals from the histograms
87  uint32_t nBinsX = histo->GetXaxis()->GetNbins();
88 
89  if( nBinsX != stripsPerApv*(it->second.nApvs) ) {
90  std::cout << "ERROR: number of bin = " << nBinsX << " != number of strips = " << stripsPerApv*(it->second.nApvs) << std::endl;
91  }
92 
93  // std::cout << "Bin 0 = " << histo->GetBinContent(0) << std::endl;
94 
95  // TH1 bins start from 1, 0 is the underflow, nBinsX+1 the overflow.
96  for( uint32_t iBin = 1; iBin <= nBinsX; ++iBin ) {
97  // encode the pedestal value and put it in the vector (push_back)
98  obj_->setData( histo->GetBinContent(iBin), theSiStripVector );
99  }
100  }
101  else {
102  std::cout << "ERROR: histo = " << histo << std::endl;
103  }
104  }
105  else {
106  std::cout << "ERROR: ME = " << mE << std::endl;
107  }
108  // If the ME was absent fill the vector with 0
109  if( theSiStripVector.empty() ) {
110  for(unsigned short j=0; j<128*it->second.nApvs; ++j){
111  obj_->setData(0, theSiStripVector);
112  }
113  }
114 
115  if ( ! obj_->put(it->first, theSiStripVector) )
116  edm::LogError("SiStripPedestalsFakeESSource::produce ")<<" detid already exists"<<std::endl;
117  }
118  dqmStore_->cd();
119 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< uint16_t > InputVector
int j
Definition: DBlmapReader.cc:9
bool put(const uint32_t &detID, InputVector &input)
TH1F * getTH1F(void) const
void setData(float ped, InputVector &vped)
tuple cout
Definition: gather_cfg.py:121
std::string fullPath() const
Definition: FileInPath.cc:165
void openRequestedFile()
Uses DQMStore to access the DQM file.
SiStripPedestalsDQMService(const edm::ParameterSet &, const edm::ActivityRegistry &)