CMS 3D CMS Logo

TestCorrection.h
Go to the documentation of this file.
1 #ifndef TESTCORRECTION_HH
2 #define TESTCORRECTION_HH
3 
4 // -*- C++ -*-
5 //
6 // Package: TestCorrection
7 // Class: TestCorrection
8 //
16 //
17 // Original Author: Marco De Mattia
18 // Created: Thu Sep 11 12:16:00 CEST 2008
19 //
20 //
21 
22 // system include files
23 #include <memory>
24 #include <string>
25 #include <vector>
26 
27 // user include files
33 
42 
44 
45 // For the momentum scale correction
50 
51 #include "TFile.h"
52 #include "TProfile.h"
53 #include "TH1F.h"
54 
55 #include "MuScleFitBase.h"
56 
57 //
58 // class decleration
59 //
60 
62 public:
63  explicit TestCorrection(const edm::ParameterSet&);
65 
66 private:
67  virtual void initialize(const edm::EventSetup&);
68  virtual void analyze(const edm::Event&, const edm::EventSetup&);
69  virtual void endJob() {};
70  template<typename T>
71  std::vector<MuScleFitMuon> fillMuonCollection( const std::vector<T>& tracks )
72  {
73  std::vector<MuScleFitMuon> muons;
74  typename std::vector<T>::const_iterator track;
75  for( track = tracks.begin(); track != tracks.end(); ++track ) {
77  mu = reco::Particle::LorentzVector(track->px(),track->py(),track->pz(),
78  sqrt(track->p()*track->p() + + 0.011163612));
79 
80  Double_t hitsTk(0), hitsMuon(0), ptError(0);
81  if ( const reco::Muon* myMu = dynamic_cast<const reco::Muon*>(&(*track)) ){
82  hitsTk = myMu->innerTrack()->hitPattern().numberOfValidTrackerHits();
83  hitsMuon = myMu->innerTrack()->hitPattern().numberOfValidMuonHits();
84  ptError = myMu->innerTrack()->ptError();
85  }
86  else if ( const pat::Muon* myMu = dynamic_cast<const pat::Muon*>(&(*track)) ) {
87  hitsTk = myMu->innerTrack()->hitPattern().numberOfValidTrackerHits();
88  hitsMuon = myMu->innerTrack()->hitPattern().numberOfValidMuonHits();
89  ptError = myMu->innerTrack()->ptError();
90  }
91  else if (const reco::Track* myMu = dynamic_cast<const reco::Track*>(&(*track))){
92  hitsTk = myMu->hitPattern().numberOfValidTrackerHits();
93  hitsMuon = myMu->hitPattern().numberOfValidMuonHits();
94  ptError = myMu->ptError();
95  }
96 
97  MuScleFitMuon muon(mu,track->charge(),ptError,hitsTk,hitsMuon,false);
98 
99  if (debug_>0) {
100  std::cout<<"[TestCorrection::fillMuonCollection] after MuScleFitMuon initialization"<<std::endl;
101  std::cout<<" muon = "<<muon<<std::endl;
102  }
103 
104  muons.push_back(muon);
105  }
106  return muons;
107  }
108 
110 
111  // ----------member data ---------------------------
112 
113  // Collections labels
114  // ------------------
115  TH1F * uncorrectedPt_;
116  TProfile * uncorrectedPtVsEta_;
117  TH1F * correctedPt_;
118  TProfile * correctedPtVsEta_;
119 
120  int eventCounter_;
121 
122  std::unique_ptr<MomentumScaleCorrector> corrector_;
123  std::unique_ptr<ResolutionFunction> resolution_;
124  std::unique_ptr<BackgroundFunction> background_;
125 };
126 
127 #endif // TESTCORRECTION_HH
lorentzVector correctMuon(const lorentzVector &muon)
TProfile * correctedPtVsEta_
virtual void initialize(const edm::EventSetup &)
virtual void endJob()
std::unique_ptr< BackgroundFunction > background_
reco::Particle::LorentzVector lorentzVector
Definition: GenMuonPair.h:9
void analyze(const edm::Event &, const edm::EventSetup &) override
T sqrt(T t)
Definition: SSEVec.h:18
std::unique_ptr< MomentumScaleCorrector > corrector_
TestCorrection(const edm::ParameterSet &)
const int mu
Definition: Constants.h:22
TProfile * uncorrectedPtVsEta_
~TestCorrection() override
std::vector< MuScleFitMuon > fillMuonCollection(const std::vector< T > &tracks)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
Analysis-level muon class.
Definition: Muon.h:51
std::unique_ptr< ResolutionFunction > resolution_