CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/EventFilter/Utilities/src/Stepper.cc

Go to the documentation of this file.
00001 
00002 
00003 #include "EventFilter/Utilities/interface/Stepper.h"
00004 
00005 #include "xgi/Input.h"
00006 #include "xgi/Output.h"
00007 #include "xgi/Utils.h"
00008 
00009 #include "cgicc/Cgicc.h"
00010 #include "cgicc/FormEntry.h"
00011 #include "cgicc/HTMLClasses.h"
00012 
00013 #include <iostream>
00014 
00015 #include <string>
00016 
00017 
00018 namespace evf{
00019 
00020   Stepper::Stepper(const edm::ParameterSet& iPS, 
00021                    edm::ActivityRegistry& reg) : ServiceWeb("Stepper"), rid_(0), eid_(0), step_(false)
00022   {
00023   
00024     reg.watchPostBeginJob(this,&Stepper::postBeginJob);
00025     reg.watchPostEndJob(this,&Stepper::postEndJob);
00026   
00027     reg.watchPreProcessEvent(this,&Stepper::preEventProcessing);
00028     reg.watchPostProcessEvent(this,&Stepper::postEventProcessing);
00029     reg.watchPreSource(this,&Stepper::preSource);
00030     reg.watchPostSource(this,&Stepper::postSource);
00031   
00032     reg.watchPreModule(this,&Stepper::preModule);
00033     reg.watchPostModule(this,&Stepper::postModule);
00034     epstate_ = "BJ";
00035     modulename_ = "NOT YET";
00036     modulelabel_ = "INIT";
00037     pthread_mutex_init(&mutex_,0);
00038     pthread_cond_init(&cond_,0);
00039   }
00040 
00041 
00042   Stepper::~Stepper()
00043   {
00044   }
00045 
00046   void Stepper::postBeginJob()
00047   {
00048     //    wait_on_signal();
00049     epstate_ = "BJD";
00050   }
00051 
00052   void Stepper::postEndJob()
00053   {
00054     wait_on_signal();
00055     epstate_ = "EJ";
00056     modulelabel_ = "done";
00057   }
00058 
00059   void Stepper::preEventProcessing(const edm::EventID& iID,
00060                                              const edm::Timestamp& iTime)
00061   {
00062     rid_ = iID.run();
00063     eid_ = iID.event();
00064     wait_on_signal();
00065     epstate_ = "PRO";
00066   }
00067 
00068   void Stepper::postEventProcessing(const edm::Event& e, const edm::EventSetup&)
00069   {
00070   }
00071   void Stepper::preSource()
00072   {
00073     wait_on_signal();
00074     modulename_ = "source";
00075     modulelabel_ = "IN";
00076   }
00077 
00078   void Stepper::postSource()
00079   {
00080     wait_on_signal();
00081     modulelabel_ = "IND";
00082   }
00083 
00084   void Stepper::preModule(const edm::ModuleDescription& desc)
00085   {
00086     wait_on_signal();
00087     modulename_ = desc.moduleName();
00088     modulelabel_ = desc.moduleLabel();
00089   }
00090 
00091   void Stepper::postModule(const edm::ModuleDescription& desc)
00092   {
00093   }
00094   
00095   void Stepper::defaultWebPage(xgi::Input *in, xgi::Output *out)
00096   {
00097 
00098     std::string path;
00099     std::string urn;
00100     std::string mname;
00101     try 
00102       {
00103         cgicc::Cgicc cgi(in);
00104         if ( xgi::Utils::hasFormElement(cgi,"service") )
00105           mname = xgi::Utils::getFormElement(cgi, "service")->getValue();
00106         if ( xgi::Utils::hasFormElement(cgi,"step") )
00107           {
00108             pthread_mutex_lock(&mutex_);
00109             
00110             pthread_cond_signal(&cond_);
00111             
00112             pthread_mutex_unlock(&mutex_);
00113           }
00114         cgicc::CgiEnvironment cgie(in);
00115         if(original_referrer_ == "")
00116           original_referrer_ = cgie.getReferrer();
00117         path = cgie.getPathInfo() + "?" + cgie.getQueryString();
00118         
00119       }
00120       catch (const std::exception & e) 
00121         {
00122           // don't care if it did not work
00123         }
00124       
00125       
00126       using std::endl;
00127       *out << "<html>"                                                   << endl;
00128       *out << "<head>"                                                   << endl;
00129 
00130 
00131       *out << "<STYLE type=\"text/css\"> #T1 {border-width: 2px; border: solid blue; text-align: center} </STYLE> "                                      << endl; 
00132       *out << "<link type=\"text/css\" rel=\"stylesheet\"";
00133       *out << " href=\"/" <<  urn
00134            << "/styles.css\"/>"                   << endl;
00135 
00136       *out << "<title>" << serviceName_
00137            << " MAIN</title>"                                            << endl;
00138 
00139       *out << "</head>"                                                  << endl;
00140       *out << "<body onload=\"loadXMLDoc()\">"                           << endl;
00141       *out << "<table border=\"0\" width=\"100%\">"                      << endl;
00142       *out << "<tr>"                                                     << endl;
00143       *out << "  <td align=\"left\">"                                    << endl;
00144       *out << "    <img"                                                 << endl;
00145       *out << "     align=\"middle\""                                    << endl;
00146       *out << "     src=\"/evf/images/stepper.jpg\""                     << endl;
00147       *out << "     alt=\"main\""                                        << endl;
00148       *out << "     width=\"90\""                                        << endl;
00149       *out << "     height=\"64\""                                       << endl;
00150       *out << "     border=\"\"/>"                                       << endl;
00151       *out << "    <b>"                                                  << endl;
00152       *out <<             serviceName_                                   << endl;
00153       *out << "    </b>"                                                 << endl;
00154       *out << "  </td>"                                                  << endl;
00155       *out << "  <td width=\"32\">"                                      << endl;
00156       *out << "    <a href=\"/urn:xdaq-application:lid=3\">"             << endl;
00157       *out << "      <img"                                               << endl;
00158       *out << "       align=\"middle\""                                  << endl;
00159       *out << "       src=\"/hyperdaq/images/HyperDAQ.jpg\""             << endl;
00160       *out << "       alt=\"HyperDAQ\""                                  << endl;
00161       *out << "       width=\"32\""                                      << endl;
00162       *out << "       height=\"32\""                                     << endl;
00163       *out << "       border=\"\"/>"                                     << endl;
00164       *out << "    </a>"                                                 << endl;
00165       *out << "  </td>"                                                  << endl;
00166       *out << "  <td width=\"32\">"                                      << endl;
00167       *out << "  </td>"                                                  << endl;
00168       *out << "  <td width=\"32\">"                                      << endl;
00169       *out << "    <a href=\"" << original_referrer_  << "\">"           << endl;
00170       *out << "      <img"                                               << endl;
00171       *out << "       align=\"middle\""                                  << endl;
00172       *out << "       src=\"/evf/images/epicon.jpg\""                    << endl;
00173       *out << "       alt=\"main\""                                      << endl;
00174       *out << "       width=\"32\""                                      << endl;
00175       *out << "       height=\"32\""                                     << endl;
00176       *out << "       border=\"\"/>"                                     << endl;
00177       *out << "    </a>"                                                 << endl;
00178       *out << "  </td>"                                                  << endl;
00179       *out << "</tr>"                                                    << endl;
00180       *out << "</table>"                                                 << endl;
00181 
00182       *out << "<hr/>"                                                    << endl;
00183       
00184       *out << "run number        " << rid_ << "<br>" << endl;
00185       *out << "event number      " << eid_ << "<br>" << endl;
00186 
00187       *out << "event processor   " << epstate_ << "<br>" << endl;
00188 
00189       *out << "next module type  " << modulename_ << "<br>" << endl;
00190       *out << "next module label " << modulelabel_ << "<br>" << endl;
00191 
00192       *out << "<hr/>"                                                    << endl;
00193   
00194       *out << cgicc::form().set("method","GET").set("action", path ) 
00195            << std::endl;
00196       *out << cgicc::input().set("type","hidden").set("name","service").set("value", mname) 
00197            << std::endl;
00198       *out << cgicc::input().set("type","hidden").set("name","step").set("value", "yes") 
00199            << std::endl;
00200       *out << cgicc::input().set("type","submit").set("value","Step")      << std::endl;
00201       *out << cgicc::form()                                                << std::endl;  
00202 
00203       *out << "</body>"                                                  << endl;
00204       *out << "</html>"                                                  << endl;
00205   }
00206 } //end namespace evf
00207