CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQMOffline/L1Trigger/interface/L1TEfficiencyMuons_Offline.h

Go to the documentation of this file.
00001 #ifndef DQMOFFLINE_L1TRIGGER_L1TEFFICIENCYMUON_OFFLINE_H
00002 #define DQMOFFLINE_L1TRIGGER_L1TEFFICIENCYMUON_OFFLINE_H
00003 
00004 /*
00005  * \file L1TEfficiencyMuons.h
00006  *
00007  * $Date: 2013/03/18 17:17:52 $
00008  * $Revision: 1.2 $
00009  * \author J. Pela, C. Battilana
00010  *
00011  */
00012 
00013 // system include files
00014 #include <memory>
00015 #include <unistd.h>
00016 
00017 // user include files
00018 #include "FWCore/Framework/interface/Frameworkfwd.h"
00019 #include "FWCore/Framework/interface/EDAnalyzer.h"
00020 #include "FWCore/Framework/interface/ESHandle.h"
00021 #include "FWCore/Framework/interface/Event.h"
00022 #include "FWCore/Framework/interface/LuminosityBlock.h"
00023 #include "FWCore/Framework/interface/MakerMacros.h"
00024 
00025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00026 
00027 #include "DQMServices/Core/interface/DQMStore.h"
00028 #include "DQMServices/Core/interface/MonitorElement.h"
00029 #include "FWCore/ServiceRegistry/interface/Service.h"
00030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00031 
00032 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00033 
00034 #include "DataFormats/MuonReco/interface/Muon.h"
00035 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00036 
00037 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00038 #include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h"
00039 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00040 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
00041 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00042 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00043 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00044 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00045 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00046 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00047 
00048 #include "MagneticField/Engine/interface/MagneticField.h"
00049 
00050 #include "DataFormats/VertexReco/interface/Vertex.h"
00051 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00052 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00053 
00054 #include "DataFormats/Math/interface/deltaR.h"
00055 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00056 #include "DataFormats/Common/interface/TriggerResults.h"
00057 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00058 #include "DataFormats/HLTReco/interface/TriggerObject.h"
00059 
00060 #include "TRegexp.h"
00061 #include "TString.h"
00062 
00063 #include <iostream>
00064 #include <fstream>
00065 #include <utility>
00066 #include <vector>
00067 
00068 
00069 //
00070 // helper class to manage GMT-Muon pariring
00071 //
00072 
00073 class MuonGmtPair {
00074 
00075  public :
00076 
00077   MuonGmtPair(const reco::Muon *muon, const L1MuGMTExtendedCand *gmt) : 
00078     m_muon(muon), m_gmt(gmt), m_eta(999.), m_phi_bar(999.), m_phi_end(999.) { };
00079     
00080   MuonGmtPair(const MuonGmtPair& muonGmtPair);
00081 
00082   ~MuonGmtPair() { };
00083 
00084   double dR();
00085 
00086   double eta() const { return m_eta; };
00087   double phi() const { return fabs(m_eta)< 1.04 ? m_phi_bar : m_phi_end; };
00088   double pt()  const { return m_muon->isGlobalMuon() ? m_muon->globalTrack()->pt() : -1; };
00089   
00090   double gmtPt() const { return m_gmt ? m_gmt->ptValue() : -1.; };
00091 
00092   void propagate(edm::ESHandle<MagneticField> bField,
00093                  edm::ESHandle<Propagator> propagatorAlong,
00094                  edm::ESHandle<Propagator> propagatorOpposite);
00095 
00096 private :
00097 
00098   // propagation private members
00099   TrajectoryStateOnSurface cylExtrapTrkSam(reco::TrackRef track, double rho);
00100   TrajectoryStateOnSurface surfExtrapTrkSam(reco::TrackRef track, double z);
00101   FreeTrajectoryState freeTrajStateMuon(reco::TrackRef track);
00102 
00103 private :
00104 
00105   const reco::Muon *m_muon;
00106   const L1MuGMTExtendedCand *m_gmt;
00107 
00108   edm::ESHandle<MagneticField> m_BField;
00109   edm::ESHandle<Propagator> m_propagatorAlong;
00110   edm::ESHandle<Propagator> m_propagatorOpposite;
00111 
00112   double m_eta;
00113   double m_phi_bar;
00114   double m_phi_end;
00115 
00116 };
00117 
00118 //
00119 // DQM class declaration
00120 //
00121 
00122 class L1TEfficiencyMuons_Offline : public edm::EDAnalyzer {
00123   
00124 public:
00125   
00126   L1TEfficiencyMuons_Offline(const edm::ParameterSet& ps);   // Constructor
00127   virtual ~L1TEfficiencyMuons_Offline();                     // Destructor
00128   
00129 protected:
00130   
00131   // Event
00132   void analyze (const edm::Event& e, const edm::EventSetup& c); 
00133   
00134   // Job
00135   void beginJob();  
00136   void endJob  ();
00137 
00138   // Run
00139   void beginRun(const edm::Run& run, const edm::EventSetup& iSetup);
00140   void endRun  (const edm::Run& run, const edm::EventSetup& iSetup);
00141   
00142    // Luminosity Block
00143   virtual void beginLuminosityBlock(edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& c);
00144   virtual void endLuminosityBlock  (edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& c);
00145 
00146 private:
00147 
00148   // Booking
00149   void bookControlHistos();
00150   void bookEfficiencyHistos(int ptCut);
00151 
00152   // Helper Functions
00153   const reco::Vertex getPrimaryVertex(edm::Handle<reco::VertexCollection> & vertex,edm::Handle<reco::BeamSpot> & beamSpot);
00154   bool matchHlt(edm::Handle<trigger::TriggerEvent>  & triggerEvent, 
00155                 const reco::Muon * mu);
00156 
00157   // Cut and Matching
00158   void getMuonGmtPairs(edm::Handle<L1MuGMTReadoutCollection> & gmtCands);
00159   void getTightMuons(edm::Handle<reco::MuonCollection> & muons, const reco::Vertex & vertex);
00160   void getProbeMuons(edm::Handle<edm::TriggerResults> & trigResults,edm::Handle<trigger::TriggerEvent> & trigEvent);  
00161   
00162 private:
00163   
00164   bool  m_verbose;
00165   DQMStore* dbe;  // The DQM Service Handle
00166 
00167   HLTConfigProvider m_hltConfig;
00168 
00169   edm::ESHandle<MagneticField> m_BField;
00170   edm::ESHandle<Propagator> m_propagatorAlong;
00171   edm::ESHandle<Propagator> m_propagatorOpposite;
00172 
00173   // histos
00174   std::map<int, std::map<std::string, MonitorElement*> > m_EfficiencyHistos;
00175   std::map<std::string, MonitorElement*> m_ControlHistos;
00176 
00177   // helper variables
00178   std::vector<const reco::Muon*>  m_TightMuons;
00179   std::vector<const reco::Muon*>  m_ProbeMuons;
00180   std::vector<MuonGmtPair>  m_MuonGmtPairs;  
00181   
00182   // config params
00183   std::vector<int> m_GmtPtCuts;
00184 
00185   edm::InputTag m_MuonInputTag;
00186   edm::InputTag m_GmtInputTag;
00187 
00188   edm::InputTag m_VtxInputTag;
00189   edm::InputTag m_BsInputTag;
00190 
00191   edm::InputTag m_trigInputTag;
00192   std::string m_trigProcess;
00193   std::vector<std::string> m_trigNames;
00194   std::vector<int> m_trigIndices;
00195 
00196   float m_MaxMuonEta;
00197   float m_MaxGmtMuonDR;
00198   float m_MaxHltMuonDR;
00199   // CB ignored at present
00200   // float m_MinMuonDR;
00201   
00202 };
00203 
00204 #endif