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 
29 
32 
33 #include <cmath>
34 #include <cstdio>
35 #include <iomanip>
36 #include <iostream>
37 #include <sstream>
38 #include <string>
39 
41  : condDataMon_{ps},
42  actionExecutor_{ps},
43  tkMapPSet_{ps.getParameter<edm::ParameterSet>("TkmapParameters")},
45  ps.getUntrackedParameter<int>("SummaryCreationFrequency", 1)},
47  ps.getUntrackedParameter<int>("StaticUpdateFrequency", 1)},
49  ps.getUntrackedParameter<int>("GlobalStatusFilling", 1)},
51  ps.getUntrackedParameter<int>("ShiftReportFrequency", 1)},
52  rawDataToken_{consumes<FEDRawDataCollection>(
53  ps.getUntrackedParameter<edm::InputTag>("RawDataTag"))},
55  ps.getUntrackedParameter<bool>("PrintFaultyModuleList", true)}
56 {
57  std::string const localPath{"DQM/SiStripMonitorClient/test/loader.html"};
58  std::ifstream fin{edm::FileInPath(localPath).fullPath(), std::ios::in};
59  if (!fin) {
60  std::cerr << "Input File: loader.html"
61  << " could not be opened!" << std::endl;
62  return;
63  }
64  edm::LogInfo("SiStripAnalyser")
65  << " SiStripAnalyser::Creating SiStripAnalyser ";
66 }
67 
69 {
70  edm::LogInfo("SiStripAnalyser")
71  << "SiStripAnalyser::Deleting SiStripAnalyser ";
72 }
73 
74 void
76 {
77  // Read the summary configuration file
79  edm::LogInfo("SiStripAnalyser")
80  << "SiStripAnalyser:: Error to read configuration file!! Summary will "
81  "not be produced!!!";
82  }
83 }
84 
85 void
87 {
88  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Begining of Run";
89 
90  // Check latest Fed cabling and create TrackerMapCreator
91  unsigned long long const cacheID =
92  eSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
93  if (m_cacheID_ != cacheID) {
94  m_cacheID_ = cacheID;
95  edm::LogInfo("SiStripAnalyser")
96  << "SiStripAnalyser::beginRun: "
97  << " Change in Cabling, recrated TrackerMap";
99  edm::LogInfo("SiStripAnalyser")
100  << "SiStripAnalyser:: Error to read configuration file!! TrackerMap "
101  "will not be produced!!!";
102  }
103  eSetup.get<SiStripFedCablingRcd>().get(fedCabling_);
104  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
105  }
106  condDataMon_.beginRun(run.run(), eSetup);
107  if (globalStatusFilling_) {
108  auto& dqm_store = *edm::Service<DQMStore>{};
109  actionExecutor_.createStatus(dqm_store);
110  }
111 }
112 
113 void
115  edm::EventSetup const& eSetup)
116 {
117  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: Begin of LS transition";
118 }
119 
120 void
122 {
123  ++nEvents_;
124  if (nEvents_ == 1 && globalStatusFilling_ > 0) {
125  checkTrackerFEDs(e);
126  if (!trackerFEDsFound_) {
129  } else {
130  auto& dqm_store = *edm::Service<DQMStore>{};
131  actionExecutor_.fillStatus(dqm_store, detCabling_, eSetup);
132  if (shiftReportFrequency_ != -1)
134  }
135  }
136 }
137 
138 void
140  edm::EventSetup const& eSetup)
141 {
142  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: End of LS transition, "
143  "performing the DQM client operation";
144  ++nLumiSecs_;
145 
146  if (!trackerFEDsFound_) {
148  return;
149  }
150  endLumiAnalysisOn_ = true;
151 
152  std::cout << "====================================================== "
153  << std::endl;
154  std::cout << " ===> Iteration # " << nLumiSecs_ << " "
155  << lumiSeg.luminosityBlock() << std::endl;
156  std::cout << "====================================================== "
157  << std::endl;
158 
159  auto& dqm_store = *edm::Service<DQMStore>{};
160  // Fill Global Status
161  if (globalStatusFilling_ > 0) {
162  actionExecutor_.fillStatus(dqm_store, detCabling_, eSetup);
163  }
164  // -- Create summary monitor elements according to the frequency
165  if (summaryFrequency_ != -1 && nLumiSecs_ > 0 &&
166  nLumiSecs_ % summaryFrequency_ == 0) {
167  std::cout << " Creating Summary " << std::endl;
168  actionExecutor_.createSummary(dqm_store);
169  }
170  endLumiAnalysisOn_ = false;
171 }
172 
173 void
175 {
176  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: End of Run";
177 }
178 
179 void
181 {
182  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser:: endjob called!";
184  std::ostringstream str_val;
185  auto& dqm_store = *edm::Service<DQMStore>{};
186  actionExecutor_.printFaultyModuleList(dqm_store, str_val);
187  std::cout << str_val.str() << std::endl;
188  }
189 }
190 
191 void
193 {
194  edm::Handle<FEDRawDataCollection> rawDataHandle;
195  e.getByToken(rawDataToken_, rawDataHandle);
196  if (!rawDataHandle.isValid()) return;
197 
198  auto const& rawDataCollection = *rawDataHandle;
199  constexpr int siStripFedIdMin{FEDNumbering::MINSiStripFEDID};
200  constexpr int siStripFedIdMax{FEDNumbering::MAXSiStripFEDID};
201 
202  for (int i = siStripFedIdMin; i <= siStripFedIdMax; ++i) {
203  auto const& fedData = rawDataCollection.FEDData(i);
204  if (fedData.size() && fedData.data()) {
205  trackerFEDsFound_ = true;
206  return;
207  }
208  }
209 }
SiStripClassToMonitorCondData condDataMon_
T getParameter(std::string const &) const
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
RunNumber_t run() const
Definition: RunBase.h:40
void beginRun(edm::RunNumber_t iRun, edm::EventSetup const &eSetup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
void createSummary(DQMStore &dqm_store)
bool readTkMapConfiguration(const edm::EventSetup &eSetup)
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
void fillStatus(DQMStore &dqm_store, edm::ESHandle< SiStripDetCabling > const &fedcabling, edm::EventSetup const &eSetup)
~SiStripAnalyser() override
LuminosityBlockNumber_t luminosityBlock() const
SiStripActionExecutor actionExecutor_
edm::ESHandle< SiStripDetCabling > detCabling_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESHandle< SiStripFedCabling > fedCabling_
bool isValid() const
Definition: HandleBase.h:74
edm::ParameterSet tkMapPSet_
void printFaultyModuleList(DQMStore &dqm_store, std::ostringstream &str_val)
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
void endJob() override
void createStatus(DQMStore &dqm_store)
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
unsigned long long m_cacheID_
T get() const
Definition: EventSetup.h:71
std::string fullPath() const
Definition: FileInPath.cc:163
SiStripAnalyser(const edm::ParameterSet &ps)
void createShiftReport(DQMStore &dqm_store)
#define constexpr
Definition: Run.h:45
void beginJob() override
void checkTrackerFEDs(edm::Event const &e)