CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/EventFilter/Goodies/src/iDie.cc

Go to the documentation of this file.
00001 #include "iDie.h"
00002 
00003 #include "xdaq/NamespaceURI.h"
00004 
00005 #include "xoap/SOAPEnvelope.h"
00006 #include "xoap/SOAPBody.h"
00007 #include "xoap/domutils.h"
00008 
00009 #include <boost/tokenizer.hpp>
00010 
00011 #include <netinet/in.h>
00012 #include <sstream>
00013 #include <errno.h>
00014 #include <iomanip>
00015 #include <algorithm>
00016 
00017 #include <sys/time.h>
00018 #include <time.h>
00019 
00020 #include "cgicc/CgiDefs.h"
00021 #include "cgicc/Cgicc.h"
00022 #include "cgicc/FormEntry.h"
00023 #include "cgicc/FormFile.h"
00024 #include "cgicc/HTMLClasses.h"
00025 
00026 #include "EventFilter/Utilities/interface/DebugUtils.h"
00027 
00028 using namespace evf;
00029 
00030 
00032 // construction/destruction
00034 
00035 //______________________________________________________________________________
00036 iDie::iDie(xdaq::ApplicationStub *s) 
00037   : xdaq::Application(s)
00038   , log_(getApplicationLogger())
00039   , instance_(0)
00040   , runNumber_(0)
00041   , totalCores_(0)
00042   , nstates_(0)
00043   , cpustat_(std::vector<std::vector<int> >(0))
00044   , last_ls_(0)
00045   , f_(0)
00046   , t_(0)
00047   , b_(0)
00048   , b1_(0)
00049   , b2_(0)
00050   , b3_(0)
00051   , b4_(0)
00052   , datap_(0)
00053   , trppriv_(0)
00054   , nModuleLegendaMessageReceived_(0)
00055   , nPathLegendaMessageReceived_(0)
00056   , nModuleLegendaMessageWithDataReceived_(0)
00057   , nPathLegendaMessageWithDataReceived_(0)
00058   , nModuleHistoMessageReceived_(0)
00059   , nPathHistoMessageReceived_(0)
00060 {
00061   // initialize application info
00062   url_     =
00063     getApplicationDescriptor()->getContextDescriptor()->getURL()+"/"+
00064     getApplicationDescriptor()->getURN();
00065   class_   =getApplicationDescriptor()->getClassName();
00066   instance_=getApplicationDescriptor()->getInstance();
00067   hostname_=getApplicationDescriptor()->getContextDescriptor()->getURL();
00068   getApplicationDescriptor()->setAttribute("icon", "/evf/images/idieapp.jpg");
00069 
00070   
00071   //soap interface
00072   xoap::bind(this,&evf::iDie::fsmCallback,"Configure",XDAQ_NS_URI);
00073   xoap::bind(this,&evf::iDie::fsmCallback,"Enable",   XDAQ_NS_URI);
00074   xoap::bind(this,&evf::iDie::fsmCallback,"Stop",     XDAQ_NS_URI);
00075   xoap::bind(this,&evf::iDie::fsmCallback,"Halt",     XDAQ_NS_URI);
00076 
00077   // web interface
00078   xgi::bind(this,&evf::iDie::defaultWeb,               "Default");
00079   xgi::bind(this,&evf::iDie::summaryTable,             "summary");
00080   xgi::bind(this,&evf::iDie::detailsTable,             "details");
00081   xgi::bind(this,&evf::iDie::dumpTable,                "dump"   );
00082   xgi::bind(this,&evf::iDie::updater,                  "updater");
00083   xgi::bind(this,&evf::iDie::iChoke,                   "iChoke" );
00084   xgi::bind(this,&evf::iDie::iChokeMiniInterface,      "iChokeMiniInterface" );
00085   xgi::bind(this,&evf::iDie::spotlight,                "Spotlight" );
00086   xgi::bind(this,&evf::iDie::postEntry,                "postEntry");
00087   xgi::bind(this,&evf::iDie::postEntryiChoke,          "postChoke");
00088   //  gui_->setSmallAppIcon("/evf/images/Hilton.gif");
00089   //  gui_->setLargeAppIcon("/evf/images/Hilton.gif");
00090 
00091   xdata::InfoSpace *ispace = getApplicationInfoSpace();
00092   ispace->fireItemAvailable("parameterSet",         &configString_                );
00093   ispace->fireItemAvailable("runNumber",            &runNumber_                   );
00094   getApplicationInfoSpace()->addItemChangedListener("runNumber",              this);
00095 
00096   // timestamps
00097   lastModuleLegendaMessageTimeStamp_.tv_sec=0;
00098   lastModuleLegendaMessageTimeStamp_.tv_usec=0;
00099   lastPathLegendaMessageTimeStamp_.tv_sec=0;
00100   lastPathLegendaMessageTimeStamp_.tv_usec=0;
00101   runStartDetectedTimeStamp_.tv_sec=0;
00102   runStartDetectedTimeStamp_.tv_usec=0;
00103 }
00104 
00105 
00106 //______________________________________________________________________________
00107 iDie::~iDie()
00108 {
00109 }
00110 
00111 //______________________________________________________________________________
00112 void iDie::actionPerformed(xdata::Event& e)
00113 {
00114   
00115   if (e.type()=="ItemChangedEvent" ) {
00116     std::string item = dynamic_cast<xdata::ItemChangedEvent&>(e).itemName();
00117     
00118     if ( item == "runNumber") {
00119       LOG4CPLUS_WARN(getApplicationLogger(),
00120                      "New Run was started - iDie will reset");
00121       reset();
00122     }
00123     
00124   }
00125 }
00126 
00127 //______________________________________________________________________________
00128 xoap::MessageReference iDie::fsmCallback(xoap::MessageReference msg)
00129   throw (xoap::exception::Exception)
00130 {
00131   
00132   xoap::SOAPPart     part    =msg->getSOAPPart();
00133   xoap::SOAPEnvelope env     =part.getEnvelope();
00134   xoap::SOAPBody     body    =env.getBody();
00135   DOMNode           *node    =body.getDOMNode();
00136   DOMNodeList       *bodyList=node->getChildNodes();
00137   DOMNode           *command =0;
00138   std::string             commandName;
00139   
00140   for (unsigned int i=0;i<bodyList->getLength();i++) {
00141     command = bodyList->item(i);
00142     if(command->getNodeType() == DOMNode::ELEMENT_NODE) {
00143       commandName = xoap::XMLCh2String(command->getLocalName());
00144       break;
00145     }
00146   }
00147   
00148   if (commandName.empty()) {
00149     XCEPT_RAISE(xoap::exception::Exception,"Command not found.");
00150   }
00151   
00152   // fire appropriate event and create according response message
00153   try {
00154 
00155     // response string
00156     xoap::MessageReference reply = xoap::createMessage();
00157     xoap::SOAPEnvelope envelope  = reply->getSOAPPart().getEnvelope();
00158     xoap::SOAPName responseName  = envelope.createName(commandName+"Response",
00159                                                        "xdaq",XDAQ_NS_URI);
00160     xoap::SOAPBodyElement responseElem =
00161       envelope.getBody().addBodyElement(responseName);
00162     
00163     std::string state;
00164     // generate correct return state string
00165     if(commandName == "Configure") state = "Ready";
00166     else if(commandName == "Enable") state = "Enabled";
00167     else if(commandName == "Stop") state = "Ready";
00168     else if(commandName == "Halt") state = "Halted";
00169     else state = "BOH";
00170 
00171     xoap::SOAPName    stateName     = envelope.createName("state",
00172                                                           "xdaq",XDAQ_NS_URI);
00173     xoap::SOAPElement stateElem     = responseElem.addChildElement(stateName);
00174     xoap::SOAPName    attributeName = envelope.createName("stateName",
00175                                                           "xdaq",XDAQ_NS_URI);
00176     stateElem.addAttribute(attributeName,state);
00177     
00178     return reply;
00179   }
00180   catch (toolbox::fsm::exception::Exception & e) {
00181     XCEPT_RETHROW(xoap::exception::Exception,"invalid command.",e);
00182   }     
00183   
00184 
00185 
00186 }
00187 
00188 //______________________________________________________________________________
00189 void iDie::defaultWeb(xgi::Input *in,xgi::Output *out)
00190   throw (xgi::exception::Exception)
00191 {
00192   cgicc::Cgicc cgi(in);
00193   std::string method = cgi.getEnvironment().getRequestMethod();
00194   if(method == "POST"){
00195     unsigned int run = 0;
00196     std::vector<cgicc::FormEntry> el1 = cgi.getElements();
00197     cgi.getElement("run",el1);
00198     if(el1.size()!=0){
00199       run = el1[0].getIntegerValue();
00200       if(run > runNumber_.value_ || runNumber_.value_==0){
00201         runNumber_.value_ = run;
00202         if(runNumber_.value_!=0) 
00203           {
00204             reset();
00205             if(f_ == 0)
00206               {
00207                 std::ostringstream ost;
00208                 ost << "microReport"<<runNumber_<<".root";
00209                 f_ = new TFile(ost.str().c_str(),"RECREATE","microreport");
00210               }
00211           }
00212       }
00213     }
00214     internal::fu fuinstance;
00215 
00216     fuinstance.ccount = 0;
00217     std::string hostname = cgi.getEnvironment().getRemoteHost();
00218     std::transform(hostname.begin(), hostname.end(),
00219                    hostname.begin(), ::toupper);
00220     fus_[hostname] = fuinstance;
00221   }
00222   else{
00223     *out << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" 
00224          << "<html><head><title>" << getApplicationDescriptor()->getClassName()
00225          << getApplicationDescriptor()->getInstance() << "</title>"
00226          << "<meta https-equiv=\"REFRESH\" content=\"0;url=/evf/html/idiePage.html\">"
00227          << "</head></html>";
00228   }
00229 }
00230 
00231 //______________________________________________________________________________
00232 void iDie::updater(xgi::Input *in,xgi::Output *out)
00233   throw (xgi::exception::Exception)
00234 {
00235   *out << runNumber_.value_ << std::endl;
00236 }
00237 //______________________________________________________________________________
00238 void iDie::summaryTable(xgi::Input *in,xgi::Output *out)
00239   throw (xgi::exception::Exception)
00240 {
00241     *out << "<tr><td>"<<fus_.size()<<"</td><td>" << totalCores_ 
00242          << "</td><td></td></tr>" << std::endl;
00243 }
00244 
00245 //______________________________________________________________________________
00246 void iDie::detailsTable(xgi::Input *in,xgi::Output *out)
00247   throw (xgi::exception::Exception)
00248 {
00249   timeval tv;
00250   gettimeofday(&tv,0);
00251   time_t now = tv.tv_sec;
00252   for(ifmap i = fus_.begin(); i != fus_.end(); i++)
00253     if((*i).second.ccount != 0){
00254       *out << "<tr><td " 
00255            << (now-(*i).second.tstamp<300 ? "style=\"background-color:red\"" : "")
00256            << ">"<<(*i).first<<"</td><td>" 
00257            << (*i).second.ccount << "</td>"
00258            << "<td onClick=loaddump(\'" << url_.value_ << "/dump?name="
00259            << (*i).first << "\')>" << (*i).second.cpids.back()
00260            << "</td><td>" <<(*i).second.signals.back() 
00261            << "</td></tr>" << std::endl;
00262     }
00263 }
00264 
00265 //______________________________________________________________________________
00266 void iDie::dumpTable(xgi::Input *in,xgi::Output *out)
00267   throw (xgi::exception::Exception)
00268 {
00269   cgicc::Cgicc cgi(in); 
00270 
00271   std::vector<cgicc::FormEntry> el1;
00272   cgi.getElement("name",el1);
00273   if(el1.size()!=0){
00274     std::string hostname = el1[0].getValue();
00275     std::transform(hostname.begin(), hostname.end(),
00276                    hostname.begin(), ::toupper);
00277     ifmap fi = fus_.find(hostname);    
00278     if(fi!=fus_.end()){
00279       *out << (*fi).second.stacktraces.back() << std::endl;
00280     }
00281     else{ 
00282       for(fi=fus_.begin(); fi != fus_.end(); fi++) 
00283         std::cout << "known hosts: " << (*fi).first << std::endl;
00284     }
00285   }
00286 }
00287 
00288 //______________________________________________________________________________
00289 void iDie::iChokeMiniInterface(xgi::Input *in,xgi::Output *out)
00290   throw (xgi::exception::Exception)
00291 {
00292   unsigned int i = 0;
00293 
00294   if(last_ls_==0) return; //wait until at least one complete cycle so we have all arrays sized correctly !!!
00295   *out << "<div id=\"cls\">" << last_ls_ << "</div>" 
00296        << "<div id=\"clr\">" << cpuentries_[last_ls_-1] << "</div>" << std::endl;
00297   sorted_indices tmp(cpustat_[last_ls_-1]);
00298   //  std::sort(tmp.begin(),tmp.end());// figure out how to remap indices of legenda
00299   *out << "<tbody id=\"cpue\">";
00300   while(i<nstates_){
00301     if(tmp[i]!=0) *out << "<tr><td>" << mapmod_[tmp.ii(i)] << "</td>" << "<td>" 
00302                        << float(tmp[i])/float(cpuentries_[last_ls_-1]) << "</td></tr>";
00303     i++;
00304   }
00305   *out << "</tbody>\n";
00306   *out << "<tbody id=\"cpui\"><tr><td></td>";
00307   unsigned int begin = last_ls_<5 ? 0 : last_ls_-5;
00308   for(i=begin; i < last_ls_; i++)
00309     *out << "<td>" << i +1 << "</td>";
00310   *out << "</tr><tr><td></td>";
00311   for(i=begin; i < last_ls_; i++)
00312     *out << "<td>" << float(cpustat_[i][2])/float(cpuentries_[i]) << "</td>";
00313   *out << "</tr></tbody>\n";
00314 
00315   *out << "<tbody id=\"rate\"><tr><td></td>";
00316   begin = last_ls_<5 ? 0 : last_ls_-5;
00317   for(i=begin; i < last_ls_; i++)
00318     *out << "<td>" << float(trp_[i].eventSummary.totalEventsPassed)/float(trp_[i].eventSummary.totalEvents) << "</td>"; 
00319   *out << "</tr>\n<tr><td></td>";
00320   for(i=begin; i < last_ls_; i++)
00321     *out << "<td>" << trp_[i].eventSummary.totalEvents << "</td>"; 
00322   *out << "</tr>\n<tr><td></td>";
00323   for(int j = 0; j < trp_[0].trigPathsInMenu; j++)
00324     {
00325       *out << "<tr><td></td>";
00326       for(i=begin; i < last_ls_; i++)
00327         *out << "<td>" << trp_[i].trigPathSummaries[j].timesPassed << "("
00328              << trp_[i].trigPathSummaries[j].timesPassedL1 << ")("
00329              << trp_[i].trigPathSummaries[j].timesPassedPs << ")</td>";
00330       *out << "<td>" << mappath_[j] << "</td>";
00331       *out << "</tr>\n";
00332     }
00333   for(int j = 0; j < trp_[0].endPathsInMenu; j++)
00334     {
00335       *out << "<tr><td></td>";
00336       for(i=begin; i < last_ls_; i++)
00337         *out << "<td>" << trp_[i].endPathSummaries[j].timesPassed << "</td>";
00338       *out << "<td>" << mappath_[j+trp_[last_ls_-1].trigPathsInMenu] << "</td>";
00339       *out << "</tr>\n";
00340     }
00341   *out << "</tbody>\n";
00342 }
00343 
00344 //______________________________________________________________________________
00345 void iDie::iChoke(xgi::Input *in,xgi::Output *out)
00346   throw (xgi::exception::Exception)
00347 {
00348     *out << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" 
00349          << "<html><head><title>" << getApplicationDescriptor()->getClassName()
00350          << getApplicationDescriptor()->getInstance() << "</title>"
00351          << "<meta https-equiv=\"REFRESH\" content=\"0;url=/evf/html/ichokePage.html\">"
00352          << "</head></html>";
00353 
00354 
00355 
00356 }
00357 
00358 //______________________________________________________________________________
00359 void iDie::postEntry(xgi::Input*in,xgi::Output*out)
00360   throw (xgi::exception::Exception)
00361 {
00362   timeval tv;
00363   gettimeofday(&tv,0);
00364   time_t now = tv.tv_sec;
00365   cgicc::Cgicc cgi(in); 
00366   unsigned int run = 0;
00367   pid_t cpid = 0;
00368   /*  cgicc::CgiEnvironment cgie(in);
00369   cout << "query = "  << cgie.getContentLength() << endl;
00370   */
00371   std::vector<cgicc::FormEntry> el1;
00372   el1 = cgi.getElements();
00373 //   for(unsigned int i = 0; i < el1.size(); i++)
00374 //     std::cout << "name="<<el1[i].getName() << std::endl;
00375   el1.clear();
00376   cgi.getElement("run",el1);
00377   if(el1.size()!=0)
00378     {
00379       run =  el1[0].getIntegerValue();
00380     }
00381   el1.clear();
00382   cgi.getElement("stacktrace",el1);
00383   if(el1.size()!=0)
00384     {
00385       cpid = run;
00386       //      std::cout << "=============== stacktrace =============" << std::endl;
00387       //      std::cout << el1[0].getValue() << std::endl;
00388       if(el1[0].getValue().find("Dead")==0){
00389 
00390         std::string host = cgi.getEnvironment().getRemoteHost();
00391         std::transform(host.begin(), host.end(),
00392                        host.begin(), ::toupper);
00393         ifmap fi = fus_.find(host);
00394         if(fi!=fus_.end()){
00395           fus_.erase(fi);
00396         }
00397         if(fus_.size()==0) //close the root file if we know the run is over 
00398           if(f_!=0){
00399             f_->cd();
00400             f_->Write();
00401             f_->Close();
00402             t_ = 0;
00403             delete f_; f_ = 0;
00404           }
00405       }
00406       else{
00407         totalCores_++;
00408         std::string st = el1[0].getValue();
00409         std::string sig; 
00410         size_t psig = st.find("signal");
00411         if(psig != std::string::npos)
00412           sig = st.substr(psig,9);
00413         std::string host = cgi.getEnvironment().getRemoteHost();
00414         std::transform(host.begin(), host.end(),
00415                        host.begin(), ::toupper);
00416         ifmap fi = fus_.find(host);
00417         if(fi!=fus_.end()){
00418           (*fi).second.tstamp = now;
00419           (*fi).second.ccount++;
00420           (*fi).second.cpids.push_back(cpid);
00421           (*fi).second.signals.push_back(sig);
00422           (*fi).second.stacktraces.push_back(st);
00423         }
00424       }
00425     }
00426   el1.clear();
00427   cgi.getElement("legenda",el1);
00428   if(el1.size()!=0)
00429     {
00430       parsePathLegenda(el1[0].getValue());
00431     }
00432   cgi.getElement("trp",el1);
00433   if(el1.size()!=0)
00434     {
00435       unsigned int lsid = run;
00436       parsePathHisto((unsigned char*)(el1[0].getValue().c_str()),lsid);
00437     }
00438   el1.clear();
00439 
00440 
00441 }
00442 
00443 //______________________________________________________________________________
00444 void iDie::postEntryiChoke(xgi::Input*in,xgi::Output*out)
00445   throw (xgi::exception::Exception)
00446 {
00447   //  std::cout << "postEntryiChoke " << std::endl;
00448   unsigned int lsid = 0;
00449   cgicc::Cgicc cgi(in); 
00450   /*  cgicc::CgiEnvironment cgie(in);
00451   cout << "query = "  << cgie.getContentLength() << endl;
00452   */
00453   std::vector<cgicc::FormEntry> el1;
00454   el1 = cgi.getElements();
00455 //   for(unsigned int i = 0; i < el1.size(); i++)
00456 //     std::cout << "name="<<el1[i].getName() << std::endl;
00457   el1.clear();
00458   cgi.getElement("run",el1);
00459   if(el1.size()!=0)
00460     {
00461       lsid =  el1[0].getIntegerValue();
00462     }
00463   el1.clear();
00464 
00465   //with the first message for the new lsid, resize all containers so 
00466   // a web access won't address an invalid location in case it interleaves between 
00467   // the first cpustat update and the first scalers update or viceversa
00468   if(lsid!=0){
00469     if(lsid>cpustat_.size()){
00470       cpustat_.resize(lsid,std::vector<int>(nstates_,0));
00471       cpuentries_.resize(lsid,0);
00472     }
00473     if(lsid>trp_.size()){
00474       trp_.resize(lsid);
00475       funcs::reset(&trp_[lsid-1]);
00476       trpentries_.resize(lsid,0);
00477     }
00478     if(last_ls_ < lsid) {
00479       last_ls_ = lsid; 
00480       funcs::reset(&trp_[lsid-1]);
00481       if(t_ && (last_ls_%10==0)) t_->Write();
00482     } 
00483   }
00484 
00485   cgi.getElement("legenda",el1);
00486   if(el1.size()!=0)
00487     {
00488       parseModuleLegenda(el1[0].getValue());
00489     }
00490   cgi.getElement("trp",el1);
00491   if(el1.size()!=0)
00492     {
00493       parseModuleHisto(el1[0].getValue().c_str(),lsid);
00494     }
00495   el1.clear();
00496 }
00497 
00498 
00499 void iDie::reset()
00500 {
00501   fus_.erase(fus_.begin(),fus_.end());
00502   totalCores_=0;
00503   last_ls_ = 0;
00504   trp_.clear();
00505   trpentries_.clear();
00506   cpustat_.clear();
00507   cpuentries_.clear();
00508   if(f_!=0){
00509     f_->cd();
00510     f_->Write();
00511     f_->Close();
00512     delete f_; f_ = 0;
00513   }
00514   if(t_ != 0)
00515     {delete t_; t_=0;}
00516   if(datap_ != 0)
00517     {delete datap_; datap_ = 0;}
00518   b_=0; b1_=0; b2_=0; b3_=0; b4_=0;
00519 
00520 }
00521 
00522 void iDie::parseModuleLegenda(std::string leg)
00523 {
00524   nModuleLegendaMessageReceived_++;
00525   if(leg=="") return;
00526   gettimeofday(&lastModuleLegendaMessageTimeStamp_,0);
00527   nModuleLegendaMessageWithDataReceived_++;
00528   mapmod_.clear();
00529   //  if(cpustat_) delete cpustat_;
00530   boost::char_separator<char> sep(",");
00531   boost::tokenizer<boost::char_separator<char> > tokens(leg, sep);
00532   for (boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = tokens.begin();
00533        tok_iter != tokens.end(); ++tok_iter){
00534     mapmod_.push_back((*tok_iter));
00535   }
00536   nstates_ = mapmod_.size();
00537   //  cpustat_ = new int[nstates_];
00538 //   for(int i = 0; i < nstates_; i++)
00539 //     cpustat_[i]=0;   
00540 //   cpuentries_ = 0;
00541 }
00542 
00543 void iDie::parseModuleHisto(const char *crp, unsigned int lsid)
00544 {
00545   if(lsid==0) return;
00546   nModuleHistoMessageReceived_++;
00547   int *trp = (int*)crp;
00548   if(t_==0 && f_!=0){
00549     datap_ = new int[nstates_+3];
00550     std::ostringstream ost;
00551     ost<<mapmod_[0]<<"/I";
00552     for(unsigned int i = 1; i < nstates_; i++)
00553       ost<<":"<<mapmod_[i];
00554     ost<<":nsubp:instance:nproc";
00555     f_->cd();
00556     t_ = new TTree("microReport","microstate report tree");
00557     t_->SetAutoSave(500000);
00558     b_ = t_->Branch("microstates",datap_,ost.str().c_str());
00559     b1_ = t_->Branch("ls",&lsid,"ls/I");
00560   }
00561   memcpy(datap_,trp,(nstates_+3)*sizeof(int));
00562   if(t_!=0){
00563     t_->SetEntries(t_->GetEntries()+1); b_->Fill(); b1_->Fill();
00564   }
00565 
00566   for(unsigned int i=0;i<nstates_; i++)
00567     {
00568       cpustat_[lsid-1][i] += trp[i];
00569       cpuentries_[lsid-1] += trp[i];
00570     }
00571 }
00572 
00573 
00574 void iDie::parsePathLegenda(std::string leg)
00575 {
00576   nPathLegendaMessageReceived_++;
00577   if(leg=="")return;
00578   gettimeofday(&lastPathLegendaMessageTimeStamp_,0);
00579   nPathLegendaMessageWithDataReceived_++;
00580   mappath_.clear();
00581   boost::char_separator<char> sep(",");
00582   boost::tokenizer<boost::char_separator<char> > tokens(leg, sep);
00583   for (boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = tokens.begin();
00584        tok_iter != tokens.end(); ++tok_iter){
00585       mappath_.push_back((*tok_iter));
00586   }
00587 }
00588 
00589 void iDie::parsePathHisto(const unsigned char *crp, unsigned int lsid)
00590 {
00591   if(lsid==0) return;
00592   nPathHistoMessageReceived_++;
00593 //   if(lsid>=trp_.size()){
00594 //     trp_.resize(lsid);
00595 //     funcs::reset(&trp_[lsid-1]);
00596 //     trpentries_.resize(lsid,0);
00597 //   }
00598   trppriv_ = (TriggerReportStatic*)crp;
00599   for( int i=0; i< trppriv_->trigPathsInMenu; i++)
00600     {
00601       r_.ptimesRun[i] = trppriv_->trigPathSummaries[i].timesRun;
00602       r_.ptimesPassedPs[i] = trppriv_->trigPathSummaries[i].timesPassedPs;
00603       r_.ptimesPassedL1[i] = trppriv_->trigPathSummaries[i].timesPassedL1;
00604       r_.ptimesPassed[i] = trppriv_->trigPathSummaries[i].timesPassed;
00605       r_.ptimesFailed[i] = trppriv_->trigPathSummaries[i].timesFailed;
00606       r_.ptimesExcept[i] = trppriv_->trigPathSummaries[i].timesExcept;
00607     }
00608   for( int i=0; i< trppriv_->endPathsInMenu; i++)
00609     {
00610       r_.etimesRun[i] = trppriv_->endPathSummaries[i].timesRun;
00611       r_.etimesPassedPs[i] = trppriv_->endPathSummaries[i].timesPassedPs;
00612       r_.etimesPassedL1[i] = trppriv_->endPathSummaries[i].timesPassedL1;
00613       r_.etimesPassed[i] = trppriv_->endPathSummaries[i].timesPassed;
00614       r_.etimesFailed[i] = trppriv_->endPathSummaries[i].timesFailed;
00615       r_.etimesExcept[i] = trppriv_->endPathSummaries[i].timesExcept;
00616     }
00617   r_.nproc = trppriv_->eventSummary.totalEvents;
00618   r_.nsub = trppriv_->nbExpected;
00619   r_.nrep = trppriv_->nbReporting;
00620 
00621   if(t_!=0 && f_!=0 && b2_==0){
00622 
00623     b2_ = t_->Branch("rate",&r_,"nproc/I:nsub:nrep");
00624     std::ostringstream ost1;
00625     ost1 << "p_nrun[" << trppriv_->trigPathsInMenu
00626          << "]/I:p_npps[" << trppriv_->trigPathsInMenu
00627          << "]:p_npl1[" << trppriv_->trigPathsInMenu
00628          << "]:p_npp[" << trppriv_->trigPathsInMenu 
00629          << "]:p_npf[" << trppriv_->trigPathsInMenu
00630          << "]:p_npe[" << trppriv_->trigPathsInMenu <<"]";
00631 
00632     b3_ = t_->Branch("paths",r_.ptimesRun,ost1.str().c_str());
00633     std::ostringstream ost2;
00634     ost2 << "ep_nrun[" << trppriv_->endPathsInMenu
00635          << "]/I:en_npps[" << trppriv_->endPathsInMenu
00636          << "]:ep_npl1[" << trppriv_->endPathsInMenu
00637          << "]:ep_npp[" << trppriv_->endPathsInMenu
00638          << "]:ep_npf[" << trppriv_->endPathsInMenu
00639          << "]:ep_npe[" << trppriv_->endPathsInMenu << "]";
00640     b4_ = t_->Branch("endpaths",r_.etimesRun,ost2.str().c_str());
00641   }
00642   if(b2_!=0) b2_->Fill();
00643   if(b3_!=0) b3_->Fill();
00644   if(b4_!=0) b4_->Fill();
00645 
00646   funcs::addToReport(&trp_[lsid-1],trppriv_,lsid);
00647   trpentries_[lsid-1]++;
00648 }
00649 
00650 // web pages
00651 
00652 void iDie::spotlight(xgi::Input *in,xgi::Output *out)
00653   throw (xgi::exception::Exception)
00654 {
00655 
00656   std::string urn = getApplicationDescriptor()->getURN();
00657 
00658   *out << "<!-- base href=\"/" <<  urn
00659        << "\"> -->" << std::endl;
00660   *out << "<html>"                                                   << std::endl;
00661   *out << "<head>"                                                   << std::endl;
00662   *out << "<link type=\"text/css\" rel=\"stylesheet\"";
00663   *out << " href=\"/evf/html/styles.css\"/>"                   << std::endl;
00664   *out << "<title>" << getApplicationDescriptor()->getClassName() 
00665        << getApplicationDescriptor()->getInstance() 
00666        << " MAIN</title>"     << std::endl;
00667   *out << "</head>"                                                  << std::endl;
00668   *out << "<body>"                                                   << std::endl;
00669   *out << "<table border=\"0\" width=\"100%\">"                      << std::endl;
00670   *out << "<tr>"                                                     << std::endl;
00671   *out << "  <td align=\"left\">"                                    << std::endl;
00672   *out << "    <img"                                                 << std::endl;
00673   *out << "     align=\"middle\""                                    << std::endl;
00674   *out << "     src=\"/evf/images/spoticon.jpg\""                            << std::endl;
00675   *out << "     alt=\"main\""                                        << std::endl;
00676   *out << "     width=\"64\""                                        << std::endl;
00677   *out << "     height=\"64\""                                       << std::endl;
00678   *out << "     border=\"\"/>"                                       << std::endl;
00679   *out << "    <b>"                                                  << std::endl;
00680   *out << getApplicationDescriptor()->getClassName() 
00681        << getApplicationDescriptor()->getInstance()                  << std::endl;
00682   *out << "    </b>"                                                 << std::endl;
00683   *out << "  </td>"                                                  << std::endl;
00684   *out << "  <td width=\"32\">"                                      << std::endl;
00685   *out << "    <a href=\"/urn:xdaq-application:lid=3\">"             << std::endl;
00686   *out << "      <img"                                               << std::endl;
00687   *out << "       align=\"middle\""                                  << std::endl;
00688   *out << "       src=\"/hyperdaq/images/HyperDAQ.jpg\""             << std::endl;
00689   *out << "       alt=\"HyperDAQ\""                                  << std::endl;
00690   *out << "       width=\"32\""                                      << std::endl;
00691   *out << "       height=\"32\""                                     << std::endl;
00692   *out << "       border=\"\"/>"                                     << std::endl;
00693   *out << "    </a>"                                                 << std::endl;
00694   *out << "  </td>"                                                  << std::endl;
00695   *out << "  <td width=\"32\">"                                      << std::endl;
00696   *out << "  </td>"                                                  << std::endl;
00697   *out << "  <td width=\"32\">"                                      << std::endl;
00698   *out << "    <a href=\"/" << urn << "/\">"                         << std::endl;
00699   *out << "      <img"                                               << std::endl;
00700   *out << "       align=\"middle\""                                  << std::endl;
00701   *out << "       src=\"/evf/images/idieapp.jpg\""                   << std::endl;
00702   *out << "       alt=\"main\""                                      << std::endl;
00703   *out << "       width=\"32\""                                      << std::endl;
00704   *out << "       height=\"32\""                                     << std::endl;
00705   *out << "       border=\"\"/>"                                     << std::endl;
00706   *out << "    </a>"                                                 << std::endl;
00707   *out << "  </td>"                                                  << std::endl;
00708   *out << "</tr>"                                                    << std::endl;
00709   *out << "</table>"                                                 << std::endl;
00710   *out << "<hr/>"                                                    << std::endl;
00711   *out << "<table><tr><th>Parameter</th><th>Value</th></tr>"         << std::endl;
00712   *out << "<tr><td>module legenda messages received</td><td>" 
00713        << nModuleLegendaMessageReceived_ << "</td></tr>"      << std::endl;
00714   *out << "<tr><td>path legenda messages received</td><td>" 
00715        << nPathLegendaMessageReceived_ << "</td></tr>"        << std::endl;
00716   *out << "<tr><td>module legenda messages with data</td><td>" 
00717        << nModuleLegendaMessageWithDataReceived_ << "</td></tr>"      << std::endl;
00718   *out << "<tr><td>path legenda messages with data</td><td>" 
00719        << nPathLegendaMessageWithDataReceived_ << "</td></tr>"        << std::endl;
00720   *out << "<tr><td>module histo messages received</td><td>" 
00721        << nModuleHistoMessageReceived_<< "</td></tr>"        << std::endl;
00722   *out << "<tr><td>path histo messages received</td><td>" 
00723        << nPathHistoMessageReceived_<< "</td></tr>"        << std::endl;
00724   tm *uptm = localtime(&lastPathLegendaMessageTimeStamp_.tv_sec);
00725   char datestring[256];
00726   strftime(datestring, sizeof(datestring),"%c", uptm);
00727   *out << "<tr><td>time stamp of last path legenda with data</td><td>" 
00728        << datestring << "</td></tr>"        << std::endl;
00729   uptm = localtime(&lastModuleLegendaMessageTimeStamp_.tv_sec);
00730   strftime(datestring, sizeof(datestring),"%c", uptm);
00731   *out << "<tr><td>time stamp of last module legenda with data</td><td>" 
00732        << datestring << "</td></tr>"        << std::endl;
00733   *out << "</table></body>" << std::endl;
00734 
00735 }
00736 
00737 
00739 // xdaq instantiator implementation macro
00741 
00742 XDAQ_INSTANTIATOR_IMPL(iDie)