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 }
SiStripClassToMonitorCondData condDataMon_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
void beginRun(edm::RunNumber_t iRun, edm::EventSetup const &eSetup)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoTokenBR_
std::string fullPath() const
Definition: FileInPath.cc:161
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
void createSummary(DQMStore &dqm_store)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoTokenELB_
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
~SiStripAnalyser() override
T getUntrackedParameter(std::string const &, T const &) const
SiStripActionExecutor actionExecutor_
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapTokenBR_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapTokenELB_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
void fillStatus(DQMStore &dqm_store, const SiStripDetCabling *cabling, const TkDetMap *tkDetMap, const TrackerTopology *tTopo)
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
Log< level::Info, false > LogInfo
void printFaultyModuleList(DQMStore &dqm_store, std::ostringstream &str_val)
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
void endJob() override
const SiStripDetCabling * detCabling_
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
void createStatus(DQMStore &dqm_store)
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
bool isValid() const
Definition: HandleBase.h:70
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
SiStripAnalyser(const edm::ParameterSet &ps)
bool readTkMapConfiguration(const SiStripDetCabling *detCabling, const TkDetMap *tkDetMap, const TrackerTopology *tTopo)
void createShiftReport(DQMStore &dqm_store)
LuminosityBlockNumber_t luminosityBlock() const
Definition: Run.h:45
void beginJob() override
void checkTrackerFEDs(edm::Event const &e)