CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQM/RPCMonitorDigi/interface/RPCMonitorSync.h

Go to the documentation of this file.
00001 #ifndef RPCMonitorSync_h
00002 #define RPCMonitorSync_h
00003 
00017 #include "FWCore/Framework/interface/Frameworkfwd.h"
00018 #include "FWCore/Framework/interface/EDAnalyzer.h"
00019 #include "FWCore/Framework/interface/ESHandle.h"
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00022 #include "FWCore/ServiceRegistry/interface/Service.h"
00023 
00024 #include "DQMServices/Core/interface/DQMStore.h"
00025 #include "DQMServices/Core/interface/MonitorElement.h"
00026 
00027 #include "DataFormats/Common/interface/Handle.h"
00028 
00029 #include <string>
00030 #include <map>
00031 #include <math.h>
00032 
00033 struct timing{
00034 
00035   int early_all[4];
00036   int inTime;
00037   int late_all[4];
00038 
00039   int early() const {
00040     return (early_all[0]+early_all[1]+early_all[2]+early_all[3]);
00041   }
00042 
00043   int late() const {
00044     return (late_all[0]+late_all[1]+late_all[2]+late_all[3]);
00045   }
00046 
00047   int early_w() const {
00048     return (early_all[0]+2*early_all[1]+3*early_all[2]+4*early_all[3]);
00049   }
00050 
00051   int late_w() const {
00052     return (late_all[0]+2*late_all[1]+3*late_all[2]+4*late_all[3]);
00053   }
00054 
00055   int early_w2() const {
00056     return (early_all[0]+4*early_all[1]+9*early_all[2]+16*early_all[3]);
00057   }
00058 
00059   int late_w2() const {
00060     return (late_all[0]+4*late_all[1]+9*late_all[2]+16*late_all[3]);
00061   }
00062 
00063   float earlyFraction() const{ 
00064     return (float)early()/(early()+inTime+late());  
00065   }
00066 
00067   float inTimeFraction() const { 
00068     return (float)inTime/(early()+inTime+late());  
00069   }
00070 
00071   float lateFraction() const { 
00072     return (float)late()/(early()+inTime+late());  
00073   }
00074 
00075   float outOfTimeFraction() const { 
00076     return (float)(early()+late())/(early()+inTime+late());  
00077   }
00078   
00079   float offset() const {
00080     return (float)(late_w()-early_w())/(early()+inTime+late());  
00081   }
00082 
00083   float width() const {
00084     return (float)sqrt((float)(late_w2()+early_w2())/(early()+inTime+late()));  
00085   }
00086 
00087 };
00088 
00089 class RPCDetId;
00090 
00091 class RPCMonitorSync : public edm::EDAnalyzer {
00092   public:
00093     explicit RPCMonitorSync( const edm::ParameterSet& );
00094             ~RPCMonitorSync();
00095    
00096     virtual void analyze( const edm::Event&, const edm::EventSetup& );
00097 
00098     virtual void endJob(void);
00099         
00101     std::map<std::string, MonitorElement*> bookDetUnitME(RPCDetId & detId);
00102 
00103   private:
00104         
00105     void readRPCDAQStrips(const edm::Event& iEvent);
00106 
00107     MonitorElement *barrelOffsetHist( std::string name, std::string title );
00108     MonitorElement *endcapOffsetHist( std::string name, std::string title );
00109     MonitorElement *barrelWidthHist( std::string name, std::string title );
00110     MonitorElement *endcapWidthHist( std::string name, std::string title );
00111 
00112     std::map<uint32_t,timing> synchroMap;
00113     int counter;
00115     DQMStore * dbe;
00116     MonitorElement * h1;
00117     std::map<uint32_t, std::map<std::string, MonitorElement*> >  meCollection;
00118                 
00119     std::string nameInLog;
00120     bool saveRootFile;
00121     int  saveRootFileEventsInterval;
00122     std::string RootFileName;
00123 };
00124 
00125 #endif