CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #ifndef EVENTFILTER_GOODIES_IDIE_H
00002 #define EVENTFILTER_GOODIES_IDIE_H
00003 
00004 #include "EventFilter/Utilities/interface/Exception.h"
00005 #include "EventFilter/Utilities/interface/TriggerReportDef.h"
00006 
00007 #include "xdata/String.h"
00008 #include "xdata/UnsignedInteger32.h"
00009 #include "xdata/ActionListener.h"
00010 
00011 #include "xoap/MessageReference.h"
00012 #include "xoap/MessageFactory.h"
00013 #include "xoap/Method.h"
00014 
00015 #include "xgi/Utils.h"
00016 #include "xgi/Input.h"
00017 #include "xgi/Output.h"
00018 #include "xgi/Method.h"
00019 
00020 #include "xdaq/Application.h"
00021 
00022 #include "toolbox/net/URN.h"
00023 #include "toolbox/fsm/exception/Exception.h"
00024 
00025 
00026 #include <vector>
00027 
00028 #include <sys/time.h>
00029 
00030 #include "TFile.h"
00031 #include "TTree.h"
00032 
00033 
00034 namespace evf {
00035 
00036 
00037   namespace internal{
00038    struct fu{
00039       time_t tstamp;
00040       unsigned int ccount;
00041       std::vector<pid_t> cpids;
00042       std::vector<std::string> signals;
00043       std::vector<std::string> stacktraces;
00044     };
00045    struct rate{
00046      int nproc;
00047      int nsub;
00048      int nrep;
00049      int npath;
00050      int nendpath;
00051      int ptimesRun[evf::max_paths];
00052      int ptimesPassedPs[evf::max_paths];
00053      int ptimesPassedL1[evf::max_paths];
00054      int ptimesPassed[evf::max_paths];
00055      int ptimesFailed[evf::max_paths];
00056      int ptimesExcept[evf::max_paths];
00057      int etimesRun[evf::max_endpaths];
00058      int etimesPassedPs[evf::max_endpaths];
00059      int etimesPassedL1[evf::max_endpaths];
00060      int etimesPassed[evf::max_endpaths];
00061      int etimesFailed[evf::max_endpaths];
00062      int etimesExcept[evf::max_endpaths];
00063    };
00064   }
00065   typedef std::map<std::string,internal::fu> fmap;
00066   typedef fmap::iterator ifmap;
00067   
00068   class iDie : public xdaq::Application,
00069     public xdata::ActionListener
00070   {
00071   public:
00072     //
00073     // xdaq instantiator macro
00074     //
00075     XDAQ_INSTANTIATOR();
00076   
00077     
00078     //
00079     // construction/destruction
00080     //
00081     iDie(xdaq::ApplicationStub *s);
00082     virtual ~iDie();
00083     //UI
00084     void defaultWeb(xgi::Input *in,xgi::Output *out)
00085       throw (xgi::exception::Exception);
00086     void summaryTable(xgi::Input *in,xgi::Output *out)
00087       throw (xgi::exception::Exception);
00088     void detailsTable(xgi::Input *in,xgi::Output *out)
00089       throw (xgi::exception::Exception);
00090     void dumpTable(xgi::Input *in,xgi::Output *out)
00091       throw (xgi::exception::Exception);
00092     void updater(xgi::Input *in,xgi::Output *out)
00093       throw (xgi::exception::Exception);
00094     void iChoke(xgi::Input *in,xgi::Output *out)
00095       throw (xgi::exception::Exception);
00096     void iChokeMiniInterface(xgi::Input *in,xgi::Output *out)
00097       throw (xgi::exception::Exception);
00098     void spotlight(xgi::Input *in,xgi::Output *out)
00099       throw (xgi::exception::Exception);
00100     //AI
00101     void postEntry(xgi::Input*in,xgi::Output*out)
00102       throw (xgi::exception::Exception);
00103     void postEntryiChoke(xgi::Input*in,xgi::Output*out)
00104       throw (xgi::exception::Exception);
00105     
00106     // *fake* fsm soap command callback
00107     xoap::MessageReference fsmCallback(xoap::MessageReference msg)
00108       throw (xoap::exception::Exception);
00109 
00110     // xdata:ActionListener interface
00111     void actionPerformed(xdata::Event& e);
00112 
00113 
00114   private:
00115 
00116     struct sorted_indices{
00117       sorted_indices(const std::vector<int> &arr) : arr_(arr)
00118       {
00119         ind_.resize(arr_.size(),0);
00120         unsigned int i = 0;
00121         while(i<ind_.size()) {ind_[i] = i; i++;}
00122         std::sort(ind_.rbegin(),ind_.rend(),*this);
00123       }
00124       int operator[](size_t ind) const {return arr_[ind_[ind]];}
00125       
00126       bool operator()(const size_t a, const size_t b) const
00127       {
00128         return arr_[a]<arr_[b];
00129       }
00130       int ii(size_t ind){return ind_[ind];}
00131       std::vector<int> ind_;
00132       const std::vector<int> &arr_;
00133     };
00134     //
00135     // private member functions
00136     //
00137     
00138     void reset();
00139     void parseModuleLegenda(std::string);
00140     void parseModuleHisto(const char *, unsigned int);
00141     void parsePathLegenda(std::string);
00142     void parsePathHisto(const unsigned char *, unsigned int);
00143     //
00144     // member data
00145     //
00146 
00147     // message logger
00148     Logger                          log_;
00149                 
00150     // monitored parameters
00151     xdata::String                   url_;
00152     xdata::String                   class_;
00153     xdata::UnsignedInteger32        instance_;
00154     xdata::String                   hostname_;
00155     xdata::UnsignedInteger32        runNumber_;
00156     xdata::String                   configString_;
00157     fmap                            fus_;
00158     
00159     unsigned int                    totalCores_;
00160     unsigned int                    nstates_;   
00161     std::vector<int>                cpuentries_;
00162     std::vector<std::vector<int> >  cpustat_;
00163     std::vector<std::string>        mapmod_;
00164     unsigned int                    last_ls_;
00165     std::vector<TriggerReportStatic>trp_;
00166     std::vector<int>                trpentries_;
00167     std::vector<std::string>        mappath_;
00168     //root stuff
00169     TFile                          *f_;
00170     TTree                          *t_;
00171     TBranch                        *b_;
00172     TBranch                        *b1_;
00173     TBranch                        *b2_;
00174     TBranch                        *b3_;
00175     TBranch                        *b4_;
00176     int                            *datap_;
00177     TriggerReportStatic            *trppriv_;
00178     internal::rate                  r_;
00179 
00180     //message statistics 
00181     int                             nModuleLegendaMessageReceived_;
00182     int                             nPathLegendaMessageReceived_;
00183     int                             nModuleLegendaMessageWithDataReceived_;
00184     int                             nPathLegendaMessageWithDataReceived_;
00185     int                             nModuleHistoMessageReceived_;
00186     int                             nPathHistoMessageReceived_;
00187     timeval                         runStartDetectedTimeStamp_;
00188     timeval                         lastModuleLegendaMessageTimeStamp_;
00189     timeval                         lastPathLegendaMessageTimeStamp_;
00190     
00191 
00192   }; // class iDie
00193 
00194 
00195 } // namespace evf
00196 
00197 
00198 #endif