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";
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 
TrackingAnalyser::globalStatusFilling_
int globalStatusFilling_
Definition: TrackingAnalyzer.h:63
FEDNumbering.h
BUF_SIZE
#define BUF_SIZE
Definition: TrackingAnalyzer.cc:36
electrons_cff.bool
bool
Definition: electrons_cff.py:372
TrackingAnalyser::fedCabling_
edm::ESHandle< SiStripFedCabling > fedCabling_
Definition: TrackingAnalyzer.h:72
TrackingActionExecutor::createShiftReport
void createShiftReport(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
Definition: TrackingActionExecutor.cc:84
MessageLogger.h
SiStripFolderOrganizer.h
funct::false
false
Definition: Factorize.h:34
TrackingActionExecutor::fillDummyLSStatus
void fillDummyLSStatus()
Definition: TrackingActionExecutor.cc:57
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
LuminosityBlock.h
TrackingActionExecutor::createDummyShiftReport
void createDummyShiftReport()
Definition: TrackingActionExecutor.cc:74
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::LogInfo
Definition: MessageLogger.h:254
TrackingActionExecutor::createGlobalStatus
void createGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
Definition: TrackingActionExecutor.cc:40
SiStripFedCabling.h
TrackingAnalyser::checkTrackerFEDsWdataInLS
void checkTrackerFEDsWdataInLS(DQMStore::IGetter &igetter, double iLS)
Definition: TrackingAnalyzer.cc:208
TrackingAnalyser::trackerFEDsFound_
bool trackerFEDsFound_
Definition: TrackingAnalyzer.h:78
TrackingAnalyser::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
End Luminosity Block.
Definition: TrackingAnalyzer.cc:123
DQMStore.h
TrackingAnalyser::checkTrackerFEDsInLS
void checkTrackerFEDsInLS(DQMStore::IGetter &igetter, double iLS)
Definition: TrackingAnalyzer.cc:190
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
TrackingAnalyser::actionExecutor_
TrackingActionExecutor * actionExecutor_
Definition: TrackingAnalyzer.h:74
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
FEDRawData.h
FileInPath.h
TrackingAnalyser::nFEDinVsLSname_
std::string nFEDinVsLSname_
Definition: TrackingAnalyzer.h:83
edm::FileInPath
Definition: FileInPath.h:64
MakerMacros.h
SiStripFedCablingRcd
Definition: SiStripCondDataRecords.h:22
TrackingActionExecutor::fillDummyGlobalStatus
void fillDummyGlobalStatus()
Definition: TrackingActionExecutor.cc:55
SiStripDetCabling.h
TrackingAnalyser::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
BeginRun.
Definition: TrackingAnalyzer.cc:93
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackingAnalyser::dqmEndJob
void dqmEndJob(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_) override
Endjob.
Definition: TrackingAnalyzer.cc:175
groupFilesInBlocks.fin
fin
Definition: groupFilesInBlocks.py:94
Service.h
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
dqm::legacy::MonitorElement::getTProfile
virtual TProfile * getTProfile() const
Definition: MonitorElement.h:506
TrackingAnalyser::nLumiSecs_
int nLumiSecs_
Definition: TrackingAnalyzer.h:77
SiStripDetCablingRcd
Definition: SiStripDependentRecords.h:19
TrackingAnalyser::beginJob
void beginJob() override
BeginJob.
Definition: TrackingAnalyzer.cc:89
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackingAnalyser::nFEDinfoDir_
std::string nFEDinfoDir_
Definition: TrackingAnalyzer.h:82
edm::ParameterSet
Definition: ParameterSet.h:36
SiStripCondDataRecords.h
Event.h
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
TrackingAnalyser::TrackingAnalyser
TrackingAnalyser(const edm::ParameterSet &ps)
Constructor.
Definition: TrackingAnalyzer.cc:41
TrackingUtility.h
TrackingAnalyser
Definition: TrackingAnalyzer.h:25
recoMuon::in
Definition: RecoMuonEnumerators.h:6
TrackingAnalyser::~TrackingAnalyser
~TrackingAnalyser() override
Destructor.
Definition: TrackingAnalyzer.cc:83
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
TrackingAnalyser::dqmBeginLuminosityBlock
void dqmBeginLuminosityBlock(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup)
Begin Luminosity Block.
Definition: TrackingAnalyzer.cc:111
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
FEDRawDataCollection.h
edm::EventSetup
Definition: EventSetup.h:57
l1tstage2_dqm_sourceclient-live_cfg.rawDataTag
rawDataTag
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:131
TrackingAnalyser::nFEDinWdataVsLSname_
std::string nFEDinWdataVsLSname_
Definition: TrackingAnalyzer.h:84
get
#define get
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
TrackingAnalyser::detCabling_
edm::ESHandle< SiStripDetCabling > detCabling_
Definition: TrackingAnalyzer.h:73
InputTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TrackingActionExecutor.h
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TrackingAnalyser::shiftReportFrequency_
int shiftReportFrequency_
Definition: TrackingAnalyzer.h:64
TrackingActionExecutor::fillGlobalStatus
void fillGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
Definition: TrackingActionExecutor.cc:62
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
dqm::implementation::IBooker
Definition: DQMStore.h:43
TrackingAnalyser::verbose_
bool verbose_
Definition: TrackingAnalyzer.h:56
TrackingAnalyser::rawDataToken_
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
Definition: TrackingAnalyzer.h:66
TrackingAnalyzer.h
SiStripDetCablingRcd.h
TrackingAnalyser::m_cacheID_
unsigned long long m_cacheID_
Definition: TrackingAnalyzer.h:76
ParameterSet.h
TrackingActionExecutor
Definition: TrackingActionExecutor.h:24
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
StripSubdetector.h
edm::InputTag
Definition: InputTag.h:15
TrackingAnalyser::html_out_
std::ostringstream html_out_
Definition: TrackingAnalyzer.h:80
TrackingAnalyser::trackerFEDsWdataFound_
bool trackerFEDsWdataFound_
Definition: TrackingAnalyzer.h:79
TrackingAnalyser::staticUpdateFrequency_
int staticUpdateFrequency_
Definition: TrackingAnalyzer.h:62