CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DPGAnalysis/SiStripTools/plugins/BigEventsDebugger.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    BigEventsDebugger
00004 // Class:      BigEventsDebugger
00005 // 
00013 //
00014 // Original Author:  Andrea Venturi
00015 //         Created:  Sun Nov 16 16:04:44 CET 2008
00016 // $Id: BigEventsDebugger.cc,v 1.1 2011/10/02 16:58:33 venturia Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/Run.h"
00030 #include "FWCore/Framework/interface/MakerMacros.h"
00031 
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033 
00034 #include <vector>
00035 #include "TH2F.h"
00036 #include "TProfile.h"
00037 
00038 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00039 
00040 #include "FWCore/ServiceRegistry/interface/Service.h"
00041 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00042 
00043 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00044 #include "DataFormats/Common/interface/DetSetVector.h"
00045 #include "DataFormats/Common/interface/DetSet.h"
00046 
00047 #include "DPGAnalysis/SiStripTools/interface/DigiCollectionProfiler.h"
00048 
00049 //
00050 // class decleration
00051 //
00052 
00053 class BigEventsDebugger : public edm::EDAnalyzer {
00054    public:
00055       explicit BigEventsDebugger(const edm::ParameterSet&);
00056       ~BigEventsDebugger();
00057 
00058 
00059    private:
00060       virtual void beginJob(const edm::EventSetup&) ;
00061       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00062       virtual void endJob() ;
00063 
00064       // ----------member data ---------------------------
00065 
00066   bool m_singleevents;
00067 
00068   TProfile* m_tibprof;
00069   TProfile* m_tobprof;
00070   TProfile* m_tecpprof;
00071   TProfile* m_tecmprof;
00072 
00073   TH2F* m_tib2d;
00074   TH2F* m_tob2d;
00075   TH2F* m_tecp2d;
00076   TH2F* m_tecm2d;
00077 
00078   std::vector<unsigned int> m_maskedmod;
00079 };
00080 
00081 //
00082 // constants, enums and typedefs
00083 //
00084 
00085 //
00086 // static data member definitions
00087 //
00088 
00089 //
00090 // constructors and destructor
00091 //
00092 BigEventsDebugger::BigEventsDebugger(const edm::ParameterSet& iConfig):
00093   m_singleevents(iConfig.getParameter<bool>("singleEvents")),
00094   m_maskedmod(iConfig.getUntrackedParameter<std::vector<unsigned int> >("maskedModules"))
00095 
00096 {
00097    //now do what ever initialization is needed
00098 
00099   sort(m_maskedmod.begin(),m_maskedmod.end());
00100 
00101   edm::Service<TFileService> tfserv;
00102 
00103   if(!m_singleevents) {
00104    char dirname[500];
00105    sprintf(dirname,"Summary");
00106    TFileDirectory subd = tfserv->mkdir(dirname);
00107    
00108    //book histos
00109 
00110    m_tibprof = subd.make<TProfile>("tibprof","TIB Digi charge profile",256,-0.5,255.5);
00111    m_tobprof = subd.make<TProfile>("tobprof","TOB Digi charge profile",256,-0.5,255.5);
00112    m_tecpprof = subd.make<TProfile>("tecpprof","TECp Digi charge profile",256,-0.5,255.5);
00113    m_tecmprof = subd.make<TProfile>("tecmprof","TECm Digi charge profile",256,-0.5,255.5);
00114 
00115    m_tib2d = subd.make<TH2F>("tib2d","TIB Digi charge distribution",256,-0.5,255.5,257,-0.5,256.5);
00116    m_tob2d = subd.make<TH2F>("tob2d","TOB Digi charge distribution",256,-0.5,255.5,257,-0.5,256.5);
00117    m_tecp2d = subd.make<TH2F>("tecp2d","TECp Digi charge distribution",256,-0.5,255.5,257,-0.5,256.5);
00118    m_tecm2d = subd.make<TH2F>("tecm2d","TECm Digi charge distribution",256,-0.5,255.5,257,-0.5,256.5);
00119 
00120   }
00121 
00122 }
00123 
00124 
00125 BigEventsDebugger::~BigEventsDebugger()
00126 {
00127 
00128  
00129    // do anything here that needs to be done at desctruction time
00130    // (e.g. close files, deallocate resources etc.)
00131 
00132 }
00133 
00134 
00135 //
00136 // member functions
00137 //
00138 
00139 // ------------ method called to for each event  ------------
00140 void
00141 BigEventsDebugger::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00142 {
00143    using namespace edm;
00144 
00145    edm::Service<TFileService> tfserv;
00146 
00147    // create a folder for each event
00148 
00149    if(m_singleevents) {
00150 
00151      char dirname[500];
00152      sprintf(dirname,"event_%u_%u",iEvent.run(),iEvent.id().event());
00153      TFileDirectory subd = tfserv->mkdir(dirname);
00154      
00155      //book histos
00156      
00157      m_tibprof = subd.make<TProfile>("tibprof","TIB Digi charge profile",256,-0.5,255.5);
00158      m_tobprof = subd.make<TProfile>("tobprof","TOB Digi charge profile",256,-0.5,255.5);
00159      m_tecpprof = subd.make<TProfile>("tecpprof","TECp Digi charge profile",256,-0.5,255.5);
00160      m_tecmprof = subd.make<TProfile>("tecmprof","TECm Digi charge profile",256,-0.5,255.5);
00161      
00162      m_tib2d = subd.make<TH2F>("tib2d","TIB Digi charge distribution",256,-0.5,255.5,257,-0.5,256.5);
00163      m_tob2d = subd.make<TH2F>("tob2d","TOB Digi charge distribution",256,-0.5,255.5,257,-0.5,256.5);
00164      m_tecp2d = subd.make<TH2F>("tecp2d","TECp Digi charge distribution",256,-0.5,255.5,257,-0.5,256.5);
00165      m_tecm2d = subd.make<TH2F>("tecm2d","TECm Digi charge distribution",256,-0.5,255.5,257,-0.5,256.5);
00166 
00167    }
00168 
00169    //analyze event
00170 
00171    DigiCollectionProfiler profiler(m_tibprof,
00172                                    m_tobprof,
00173                                    m_tecpprof,
00174                                    m_tecmprof,
00175                                    m_tib2d,
00176                                    m_tob2d,
00177                                    m_tecp2d,
00178                                    m_tecm2d);
00179 
00180    Handle<edm::DetSetVector<SiStripDigi> > digis;
00181    iEvent.getByLabel("siStripDigis","ZeroSuppressed",digis);
00182    profiler.setMaskedModules(m_maskedmod);
00183    profiler.analyze(digis);
00184 
00185 }
00186 
00187 
00188 // ------------ method called once each job just before starting event loop  ------------
00189 void 
00190 BigEventsDebugger::beginJob(const edm::EventSetup&)
00191 {
00192   edm::LogInfo("MaskedModules") << m_maskedmod.size() << " masked modules ";
00193   for(std::vector<unsigned int>::const_iterator it=m_maskedmod.begin();it!=m_maskedmod.end();it++) {
00194     edm::LogVerbatim("MaskedModules") << (*it);
00195   }
00196 }
00197 
00198 // ------------ method called once each job just after ending the event loop  ------------
00199 void 
00200 BigEventsDebugger::endJob() {
00201 }
00202 
00203 //define this as a plug-in
00204 DEFINE_FWK_MODULE(BigEventsDebugger);