CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripWebInterface.cc
Go to the documentation of this file.
9 
10 
11 #include <map>
12 #include <iostream>
13 #include <sstream>
14 
15 #define BUF_SIZE 256
16 //
17 // -- Constructor
18 //
19 SiStripWebInterface::SiStripWebInterface(DQMStore* dqm_store) : dqmStore_(dqm_store) {
20 
22  infoExtractor_ = 0;
24  TkMapType = "QTestAlarm";
25 }
26 //
27 // -- Destructor
28 //
30  if (infoExtractor_) delete infoExtractor_;
31  infoExtractor_ = 0;
32 }
33 //
34 // -- Handles requests from WebElements submitting non-default requests
35 //
37  DQMScope enter;
38  // put the request information in a multimap...
39  // std::multimap<std::string, std::string> requestMap_;
40  CgiReader reader(in);
41  reader.read_form(requestMap_);
42  if (niter < 0) return;
43  std::string requestID = get_from_multimap(requestMap_, "RequestID");
44  // get the string that identifies the request:
45  edm::LogInfo ("SiStripWebInterface") << "SiStripWebInterface::handleAnalyserRequest RequestID = " << requestID ;
46  if (requestID == "IsReady") {
48  if (niter > 0) {
50  } else {
51  returnReplyXml(out, "ReadyState", "wait");
52  }
53  }
54  else if (requestID == "CheckQTResults") {
55  std::string infoType = get_from_multimap(requestMap_, "InfoType");
56  infoExtractor_->readQTestSummary(dqmStore_, infoType, out);
58  }
59  else if (requestID == "SingleModuleHistoList") {
61  std::string sname = get_from_multimap(requestMap_, "FolderName");
62  infoExtractor_->readModuleAndHistoList(dqmStore_, sname, detcabling, out);
63  }
64  else if (requestID == "GlobalHistoList") {
66  std::string gname = get_from_multimap(requestMap_, "GlobalFolder");
68  }
69  else if (requestID == "SummaryHistoList") {
71  std::string sname = get_from_multimap(requestMap_, "StructureName");
73  }
74  else if (requestID == "AlarmList") {
76  std::string sname = get_from_multimap(requestMap_, "StructureName");
78  }
79  else if (requestID == "ReadQTestStatus") {
82  }
83  else if (requestID == "PlotAsModule") {
86  }
87  else if (requestID == "PlotGlobalHisto") {
90  }
91  else if (requestID == "PlotHistogramFromPath") {
94  }
95  else if (requestID == "PlotTkMapHistogram") {
97  requestMap_.insert(std::pair<std::string,std::string>("TkMapType", TkMapType));
99  }
100  else if (requestID == "PlotHistogramFromLayout") {
102  }
103  else if (requestID == "GetImage") {
105  }
106  else if (requestID == "GetTkMap") {
108 
109  ifstream fin("dqmtmapviewer.xhtml");
110  char buf[BUF_SIZE];
111  std::ostringstream html_out;
112  if (!fin) {
113  std::cerr << "Input File: dqmtmapviewer.xhtml "<< " could not be opened!" << std::endl;
114  return;
115  }
116  while (fin.getline(buf, BUF_SIZE, '\n')) { // pops off the newline character
117  html_out << buf << std::endl;
118  }
119  fin.close();
120 
121  out->getHTTPResponseHeader().addHeader("Content-type","application/xhtml+xml");
122  *out << html_out.str();
123  }
124  else if (requestID == "NonGeomHistoList") {
126  std::string fname = get_from_multimap(requestMap_, "FolderName");
128  }
129  else if (requestID == "PlotModuleCondDBHistos") {
131  CondDBPlotParameter local_par;
132  uint32_t detId = atoi(get_from_multimap(requestMap_,"ModId").c_str());
133  local_par.detId = detId;
134  local_par.type = "";
135  local_par.side = 999;
136  local_par.layer = 999;
137  bool create_plot;
138  infoExtractor_->getCondDBHistos(dqmStore_, create_plot, requestMap_, out);
139  if (create_plot) condDBRequestList_.push_back(local_par);
140  }
141  else if (requestID == "PlotLayerCondDBHistos") {
142 
144  CondDBPlotParameter local_par;
145  std::string sname = get_from_multimap(requestMap_,"StructureName");
146  local_par.detId = 999;
147  local_par.type = sname.substr(sname.find_first_of("/")+1,3);
148  if (sname.find("side_")!=std::string::npos)
149  local_par.side = atoi((sname.substr(sname.find("side_")+5,1)).c_str());
150  else local_par.side = 999;
151  local_par.layer = atoi((sname.substr(sname.find_last_of("_")+1)).c_str());
152  bool create_plot;
153  infoExtractor_->getCondDBHistos(dqmStore_, create_plot, requestMap_, out);
154  if (create_plot) condDBRequestList_.push_back(local_par);
155 
156  } else if (requestID == "UpdateTrackerMapOption") {
159  returnReplyXml(out, "TkMapOption", TkMapType);
160  }
161 
162  performAction();
163 }
164 //
165 // -- Perform action
166 //
168 
169  switch (theActionFlag) {
171  {
172  // actionExecutor_->createSummary(dqmStore_);
173  break;
174  }
176  {
177 // infoExtractor_->plotSingleModuleHistos(dqmStore_, requestMap_, out);
178  break;
179  }
181  {
182 // infoExtractor_->plotGlobalHistos(dqmStore_, requestMap_, out);
183  break;
184  }
186  {
187 // infoExtractor_->plotTrackerMapHistos(dqmStore_, requestMap_, out);
188  break;
189  }
191  {
192 // infoExtractor_->plotHistosFromPath(dqmStore_, requestMap_, out);
193  break;
194  }
196  {
198  break;
199  }
201  {
203  break;
204  }
206  {
207  break;
208  }
209  }
211 }
212 void SiStripWebInterface::returnReplyXml(xgi::Output * out, const std::string& name, const std::string& comment){
213  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
214  *out << "<?xml version=\"1.0\" ?>" << std::endl;
215  *out << "<"<<name<<">" << std::endl;
216  *out << " <Response>" << comment << "</Response>" << std::endl;
217  *out << "</"<<name<<">" << std::endl;
218 }
219 //
220 // Get the RequestId and tags
221 //
222 std::string SiStripWebInterface::get_from_multimap(std::multimap<std::string, std::string> &mymap, std::string key)
223 {
224  std::multimap<std::string, std::string>::iterator it;
225  it = mymap.find(key);
226  if (it != mymap.end())
227  {
228  return (it->second);
229  }
230  return "";
231 }
232 //
233 // -- Get CondDB Parameters
234 //
235 void SiStripWebInterface::getConDBPlotParameters(unsigned int ival, uint32_t &det_id,
236  std::string& subdet_type, uint32_t& subdet_side, uint32_t& layer_number) {
237  if (condDBRequestList_.size() > ival) {
238  det_id = condDBRequestList_[ival].detId;
239  subdet_type = condDBRequestList_[ival].type;
240  subdet_side = condDBRequestList_[ival].side;
241  layer_number = condDBRequestList_[ival].layer;
242  } else {
243  det_id = 999;
244  subdet_type = "";
245  subdet_side = 999;
246  layer_number = 999;
247  }
248 
249 }
void readSummaryHistoTree(DQMStore *dqm_store, std::string &str_name, xgi::Output *out)
void getSingleModuleHistos(DQMStore *dqm_store, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
#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 plotHistosFromLayout(DQMStore *dqm_store)
void getCondDBHistos(DQMStore *dqm_store, bool &plot_flag, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void getTrackerMapHistos(DQMStore *dqm_store, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void returnReplyXml(xgi::Output *out, const std::string &name, const std::string &comment)
void readModuleAndHistoList(DQMStore *dqm_store, std::string &sname, const edm::ESHandle< SiStripDetCabling > &detcabling, xgi::Output *out)
std::vector< CondDBPlotParameter > condDBRequestList_
SiStripInformationExtractor * infoExtractor_
SiStripActionType theActionFlag
void read_form(std::multimap< std::string, std::string > &form_info)
Definition: CgiReader.cc:6
void readStatusMessage(DQMStore *dqm_store, std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void createImages(DQMStore *dqm_store)
void readGlobalHistoList(DQMStore *dqm_store, std::string &dname, xgi::Output *out)
void getImage(const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void readLayoutNames(DQMStore *dqm_store, xgi::Output *out)
void getGlobalHistos(DQMStore *dqm_store, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
tuple out
Definition: dbtoconf.py:99
void getHistosFromPath(DQMStore *dqm_store, const std::multimap< std::string, std::string > &req_map, xgi::Output *out)
void handleAnalyserRequest(xgi::Input *in, xgi::Output *out, const edm::ESHandle< SiStripDetCabling > &detcabling, int niter)
std::string get_from_multimap(std::multimap< std::string, std::string > &mymap, std::string key)
string fname
main script
SiStripWebInterface(DQMStore *dqm_store)
list key
Definition: combine.py:13
#define Output(cl)
Definition: vmac.h:193
void readQTestSummary(DQMStore *dqm_store, std::string type, xgi::Output *out)
#define BUF_SIZE
std::multimap< std::string, std::string > requestMap_
void readNonGeomHistoTree(DQMStore *dqm_store, std::string &fld_name, xgi::Output *out)
void setActionFlag(SiStripActionType flag)
void readAlarmTree(DQMStore *dqm_store, std::string &str_name, xgi::Output *out)
#define comment(par)
Definition: vmac.h:162