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 
32 
35 
36 #include "SiStripOfflineDQM.h"
37 
38 //Run Info
42 
43 // Cabling
46 
47 #include <iostream>
48 #include <iomanip>
49 #include <cstdio>
50 #include <string>
51 #include <sstream>
52 #include <cmath>
53 
55  : configPar_{pSet},
56  actionExecutor_{pSet},
57  usedWithEDMtoMEConverter_{configPar_.getUntrackedParameter<bool>("UsedWithEDMtoMEConverter", false)},
58  createSummary_{configPar_.getUntrackedParameter<bool>("CreateSummary", false)},
59  createTkInfoFile_{configPar_.getUntrackedParameter<bool>("CreateTkInfoFile", false)},
60  inputFileName_{configPar_.getUntrackedParameter<std::string>("InputFileName", "")},
61  outputFileName_{configPar_.getUntrackedParameter<std::string>("OutputFileName", "")},
62  globalStatusFilling_{configPar_.getUntrackedParameter<int>("GlobalStatusFilling", 1)},
63  printFaultyModuleList_{configPar_.getUntrackedParameter<bool>("PrintFaultyModuleList", false)} {
64  if (createTkInfoFile_) {
65  tkinfoTree_ = edm::Service<TFileService> {}
66  ->make<TTree>("TkDetIdInfo", "");
67  }
68 
69  // explicit dependency to make sure the QTest reults needed here are present
70  // already in endRun.
71  consumes<DQMToken, edm::InRun>(edm::InputTag("siStripQTester", "DQMGenerationQTestRun"));
72  consumes<DQMToken, edm::InLumi>(edm::InputTag("siStripQTester", "DQMGenerationQTestLumi"));
73  usesResource("DQMStore");
74  produces<DQMToken, edm::Transition::EndRun>("DQMGenerationSiStripAnalyserRun");
75  produces<DQMToken, edm::Transition::EndLuminosityBlock>("DQMGenerationSiStripAnalyserLumi");
76 }
77 
79  // Essential: reads xml file to get the histogram names to create summary
80  // Read the summary configuration file
81  if (createSummary_) {
83  edm::LogInfo("ReadConfigurationProblem") << "SiStripOfflineDQM:: Error to read configuration file!! Summary "
84  "will not be produced!!!";
85  createSummary_ = false;
86  }
87  }
88  edm::LogInfo("BeginJobDone") << "SiStripOfflineDQM::beginJob done";
89 }
90 
92  edm::LogInfo("BeginRun") << "SiStripOfflineDQM:: Begining of Run";
93 
94  int nFEDs = 0;
95  if (auto runInfoRec = eSetup.tryToGet<RunInfoRcd>()) {
97  runInfoRec->get(sumFED);
98  if (sumFED.isValid()) {
99  constexpr int siStripFedIdMin{FEDNumbering::MINSiStripFEDID};
100  constexpr int siStripFedIdMax{FEDNumbering::MAXSiStripFEDID};
101 
102  for (auto const fedID : sumFED->m_fed_in) {
103  if (fedID >= siStripFedIdMin && fedID <= siStripFedIdMax)
104  ++nFEDs;
105  }
106  }
107  }
108  auto& dqm_store = *edm::Service<DQMStore>{};
109  trackerFEDsFound_ = (nFEDs > 0);
111  if (!openInputFile(dqm_store))
112  createSummary_ = false;
113  }
114  if (globalStatusFilling_ > 0) {
115  actionExecutor_.createStatus(dqm_store);
116  }
117 }
118 
120 
122  edm::LogInfo("EndLumiBlock") << "SiStripOfflineDQM::endLuminosityBlock";
123  if (trackerFEDsFound_) {
124  if (globalStatusFilling_ > 0) {
125  auto& dqm_store = *edm::Service<DQMStore>{};
127  }
128  }
129 }
130 
132  edm::LogInfo("EndOfRun") << "SiStripOfflineDQM::endRun";
133 
134  // Access Cabling
136  eSetup.get<SiStripDetCablingRcd>().get(det_cabling);
137 
138  auto& dqm_store = *edm::Service<DQMStore>{};
139  if (globalStatusFilling_ > 0) {
140  actionExecutor_.createStatus(dqm_store);
141  if (!trackerFEDsFound_) {
143  return;
144  }
145  // Fill Global Status
146  actionExecutor_.fillStatus(dqm_store, det_cabling, eSetup);
147  }
148 
150  return;
151 
152  // create Summary Plots
153  if (createSummary_)
155 
156  // Create TrackerMap
157  bool const create_tkmap = configPar_.getUntrackedParameter<bool>("CreateTkMap", false);
158  if (create_tkmap) {
159  auto const tkMapOptions = configPar_.getUntrackedParameter<std::vector<edm::ParameterSet>>("TkMapOptions");
161  std::vector<std::string> map_names;
162  for (auto const& ps : tkMapOptions) {
163  edm::ParameterSet tkMapPSet = ps;
164  std::string map_type = ps.getUntrackedParameter<std::string>("mapName", "");
165  map_names.push_back(map_type);
166  tkMapPSet.augment(configPar_.getUntrackedParameter<edm::ParameterSet>("TkmapParameters"));
167  edm::LogInfo("TkMapParameters") << tkMapPSet;
168  actionExecutor_.createOfflineTkMap(tkMapPSet, dqm_store, map_type, eSetup);
169  }
170  if (createTkInfoFile_) {
171  actionExecutor_.createTkInfoFile(map_names, tkinfoTree_, dqm_store);
172  }
173  }
174  }
175 }
176 
178  edm::LogInfo("EndOfJob") << "SiStripOfflineDQM::endJob";
180  return;
181 
183  std::ostringstream str_val;
184  auto& dqm_store = *edm::Service<DQMStore>{};
185  actionExecutor_.printFaultyModuleList(dqm_store, str_val);
186  std::cout << str_val.str() << std::endl;
187  }
188 }
189 
191  if (inputFileName_.empty())
192  return false;
193  edm::LogInfo("OpenFile") << "SiStripOfflineDQM::openInputFile: Accessing root File" << inputFileName_;
194  dqm_store.open(inputFileName_, false);
195  return true;
196 }
197 
SiStripOfflineDQM::endRun
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiStripOfflineDQM.cc:131
FEDNumbering.h
SiStripActionExecutor.h
SiStripOfflineDQM::trackerFEDsFound_
bool trackerFEDsFound_
Definition: SiStripOfflineDQM.h:78
MessageLogger.h
SiStripFolderOrganizer.h
RunSummaryRcd.h
SiStripOfflineDQM::actionExecutor_
SiStripActionExecutor actionExecutor_
Definition: SiStripOfflineDQM.h:70
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
SiStripActionExecutor::fillStatusAtLumi
void fillStatusAtLumi(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:122
edm::Run
Definition: Run.h:45
LuminosityBlock.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiStripOfflineDQM::createTkInfoFile_
const bool createTkInfoFile_
Definition: SiStripOfflineDQM.h:74
SiStripOfflineDQM::openInputFile
bool openInputFile(DQMStore &dqm_store)
Definition: SiStripOfflineDQM.cc:190
SiStripActionExecutor::createTkInfoFile
void createTkInfoFile(std::vector< std::string > tkhmap_names, TTree *tkinfo_tree, DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:96
edm::ParameterSet::augment
void augment(ParameterSet const &from)
Definition: ParameterSet.cc:426
DQMStore.h
RunInfo::m_fed_in
std::vector< int > m_fed_in
Definition: RunInfo.h:25
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripActionExecutor::createSummaryOffline
void createSummaryOffline(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:62
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripActionExecutor::printFaultyModuleList
void printFaultyModuleList(DQMStore &dqm_store, std::ostringstream &str_val)
Definition: SiStripActionExecutor.cc:241
SiStripActionExecutor::fillStatus
void fillStatus(DQMStore &dqm_store, edm::ESHandle< SiStripDetCabling > const &fedcabling, edm::EventSetup const &eSetup)
Definition: SiStripActionExecutor.cc:116
SiStripOfflineDQM::tkinfoTree_
TTree * tkinfoTree_
Definition: SiStripOfflineDQM.h:80
FileInPath.h
SiStripOfflineDQM::SiStripOfflineDQM
SiStripOfflineDQM(edm::ParameterSet const &ps)
Definition: SiStripOfflineDQM.cc:54
MakerMacros.h
SiStripDetCabling.h
edm::EventSetup::tryToGet
std::optional< T > tryToGet() const
Definition: EventSetup.h:101
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
SiStripOfflineDQM
Definition: SiStripOfflineDQM.h:43
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:727
DQMToken.h
SiStripOfflineDQM::globalStatusFilling_
int globalStatusFilling_
Definition: SiStripOfflineDQM.h:77
Service.h
edm::ESHandle
Definition: DTSurvey.h:22
SiStripDetCablingRcd
Definition: SiStripDependentRecords.h:19
RunInfoRcd
Definition: RunSummaryRcd.h:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
FEDNumbering::MAXSiStripFEDID
Definition: FEDNumbering.h:30
SiStripOfflineDQM.h
SiStripOfflineDQM::usedWithEDMtoMEConverter_
bool usedWithEDMtoMEConverter_
Definition: SiStripOfflineDQM.h:72
SiStripActionExecutor::createOfflineTkMap
void createOfflineTkMap(const edm::ParameterSet &tkmapPset, DQMStore &dqm_store, std::string &map_type, const edm::EventSetup &eSetup)
Definition: SiStripActionExecutor.cc:86
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripOfflineDQM::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &iSetup) override
Definition: SiStripOfflineDQM.cc:121
SiStripActionExecutor::createStatus
void createStatus(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:107
SiStripOfflineDQM::printFaultyModuleList_
bool printFaultyModuleList_
Definition: SiStripOfflineDQM.h:79
SiStripOfflineDQM::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiStripOfflineDQM.cc:91
edm::Service< TFileService >
SiStripOfflineDQM::beginJob
void beginJob() override
Definition: SiStripOfflineDQM.cc:78
edm::EventSetup
Definition: EventSetup.h:57
SiStripOfflineDQM::inputFileName_
const std::string inputFileName_
Definition: SiStripOfflineDQM.h:75
SiStripActionExecutor::readTkMapConfiguration
bool readTkMapConfiguration(const edm::EventSetup &eSetup)
Definition: SiStripActionExecutor.cc:41
get
#define get
RunSummary.h
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
RunInfo.h
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripActionExecutor::fillDummyStatus
void fillDummyStatus()
Definition: SiStripActionExecutor.cc:114
SiStripActionExecutor::readConfiguration
bool readConfiguration()
Definition: SiStripActionExecutor.cc:29
dqm::implementation::DQMStore::open
DQM_DEPRECATED 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:767
SiStripOfflineDQM::configPar_
const edm::ParameterSet configPar_
Definition: SiStripOfflineDQM.h:68
SiStripDetCablingRcd.h
SiStripOfflineDQM::endJob
void endJob() override
Definition: SiStripOfflineDQM.cc:177
ParameterSet.h
edm::Event
Definition: Event.h:73
SiStripOfflineDQM::produce
void produce(edm::Event &e, edm::EventSetup const &eSetup) override
Definition: SiStripOfflineDQM.cc:119
edm::InputTag
Definition: InputTag.h:15
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
SiStripOfflineDQM::createSummary_
bool createSummary_
Definition: SiStripOfflineDQM.h:73
FEDNumbering::MINSiStripFEDID
Definition: FEDNumbering.h:29