CMS 3D CMS Logo

SiStripAnalyser.cc
Go to the documentation of this file.
1 /*
2  * \file SiStripAnalyser.cc
3  *
4  * \author S. Dutta INFN-Pisa
5  *
6  */
7 
8 #include "SiStripAnalyser.h"
9 
17 
19 
24 
27 
28 #include <cmath>
29 #include <cstdio>
30 #include <iomanip>
31 #include <iostream>
32 #include <sstream>
33 #include <string>
34 
36  : condDataMon_{ps, consumesCollector()},
37  actionExecutor_{ps},
38  tkMapPSet_{ps.getParameter<edm::ParameterSet>("TkmapParameters")},
39  summaryFrequency_{ps.getUntrackedParameter<int>("SummaryCreationFrequency", 1)},
40  staticUpdateFrequency_{ps.getUntrackedParameter<int>("StaticUpdateFrequency", 1)},
41  globalStatusFilling_{ps.getUntrackedParameter<int>("GlobalStatusFilling", 1)},
42  shiftReportFrequency_{ps.getUntrackedParameter<int>("ShiftReportFrequency", 1)},
43  rawDataToken_{consumes<FEDRawDataCollection>(ps.getUntrackedParameter<edm::InputTag>("RawDataTag"))},
44  detCablingToken_(esConsumes<edm::Transition::BeginRun>()),
45  tTopoToken_(esConsumes()),
46  tTopoTokenELB_(esConsumes<edm::Transition::EndLuminosityBlock>()),
47  tTopoTokenBR_(esConsumes<edm::Transition::BeginRun>()),
48  tkDetMapToken_(esConsumes()),
49  tkDetMapTokenELB_(esConsumes<edm::Transition::EndLuminosityBlock>()),
50  tkDetMapTokenBR_(esConsumes<edm::Transition::BeginRun>()),
51  printFaultyModuleList_{ps.getUntrackedParameter<bool>("PrintFaultyModuleList", true)} {
52  std::string const localPath{"DQM/SiStripMonitorClient/test/loader.html"};
53  std::ifstream fin{edm::FileInPath(localPath).fullPath(), std::ios::in};
54  if (!fin) {
55  std::cerr << "Input File: loader.html"
56  << " could not be opened!" << std::endl;
57  return;
58  }
59  edm::LogInfo("SiStripAnalyser") << " SiStripAnalyser::Creating SiStripAnalyser ";
60 }
61 
62 SiStripAnalyser::~SiStripAnalyser() { edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser::Deleting SiStripAnalyser "; }
63 
65  // Read the summary configuration file
67  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Error to read configuration file!! Summary will "
68  "not be produced!!!";
69  }
70 }
71 
73  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Begining of Run";
74 
75  // Check latest Fed cabling and create TrackerMapCreator
76  if (fedCablingWatcher_.check(eSetup)) {
77  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser::beginRun: "
78  << " Change in Cabling, recrated TrackerMap";
82  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Error to read configuration file!! TrackerMap "
83  "will not be produced!!!";
84  }
85  }
86  condDataMon_.beginRun(run.run(), eSetup);
88  auto& dqm_store = *edm::Service<DQMStore>{};
89  actionExecutor_.createStatus(dqm_store);
90  }
91 }
92 
94  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Begin of LS transition";
95 }
96 
98  ++nEvents_;
99  if (nEvents_ == 1 && globalStatusFilling_ > 0) {
101  if (!trackerFEDsFound_) {
104  } else {
105  auto& dqm_store = *edm::Service<DQMStore>{};
107  if (shiftReportFrequency_ != -1)
109  }
110  }
111 }
112 
114  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: End of LS transition, "
115  "performing the DQM client operation";
116  ++nLumiSecs_;
117 
118  if (!trackerFEDsFound_) {
120  return;
121  }
122  endLumiAnalysisOn_ = true;
123 
124  std::cout << "====================================================== " << std::endl;
125  std::cout << " ===> Iteration # " << nLumiSecs_ << " " << lumiSeg.luminosityBlock() << std::endl;
126  std::cout << "====================================================== " << std::endl;
127 
128  auto& dqm_store = *edm::Service<DQMStore>{};
129  // Fill Global Status
130  if (globalStatusFilling_ > 0) {
132  dqm_store, detCabling_, &eSetup.getData(tkDetMapTokenELB_), &eSetup.getData(tTopoTokenELB_));
133  }
134  // -- Create summary monitor elements according to the frequency
135  if (summaryFrequency_ != -1 && nLumiSecs_ > 0 && nLumiSecs_ % summaryFrequency_ == 0) {
136  std::cout << " Creating Summary " << std::endl;
137  actionExecutor_.createSummary(dqm_store);
138  }
139  endLumiAnalysisOn_ = false;
140 }
141 
143  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: End of Run";
144 }
145 
147  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: endjob called!";
149  std::ostringstream str_val;
150  auto& dqm_store = *edm::Service<DQMStore>{};
151  actionExecutor_.printFaultyModuleList(dqm_store, str_val);
152  std::cout << str_val.str() << std::endl;
153  }
154 }
155 
157  edm::Handle<FEDRawDataCollection> rawDataHandle;
158  e.getByToken(rawDataToken_, rawDataHandle);
159  if (!rawDataHandle.isValid())
160  return;
161 
162  auto const& rawDataCollection = *rawDataHandle;
163  constexpr int siStripFedIdMin{FEDNumbering::MINSiStripFEDID};
164  constexpr int siStripFedIdMax{FEDNumbering::MAXSiStripFEDID};
165 
166  for (int i = siStripFedIdMin; i <= siStripFedIdMax; ++i) {
167  auto const& fedData = rawDataCollection.FEDData(i);
168  if (fedData.size() && fedData.data()) {
169  trackerFEDsFound_ = true;
170  return;
171  }
172  }
173 }
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
FEDNumbering.h
SiStripClassToMonitorCondData::beginRun
void beginRun(edm::RunNumber_t iRun, edm::EventSetup const &eSetup)
Definition: SiStripClassToMonitorCondData.cc:101
mps_fire.i
i
Definition: mps_fire.py:428
SiStripAnalyser::nLumiSecs_
int nLumiSecs_
Definition: SiStripAnalyser.h:75
MessageLogger.h
SiStripFolderOrganizer.h
SiStripAnalyser::detCablingToken_
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
Definition: SiStripAnalyser.h:69
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
LuminosityBlock.h
SiStripAnalyser::analyze
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
Definition: SiStripAnalyser.cc:97
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiStripAnalyser::tTopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: SiStripAnalyser.h:71
SiStripAnalyser::tTopoTokenELB_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoTokenELB_
Definition: SiStripAnalyser.h:71
SiStripAnalyser::detCabling_
const SiStripDetCabling * detCabling_
Definition: SiStripAnalyser.h:68
SiStripAnalyser::tTopoTokenBR_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoTokenBR_
Definition: SiStripAnalyser.h:71
SiStripAnalyser::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
Definition: SiStripAnalyser.cc:93
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:47
DQMStore.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripAnalyser::~SiStripAnalyser
~SiStripAnalyser() override
Definition: SiStripAnalyser.cc:62
SiStripAnalyser::checkTrackerFEDs
void checkTrackerFEDs(edm::Event const &e)
Definition: SiStripAnalyser.cc:156
SiStripActionExecutor::printFaultyModuleList
void printFaultyModuleList(DQMStore &dqm_store, std::ostringstream &str_val)
Definition: SiStripActionExecutor.cc:244
SiStripAnalyser::tkDetMapToken_
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
Definition: SiStripAnalyser.h:72
FEDRawData.h
edm::Handle< FEDRawDataCollection >
SiStripUtility.h
SiStripAnalyser::endRun
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiStripAnalyser.cc:142
FileInPath.h
SiStripAnalyser::endJob
void endJob() override
Definition: SiStripAnalyser.cc:146
SiStripAnalyser::fedCablingWatcher_
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
Definition: SiStripAnalyser.h:70
SiStripAnalyser.h
edm::FileInPath
Definition: FileInPath.h:64
MakerMacros.h
SiStripAnalyser::endLumiAnalysisOn_
bool endLumiAnalysisOn_
Definition: SiStripAnalyser.h:79
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
groupFilesInBlocks.fin
fin
Definition: groupFilesInBlocks.py:94
Service.h
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
SiStripActionExecutor::createShiftReport
void createShiftReport(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:134
SiStripActionExecutor::readTkMapConfiguration
bool readTkMapConfiguration(const SiStripDetCabling *detCabling, const TkDetMap *tkDetMap, const TrackerTopology *tTopo)
Definition: SiStripActionExecutor.cc:41
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripAnalyser::condDataMon_
SiStripClassToMonitorCondData condDataMon_
Definition: SiStripAnalyser.h:54
FEDNumbering::MAXSiStripFEDID
Definition: FEDNumbering.h:30
SiStripAnalyser::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiStripAnalyser.cc:72
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
SiStripActionExecutor::createStatus
void createStatus(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:109
recoMuon::in
Definition: RecoMuonEnumerators.h:6
SiStripAnalyser::trackerFEDsFound_
bool trackerFEDsFound_
Definition: SiStripAnalyser.h:77
edm::Service
Definition: Service.h:30
FEDRawDataCollection.h
SiStripAnalyser
Definition: SiStripAnalyser.h:35
edm::EventSetup
Definition: EventSetup.h:58
SiStripAnalyser::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
Definition: SiStripAnalyser.cc:113
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
SiStripAnalyser::beginJob
void beginJob() override
Definition: SiStripAnalyser.cc:64
SiStripActionExecutor::fillStatus
void fillStatus(DQMStore &dqm_store, const SiStripDetCabling *cabling, const TkDetMap *tkDetMap, const TrackerTopology *tTopo)
Definition: SiStripActionExecutor.cc:118
SiStripAnalyser::nEvents_
int nEvents_
Definition: SiStripAnalyser.h:76
SiStripActionExecutor::createDummyShiftReport
void createDummyShiftReport()
Definition: SiStripActionExecutor.cc:127
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripAnalyser::printFaultyModuleList_
bool printFaultyModuleList_
Definition: SiStripAnalyser.h:78
SiStripActionExecutor::fillDummyStatus
void fillDummyStatus()
Definition: SiStripActionExecutor.cc:116
SiStripAnalyser::summaryFrequency_
int summaryFrequency_
Definition: SiStripAnalyser.h:58
SiStripAnalyser::SiStripAnalyser
SiStripAnalyser(const edm::ParameterSet &ps)
Definition: SiStripAnalyser.cc:35
SiStripAnalyser::globalStatusFilling_
int globalStatusFilling_
Definition: SiStripAnalyser.h:60
SiStripAnalyser::tkDetMapTokenELB_
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapTokenELB_
Definition: SiStripAnalyser.h:72
SiStripAnalyser::actionExecutor_
SiStripActionExecutor actionExecutor_
Definition: SiStripAnalyser.h:55
SiStripActionExecutor::readConfiguration
bool readConfiguration()
Definition: SiStripActionExecutor.cc:29
SiStripActionExecutor::createSummary
void createSummary(DQMStore &dqm_store)
Definition: SiStripActionExecutor.cc:50
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
StripSubdetector.h
edm::InputTag
Definition: InputTag.h:15
SiStripAnalyser::tkDetMapTokenBR_
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapTokenBR_
Definition: SiStripAnalyser.h:72
SiStripAnalyser::rawDataToken_
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
Definition: SiStripAnalyser.h:63
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
SiStripAnalyser::shiftReportFrequency_
int shiftReportFrequency_
Definition: SiStripAnalyser.h:61
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
FEDNumbering::MINSiStripFEDID
Definition: FEDNumbering.h:29