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: 2013/01/02 17:41:51 $
7  * $Revision: 1.62 $
8  * \author S. Dutta INFN-Pisa
9  *
10  */
11 
12 
14 
15 
17 
18 
25 
27 
31 
35 
40 
46 
47 #include "xgi/Method.h"
48 #include "xgi/Utils.h"
49 
50 #include "cgicc/Cgicc.h"
51 #include "cgicc/FormEntry.h"
52 #include "cgicc/HTMLClasses.h"
53 
54 #include <iostream>
55 #include <iomanip>
56 #include <stdio.h>
57 #include <string>
58 #include <sstream>
59 #include <math.h>
60 
61 #define BUF_SIZE 256
62 
63 //
64 // -- Constructor
65 //
67  ModuleWeb("SiStripAnalyser") {
68 
69  // Get TkMap ParameterSet
70  tkMapPSet_ = ps.getParameter<edm::ParameterSet>("TkmapParameters");
71 
72  std::string localPath = std::string("DQM/SiStripMonitorClient/test/loader.html");
73  ifstream fin(edm::FileInPath(localPath).fullPath().c_str(), std::ios::in);
74  char buf[BUF_SIZE];
75 
76  if (!fin) {
77  std::cerr << "Input File: loader.html"<< " could not be opened!" << std::endl;
78  return;
79  }
80 
81  while (fin.getline(buf, BUF_SIZE, '\n')) { // pops off the newline character
82  html_out_ << buf ;
83  }
84  fin.close();
85 
86 
87 
88  edm::LogInfo("SiStripAnalyser") << " SiStripAnalyser::Creating SiStripAnalyser ";
89  summaryFrequency_ = ps.getUntrackedParameter<int>("SummaryCreationFrequency",1);
90  tkMapFrequency_ = ps.getUntrackedParameter<int>("TkMapCreationFrequency",1);
91  staticUpdateFrequency_ = ps.getUntrackedParameter<int>("StaticUpdateFrequency",1);
92  globalStatusFilling_ = ps.getUntrackedParameter<int>("GlobalStatusFilling", 1);
93  shiftReportFrequency_ = ps.getUntrackedParameter<int>("ShiftReportFrequency", 1);
94  rawDataTag_ = ps.getUntrackedParameter<edm::InputTag>("RawDataTag");
95  printFaultyModuleList_ = ps.getUntrackedParameter<bool>("PrintFaultyModuleList", true);
96 
97  // get back-end interface
99 
100 
101  // instantiate web interface
102  sistripWebInterface_ = new SiStripWebInterface(dqmStore_);
105  trackerFEDsFound_ = false;
106  endLumiAnalysisOn_ = false;
107 }
108 //
109 // -- Destructor
110 //
112 
113  edm::LogInfo("SiStripAnalyser") << "SiStripAnalyser::Deleting SiStripAnalyser ";
114 // if (sistripWebInterface_) {
115 // delete sistripWebInterface_;
116 // sistripWebInterface_ = 0;
117 // }
118 // if (trackerMapCreator_) {
119 // delete trackerMapCreator_;
120 // trackerMapCreator_ = 0;
121 // }
122 
123 }
124 //
125 // -- Begin Job
126 //
128 
129  // Read the summary configuration file
131  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: Error to read configuration file!! Summary will not be produced!!!";
132  summaryFrequency_ = -1;
133  }
134  nLumiSecs_ = 0;
135  nEvents_ = 0;
136 }
137 //
138 // -- Begin Run
139 //
141  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: Begining of Run";
142 
143  // Check latest Fed cabling and create TrackerMapCreator
144  unsigned long long cacheID = eSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
145  if (m_cacheID_ != cacheID) {
146  m_cacheID_ = cacheID;
147  edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser::beginRun: "
148  << " Change in Cabling, recrated TrackerMap";
149  if (!actionExecutor_->readTkMapConfiguration(eSetup)) {
150  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: Error to read configuration file!! TrackerMap will not be produced!!!";
151  tkMapFrequency_ = -1;
152 
153  }
154  eSetup.get<SiStripFedCablingRcd>().get(fedCabling_);
155  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
156  }
157  if (condDataMon_) condDataMon_->beginRun(eSetup);
159 }
160 //
161 // -- Begin Luminosity Block
162 //
164  edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser:: Begin of LS transition";
165 }
166 //
167 // -- Analyze
168 //
170  nEvents_++;
171  if (nEvents_ == 1 && globalStatusFilling_ > 0) {
172  checkTrackerFEDs(e);
173  if (!trackerFEDsFound_) {
176  } else {
179  }
180  }
181 
182  unsigned int nval = sistripWebInterface_->getNumberOfConDBPlotRequest();
183  if (nval > 0) {
184  for (unsigned int ival = 0; ival < nval; ival++) {
185  uint32_t det_id;
186  std::string subdet_type;
187  uint32_t subdet_side;
188  uint32_t layer_number;
189  sistripWebInterface_->getConDBPlotParameters(ival, det_id, subdet_type, subdet_side, layer_number);
190  if (condDataMon_) {
191  if (det_id == 999) condDataMon_->getLayerMEsOnDemand(eSetup,subdet_type, subdet_side,layer_number);
192  else if (layer_number == 999 && subdet_side == 999) condDataMon_->getModMEsOnDemand(eSetup,det_id);
193  }
194  }
196  }
199 }
200 //
201 // -- End Luminosity Block
202 //
204  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: End of LS transition, performing the DQM client operation";
205 
206  nLumiSecs_++;
207 
208  if (!trackerFEDsFound_) {
210  return;
211  }
212  endLumiAnalysisOn_ = true;
213 
214  // sistripWebInterface_->setCabling(detCabling_);
215 
216  std::cout << "====================================================== " << std::endl;
217  std::cout << " ===> Iteration # " << nLumiSecs_ << " "
218  << lumiSeg.luminosityBlock() << std::endl;
219  std::cout << "====================================================== " << std::endl;
220  // Create predefined plots
222  std::cout << " Creating predefined plots " << std::endl;
225  }
226  // Fill Global Status
227  if (globalStatusFilling_ > 0) {
229  }
230  // -- Create summary monitor elements according to the frequency
231  if (summaryFrequency_ != -1 && nLumiSecs_ > 0 && nLumiSecs_%summaryFrequency_ == 0) {
232  std::cout << " Creating Summary " << std::endl;
234  }
235  // -- Create TrackerMap according to the frequency
236  if (tkMapFrequency_ != -1 && nLumiSecs_ > 0 && nLumiSecs_%tkMapFrequency_ == 0) {
237  std::cout << " Creating Tracker Map " << std::endl;
239  actionExecutor_->createTkMap(tkMapPSet_, dqmStore_, tkmap_type, eSetup);
240  }
241  // Create Shift Report
242  // if (shiftReportFrequency_ != -1 && trackerFEDsFound_ && nLumiSecs_%shiftReportFrequency_ == 0) {
243  // actionExecutor_->createShiftReport(dqmStore_);
244  // }
245  endLumiAnalysisOn_ = false;
246 }
247 
248 //
249 // -- End Run
250 //
252  edm::LogInfo ("SiStripAnalyser") <<"SiStripAnalyser:: End of Run";
253 }
254 //
255 // -- End Job
256 //
258  edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser:: endjob called!";
260  std::ostringstream str_val;
262  std::cout << str_val.str() << std::endl;
263  }
264 }
265 //
266 // Check Tracker FEDs
267 //
269  edm::Handle<FEDRawDataCollection> rawDataHandle;
270  e.getByLabel(rawDataTag_, rawDataHandle);
271  if ( !rawDataHandle.isValid() ) return;
272 
273  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
274  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
275  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
276 
277  unsigned int nFed = 0;
278  for (int i=siStripFedIdMin; i <= siStripFedIdMax; i++) {
279  if (rawDataCollection.FEDData(i).size() && rawDataCollection.FEDData(i).data()) {
280  nFed++;
281  }
282  }
283  if (nFed > 0) trackerFEDsFound_ = true;
284 }
285 //
286 // -- Create default web page
287 //
289 {
290  bool isRequest = false;
291  cgicc::Cgicc cgi(in);
292  cgicc::CgiEnvironment cgie(in);
293  // edm::LogInfo("SiStripAnalyser") <<"SiStripAnalyser:: defaultWebPage "
294  // << " query string : " << cgie.getQueryString();
295  // if ( xgi::Utils::hasFormElement(cgi,"ClientRequest") ) isRequest = true;
296  std::string q_string = cgie.getQueryString();
297  if (q_string.find("RequestID") != std::string::npos) isRequest = true;
298  if (!isRequest) {
299  *out << html_out_.str() << std::endl;
300  } else {
301  // Handles all HTTP requests of the form
302  int iter = -1;
303  if (endLumiAnalysisOn_) {
305  } else {
306  iter = nEvents_/10;
308  }
309  }
310 }
311 
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)
void createTkMap(const edm::ParameterSet &tkmapPset, DQMStore *dqm_store, std::string &map_type, const edm::EventSetup &eSetup)
DQMStore * dqmStore_
#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
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:361
void getModMEsOnDemand(edm::EventSetup const &eSetup, uint32_t requestedDetId)
tuple out
Definition: dbtoconf.py:99
SiStripWebInterface * sistripWebInterface_
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:36
void checkTrackerFEDs(edm::Event const &e)
void defaultWebPage(xgi::Input *in, xgi::Output *out)