CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/DQMOffline/EGamma/plugins/ElectronGeneralAnalyzer.cc

Go to the documentation of this file.
00001 
00002 #include "DQMOffline/EGamma/plugins/ElectronGeneralAnalyzer.h"
00003 
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 
00006 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00007 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00008 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00009 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00010 #include "DataFormats/VertexReco/interface/Vertex.h"
00011 #include "DataFormats/Common/interface/Handle.h"
00012 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00013 #include "DataFormats/Common/interface/TriggerResults.h"
00014 
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016 #include "FWCore/Framework/interface/EDAnalyzer.h"
00017 #include "FWCore/Framework/interface/Event.h"
00018 #include "FWCore/Framework/interface/MakerMacros.h"
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020 #include "FWCore/ServiceRegistry/interface/Service.h"
00021 
00022 //#include "CLHEP/Units/GlobalPhysicalConstants.h"
00023 //#include "TMath.h"
00024 
00025 #include <iostream>
00026 
00027 using namespace reco ;
00028 
00029 ElectronGeneralAnalyzer::ElectronGeneralAnalyzer( const edm::ParameterSet & conf )
00030  : ElectronDqmAnalyzerBase(conf)
00031  {
00032   // collection input tags
00033   electronCollection_ = conf.getParameter<edm::InputTag>("ElectronCollection");
00034   matchingObjectCollection_ = conf.getParameter<edm::InputTag>("MatchingObjectCollection");
00035   trackCollection_ = conf.getParameter<edm::InputTag>("TrackCollection");
00036   vertexCollection_ = conf.getParameter<edm::InputTag>("VertexCollection");
00037   gsftrackCollection_ = conf.getParameter<edm::InputTag>("GsfTrackCollection");
00038   beamSpotTag_ = conf.getParameter<edm::InputTag>("BeamSpot");
00039   triggerResults_ = conf.getParameter<edm::InputTag>("TriggerResults");
00040 
00041 //  // for trigger
00042 //  HLTPathsByName_= conf.getParameter<std::vector<std::string > >("HltPaths");
00043 //  HLTPathsByIndex_.resize(HLTPathsByName_.size());
00044  }
00045 
00046 ElectronGeneralAnalyzer::~ElectronGeneralAnalyzer()
00047  {}
00048 
00049 void ElectronGeneralAnalyzer::book()
00050  {
00051   h2_ele_beamSpotXvsY = bookH2("beamSpotXvsY","beam spot x vs y",100,-0.2,0.2,100,-0.2,0.2,"x (cm)","y (cm)") ;
00052   py_ele_nElectronsVsLs = bookP1("nElectronsVsLs","# gsf electrons vs LS",150,0.,1500.,0.,20.,"LS","<N_{ele}>") ;
00053   py_ele_nClustersVsLs = bookP1("nClustersVsLs","# clusters vs LS",150,0.,1500.,0.,100.,"LS","<N_{SC}>") ;
00054   py_ele_nGsfTracksVsLs = bookP1("nGsfTracksVsLs","# gsf tracks vs LS",150,0.,1500.,0.,20.,"LS","<N_{GSF tk}>") ;
00055   py_ele_nTracksVsLs = bookP1("nTracksVsLs","# tracks vs LS",150,0.,1500.,0.,100.,"LS","<N_{gen tk}>") ;
00056   py_ele_nVerticesVsLs = bookP1("nVerticesVsLs","# vertices vs LS",150,0.,1500.,0.,10.,"LS","<N_{vert}>") ;
00057   h1_ele_triggers = bookH1("triggers","hlt triggers",256,0.,256.,"HLT bit") ;
00058  }
00059 
00060 void ElectronGeneralAnalyzer::analyze( const edm::Event& iEvent, const edm::EventSetup & iSetup )
00061  {
00062   edm::Handle<GsfElectronCollection> gsfElectrons ;
00063   iEvent.getByLabel(electronCollection_,gsfElectrons) ;
00064   edm::Handle<reco::SuperClusterCollection> recoClusters ;
00065   iEvent.getByLabel(matchingObjectCollection_,recoClusters) ;
00066   edm::Handle<reco::TrackCollection> tracks;
00067   iEvent.getByLabel(trackCollection_,tracks);
00068   edm::Handle<reco::GsfTrackCollection> gsfTracks;
00069   iEvent.getByLabel(gsftrackCollection_,gsfTracks);
00070   edm::Handle<reco::VertexCollection> vertices;
00071   iEvent.getByLabel(vertexCollection_,vertices);
00072   edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
00073   iEvent.getByLabel(beamSpotTag_,recoBeamSpotHandle) ;
00074   const BeamSpot bs = *recoBeamSpotHandle ;
00075 
00076   int ievt = iEvent.id().event();
00077   int irun = iEvent.id().run();
00078   int ils = iEvent.luminosityBlock();
00079 
00080   edm::LogInfo("ElectronGeneralAnalyzer::analyze")
00081     <<"Treating "<<gsfElectrons.product()->size()<<" electrons"
00082     <<" from event "<<ievt<<" in run "<<irun<<" and lumiblock "<<ils ;
00083 
00084   h2_ele_beamSpotXvsY->Fill(bs.position().x(),bs.position().y());
00085   py_ele_nElectronsVsLs->Fill(float(ils),(*gsfElectrons).size());
00086   py_ele_nClustersVsLs->Fill(float(ils),(*recoClusters).size());
00087   py_ele_nGsfTracksVsLs->Fill(float(ils),(*gsfTracks).size());
00088   py_ele_nTracksVsLs->Fill(float(ils),(*tracks).size());
00089   py_ele_nVerticesVsLs->Fill(float(ils),(*vertices).size());
00090 
00091   // trigger
00092   edm::Handle<edm::TriggerResults> triggerResults ;
00093   iEvent.getByLabel(triggerResults_,triggerResults) ;
00094   if (triggerResults.isValid())
00095    {
00096     unsigned int i, n = triggerResults->size() ;
00097     for ( i=0 ; i!=n ; ++i )
00098      {
00099       if (triggerResults->accept(i))
00100        { h1_ele_triggers->Fill(float(i)) ; }
00101      }
00102    }
00103  }
00104