CMS 3D CMS Logo

TrackingAnalyzer.cc
Go to the documentation of this file.
2 
4 
11 
13 
15 
19 
24 
28 
29 #include <iostream>
30 #include <iomanip>
31 #include <cstdio>
32 #include <string>
33 #include <sstream>
34 #include <cmath>
35 
36 #define BUF_SIZE 256
37 
38 //
39 // -- Constructor
40 //
42  : verbose_(ps.getUntrackedParameter<bool>("verbose", false)) {
43  if (verbose_)
44  std::cout << "[TrackingAnalyser::TrackingAnalyser]" << std::endl;
45  // Get TkMap ParameterSet
46  // tkMapPSet_ = ps.getParameter<edm::ParameterSet>("TkmapParameters");
47 
48  std::string localPath = std::string("DQM/TrackingMonitorClient/test/loader.html");
49  std::ifstream fin(edm::FileInPath(localPath).fullPath().c_str(), std::ios::in);
50  char buf[BUF_SIZE];
51 
52  if (!fin) {
53  std::cerr << "Input File: loader.html"
54  << " could not be opened!" << std::endl;
55  return;
56  }
57 
58  while (fin.getline(buf, BUF_SIZE, '\n')) { // pops off the newline character
59  html_out_ << buf;
60  }
61  fin.close();
62 
63  edm::LogInfo("TrackingAnalyser") << " TrackingAnalyser::Creating TrackingAnalyser ";
64  staticUpdateFrequency_ = ps.getUntrackedParameter<int>("StaticUpdateFrequency", 1);
65  globalStatusFilling_ = ps.getUntrackedParameter<int>("GlobalStatusFilling", 1);
66  shiftReportFrequency_ = ps.getUntrackedParameter<int>("ShiftReportFrequency", 1);
67 
69  rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag);
70 
71  // instantiate web interface
73  trackerFEDsFound_ = false;
74  trackerFEDsWdataFound_ = false;
75 
76  nFEDinfoDir_ = ps.getParameter<std::string>("nFEDinfoDir");
77  nFEDinVsLSname_ = ps.getParameter<std::string>("nFEDinVsLSname");
78  nFEDinWdataVsLSname_ = ps.getParameter<std::string>("nFEDinWdataVsLSname");
79 }
80 //
81 // -- Destructor
82 //
84  edm::LogInfo("TrackingAnalyser") << "TrackingAnalyser::Deleting TrackingAnalyser ";
85 }
86 //
87 // -- Begin Job
88 //
90 //
91 // -- Begin Run
92 //
94  edm::LogInfo("TrackingAnalyser") << "TrackingAnalyser:: Begining of Run";
95 
96  if (verbose_)
97  std::cout << "[TrackingAnalyser::beginRun]" << std::endl;
98  // Check latest Fed cabling and create TrackerMapCreator
99  unsigned long long cacheID = eSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
100  if (m_cacheID_ != cacheID) {
101  m_cacheID_ = cacheID;
102  edm::LogInfo("TrackingAnalyser") << "TrackingAnalyser::beginRun: "
103  << " Change in Cabling, recrated TrackerMap";
104  eSetup.get<SiStripFedCablingRcd>().get(fedCabling_);
105  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
106  }
107 }
108 //
109 // -- Begin Luminosity Block
110 //
112  DQMStore::IGetter& igetter_,
113  edm::LuminosityBlock const& lumiSeg,
114  edm::EventSetup const& eSetup) {
115  edm::LogInfo("TrackingAnalyser") << "TrackingAnalyser:: Begin of LS transition";
116  if (verbose_)
117  std::cout << "[TrackingAnalyser::dqmBeginLuminosityBlock]" << std::endl;
118 }
119 
120 //
121 // -- End Luminosity Block
122 //
124  DQMStore::IGetter& igetter_,
125  edm::LuminosityBlock const& lumiSeg,
126  edm::EventSetup const& eSetup) {
127  edm::LogInfo("TrackingAnalyser") << "TrackingAnalyser:: End of LS transition, performing the DQM client operation";
128  if (verbose_)
129  std::cout << "[TrackingAnalyser::endLuminosityBlock]" << std::endl;
130  nLumiSecs_++;
131 
132  if (verbose_)
133  std::cout << "[TrackingAnalyser::endLuminosityBlock] globalStatusFilling_ "
134  << (globalStatusFilling_ ? "YES" : "NOPE") << std::endl;
136  actionExecutor_->createGlobalStatus(ibooker_, igetter_);
137 
138  double iLS = lumiSeg.id().luminosityBlock();
139  checkTrackerFEDsInLS(igetter_, iLS);
140  checkTrackerFEDsWdataInLS(igetter_, iLS);
141  if (verbose_)
142  std::cout << "[TrackingAnalyser::endLuminosityBlock] trackerFEDsFound_ " << (trackerFEDsFound_ ? "YES" : "NOPE")
143  << std::endl;
144  if (verbose_)
145  std::cout << "[TrackingAnalyser::endLuminosityBlock] trackerFEDsWdataFound_ "
146  << (trackerFEDsWdataFound_ ? "YES" : "NOPE") << std::endl;
147 
148  if (!trackerFEDsFound_) {
151  } else {
153  actionExecutor_->fillGlobalStatus(ibooker_, igetter_);
154  if (shiftReportFrequency_ != -1)
155  actionExecutor_->createShiftReport(ibooker_, igetter_);
156  }
157  }
158 
159  if (!trackerFEDsFound_) {
161  return;
162  }
163 
164  if (verbose_)
165  std::cout << "====================================================== " << std::endl;
166  if (verbose_)
167  std::cout << " ===> Iteration # " << nLumiSecs_ << " " << lumiSeg.luminosityBlock() << std::endl;
168  if (verbose_)
169  std::cout << "====================================================== " << std::endl;
170 }
171 
172 //
173 // -- End Job
174 //
176  edm::LogInfo("TrackingAnalyser") << "TrackingAnalyser:: endjob called!";
177  if (verbose_)
178  std::cout << "[TrackingAnalyser::dqmEndJob]" << std::endl;
179 
181  actionExecutor_->createGlobalStatus(ibooker_, igetter_);
182  // Fill Global Status
183  if (globalStatusFilling_ > 0) {
184  actionExecutor_->fillGlobalStatus(ibooker_, igetter_);
185  }
186 }
187 //
188 // Check Tracker FEDs
189 //
191  double nFEDinLS = 0.;
192  MonitorElement* tmpME = igetter.get(nFEDinfoDir_ + "/" + nFEDinVsLSname_);
193  if (tmpME) {
194  TProfile* tmpP = tmpME->getTProfile();
195  size_t ibin = tmpP->GetXaxis()->FindBin(iLS);
196  if (verbose_)
197  std::cout << "iLS: " << iLS << " ibin: " << ibin;
198  nFEDinLS = tmpME->getBinContent(ibin);
199  if (verbose_)
200  std::cout << " ---> nFEDinLS: " << nFEDinLS;
201  }
202 
203  trackerFEDsFound_ = (nFEDinLS > 0);
204  if (verbose_)
205  std::cout << " ---> trackerFEDsFound_: " << trackerFEDsFound_ << std::endl;
206 }
207 
209  double nFEDinLS = 0.;
210  MonitorElement* tmpME = igetter.get(nFEDinfoDir_ + "/" + nFEDinWdataVsLSname_);
211  if (verbose_)
212  std::cout << "found " << nFEDinfoDir_ << "/" << nFEDinWdataVsLSname_ << " ? " << (tmpME ? "YES" : "NOPE")
213  << std::endl;
214  if (tmpME) {
215  TProfile* tmpP = tmpME->getTProfile();
216  size_t ibin = tmpP->GetXaxis()->FindBin(iLS);
217  if (verbose_)
218  std::cout << "iLS: " << iLS << " ibin: " << ibin;
219  nFEDinLS = tmpME->getBinContent(ibin);
220  if (verbose_)
221  std::cout << " ---> nFEDinLS: " << nFEDinLS;
222  }
223 
224  trackerFEDsWdataFound_ = (nFEDinLS > 0);
225  if (verbose_)
226  std::cout << " ---> trackerFEDsWdataFound_: " << trackerFEDsWdataFound_ << std::endl;
227 }
228 
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ESHandle< SiStripDetCabling > detCabling_
std::string nFEDinfoDir_
~TrackingAnalyser() override
Destructor.
void fillGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
BeginRun.
void createShiftReport(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
LuminosityBlockNumber_t luminosityBlock() const
std::string nFEDinWdataVsLSname_
TrackingAnalyser(const edm::ParameterSet &ps)
Constructor.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::string nFEDinVsLSname_
unsigned long long m_cacheID_
virtual double getBinContent(int binx) const
get content of bin (1-D)
void dqmEndJob(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_) override
Endjob.
void dqmEndLuminosityBlock(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
End Luminosity Block.
virtual TProfile * getTProfile() const
LuminosityBlockNumber_t luminosityBlock() const
std::ostringstream html_out_
void dqmBeginLuminosityBlock(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup)
Begin Luminosity Block.
T get() const
Definition: EventSetup.h:73
void createGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void checkTrackerFEDsWdataInLS(DQMStore::IGetter &igetter, double iLS)
edm::ESHandle< SiStripFedCabling > fedCabling_
TrackingActionExecutor * actionExecutor_
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:437
#define BUF_SIZE
void beginJob() override
BeginJob.
void checkTrackerFEDsInLS(DQMStore::IGetter &igetter, double iLS)
Definition: Run.h:45