CMS 3D CMS Logo

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