CMS 3D CMS Logo

SiStripAnalyser.cc
Go to the documentation of this file.
1 
27 
28 #include <cmath>
29 #include <cstdio>
30 #include <iomanip>
31 #include <iostream>
32 #include <map>
33 #include <vector>
34 #include <sstream>
35 #include <string>
36 
37 class SiStripWebInterface;
38 class SiStripFedCabling;
39 class SiStripDetCabling;
42 
44  : public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
45 public:
48 
50  ~SiStripAnalyser() override;
51 
52 private:
53  void beginJob() override;
54  void beginRun(edm::Run const& run, edm::EventSetup const& eSetup) override;
55  void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
56  void beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& eSetup) override;
57  void endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& eSetup) override;
58  void endRun(edm::Run const& run, edm::EventSetup const& eSetup) override;
59  void endJob() override;
60 
61  void checkTrackerFEDs(edm::Event const& e);
62 
66 
71 
73 
76 
83 
84  int nLumiSecs_{};
85  int nEvents_{};
86  bool trackerFEDsFound_{false};
88  bool endLumiAnalysisOn_{false};
89 };
90 
92  : condDataMon_{ps, consumesCollector()},
93  actionExecutor_{ps},
94  tkMapPSet_{ps.getParameter<edm::ParameterSet>("TkmapParameters")},
95  summaryFrequency_{ps.getUntrackedParameter<int>("SummaryCreationFrequency", 1)},
96  staticUpdateFrequency_{ps.getUntrackedParameter<int>("StaticUpdateFrequency", 1)},
97  globalStatusFilling_{ps.getUntrackedParameter<int>("GlobalStatusFilling", 1)},
98  shiftReportFrequency_{ps.getUntrackedParameter<int>("ShiftReportFrequency", 1)},
99  rawDataToken_{consumes<FEDRawDataCollection>(ps.getUntrackedParameter<edm::InputTag>("RawDataTag"))},
100  detCablingToken_(esConsumes<edm::Transition::BeginRun>()),
101  tTopoToken_(esConsumes()),
102  tTopoTokenELB_(esConsumes<edm::Transition::EndLuminosityBlock>()),
103  tTopoTokenBR_(esConsumes<edm::Transition::BeginRun>()),
104  tkDetMapToken_(esConsumes()),
105  tkDetMapTokenELB_(esConsumes<edm::Transition::EndLuminosityBlock>()),
106  tkDetMapTokenBR_(esConsumes<edm::Transition::BeginRun>()),
107  printFaultyModuleList_{ps.getUntrackedParameter<bool>("PrintFaultyModuleList", true)} {
108  usesResource("DQMStore");
109  std::string const localPath{"DQM/SiStripMonitorClient/test/loader.html"};
110  std::ifstream fin{edm::FileInPath(localPath).fullPath(), std::ios::in};
111  if (!fin) {
112  std::cerr << "Input File: loader.html"
113  << " could not be opened!" << std::endl;
114  return;
115  }
116  edm::LogInfo("SiStripAnalyser") << " SiStripAnalyser::Creating SiStripAnalyser ";
117 }
118 
119 SiStripAnalyser::~SiStripAnalyser() { edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser::Deleting SiStripAnalyser "; }
120 
122  // Read the summary configuration file
124  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Error to read configuration file!! Summary will "
125  "not be produced!!!";
126  }
127 }
128 
130  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Begining of Run";
131 
132  // Check latest Fed cabling and create TrackerMapCreator
133  if (fedCablingWatcher_.check(eSetup)) {
134  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser::beginRun: "
135  << " Change in Cabling, recrated TrackerMap";
139  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Error to read configuration file!! TrackerMap "
140  "will not be produced!!!";
141  }
142  }
143  condDataMon_.beginRun(run.run(), eSetup);
144  if (globalStatusFilling_) {
145  auto& dqm_store = *edm::Service<DQMStore>{};
146  actionExecutor_.createStatus(dqm_store);
147  }
148 }
149 
151  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Begin of LS transition";
152 }
153 
155  ++nEvents_;
156  if (nEvents_ == 1 && globalStatusFilling_ > 0) {
158  if (!trackerFEDsFound_) {
161  } else {
162  auto& dqm_store = *edm::Service<DQMStore>{};
164  if (shiftReportFrequency_ != -1)
166  }
167  }
168 }
169 
171  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: End of LS transition, "
172  "performing the DQM client operation";
173  ++nLumiSecs_;
174 
175  if (!trackerFEDsFound_) {
177  return;
178  }
179  endLumiAnalysisOn_ = true;
180 
181  std::cout << "====================================================== " << std::endl;
182  std::cout << " ===> Iteration # " << nLumiSecs_ << " " << lumiSeg.luminosityBlock() << std::endl;
183  std::cout << "====================================================== " << std::endl;
184 
185  auto& dqm_store = *edm::Service<DQMStore>{};
186  // Fill Global Status
187  if (globalStatusFilling_ > 0) {
189  dqm_store, detCabling_, &eSetup.getData(tkDetMapTokenELB_), &eSetup.getData(tTopoTokenELB_));
190  }
191  // -- Create summary monitor elements according to the frequency
192  if (summaryFrequency_ != -1 && nLumiSecs_ > 0 && nLumiSecs_ % summaryFrequency_ == 0) {
193  std::cout << " Creating Summary " << std::endl;
194  actionExecutor_.createSummary(dqm_store);
195  }
196  endLumiAnalysisOn_ = false;
197 }
198 
200  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: End of Run";
201 }
202 
204  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: endjob called!";
206  std::ostringstream str_val;
207  auto& dqm_store = *edm::Service<DQMStore>{};
208  actionExecutor_.printFaultyModuleList(dqm_store, str_val);
209  std::cout << str_val.str() << std::endl;
210  }
211 }
212 
214  edm::Handle<FEDRawDataCollection> rawDataHandle;
215  e.getByToken(rawDataToken_, rawDataHandle);
216  if (!rawDataHandle.isValid())
217  return;
218 
219  auto const& rawDataCollection = *rawDataHandle;
220  constexpr int siStripFedIdMin{FEDNumbering::MINSiStripFEDID};
221  constexpr int siStripFedIdMax{FEDNumbering::MAXSiStripFEDID};
222 
223  for (int i = siStripFedIdMin; i <= siStripFedIdMax; ++i) {
224  auto const& fedData = rawDataCollection.FEDData(i);
225  if (fedData.size() && fedData.data()) {
226  trackerFEDsFound_ = true;
227  return;
228  }
229  }
230 }
std::string outputFileName_
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
dqm::harvesting::DQMStore DQMStore
std::string outputFilePath_
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
dqm::harvesting::MonitorElement MonitorElement
T getUntrackedParameter(std::string const &, T const &) const
SiStripActionExecutor actionExecutor_
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapTokenBR_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapTokenELB_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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_
edm::ParameterSet tkMapPSet_
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
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
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)