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