1 #ifndef TESTCORRECTION_HH 2 #define TESTCORRECTION_HH 75 std::vector<MuScleFitMuon>
muons;
76 typename std::vector<T>::const_iterator
track;
77 for( track = tracks.begin(); track != tracks.end(); ++
track ) {
80 sqrt(track->p()*track->p() + + 0.011163612));
82 Double_t hitsTk(0), hitsMuon(0), ptError(0);
83 if (
const reco::Muon* myMu = dynamic_cast<const reco::Muon*>(&(*track)) ){
84 hitsTk = myMu->innerTrack()->hitPattern().numberOfValidTrackerHits();
85 hitsMuon = myMu->innerTrack()->hitPattern().numberOfValidMuonHits();
86 ptError = myMu->innerTrack()->ptError();
88 else if (
const pat::Muon* myMu = dynamic_cast<const pat::Muon*>(&(*track)) ) {
89 hitsTk = myMu->innerTrack()->hitPattern().numberOfValidTrackerHits();
90 hitsMuon = myMu->innerTrack()->hitPattern().numberOfValidMuonHits();
91 ptError = myMu->innerTrack()->ptError();
93 else if (
const reco::Track* myMu = dynamic_cast<const reco::Track*>(&(*track))){
94 hitsTk = myMu->hitPattern().numberOfValidTrackerHits();
95 hitsMuon = myMu->hitPattern().numberOfValidMuonHits();
96 ptError = myMu->ptError();
102 std::cout<<
"[TestCorrection::fillMuonCollection] after MuScleFitMuon initialization"<<std::endl;
106 muons.push_back(
muon);
136 #endif // TESTCORRECTION_HH 162 uncorrectedPt_ =
new TH1F(
"uncorrectedPt",
"uncorrected pt", 1000, 0, 100);
163 uncorrectedPtVsEta_ =
new TProfile(
"uncorrectedPtVsEta",
"uncorrected pt vs eta", 1000, 0, 100, -3., 3.);
164 correctedPt_ =
new TH1F(
"correctedPt",
"corrected pt", 1000, 0, 100);
165 correctedPtVsEta_ =
new TProfile(
"correctedPtVsEta",
"corrected pt vs eta", 1000, 0, 100, -3., 3.);
185 TCanvas
canvas(
"ptComparison",
"pt comparison", 1000, 800);
189 TLegend *
legend =
new TLegend(0.7,0.71,0.98,1.);
190 legend->SetTextSize(0.02);
191 legend->SetFillColor(0);
196 legend->Draw(
"same");
228 std::vector<MuScleFitMuon>
muons;
248 std::pair <MuScleFitMuon, MuScleFitMuon> recMuFromBestRes =
276 if ((
std::abs(recMu1.eta())<2.5) && (recMu1.pt()>2.5)) {
277 mapHisto_[
"hRecBestMu_Acc"]->Fill(recMu1);
280 if ((
std::abs(recMu2.eta())<2.5) && (recMu2.pt()>2.5)) {
281 mapHisto_[
"hRecBestMu_Acc"]->Fill(recMu2);
283 mapHisto_[
"hDeltaRecBestMu"]->Fill(recMu1, recMu2);
285 mapHisto_[
"hRecBestRes"]->Fill(bestRecRes);
286 if ((
std::abs(recMu1.eta())<2.5) && (recMu1.pt()>2.5) && (
std::abs(recMu2.eta())<2.5) && (recMu2.pt()>2.5)){
287 mapHisto_[
"hRecBestRes_Acc"]->Fill(bestRecRes);
289 mapHisto_[
"hRecBestResVSMu"]->Fill (recMu1, bestRecRes, -1);
290 mapHisto_[
"hRecBestResVSMu"]->Fill (recMu2, bestRecRes, +1);
295 std::vector<MuScleFitMuon>::const_iterator recMuon = muons.begin();
297 for ( ; recMuon!=muons.end(); ++recMuon, ++muonCount ) {
304 std::cout <<
"correcting muon["<<muonCount<<
"] with pt = " << recMuon->pt() << std::endl;
305 double corrPt = (*corrector_)(*recMuon);
306 std::cout <<
"to pt = " << corrPt << std::endl;
315 double ptEtaPhiE[4] = {corrPt, muon.Eta(), muon.Phi(), muon.E()};
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag theMuonLabel_
lorentzVector correctMuon(const lorentzVector &muon)
TProfile * correctedPtVsEta_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static std::vector< double > parResol
virtual void initialize(const edm::EventSetup &)
std::vector< Track > TrackCollection
collection of Tracks
edm::EDGetTokenT< reco::TrackCollection > saMuonsToken_
std::map< std::string, Histograms * > mapHisto_
The map of histograms.
std::unique_ptr< BackgroundFunction > background_
std::vector< Muon > MuonCollection
collection of Muon objects
reco::Particle::LorentzVector lorentzVector
static std::pair< MuScleFitMuon, MuScleFitMuon > findBestRecoRes(const std::vector< MuScleFitMuon > &muons)
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
resolutionFunctionBase< std::vector< double > > * resolutionFunctionVecService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier when receiving a std::...
std::unique_ptr< MomentumScaleCorrector > corrector_
static lorentzVector fromPtEtaPhiToPxPyPz(const double *ptEtaPhiE)
Abs< T >::type abs(const T &t)
TestCorrection(const edm::ParameterSet &)
static std::vector< std::pair< lorentzVector, lorentzVector > > SavedPair
TProfile * uncorrectedPtVsEta_
~TestCorrection() override
std::vector< MuScleFitMuon > fillMuonCollection(const std::vector< T > &tracks)
void writeHistoMap(const unsigned int iLoop)
Save the histograms map to file.
std::string theRootFileName_
void fillHistoMap(TFile *outputFile, unsigned int iLoop)
Create the histograms map.
std::vector< TFile * > theFiles_
The files were the histograms are saved.
edm::EDGetTokenT< reco::MuonCollection > glbMuonsToken_
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
static std::vector< int > resfind
void readProbabilityDistributionsFromFile()
Read probability distributions from a local root file.
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
static resolutionFunctionBase< std::vector< double > > * resolutionFunctionForVec
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Analysis-level muon class.
static resolutionFunctionBase< double * > * resolutionFunction
std::unique_ptr< ResolutionFunction > resolution_