CMS 3D CMS Logo

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