test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripBaseServiceFromDQM.h
Go to the documentation of this file.
1 #ifndef DQMOffline_SiStripBaseServiceFromDQM_SiStripBaseServiceFromDQM_H
2 #define DQMOffline_SiStripBaseServiceFromDQM_SiStripBaseServiceFromDQM_H
3 
11 
12 #include "TH1.h"
13 
14 #include <string>
15 #include <memory>
16 #include <sstream>
17 #include <algorithm>
18 #include <boost/lexical_cast.hpp>
19 #include <boost/shared_ptr.hpp>
20 
21 
22 
29 template <class T>
31 {
32  public:
33 
36 
38  virtual void getMetaDataString(std::stringstream& ss);
40  virtual bool checkForCompatibility(std::string ss);
41 
42  protected:
43 
45  void openRequestedFile();
47  bool goToDir(const std::string & name);
49  void getModuleFolderList(std::vector<std::string>& mfolders);
51  uint32_t getRunNumber() const;
58  MonitorElement * getModuleHistogram(const uint32_t detId, const std::string & name);
59 
62  boost::shared_ptr<SiStripFolderOrganizer> folderOrganizer_;
63 
64  // Simple functor to remove unneeded ME
66  {
67  StringNotMatch(const std::string & name) :
68  name_(name)
69  {
70  }
71  bool operator()(const MonitorElement * ME) const
72  {
73  return( ME->getName().find(name_) == std::string::npos );
74  }
75  protected:
77  };
78 
79 };
80 
81 template <class T>
84  iConfig_(iConfig),
85  folderOrganizer_(boost::shared_ptr<SiStripFolderOrganizer>(new SiStripFolderOrganizer))
86 {
87  // Needed because this is a template inheriting from another template, so it cannot
88  // access directly unnamed (independent from the template parameters) members.
89  this->obj_ = 0;
90 }
91 
92 template <class T>
94 {
95 }
96 
97 template <class T>
99 {
100  dqmStore_ = edm::Service<DQMStore>().operator->();
101 
102  // ** FIXME ** //
103  dqmStore_->setVerbose(0); //add config param
104 
105  if( iConfig_.getParameter<bool>("accessDQMFile") ){
106 
107  std::string fileName = iConfig_.getUntrackedParameter<std::string>("FILE_NAME","");
108 
109  edm::LogInfo("SiStripBaseServiceFromDQM") << "[SiStripBaseServiceFromDQM::openRequestedFile] Accessing root File" << fileName;
110 
111  dqmStore_->open(fileName, false);
112  } else {
113  edm::LogInfo("SiStripBaseServiceFromDQM") << "[SiStripBaseServiceFromDQM::openRequestedFile] Accessing dqmStore stream in Online Operation";
114  }
115 }
116 
117 template <class T>
119 {
120  std::string currDir = dqmStore_->pwd();
121  std::string dirName = currDir.substr(currDir.find_last_of("/")+1);
122  // Protection vs directories written with a trailing "/"
123  if( dirName.length() == 0 ) {
124  std::string currDirCopy(currDir, 0, currDir.length()-1);
125  dirName = currDirCopy.substr(currDirCopy.find_last_of("/")+1);
126  }
127  if (dirName.find(name) == 0) {
128  return true;
129  }
130  std::vector<std::string> subDirVec = dqmStore_->getSubdirs();
131  for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
132  ic != subDirVec.end(); ic++) {
133  dqmStore_->cd(*ic);
134  if (!goToDir(name)) dqmStore_->goUp();
135  else return true;
136  }
137  return false;
138 }
139 
140 template <class T>
141 void SiStripBaseServiceFromDQM<T>::getModuleFolderList(std::vector<std::string>& mfolders)
142 {
143  std::string currDir = dqmStore_->pwd();
144  if (currDir.find("module_") != std::string::npos) {
145  // std::string mId = currDir.substr(currDir.find("module_")+7, 9);
146  mfolders.push_back(currDir);
147  } else {
148  std::vector<std::string> subdirs = dqmStore_->getSubdirs();
149  for( std::vector<std::string>::const_iterator it = subdirs.begin();
150  it != subdirs.end(); ++it) {
151  dqmStore_->cd(*it);
152  getModuleFolderList(mfolders);
153  dqmStore_->goUp();
154  }
155  }
156 }
157 
158 // template <class T>
159 // MonitorElement * SiStripBaseServiceFromDQM<T>::getModuleHistogram(const uint32_t detId, const std::string & name)
160 // {
161 // // Take the full path to the histogram
162 // std::string path;
163 // folderOrganizer_->getFolderName(detId, path);
164 // std::cout << "path = " << path << std::endl;
165 // // build the name of the histogram
166 // std::cout << "pwd = " << dqmStore_->pwd() << std::endl;
167 // // std::string fullName(dqmStore_->pwd()+"/"+path+"/"+name+"__det__");
168 // std::string fullName(path+"/"+name+"__det__");
169 // fullName += boost::lexical_cast<std::string>(detId);
170 
171 // // ATTENTION: fixing the problem in the folderOrganizer
172 // size_t firstSlash = fullName.find_first_of("/");
173 // fullName = fullName.substr(firstSlash, fullName.size());
174 // // fullName = dqmStore_->pwd() + "/SiStrip/Run summary" + fullName;
175 // fullName = "SiStrip/Run summary" + fullName;
176 
177 // std::cout << "fullName = " << fullName << std::endl;
178 
179 // return dqmStore_->get(fullName);
180 // }
181 
182 template <class T>
184 {
185  edm::LogInfo("SiStripBaseServiceFromDQM") << "[SiStripBaseServiceFromDQM::getRunNumber] " << iConfig_.getParameter<uint32_t>("RunNb");
186  return iConfig_.getParameter<uint32_t>("RunNb");
187 }
188 
189 template <class T>
191 {
192  std::cout << "SiStripPedestalsDQMService::getMetaDataString" << std::endl;
193  ss << "Run " << getRunNumber() << std::endl;
194 }
195 
196 template <class T>
198 {
199  std::stringstream localString;
200  getMetaDataString(localString);
201  if( ss == localString.str() ) return false;
202 
203  return true;
204 }
205 
206 #endif //DQMOffline_SiStripBaseServiceFromDQM_SiStripBaseServiceFromDQM_H
const std::string & getName(void) const
get name of ME
boost::shared_ptr< SiStripFolderOrganizer > folderOrganizer_
virtual bool checkForCompatibility(std::string ss)
Check is the transfer is needed.
bool operator()(const MonitorElement *ME) const
bool goToDir(const std::string &name)
Uses DQM utilities to access the requested dir.
uint32_t getRunNumber() const
Returns the run number from the cfg.
Definition: ME.h:11
virtual void getMetaDataString(std::stringstream &ss)
Used to fill the logDB.
void getModuleFolderList(std::vector< std::string > &mfolders)
Fill the mfolders vector with the full list of directories for all the modules.
MonitorElement * getModuleHistogram(const uint32_t detId, const std::string &name)
tuple cout
Definition: gather_cfg.py:145
long double T
void openRequestedFile()
Uses DQMStore to access the DQM file.
SiStripBaseServiceFromDQM(const edm::ParameterSet &)