CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TrackingAnalyzer.cc
Go to the documentation of this file.
2 
4 
11 
13 
15 
19 
24 
28 
29 #include <iomanip>
30 #include <cstdio>
31 #include <string>
32 #include <sstream>
33 #include <cmath>
34 
35 #define BUF_SIZE 256
36 
37 //
38 // -- Constructor
39 //
41  : verbose_(ps.getUntrackedParameter<bool>("verbose", false)),
42  fedCablingToken_(esConsumes<SiStripFedCabling, SiStripFedCablingRcd, edm::Transition::BeginRun>()),
43  detCablingToken_(esConsumes<SiStripDetCabling, SiStripDetCablingRcd, edm::Transition::BeginRun>()) {
44  edm::LogInfo("TrackingAnalyser") << "Creating TrackingAnalyser ";
45 
46  // Get TkMap ParameterSet
47  // tkMapPSet_ = ps.getParameter<edm::ParameterSet>("TkmapParameters");
48 
49  std::string localPath = std::string("DQM/TrackingMonitorClient/test/loader.html");
50  std::ifstream fin(edm::FileInPath(localPath).fullPath().c_str(), std::ios::in);
51  char buf[BUF_SIZE];
52 
53  if (!fin) {
54  edm::LogError("TrackingAnalyzer") << "Input File: loader.html"
55  << " 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  staticUpdateFrequency_ = ps.getUntrackedParameter<int>("StaticUpdateFrequency", 1);
65  globalStatusFilling_ = ps.getUntrackedParameter<int>("GlobalStatusFilling", 1);
66  shiftReportFrequency_ = ps.getUntrackedParameter<int>("ShiftReportFrequency", 1);
67 
68  edm::InputTag rawDataTag = ps.getUntrackedParameter<edm::InputTag>("RawDataTag");
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 //
83 TrackingAnalyser::~TrackingAnalyser() { edm::LogInfo("TrackingAnalyser") << "Deleting TrackingAnalyser "; }
84 //
85 // -- Begin Job
86 //
88 //
89 // -- Begin Run
90 //
92  edm::LogInfo("TrackingAnalyser") << " Begining of Run";
93 
94  // Check latest Fed cabling and create TrackerMapCreator
95  if (fedCablingWatcher_.check(eSetup)) { //this should check if cabling record has changed
96  edm::LogInfo("TrackingAnalyser") << "beginRun: "
97  << " Change in Cabling, recrated TrackerMap";
100  }
101 }
102 //
103 // -- Begin Luminosity Block
104 //
106  DQMStore::IGetter& igetter_,
107  edm::LuminosityBlock const& lumiSeg,
108  edm::EventSetup const& eSetup) {
109  edm::LogInfo("TrackingAnalyser") << " Begin of LS transition";
110 }
111 
112 //
113 // -- End Luminosity Block
114 //
116  DQMStore::IGetter& igetter_,
117  edm::LuminosityBlock const& lumiSeg,
118  edm::EventSetup const& eSetup) {
119  edm::LogInfo("TrackingAnalyser") << " End of LS transition, performing the DQM client operation";
120 
121  nLumiSecs_++;
122 
123  if (verbose_)
124  edm::LogInfo("TrackingAnalyser") << "[TrackingAnalyser::endLuminosityBlock] globalStatusFilling_ "
125  << (globalStatusFilling_ ? "YES" : "NOPE") << std::endl;
127  actionExecutor_->createGlobalStatus(ibooker_, igetter_);
128 
129  double iLS = lumiSeg.id().luminosityBlock();
130  checkTrackerFEDsInLS(igetter_, iLS);
131  checkTrackerFEDsWdataInLS(igetter_, iLS);
132  if (verbose_)
133  edm::LogInfo("TrackingAnalyser") << "endLuminosityBlock trackerFEDsFound_ " << (trackerFEDsFound_ ? "YES" : "NOPE")
134  << std::endl;
135  if (verbose_)
136  edm::LogInfo("TrackingAnalyser") << "endLuminosityBlock trackerFEDsWdataFound_ "
137  << (trackerFEDsWdataFound_ ? "YES" : "NOPE") << std::endl;
138 
139  if (!trackerFEDsFound_) {
142  } else {
144  actionExecutor_->fillGlobalStatus(ibooker_, igetter_);
145  if (shiftReportFrequency_ != -1)
146  actionExecutor_->createShiftReport(ibooker_, igetter_);
147  }
148  }
149 
150  if (!trackerFEDsFound_) {
152  return;
153  }
154 
155  if (verbose_)
156  edm::LogInfo("TrackingAnalyser") << "====================================================== " << std::endl;
157  if (verbose_)
158  edm::LogInfo("TrackingAnalyser") << " ===> Iteration # " << nLumiSecs_ << " " << lumiSeg.luminosityBlock()
159  << std::endl;
160  if (verbose_)
161  edm::LogInfo("TrackingAnalyser") << "====================================================== " << std::endl;
162 }
163 
164 //
165 // -- End Job
166 //
168  edm::LogInfo("TrackingAnalyser") << " endjob called!";
169 
171  actionExecutor_->createGlobalStatus(ibooker_, igetter_);
172  // Fill Global Status
173  if (globalStatusFilling_ > 0) {
174  actionExecutor_->fillGlobalStatus(ibooker_, igetter_);
175  }
176 }
177 //
178 // Check Tracker FEDs
179 //
181  double nFEDinLS = 0.;
182  MonitorElement* tmpME = igetter.get(nFEDinfoDir_ + "/" + nFEDinVsLSname_);
183  if (tmpME) {
184  TProfile* tmpP = tmpME->getTProfile();
185  size_t ibin = tmpP->GetXaxis()->FindBin(iLS);
186  if (verbose_)
187  edm::LogInfo("TrackingAnalyser") << "iLS: " << iLS << " ibin: " << ibin;
188  nFEDinLS = tmpME->getBinContent(ibin);
189  if (verbose_)
190  edm::LogInfo("TrackingAnalyser") << " ---> nFEDinLS: " << nFEDinLS;
191  }
192 
193  trackerFEDsFound_ = (nFEDinLS > 0);
194  if (verbose_)
195  edm::LogInfo("TrackingAnalyser") << " ---> trackerFEDsFound_: " << trackerFEDsFound_ << std::endl;
196 }
197 
199  double nFEDinLS = 0.;
200  MonitorElement* tmpME = igetter.get(nFEDinfoDir_ + "/" + nFEDinWdataVsLSname_);
201  if (verbose_)
202  edm::LogInfo("TrackingAnalyser") << "found " << nFEDinfoDir_ << "/" << nFEDinWdataVsLSname_ << " ? "
203  << (tmpME ? "YES" : "NOPE") << std::endl;
204  if (tmpME) {
205  TProfile* tmpP = tmpME->getTProfile();
206  size_t ibin = tmpP->GetXaxis()->FindBin(iLS);
207  if (verbose_)
208  edm::LogInfo("TrackingAnalyser") << "iLS: " << iLS << " ibin: " << ibin;
209  nFEDinLS = tmpME->getBinContent(ibin);
210  if (verbose_)
211  edm::LogInfo("TrackingAnalyser") << " ---> nFEDinLS: " << nFEDinLS;
212  }
213 
214  trackerFEDsWdataFound_ = (nFEDinLS > 0);
215  if (verbose_)
216  edm::LogInfo("TrackingAnalyser") << " ---> trackerFEDsWdataFound_: " << trackerFEDsWdataFound_ << std::endl;
217 }
218 
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
LuminosityBlockID id() 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.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
Log< level::Error, false > LogError
void createShiftReport(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
LuminosityBlockNumber_t luminosityBlock() const
bool getData(T &iHolder) const
Definition: EventSetup.h:122
std::string nFEDinWdataVsLSname_
TrackingAnalyser(const edm::ParameterSet &ps)
Constructor.
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
std::string nFEDinVsLSname_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
const SiStripDetCabling * detCabling_
Transition
Definition: Transition.h:12
virtual double getBinContent(int binx) const
get content of bin (1-D)
void dqmEndJob(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_) override
Endjob.
Log< level::Info, false > LogInfo
void dqmEndLuminosityBlock(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
End Luminosity Block.
virtual TProfile * getTProfile() const
const SiStripFedCabling * fedCabling_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
LuminosityBlockNumber_t luminosityBlock() const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
std::ostringstream html_out_
void dqmBeginLuminosityBlock(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup)
Begin Luminosity Block.
void createGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void checkTrackerFEDsWdataInLS(DQMStore::IGetter &igetter, double iLS)
TrackingActionExecutor * actionExecutor_
#define BUF_SIZE
void beginJob() override
BeginJob.
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void checkTrackerFEDsInLS(DQMStore::IGetter &igetter, double iLS)
Definition: Run.h:45