CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Validation/RecoMuon/plugins/MuonTrackValidator.cc

Go to the documentation of this file.
00001 #include "Validation/RecoMuon/plugins/MuonTrackValidator.h"
00002 #include "DQMServices/ClientConfig/interface/FitSlicesYTool.h"
00003 
00004 #include "FWCore/Framework/interface/MakerMacros.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 #include "DataFormats/TrackReco/interface/Track.h"
00008 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00009 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00010 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
00011 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00012 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00013 #include "SimTracker/TrackAssociation/interface/TrackAssociatorByChi2.h"
00014 #include "SimTracker/TrackAssociation/interface/TrackAssociatorByHits.h"
00015 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
00016 #include "SimTracker/Records/interface/TrackAssociatorRecord.h"
00017 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
00018 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00019 #include "TrackingTools/PatternTools/interface/TSCBLBuilderNoMaterial.h"
00020 #include "SimTracker/TrackAssociation/plugins/ParametersDefinerForTPESProducer.h"
00021 #include "SimTracker/TrackAssociation/plugins/CosmicParametersDefinerForTPESProducer.h"
00022 
00023 #include "TMath.h"
00024 #include <TF1.h>
00025 
00026 using namespace std;
00027 using namespace edm;
00028 
00029 void MuonTrackValidator::beginRun(Run const&, EventSetup const& setup) {
00030 
00031   //  dbe_->showDirStructure();
00032 
00033   int j=0;
00034   for (unsigned int ww=0;ww<associators.size();ww++){
00035     for (unsigned int www=0;www<label.size();www++){
00036 
00037       dbe_->cd();
00038       InputTag algo = label[www];
00039       string dirName=dirName_;
00040       if (algo.process()!="")
00041         dirName+=algo.process()+"_";
00042       if(algo.label()!="")
00043         dirName+=algo.label()+"_";
00044       if(algo.instance()!="")
00045         dirName+=algo.instance()+"_";      
00046       if (dirName.find("Tracks")<dirName.length()){
00047         dirName.replace(dirName.find("Tracks"),6,"");
00048       }
00049       string assoc= associators[ww];
00050       if (assoc.find("Track")<assoc.length()){
00051         assoc.replace(assoc.find("Track"),5,"");
00052       }
00053       dirName+=assoc;
00054       std::replace(dirName.begin(), dirName.end(), ':', '_');
00055       dbe_->setCurrentFolder(dirName.c_str());
00056 
00057       setUpVectors();
00058 
00059       dbe_->goUp();
00060       string subDirName = dirName + "/simulation";
00061       dbe_->setCurrentFolder(subDirName.c_str());
00062       h_ptSIM.push_back( dbe_->book1D("ptSIM", "generated p_{t}", 5500, 0, 110 ) );
00063       h_etaSIM.push_back( dbe_->book1D("etaSIM", "generated pseudorapidity", 500, -2.5, 2.5 ) );
00064       h_tracksSIM.push_back( dbe_->book1D("tracksSIM","number of simulated tracks",200,-0.5,99.5) );
00065       h_vertposSIM.push_back( dbe_->book1D("vertposSIM","Transverse position of sim vertices",100,0.,120.) );
00066       
00067       dbe_->cd();
00068       dbe_->setCurrentFolder(dirName.c_str());
00069       h_tracks.push_back( dbe_->book1D("tracks","number of reconstructed tracks",200,-0.5,19.5) );
00070       h_fakes.push_back( dbe_->book1D("fakes","number of fake reco tracks",20,-0.5,19.5) );
00071       h_charge.push_back( dbe_->book1D("charge","charge",3,-1.5,1.5) );
00072       h_hits.push_back( dbe_->book1D("hits", "number of hits per track", nintHit,minHit,maxHit ) );
00073       h_losthits.push_back( dbe_->book1D("losthits", "number of lost hits per track", nintHit,minHit,maxHit) );
00074       h_nchi2.push_back( dbe_->book1D("chi2", "normalized #chi^{2}", 200, 0, 20 ) );
00075       h_nchi2_prob.push_back( dbe_->book1D("chi2_prob", "normalized #chi^{2} probability",100,0,1));
00076 
00077       h_effic.push_back( dbe_->book1D("effic","efficiency vs #eta",nint,min,max) );
00078       h_efficPt.push_back( dbe_->book1D("efficPt","efficiency vs pT",nintpT,minpT,maxpT) );
00079       h_effic_vs_hit.push_back( dbe_->book1D("effic_vs_hit","effic vs hit",nintHit,minHit,maxHit) );
00080       h_effic_vs_phi.push_back( dbe_->book1D("effic_vs_phi","effic vs phi",nintPhi,minPhi,maxPhi) );
00081       h_effic_vs_dxy.push_back( dbe_->book1D("effic_vs_dxy","effic vs dxy",nintDxy,minDxy,maxDxy) );
00082       h_effic_vs_dz.push_back( dbe_->book1D("effic_vs_dz","effic vs dz",nintDz,minDz,maxDz) );
00083       h_effic_vs_vertpos.push_back( dbe_->book1D("effic_vs_vertpos","effic vs vertpos",nintVertpos,minVertpos,maxVertpos) );
00084       h_effic_vs_zpos.push_back( dbe_->book1D("effic_vs_zpos","effic vs zpos",nintZpos,minZpos,maxZpos) );
00085 
00086       h_fakerate.push_back( dbe_->book1D("fakerate","fake rate vs #eta",nint,min,max) );
00087       h_fakeratePt.push_back( dbe_->book1D("fakeratePt","fake rate vs pT",nintpT,minpT,maxpT) );
00088       h_fake_vs_hit.push_back( dbe_->book1D("fakerate_vs_hit","fake rate vs hit",nintHit,minHit,maxHit) );
00089       h_fake_vs_phi.push_back( dbe_->book1D("fakerate_vs_phi","fake vs phi",nintPhi,minPhi,maxPhi) );
00090       h_fake_vs_dxy.push_back( dbe_->book1D("fakerate_vs_dxy","fake rate vs dxy",nintDxy,minDxy,maxDxy) );
00091       h_fake_vs_dz.push_back( dbe_->book1D("fakerate_vs_dz","fake vs dz",nintDz,minDz,maxDz) );
00092 
00093 
00095       h_recoeta.push_back( dbe_->book1D("num_reco_eta","N of reco track vs eta",nint,min,max) );
00096       h_assoceta.push_back( dbe_->book1D("num_assoc(simToReco)_eta","N of associated tracks (simToReco) vs eta",nint,min,max) );
00097       h_assoc2eta.push_back( dbe_->book1D("num_assoc(recoToSim)_eta","N of associated (recoToSim) tracks vs eta",nint,min,max) );
00098       h_simuleta.push_back( dbe_->book1D("num_simul_eta","N of simulated tracks vs eta",nint,min,max) );
00099       h_recopT.push_back( dbe_->book1D("num_reco_pT","N of reco track vs pT",nintpT,minpT,maxpT) );
00100       h_assocpT.push_back( dbe_->book1D("num_assoc(simToReco)_pT","N of associated tracks (simToReco) vs pT",nintpT,minpT,maxpT) );
00101       h_assoc2pT.push_back( dbe_->book1D("num_assoc(recoToSim)_pT","N of associated (recoToSim) tracks vs pT",nintpT,minpT,maxpT) );
00102       h_simulpT.push_back( dbe_->book1D("num_simul_pT","N of simulated tracks vs pT",nintpT,minpT,maxpT) );
00103       //
00104       h_recohit.push_back( dbe_->book1D("num_reco_hit","N of reco track vs hit",nintHit,minHit,maxHit) );
00105       h_assochit.push_back( dbe_->book1D("num_assoc(simToReco)_hit","N of associated tracks (simToReco) vs hit",nintHit,minHit,maxHit) );
00106       h_assoc2hit.push_back( dbe_->book1D("num_assoc(recoToSim)_hit","N of associated (recoToSim) tracks vs hit",nintHit,minHit,maxHit) );
00107       h_simulhit.push_back( dbe_->book1D("num_simul_hit","N of simulated tracks vs hit",nintHit,minHit,maxHit) );
00108       //
00109       h_recophi.push_back( dbe_->book1D("num_reco_phi","N of reco track vs phi",nintPhi,minPhi,maxPhi) );
00110       h_assocphi.push_back( dbe_->book1D("num_assoc(simToReco)_phi","N of associated tracks (simToReco) vs phi",nintPhi,minPhi,maxPhi) );
00111       h_assoc2phi.push_back( dbe_->book1D("num_assoc(recoToSim)_phi","N of associated (recoToSim) tracks vs phi",nintPhi,minPhi,maxPhi) );
00112       h_simulphi.push_back( dbe_->book1D("num_simul_phi","N of simulated tracks vs phi",nintPhi,minPhi,maxPhi) );
00113 
00114       h_recodxy.push_back( dbe_->book1D("num_reco_dxy","N of reco track vs dxy",nintDxy,minDxy,maxDxy) );
00115       h_assocdxy.push_back( dbe_->book1D("num_assoc(simToReco)_dxy","N of associated tracks (simToReco) vs dxy",nintDxy,minDxy,maxDxy) );
00116       h_assoc2dxy.push_back( dbe_->book1D("num_assoc(recoToSim)_dxy","N of associated (recoToSim) tracks vs dxy",nintDxy,minDxy,maxDxy) );
00117       h_simuldxy.push_back( dbe_->book1D("num_simul_dxy","N of simulated tracks vs dxy",nintDxy,minDxy,maxDxy) );
00118       
00119       h_recodz.push_back( dbe_->book1D("num_reco_dz","N of reco track vs dz",nintDz,minDz,maxDz) );
00120       h_assocdz.push_back( dbe_->book1D("num_assoc(simToReco)_dz","N of associated tracks (simToReco) vs dz",nintDz,minDz,maxDz) );
00121       h_assoc2dz.push_back( dbe_->book1D("num_assoc(recoToSim)_dz","N of associated (recoToSim) tracks vs dz",nintDz,minDz,maxDz) );
00122       h_simuldz.push_back( dbe_->book1D("num_simul_dz","N of simulated tracks vs dz",nintDz,minDz,maxDz) );
00123 
00124       h_assocvertpos.push_back( dbe_->book1D("num_assoc(simToReco)_vertpos","N of associated tracks (simToReco) vs transverse vert position",nintVertpos,minVertpos,maxVertpos) );
00125       h_simulvertpos.push_back( dbe_->book1D("num_simul_vertpos","N of simulated tracks vs transverse vert position",nintVertpos,minVertpos,maxVertpos) );
00126 
00127       h_assoczpos.push_back( dbe_->book1D("num_assoc(simToReco)_zpos","N of associated tracks (simToReco) vs z vert position",nintZpos,minZpos,maxZpos) );
00128       h_simulzpos.push_back( dbe_->book1D("num_simul_zpos","N of simulated tracks vs z vert position",nintZpos,minZpos,maxZpos) );
00129 
00130 
00132 
00133       h_eta.push_back( dbe_->book1D("eta", "pseudorapidity residue", 1000, -0.1, 0.1 ) );
00134       h_pt.push_back( dbe_->book1D("pullPt", "pull of p_{t}", 100, -10, 10 ) );
00135       h_pullTheta.push_back( dbe_->book1D("pullTheta","pull of #theta parameter",250,-25,25) );
00136       h_pullPhi.push_back( dbe_->book1D("pullPhi","pull of #phi parameter",250,-25,25) );
00137       h_pullDxy.push_back( dbe_->book1D("pullDxy","pull of dxy parameter",250,-25,25) );
00138       h_pullDz.push_back( dbe_->book1D("pullDz","pull of dz parameter",250,-25,25) );
00139       h_pullQoverp.push_back( dbe_->book1D("pullQoverp","pull of qoverp parameter",250,-25,25) );
00140       
00141       if (associators[ww]=="TrackAssociatorByChi2"){
00142         h_assochi2.push_back( dbe_->book1D("assocChi2","track association #chi^{2}",1000000,0,100000) );
00143         h_assochi2_prob.push_back(dbe_->book1D("assocChi2_prob","probability of association #chi^{2}",100,0,1));
00144       } else if (associators[ww]=="TrackAssociatorByHits"){
00145         h_assocFraction.push_back( dbe_->book1D("assocFraction","fraction of shared hits",200,0,2) );
00146         h_assocSharedHit.push_back(dbe_->book1D("assocSharedHit","number of shared hits",20,0,20));
00147       }
00148 
00149       chi2_vs_nhits.push_back( dbe_->book2D("chi2_vs_nhits","#chi^{2} vs nhits",25,0,25,100,0,10) );
00150       h_chi2meanhitsh.push_back( dbe_->bookProfile("chi2mean_vs_nhits","mean #chi^{2} vs nhits",25,0,25,100,0,10) );
00151 
00152       etares_vs_eta.push_back( dbe_->book2D("etares_vs_eta","etaresidue vs eta",nint,min,max,200,-0.1,0.1) );
00153       nrec_vs_nsim.push_back( dbe_->book2D("nrec_vs_nsim","nrec vs nsim",20,-0.5,19.5,20,-0.5,19.5) );
00154 
00155       chi2_vs_eta.push_back( dbe_->book2D("chi2_vs_eta","chi2_vs_eta",nint,min,max, 200, 0, 20 ));
00156       h_chi2meanh.push_back( dbe_->bookProfile("chi2mean","mean #chi^{2} vs #eta",nint,min,max, 200, 0, 20) );
00157       chi2_vs_phi.push_back( dbe_->book2D("chi2_vs_phi","#chi^{2} vs #phi",nintPhi,minPhi,maxPhi, 200, 0, 20 ) );
00158       h_chi2mean_vs_phi.push_back( dbe_->bookProfile("chi2mean_vs_phi","mean of #chi^{2} vs #phi",nintPhi,minPhi,maxPhi, 200, 0, 20) );
00159 
00160       nhits_vs_eta.push_back( dbe_->book2D("nhits_vs_eta","nhits vs eta",nint,min,max,nintHit,minHit,maxHit) );
00161       nDThits_vs_eta.push_back( dbe_->book2D("nDThits_vs_eta","# DT hits vs eta",nint,min,max,nintHit,minHit,maxHit) );
00162       nCSChits_vs_eta.push_back( dbe_->book2D("nCSChits_vs_eta","# CSC hits vs eta",nint,min,max,nintHit,minHit,maxHit) );
00163       nRPChits_vs_eta.push_back( dbe_->book2D("nRPChits_vs_eta","# RPC hits vs eta",nint,min,max,nintHit,minHit,maxHit) );
00164 
00165       h_DThits_eta.push_back( dbe_->bookProfile("DThits_eta","mean # DT hits vs eta",nint,min,max,nintHit,minHit,maxHit) );
00166       h_CSChits_eta.push_back( dbe_->bookProfile("CSChits_eta","mean # CSC hits vs eta",nint,min,max,nintHit,minHit,maxHit) );
00167       h_RPChits_eta.push_back( dbe_->bookProfile("RPChits_eta","mean # RPC hits vs eta",nint,min,max,nintHit,minHit,maxHit) );
00168       h_hits_eta.push_back( dbe_->bookProfile("hits_eta","mean #hits vs eta",nint,min,max,nintHit,minHit,maxHit) );
00169       nhits_vs_phi.push_back( dbe_->book2D("nhits_vs_phi","#hits vs #phi",nintPhi,minPhi,maxPhi,nintHit,minHit,maxHit) );
00170       h_hits_phi.push_back( dbe_->bookProfile("hits_phi","mean #hits vs #phi",nintPhi,minPhi,maxPhi, nintHit,minHit,maxHit) );
00171 
00172       nlosthits_vs_eta.push_back( dbe_->book2D("nlosthits_vs_eta","nlosthits vs eta",nint,min,max,nintHit,minHit,maxHit) );
00173       h_losthits_eta.push_back( dbe_->bookProfile("losthits_eta","losthits_eta",nint,min,max,nintHit,minHit,maxHit) );
00174 
00175       ptres_vs_eta.push_back(dbe_->book2D("ptres_vs_eta","ptres_vs_eta",nint,min,max, ptRes_nbin, ptRes_rangeMin, ptRes_rangeMax));
00176       h_ptrmsh.push_back( dbe_->book1D("ptres_vs_eta_Sigma","#sigma(#deltap_{t}/p_{t}) vs #eta",nint,min,max) );
00177 
00178       ptres_vs_phi.push_back( dbe_->book2D("ptres_vs_phi","p_{t} res vs #phi",nintPhi,minPhi,maxPhi, ptRes_nbin, ptRes_rangeMin, ptRes_rangeMax));
00179       h_ptmeanhPhi.push_back( dbe_->book1D("ptres_vs_phi_Mean","mean of p_{t} resolution vs #phi",nintPhi,minPhi,maxPhi));
00180       h_ptrmshPhi.push_back( dbe_->book1D("ptres_vs_phi_Sigma","#sigma(#deltap_{t}/p_{t}) vs #phi",nintPhi,minPhi,maxPhi) );
00181 
00182       ptres_vs_pt.push_back(dbe_->book2D("ptres_vs_pt","ptres_vs_pt",nintpT,minpT,maxpT, ptRes_nbin, ptRes_rangeMin, ptRes_rangeMax));
00183       h_ptmeanhPt.push_back( dbe_->book1D("ptres_vs_pt_Mean","mean of p_{t} resolution vs p_{t}",nintpT,minpT,maxpT));
00184       h_ptrmshPt.push_back( dbe_->book1D("ptres_vs_pt_Sigma","#sigma(#deltap_{t}/p_{t}) vs pT",nintpT,minpT,maxpT) );
00185 
00186       cotThetares_vs_eta.push_back(dbe_->book2D("cotThetares_vs_eta","cotThetares_vs_eta",nint,min,max,cotThetaRes_nbin, cotThetaRes_rangeMin, cotThetaRes_rangeMax));
00187       h_cotThetameanh.push_back( dbe_->book1D("cotThetares_vs_eta_Mean","#sigma(cot(#theta)) vs #eta Mean",nint,min,max) );
00188       h_cotThetarmsh.push_back( dbe_->book1D("cotThetares_vs_eta_Sigma","#sigma(cot(#theta)) vs #eta Sigma",nint,min,max) );
00189 
00190 
00191       cotThetares_vs_pt.push_back(dbe_->book2D("cotThetares_vs_pt","cotThetares_vs_pt",nintpT,minpT,maxpT, cotThetaRes_nbin, cotThetaRes_rangeMin, cotThetaRes_rangeMax));      
00192       h_cotThetameanhPt.push_back( dbe_->book1D("cotThetares_vs_pt_Mean","#sigma(cot(#theta)) vs pT Mean",nintpT,minpT,maxpT) );
00193       h_cotThetarmshPt.push_back( dbe_->book1D("cotThetares_vs_pt_Sigma","#sigma(cot(#theta)) vs pT Sigma",nintpT,minpT,maxpT) );
00194 
00195 
00196       phires_vs_eta.push_back(dbe_->book2D("phires_vs_eta","phires_vs_eta",nint,min,max, phiRes_nbin, phiRes_rangeMin, phiRes_rangeMax));
00197       h_phimeanh.push_back(dbe_->book1D("phires_vs_eta_Mean","mean of #phi res vs #eta",nint,min,max));
00198       h_phirmsh.push_back( dbe_->book1D("phires_vs_eta_Sigma","#sigma(#delta#phi) vs #eta",nint,min,max) );
00199 
00200       phires_vs_pt.push_back(dbe_->book2D("phires_vs_pt","phires_vs_pt",nintpT,minpT,maxpT, phiRes_nbin, phiRes_rangeMin, phiRes_rangeMax));
00201       h_phimeanhPt.push_back(dbe_->book1D("phires_vs_pt_Mean","mean of #phi res vs pT",nintpT,minpT,maxpT));
00202       h_phirmshPt.push_back( dbe_->book1D("phires_vs_pt_Sigma","#sigma(#delta#phi) vs pT",nintpT,minpT,maxpT) );
00203 
00204       phires_vs_phi.push_back(dbe_->book2D("phires_vs_phi","#phi res vs #phi",nintPhi,minPhi,maxPhi,phiRes_nbin, phiRes_rangeMin, phiRes_rangeMax));
00205       h_phimeanhPhi.push_back(dbe_->book1D("phires_vs_phi_Mean","mean of #phi res vs #phi",nintPhi,minPhi,maxPhi));
00206       h_phirmshPhi.push_back( dbe_->book1D("phires_vs_phi_Sigma","#sigma(#delta#phi) vs #phi",nintPhi,minPhi,maxPhi) );
00207 
00208       dxyres_vs_eta.push_back(dbe_->book2D("dxyres_vs_eta","dxyres_vs_eta",nint,min,max,dxyRes_nbin, dxyRes_rangeMin, dxyRes_rangeMax));
00209       h_dxymeanh.push_back( dbe_->book1D("dxyres_vs_eta_Mean","mean of dxyres vs #eta",nint,min,max) );
00210       h_dxyrmsh.push_back( dbe_->book1D("dxyres_vs_eta_Sigma","#sigma(#deltadxy) vs #eta",nint,min,max) );
00211 
00212       dxyres_vs_pt.push_back( dbe_->book2D("dxyres_vs_pt","dxyres_vs_pt",nintpT,minpT,maxpT,dxyRes_nbin, dxyRes_rangeMin, dxyRes_rangeMax));
00213       h_dxymeanhPt.push_back( dbe_->book1D("dxyres_vs_pt_Mean","mean of dxyres vs pT",nintpT,minpT,maxpT) );
00214       h_dxyrmshPt.push_back( dbe_->book1D("dxyres_vs_pt_Sigma","#sigmadxy vs pT",nintpT,minpT,maxpT) );
00215 
00216       dzres_vs_eta.push_back(dbe_->book2D("dzres_vs_eta","dzres_vs_eta",nint,min,max,dzRes_nbin, dzRes_rangeMin, dzRes_rangeMax));
00217       h_dzmeanh.push_back( dbe_->book1D("dzres_vs_eta_Mean","mean of dzres vs #eta",nint,min,max) );
00218       h_dzrmsh.push_back( dbe_->book1D("dzres_vs_eta_Sigma","#sigma(#deltadz) vs #eta",nint,min,max) );
00219 
00220       dzres_vs_pt.push_back(dbe_->book2D("dzres_vs_pt","dzres_vs_pt",nintpT,minpT,maxpT,dzRes_nbin, dzRes_rangeMin, dzRes_rangeMax));
00221       h_dzmeanhPt.push_back( dbe_->book1D("dzres_vs_pt_Mean","mean of dzres vs pT",nintpT,minpT,maxpT) );
00222       h_dzrmshPt.push_back( dbe_->book1D("dzres_vs_pt_Sigma","#sigma(#deltadz vs pT",nintpT,minpT,maxpT) );
00223 
00224       ptmean_vs_eta_phi.push_back(dbe_->bookProfile2D("ptmean_vs_eta_phi","mean p_{t} vs #eta and #phi",nintPhi,minPhi,maxPhi,nint,min,max,1000,0,1000));
00225       phimean_vs_eta_phi.push_back(dbe_->bookProfile2D("phimean_vs_eta_phi","mean #phi vs #eta and #phi",nintPhi,minPhi,maxPhi,nint,min,max,nintPhi,minPhi,maxPhi));
00226 
00227       //pulls of track params vs eta: to be used with fitslicesytool
00228       dxypull_vs_eta.push_back(dbe_->book2D("dxypull_vs_eta","dxypull_vs_eta",nint,min,max,100,-10,10));
00229       ptpull_vs_eta.push_back(dbe_->book2D("ptpull_vs_eta","ptpull_vs_eta",nint,min,max,100,-10,10)); 
00230       dzpull_vs_eta.push_back(dbe_->book2D("dzpull_vs_eta","dzpull_vs_eta",nint,min,max,100,-10,10)); 
00231       phipull_vs_eta.push_back(dbe_->book2D("phipull_vs_eta","phipull_vs_eta",nint,min,max,100,-10,10)); 
00232       thetapull_vs_eta.push_back(dbe_->book2D("thetapull_vs_eta","thetapull_vs_eta",nint,min,max,100,-10,10));
00233 
00234       h_dxypulletamean.push_back( dbe_->book1D("h_dxypulleta_Mean","mean of dxy pull vs #eta",nint,min,max) ); 
00235       h_ptpulletamean.push_back( dbe_->book1D("h_ptpulleta_Mean","mean of p_{t} pull vs #eta",nint,min,max) ); 
00236       h_dzpulletamean.push_back( dbe_->book1D("h_dzpulleta_Mean","mean of dz pull vs #eta",nint,min,max) ); 
00237       h_phipulletamean.push_back( dbe_->book1D("h_phipulleta_Mean","mean of #phi pull vs #eta",nint,min,max) ); 
00238       h_thetapulletamean.push_back( dbe_->book1D("h_thetapulleta_Mean","mean of #theta pull vs #eta",nint,min,max) );
00239       //      h_ptshiftetamean.push_back( dbe_->book1D("h_ptshifteta_Mean","<#deltapT/pT>[%] vs #eta",nint,min,max) ); 
00240 
00241       h_dxypulleta.push_back( dbe_->book1D("h_dxypulleta_Sigma","#sigma of dxy pull vs #eta",nint,min,max) ); 
00242       h_ptpulleta.push_back( dbe_->book1D("h_ptpulleta_Sigma","#sigma of p_{t} pull vs #eta",nint,min,max) ); 
00243       h_dzpulleta.push_back( dbe_->book1D("h_dzpulleta_Sigma","#sigma of dz pull vs #eta",nint,min,max) ); 
00244       h_phipulleta.push_back( dbe_->book1D("h_phipulleta_Sigma","#sigma of #phi pull vs #eta",nint,min,max) ); 
00245       h_thetapulleta.push_back( dbe_->book1D("h_thetapulleta_Sigma","#sigma of #theta pull vs #eta",nint,min,max) );
00246       h_ptshifteta.push_back( dbe_->book1D("ptres_vs_eta_Mean","<#deltapT/pT>[%] vs #eta",nint,min,max) ); 
00247 
00248       //pulls of track params vs phi
00249       ptpull_vs_phi.push_back(dbe_->book2D("ptpull_vs_phi","p_{t} pull vs #phi",nintPhi,minPhi,maxPhi,100,-10,10)); 
00250       phipull_vs_phi.push_back(dbe_->book2D("phipull_vs_phi","#phi pull vs #phi",nintPhi,minPhi,maxPhi,100,-10,10)); 
00251       thetapull_vs_phi.push_back(dbe_->book2D("thetapull_vs_phi","#theta pull vs #phi",nintPhi,minPhi,maxPhi,100,-10,10));
00252 
00253       h_ptpullphimean.push_back( dbe_->book1D("h_ptpullphi_Mean","mean of p_{t} pull vs #phi",nintPhi,minPhi,maxPhi) ); 
00254       h_phipullphimean.push_back( dbe_->book1D("h_phipullphi_Mean","mean of #phi pull vs #phi",nintPhi,minPhi,maxPhi) );
00255       h_thetapullphimean.push_back( dbe_->book1D("h_thetapullphi_Mean","mean of #theta pull vs #phi",nintPhi,minPhi,maxPhi) );
00256 
00257       h_ptpullphi.push_back( dbe_->book1D("h_ptpullphi_Sigma","#sigma of p_{t} pull vs #phi",nintPhi,minPhi,maxPhi) ); 
00258       h_phipullphi.push_back( dbe_->book1D("h_phipullphi_Sigma","#sigma of #phi pull vs #phi",nintPhi,minPhi,maxPhi) );
00259       h_thetapullphi.push_back( dbe_->book1D("h_thetapullphi_Sigma","#sigma of #theta pull vs #phi",nintPhi,minPhi,maxPhi) );
00260   
00261       
00262       nrecHit_vs_nsimHit_sim2rec.push_back( dbe_->book2D("nrecHit_vs_nsimHit_sim2rec","nrecHit vs nsimHit (Sim2RecAssoc)",nintHit,minHit,maxHit, nintHit,minHit,maxHit ));
00263       nrecHit_vs_nsimHit_rec2sim.push_back( dbe_->book2D("nrecHit_vs_nsimHit_rec2sim","nrecHit vs nsimHit (Rec2simAssoc)",nintHit,minHit,maxHit, nintHit,minHit,maxHit ));
00264       
00265       if (MABH) {
00266         h_PurityVsQuality.push_back( dbe_->book2D("PurityVsQuality","Purity vs Quality (MABH)",20,0.01,1.01,20,0.01,1.01) );
00267         h_effic_Quality05.push_back( dbe_->book1D("effic_Q05","efficiency vs #eta (Quality>0.5)",nint,min,max) );
00268         h_effic_Quality075.push_back( dbe_->book1D("effic_Q075","efficiency vs #eta (Quality>0.75)",nint,min,max) );
00269         h_efficPt_Quality05.push_back( dbe_->book1D("efficPt_Q05","efficiency vs pT (Quality>0.5)",nintpT,minpT,maxpT) );
00270         h_efficPt_Quality075.push_back( dbe_->book1D("efficPt_Q075","efficiency vs pT (Quality>0.75)",nintpT,minpT,maxpT) );
00271         h_effic_vs_phi_Quality05.push_back( dbe_->book1D("effic_vs_phi_Q05","effic vs phi (Quality>0.5)",nintPhi,minPhi,maxPhi) );
00272         h_effic_vs_phi_Quality075.push_back( dbe_->book1D("effic_vs_phi_Q075","effic vs phi (Quality>0.75)",nintPhi,minPhi,maxPhi) );
00273         //
00274         h_assoceta_Quality05.push_back( dbe_->book1D("num_assoc(simToReco)_eta_Q05","N of associated tracks (simToReco) vs eta (Quality>0.5)",nint,min,max) );
00275         h_assoceta_Quality075.push_back( dbe_->book1D("num_assoc(simToReco)_eta_Q075","N of associated tracks (simToReco) vs eta (Quality>0.75)",nint,min,max) );
00276         h_assocpT_Quality05.push_back( dbe_->book1D("num_assoc(simToReco)_pT_Q05","N of associated tracks (simToReco) vs pT (Quality>0.5)",nintpT,minpT,maxpT) );
00277         h_assocpT_Quality075.push_back( dbe_->book1D("num_assoc(simToReco)_pT_Q075","N of associated tracks (simToReco) vs pT (Quality>0.75)",nintpT,minpT,maxpT) );
00278         h_assocphi_Quality05.push_back( dbe_->book1D("num_assoc(simToReco)_phi_Q05","N of associated tracks (simToReco) vs phi (Quality>0.5)",nintPhi,minPhi,maxPhi) );
00279         h_assocphi_Quality075.push_back( dbe_->book1D("num_assoc(simToReco)_phi_Q075","N of associated tracks (simToReco) vs phi (Quality>0.75)",nintPhi,minPhi,maxPhi) );
00280       }
00281 
00282       if(useLogPt){
00283       BinLogX(dzres_vs_pt[j]->getTH2F());
00284       BinLogX(h_dzmeanhPt[j]->getTH1F());
00285       BinLogX(h_dzrmshPt[j]->getTH1F());
00286 
00287       BinLogX(dxyres_vs_pt[j]->getTH2F());
00288       BinLogX(h_dxymeanhPt[j]->getTH1F());
00289       BinLogX(h_dxyrmshPt[j]->getTH1F());
00290 
00291       BinLogX(phires_vs_pt[j]->getTH2F());
00292       BinLogX(h_phimeanhPt[j]->getTH1F());
00293       BinLogX(h_phirmshPt[j]->getTH1F());
00294 
00295       BinLogX(cotThetares_vs_pt[j]->getTH2F());
00296       BinLogX(h_cotThetameanhPt[j]->getTH1F());
00297       BinLogX(h_cotThetarmshPt[j]->getTH1F());
00298 
00299       BinLogX(ptres_vs_pt[j]->getTH2F());
00300       BinLogX(h_ptmeanhPt[j]->getTH1F());
00301       BinLogX(h_ptrmshPt[j]->getTH1F());
00302 
00303       BinLogX(h_efficPt[j]->getTH1F());
00304       BinLogX(h_fakeratePt[j]->getTH1F());
00305       BinLogX(h_recopT[j]->getTH1F());
00306       BinLogX(h_assocpT[j]->getTH1F());
00307       BinLogX(h_assoc2pT[j]->getTH1F());
00308       BinLogX(h_simulpT[j]->getTH1F());
00309 
00310       if (MABH) 
00311         {
00312           BinLogX(h_efficPt_Quality05[j]->getTH1F());
00313           BinLogX(h_efficPt_Quality075[j]->getTH1F());
00314           //
00315           BinLogX(h_assocpT_Quality05[j]->getTH1F());
00316           BinLogX(h_assocpT_Quality075[j]->getTH1F());
00317         }
00318       
00319       j++;
00320       }
00321     }
00322   }
00323   if (UseAssociators) {
00324     edm::ESHandle<TrackAssociatorBase> theAssociator;
00325     for (unsigned int w=0;w<associators.size();w++) {
00326       setup.get<TrackAssociatorRecord>().get(associators[w],theAssociator);
00327       associator.push_back( theAssociator.product() );
00328     }
00329   }
00330 }
00331 
00332 void MuonTrackValidator::analyze(const edm::Event& event, const edm::EventSetup& setup){
00333   using namespace reco;
00334   
00335   edm::LogInfo("MuonTrackValidator") << "\n====================================================" << "\n"
00336                                      << "Analyzing new event" << "\n"
00337                                      << "====================================================\n" << "\n";
00338   edm::ESHandle<ParametersDefinerForTP> parametersDefinerTP; 
00339   setup.get<TrackAssociatorRecord>().get(parametersDefiner,parametersDefinerTP);    
00340   
00341   edm::Handle<TrackingParticleCollection>  TPCollectionHeff ;
00342   event.getByLabel(label_tp_effic,TPCollectionHeff);
00343   const TrackingParticleCollection tPCeff = *(TPCollectionHeff.product());
00344   
00345   edm::Handle<TrackingParticleCollection>  TPCollectionHfake ;
00346   event.getByLabel(label_tp_fake,TPCollectionHfake);
00347   const TrackingParticleCollection tPCfake = *(TPCollectionHfake.product());
00348   
00349   edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00350   event.getByLabel(bsSrc,recoBeamSpotHandle);
00351   reco::BeamSpot bs = *recoBeamSpotHandle;      
00352   
00353   int w=0;
00354   for (unsigned int ww=0;ww<associators.size();ww++){
00355     for (unsigned int www=0;www<label.size();www++){
00356       //
00357       //get collections from the event
00358       //
00359       edm::Handle<View<Track> >  trackCollection;
00360 
00361       reco::RecoToSimCollection recSimColl;
00362       reco::SimToRecoCollection simRecColl;
00363       unsigned int trackCollectionSize = 0;
00364 
00365       //      if(!event.getByLabel(label[www], trackCollection)&&ignoremissingtkcollection_) continue;
00366       if(!event.getByLabel(label[www], trackCollection)&&ignoremissingtkcollection_) {
00367 
00368         recSimColl.post_insert();
00369         simRecColl.post_insert();
00370 
00371       }
00372 
00373       else {
00374 
00375         trackCollectionSize = trackCollection->size();
00376         //associate tracks
00377         if(UseAssociators){
00378           edm::LogVerbatim("MuonTrackValidator") << "Analyzing " 
00379                                                  << label[www].process()<<":"
00380                                                  << label[www].label()<<":"
00381                                                  << label[www].instance()<<" with "
00382                                                  << associators[ww].c_str() <<"\n";
00383         
00384           LogTrace("MuonTrackValidator") << "Calling associateRecoToSim method" << "\n";
00385           recSimColl=associator[ww]->associateRecoToSim(trackCollection,
00386                                                         TPCollectionHfake,
00387                                                         &event);
00388           LogTrace("MuonTrackValidator") << "Calling associateSimToReco method" << "\n";
00389           simRecColl=associator[ww]->associateSimToReco(trackCollection,
00390                                                         TPCollectionHeff, 
00391                                                         &event);
00392         }
00393         else{
00394           edm::LogVerbatim("MuonTrackValidator") << "Analyzing " 
00395                                                  << label[www].process()<<":"
00396                                                  << label[www].label()<<":"
00397                                                  << label[www].instance()<<" with "
00398                                                  << associatormap.process()<<":"
00399                                                  << associatormap.label()<<":"
00400                                                  << associatormap.instance()<<"\n";
00401         
00402           Handle<reco::SimToRecoCollection > simtorecoCollectionH;
00403           event.getByLabel(associatormap,simtorecoCollectionH);
00404           simRecColl= *(simtorecoCollectionH.product()); 
00405         
00406           Handle<reco::RecoToSimCollection > recotosimCollectionH;
00407           event.getByLabel(associatormap,recotosimCollectionH);
00408           recSimColl= *(recotosimCollectionH.product()); 
00409         }
00410 
00411       }
00412 
00413       
00414       //
00415       //fill simulation histograms
00416       //compute number of tracks per eta interval
00417       //
00418       edm::LogVerbatim("MuonTrackValidator") << "\n# of TrackingParticles: " << tPCeff.size() << "\n";
00419       int ats = 0;
00420       int st=0;
00421       for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
00422         bool TP_is_matched = false;
00423         double quality = 0.;
00424         bool Quality05  = false;
00425         bool Quality075 = false;
00426 
00427         TrackingParticleRef tpr(TPCollectionHeff, i);
00428         TrackingParticle* tp=const_cast<TrackingParticle*>(tpr.get());
00429         ParticleBase::Vector momentumTP; 
00430         ParticleBase::Point vertexTP;
00431         double dxySim = 0;
00432         double dzSim = 0; 
00433 
00434         //If the TrackingParticle is collison like, get the momentum and vertex at production state
00435         if(parametersDefiner=="LhcParametersDefinerForTP")
00436           {
00437             if(! tpSelector(*tp)) continue;
00438             momentumTP = tp->momentum();
00439             vertexTP = tp->vertex();
00440             //Calcualte the impact parameters w.r.t. PCA
00441             ParticleBase::Vector momentum = parametersDefinerTP->momentum(event,setup,*tp);
00442             ParticleBase::Point vertex = parametersDefinerTP->vertex(event,setup,*tp);
00443             dxySim = (-vertex.x()*sin(momentum.phi())+vertex.y()*cos(momentum.phi()));
00444             dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/sqrt(momentum.perp2()) * momentum.z()/sqrt(momentum.perp2());
00445           }
00446         //If the TrackingParticle is comics, get the momentum and vertex at PCA
00447         if(parametersDefiner=="CosmicParametersDefinerForTP")
00448           {
00449             if(! cosmictpSelector(*tp,&bs,event,setup)) continue;       
00450             momentumTP = parametersDefinerTP->momentum(event,setup,*tp);
00451             vertexTP = parametersDefinerTP->vertex(event,setup,*tp);
00452             dxySim = (-vertexTP.x()*sin(momentumTP.phi())+vertexTP.y()*cos(momentumTP.phi()));
00453             dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/sqrt(momentumTP.perp2()) * momentumTP.z()/sqrt(momentumTP.perp2());
00454           }
00455         edm::LogVerbatim("MuonTrackValidator") <<"--------------------Selected TrackingParticle #"<<tpr.key();
00456         st++;
00457 
00458         h_ptSIM[w]->Fill(sqrt(momentumTP.perp2()));
00459         h_etaSIM[w]->Fill(momentumTP.eta());
00460         h_vertposSIM[w]->Fill(sqrt(vertexTP.perp2()));
00461         
00462         std::vector<std::pair<RefToBase<Track>, double> > rt;
00463         if(simRecColl.find(tpr) != simRecColl.end()){
00464           rt = (std::vector<std::pair<RefToBase<Track>, double> >) simRecColl[tpr];
00465           if (rt.size()!=0) {
00466             RefToBase<Track> assoc_recoTrack = rt.begin()->first;
00467             edm::LogVerbatim("MuonTrackValidator")<<"-----------------------------associated Track #"<<assoc_recoTrack.key();
00468             TP_is_matched = true;
00469             ats++;
00470             quality = rt.begin()->second;
00471             edm::LogVerbatim("MuonTrackValidator") << "TrackingParticle #" <<tpr.key()  
00472                                                    << " with pt=" << sqrt(momentumTP.perp2()) 
00473                                                    << " associated with quality:" << quality <<"\n";
00474             if (MABH) {
00475               if (quality > 0.75) {
00476                 Quality075 = true;
00477                 Quality05  = true;
00478               } 
00479               else if (quality > 0.5) {
00480                 Quality05  = true;
00481               }
00482             }       
00483           }
00484         }else{
00485           edm::LogVerbatim("MuonTrackValidator") 
00486             << "TrackingParticle #" << tpr.key()
00487             << " with pt,eta,phi: " 
00488             << sqrt(momentumTP.perp2()) << " , "
00489             << momentumTP.eta() << " , "
00490             << momentumTP.phi() << " , "
00491             << " NOT associated to any reco::Track" << "\n";
00492         }
00493         
00494         for (unsigned int f=0; f<etaintervals[w].size()-1; f++){
00495           if (getEta(momentumTP.eta())>etaintervals[w][f]&&
00496               getEta(momentumTP.eta())<etaintervals[w][f+1]) {
00497             totSIMeta[w][f]++;
00498             if (TP_is_matched) {
00499               totASSeta[w][f]++;
00500 
00501               if (MABH) {
00502                 if (Quality075) {
00503                   totASSeta_Quality075[w][f]++;
00504                   totASSeta_Quality05[w][f]++;
00505                 }
00506                 else if (Quality05) {
00507                   totASSeta_Quality05[w][f]++;
00508                 }
00509               }
00510             }
00511           }
00512         } // END for (unsigned int f=0; f<etaintervals[w].size()-1; f++){
00513         
00514         for (unsigned int f=0; f<phiintervals[w].size()-1; f++){
00515           if (momentumTP.phi() > phiintervals[w][f]&&
00516               momentumTP.phi() <phiintervals[w][f+1]) {
00517             totSIM_phi[w][f]++;
00518             if (TP_is_matched) {
00519               totASS_phi[w][f]++;
00520               
00521               if (MABH) {
00522                 if (Quality075) {
00523                   totASS_phi_Quality075[w][f]++;
00524                   totASS_phi_Quality05[w][f]++;
00525                 }
00526                 else if (Quality05) {
00527                   totASS_phi_Quality05[w][f]++;
00528                 }
00529               }
00530             }
00531           }
00532         } // END for (unsigned int f=0; f<phiintervals[w].size()-1; f++){
00533         
00534         
00535         for (unsigned int f=0; f<pTintervals[w].size()-1; f++){
00536           if (getPt(sqrt(momentumTP.perp2()))>pTintervals[w][f]&&
00537               getPt(sqrt(momentumTP.perp2()))<pTintervals[w][f+1]) {
00538             totSIMpT[w][f]++;
00539             if (TP_is_matched) {
00540               totASSpT[w][f]++;
00541               
00542               if (MABH) {
00543                 if (Quality075) {
00544                   totASSpT_Quality075[w][f]++;
00545                   totASSpT_Quality05[w][f]++;
00546                 }
00547                 else if (Quality05) { 
00548                   totASSpT_Quality05[w][f]++;
00549                 }
00550               }
00551             }
00552           }
00553         } // END for (unsigned int f=0; f<pTintervals[w].size()-1; f++){
00554         
00555         for (unsigned int f=0; f<dxyintervals[w].size()-1; f++){
00556           if (dxySim>dxyintervals[w][f]&&
00557               dxySim<dxyintervals[w][f+1]) {
00558             totSIM_dxy[w][f]++;
00559             if (TP_is_matched) {
00560               totASS_dxy[w][f]++;
00561             }
00562           }
00563         } // END for (unsigned int f=0; f<dxyintervals[w].size()-1; f++){
00564 
00565         for (unsigned int f=0; f<dzintervals[w].size()-1; f++){
00566           if (dzSim>dzintervals[w][f]&&
00567               dzSim<dzintervals[w][f+1]) {
00568             totSIM_dz[w][f]++;
00569             if (TP_is_matched) {
00570               totASS_dz[w][f]++;
00571             }
00572           }
00573         } // END for (unsigned int f=0; f<dzintervals[w].size()-1; f++){
00574 
00575         for (unsigned int f=0; f<vertposintervals[w].size()-1; f++){
00576           if (sqrt(vertexTP.perp2())>vertposintervals[w][f]&&
00577               sqrt(vertexTP.perp2())<vertposintervals[w][f+1]) {
00578             totSIM_vertpos[w][f]++;
00579             if (TP_is_matched) {
00580               totASS_vertpos[w][f]++;
00581             }
00582           }
00583         } // END for (unsigned int f=0; f<vertposintervals[w].size()-1; f++){
00584 
00585         for (unsigned int f=0; f<zposintervals[w].size()-1; f++){
00586           if (vertexTP.z()>zposintervals[w][f]&&
00587               vertexTP.z()<zposintervals[w][f+1]) {
00588             totSIM_zpos[w][f]++;
00589             if (TP_is_matched) {
00590               totASS_zpos[w][f]++;
00591             }
00592           }
00593         } // END for (unsigned int f=0; f<zposintervals[w].size()-1; f++){
00594         
00595         std::vector<PSimHit> simhits;
00596         
00597         if (usetracker && usemuon) {
00598           simhits=tp->trackPSimHit();
00599         } 
00600         else if (!usetracker && usemuon) {
00601           simhits=tp->trackPSimHit(DetId::Muon);
00602         }
00603         else if (usetracker && !usemuon) {
00604           simhits=tp->trackPSimHit(DetId::Tracker);
00605         }
00606         
00607         int tmp = std::min((int)(simhits.end()-simhits.begin()),int(maxHit-1));
00608         edm::LogVerbatim("MuonTrackValidator") << "\t N simhits = "<< (int)(simhits.end()-simhits.begin())<<"\n";
00609 
00610         totSIM_hit[w][tmp]++;
00611         if (TP_is_matched) totASS_hit[w][tmp]++;
00612 
00613         if (TP_is_matched)       
00614           {
00615             RefToBase<Track> assoctrack = rt.begin()->first; 
00616             nrecHit_vs_nsimHit_sim2rec[w]->Fill( assoctrack->numberOfValidHits(),(int)(simhits.end()-simhits.begin() ));
00617           }
00618       } // End  for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
00619       if (st!=0) h_tracksSIM[w]->Fill(st);
00620       
00621 
00622       //
00623       //fill reconstructed track histograms
00624       // 
00625       edm::LogVerbatim("MuonTrackValidator") << "\n# of reco::Tracks with "
00626                                          << label[www].process()<<":"
00627                                          << label[www].label()<<":"
00628                                          << label[www].instance()
00629                                          << ": " << trackCollectionSize << "\n";
00630       int at=0;
00631       int rT=0;
00632       for(View<Track>::size_type i=0; i<trackCollectionSize; ++i){
00633         bool Track_is_matched = false; 
00634         RefToBase<Track> track(trackCollection, i);
00635         rT++;
00636 
00637         std::vector<std::pair<TrackingParticleRef, double> > tp;
00638         TrackingParticleRef tpr;
00639 
00640         // new logic (bidirectional)
00641         if (BiDirectional_RecoToSim_association) {        
00642           edm::LogVerbatim("MuonTrackValidator")<<"----------------------------------------Track #"<< track.key();
00643 
00644           if(recSimColl.find(track) != recSimColl.end()) {
00645             tp = recSimColl[track];         
00646             if (tp.size() != 0) {
00647               tpr = tp.begin()->first;        
00648               // RtS and StR must associate the same pair !
00649               if(simRecColl.find(tpr) != simRecColl.end()) {
00650                 std::vector<std::pair<RefToBase<Track>, double> > track_checkback  = simRecColl[tpr];
00651                 RefToBase<Track> assoc_track_checkback;
00652                 assoc_track_checkback = track_checkback.begin()->first;
00653 
00654                 if ( assoc_track_checkback.key() == track.key() ) {
00655                   edm::LogVerbatim("MuonTrackValidator")<<"------------------associated TrackingParticle #"<<tpr.key();
00656                   Track_is_matched = true;
00657                   at++;
00658                   double Purity = tp.begin()->second;
00659                   double Quality = track_checkback.begin()->second;
00660                   edm::LogVerbatim("MuonTrackValidator") << "reco::Track #" << track.key() << " with pt=" << track->pt() 
00661                                                          << " associated with quality:" << Purity <<"\n";
00662                   if (MABH) h_PurityVsQuality[w]->Fill(Quality,Purity);
00663                 }
00664               }
00665             }
00666           }
00667 
00668           if (!Track_is_matched) edm::LogVerbatim("MuonTrackValidator") 
00669             << "reco::Track #" << track.key() << " with pt=" << track->pt() << " NOT associated to any TrackingParticle" << "\n";
00670         }
00671         // old logic (bugged)
00672         else {
00673           if(recSimColl.find(track) != recSimColl.end()){
00674             tp = recSimColl[track];
00675             if (tp.size()!=0) {
00676               Track_is_matched = true;
00677               tpr = tp.begin()->first;
00678               at++;
00679               edm::LogVerbatim("MuonTrackValidator") << "reco::Track #" << track.key() << " with pt=" << track->pt() 
00680                                                      << " associated with quality:" << tp.begin()->second <<"\n";
00681             }
00682           } else {
00683             edm::LogVerbatim("MuonTrackValidator") << "reco::Track #" << track.key() << " with pt=" << track->pt()
00684                                                    << " NOT associated to any TrackingParticle" << "\n";                  
00685           }
00686         }
00687         
00688         //Compute fake rate vs eta
00689         for (unsigned int f=0; f<etaintervals[w].size()-1; f++){
00690           if (getEta(track->momentum().eta())>etaintervals[w][f]&&
00691               getEta(track->momentum().eta())<etaintervals[w][f+1]) {
00692             totRECeta[w][f]++; 
00693             if (Track_is_matched) {
00694               totASS2eta[w][f]++;
00695             }           
00696           }
00697         } // End for (unsigned int f=0; f<etaintervals[w].size()-1; f++){
00698 
00699         for (unsigned int f=0; f<phiintervals[w].size()-1; f++){
00700           if (track->momentum().phi()>phiintervals[w][f]&&
00701               track->momentum().phi()<phiintervals[w][f+1]) {
00702             totREC_phi[w][f]++; 
00703             if (Track_is_matched) {
00704               totASS2_phi[w][f]++;
00705             }           
00706           }
00707         } // End for (unsigned int f=0; f<phiintervals[w].size()-1; f++){
00708 
00709         
00710         for (unsigned int f=0; f<pTintervals[w].size()-1; f++){
00711           if (getPt(sqrt(track->momentum().perp2()))>pTintervals[w][f]&&
00712               getPt(sqrt(track->momentum().perp2()))<pTintervals[w][f+1]) {
00713             totRECpT[w][f]++; 
00714             if (Track_is_matched) {
00715               totASS2pT[w][f]++;
00716             }         
00717           }
00718         } // End for (unsigned int f=0; f<pTintervals[w].size()-1; f++){
00719 
00720         for (unsigned int f=0; f<dxyintervals[w].size()-1; f++){
00721           if (track->dxy(bs.position())>dxyintervals[w][f]&&
00722               track->dxy(bs.position())<dxyintervals[w][f+1]) {
00723             totREC_dxy[w][f]++; 
00724             if (Track_is_matched) {
00725               totASS2_dxy[w][f]++;
00726             }         
00727           }
00728         } // End for (unsigned int f=0; f<dxyintervals[w].size()-1; f++){
00729 
00730         for (unsigned int f=0; f<dzintervals[w].size()-1; f++){
00731           if (track->dz(bs.position())>dzintervals[w][f]&&
00732               track->dz(bs.position())<dzintervals[w][f+1]) {
00733             totREC_dz[w][f]++; 
00734             if (Track_is_matched) {
00735               totASS2_dz[w][f]++;
00736             }         
00737           }
00738         } // End for (unsigned int f=0; f<dzintervals[w].size()-1; f++){
00739 
00740         int tmp = std::min((int)track->found(),int(maxHit-1));
00741         totREC_hit[w][tmp]++;
00742         if (Track_is_matched) totASS2_hit[w][tmp]++;
00743 
00744         edm::LogVerbatim("MuonTrackValidator") << "\t N valid rechits = "<< (int)track->found() <<"\n";
00745 
00746         //Fill other histos
00747         try{
00748           if (!Track_is_matched) continue;
00749 
00750           if (associators[ww]=="TrackAssociatorByChi2"){
00751             //association chi2
00752             double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
00753             h_assochi2[www]->Fill(assocChi2);
00754             h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
00755           }
00756           else if (associators[ww]=="TrackAssociatorByHits"){
00757             double fraction = tp.begin()->second;
00758             h_assocFraction[www]->Fill(fraction);
00759             h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
00760           }
00761     
00762           //nchi2 and hits global distributions
00763           h_nchi2[w]->Fill(track->normalizedChi2());
00764           h_nchi2_prob[w]->Fill(TMath::Prob(track->chi2(),(int)track->ndof()));
00765           h_hits[w]->Fill(track->numberOfValidHits());
00766           h_losthits[w]->Fill(track->numberOfLostHits());
00767           chi2_vs_nhits[w]->Fill(track->numberOfValidHits(),track->normalizedChi2());
00768           h_charge[w]->Fill( track->charge() );
00769           
00770           //Get tracking particle parameters at point of closest approach to the beamline
00771           ParticleBase::Vector momentumTP = parametersDefinerTP->momentum(event,setup,*(tpr.get()));
00772           ParticleBase::Point vertexTP = parametersDefinerTP->vertex(event,setup,*(tpr.get()));
00773           double ptSim = sqrt(momentumTP.perp2());
00774           double qoverpSim = tpr->charge()/sqrt(momentumTP.x()*momentumTP.x()+momentumTP.y()*momentumTP.y()+momentumTP.z()*momentumTP.z());
00775           double thetaSim = momentumTP.theta();
00776           double lambdaSim = M_PI/2-momentumTP.theta();
00777           double phiSim    = momentumTP.phi();
00778           double dxySim    = (-vertexTP.x()*sin(momentumTP.phi())+vertexTP.y()*cos(momentumTP.phi()));
00779           double dzSim     = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/sqrt(momentumTP.perp2()) * momentumTP.z()/sqrt(momentumTP.perp2());
00780           
00781           TrackBase::ParameterVector rParameters = track->parameters();
00782 
00783           double qoverpRec(0);
00784           double qoverpErrorRec(0); 
00785           double ptRec(0);
00786           double ptErrorRec(0);
00787           double lambdaRec(0); 
00788           double lambdaErrorRec(0);
00789           double phiRec(0);
00790           double phiErrorRec(0);
00791 
00792 
00793           //loop to decide whether to take gsfTrack (utilisation of mode-function) or common track
00794           const GsfTrack* gsfTrack(0);
00795           if(useGsf){
00796             gsfTrack = dynamic_cast<const GsfTrack*>(&(*track));
00797             if (gsfTrack==0) edm::LogInfo("MuonTrackValidator") << "Trying to access mode for a non-GsfTrack";
00798           }
00799           
00800           if (gsfTrack) {
00801             // get values from mode
00802             getRecoMomentum(*gsfTrack, ptRec, ptErrorRec, qoverpRec, qoverpErrorRec, 
00803                             lambdaRec,lambdaErrorRec, phiRec, phiErrorRec); 
00804           }
00805          
00806           else {
00807             // get values from track (without mode) 
00808             getRecoMomentum(*track, ptRec, ptErrorRec, qoverpRec, qoverpErrorRec, 
00809                             lambdaRec,lambdaErrorRec, phiRec, phiErrorRec); 
00810           }
00811          
00812           double thetaRec = track->theta();
00813           double ptError = ptErrorRec;
00814           double ptres = ptRec - ptSim; 
00815           double etares = track->eta()-momentumTP.Eta();
00816           double dxyRec    = track->dxy(bs.position());
00817           double dzRec     = track->dz(bs.position());
00818           // eta residue; pt, k, theta, phi, dxy, dz pulls
00819           double qoverpPull=(qoverpRec-qoverpSim)/qoverpErrorRec;
00820           double thetaPull=(lambdaRec-lambdaSim)/lambdaErrorRec;
00821           double phiDiff = phiRec - phiSim;
00822           if (abs(phiDiff) > M_PI) {
00823             if (phiDiff >0.) phiDiff = phiDiff - 2.*M_PI;
00824             else phiDiff = phiDiff + 2.*M_PI;
00825           }
00826           double phiPull=phiDiff/phiErrorRec;
00827           double dxyPull=(dxyRec-dxySim)/track->dxyError();
00828           double dzPull=(dzRec-dzSim)/track->dzError();
00829 
00830           double contrib_Qoverp = ((qoverpRec-qoverpSim)/qoverpErrorRec)*
00831             ((qoverpRec-qoverpSim)/qoverpErrorRec)/5;
00832           double contrib_dxy = ((dxyRec-dxySim)/track->dxyError())*((dxyRec-dxySim)/track->dxyError())/5;
00833           double contrib_dz = ((dzRec-dzSim)/track->dzError())*((dzRec-dzSim)/track->dzError())/5;
00834           double contrib_theta = ((lambdaRec-lambdaSim)/lambdaErrorRec)*
00835             ((lambdaRec-lambdaSim)/lambdaErrorRec)/5;
00836           double contrib_phi = (phiDiff/phiErrorRec)*(phiDiff/phiErrorRec)/5;
00837           
00838           LogTrace("MuonTrackValidator") << "assocChi2=" << tp.begin()->second << "\n"
00839                                          << "" <<  "\n"
00840                                          << "ptREC=" << ptRec << "\n"
00841                                          << "etaREC=" << track->eta() << "\n"
00842                                          << "qoverpREC=" << qoverpRec << "\n"
00843                                          << "dxyREC=" << dxyRec << "\n"
00844                                          << "dzREC=" << dzRec << "\n"
00845                                          << "thetaREC=" << track->theta() << "\n"
00846                                          << "phiREC=" << phiRec << "\n"
00847                                          << "" <<  "\n"
00848                                          << "qoverpError()=" << qoverpErrorRec << "\n"
00849                                          << "dxyError()=" << track->dxyError() << "\n"
00850                                          << "dzError()=" << track->dzError() << "\n"
00851                                          << "thetaError()=" << lambdaErrorRec << "\n"
00852                                          << "phiError()=" << phiErrorRec << "\n"
00853                                          << "" <<  "\n"
00854                                          << "ptSIM=" << ptSim << "\n"
00855                                          << "etaSIM=" << momentumTP.Eta() << "\n"    
00856                                          << "qoverpSIM=" << qoverpSim << "\n"
00857                                          << "dxySIM=" << dxySim << "\n"
00858                                          << "dzSIM=" << dzSim << "\n"
00859                                          << "thetaSIM=" << M_PI/2-lambdaSim << "\n"
00860                                          << "phiSIM=" << phiSim << "\n"
00861                                          << "" << "\n"
00862                                          << "contrib_Qoverp=" << contrib_Qoverp << "\n"
00863                                          << "contrib_dxy=" << contrib_dxy << "\n"
00864                                          << "contrib_dz=" << contrib_dz << "\n"
00865                                          << "contrib_theta=" << contrib_theta << "\n"
00866                                          << "contrib_phi=" << contrib_phi << "\n"
00867                                          << "" << "\n"
00868                                          <<"chi2PULL="<<contrib_Qoverp+contrib_dxy+contrib_dz+contrib_theta+contrib_phi<<"\n";
00869           
00870           h_pullQoverp[w]->Fill(qoverpPull);
00871           h_pullTheta[w]->Fill(thetaPull);
00872           h_pullPhi[w]->Fill(phiPull);
00873           h_pullDxy[w]->Fill(dxyPull);
00874           h_pullDz[w]->Fill(dzPull);
00875 
00876 
00877           h_pt[w]->Fill(ptres/ptError);
00878           h_eta[w]->Fill(etares);
00879           etares_vs_eta[w]->Fill(getEta(track->eta()),etares);
00880  
00881 
00882           //chi2 and #hit vs eta: fill 2D histos
00883           chi2_vs_eta[w]->Fill(getEta(track->eta()),track->normalizedChi2());
00884           nhits_vs_eta[w]->Fill(getEta(track->eta()),track->numberOfValidHits());
00885           nDThits_vs_eta[w]->Fill(getEta(track->eta()),track->hitPattern().numberOfValidMuonDTHits());
00886           nCSChits_vs_eta[w]->Fill(getEta(track->eta()),track->hitPattern().numberOfValidMuonCSCHits());
00887           nRPChits_vs_eta[w]->Fill(getEta(track->eta()),track->hitPattern().numberOfValidMuonRPCHits());
00888 
00889           nlosthits_vs_eta[w]->Fill(getEta(track->eta()),track->numberOfLostHits());
00890 
00891           //resolution of track params: fill 2D histos
00892           dxyres_vs_eta[w]->Fill(getEta(track->eta()),dxyRec-dxySim);
00893           ptres_vs_eta[w]->Fill(getEta(track->eta()),(ptRec-ptSim)/ptRec);
00894           dzres_vs_eta[w]->Fill(getEta(track->eta()),dzRec-dzSim);
00895           phires_vs_eta[w]->Fill(getEta(track->eta()),phiDiff);
00896           cotThetares_vs_eta[w]->Fill(getEta(track->eta()), cos(thetaRec)/sin(thetaRec) - cos(thetaSim)/sin(thetaSim));
00897           
00898           //same as before but vs pT
00899           dxyres_vs_pt[w]->Fill(getPt(ptRec),dxyRec-dxySim);
00900           ptres_vs_pt[w]->Fill(getPt(ptRec),(ptRec-ptSim)/ptRec);
00901           dzres_vs_pt[w]->Fill(getPt(ptRec),dzRec-dzSim);
00902           phires_vs_pt[w]->Fill(getPt(ptRec),phiDiff);
00903           cotThetares_vs_pt[w]->Fill(getPt(ptRec), cos(thetaRec)/sin(thetaRec) - cos(thetaSim)/sin(thetaSim));
00904                  
00905           //pulls of track params vs eta: fill 2D histos
00906           dxypull_vs_eta[w]->Fill(getEta(track->eta()),dxyPull);
00907           ptpull_vs_eta[w]->Fill(getEta(track->eta()),ptres/ptError);
00908           dzpull_vs_eta[w]->Fill(getEta(track->eta()),dzPull);
00909           phipull_vs_eta[w]->Fill(getEta(track->eta()),phiPull);
00910           thetapull_vs_eta[w]->Fill(getEta(track->eta()),thetaPull);
00911 
00912           //plots vs phi
00913           nhits_vs_phi[w]->Fill(phiRec,track->numberOfValidHits());
00914           chi2_vs_phi[w]->Fill(phiRec,track->normalizedChi2());
00915           ptmean_vs_eta_phi[w]->Fill(phiRec,getEta(track->eta()),ptRec);
00916           phimean_vs_eta_phi[w]->Fill(phiRec,getEta(track->eta()),phiRec);
00917           ptres_vs_phi[w]->Fill(phiRec,(ptRec-ptSim)/ptRec);
00918           phires_vs_phi[w]->Fill(phiRec,phiDiff);
00919           ptpull_vs_phi[w]->Fill(phiRec,ptres/ptError);
00920           phipull_vs_phi[w]->Fill(phiRec,phiPull); 
00921           thetapull_vs_phi[w]->Fill(phiRec,thetaPull); 
00922           
00923           std::vector<PSimHit> simhits;
00924           
00925           if (usetracker && usemuon) {
00926             simhits=tpr.get()->trackPSimHit();
00927           } 
00928           else if (!usetracker && usemuon) {
00929             simhits=tpr.get()->trackPSimHit(DetId::Muon);
00930           }
00931           else if (usetracker && !usemuon) {
00932             simhits=tpr.get()->trackPSimHit(DetId::Tracker);
00933           }
00934           
00935           nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
00936           
00937         } // End of try{
00938         catch (cms::Exception e){
00939           LogTrace("MuonTrackValidator") << "exception found: " << e.what() << "\n";
00940         }
00941       } // End of for(View<Track>::size_type i=0; i<trackCollectionSize; ++i){
00942       if (at!=0) h_tracks[w]->Fill(at);
00943       h_fakes[w]->Fill(rT-at);
00944       edm::LogVerbatim("MuonTrackValidator") << "Total Simulated: " << st << "\n"
00945                                              << "Total Associated (simToReco): " << ats << "\n"
00946                                              << "Total Reconstructed: " << rT << "\n"
00947                                              << "Total Associated (recoToSim): " << at << "\n"
00948                                              << "Total Fakes: " << rT-at << "\n";
00949       nrec_vs_nsim[w]->Fill(rT,st);
00950       w++;
00951     } // End of  for (unsigned int www=0;www<label.size();www++){
00952   } //END of for (unsigned int ww=0;ww<associators.size();ww++){
00953 }
00954 
00955 void MuonTrackValidator::endRun(Run const&, EventSetup const&) {
00956 
00957   int w=0;
00958   for (unsigned int ww=0;ww<associators.size();ww++){
00959     for (unsigned int www=0;www<label.size();www++){
00960 
00961       //resolution of track params: get sigma from 2D histos
00962       if(!skipHistoFit){
00963       FitSlicesYTool fsyt_dxy(dxyres_vs_eta[w]);
00964       fsyt_dxy.getFittedSigmaWithError(h_dxyrmsh[w]);
00965       fsyt_dxy.getFittedMeanWithError(h_dxymeanh[w]);
00966       FitSlicesYTool fsyt_dxyPt(dxyres_vs_pt[w]);
00967       fsyt_dxyPt.getFittedSigmaWithError(h_dxyrmshPt[w]);
00968       fsyt_dxyPt.getFittedMeanWithError(h_dxymeanhPt[w]);
00969       FitSlicesYTool fsyt_pt(ptres_vs_eta[w]);
00970       fsyt_pt.getFittedSigmaWithError(h_ptrmsh[w]);
00971       fsyt_pt.getFittedMeanWithError(h_ptshifteta[w]);      
00972       FitSlicesYTool fsyt_ptPt(ptres_vs_pt[w]);
00973       fsyt_ptPt.getFittedSigmaWithError(h_ptrmshPt[w]);
00974       fsyt_ptPt.getFittedMeanWithError(h_ptmeanhPt[w]);
00975       FitSlicesYTool fsyt_ptPhi(ptres_vs_phi[w]); 
00976       fsyt_ptPhi.getFittedSigmaWithError(h_ptrmshPhi[w]);
00977       fsyt_ptPhi.getFittedMeanWithError(h_ptmeanhPhi[w]);
00978       FitSlicesYTool fsyt_dz(dzres_vs_eta[w]);
00979       fsyt_dz.getFittedSigmaWithError(h_dzrmsh[w]);
00980       fsyt_dz.getFittedMeanWithError(h_dzmeanh[w]);
00981       FitSlicesYTool fsyt_dzPt(dzres_vs_pt[w]);
00982       fsyt_dzPt.getFittedSigmaWithError(h_dzrmshPt[w]);
00983       fsyt_dzPt.getFittedMeanWithError(h_dzmeanhPt[w]);
00984       FitSlicesYTool fsyt_phi(phires_vs_eta[w]);
00985       fsyt_phi.getFittedSigmaWithError(h_phirmsh[w]);
00986       fsyt_phi.getFittedMeanWithError(h_phimeanh[w]);
00987       FitSlicesYTool fsyt_phiPt(phires_vs_pt[w]);
00988       fsyt_phiPt.getFittedSigmaWithError(h_phirmshPt[w]);
00989       fsyt_phiPt.getFittedMeanWithError(h_phimeanhPt[w]);
00990       FitSlicesYTool fsyt_phiPhi(phires_vs_phi[w]); 
00991       fsyt_phiPhi.getFittedSigmaWithError(h_phirmshPhi[w]); 
00992       fsyt_phiPhi.getFittedMeanWithError(h_phimeanhPhi[w]); 
00993       FitSlicesYTool fsyt_cotTheta(cotThetares_vs_eta[w]);
00994       fsyt_cotTheta.getFittedSigmaWithError(h_cotThetarmsh[w]);
00995       fsyt_cotTheta.getFittedMeanWithError(h_cotThetameanh[w]);
00996       FitSlicesYTool fsyt_cotThetaPt(cotThetares_vs_pt[w]);
00997       fsyt_cotThetaPt.getFittedSigmaWithError(h_cotThetarmshPt[w]);
00998       fsyt_cotThetaPt.getFittedMeanWithError(h_cotThetameanhPt[w]);
00999       }
01000       //chi2 and #hit vs eta: get mean from 2D histos
01001       doProfileX(chi2_vs_eta[w],h_chi2meanh[w]);
01002       doProfileX(nhits_vs_eta[w],h_hits_eta[w]);    
01003       doProfileX(nDThits_vs_eta[w],h_DThits_eta[w]);    
01004       doProfileX(nCSChits_vs_eta[w],h_CSChits_eta[w]);    
01005       doProfileX(nRPChits_vs_eta[w],h_RPChits_eta[w]);    
01006 
01007       doProfileX(nlosthits_vs_eta[w],h_losthits_eta[w]);    
01008       //vs phi
01009       doProfileX(chi2_vs_nhits[w],h_chi2meanhitsh[w]); 
01010       //      doProfileX(ptres_vs_eta[w],h_ptresmean_vs_eta[w]);
01011       //      doProfileX(phires_vs_eta[w],h_phiresmean_vs_eta[w]);
01012       doProfileX(chi2_vs_phi[w],h_chi2mean_vs_phi[w]);
01013       doProfileX(nhits_vs_phi[w],h_hits_phi[w]);
01014       //       doProfileX(ptres_vs_phi[w],h_ptresmean_vs_phi[w]);
01015       //       doProfileX(phires_vs_phi[w],h_phiresmean_vs_phi[w]);
01016       if(!skipHistoFit){      
01017       //pulls of track params vs eta: get sigma from 2D histos
01018       FitSlicesYTool fsyt_dxyp(dxypull_vs_eta[w]);
01019       fsyt_dxyp.getFittedSigmaWithError(h_dxypulleta[w]);
01020       fsyt_dxyp.getFittedMeanWithError(h_dxypulletamean[w]);
01021       FitSlicesYTool fsyt_ptp(ptpull_vs_eta[w]);
01022       fsyt_ptp.getFittedSigmaWithError(h_ptpulleta[w]);
01023       fsyt_ptp.getFittedMeanWithError(h_ptpulletamean[w]);
01024       FitSlicesYTool fsyt_dzp(dzpull_vs_eta[w]);
01025       fsyt_dzp.getFittedSigmaWithError(h_dzpulleta[w]);
01026       fsyt_dzp.getFittedMeanWithError(h_dzpulletamean[w]);
01027       FitSlicesYTool fsyt_phip(phipull_vs_eta[w]);
01028       fsyt_phip.getFittedSigmaWithError(h_phipulleta[w]);
01029       fsyt_phip.getFittedMeanWithError(h_phipulletamean[w]);
01030       FitSlicesYTool fsyt_thetap(thetapull_vs_eta[w]);
01031       fsyt_thetap.getFittedSigmaWithError(h_thetapulleta[w]);
01032       fsyt_thetap.getFittedMeanWithError(h_thetapulletamean[w]);
01033       //vs phi
01034       FitSlicesYTool fsyt_ptpPhi(ptpull_vs_phi[w]);
01035       fsyt_ptpPhi.getFittedSigmaWithError(h_ptpullphi[w]);
01036       fsyt_ptpPhi.getFittedMeanWithError(h_ptpullphimean[w]);
01037       FitSlicesYTool fsyt_phipPhi(phipull_vs_phi[w]);
01038       fsyt_phipPhi.getFittedSigmaWithError(h_phipullphi[w]);
01039       fsyt_phipPhi.getFittedMeanWithError(h_phipullphimean[w]);
01040       FitSlicesYTool fsyt_thetapPhi(thetapull_vs_phi[w]);
01041       fsyt_thetapPhi.getFittedSigmaWithError(h_thetapullphi[w]);
01042       fsyt_thetapPhi.getFittedMeanWithError(h_thetapullphimean[w]);
01043       //effic&fake
01044       fillPlotFromVectors(h_effic[w],totASSeta[w],totSIMeta[w],"effic");
01045       fillPlotFromVectors(h_fakerate[w],totASS2eta[w],totRECeta[w],"fakerate");
01046       fillPlotFromVectors(h_efficPt[w],totASSpT[w],totSIMpT[w],"effic");
01047       fillPlotFromVectors(h_fakeratePt[w],totASS2pT[w],totRECpT[w],"fakerate");
01048       fillPlotFromVectors(h_effic_vs_hit[w],totASS_hit[w],totSIM_hit[w],"effic");
01049       fillPlotFromVectors(h_fake_vs_hit[w],totASS2_hit[w],totREC_hit[w],"fakerate");
01050       fillPlotFromVectors(h_effic_vs_phi[w],totASS_phi[w],totSIM_phi[w],"effic");
01051       fillPlotFromVectors(h_fake_vs_phi[w],totASS2_phi[w],totREC_phi[w],"fakerate");
01052       fillPlotFromVectors(h_effic_vs_dxy[w],totASS_dxy[w],totSIM_dxy[w],"effic");
01053       fillPlotFromVectors(h_fake_vs_dxy[w],totASS2_dxy[w],totREC_dxy[w],"fakerate");
01054       fillPlotFromVectors(h_effic_vs_dz[w],totASS_dz[w],totSIM_dz[w],"effic");
01055       fillPlotFromVectors(h_fake_vs_dz[w],totASS2_dz[w],totREC_dz[w],"fakerate");
01056       fillPlotFromVectors(h_effic_vs_vertpos[w],totASS_vertpos[w],totSIM_vertpos[w],"effic");
01057       fillPlotFromVectors(h_effic_vs_zpos[w],totASS_zpos[w],totSIM_zpos[w],"effic");
01058 
01059       if (MABH) 
01060         {
01061           fillPlotFromVectors(h_effic_Quality05[w] ,totASSeta_Quality05[w] ,totSIMeta[w],"effic");
01062           fillPlotFromVectors(h_effic_Quality075[w],totASSeta_Quality075[w],totSIMeta[w],"effic");
01063           fillPlotFromVectors(h_efficPt_Quality05[w] ,totASSpT_Quality05[w] ,totSIMpT[w],"effic");
01064           fillPlotFromVectors(h_efficPt_Quality075[w],totASSpT_Quality075[w],totSIMpT[w],"effic");
01065           fillPlotFromVectors(h_effic_vs_phi_Quality05[w] ,totASS_phi_Quality05[w],totSIM_phi[w],"effic");
01066           fillPlotFromVectors(h_effic_vs_phi_Quality075[w],totASS_phi_Quality075[w],totSIM_phi[w],"effic");
01067         }
01068       }
01069 
01070       fillPlotFromVector(h_recoeta[w],totRECeta[w]);
01071       fillPlotFromVector(h_simuleta[w],totSIMeta[w]);
01072       fillPlotFromVector(h_assoceta[w],totASSeta[w]);
01073       fillPlotFromVector(h_assoc2eta[w],totASS2eta[w]);
01074 
01075       fillPlotFromVector(h_recopT[w],totRECpT[w]);
01076       fillPlotFromVector(h_simulpT[w],totSIMpT[w]);
01077       fillPlotFromVector(h_assocpT[w],totASSpT[w]);
01078       fillPlotFromVector(h_assoc2pT[w],totASS2pT[w]);
01079 
01080       fillPlotFromVector(h_recohit[w],totREC_hit[w]);
01081       fillPlotFromVector(h_simulhit[w],totSIM_hit[w]);
01082       fillPlotFromVector(h_assochit[w],totASS_hit[w]);
01083       fillPlotFromVector(h_assoc2hit[w],totASS2_hit[w]);
01084 
01085       fillPlotFromVector(h_recophi[w],totREC_phi[w]);
01086       fillPlotFromVector(h_simulphi[w],totSIM_phi[w]);
01087       fillPlotFromVector(h_assocphi[w],totASS_phi[w]);
01088       fillPlotFromVector(h_assoc2phi[w],totASS2_phi[w]);
01089 
01090       fillPlotFromVector(h_recodxy[w],totREC_dxy[w]);
01091       fillPlotFromVector(h_simuldxy[w],totSIM_dxy[w]);
01092       fillPlotFromVector(h_assocdxy[w],totASS_dxy[w]);
01093       fillPlotFromVector(h_assoc2dxy[w],totASS2_dxy[w]);
01094 
01095       fillPlotFromVector(h_recodz[w],totREC_dz[w]);
01096       fillPlotFromVector(h_simuldz[w],totSIM_dz[w]);
01097       fillPlotFromVector(h_assocdz[w],totASS_dz[w]);
01098       fillPlotFromVector(h_assoc2dz[w],totASS2_dz[w]);
01099 
01100       fillPlotFromVector(h_simulvertpos[w],totSIM_vertpos[w]);
01101       fillPlotFromVector(h_assocvertpos[w],totASS_vertpos[w]);
01102 
01103       fillPlotFromVector(h_simulzpos[w],totSIM_zpos[w]);
01104       fillPlotFromVector(h_assoczpos[w],totASS_zpos[w]);
01105       
01106       if (MABH) {
01107         fillPlotFromVector(h_assoceta_Quality05[w] ,totASSeta_Quality05[w]);
01108         fillPlotFromVector(h_assoceta_Quality075[w],totASSeta_Quality075[w]);
01109         fillPlotFromVector(h_assocpT_Quality05[w] ,totASSpT_Quality05[w]);
01110         fillPlotFromVector(h_assocpT_Quality075[w],totASSpT_Quality075[w]);
01111         fillPlotFromVector(h_assocphi_Quality05[w] ,totASS_phi_Quality05[w]);
01112         fillPlotFromVector(h_assocphi_Quality075[w],totASS_phi_Quality075[w]);
01113       }
01114       
01115       w++;
01116     }
01117   }
01118   
01119   if ( out.size() != 0 && dbe_ ) dbe_->save(out);
01120 }
01121 
01122 
01123 void 
01124 MuonTrackValidator::getRecoMomentum (const reco::Track& track, double& pt, double& ptError,
01125                                       double& qoverp, double& qoverpError, double& lambda,double& lambdaError,  double& phi, double& phiError ) const {
01126   pt = track.pt();
01127   ptError = track.ptError();
01128   qoverp = track.qoverp();
01129   qoverpError = track.qoverpError();
01130   lambda = track.lambda();
01131   lambdaError = track.lambdaError(); 
01132   phi = track.phi(); 
01133   phiError = track.phiError();
01134 
01135 }
01136 
01137 void 
01138 MuonTrackValidator::getRecoMomentum (const reco::GsfTrack& gsfTrack, double& pt, double& ptError,
01139                                       double& qoverp, double& qoverpError, double& lambda,double& lambdaError,  double& phi, double& phiError  ) const {
01140 
01141   pt = gsfTrack.ptMode();
01142   ptError = gsfTrack.ptModeError();
01143   qoverp = gsfTrack.qoverpMode();
01144   qoverpError = gsfTrack.qoverpModeError();
01145   lambda = gsfTrack.lambdaMode();
01146   lambdaError = gsfTrack.lambdaModeError(); 
01147   phi = gsfTrack.phiMode(); 
01148   phiError = gsfTrack.phiModeError();
01149 
01150 }
01151