CMS 3D CMS Logo

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