CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/TrackingMonitor/src/TrackBuildingAnalyzer.cc

Go to the documentation of this file.
00001 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00002 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00003 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
00004 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00005 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00006 #include "TrackingTools/PatternTools/interface/TSCBLBuilderNoMaterial.h"
00007 #include "TrackingTools/PatternTools/interface/TSCPBuilderNoMaterial.h"
00008 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00009 #include "MagneticField/Engine/interface/MagneticField.h"
00010 
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 #include "FWCore/Utilities/interface/InputTag.h"
00013 #include "DQMServices/Core/interface/DQMStore.h"
00014 #include "DQM/TrackingMonitor/interface/TrackBuildingAnalyzer.h"
00015 #include <string>
00016 #include "TMath.h"
00017 
00018 #include <iostream>
00019 
00020 TrackBuildingAnalyzer::TrackBuildingAnalyzer(const edm::ParameterSet& iConfig) 
00021     : conf_( iConfig )
00022     , SeedPt(NULL)
00023     , SeedEta(NULL)
00024     , SeedPhi(NULL)
00025     , SeedTheta(NULL)
00026     , SeedQ(NULL)
00027     , SeedDxy(NULL)
00028     , SeedDz(NULL)
00029     , NumberOfRecHitsPerSeed(NULL)
00030     , NumberOfRecHitsPerSeedVsPhiProfile(NULL)
00031     , NumberOfRecHitsPerSeedVsEtaProfile(NULL)
00032 {
00033 }
00034 
00035 TrackBuildingAnalyzer::~TrackBuildingAnalyzer() 
00036 { 
00037 }
00038 
00039 void TrackBuildingAnalyzer::beginJob(DQMStore * dqmStore_) 
00040 {
00041 
00042     // parameters from the configuration
00043     std::string AlgoName       = conf_.getParameter<std::string>("AlgoName");
00044     std::string MEFolderName   = conf_.getParameter<std::string>("FolderName"); 
00045 
00046     // use the AlgoName and Quality Name 
00047     std::string CatagoryName = AlgoName;
00048 
00049     // get binning from the configuration
00050     int    TrackPtBin = conf_.getParameter<int>(   "TrackPtBin");
00051     double TrackPtMin = conf_.getParameter<double>("TrackPtMin");
00052     double TrackPtMax = conf_.getParameter<double>("TrackPtMax");
00053 
00054     int    PhiBin     = conf_.getParameter<int>(   "PhiBin");
00055     double PhiMin     = conf_.getParameter<double>("PhiMin");
00056     double PhiMax     = conf_.getParameter<double>("PhiMax");
00057 
00058     int    EtaBin     = conf_.getParameter<int>(   "EtaBin");
00059     double EtaMin     = conf_.getParameter<double>("EtaMin");
00060     double EtaMax     = conf_.getParameter<double>("EtaMax");
00061 
00062     int    ThetaBin   = conf_.getParameter<int>(   "ThetaBin");
00063     double ThetaMin   = conf_.getParameter<double>("ThetaMin");
00064     double ThetaMax   = conf_.getParameter<double>("ThetaMax");
00065 
00066     int    TrackQBin  = conf_.getParameter<int>(   "TrackQBin");
00067     double TrackQMin  = conf_.getParameter<double>("TrackQMin");
00068     double TrackQMax  = conf_.getParameter<double>("TrackQMax");
00069 
00070     int    SeedDxyBin = conf_.getParameter<int>(   "SeedDxyBin");
00071     double SeedDxyMin = conf_.getParameter<double>("SeedDxyMin");
00072     double SeedDxyMax = conf_.getParameter<double>("SeedDxyMax");
00073 
00074     int    SeedDzBin  = conf_.getParameter<int>(   "SeedDzBin");
00075     double SeedDzMin  = conf_.getParameter<double>("SeedDzMin");
00076     double SeedDzMax  = conf_.getParameter<double>("SeedDzMax");
00077 
00078     int    SeedHitBin = conf_.getParameter<int>(   "SeedHitBin");
00079     double SeedHitMin = conf_.getParameter<double>("SeedHitMin");
00080     double SeedHitMax = conf_.getParameter<double>("SeedHitMax");
00081 
00082     int    TCDxyBin   = conf_.getParameter<int>(   "TCDxyBin");
00083     double TCDxyMin   = conf_.getParameter<double>("TCDxyMin");
00084     double TCDxyMax   = conf_.getParameter<double>("TCDxyMax");
00085 
00086     int    TCDzBin    = conf_.getParameter<int>(   "TCDzBin");
00087     double TCDzMin    = conf_.getParameter<double>("TCDzMin");
00088     double TCDzMax    = conf_.getParameter<double>("TCDzMax");
00089 
00090     int    TCHitBin   = conf_.getParameter<int>(   "TCHitBin");
00091     double TCHitMin   = conf_.getParameter<double>("TCHitMin");
00092     double TCHitMax   = conf_.getParameter<double>("TCHitMax");
00093 
00094     dqmStore_->setCurrentFolder(MEFolderName);
00095 
00096     // book the Seed histograms
00097     // ---------------------------------------------------------------------------------//
00098     dqmStore_->setCurrentFolder(MEFolderName+"/TrackBuilding");
00099 
00100     histname = "SeedPt_";
00101     SeedPt = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, TrackPtBin, TrackPtMin, TrackPtMax);
00102     SeedPt->setAxisTitle("Seed p_{T} (GeV/c)", 1);
00103     SeedPt->setAxisTitle("Number of Seeds", 2);
00104 
00105     histname = "SeedEta_";
00106     SeedEta = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax);
00107     SeedEta->setAxisTitle("Seed #eta", 1);
00108     SeedEta->setAxisTitle("Number of Seeds", 2);
00109 
00110     histname = "SeedPhi_";
00111     SeedPhi = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax);
00112     SeedPhi->setAxisTitle("Seed #phi", 1);
00113     SeedPhi->setAxisTitle("Number of Seed", 2);
00114 
00115     histname = "SeedTheta_";
00116     SeedTheta = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, ThetaBin, ThetaMin, ThetaMax);
00117     SeedTheta->setAxisTitle("Seed #theta", 1);
00118     SeedTheta->setAxisTitle("Number of Seeds", 2);
00119 
00120     histname = "SeedQ_";
00121     SeedQ = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, TrackQBin, TrackQMin, TrackQMax);
00122     SeedQ->setAxisTitle("Seed Charge", 1);
00123     SeedQ->setAxisTitle("Number of Seeds",2);
00124 
00125     histname = "SeedDxy_";
00126     SeedDxy = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, SeedDxyBin, SeedDxyMin, SeedDxyMax);
00127     SeedDxy->setAxisTitle("Seed d_{xy} (cm)", 1);
00128     SeedDxy->setAxisTitle("Number of Seeds",2);
00129 
00130     histname = "SeedDz_";
00131     SeedDz = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, SeedDzBin, SeedDzMin, SeedDzMax);
00132     SeedDz->setAxisTitle("Seed d_{z} (cm)", 1);
00133     SeedDz->setAxisTitle("Number of Seeds",2);
00134 
00135     histname = "NumberOfRecHitsPerSeed_";
00136     NumberOfRecHitsPerSeed = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, SeedHitBin, SeedHitMin, SeedHitMax);
00137     NumberOfRecHitsPerSeed->setAxisTitle("Number of RecHits per Seed", 1);
00138     NumberOfRecHitsPerSeed->setAxisTitle("Number of Seeds",2);
00139 
00140     histname = "NumberOfRecHitsPerSeedVsPhiProfile_";
00141     NumberOfRecHitsPerSeedVsPhiProfile = dqmStore_->bookProfile(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax, SeedHitBin, SeedHitMin, SeedHitMax,"s");
00142     NumberOfRecHitsPerSeedVsPhiProfile->setAxisTitle("Seed #phi",1);
00143     NumberOfRecHitsPerSeedVsPhiProfile->setAxisTitle("Number of RecHits of each Seed",2);
00144 
00145     histname = "NumberOfRecHitsPerSeedVsEtaProfile_";
00146     NumberOfRecHitsPerSeedVsEtaProfile = dqmStore_->bookProfile(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, SeedHitBin, SeedHitMin, SeedHitMax,"s");
00147     NumberOfRecHitsPerSeedVsEtaProfile->setAxisTitle("Seed #eta",1);
00148     NumberOfRecHitsPerSeedVsEtaProfile->setAxisTitle("Number of RecHits of each Seed",2);
00149 
00150     // book the TrackCandidate histograms
00151     // ---------------------------------------------------------------------------------//
00152     dqmStore_->setCurrentFolder(MEFolderName+"/TrackBuilding");
00153 
00154     histname = "TrackCandPt_";
00155     TrackCandPt = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, TrackPtBin, TrackPtMin, TrackPtMax);
00156     TrackCandPt->setAxisTitle("Track Candidate p_{T} (GeV/c)", 1);
00157     TrackCandPt->setAxisTitle("Number of Track Candidates", 2);
00158 
00159     histname = "TrackCandEta_";
00160     TrackCandEta = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax);
00161     TrackCandEta->setAxisTitle("Track Candidate #eta", 1);
00162     TrackCandEta->setAxisTitle("Number of Track Candidates", 2);
00163 
00164     histname = "TrackCandPhi_";
00165     TrackCandPhi = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax);
00166     TrackCandPhi->setAxisTitle("Track Candidate #phi", 1);
00167     TrackCandPhi->setAxisTitle("Number of Track Candidates", 2);
00168 
00169     histname = "TrackCandTheta_";
00170     TrackCandTheta = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, ThetaBin, ThetaMin, ThetaMax);
00171     TrackCandTheta->setAxisTitle("Track Candidate #theta", 1);
00172     TrackCandTheta->setAxisTitle("Number of Track Candidates", 2);
00173 
00174     histname = "TrackCandQ_";
00175     TrackCandQ = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, TrackQBin, TrackQMin, TrackQMax);
00176     TrackCandQ->setAxisTitle("Track Candidate Charge", 1);
00177     TrackCandQ->setAxisTitle("Number of Track Candidates",2);
00178 
00179     histname = "TrackCandDxy_";
00180     TrackCandDxy = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, TCDxyBin, TCDxyMin, TCDxyMax);
00181     TrackCandDxy->setAxisTitle("Track Candidate d_{xy} (cm)", 1);
00182     TrackCandDxy->setAxisTitle("Number of Track Candidates",2);
00183 
00184     histname = "TrackCandDz_";
00185     TrackCandDz = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, TCDzBin, TCDzMin, TCDzMax);
00186     TrackCandDz->setAxisTitle("Track Candidate d_{z} (cm)", 1);
00187     TrackCandDz->setAxisTitle("Number of Track Candidates",2);
00188 
00189     histname = "NumberOfRecHitsPerTrackCand_";
00190     NumberOfRecHitsPerTrackCand = dqmStore_->book1D(histname+CatagoryName, histname+CatagoryName, TCHitBin, TCHitMin, TCHitMax);
00191     NumberOfRecHitsPerTrackCand->setAxisTitle("Number of RecHits per Track Candidate", 1);
00192     NumberOfRecHitsPerTrackCand->setAxisTitle("Number of Track Candidates",2);
00193 
00194     histname = "NumberOfRecHitsPerTrackCandVsPhiProfile_";
00195     NumberOfRecHitsPerTrackCandVsPhiProfile = dqmStore_->bookProfile(histname+CatagoryName, histname+CatagoryName, PhiBin, PhiMin, PhiMax, TCHitBin, TCHitMin, TCHitMax,"s");
00196     NumberOfRecHitsPerTrackCandVsPhiProfile->setAxisTitle("Track Candidate #phi",1);
00197     NumberOfRecHitsPerTrackCandVsPhiProfile->setAxisTitle("Number of RecHits of each Track Candidate",2);
00198 
00199     histname = "NumberOfRecHitsPerTrackCandVsEtaProfile_";
00200     NumberOfRecHitsPerTrackCandVsEtaProfile = dqmStore_->bookProfile(histname+CatagoryName, histname+CatagoryName, EtaBin, EtaMin, EtaMax, TCHitBin, TCHitMin, TCHitMax,"s");
00201     NumberOfRecHitsPerTrackCandVsEtaProfile->setAxisTitle("Track Candidate #eta",1);
00202     NumberOfRecHitsPerTrackCandVsEtaProfile->setAxisTitle("Number of RecHits of each Track Candidate",2);
00203 }
00204 
00205 // -- Analyse
00206 // ---------------------------------------------------------------------------------//
00207 void TrackBuildingAnalyzer::analyze
00208 (
00209     const edm::Event& iEvent,
00210     const edm::EventSetup& iSetup,
00211     const TrajectorySeed& candidate,
00212     const reco::BeamSpot& bs,
00213     const edm::ESHandle<MagneticField>& theMF,
00214     const edm::ESHandle<TransientTrackingRecHitBuilder>& theTTRHBuilder
00215 )
00216 {
00217 
00218     TrajectoryStateTransform tsTransform;
00219     TSCBLBuilderNoMaterial tscblBuilder;
00220 
00221     //get parameters and errors from the candidate state
00222     TransientTrackingRecHit::RecHitPointer recHit = theTTRHBuilder->build(&*(candidate.recHits().second-1));
00223     TrajectoryStateOnSurface state = tsTransform.transientState( candidate.startingState(), recHit->surface(), theMF.product());
00224     TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed = tscblBuilder(*state.freeState(),bs);//as in TrackProducerAlgorithm
00225     if(!(tsAtClosestApproachSeed.isValid())) {
00226         edm::LogVerbatim("TrackBuilding") << "TrajectoryStateClosestToBeamLine not valid";
00227         return;
00228     }
00229     GlobalPoint  v0 = tsAtClosestApproachSeed.trackStateAtPCA().position();
00230     GlobalVector p = tsAtClosestApproachSeed.trackStateAtPCA().momentum();
00231     GlobalPoint  v(v0.x()-bs.x0(),v0.y()-bs.y0(),v0.z()-bs.z0());
00232 
00233     double pt           = sqrt(state.globalMomentum().perp2());
00234     double eta          = state.globalMomentum().eta();
00235     double phi          = state.globalMomentum().phi();
00236     double theta        = state.globalMomentum().theta();
00237     //double pm           = sqrt(state.globalMomentum().mag2());
00238     //double pz           = state.globalMomentum().z();
00239     //double qoverp       = tsAtClosestApproachSeed.trackStateAtPCA().charge()/p.mag();
00240     //double theta        = p.theta();
00241     //double lambda       = M_PI/2-p.theta();
00242     double numberOfHits = candidate.recHits().second-candidate.recHits().first;
00243     double dxy          = (-v.x()*sin(p.phi())+v.y()*cos(p.phi()));
00244     double dz           = v.z() - (v.x()*p.x()+v.y()*p.y())/p.perp() * p.z()/p.perp();
00245 
00246     // fill the ME's
00247     SeedQ->Fill( state.charge() );
00248     SeedPt->Fill( pt );
00249     SeedEta->Fill( eta );
00250     SeedPhi->Fill( phi );
00251     SeedTheta->Fill( theta );
00252     SeedDxy->Fill( dxy );
00253     SeedDz->Fill( dz );
00254     NumberOfRecHitsPerSeed->Fill( numberOfHits );
00255     NumberOfRecHitsPerSeedVsEtaProfile->Fill( eta, numberOfHits );
00256     NumberOfRecHitsPerSeedVsPhiProfile->Fill( phi, numberOfHits );
00257 }
00258 
00259 // -- Analyse
00260 // ---------------------------------------------------------------------------------//
00261 void TrackBuildingAnalyzer::analyze
00262 (
00263     const edm::Event& iEvent,
00264     const edm::EventSetup& iSetup,
00265     const TrackCandidate& candidate,
00266     const reco::BeamSpot& bs,
00267     const edm::ESHandle<MagneticField>& theMF,
00268     const edm::ESHandle<TransientTrackingRecHitBuilder>& theTTRHBuilder
00269 )
00270 {
00271 
00272     TrajectoryStateTransform tsTransform;
00273     TSCBLBuilderNoMaterial tscblBuilder;
00274 
00275     //get parameters and errors from the candidate state
00276     TransientTrackingRecHit::RecHitPointer recHit = theTTRHBuilder->build(&*(candidate.recHits().second-1));
00277     TrajectoryStateOnSurface state = tsTransform.transientState( candidate.trajectoryStateOnDet(), recHit->surface(), theMF.product());
00278     TrajectoryStateClosestToBeamLine tsAtClosestApproachTrackCand = tscblBuilder(*state.freeState(),bs);//as in TrackProducerAlgorithm
00279     if(!(tsAtClosestApproachTrackCand.isValid())) {
00280         edm::LogVerbatim("TrackBuilding") << "TrajectoryStateClosestToBeamLine not valid";
00281         return;
00282     }
00283     GlobalPoint  v0 = tsAtClosestApproachTrackCand.trackStateAtPCA().position();
00284     GlobalVector p = tsAtClosestApproachTrackCand.trackStateAtPCA().momentum();
00285     GlobalPoint  v(v0.x()-bs.x0(),v0.y()-bs.y0(),v0.z()-bs.z0());
00286 
00287     double pt           = sqrt(state.globalMomentum().perp2());
00288     double eta          = state.globalMomentum().eta();
00289     double phi          = state.globalMomentum().phi();
00290     double theta        = state.globalMomentum().theta();
00291     //double pm           = sqrt(state.globalMomentum().mag2());
00292     //double pz           = state.globalMomentum().z();
00293     //double qoverp       = tsAtClosestApproachTrackCand.trackStateAtPCA().charge()/p.mag();
00294     //double theta        = p.theta();
00295     //double lambda       = M_PI/2-p.theta();
00296     double numberOfHits = candidate.recHits().second-candidate.recHits().first;
00297     double dxy          = (-v.x()*sin(p.phi())+v.y()*cos(p.phi()));
00298     double dz           = v.z() - (v.x()*p.x()+v.y()*p.y())/p.perp() * p.z()/p.perp();
00299 
00300     // fill the ME's
00301     TrackCandQ->Fill( state.charge() );
00302     TrackCandPt->Fill( pt );
00303     TrackCandEta->Fill( eta );
00304     TrackCandPhi->Fill( phi );
00305     TrackCandTheta->Fill( theta );
00306     TrackCandDxy->Fill( dxy );
00307     TrackCandDz->Fill( dz );
00308     NumberOfRecHitsPerTrackCand->Fill( numberOfHits );
00309     NumberOfRecHitsPerTrackCandVsEtaProfile->Fill( eta, numberOfHits );
00310     NumberOfRecHitsPerTrackCandVsPhiProfile->Fill( phi, numberOfHits );
00311 }