CMS 3D CMS Logo

SiStripAnalyser.cc
Go to the documentation of this file.
1 
2 
3 /*
4  * \file SiStripAnalyser.cc
5  *
6  * \author S. Dutta INFN-Pisa
7  *
8  */
9 
10 
12 
13 
15 
16 
23 
25 
27 
31 
36 
41 
42 #include <iostream>
43 #include <iomanip>
44 #include <cstdio>
45 #include <string>
46 #include <sstream>
47 #include <cmath>
48 
49 #define BUF_SIZE 256
50 
51 //
52 // -- Constructor
53 //
55 
56  // Get TkMap ParameterSet
57  tkMapPSet_ = ps.getParameter<edm::ParameterSet>("TkmapParameters");
58 
59  std::string localPath = std::string("DQM/SiStripMonitorClient/test/loader.html");
60  std::ifstream fin(edm::FileInPath(localPath).fullPath().c_str(), std::ios::in);
61  char buf[BUF_SIZE];
62 
63  if (!fin) {
64  std::cerr << "Input File: loader.html"<< " could not be opened!" << std::endl;
65  return;
66  }
67 
68  while (fin.getline(buf, BUF_SIZE, '\n')) { // pops off the newline character
69  html_out_ << buf ;
70  }
71  fin.close();
72 
73 
74 
75  edm::LogInfo("SiStripAnalyser") << " SiStripAnalyser::Creating SiStripAnalyser ";
76  summaryFrequency_ = ps.getUntrackedParameter<int>("SummaryCreationFrequency",1);
77  tkMapFrequency_ = ps.getUntrackedParameter<int>("TkMapCreationFrequency",1);
78  staticUpdateFrequency_ = ps.getUntrackedParameter<int>("StaticUpdateFrequency",1);
79  globalStatusFilling_ = ps.getUntrackedParameter<int>("GlobalStatusFilling", 1);
80  shiftReportFrequency_ = ps.getUntrackedParameter<int>("ShiftReportFrequency", 1);
81  rawDataTag_ = ps.getUntrackedParameter<edm::InputTag>("RawDataTag");
82  printFaultyModuleList_ = ps.getUntrackedParameter<bool>("PrintFaultyModuleList", true);
83 
84  rawDataToken_ = consumes<FEDRawDataCollection>(ps.getUntrackedParameter<edm::InputTag>("RawDataTag") );
85  // get back-end interface
87 
88 
89  // instantiate web interface
92  trackerFEDsFound_ = false;
93  endLumiAnalysisOn_ = false;
94 }
95 //
96 // -- Destructor
97 //
99 
100  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser::Deleting SiStripAnalyser ";
101 // if (sistripWebInterface_) {
102 // delete sistripWebInterface_;
103 // sistripWebInterface_ = 0;
104 // }
105 // if (trackerMapCreator_) {
106 // delete trackerMapCreator_;
107 // trackerMapCreator_ = 0;
108 // }
109 
110 }
111 //
112 // -- Begin Job
113 //
115 
116  // Read the summary configuration file
118  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: Error to read configuration file!! Summary will not be produced!!!";
119  summaryFrequency_ = -1;
120  }
121  nLumiSecs_ = 0;
122  nEvents_ = 0;
123 }
124 //
125 // -- Begin Run
126 //
128  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: Begining of Run";
129 
130  // Check latest Fed cabling and create TrackerMapCreator
131  unsigned long long cacheID = eSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
132  if (m_cacheID_ != cacheID) {
133  m_cacheID_ = cacheID;
134  edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser::beginRun: "
135  << " Change in Cabling, recrated TrackerMap";
136  if (!actionExecutor_->readTkMapConfiguration(eSetup)) {
137  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: Error to read configuration file!! TrackerMap will not be produced!!!";
138  tkMapFrequency_ = -1;
139 
140  }
141  eSetup.get<SiStripFedCablingRcd>().get(fedCabling_);
142  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
143  }
144  if (condDataMon_) condDataMon_->beginRun(eSetup);
146 }
147 //
148 // -- Begin Luminosity Block
149 //
151  edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser:: Begin of LS transition";
152 }
153 //
154 // -- Analyze
155 //
157  nEvents_++;
158  if (nEvents_ == 1 && globalStatusFilling_ > 0) {
159  checkTrackerFEDs(e);
160  if (!trackerFEDsFound_) {
163  } else {
166  }
167  }
168  /* removing xdaq deps
169  unsigned int nval = sistripWebInterface_->getNumberOfConDBPlotRequest();
170  if (nval > 0) {
171  for (unsigned int ival = 0; ival < nval; ival++) {
172  uint32_t det_id;
173  std::string subdet_type;
174  uint32_t subdet_side;
175  uint32_t layer_number;
176  sistripWebInterface_->getConDBPlotParameters(ival, det_id, subdet_type, subdet_side, layer_number);
177  if (condDataMon_) {
178  if (det_id == 999) condDataMon_->getLayerMEsOnDemand(eSetup,subdet_type, subdet_side,layer_number);
179  else if (layer_number == 999 && subdet_side == 999) condDataMon_->getModMEsOnDemand(eSetup,det_id);
180  }
181  }
182  sistripWebInterface_->clearConDBPlotRequests();
183  }
184  sistripWebInterface_->setActionFlag(SiStripWebInterface::CreatePlots);
185  sistripWebInterface_->performAction();
186  */
187 }
188 //
189 // -- End Luminosity Block
190 //
192  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: End of LS transition, performing the DQM client operation";
193 
194  nLumiSecs_++;
195 
196  if (!trackerFEDsFound_) {
198  return;
199  }
200  endLumiAnalysisOn_ = true;
201 
202  // sistripWebInterface_->setCabling(detCabling_);
203 
204  std::cout << "====================================================== " << std::endl;
205  std::cout << " ===> Iteration # " << nLumiSecs_ << " "
206  << lumiSeg.luminosityBlock() << std::endl;
207  std::cout << "====================================================== " << std::endl;
208  // Create predefined plots
209  /*removing xdaq dep
210  if (staticUpdateFrequency_ != -1 && nLumiSecs_ > 0 && nLumiSecs_%staticUpdateFrequency_ == 0) {
211  std::cout << " Creating predefined plots " << std::endl;
212  sistripWebInterface_->setActionFlag(SiStripWebInterface::PlotHistogramFromLayout);
213  sistripWebInterface_->performAction();
214  }
215  */
216  // Fill Global Status
217  if (globalStatusFilling_ > 0) {
219  }
220  // -- Create summary monitor elements according to the frequency
221  if (summaryFrequency_ != -1 && nLumiSecs_ > 0 && nLumiSecs_%summaryFrequency_ == 0) {
222  std::cout << " Creating Summary " << std::endl;
224  }
225  // -- Create TrackerMap according to the frequency
226  /* removing xdaq deps
227  if (tkMapFrequency_ != -1 && nLumiSecs_ > 0 && nLumiSecs_%tkMapFrequency_ == 0) {
228  std::cout << " Creating Tracker Map " << std::endl;
229  std::string tkmap_type = sistripWebInterface_->getTkMapType();
230  actionExecutor_->createTkMap(tkMapPSet_, dqmStore_, tkmap_type, eSetup);
231  }
232  */
233  // Create Shift Report
234  // if (shiftReportFrequency_ != -1 && trackerFEDsFound_ && nLumiSecs_%shiftReportFrequency_ == 0) {
235  // actionExecutor_->createShiftReport(dqmStore_);
236  // }
237  endLumiAnalysisOn_ = false;
238 }
239 
240 //
241 // -- End Run
242 //
244  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: End of Run";
245 }
246 //
247 // -- End Job
248 //
250  edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser:: endjob called!";
252  std::ostringstream str_val;
254  std::cout << str_val.str() << std::endl;
255  }
256 }
257 //
258 // Check Tracker FEDs
259 //
261  edm::Handle<FEDRawDataCollection> rawDataHandle;
262  e.getByToken( rawDataToken_, rawDataHandle );
263  if ( !rawDataHandle.isValid() ) return;
264 
265  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
266  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
267  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
268 
269  unsigned int nFed = 0;
270  for (int i=siStripFedIdMin; i <= siStripFedIdMax; i++) {
271  if (rawDataCollection.FEDData(i).size() && rawDataCollection.FEDData(i).data()) {
272  nFed++;
273  }
274  }
275  if (nFed > 0) trackerFEDsFound_ = true;
276 }
277 //
278 // -- Create default web page
279 //
280 /* removing xdaq deps
281 void SiStripAnalyser::defaultWebPage(xgi::Input *in, xgi::Output *out)
282 {
283  bool isRequest = false;
284  cgicc::Cgicc cgi(in);
285  cgicc::CgiEnvironment cgie(in);
286  // edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser:: defaultWebPage "
287  // << " query string : " << cgie.getQueryString();
288  // if ( xgi::Utils::hasFormElement(cgi,"ClientRequest") ) isRequest = true;
289  std::string q_string = cgie.getQueryString();
290  if (q_string.find("RequestID") != std::string::npos) isRequest = true;
291  if (!isRequest) {
292  *out << html_out_.str() << std::endl;
293  } else {
294  // Handles all HTTP requests of the form
295  int iter = -1;
296  if (endLumiAnalysisOn_) {
297  sistripWebInterface_->handleAnalyserRequest(in, out, detCabling_, iter);
298  } else {
299  iter = nEvents_/10;
300  sistripWebInterface_->handleAnalyserRequest(in, out, detCabling_, iter);
301  }
302  }
303 }
304 */
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
EndRun.
edm::InputTag rawDataTag_
edm::ESHandle< SiStripFedCabling > fedCabling_
DQMStore * dqmStore_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void createSummary(DQMStore *dqm_store)
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
Analyze.
void fillStatus(DQMStore *dqm_store, const edm::ESHandle< SiStripDetCabling > &fedcabling, const edm::EventSetup &eSetup)
std::ostringstream html_out_
void beginRun(edm::EventSetup const &eSetup)
bool readTkMapConfiguration(const edm::EventSetup &eSetup)
void createStatus(DQMStore *dqm_store)
edm::ESHandle< SiStripDetCabling > detCabling_
#define BUF_SIZE
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
~SiStripAnalyser() override
Destructor.
LuminosityBlockNumber_t luminosityBlock() const
SiStripActionExecutor * actionExecutor_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
bool isValid() const
Definition: HandleBase.h:74
edm::ParameterSet tkMapPSet_
void createShiftReport(DQMStore *dqm_store)
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
BeginRun.
void endJob() override
Endjob.
const T & get() const
Definition: EventSetup.h:55
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
Begin Luminosity Block.
SiStripClassToMonitorCondData * condDataMon_
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
End Luminosity Block.
unsigned long long m_cacheID_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
SiStripAnalyser(const edm::ParameterSet &ps)
Constructor.
void printFaultyModuleList(DQMStore *dqm_store, std::ostringstream &str_val)
Definition: Run.h:43
void beginJob() override
BeginJob.
void checkTrackerFEDs(edm::Event const &e)