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
40 
41 #include <iostream>
42 #include <iomanip>
43 #include <cstdio>
44 #include <string>
45 #include <sstream>
46 #include <cmath>
47 
49  : actionExecutor_{pSet},
50  usedWithEDMtoMEConverter_{pSet.getUntrackedParameter<bool>("UsedWithEDMtoMEConverter", false)},
51  createSummary_{pSet.getUntrackedParameter<bool>("CreateSummary", false)},
52  createTkMap_{pSet.getUntrackedParameter<bool>("CreateTkMap", false)},
53  createTkInfoFile_{pSet.getUntrackedParameter<bool>("CreateTkInfoFile", false)},
54  inputFileName_{pSet.getUntrackedParameter<std::string>("InputFileName", "")},
55  outputFileName_{pSet.getUntrackedParameter<std::string>("OutputFileName", "")},
56  globalStatusFilling_{pSet.getUntrackedParameter<int>("GlobalStatusFilling", 1)},
57  printFaultyModuleList_{pSet.getUntrackedParameter<bool>("PrintFaultyModuleList", false)},
58  detCablingToken_{globalStatusFilling_ > 0 || createTkMap_
59  ? decltype(detCablingToken_){esConsumes<edm::Transition::EndRun>()}
60  : decltype(detCablingToken_){}},
61  tTopoToken_{globalStatusFilling_ > 0 || createTkMap_
62  ? decltype(tTopoToken_){esConsumes<edm::Transition::EndRun>()}
63  : decltype(tTopoToken_){}},
64  tkDetMapToken_{globalStatusFilling_ > 0 || createTkMap_
65  ? decltype(tkDetMapToken_){esConsumes<edm::Transition::EndRun>()}
66  : decltype(tkDetMapToken_){}},
67  geomDetToken_{createTkMap_ && createTkInfoFile_ ? decltype(geomDetToken_){esConsumes<edm::Transition::EndRun>()}
68  : decltype(geomDetToken_){}},
69  runInfoToken_{esConsumes<edm::Transition::BeginRun>()} {
70  if (createTkMap_) {
72  for (const auto& ps : pSet.getUntrackedParameter<std::vector<edm::ParameterSet>>("TkMapOptions")) {
73  edm::ParameterSet tkMapPSet = ps;
74  const auto map_type = ps.getUntrackedParameter<std::string>("mapName", "");
75  tkMapPSet.augment(pSet.getUntrackedParameter<edm::ParameterSet>("TkmapParameters"));
76  const bool useSSQ = tkMapPSet.getUntrackedParameter<bool>("useSSQuality", false);
77  auto token = useSSQ ? QualityToken{esConsumes<edm::Transition::EndRun>(
78  edm::ESInputTag{"", tkMapPSet.getUntrackedParameter<std::string>("ssqLabel", "")})}
79  : QualityToken{};
80  tkMapOptions_.emplace_back(map_type, std::move(tkMapPSet), useSSQ, std::move(token));
81  }
82  }
83 
84  if (createTkInfoFile_) {
85  tkinfoTree_ = edm::Service<TFileService> {}
86  ->make<TTree>("TkDetIdInfo", "");
87  }
88 
89  // explicit dependency to make sure the QTest reults needed here are present
90  // already in endRun.
91  consumes<DQMToken, edm::InRun>(edm::InputTag("siStripQTester", "DQMGenerationQTestRun"));
92  consumes<DQMToken, edm::InLumi>(edm::InputTag("siStripQTester", "DQMGenerationQTestLumi"));
93  usesResource("DQMStore");
94  produces<DQMToken, edm::Transition::EndRun>("DQMGenerationSiStripAnalyserRun");
95  produces<DQMToken, edm::Transition::EndLuminosityBlock>("DQMGenerationSiStripAnalyserLumi");
96 }
97 
99  // Essential: reads xml file to get the histogram names to create summary
100  // Read the summary configuration file
101  if (createSummary_) {
103  edm::LogInfo("ReadConfigurationProblem") << "SiStripOfflineDQM:: Error to read configuration file!! Summary "
104  "will not be produced!!!";
105  createSummary_ = false;
106  }
107  }
108  edm::LogInfo("BeginJobDone") << "SiStripOfflineDQM::beginJob done";
109 }
110 
112  edm::LogInfo("BeginRun") << "SiStripOfflineDQM:: Begining of Run";
113 
114  int nFEDs = 0;
115  if (eSetup.tryToGet<RunInfoRcd>()) {
116  if (auto sumFED = eSetup.getHandle(runInfoToken_)) {
117  constexpr int siStripFedIdMin{FEDNumbering::MINSiStripFEDID};
118  constexpr int siStripFedIdMax{FEDNumbering::MAXSiStripFEDID};
119 
120  for (auto const fedID : sumFED->m_fed_in) {
121  if (fedID >= siStripFedIdMin && fedID <= siStripFedIdMax)
122  ++nFEDs;
123  }
124  }
125  }
126  auto& dqm_store = *edm::Service<DQMStore>{};
127  trackerFEDsFound_ = (nFEDs > 0);
129  if (!openInputFile(dqm_store))
130  createSummary_ = false;
131  }
132  if (globalStatusFilling_ > 0) {
133  actionExecutor_.createStatus(dqm_store);
134  }
135 }
136 
138 
140  edm::LogInfo("EndLumiBlock") << "SiStripOfflineDQM::endLuminosityBlock";
141  if (trackerFEDsFound_) {
142  if (globalStatusFilling_ > 0) {
143  auto& dqm_store = *edm::Service<DQMStore>{};
145  }
146  }
147 }
148 
150  edm::LogInfo("EndOfRun") << "SiStripOfflineDQM::endRun";
151 
152  auto& dqm_store = *edm::Service<DQMStore>{};
153  if (globalStatusFilling_ > 0) {
154  actionExecutor_.createStatus(dqm_store);
155  if (!trackerFEDsFound_) {
157  return;
158  }
159  // Fill Global Status
161  dqm_store, &eSetup.getData(detCablingToken_), &eSetup.getData(tkDetMapToken_), &eSetup.getData(tTopoToken_));
162  }
163 
165  return;
166 
167  // create Summary Plots
168  if (createSummary_)
170 
171  // Create TrackerMap
172  if (createTkMap_) {
174  &eSetup.getData(detCablingToken_), &eSetup.getData(tkDetMapToken_), &eSetup.getData(tTopoToken_))) {
175  std::vector<std::string> mapNames;
176  for (const auto& mapOptions : tkMapOptions_) {
177  edm::LogInfo("TkMapParameters") << mapOptions.pset;
178  std::string map_type = mapOptions.type;
180  mapOptions.pset, dqm_store, map_type, mapOptions.useSSQ ? &eSetup.getData(mapOptions.token) : nullptr);
181  mapNames.push_back(map_type);
182  }
183  if (createTkInfoFile_) {
184  actionExecutor_.createTkInfoFile(mapNames, tkinfoTree_, dqm_store, &eSetup.getData(geomDetToken_));
185  }
186  }
187  }
188 }
189 
191  edm::LogInfo("EndOfJob") << "SiStripOfflineDQM::endJob";
193  return;
194 
196  std::ostringstream str_val;
197  auto& dqm_store = *edm::Service<DQMStore>{};
198  actionExecutor_.printFaultyModuleList(dqm_store, str_val);
199  std::cout << str_val.str() << std::endl;
200  }
201 }
202 
204  if (inputFileName_.empty())
205  return false;
206  edm::LogInfo("OpenFile") << "SiStripOfflineDQM::openInputFile: Accessing root File" << inputFileName_;
207  dqm_store.open(inputFileName_, false);
208  return true;
209 }
210 
SiStripOfflineDQM::endRun
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiStripOfflineDQM.cc:149
FEDNumbering.h
SiStripOfflineDQM::tkMapOptions_
std::vector< MapOptions > tkMapOptions_
Definition: SiStripOfflineDQM.h:103
SiStripActionExecutor.h
edm::ESInputTag
Definition: ESInputTag.h:87
SiStripOfflineDQM::geomDetToken_
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
Definition: SiStripOfflineDQM.h:88
SiStripOfflineDQM::trackerFEDsFound_
bool trackerFEDsFound_
Definition: SiStripOfflineDQM.h:82
MessageLogger.h
SiStripFolderOrganizer.h
SiStripOfflineDQM::actionExecutor_
SiStripActionExecutor actionExecutor_
Definition: SiStripOfflineDQM.h:74
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
SiStripActionExecutor::fillStatusAtLumi
void fillStatusAtLumi(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:125
edm::Run
Definition: Run.h:45
LuminosityBlock.h
SiStripOfflineDQM::tTopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: SiStripOfflineDQM.h:86
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiStripOfflineDQM::createTkInfoFile_
const bool createTkInfoFile_
Definition: SiStripOfflineDQM.h:78
SiStripOfflineDQM::openInputFile
bool openInputFile(DQMStore &dqm_store)
Definition: SiStripOfflineDQM.cc:203
edm::ParameterSet::augment
void augment(ParameterSet const &from)
Definition: ParameterSet.cc:426
DQMStore.h
SiStripActionExecutor::createTkInfoFile
void createTkInfoFile(std::vector< std::string > tkhmap_names, TTree *tkinfo_tree, DQMStore &dqm_store, const GeometricDet *geomDet)
Definition: SiStripActionExecutor.cc:97
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripActionExecutor::createSummaryOffline
void createSummaryOffline(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:64
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:244
SiStripOfflineDQM::tkinfoTree_
TTree * tkinfoTree_
Definition: SiStripOfflineDQM.h:84
FileInPath.h
SiStripOfflineDQM::SiStripOfflineDQM
SiStripOfflineDQM(edm::ParameterSet const &ps)
Definition: SiStripOfflineDQM.cc:48
MakerMacros.h
edm::EventSetup::tryToGet
std::optional< T > tryToGet() const
Definition: EventSetup.h:108
SiStripOfflineDQM::runInfoToken_
edm::ESGetToken< RunInfo, RunInfoRcd > runInfoToken_
Definition: SiStripOfflineDQM.h:89
SiStripOfflineDQM
Definition: SiStripOfflineDQM.h:49
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:81
SiStripOfflineDQM::tkDetMapToken_
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
Definition: SiStripOfflineDQM.h:87
Service.h
SiStripActionExecutor::readTkMapConfiguration
bool readTkMapConfiguration(const SiStripDetCabling *detCabling, const TkDetMap *tkDetMap, const TrackerTopology *tTopo)
Definition: SiStripActionExecutor.cc:41
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:76
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripOfflineDQM::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &iSetup) override
Definition: SiStripOfflineDQM.cc:139
SiStripOfflineDQM::detCablingToken_
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
Definition: SiStripOfflineDQM.h:85
SiStripActionExecutor::createStatus
void createStatus(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:109
SiStripOfflineDQM::printFaultyModuleList_
bool printFaultyModuleList_
Definition: SiStripOfflineDQM.h:83
SiStripOfflineDQM::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiStripOfflineDQM.cc:111
edm::Service< TFileService >
SiStripOfflineDQM::beginJob
void beginJob() override
Definition: SiStripOfflineDQM.cc:98
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::EventSetup
Definition: EventSetup.h:58
SiStripOfflineDQM::inputFileName_
const std::string inputFileName_
Definition: SiStripOfflineDQM.h:79
edm::ESGetToken< SiStripQuality, SiStripQualityRcd >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
SiStripActionExecutor::fillStatus
void fillStatus(DQMStore &dqm_store, const SiStripDetCabling *cabling, const TkDetMap *tkDetMap, const TrackerTopology *tTopo)
Definition: SiStripActionExecutor.cc:118
RunInfo.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripActionExecutor::fillDummyStatus
void fillDummyStatus()
Definition: SiStripActionExecutor.cc:116
SiStripActionExecutor::createOfflineTkMap
void createOfflineTkMap(const edm::ParameterSet &tkmapPset, DQMStore &dqm_store, std::string &map_type, const SiStripQuality *stripQuality)
Definition: SiStripActionExecutor.cc:87
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::endJob
void endJob() override
Definition: SiStripOfflineDQM.cc:190
ParameterSet.h
edm::Event
Definition: Event.h:73
SiStripOfflineDQM::createTkMap_
const bool createTkMap_
Definition: SiStripOfflineDQM.h:78
SiStripOfflineDQM::produce
void produce(edm::Event &e, edm::EventSetup const &eSetup) override
Definition: SiStripOfflineDQM.cc:137
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:77
FEDNumbering::MINSiStripFEDID
Definition: FEDNumbering.h:29
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316