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  * $Date: 2012/11/20 11:28:25 $
7  * $Revision: 1.61 $
8  * \author S. Dutta INFN-Pisa
9  *
10  */
11 
12 
14 
15 
17 
18 
25 
27 
33 
37 
42 
48 
49 #include "xgi/Method.h"
50 #include "xgi/Utils.h"
51 
52 #include "cgicc/Cgicc.h"
53 #include "cgicc/FormEntry.h"
54 #include "cgicc/HTMLClasses.h"
55 
56 #include <iostream>
57 #include <iomanip>
58 #include <stdio.h>
59 #include <string>
60 #include <sstream>
61 #include <math.h>
62 
63 #define BUF_SIZE 256
64 
65 //
66 // -- Constructor
67 //
69  ModuleWeb("SiStripAnalyser") {
70 
71  // Get TkMap ParameterSet
72  tkMapPSet_ = ps.getParameter<edm::ParameterSet>("TkmapParameters");
73 
74  std::string localPath = std::string("DQM/SiStripMonitorClient/test/loader.html");
75  ifstream fin(edm::FileInPath(localPath).fullPath().c_str(), std::ios::in);
76  char buf[BUF_SIZE];
77 
78  if (!fin) {
79  std::cerr << "Input File: loader.html"<< " could not be opened!" << std::endl;
80  return;
81  }
82 
83  while (fin.getline(buf, BUF_SIZE, '\n')) { // pops off the newline character
84  html_out_ << buf ;
85  }
86  fin.close();
87 
88 
89 
90  edm::LogInfo("SiStripAnalyser") << " SiStripAnalyser::Creating SiStripAnalyser ";
91  summaryFrequency_ = ps.getUntrackedParameter<int>("SummaryCreationFrequency",1);
92  tkMapFrequency_ = ps.getUntrackedParameter<int>("TkMapCreationFrequency",1);
93  staticUpdateFrequency_ = ps.getUntrackedParameter<int>("StaticUpdateFrequency",1);
94  globalStatusFilling_ = ps.getUntrackedParameter<int>("GlobalStatusFilling", 1);
95  shiftReportFrequency_ = ps.getUntrackedParameter<int>("ShiftReportFrequency", 1);
96  rawDataTag_ = ps.getUntrackedParameter<edm::InputTag>("RawDataTag");
97  printFaultyModuleList_ = ps.getUntrackedParameter<bool>("PrintFaultyModuleList", true);
98 
99  // get back-end interface
101 
102 
103  // instantiate web interface
104  sistripWebInterface_ = new SiStripWebInterface(dqmStore_);
107  trackerFEDsFound_ = false;
108  endLumiAnalysisOn_ = false;
109 }
110 //
111 // -- Destructor
112 //
114 
115  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser::Deleting SiStripAnalyser ";
116 // if (sistripWebInterface_) {
117 // delete sistripWebInterface_;
118 // sistripWebInterface_ = 0;
119 // }
120 // if (trackerMapCreator_) {
121 // delete trackerMapCreator_;
122 // trackerMapCreator_ = 0;
123 // }
124 
125 }
126 //
127 // -- Begin Job
128 //
130 
131  // Read the summary configuration file
133  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: Error to read configuration file!! Summary will not be produced!!!";
134  summaryFrequency_ = -1;
135  }
136  nLumiSecs_ = 0;
137  nEvents_ = 0;
138 }
139 //
140 // -- Begin Run
141 //
143  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: Begining of Run";
144 
145  // Check latest Fed cabling and create TrackerMapCreator
146  unsigned long long cacheID = eSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
147  if (m_cacheID_ != cacheID) {
148  m_cacheID_ = cacheID;
149  edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser::beginRun: "
150  << " Change in Cabling, recrated TrackerMap";
151  if (!actionExecutor_->readTkMapConfiguration(eSetup)) {
152  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: Error to read configuration file!! TrackerMap will not be produced!!!";
153  tkMapFrequency_ = -1;
154 
155  }
156  eSetup.get<SiStripFedCablingRcd>().get(fedCabling_);
157  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
158  }
159  if (condDataMon_) condDataMon_->beginRun(eSetup);
161 }
162 //
163 // -- Begin Luminosity Block
164 //
166  edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser:: Begin of LS transition";
167 }
168 //
169 // -- Analyze
170 //
172  nEvents_++;
173  if (nEvents_ == 1 && globalStatusFilling_ > 0) {
174  checkTrackerFEDs(e);
175  if (!trackerFEDsFound_) {
178  } else {
181  }
182  }
183 
184  unsigned int nval = sistripWebInterface_->getNumberOfConDBPlotRequest();
185  if (nval > 0) {
186  for (unsigned int ival = 0; ival < nval; ival++) {
187  uint32_t det_id;
188  std::string subdet_type;
189  uint32_t subdet_side;
190  uint32_t layer_number;
191  sistripWebInterface_->getConDBPlotParameters(ival, det_id, subdet_type, subdet_side, layer_number);
192  if (condDataMon_) {
193  if (det_id == 999) condDataMon_->getLayerMEsOnDemand(eSetup,subdet_type, subdet_side,layer_number);
194  else if (layer_number == 999 && subdet_side == 999) condDataMon_->getModMEsOnDemand(eSetup,det_id);
195  }
196  }
198  }
201 }
202 //
203 // -- End Luminosity Block
204 //
206  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: End of LS transition, performing the DQM client operation";
207 
208  nLumiSecs_++;
209 
210  if (!trackerFEDsFound_) {
212  return;
213  }
214  endLumiAnalysisOn_ = true;
215 
216  // sistripWebInterface_->setCabling(detCabling_);
217 
218  std::cout << "====================================================== " << std::endl;
219  std::cout << " ===> Iteration # " << nLumiSecs_ << " "
220  << lumiSeg.luminosityBlock() << std::endl;
221  std::cout << "====================================================== " << std::endl;
222  // Create predefined plots
224  std::cout << " Creating predefined plots " << std::endl;
227  }
228  // Fill Global Status
229  if (globalStatusFilling_ > 0) {
231  }
232  // -- Create summary monitor elements according to the frequency
233  if (summaryFrequency_ != -1 && nLumiSecs_ > 0 && nLumiSecs_%summaryFrequency_ == 0) {
234  std::cout << " Creating Summary " << std::endl;
236  }
237  // -- Create TrackerMap according to the frequency
238  if (tkMapFrequency_ != -1 && nLumiSecs_ > 0 && nLumiSecs_%tkMapFrequency_ == 0) {
239  std::cout << " Creating Tracker Map " << std::endl;
240  std::string tkmap_type = sistripWebInterface_->getTkMapType();
242  }
243  // Create Shift Report
244  // if (shiftReportFrequency_ != -1 && trackerFEDsFound_ && nLumiSecs_%shiftReportFrequency_ == 0) {
245  // actionExecutor_->createShiftReport(dqmStore_);
246  // }
247  endLumiAnalysisOn_ = false;
248 }
249 
250 //
251 // -- End Run
252 //
254  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: End of Run";
255 }
256 //
257 // -- End Job
258 //
260  edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser:: endjob called!";
262  std::ostringstream str_val;
264  std::cout << str_val.str() << std::endl;
265  }
266 }
267 //
268 // Check Tracker FEDs
269 //
271  edm::Handle<FEDRawDataCollection> rawDataHandle;
272  e.getByLabel(rawDataTag_, rawDataHandle);
273  if ( !rawDataHandle.isValid() ) return;
274 
275  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
276  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
277  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
278 
279  unsigned int nFed = 0;
280  for (int i=siStripFedIdMin; i <= siStripFedIdMax; i++) {
281  if (rawDataCollection.FEDData(i).size() && rawDataCollection.FEDData(i).data()) {
282  nFed++;
283  }
284  }
285  if (nFed > 0) trackerFEDsFound_ = true;
286 }
287 //
288 // -- Create default web page
289 //
291 {
292  bool isRequest = false;
293  cgicc::Cgicc cgi(in);
294  cgicc::CgiEnvironment cgie(in);
295  // edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser:: defaultWebPage "
296  // << " query string : " << cgie.getQueryString();
297  // if ( xgi::Utils::hasFormElement(cgi,"ClientRequest") ) isRequest = true;
298  std::string q_string = cgie.getQueryString();
299  if (q_string.find("RequestID") != std::string::npos) isRequest = true;
300  if (!isRequest) {
301  *out << html_out_.str() << std::endl;
302  } else {
303  // Handles all HTTP requests of the form
304  int iter = -1;
305  if (endLumiAnalysisOn_) {
307  } else {
308  iter = nEvents_/10;
310  }
311  }
312 }
313 
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_
#define Input(cl)
Definition: vmac.h:189
void getConDBPlotParameters(unsigned int ival, uint32_t &det_id, std::string &subdet_type, uint32_t &subdet_side, uint32_t &layer_number)
DQMStore * dqmStore_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void createSummary(DQMStore *dqm_store)
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_
void createTkMap(const edm::ParameterSet &tkmapPset, DQMStore *dqm_store, std::string &map_type)
#define BUF_SIZE
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
LuminosityBlockNumber_t luminosityBlock() const
SiStripActionExecutor * actionExecutor_
void getLayerMEsOnDemand(edm::EventSetup const &eSetup, std::string requestedSubDetector, uint32_t requestedSide, uint32_t requestedLayer)
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:76
edm::ParameterSet tkMapPSet_
void createShiftReport(DQMStore *dqm_store)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void getModMEsOnDemand(edm::EventSetup const &eSetup, uint32_t requestedDetId)
tuple out
Definition: dbtoconf.py:99
SiStripWebInterface * sistripWebInterface_
void fillStatus(DQMStore *dqm_store, const edm::ESHandle< SiStripDetCabling > &fedcabling)
void handleAnalyserRequest(xgi::Input *in, xgi::Output *out, const edm::ESHandle< SiStripDetCabling > &detcabling, int niter)
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_
#define Output(cl)
Definition: vmac.h:193
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
EndRun.
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
BeginRun.
std::string getTkMapType()
tuple cout
Definition: gather_cfg.py:121
SiStripAnalyser(const edm::ParameterSet &ps)
Constructor.
void analyze(edm::Event const &e, edm::EventSetup const &eSetup)
Analyze.
unsigned int getNumberOfConDBPlotRequest()
void printFaultyModuleList(DQMStore *dqm_store, std::ostringstream &str_val)
void setActionFlag(SiStripActionType flag)
Definition: Run.h:33
void checkTrackerFEDs(edm::Event const &e)
void defaultWebPage(xgi::Input *in, xgi::Output *out)