CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelWebInterface.cc
Go to the documentation of this file.
9 
10 #include <map>
11 #include <iostream>
12 #include <sstream>
13 
14 #define BUF_SIZE 256
15 
16 using namespace std ;
17 
18 
19 //____________________________________________________________________________________________________
21  bool offlineXMLfile,
22  bool Tier0Flag) :
23  bei_(bei),
24  offlineXMLfile_(offlineXMLfile),
25  Tier0Flag_(Tier0Flag) {
26 
28  actionExecutor_ = 0;
29  infoExtractor_ = 0;
30  tkMapOptions_.push_back("Persistant");
31  tkMapOptions_.push_back("Temporary");
32  tkMapCreated = false;
35 }
36 
37 //____________________________________________________________________________________________________
38 //
39 // -- Destructor
40 //
42  if (actionExecutor_) delete actionExecutor_;
43  actionExecutor_ = 0;
44  if (infoExtractor_) delete infoExtractor_;
45  infoExtractor_ = 0;
46 }
47 
48 //____________________________________________________________________________________________________
49 //
50 // -- Handles requests from WebElements submitting non-default requests
51 //
53  DQMScope enter;
54  //DQMStore* bei = (*mui_p)->getBEInterface();
55  CgiReader reader(in);
56  reader.read_form(requestMap_);
57  // get the string that identifies the request:
58  std::string requestID = get_from_multimap(requestMap_, "RequestID");
59  cout << ACGreen << ACBold << ACReverse
60  << "[SiPixelWebInterface::handleEDARequest]"
61  << ACCyan
62  << " requestID "
63  << ACPlain
64  << requestID << endl;
65 
66  if (requestID == "IsReady") {
68  returnReplyXml(out, "ReadyState", "wait");
69  } else if (requestID == "CheckQTResults") {
71  } else if (requestID == "updateIMGCPlots") { // <-----------------
73  std::string MEFolder = get_from_multimap(requestMap_, "MEFolder");
74  //cout << ACYellow << ACBold
75  // << "[SiPixelWebInterface::handleEDARequest] "
76  // << ACPlain
77  // << "Collecting ME from folder "
78  // << MEFolder
79  // << endl ;
80  out->getHTTPResponseHeader().addHeader("Content-Type", "text/html");
81  out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
82  out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
83  out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
84  bei_->cd() ;
85  bei_->cd(MEFolder) ;
86 
87  vector<std::string> meList = bei_->getMEs() ;
88 
89  *out << MEFolder << " " ;
90  bei_->cd() ;
91  for(vector<std::string>::iterator it=meList.begin(); it!=meList.end(); it++)
92  {
93  *out << *it << " " ;
94  }
95 
96  } else if (requestID == "getIMGCPlot") { // <-----------------
98 
99  } else if (requestID == "SetupQTest") { // <-----------------
101 
102  } else if (requestID == "CreateSummary") { // <-----------------
104 
105  } else if (requestID == "CreateTkMap") {
106  std::string name = "TkMap";
107  std::string comment;
108  if (tkMapCreated) comment = "Successful";
109  else comment = "Failed";
110  returnReplyXml(out, name, comment);
112  } else if (requestID == "SingleModuleHistoList") {
115  } else if (requestID == "ModuleHistoList") {
117  string sname = get_from_multimap(requestMap_, "StructureName");
118  //cout<<"in EDARequest: structure name= "<<sname<<endl;
119  infoExtractor_->readModuleHistoTree(bei_, sname, out);
120  } else if (requestID == "SummaryHistoList") {
122  string sname = get_from_multimap(requestMap_, "StructureName");
124  } else if (requestID == "AlarmList") {
126  string sname = get_from_multimap(requestMap_, "StructureName");
127  infoExtractor_->readAlarmTree(bei_, sname, out);
128  } else if (requestID == "ReadQTestStatus") {
130  //string path = get_from_multimap(requestMap_, "Path");
131  //infoExtractor_->readStatusMessage(bei_, path, out);
133  } else if (requestID == "PlotAsModule") {
134  //theActionFlag = PlotSingleModuleHistos;
137  } else if (requestID == "PlotHistogramFromPath") {
138  //theActionFlag = PlotHistogramFromPath;
141  //} else if (requestID == "PlotSingleHistogram") {
142  // theActionFlag = PlotSingleHistogram;
143 
144  } else if (requestID == "PlotTkMapHistogram") {
145  //string theMEName = get_from_multimap(requestMap_, "MEName");
146  //string theModId = get_from_multimap(requestMap_, "ModId");
147  //infoExtractor_->plotTkMapHisto(bei, theModId, theMEName);
148  //out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
149  //out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
150  //out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
151  //out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
152  //*out << infoExtractor_->getNamedImage(theMEName).str();
155  //} else if (requestID == "UpdatePlot") {
156  // string theMEName = get_from_multimap(requestMap_, "MEName");
157  // out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
158  // out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
159  // out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
160  // out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
161  // *out << infoExtractor_->getImage().str();
162  // theActionFlag = NoAction;
163  // } else if (requestID == "UpdateTkMapPlot") {
164  // string theMEName = get_from_multimap(requestMap_, "MEName");
165  // out->getHTTPResponseHeader().addHeader("Content-Type", "image/png");
166  // out->getHTTPResponseHeader().addHeader("Pragma", "no-cache");
167  // out->getHTTPResponseHeader().addHeader("Cache-Control", "no-store, no-cache, must-revalidate,max-age=0");
168  // out->getHTTPResponseHeader().addHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
169  // *out << infoExtractor_->getNamedImage(theMEName).str();
170  // theActionFlag = NoAction;
171 
172  } else if (requestID == "GetMEList") {
175 
176  } else if (requestID == "GetTkMap") {
178 
179  ifstream fin("dqmtmapviewer.xhtml");
180  char buf[BUF_SIZE];
181  std::ostringstream html_out;
182  if (!fin) {
183  std::cerr << "Input File: dqmtmapviewer.xhtml "<< " could not be opened!" << std::endl;
184  return;
185  }
186  while (fin.getline(buf, BUF_SIZE, '\n')) { // pops off the newline character
187  html_out << buf << std::endl;
188  }
189  fin.close();
190 
191  out->getHTTPResponseHeader().addHeader("Content-type","application/xhtml+xml");
192  *out << html_out.str();
193  } else if (requestID == "periodicTrackerMapUpdate") {
195  periodicTkMapUpdate(out) ;
196 
197  } else if (requestID == "globalQFlag") {
198  //cout << ACYellow << ACBold << "[SiPixelWebInterface::handleEDARequest] "
199  // << ACPlain << "Compute global Pixel quality flag" << endl;
201  } else if (requestID == "dumpModIds") {
203  }
204 
205  performAction();
206 }
207 
208 //____________________________________________________________________________________________________
209 // -- Perform action
210 //
212 //cout<<"entering performAction..."<<endl;
213  //DQMStore * bei_ = (*mui_p)->getBEInterface();
214  switch (theActionFlag) {
216  {
217  if (createTkMap()) {
218 // cout<<"calling the dtor before this?"<<endl;
219  tkMapCreated = true;
220 // theOut->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
221 // *theOut << "<?xml version=\"1.0\" ?>" << endl;
222 // *theOut << "<TkMap>" << endl;
223 // *theOut << " <Response>Successfull</Response>" << endl;
224 // *theOut << "</TkMap>" << endl;
225 //cout<<"Done creating the TkMap in WI::performAction, what now?!"<<endl;
226  }
227  break;
228  }
230  {
232  break;
233  }
235  {
237  break;
238  }
240  {
242  break;
243  }
245  {
247  break;
248  }
250  {
251 // infoExtractor_->plotSingleModuleHistos(bei_, requestMap_);
252  break;
253  }
255  {
256 // string theMEName = get_from_multimap(requestMap_, "MEName");
257 // string theModId = get_from_multimap(requestMap_, "ModId");
258 // infoExtractor_->plotTkMapHisto(bei_, theModId, theMEName);
259 //
260 // cout << ACYellow << ACBold
261 // << "[SiPixelWebInterface::PlotTkMapHistogram()]"
262 // << ACPlain
263 // << " Buffer for "
264 // << theMEName
265 // << " stored away: shipping back header (" << theOut << ")"
266 // << endl ;
279  break;
280  }
282  {
283 // infoExtractor_->plotSingleHistogram(bei_, requestMap_);
284  break;
285  }
287  {
288  break;
289  }
291  {
292 // infoExtractor_->getHistosFromPath(bei_, requestMap_);
293  break;
294  }
296  {
298  break;
299  }
301  {
302  break;
303  }
305  {
306  break;
307  }
309  {
310  break;
311  }
312  }
314 // cout<<"leaving performAction..."<<endl;
315 }
316 
317 
318 //____________________________________________________________________________________________________
320  const std::string& name,
321  const std::string& comment){
322  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
323  *out << "<?xml version=\"1.0\" ?>" << std::endl;
324  *out << "<TkMap>" << endl;
325  *out << " <Response>" << comment << "</Response>" << endl;
326  *out << "</TkMap>" << endl;
327 
328 }
329 
330 
331 //____________________________________________________________________________________________________
333  //DQMStore * bei = (*mui_p)->getBEInterface();
335  string sname = get_from_multimap(requestMap_, "MEName");
336  string theTKType = get_from_multimap(requestMap_, "TKMapType");
337  actionExecutor_->createTkMap(bei_, sname, theTKType);
338  return true;
339  } else {
340  return false;
341  }
342 }
343 
344 
345 //____________________________________________________________________________________________________
347 {
348  //DQMStore * bei = (*mui_p)->getBEInterface();
349  string sname = get_from_multimap(requestMap_, "MEName");
350  string theTKType = get_from_multimap(requestMap_, "TKMapType");
351  infoExtractor_->sendTkUpdatedStatus(bei_, out, sname, theTKType) ;
352 }
353 
354 //____________________________________________________________________________________________________
355 bool SiPixelWebInterface::readConfiguration(int& tkmap_freq,int& summary_freq){
356  bool success=false;
357  tkmap_freq = -1;
358  summary_freq = -1;
359  if (actionExecutor_) {
360  actionExecutor_->readConfiguration(tkmap_freq,summary_freq);
361  if(tkmap_freq!=-1 && summary_freq!=-1) success=true;
362  }
363  return success;
364 }
365 
366 //
367 // Get the RequestId and tags
368 //
369 std::string SiPixelWebInterface::get_from_multimap(std::multimap<std::string, std::string> &mymap, std::string key)
370 {
371  std::multimap<std::string, std::string>::iterator it;
372  it = mymap.find(key);
373  if (it != mymap.end())
374  {
375  return (it->second);
376  }
377  return "";
378 }
#define Input(cl)
Definition: vmac.h:189
void getTrackerMapHistos(DQMStore *bei, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
bool readConfiguration(int &tkmap_freq, int &summary_freq)
void getIMGCImage(const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:209
void periodicTkMapUpdate(xgi::Output *out)
SiPixelActionExecutor * actionExecutor_
void createTkMap(DQMStore *bei, std::string mEName, std::string theTKType)
void readModuleHistoTree(DQMStore *bei, std::string &str_name, xgi::Output *out)
(Documentation under construction).
void sendTkUpdatedStatus(DQMStore *bei, xgi::Output *out, std::string &meName, std::string &theTKType)
(Documentation under construction).
bool readConfiguration(int &tkmap_freq, int &sum_barrel_freq, int &sum_endcap_freq, int &sum_grandbarrel_freq, int &sum_grandendcap_freq, int &message_limit, int &source_type, int &calib_type)
SiPixelInformationExtractor * infoExtractor_
std::vector< std::string > tkMapOptions_
void setupQTests(DQMStore *bei)
std::multimap< std::string, std::string > requestMap_
void createOccupancy(DQMStore *bei)
void readStatusMessage(DQMStore *bei, std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void read_form(std::multimap< std::string, std::string > &form_info)
Definition: CgiReader.cc:6
void getHistosFromPath(DQMStore *bei, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void setActionFlag(SiPixelActionType flag)
void handleEDARequest(xgi::Input *in, xgi::Output *out, int niter)
#define ACReverse
Definition: ANSIColors.h:32
tuple out
Definition: dbtoconf.py:99
void readModuleAndHistoList(DQMStore *bei, xgi::Output *out)
(Documentation under construction).
#define ACCyan
Definition: ANSIColors.h:14
void getSingleModuleHistos(DQMStore *bei, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
std::string get_from_multimap(std::multimap< std::string, std::string > &mymap, std::string key)
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1239
#define ACGreen
Definition: ANSIColors.h:13
list key
Definition: combine.py:13
#define Output(cl)
Definition: vmac.h:193
#define BUF_SIZE
void readAlarmTree(DQMStore *bei, std::string &str_name, xgi::Output *out)
(Documentation under construction).
tuple cout
Definition: gather_cfg.py:41
#define ACPlain
Definition: ANSIColors.h:28
void readSummaryHistoTree(DQMStore *bei, std::string &str_name, xgi::Output *out)
(Documentation under construction).
void checkQTestResults(DQMStore *bei)
SiPixelActionType theActionFlag
#define ACBold
Definition: ANSIColors.h:29
void returnReplyXml(xgi::Output *out, const std::string &name, const std::string &comment)
void createSummary(DQMStore *bei)
SiPixelWebInterface(DQMStore *bei, bool offlineXMLfile, bool Tier0Flag)
#define comment(par)
Definition: vmac.h:162