From 5959a061a57fedcf82fae3170d5d3c1d24ee2431 Mon Sep 17 00:00:00 2001 From: Manos Vourliotis Date: Mon, 2 May 2022 14:06:19 -0700 Subject: [PATCH] Addition of moduleType variable in tracking NTuple --- .../RecoTrack/plugins/TrackingNtuple.cc | 63 +++++++++++++------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/Validation/RecoTrack/plugins/TrackingNtuple.cc b/Validation/RecoTrack/plugins/TrackingNtuple.cc index 4f82fe9dd366d..d74e12b72d038 100644 --- a/Validation/RecoTrack/plugins/TrackingNtuple.cc +++ b/Validation/RecoTrack/plugins/TrackingNtuple.cc @@ -514,6 +514,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { void fillBeamSpot(const reco::BeamSpot& bs); void fillPixelHits(const edm::Event& iEvent, + const TrackerGeometry& tracker, const ClusterTPAssociation& clusterToTPMap, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList& simHitsTPAssoc, @@ -524,6 +525,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { std::set& hitProductIds); void fillStripRphiStereoHits(const edm::Event& iEvent, + const TrackerGeometry& tracker, const ClusterTPAssociation& clusterToTPMap, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList& simHitsTPAssoc, @@ -534,11 +536,13 @@ class TrackingNtuple : public edm::one::EDAnalyzer { std::set& hitProductIds); void fillStripMatchedHits(const edm::Event& iEvent, + const TrackerGeometry& tracker, const TransientTrackingRecHitBuilder& theTTRHBuilder, const TrackerTopology& tTopo, std::vector>& monoStereoClusterList); size_t addStripMatchedHit(const SiStripMatchedRecHit2D& hit, + const TrackerGeometry& tracker, const TransientTrackingRecHitBuilder& theTTRHBuilder, const TrackerTopology& tTopo, const std::vector>& stripMasks, @@ -546,6 +550,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { void fillPhase2OTHits(const edm::Event& iEvent, const ClusterTPAssociation& clusterToTPMap, + const TrackerGeometry& tracker, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList& simHitsTPAssoc, const edm::DetSetVector& digiSimLink, @@ -558,6 +563,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { const TrackingParticleRefVector& tpCollection, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const reco::BeamSpot& bs, + const TrackerGeometry& tracker, const reco::TrackToTrackingParticleAssociator& associatorByHits, const ClusterTPAssociation& clusterToTPMap, const TransientTrackingRecHitBuilder& theTTRHBuilder, @@ -568,6 +574,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { std::map& seedToCollIndex); void fillTracks(const edm::RefToBaseVector& tracks, + const TrackerGeometry& tracker, const TrackingParticleRefVector& tpCollection, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const TrackingParticleRefKeyToCount& tpKeyToClusterCount, @@ -696,13 +703,15 @@ class TrackingNtuple : public edm::one::EDAnalyzer { BOOK(layer); BOOK(side); BOOK(module); + BOOK(moduleType); } - void push_back(const TrackerTopology& tTopo, const DetId& id) { + void push_back(const TrackerGeometry& tracker, const TrackerTopology& tTopo, const DetId& id) { detId.push_back(id.rawId()); subdet.push_back(id.subdetId()); layer.push_back(tTopo.layer(id)); module.push_back(tTopo.module(id)); + moduleType.push_back(static_cast(tracker.getDetectorType(id))); unsigned short s = 0; switch (id.subdetId()) { @@ -724,14 +733,16 @@ class TrackingNtuple : public edm::one::EDAnalyzer { layer.resize(size); side.resize(size); module.resize(size); + moduleType.resize(size); } - void set(size_t index, const TrackerTopology& tTopo, const DetId& id) { + void set(size_t index, const TrackerGeometry& tracker, const TrackerTopology& tTopo, const DetId& id) { detId[index] = id.rawId(); subdet[index] = id.subdetId(); layer[index] = tTopo.layer(id); side[index] = tTopo.side(id); module[index] = tTopo.module(id); + moduleType[index] = static_cast(tracker.getDetectorType(id)); } void clear() { @@ -740,6 +751,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { layer.clear(); side.clear(); module.clear(); + moduleType.clear(); } private: @@ -748,6 +760,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { std::vector layer; // or disk/wheel std::vector side; std::vector module; + std::vector moduleType; }; class DetIdPixelOnly { @@ -760,7 +773,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { BOOK(panel); } - void push_back(const TrackerTopology& tTopo, const DetId& id) { + void push_back(const TrackerGeometry& tracker, const TrackerTopology& tTopo, const DetId& id) { const bool isBarrel = id.subdetId() == PixelSubdetector::PixelBarrel; ladder.push_back(isBarrel ? tTopo.pxbLadder(id) : 0); blade.push_back(isBarrel ? 0 : tTopo.pxfBlade(id)); @@ -789,7 +802,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { BOOK(rod); } - void push_back(const TrackerTopology& tTopo, const DetId& id) { + void push_back(const TrackerGeometry& tracker, const TrackerTopology& tTopo, const DetId& id) { const auto parsed = parse(tTopo, id); order.push_back(parsed.order); ring.push_back(parsed.ring); @@ -802,7 +815,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { rod.resize(size); } - void set(size_t index, const TrackerTopology& tTopo, const DetId& id) { + void set(size_t index, const TrackerGeometry& tracker, const TrackerTopology& tTopo, const DetId& id) { const auto parsed = parse(tTopo, id); order[index] = parsed.order; ring[index] = parsed.ring; @@ -855,7 +868,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { BOOK(isGlued); } - void push_back(const TrackerTopology& tTopo, const DetId& id) { + void push_back(const TrackerGeometry& tracker, const TrackerTopology& tTopo, const DetId& id) { const auto parsed = parse(tTopo, id); string.push_back(parsed.string); petalNumber.push_back(parsed.petalNumber); @@ -872,7 +885,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { isGlued.resize(size); } - void set(size_t index, const TrackerTopology& tTopo, const DetId& id) { + void set(size_t index, const TrackerGeometry& tracker, const TrackerTopology& tTopo, const DetId& id) { const auto parsed = parse(tTopo, id); string[index] = parsed.string; petalNumber[index] = parsed.petalNumber; @@ -929,7 +942,7 @@ class TrackingNtuple : public edm::one::EDAnalyzer { BOOK(isStack); } - void push_back(const TrackerTopology& tTopo, const DetId& id) { + void push_back(const TrackerGeometry& tracker, const TrackerTopology& tTopo, const DetId& id) { isLower.push_back(tTopo.isLower(id)); isUpper.push_back(tTopo.isUpper(id)); isStack.push_back(tTopo.stack(id) == @@ -2219,6 +2232,7 @@ void TrackingNtuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iS //pixel hits fillPixelHits(iEvent, + tracker, clusterToTPMap, tpKeyToIndex, *simHitsTPAssoc, @@ -2233,6 +2247,7 @@ void TrackingNtuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iS LogDebug("TrackingNtuple") << "foundStripSimLink"; const auto& stripDigiSimLinks = *stripDigiSimLinksHandle; fillStripRphiStereoHits(iEvent, + tracker, clusterToTPMap, tpKeyToIndex, *simHitsTPAssoc, @@ -2243,7 +2258,7 @@ void TrackingNtuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iS hitProductIds); //matched hits - fillStripMatchedHits(iEvent, *theTTRHBuilder, tTopo, monoStereoClusterList); + fillStripMatchedHits(iEvent, tracker, *theTTRHBuilder, tTopo, monoStereoClusterList); } if (includePhase2OTHits_) { @@ -2251,6 +2266,7 @@ void TrackingNtuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iS const auto& phase2OTSimLinks = *siphase2OTSimLinksHandle; fillPhase2OTHits(iEvent, clusterToTPMap, + tracker, tpKeyToIndex, *simHitsTPAssoc, phase2OTSimLinks, @@ -2267,6 +2283,7 @@ void TrackingNtuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iS tpCollection, tpKeyToIndex, bs, + tracker, associatorByHits, clusterToTPMap, *theTTRHBuilder, @@ -2317,6 +2334,7 @@ void TrackingNtuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iS iEvent.getByToken(vertexToken_, vertices); fillTracks(trackRefs, + tracker, tpCollection, tpKeyToIndex, tpKeyToClusterCount, @@ -2654,9 +2672,9 @@ void TrackingNtuple::fillSimHits(const TrackerGeometry& tracker, simHitRefKeyToIndex[simHitKey] = simHitIndex; if (includeStripHits_) - simhit_detId.push_back(tTopo, detId); + simhit_detId.push_back(tracker, tTopo, detId); else - simhit_detId_phase2.push_back(tTopo, detId); + simhit_detId_phase2.push_back(tracker, tTopo, detId); simhit_x.push_back(pos.x()); simhit_y.push_back(pos.y()); simhit_z.push_back(pos.z()); @@ -2682,6 +2700,7 @@ void TrackingNtuple::fillSimHits(const TrackerGeometry& tracker, } void TrackingNtuple::fillPixelHits(const edm::Event& iEvent, + const TrackerGeometry& tracker, const ClusterTPAssociation& clusterToTPMap, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList& simHitsTPAssoc, @@ -2719,7 +2738,7 @@ void TrackingNtuple::fillPixelHits(const edm::Event& iEvent, const int lay = tTopo.layer(hitId); pix_isBarrel.push_back(hitId.subdetId() == 1); - pix_detId.push_back(tTopo, hitId); + pix_detId.push_back(tracker, tTopo, hitId); pix_trkIdx.emplace_back(); // filled in fillTracks pix_seeIdx.emplace_back(); // filled in fillSeeds pix_x.push_back(ttrh->globalPosition().x()); @@ -2771,6 +2790,7 @@ void TrackingNtuple::fillPixelHits(const edm::Event& iEvent, } void TrackingNtuple::fillStripRphiStereoHits(const edm::Event& iEvent, + const TrackerGeometry& tracker, const ClusterTPAssociation& clusterToTPMap, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList& simHitsTPAssoc, @@ -2836,7 +2856,7 @@ void TrackingNtuple::fillStripRphiStereoHits(const edm::Event& iEvent, const int key = hit.cluster().key(); const int lay = tTopo.layer(hitId); str_isBarrel[key] = (hitId.subdetId() == StripSubdetector::TIB || hitId.subdetId() == StripSubdetector::TOB); - str_detId.set(key, tTopo, hitId); + str_detId.set(key, tracker, tTopo, hitId); str_x[key] = ttrh->globalPosition().x(); str_y[key] = ttrh->globalPosition().y(); str_z[key] = ttrh->globalPosition().z(); @@ -2892,6 +2912,7 @@ void TrackingNtuple::fillStripRphiStereoHits(const edm::Event& iEvent, } size_t TrackingNtuple::addStripMatchedHit(const SiStripMatchedRecHit2D& hit, + const TrackerGeometry& tracker, const TransientTrackingRecHitBuilder& theTTRHBuilder, const TrackerTopology& tTopo, const std::vector>& stripMasks, @@ -2910,7 +2931,7 @@ size_t TrackingNtuple::addStripMatchedHit(const SiStripMatchedRecHit2D& hit, const int lay = tTopo.layer(hitId); monoStereoClusterList.emplace_back(hit.monoHit().cluster().key(), hit.stereoHit().cluster().key()); glu_isBarrel.push_back((hitId.subdetId() == StripSubdetector::TIB || hitId.subdetId() == StripSubdetector::TOB)); - glu_detId.push_back(tTopo, hitId); + glu_detId.push_back(tracker, tTopo, hitId); glu_monoIdx.push_back(hit.monoHit().cluster().key()); glu_stereoIdx.push_back(hit.stereoHit().cluster().key()); glu_seeIdx.emplace_back(); // filled in fillSeeds @@ -2938,6 +2959,7 @@ size_t TrackingNtuple::addStripMatchedHit(const SiStripMatchedRecHit2D& hit, } void TrackingNtuple::fillStripMatchedHits(const edm::Event& iEvent, + const TrackerGeometry& tracker, const TransientTrackingRecHitBuilder& theTTRHBuilder, const TrackerTopology& tTopo, std::vector>& monoStereoClusterList) { @@ -2953,13 +2975,14 @@ void TrackingNtuple::fillStripMatchedHits(const edm::Event& iEvent, iEvent.getByToken(stripMatchedRecHitToken_, matchedHits); for (auto it = matchedHits->begin(); it != matchedHits->end(); it++) { for (auto hit = it->begin(); hit != it->end(); hit++) { - addStripMatchedHit(*hit, theTTRHBuilder, tTopo, stripMasks, monoStereoClusterList); + addStripMatchedHit(*hit, tracker, theTTRHBuilder, tTopo, stripMasks, monoStereoClusterList); } } } void TrackingNtuple::fillPhase2OTHits(const edm::Event& iEvent, const ClusterTPAssociation& clusterToTPMap, + const TrackerGeometry& tracker, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList& simHitsTPAssoc, const edm::DetSetVector& digiSimLink, @@ -2980,7 +3003,7 @@ void TrackingNtuple::fillPhase2OTHits(const edm::Event& iEvent, const int lay = tTopo.layer(hitId); ph2_isBarrel.push_back(hitId.subdetId() == 1); - ph2_detId.push_back(tTopo, hitId); + ph2_detId.push_back(tracker, tTopo, hitId); ph2_trkIdx.emplace_back(); // filled in fillTracks ph2_seeIdx.emplace_back(); // filled in fillSeeds ph2_x.push_back(ttrh->globalPosition().x()); @@ -3032,6 +3055,7 @@ void TrackingNtuple::fillSeeds(const edm::Event& iEvent, const TrackingParticleRefVector& tpCollection, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const reco::BeamSpot& bs, + const TrackerGeometry& tracker, const reco::TrackToTrackingParticleAssociator& associatorByHits, const ClusterTPAssociation& clusterToTPMap, const TransientTrackingRecHitBuilder& theTTRHBuilder, @@ -3268,7 +3292,7 @@ void TrackingNtuple::fillSeeds(const edm::Event& iEvent, // SiStripMatchedRecHit2DCollection, e.g. via muon // outside-in seeds (or anything taking hits from // MeasurementTrackerEvent). So let's add them here. - gluedIndex = addStripMatchedHit(*matchedHit, theTTRHBuilder, tTopo, stripMasks, monoStereoClusterList); + gluedIndex = addStripMatchedHit(*matchedHit, tracker, theTTRHBuilder, tTopo, stripMasks, monoStereoClusterList); } if (includeAllHits_) @@ -3401,6 +3425,7 @@ void TrackingNtuple::fillSeeds(const edm::Event& iEvent, } void TrackingNtuple::fillTracks(const edm::RefToBaseVector& tracks, + const TrackerGeometry& tracker, const TrackingParticleRefVector& tpCollection, const TrackingParticleRefKeyToIndex& tpKeyToIndex, const TrackingParticleRefKeyToCount& tpKeyToClusterCount, @@ -3670,9 +3695,9 @@ void TrackingNtuple::fillTracks(const edm::RefToBaseVector& tracks, inv_isBarrel.push_back(hitId.subdetId() == 1); if (includeStripHits_) - inv_detId.push_back(tTopo, hitId); + inv_detId.push_back(tracker, tTopo, hitId); else - inv_detId_phase2.push_back(tTopo, hitId); + inv_detId_phase2.push_back(tracker, tTopo, hitId); inv_type.push_back(hit->getType()); } }