CMS 3D CMS Logo

SiStripOfflineDQM.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripMonitorCluster
4 // Class: SiStripOfflineDQM
5 //
13 //
14 // Original Author: Samvel Khalatyan (ksamdev at gmail dot com)
15 // Created: Wed Oct 5 16:42:34 CET 2006
16 //
17 //
18 
20 
21 
26 
28 
30 
32 
35 
36 #include "SiStripOfflineDQM.h"
37 
38 //Run Info
42 // Cabling
45 //#include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
46 
47 #include <iostream>
48 #include <iomanip>
49 #include <cstdio>
50 #include <string>
51 #include <sstream>
52 #include <cmath>
53 
54 
63  // Create MessageSender
64 
65  // Action Executor
67 
68  // get back-end interface
70 
71  usedWithEDMtoMEConverter_= configPar_.getUntrackedParameter<bool>("UsedWithEDMtoMEConverter",false);
72  createSummary_ = configPar_.getUntrackedParameter<bool>("CreateSummary",false);
73  createTkInfoFile_ = configPar_.getUntrackedParameter<bool>("CreateTkInfoFile",false);
76  globalStatusFilling_ = configPar_.getUntrackedParameter<int>("GlobalStatusFilling", 1);
77  printFaultyModuleList_ = configPar_.getUntrackedParameter<bool>("PrintFaultyModuleList", false);
78 
79  nEvents_ = 0;
80 
81  tkinfoTree_ = nullptr;
82 
83  if(createTkInfoFile_) {
85  tkinfoTree_ = fs->make<TTree>("TkDetIdInfo", "");
86  }
87 
88 }
95 
96 }
105 
106  // Essential: reads xml file to get the histogram names to create summary
107  // Read the summary configuration file
108  if (createSummary_) {
110  edm::LogInfo ("ReadConfigurationProblem") <<"SiStripOfflineDQM:: Error to read configuration file!! Summary will not be produced!!!";
111  createSummary_ = false;
112  }
113  }
114  edm::LogInfo("BeginJobDone") << "SiStripOfflineDQM::beginJob done";
115 }
126  edm::LogInfo ("BeginRun") <<"SiStripOfflineDQM:: Begining of Run";
127 
128  int nFEDs = 0;
129  if(auto runInfoRec = eSetup.tryToGet<RunInfoRcd>()) {
130 
131  edm::ESHandle<RunInfo> sumFED;
132  runInfoRec->get(sumFED);
133  if ( sumFED.isValid() ) {
134 
135  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
136  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
137 
138  std::vector<int> FedsInIds= sumFED->m_fed_in;
139  for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
140  int fedID = FedsInIds[it];
141 
142  if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDs;
143  }
144  }
145  }
146  if (nFEDs > 0) trackerFEDsFound_ = true;
147  else trackerFEDsFound_ = false;
149  if (!openInputFile()) createSummary_ = false;
150  }
152 }
165  nEvents_++;
166 }
174  edm::LogInfo( "EndLumiBlock") << "SiStripOfflineDQM::endLuminosityBlock";
175  if (trackerFEDsFound_) {
177  }
178 }
186 
187  edm::LogInfo( "EndOfRun") << "SiStripOfflineDQM::endRun";
188 
189  // Access Cabling
191  eSetup.get<SiStripDetCablingRcd>().get(det_cabling);
192  // edm::ESHandle< SiStripFedCabling > fed_cabling;
193  // eSetup.get<SiStripFedCablingRcd>().get(fed_cabling);
195 
196  if (!trackerFEDsFound_) {
198  return;
199  }
200 
201  // Fill Global Status
202  if (globalStatusFilling_ > 0) actionExecutor_->fillStatus(dqmStore_, det_cabling, eSetup);
203 
205 
206  // create Summary Plots
208 
209  // Create TrackerMap
210  bool create_tkmap = configPar_.getUntrackedParameter<bool>("CreateTkMap",false);
211  if (create_tkmap) {
212  std::vector<edm::ParameterSet> tkMapOptions = configPar_.getUntrackedParameter< std::vector<edm::ParameterSet> >("TkMapOptions" );
214  std::vector<std::string> map_names;
215 
216  for(std::vector<edm::ParameterSet>::iterator it = tkMapOptions.begin(); it != tkMapOptions.end(); ++it) {
217  edm::ParameterSet tkMapPSet = *it;
218  std::string map_type = it->getUntrackedParameter<std::string>("mapName","");
219  map_names.push_back(map_type);
220  tkMapPSet.augment(configPar_.getUntrackedParameter<edm::ParameterSet>("TkmapParameters"));
221  edm::LogInfo("TkMapParameters") << tkMapPSet;
222  actionExecutor_->createOfflineTkMap(tkMapPSet, dqmStore_, map_type, eSetup);
223  }
224  if(createTkInfoFile_) {
226  }
227  }
228  }
229  }
230 }
238 
239  edm::LogInfo( "EndOfJob") << "SiStripOfflineDQM::endJob";
242  std::ostringstream str_val;
244  std::cout << str_val.str() << std::endl;
245  }
246  }
247 }
255  if (inputFileName_.empty()) return false;
256  edm::LogInfo("OpenFile") << "SiStripOfflineDQM::openInputFile: Accessing root File" << inputFileName_;
257  dqmStore_->open(inputFileName_, false);
258  return true;
259 }
260 
T getUntrackedParameter(std::string const &, T const &) const
SiStripActionExecutor * actionExecutor_
std::optional< T > tryToGet() const
Definition: EventSetup.h:87
void createOfflineTkMap(const edm::ParameterSet &tkmapPset, DQMStore *dqm_store, std::string &map_type, const edm::EventSetup &eSetup)
SiStripOfflineDQM(const edm::ParameterSet &ps)
Constructor.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
EndRun.
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
Analyze.
void fillStatus(DQMStore *dqm_store, const edm::ESHandle< SiStripDetCabling > &fedcabling, const edm::EventSetup &eSetup)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::string outputFileName_
bool readTkMapConfiguration(const edm::EventSetup &eSetup)
void createStatus(DQMStore *dqm_store)
void augment(ParameterSet const &from)
std::vector< int > m_fed_in
Definition: RunInfo.h:26
bool open(std::string const &filename, bool overwrite=false, std::string const &path="", std::string const &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2861
std::string inputFileName_
void endJob() override
Endjob.
void fillStatusAtLumi(DQMStore *dqm_store)
~SiStripOfflineDQM() override
Destructor.
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &iSetup) override
End Of Luminosity.
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
BeginRun.
void beginJob() override
BeginJob.
bool openInputFile()
Open Input File.
void createTkInfoFile(std::vector< std::string > tkhmap_names, TTree *tkinfo_tree, DQMStore *dqm_store)
T get() const
Definition: EventSetup.h:68
void createSummaryOffline(DQMStore *dqm_store)
bool isValid() const
Definition: ESHandle.h:45
void printFaultyModuleList(DQMStore *dqm_store, std::ostringstream &str_val)
Definition: Run.h:44
edm::ParameterSet configPar_