From 852ae40c95116ec7bfcff4f299ed622a908ccea8 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Thu, 1 Dec 2016 17:31:15 +0100 Subject: [PATCH] Add ability to not store TrackingParticles --- .../RecoTrack/plugins/TrackingNtuple.cc | 122 +++++++++++------- .../RecoTrack/python/trackingNtuple_cff.py | 4 + 2 files changed, 80 insertions(+), 46 deletions(-) diff --git a/Validation/RecoTrack/plugins/TrackingNtuple.cc b/Validation/RecoTrack/plugins/TrackingNtuple.cc index 61a7057991662..175559c686e95 100644 --- a/Validation/RecoTrack/plugins/TrackingNtuple.cc +++ b/Validation/RecoTrack/plugins/TrackingNtuple.cc @@ -475,6 +475,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { const bool includeSeeds_; const bool includeAllHits_; const bool includeMVA_; + const bool includeTrackingParticles_; HistoryBase tracer_; @@ -534,6 +535,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { std::vector trk_isHP ; std::vector trk_seedIdx ; std::vector trk_vtxIdx; + std::vector trk_isTrue; std::vector > trk_shareFrac; // second index runs through matched TrackingParticles std::vector > trk_simTrkIdx; // second index runs through matched TrackingParticles std::vector > trk_hitIdx; // second index runs through hits @@ -730,6 +732,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { std::vector see_algo ; std::vector see_stopReason; std::vector see_trkIdx; + std::vector see_isTrue; std::vector > see_shareFrac; // second index runs through matched TrackingParticles std::vector > see_simTrkIdx; // second index runs through matched TrackingParticles std::vector > see_hitIdx; // second index runs through hits @@ -795,7 +798,8 @@ TrackingNtuple::TrackingNtuple(const edm::ParameterSet& iConfig): parametersDefinerName_(iConfig.getUntrackedParameter("parametersDefiner")), includeSeeds_(iConfig.getUntrackedParameter("includeSeeds")), includeAllHits_(iConfig.getUntrackedParameter("includeAllHits")), - includeMVA_(iConfig.getUntrackedParameter("includeMVA")) + includeMVA_(iConfig.getUntrackedParameter("includeMVA")), + includeTrackingParticles_(iConfig.getUntrackedParameter("includeTrackingParticles")) { if(includeSeeds_) { seedTokens_ = edm::vector_transform(iConfig.getUntrackedParameter >("seedTracks"), [&](const edm::InputTag& tag) { @@ -886,47 +890,54 @@ TrackingNtuple::TrackingNtuple(const edm::ParameterSet& iConfig): t->Branch("trk_seedIdx" , &trk_seedIdx ); } t->Branch("trk_vtxIdx" , &trk_vtxIdx); - t->Branch("trk_shareFrac", &trk_shareFrac); - t->Branch("trk_simTrkIdx", &trk_simTrkIdx ); + if(includeTrackingParticles_) { + t->Branch("trk_shareFrac", &trk_shareFrac); + t->Branch("trk_simTrkIdx", &trk_simTrkIdx ); + } + else { + t->Branch("trk_isTrue", &trk_isTrue); + } if(includeAllHits_) { t->Branch("trk_hitIdx" , &trk_hitIdx); t->Branch("trk_hitType", &trk_hitType); } - //sim tracks - t->Branch("sim_event" , &sim_event ); - t->Branch("sim_bunchCrossing", &sim_bunchCrossing); - t->Branch("sim_pdgId" , &sim_pdgId ); - t->Branch("sim_genPdgIds", &sim_genPdgIds); - t->Branch("sim_isFromBHadron", &sim_isFromBHadron); - t->Branch("sim_px" , &sim_px ); - t->Branch("sim_py" , &sim_py ); - t->Branch("sim_pz" , &sim_pz ); - t->Branch("sim_pt" , &sim_pt ); - t->Branch("sim_eta" , &sim_eta ); - t->Branch("sim_phi" , &sim_phi ); - t->Branch("sim_pca_pt" , &sim_pca_pt ); - t->Branch("sim_pca_eta" , &sim_pca_eta ); - t->Branch("sim_pca_lambda", &sim_pca_lambda); - t->Branch("sim_pca_cotTheta", &sim_pca_cotTheta); - t->Branch("sim_pca_phi" , &sim_pca_phi ); - t->Branch("sim_pca_dxy" , &sim_pca_dxy ); - t->Branch("sim_pca_dz" , &sim_pca_dz ); - t->Branch("sim_q" , &sim_q ); - t->Branch("sim_nValid" , &sim_nValid ); - t->Branch("sim_nPixel" , &sim_nPixel ); - t->Branch("sim_nStrip" , &sim_nStrip ); - t->Branch("sim_nLay" , &sim_nLay ); - t->Branch("sim_nPixelLay", &sim_nPixelLay); - t->Branch("sim_n3DLay" , &sim_n3DLay ); - t->Branch("sim_trkIdx" , &sim_trkIdx ); - t->Branch("sim_shareFrac", &sim_shareFrac); - if(includeSeeds_) { - t->Branch("sim_seedIdx" , &sim_seedIdx ); - } - t->Branch("sim_parentVtxIdx", &sim_parentVtxIdx); - t->Branch("sim_decayVtxIdx", &sim_decayVtxIdx); - if(includeAllHits_) { - t->Branch("sim_simHitIdx" , &sim_simHitIdx ); + if(includeTrackingParticles_) { + //sim tracks + t->Branch("sim_event" , &sim_event ); + t->Branch("sim_bunchCrossing", &sim_bunchCrossing); + t->Branch("sim_pdgId" , &sim_pdgId ); + t->Branch("sim_genPdgIds", &sim_genPdgIds); + t->Branch("sim_isFromBHadron", &sim_isFromBHadron); + t->Branch("sim_px" , &sim_px ); + t->Branch("sim_py" , &sim_py ); + t->Branch("sim_pz" , &sim_pz ); + t->Branch("sim_pt" , &sim_pt ); + t->Branch("sim_eta" , &sim_eta ); + t->Branch("sim_phi" , &sim_phi ); + t->Branch("sim_pca_pt" , &sim_pca_pt ); + t->Branch("sim_pca_eta" , &sim_pca_eta ); + t->Branch("sim_pca_lambda", &sim_pca_lambda); + t->Branch("sim_pca_cotTheta", &sim_pca_cotTheta); + t->Branch("sim_pca_phi" , &sim_pca_phi ); + t->Branch("sim_pca_dxy" , &sim_pca_dxy ); + t->Branch("sim_pca_dz" , &sim_pca_dz ); + t->Branch("sim_q" , &sim_q ); + t->Branch("sim_nValid" , &sim_nValid ); + t->Branch("sim_nPixel" , &sim_nPixel ); + t->Branch("sim_nStrip" , &sim_nStrip ); + t->Branch("sim_nLay" , &sim_nLay ); + t->Branch("sim_nPixelLay", &sim_nPixelLay); + t->Branch("sim_n3DLay" , &sim_n3DLay ); + t->Branch("sim_trkIdx" , &sim_trkIdx ); + t->Branch("sim_shareFrac", &sim_shareFrac); + if(includeSeeds_) { + t->Branch("sim_seedIdx" , &sim_seedIdx ); + } + t->Branch("sim_parentVtxIdx", &sim_parentVtxIdx); + t->Branch("sim_decayVtxIdx", &sim_decayVtxIdx); + if(includeAllHits_) { + t->Branch("sim_simHitIdx" , &sim_simHitIdx ); + } } if(includeAllHits_) { //pixels @@ -1086,8 +1097,13 @@ TrackingNtuple::TrackingNtuple(const edm::ParameterSet& iConfig): t->Branch("see_algo" , &see_algo ); t->Branch("see_stopReason", &see_stopReason); t->Branch("see_trkIdx" , &see_trkIdx ); - t->Branch("see_shareFrac", &see_shareFrac); - t->Branch("see_simTrkIdx", &see_simTrkIdx ); + if(includeTrackingParticles_) { + t->Branch("see_shareFrac", &see_shareFrac); + t->Branch("see_simTrkIdx", &see_simTrkIdx ); + } + else { + t->Branch("see_isTrue", &see_isTrue); + } if(includeAllHits_) { t->Branch("see_hitIdx" , &see_hitIdx ); t->Branch("see_hitType", &see_hitType ); @@ -1188,6 +1204,7 @@ void TrackingNtuple::clearVariables() { trk_isHP .clear(); trk_seedIdx .clear(); trk_vtxIdx .clear(); + trk_isTrue .clear(); trk_shareFrac.clear(); trk_simTrkIdx.clear(); trk_hitIdx .clear(); @@ -1365,8 +1382,10 @@ void TrackingNtuple::clearVariables() { see_algo .clear(); see_stopReason.clear(); see_trkIdx .clear(); - see_shareFrac.clear(); - see_simTrkIdx.clear(); + if(includeTrackingParticles_) { + see_shareFrac.clear(); + see_simTrkIdx.clear(); + } see_hitIdx .clear(); see_hitType .clear(); //seed algo offset @@ -2199,8 +2218,13 @@ void TrackingNtuple::fillSeeds(const edm::Event& iEvent, see_stateTrajPz.push_back(mom.z()); see_trkIdx .push_back(-1); // to be set correctly in fillTracks - see_shareFrac.push_back( sharedFraction ); - see_simTrkIdx.push_back( tpIdx ); + if(includeTrackingParticles_) { + see_shareFrac.push_back( sharedFraction ); + see_simTrkIdx.push_back( tpIdx ); + } + else { + see_isTrue.push_back(!tpIdx.empty()); + } /// Hmm, the following could make sense instead of plain failing if propagation to beam line fails /* @@ -2417,7 +2441,6 @@ void TrackingNtuple::fillTracks(const edm::RefToBaseVector& tracks, trk_refpoint_y.push_back(itTrack->vy()); trk_refpoint_z.push_back(itTrack->vz()); trk_nChi2 .push_back( itTrack->normalizedChi2()); - trk_shareFrac.push_back(sharedFraction); trk_q .push_back(charge); trk_nValid .push_back(hp.numberOfValidHits()); trk_nInvalid .push_back(hp.numberOfLostHits(reco::HitPattern::TRACK_HITS)); @@ -2454,7 +2477,13 @@ void TrackingNtuple::fillTracks(const edm::RefToBaseVector& tracks, see_trkIdx[seedIndex] = iTrack; } trk_vtxIdx .push_back(-1); // to be set correctly in fillVertices - trk_simTrkIdx.push_back(tpIdx); + if(includeTrackingParticles_) { + trk_simTrkIdx.push_back(tpIdx); + trk_shareFrac.push_back(sharedFraction); + } + else { + trk_isTrue.push_back(!tpIdx.empty()); + } LogTrace("TrackingNtuple") << "Track #" << itTrack.key() << " with q=" << charge << ", pT=" << pt << " GeV, eta: " << eta << ", phi: " << phi << ", chi2=" << chi2 @@ -2826,6 +2855,7 @@ void TrackingNtuple::fillDescriptions(edm::ConfigurationDescriptions& descriptio desc.addUntracked("includeSeeds", false); desc.addUntracked("includeAllHits", false); desc.addUntracked("includeMVA", true); + desc.addUntracked("includeTrackingParticles", true); descriptions.add("trackingNtuple",desc); } diff --git a/Validation/RecoTrack/python/trackingNtuple_cff.py b/Validation/RecoTrack/python/trackingNtuple_cff.py index aa120a6b4f837..d37f1c400c5db 100644 --- a/Validation/RecoTrack/python/trackingNtuple_cff.py +++ b/Validation/RecoTrack/python/trackingNtuple_cff.py @@ -23,6 +23,9 @@ _includeMVA = True #_includeMVA = False +_includeTrackingParticles = True +#_includeTrackingParticles = False + from CommonTools.RecoAlgos.trackingParticleRefSelector_cfi import trackingParticleRefSelector as _trackingParticleRefSelector trackingParticlesIntime = _trackingParticleRefSelector.clone( signalOnly = False, @@ -39,6 +42,7 @@ trackingNtuple.includeAllHits = _includeHits trackingNtuple.includeSeeds = _includeSeeds trackingNtuple.includeMVA = _includeMVA +trackingNtuple.includeTrackingParticles = _includeTrackingParticles def _filterForNtuple(lst): ret = []