CMS 3D CMS Logo

SiStripOfflineDQM.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripMonitorCluster
4 // Class: SiStripOfflineDQM
5 //
14 //
15 // Original Author: Samvel Khalatyan (ksamdev at gmail dot com)
16 // Created: Wed Oct 5 16:42:34 CET 2006
17 //
18 //
19 
25 
27 
29 
31 
34 
35 #include "SiStripOfflineDQM.h"
36 
37 //Run Info
41 
42 // Cabling
45 
46 #include <iostream>
47 #include <iomanip>
48 #include <cstdio>
49 #include <string>
50 #include <sstream>
51 #include <cmath>
52 
54  : configPar_{pSet},
55  actionExecutor_{pSet},
57  configPar_.getUntrackedParameter<bool>("UsedWithEDMtoMEConverter",
58  false)},
60  configPar_.getUntrackedParameter<bool>("CreateSummary", false)},
62  configPar_.getUntrackedParameter<bool>("CreateTkInfoFile", false)},
64  configPar_.getUntrackedParameter<std::string>("InputFileName", "")},
66  configPar_.getUntrackedParameter<std::string>("OutputFileName", "")},
68  configPar_.getUntrackedParameter<int>("GlobalStatusFilling", 1)},
70  configPar_.getUntrackedParameter<bool>("PrintFaultyModuleList", false)}
71 {
72  if (createTkInfoFile_) {
74  ->make<TTree>("TkDetIdInfo", "");
75  }
76 }
77 
78 void
80 {
81  // Essential: reads xml file to get the histogram names to create summary
82  // Read the summary configuration file
83  if (createSummary_) {
85  edm::LogInfo("ReadConfigurationProblem")
86  << "SiStripOfflineDQM:: Error to read configuration file!! Summary "
87  "will not be produced!!!";
88  createSummary_ = false;
89  }
90  }
91  edm::LogInfo("BeginJobDone") << "SiStripOfflineDQM::beginJob done";
92 }
93 
94 void
96 {
97  edm::LogInfo ("BeginRun") <<"SiStripOfflineDQM:: Begining of Run";
98 
99  int nFEDs = 0;
100  if(auto runInfoRec = eSetup.tryToGet<RunInfoRcd>()) {
101 
102  edm::ESHandle<RunInfo> sumFED;
103  runInfoRec->get(sumFED);
104  if (sumFED.isValid()) {
105  constexpr int siStripFedIdMin{FEDNumbering::MINSiStripFEDID};
106  constexpr int siStripFedIdMax{FEDNumbering::MAXSiStripFEDID};
107 
108  for (auto const fedID : sumFED->m_fed_in) {
109  if (fedID >= siStripFedIdMin && fedID <= siStripFedIdMax) ++nFEDs;
110  }
111  }
112  }
113  auto& dqm_store = *edm::Service<DQMStore>{};
114  trackerFEDsFound_ = (nFEDs > 0);
116  if (!openInputFile(dqm_store)) createSummary_ = false;
117  }
118  if (globalStatusFilling_ > 0) {
119  actionExecutor_.createStatus(dqm_store);
120  }
121 }
122 
123 void
125 {}
126 
127 void
129  edm::EventSetup const& iSetup)
130 {
131  edm::LogInfo( "EndLumiBlock") << "SiStripOfflineDQM::endLuminosityBlock";
132  if (trackerFEDsFound_) {
133  if (globalStatusFilling_ > 0) {
134  auto& dqm_store = *edm::Service<DQMStore>{};
136  }
137  }
138 }
139 
140 void
142 {
143  edm::LogInfo( "EndOfRun") << "SiStripOfflineDQM::endRun";
144 
145  // Access Cabling
147  eSetup.get<SiStripDetCablingRcd>().get(det_cabling);
148 
149  auto& dqm_store = *edm::Service<DQMStore>{};
150  if (globalStatusFilling_ > 0) {
151  actionExecutor_.createStatus(dqm_store);
152  if (!trackerFEDsFound_) {
154  return;
155  }
156  // Fill Global Status
157  actionExecutor_.fillStatus(dqm_store, det_cabling, eSetup);
158  }
159 
160  if (usedWithEDMtoMEConverter_) return;
161 
162  // create Summary Plots
164 
165  // Create TrackerMap
166  bool const create_tkmap =
167  configPar_.getUntrackedParameter<bool>("CreateTkMap", false);
168  if (create_tkmap) {
169  auto const tkMapOptions =
170  configPar_.getUntrackedParameter<std::vector<edm::ParameterSet>>(
171  "TkMapOptions");
173  std::vector<std::string> map_names;
174  for (auto const& ps : tkMapOptions) {
175  edm::ParameterSet tkMapPSet = ps;
176  std::string map_type =
177  ps.getUntrackedParameter<std::string>("mapName", "");
178  map_names.push_back(map_type);
180  "TkmapParameters"));
181  edm::LogInfo("TkMapParameters") << tkMapPSet;
183  tkMapPSet, dqm_store, map_type, eSetup);
184  }
185  if (createTkInfoFile_) {
186  actionExecutor_.createTkInfoFile(map_names, tkinfoTree_, dqm_store);
187  }
188  }
189  }
190 }
191 
192 void
194 {
195  edm::LogInfo( "EndOfJob") << "SiStripOfflineDQM::endJob";
196  if (usedWithEDMtoMEConverter_) return;
197 
199  std::ostringstream str_val;
200  auto& dqm_store = *edm::Service<DQMStore>{};
201  actionExecutor_.printFaultyModuleList(dqm_store, str_val);
202  std::cout << str_val.str() << std::endl;
203  }
204 }
205 
206 bool
208 {
209  if (inputFileName_.empty()) return false;
210  edm::LogInfo("OpenFile") << "SiStripOfflineDQM::openInputFile: Accessing root File" << inputFileName_;
211  dqm_store.open(inputFileName_, false);
212  return true;
213 }
214 
T getUntrackedParameter(std::string const &, T const &) const
std::optional< T > tryToGet() const
Definition: EventSetup.h:92
std::string const inputFileName_
SiStripOfflineDQM(edm::ParameterSet const &ps)
void fillStatusAtLumi(DQMStore &dqm_store)
void createTkInfoFile(std::vector< std::string > tkhmap_names, TTree *tkinfo_tree, DQMStore &dqm_store)
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
bool readTkMapConfiguration(const edm::EventSetup &eSetup)
void fillStatus(DQMStore &dqm_store, edm::ESHandle< SiStripDetCabling > const &fedcabling, edm::EventSetup const &eSetup)
void augment(ParameterSet const &from)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool openInputFile(DQMStore &dqm_store)
std::vector< int > m_fed_in
Definition: RunInfo.h:26
bool const createTkInfoFile_
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:2883
void endJob() override
void printFaultyModuleList(DQMStore &dqm_store, std::ostringstream &str_val)
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &iSetup) override
void createStatus(DQMStore &dqm_store)
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
void beginJob() override
T get() const
Definition: EventSetup.h:71
void createSummaryOffline(DQMStore &dqm_store)
std::string const outputFileName_
SiStripActionExecutor actionExecutor_
bool isValid() const
Definition: ESHandle.h:44
edm::ParameterSet const configPar_
void createOfflineTkMap(const edm::ParameterSet &tkmapPset, DQMStore &dqm_store, std::string &map_type, const edm::EventSetup &eSetup)
#define constexpr
Definition: Run.h:45