From 1d33be2d6015ca1288068aeaff9bbfae3c2cc121 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sun, 22 Sep 2019 20:49:17 +0200 Subject: [PATCH 001/115] commit VH technical integration changes only - VH switched off by default --- CommonTools/RecoAlgos/src/ClusterStorer.cc | 5 + DataFormats/TrackerRecHit2D/BuildFile.xml | 19 +- .../interface/BaseTrackerRecHit.h | 8 +- .../TrackerRecHit2D/interface/TkCloner.h | 3 + .../TrackerRecHit2D/interface/VectorHit.h | 164 +++ .../TrackerRecHit2D/interface/VectorHit2D.h | 32 + .../interface/trackerHitRTTI.h | 4 +- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 452 +++++++ DataFormats/TrackerRecHit2D/src/classes.h | 121 +- .../TrackerRecHit2D/src/classes_def.xml | 15 + .../src/TrackerGeomBuilderFromGeometricDet.cc | 4 +- .../python/RecoLocalTracker_cff.py | 1 + .../SiPhase2VectorHitBuilder/BuildFile.xml | 16 + .../interface/VectorHitBuilderAlgorithm.h | 80 ++ .../interface/VectorHitBuilderAlgorithmBase.h | 75 ++ .../interface/VectorHitBuilderEDProducer.h | 41 + .../plugins/BuildFile.xml | 4 + .../plugins/SealModules.cc | 11 + .../SiPhase2RecHitMatcherESProducer.cc | 34 + .../plugins/SiPhase2RecHitMatcherESProducer.h | 23 + .../python/SiPhase2RecHitMatcher_cfi.py | 17 + .../python/SiPhase2VectorHitBuilder_cfi.py | 12 + .../src/VectorHitBuilderAlgorithm.cc | 397 ++++++ .../src/VectorHitBuilderAlgorithmBase.cc | 151 +++ .../src/VectorHitBuilderEDProducer.cc | 107 ++ .../test/BuildFile.xml | 33 + .../test/ClustersValidationTGraph.cc | 584 +++++++++ .../test/Clusters_productionAndTesting.py | 103 ++ .../test/VHs_combinatorialStudies_PU200.py | 123 ++ .../test/VHs_productionAndTesting.py | 114 ++ ...oductionAndTesting_TenMuExtendedE_0_200.py | 105 ++ .../test/VectorHitsValidation.cc | 1154 +++++++++++++++++ .../test/VectorHitsValidation.h | 144 ++ .../test/step3_SeedingOT_tilted.py | 117 ++ .../src/SeedClusterRemoverPhase2.cc | 38 +- .../src/TrackClusterRemoverPhase2.cc | 14 + RecoTracker/CkfPattern/src/PrintoutHelper.cc | 10 +- .../plugins/DuplicateTrackMerger.cc | 10 + .../plugins/TrackerRecoGeometryESProducer.cc | 9 +- .../TrackerRecoGeometryESProducer_cfi.py | 6 +- RecoTracker/MeasurementDet/BuildFile.xml | 1 + .../plugins/MeasurementTrackerESProducer.cc | 9 + .../MeasurementTrackerEventProducer.cc | 3 + .../plugins/MeasurementTrackerImpl.cc | 5 +- .../plugins/MeasurementTrackerImpl.h | 1 + .../plugins/TkStackMeasurementDet.cc | 106 +- .../plugins/TkStackMeasurementDet.h | 18 +- .../MeasurementTrackerESProducer_cfi.py | 1 + .../MeasurementDet/src/TkMeasurementDetSet.cc | 1 + .../MeasurementDet/src/TkMeasurementDetSet.h | 11 +- .../Record/interface/CkfComponentsRecord.h | 1 + .../interface/GeometricSearchTrackerBuilder.h | 5 +- .../src/GeometricSearchTrackerBuilder.cc | 35 +- .../src/Phase2EndcapLayerBuilder.cc | 17 +- .../src/Phase2EndcapLayerBuilder.h | 4 +- .../src/Phase2EndcapRingBuilder.cc | 9 +- .../src/Phase2OTBarrelLayerBuilder.cc | 35 +- .../src/Phase2OTBarrelLayerBuilder.h | 7 +- .../TkDetLayers/src/Phase2OTBarrelRod.cc | 10 +- .../TkDetLayers/src/Phase2OTBarrelRod.h | 4 +- .../src/Phase2OTBarrelRodBuilder.cc | 119 +- .../src/Phase2OTBarrelRodBuilder.h | 7 +- .../interface/SeedingOTEDProducer.h | 71 + .../TkSeedGenerator/plugins/SealModules.cc | 3 + .../src/SeedingOTEDProducer.cc | 445 +++++++ .../TkSeedingLayers/src/HitExtractorSTRP.cc | 527 ++++---- .../TkSeedingLayers/src/HitExtractorSTRP.h | 10 + .../src/SeedingLayerSetsBuilder.cc | 3 + .../interface/TkClonerImpl.h | 3 +- ...ransientTrackingRecHitBuilderESProducer.cc | 1 + .../src/TkClonerImpl.cc | 9 + .../plugins/QuickTrackAssociatorByHitsImpl.cc | 9 +- 72 files changed, 5450 insertions(+), 400 deletions(-) create mode 100644 DataFormats/TrackerRecHit2D/interface/VectorHit.h create mode 100644 DataFormats/TrackerRecHit2D/interface/VectorHit2D.h create mode 100644 DataFormats/TrackerRecHit2D/src/VectorHit.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/BuildFile.xml create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting_TenMuExtendedE_0_200.py create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/step3_SeedingOT_tilted.py create mode 100644 RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h create mode 100644 RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc diff --git a/CommonTools/RecoAlgos/src/ClusterStorer.cc b/CommonTools/RecoAlgos/src/ClusterStorer.cc index e08c16c59fc07..820837d660ab1 100644 --- a/CommonTools/RecoAlgos/src/ClusterStorer.cc +++ b/CommonTools/RecoAlgos/src/ClusterStorer.cc @@ -9,6 +9,7 @@ #include "DataFormats/TrackerRecHit2D/interface/ProjectedSiStripRecHit2D.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h" #include "DataFormats/TrackerRecHit2D/interface/Phase2TrackerRecHit1D.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" // FastSim hits: #include "DataFormats/TrackerRecHit2D/interface/FastTrackerRecHit.h" #include "DataFormats/TrackerRecHit2D/interface/FastProjectedTrackerRecHit.h" @@ -47,6 +48,10 @@ namespace helper { //std::cout << "| It is a Phase2TrackerRecHit1D hit !!" << std::endl; phase2OTClusterRecords_.push_back( Phase2OTClusterHitRecord(static_cast(newHit), hits, index)); + } else if (hit_type == typeid(VectorHit)) { + //FIXME:: this is just temporary solution for phase2, + //the VectorHit has 2 clusters but just a hit! + phase2OTClusterRecords_.push_back(Phase2OTClusterHitRecord(static_cast(newHit), hits, index)); } else { if (hit_type == typeid(FastTrackerRecHit) || hit_type == typeid(FastProjectedTrackerRecHit) || hit_type == typeid(FastMatchedTrackerRecHit)) { diff --git a/DataFormats/TrackerRecHit2D/BuildFile.xml b/DataFormats/TrackerRecHit2D/BuildFile.xml index 17ee9fb29a2e0..085dd084880ff 100644 --- a/DataFormats/TrackerRecHit2D/BuildFile.xml +++ b/DataFormats/TrackerRecHit2D/BuildFile.xml @@ -1,12 +1,13 @@ - - - - - - - - - + + + + + + + + + + diff --git a/DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h b/DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h index 9928e44849e48..79a8fdfe4d2bc 100644 --- a/DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h +++ b/DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h @@ -23,6 +23,7 @@ class BaseTrackerRecHit : public TrackingRecHit { // no position (as in persistent) BaseTrackerRecHit(DetId id, trackerHitRTTI::RTTI rt) : TrackingRecHit(id, (unsigned int)(rt)), qualWord_(0) {} + BaseTrackerRecHit(const GeomDet & idet, trackerHitRTTI::RTTI rt) : TrackingRecHit(idet,(unsigned int)(rt)),qualWord_(0) {} BaseTrackerRecHit(const LocalPoint& p, const LocalError& e, GeomDet const& idet, trackerHitRTTI::RTTI rt) : TrackingRecHit(idet, (unsigned int)(rt)), pos_(p), err_(e), qualWord_(0) { @@ -49,18 +50,17 @@ class BaseTrackerRecHit : public TrackingRecHit { // verify that hits can share clusters... inline bool sameDetModule(TrackingRecHit const& hit) const; - bool hasPositionAndError() const final; + bool hasPositionAndError() const override; - LocalPoint localPosition() const final { + LocalPoint localPosition() const override{ check(); return pos_; } - LocalError localPositionError() const final { + LocalError localPositionError() const override{ check(); return err_; } - const LocalPoint& localPositionFast() const { check(); return pos_; diff --git a/DataFormats/TrackerRecHit2D/interface/TkCloner.h b/DataFormats/TrackerRecHit2D/interface/TkCloner.h index ed6ea47cd5d8d..81412962b97e6 100644 --- a/DataFormats/TrackerRecHit2D/interface/TkCloner.h +++ b/DataFormats/TrackerRecHit2D/interface/TkCloner.h @@ -11,6 +11,7 @@ class SiStripRecHit1D; class SiStripMatchedRecHit2D; class ProjectedSiStripRecHit2D; class Phase2TrackerRecHit1D; +class VectorHit; class TkCloner { public: @@ -39,6 +40,7 @@ class TkCloner { TrajectoryStateOnSurface const& tsos) const = 0; virtual std::unique_ptr operator()(Phase2TrackerRecHit1D const& hit, TrajectoryStateOnSurface const& tsos) const = 0; + virtual std::unique_ptr operator()(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const=0; #ifndef __GCCXML__ virtual TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const& hit, @@ -53,6 +55,7 @@ class TkCloner { TrajectoryStateOnSurface const& tsos) const = 0; virtual TrackingRecHit::ConstRecHitPointer makeShared(Phase2TrackerRecHit1D const& hit, TrajectoryStateOnSurface const& tsos) const = 0; + virtual TrackingRecHit::ConstRecHitPointer makeShared(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const=0; #endif }; #endif diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h new file mode 100644 index 0000000000000..693e332611e51 --- /dev/null +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -0,0 +1,164 @@ +#ifndef TrackerRecHit2D_VectorHit_h +#define TrackerRecHit2D_VectorHit_h + +/** \class VectorHit + * + * 4-parameter RecHits for Phase2 Tracker (x,y, dx/dz, dy/dz) + * + * $Date: 2015/03/30 $ + * \author Erica Brondolin + * + */ + +#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit2D.h" +#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h" + +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" + +#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" +#include "DataFormats/GeometryVector/interface/LocalVector.h" +#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" +#include "MagneticField/Engine/interface/MagneticField.h" + +#include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h" + +#include "TkCloner.h" + +class VectorHit GCC11_FINAL : public BaseTrackerRecHit { + + public: + + typedef OmniClusterRef::Phase2Cluster1DRef ClusterRef; + + VectorHit() : thePosition(), theDirection(), theCovMatrix(), theDimension(0) { setType(bad); } + + VectorHit(const VectorHit& vh) ; + + VectorHit(const GeomDet& idet, const LocalPoint& posInner, const LocalVector& dir, + const AlgebraicSymMatrix& covMatrix, const double& Chi2, + OmniClusterRef const& lower, OmniClusterRef const& upper) ; + + VectorHit(const GeomDet& idet, const VectorHit2D& vh2Dzx, const VectorHit2D& vh2Dzy, + OmniClusterRef const& lower, OmniClusterRef const& upper) ; + + ~VectorHit() ; + + virtual VectorHit* clone() const override { return new VectorHit(*this);} +#ifndef __GCCXML__ + virtual RecHitPointer cloneSH() const override { return std::make_shared(*this);} +#endif + + virtual bool sharesInput( const TrackingRecHit* other, SharedInputType what) const override; + bool sharesClusters(VectorHit const & h1, VectorHit const & h2, + SharedInputType what) const ; + + // Parameters of the segment, for the track fit + // For a 4D segment: (dx/dz,dy/dz,x,y) + bool hasPositionAndError() const GCC11_FINAL{ + //bool hasPositionAndError() const { + return true; +// return (err_.xx() != 0) || (err_.yy() != 0) || (err_.xy() != 0) || +// (pos_.x() != 0) || (pos_.y() != 0) || (pos_.z() != 0); + }; + + virtual AlgebraicVector parameters() const override; + virtual void getKfComponents( KfComponentsHolder & holder ) const override { getKfComponents4D(holder); } + void getKfComponents4D( KfComponentsHolder & holder ) const ; + + // returning methods + LocalPoint localPosition() const GCC11_FINAL { return thePosition; } + virtual LocalVector localDirection() const { return theDirection; } + AlgebraicSymMatrix parametersError() const override ; + LocalError localPositionError() const GCC11_FINAL ; + virtual LocalError localDirectionError() const ; + Global3DVector globalDirection() const; + + virtual double chi2() const { return theChi2; } + virtual int dimension() const override { return theDimension; } + + std::pair curvatureORphi(std::string curvORphi = "curvature") const ; + float transverseMomentum(const MagneticField* magField); + float momentum(const MagneticField* magField); + + ClusterRef lowerCluster() const { return theLowerCluster.cluster_phase2OT(); } + ClusterRef upperCluster() const { return theUpperCluster.cluster_phase2OT(); } + OmniClusterRef const lowerClusterRef() const { return theLowerCluster; } + OmniClusterRef const upperClusterRef() const { return theUpperCluster; } + + //FIXME::to update with a proper CPE maybe... + Global3DPoint lowerGlobalPos() const ; + Global3DPoint upperGlobalPos() const ; + Global3DPoint phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster) const; + GlobalError lowerGlobalPosErr() const ; + GlobalError upperGlobalPosErr() const ; + GlobalError phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet) const; + + virtual bool isPhase2() const override { return true; } + + //FIXME: I have always two clusters in a VH + virtual OmniClusterRef const & firstClusterRef() const GCC11_FINAL { return theLowerCluster;} + ClusterRef cluster() const { return theLowerCluster.cluster_phase2OT(); } + + //This method returns the delta in global coordinates + Global3DVector globalDelta() const; + float theta(); + + /// The projection matrix relates the trajectory state parameters to the segment parameters(). + virtual AlgebraicMatrix projectionMatrix() const override; + + // Degrees of freedom of the segment fit + virtual int degreesOfFreedom() const { return 0; } //number of hits (2+2) - dimension + + // Access to component RecHits (if any) + virtual std::vector recHits() const override; + virtual std::vector recHits() override ; + + // setting methods + void setPosition(LocalPoint pos) { thePosition = pos; } + void setDirection(LocalVector dir) { theDirection = dir; } + void setCovMatrix(AlgebraicSymMatrix mat) { theCovMatrix = mat; } + + private: + // double dispatch + virtual VectorHit * clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override{ + return cloner(*this,tsos).release(); + } + virtual RecHitPointer cloneSH_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override{ + return cloner.makeShared(*this,tsos); + } + + LocalPoint thePosition; + LocalVector theDirection; + + // the covariance matrix, has the following meaning + // mat[0][0]=var(dx/dz) + // mat[1][1]=var(dy/dz) + // mat[2][2]=var(x) + // mat[3][3]=var(y) + // mat[0][2]=cov(dx/dz,x) + // mat[1][3]=cov(dy/dz,y) + AlgebraicSymMatrix theCovMatrix; + double theChi2; + int theDimension; + OmniClusterRef theLowerCluster; + OmniClusterRef theUpperCluster; + +}; + +inline bool operator<( const VectorHit& one, const VectorHit& other) { + + if ( one.chi2() > other.chi2() ) { + return true; + } + + return false; +} + +std::ostream& operator<<(std::ostream& os, const VectorHit& vh); + +typedef edmNew::DetSetVector VectorHitCollection; +typedef VectorHitCollection VectorHitCollectionNew; + +#endif diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h new file mode 100644 index 0000000000000..91438a397746e --- /dev/null +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -0,0 +1,32 @@ +#ifndef TrackingRecHit_VectorHit2D_h +#define TrackingRecHit_VectorHit2D_h + +#include "DataFormats/GeometryVector/interface/LocalVector.h" +#include "DataFormats/GeometryVector/interface/LocalPoint.h" + +class VectorHit2D { + + public: + VectorHit2D() : thePosition(), theDirection(), theCovMatrix(), theChi2(), theDimension(2) {} + VectorHit2D(const LocalPoint& pos, const LocalVector& dir, const AlgebraicSymMatrix22& covMatrix, const double& Chi2) : + thePosition(pos), theDirection(dir), theCovMatrix(covMatrix), theChi2(Chi2), theDimension(2){}; + virtual ~VectorHit2D() {}; + + LocalPoint localPosition() const { return thePosition; } + LocalVector localDirection() const { return theDirection; } + LocalError localDirectionError() const { return LocalError(theCovMatrix[0][0],theCovMatrix[0][1],theCovMatrix[1][1]); } + AlgebraicSymMatrix22 covMatrix() const { return theCovMatrix; } + double chi2() const { return theChi2; } + int degreesOfFreedom() const { return 0; } //number of hits (2) - dimension + int dimension() const { return 2; } + + private: + LocalPoint thePosition; + LocalVector theDirection; + AlgebraicSymMatrix22 theCovMatrix; + double theChi2; + int theDimension; + +}; +#endif + diff --git a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h index 23370e4284049..6268b68ca0d8b 100644 --- a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h +++ b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h @@ -17,7 +17,8 @@ namespace trackerHitRTTI { fastProjMono = 8, fastMatch = 9, notFromCluster = 10, - mipTiming = 11 + mipTiming = 11, + vector = 12 }; inline RTTI rtti(TrackingRecHit const& hit) { return RTTI(hit.getRTTI()); } inline bool isUndef(TrackingRecHit const& hit) { return rtti(hit) == undef; } @@ -36,6 +37,7 @@ namespace trackerHitRTTI { inline bool isFast(TrackingRecHit const& hit) { return (rtti(hit) > 5) & (rtti(hit) <= 9); } inline bool isFromDetOrFast(TrackingRecHit const& hit) { return (rtti(hit) > 0) & (rtti(hit) < 10); } inline bool isTiming(TrackingRecHit const& hit) { return rtti(hit) == mipTiming; } + inline bool isVector(TrackingRecHit const & hit) { return rtti(hit)==vector;} inline unsigned int projId(TrackingRecHit const& hit) { return hit.rawId() + int(rtti(hit)) - 1; } } // namespace trackerHitRTTI diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc new file mode 100644 index 0000000000000..83ebea20d2b11 --- /dev/null +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -0,0 +1,452 @@ +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "Geometry/TrackerGeometryBuilder/interface/StackGeomDet.h" + +VectorHit::VectorHit(const VectorHit& vh): + BaseTrackerRecHit(*vh.det(), trackerHitRTTI::vector), + thePosition(vh.localPosition()), + theDirection(vh.localDirection()), + theCovMatrix(vh.parametersError()), + theChi2(vh.chi2()), + theDimension(vh.dimension()), + theLowerCluster(vh.lowerClusterRef()), + theUpperCluster(vh.upperClusterRef()) +{} + +VectorHit::VectorHit(const GeomDet& idet, + const LocalPoint& posLower, + const LocalVector& dir, + const AlgebraicSymMatrix& covMatrix, + const double& Chi2, + OmniClusterRef const& lower, OmniClusterRef const& upper) : + BaseTrackerRecHit(idet, trackerHitRTTI::vector), + thePosition(posLower), + theDirection(dir), + theCovMatrix(covMatrix), + theChi2(Chi2), + theDimension(4), + theLowerCluster(lower), + theUpperCluster(upper) +{} + +VectorHit::VectorHit(const GeomDet& idet, const VectorHit2D& vh2Dzx, const VectorHit2D& vh2Dzy, + OmniClusterRef const& lower, OmniClusterRef const& upper) : + BaseTrackerRecHit(idet, trackerHitRTTI::vector), + theDimension(4), + theLowerCluster(lower), + theUpperCluster(upper) +{ + thePosition = LocalPoint(vh2Dzx.localPosition().x(), vh2Dzy.localPosition().x(), 0.); + + theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), 1.); + //theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), vh2Dzy.localDirection().z()); + //theDirection = theDirection.unit(); + + //building the cov matrix 4x4 starting from the 2x2 + AlgebraicSymMatrix22 covMatZX = vh2Dzx.covMatrix(); + AlgebraicSymMatrix22 covMatZY = vh2Dzy.covMatrix(); + + theCovMatrix=AlgebraicSymMatrix(4); + theCovMatrix[0][0] = covMatZX[0][0]; // var(dx/dz) + theCovMatrix[1][1] = covMatZY[0][0]; // var(dy/dz) + theCovMatrix[2][2] = covMatZX[1][1]; // var(x) + theCovMatrix[3][3] = covMatZY[1][1]; // var(y) + theCovMatrix[0][2] = covMatZX[0][1]; // cov(dx/dz,x) + theCovMatrix[1][3] = covMatZY[0][1]; // cov(dy/dz,y) + + theChi2 = vh2Dzx.chi2() + vh2Dzy.chi2(); +} + +bool VectorHit::sharesInput( const TrackingRecHit* other, SharedInputType what) const +{ + if (what==all && (geographicalId() != other->geographicalId())) return false; + + if (!sameDetModule(*other)) return false; + + if (trackerHitRTTI::isVector(*other) ) { + const VectorHit* otherVh = static_cast(other); + return sharesClusters(*this, *otherVh, what); + } + + if (what==all) return false; + + // what about multi??? + auto const & otherClus = reinterpret_cast(other)->firstClusterRef(); + return (otherClus==lowerClusterRef()) || (otherClus==upperClusterRef()); + +} + +bool VectorHit::sharesClusters(VectorHit const & h1, VectorHit const & h2, + SharedInputType what) const { + bool lower = h1.lowerClusterRef()== h2.lowerClusterRef(); + bool upper = h1.upperClusterRef()== h2.upperClusterRef(); + + return (what==TrackingRecHit::all) ? (lower && upper) : (upper||lower); + +} + +void VectorHit::getKfComponents4D( KfComponentsHolder & holder ) const { + //if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents"); + AlgebraicVector4 & pars = holder.params<4>(); + pars[0] = theDirection.x(); + pars[1] = theDirection.y(); + pars[2] = thePosition.x(); + pars[3] = thePosition.y(); + + AlgebraicSymMatrix44 & errs = holder.errors<4>(); + for(int i = 0; i < 4; i++){ + for(int j = 0; j < 4; j++){ + errs(i,j) = theCovMatrix[i][j]; + } + } + + ProjectMatrix & pf = holder.projFunc<4>(); + pf.index[0] = 1; + pf.index[1] = 2; + pf.index[2] = 3; + pf.index[3] = 4; + + holder.measuredParams<4>() = AlgebraicVector4( & holder.tsosLocalParameters().At(1), 4 ); + holder.measuredErrors<4>() = holder.tsosLocalErrors().Sub( 1, 1 ); + +} + +VectorHit::~VectorHit() {} + +AlgebraicVector VectorHit::parameters() const { + + // (dx/dz,dy/dz,x,y) + AlgebraicVector result(4); + + result[0] = theDirection.x(); + result[1] = theDirection.y(); + result[2] = thePosition.x(); + result[3] = thePosition.y(); + return result; + +} + +Global3DPoint VectorHit::lowerGlobalPos() const { + const StackGeomDet* stackDet = dynamic_cast< const StackGeomDet* >(det()); + const PixelGeomDetUnit* geomDetLower = dynamic_cast< const PixelGeomDetUnit* >(stackDet->lowerDet()); + return phase2clusterGlobalPos(geomDetLower, lowerCluster()); +} + +Global3DPoint VectorHit::upperGlobalPos() const { + const StackGeomDet* stackDet = dynamic_cast< const StackGeomDet* >(det()); + const PixelGeomDetUnit* geomDetUpper = dynamic_cast< const PixelGeomDetUnit* >(stackDet->upperDet()); + return phase2clusterGlobalPos(geomDetUpper, upperCluster()); +} + +Global3DPoint VectorHit::phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster) const { + const PixelTopology * topo = &geomDet->specificTopology(); + float ix = cluster->center(); + float iy = cluster->column()+0.5; // halfway the column + LocalPoint lp( topo->localX(ix), topo->localY(iy), 0 ); // x, y, z + Global3DPoint gp = geomDet->surface().toGlobal(lp); + return gp; +} + +GlobalError VectorHit::lowerGlobalPosErr() const { + const StackGeomDet* stackDet = dynamic_cast< const StackGeomDet* >(det()); + const PixelGeomDetUnit* geomDetLower = dynamic_cast< const PixelGeomDetUnit* >(stackDet->lowerDet()); + return phase2clusterGlobalPosErr(geomDetLower); +} + +GlobalError VectorHit::upperGlobalPosErr() const { + const StackGeomDet* stackDet = dynamic_cast< const StackGeomDet* >(det()); + const PixelGeomDetUnit* geomDetUpper = dynamic_cast< const PixelGeomDetUnit* >(stackDet->upperDet()); + return phase2clusterGlobalPosErr(geomDetUpper); +} + +GlobalError VectorHit::phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet) const { + const PixelTopology * topo = &geomDet->specificTopology(); + float pitchX = topo->pitch().first; + float pitchY = topo->pitch().second; + LocalError le( pow(pitchX, 2) / 12., 0, pow(pitchY, 2) / 12.); // e2_xx, e2_xy, e2_yy + GlobalError ge( ErrorFrameTransformer().transform( le, geomDet->surface() )); + return ge; +} + +Global3DVector VectorHit::globalDelta() const { + Local3DVector theLocalDelta = LocalVector(theDirection.x()*theDirection.z(), theDirection.y()*theDirection.z(), theDirection.z()); + Global3DVector g = det()->surface().toGlobal(theLocalDelta); + return g; +} + +Global3DVector VectorHit::globalDirection() const { + return (det()->surface().toGlobal(localDirection())); +} + +std::pair VectorHit::curvatureORphi(std::string curvORphi) const { + + double curvature = 0.0; + double errorCurvature = 0.0; + double phi = 0.0; + + //global pos and errors + Global3DPoint gPositionLower = lowerGlobalPos(); + Global3DPoint gPositionUpper = upperGlobalPos(); + + GlobalError gErrorLower = lowerGlobalPosErr(); + GlobalError gErrorUpper = upperGlobalPosErr(); + + //insert lower and upper in the global sor + if(gPositionLower.perp() > gPositionUpper.perp()){ + gPositionLower = upperGlobalPos(); + gPositionUpper = lowerGlobalPos(); + gErrorLower = upperGlobalPosErr(); + gErrorUpper = lowerGlobalPosErr(); + } + + double h1 = gPositionLower.x()*gPositionUpper.y() - gPositionUpper.x()*gPositionLower.y(); + + //determine sign of curvature + AlgebraicVector2 n1; + n1[0] = -gPositionLower.y(); + n1[1] = gPositionLower.x(); + AlgebraicVector2 n2; + n2[0] = gPositionUpper.x()-gPositionLower.x(); + n2[1] = gPositionUpper.y()-gPositionLower.y(); + + double n3 = n1[0]*n2[0] + n1[1]*n2[1]; + double signCurv = -copysign(1.0,n3); + double phi1 = atan2(gPositionUpper.y()-gPositionLower.y(),gPositionUpper.x()-gPositionLower.x()); + + if(h1!=0) { + double h2 = 2*h1; + double r12 = pow(gPositionLower.x(),2) + pow(gPositionLower.y(),2); + double r22 = pow(gPositionUpper.x(),2) + pow(gPositionUpper.y(),2); + double h3 = (pow(gPositionLower.x(),2) - 2.*gPositionLower.x()*gPositionUpper.x() + pow(gPositionUpper.x(),2) + pow(gPositionLower.y(),2) - 2.*gPositionLower.y()*gPositionUpper.y() + pow(gPositionUpper.y(),2)); + double h4 = - pow(gPositionLower.x(),2)*gPositionUpper.x() + gPositionLower.x()*pow(gPositionUpper.x(),2) + + gPositionLower.x()*pow(gPositionUpper.y(),2) - gPositionUpper.x()*pow(gPositionLower.y(),2); + double h5 = pow(gPositionLower.x(),2)*gPositionUpper.y() - pow(gPositionUpper.x(),2)*gPositionLower.y() + + pow(gPositionLower.y(),2)*gPositionUpper.y() - gPositionLower.y()*pow(gPositionUpper.y(),2); + + //radius of circle + double rho = sqrt(r12*r22*h3)/(2.*h1); + curvature = 1./rho; + + //center of circle + double xcentre = h5/h2; + double ycentre = h4/h2; + + //to compute phi at the cluster points + double xtg = gPositionLower.y() - ycentre; + double ytg = -( gPositionLower.x() - xcentre); + + //to compute phi at the origin + //double xtg = ycentre; + //double ytg = -(xcentre); + phi = atan2(ytg,xtg); + + AlgebraicROOTObject<4,4>::Matrix jacobian; + for(int i = 0; i < 4; i++){ + for(int j = 0; j < 4; j++){ + jacobian[i][j] = 0.0; + } + } + + jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 + jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 + jacobian[2][0] = (h1*(2.*gPositionLower.x()*r22*h3 + (2.*gPositionLower.x() - 2.*gPositionUpper.x())*r12*r22))/(pow(r12*r22*h3,1.5)) + - (2.*gPositionUpper.y())/sqrt(r12*r22*h3); // dkappa/dx1 + jacobian[2][1] = (2.*gPositionUpper.x())/sqrt(r12*r22*h3) + (h1*(2.*gPositionLower.y()*r22*h3 + r12*r22*(2.*gPositionLower.y() + - 2.*gPositionUpper.y())))/pow(r12*r22*h3,1.5); // dkappa/dy1 + jacobian[2][2] = (2.*gPositionLower.y())/sqrt(r12*r22*h3) + (h1*(2.*gPositionUpper.x()*r12*h3 + - 2.*(gPositionLower.x() - gPositionUpper.x())*r12*r22))/pow(r12*r22*h3,1.5); // dkappa/dx2 + jacobian[2][3] = (h1*(2.*gPositionUpper.y()*r12*h3 - r12*r22*2.*(gPositionLower.y() - gPositionUpper.y())))/pow(r12*r22*h3,1.5) + - (2.*gPositionLower.x())/sqrt(r12*r22*h3); // dkappa/dy2 + + for(int i = 0; i < 4; i++){ + jacobian[2][i] = -jacobian[2][i]; + } + + AlgebraicVector2 M; + //to compute phi at the cluster points + M[0] = (gPositionLower.y() - ycentre)/pow(rho,2); // dphi/dxcentre + M[1] =-(gPositionLower.x() - xcentre)/pow(rho,2); // dphi/dycentre + //to compute phi at the origin + //float x0 = 0.0; + //float y0 = 0.0; + //M[0] = (y0 - ycentre)/pow(rho,2); // dphi/dxcentre + //M[1] =-(x0 - xcentre)/pow(rho,2); // dphi/dycentre + + AlgebraicROOTObject<2,4>::Matrix K; + K[0][0]=(2.*gPositionLower.x()*gPositionUpper.y())/h2 - (2.*gPositionUpper.y()*h5)/pow(h2,2); // dxm/dx1 + K[0][1]=(2.*gPositionUpper.x()*h5)/pow(h2,2) - (pow(gPositionUpper.x(),2) + pow(gPositionUpper.y(),2) - 2.*gPositionLower.y()*gPositionUpper.y())/h2; // dxm/dy1 + K[0][2]=(2.*gPositionLower.y()*h5)/pow(h2,2) - (2.*gPositionUpper.x()*gPositionLower.y())/h2; // dxm/dx2 + K[0][3]=(pow(gPositionLower.x(),2) + pow(gPositionLower.y(),2) - 2.*gPositionUpper.y()*gPositionLower.y())/h2 - (2.*gPositionLower.x()*h5)/pow(h2,2); // dxm/dy2 + K[1][0]=(pow(gPositionUpper.x(),2) - 2.*gPositionLower.x()*gPositionUpper.x() + pow(gPositionUpper.y(),2))/h2 - (2.*gPositionUpper.y()*h4)/pow(h2,2); // dym/dx1 + K[1][1]=(2.*gPositionUpper.x()*h4)/pow(h2,2) - (2.*gPositionUpper.x()*gPositionLower.y())/h2; // dym/dy1 + K[1][2]=(2.*gPositionLower.y()*h4)/pow(h2,2) - (pow(gPositionLower.x(),2) - 2.*gPositionUpper.x()*gPositionLower.x() + pow(gPositionLower.y(),2))/h2; // dym/dx2 + K[1][3]=(2.*gPositionLower.x()*gPositionUpper.y())/h2 - (2.*gPositionLower.x()*h4)/pow(h2,2); // dym/dy2 + + AlgebraicVector4 N = M*K; + jacobian[3][0] = N[0]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][1] = N[1]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][2] = N[2]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][3] = N[3]; // dphi/(dx1,dy1,dx2,dy2) + + //assign correct sign to the curvature errors + if( (signCurv < 0 && curvature > 0 ) || (signCurv > 0 && curvature < 0 )){ + curvature=-curvature; + for(int i = 0; i < 4; i++){ + jacobian[2][i] = -jacobian[2][i]; + } + } + + // bring phi in the same quadrant as phi1 + if (abs(phi-phi1) > M_PI/2.){ + phi = phi+M_PI; + if (phi>M_PI) + phi=phi-2.*M_PI; + } + + //computing the curvature error + AlgebraicVector4 curvatureJacobian; + for(int i = 0; i < 4; i++){ + curvatureJacobian[i] = jacobian[2][i]; + } + + AlgebraicROOTObject<4,4>::Matrix gErrors; + for(int i = 0; i < 4; i++){ + for(int j = 0; j < 4; j++){ + gErrors[i][j] = 0.0; + } + } + + gErrors[0][0] = gErrorLower.cxx(); + gErrors[0][1] = gErrorLower.cyx(); + gErrors[1][0] = gErrorLower.cyx(); + gErrors[1][1] = gErrorLower.cyy(); + gErrors[2][2] = gErrorUpper.cxx(); + gErrors[2][3] = gErrorUpper.cyx(); + gErrors[3][2] = gErrorUpper.cyx(); + gErrors[3][3] = gErrorUpper.cyy(); + + AlgebraicVector4 temp = curvatureJacobian; + temp = temp*gErrors; + errorCurvature = temp[0]*curvatureJacobian[0] + temp[1]*curvatureJacobian[1] + temp[2]*curvatureJacobian[2] + temp[3]*curvatureJacobian[3]; + //if(curvORphi == "curvature") std::cout << "curvature: " << curvature << std::endl; + //if(curvORphi == "curvature") std::cout << "curvature error: " << errorCurvature << std::endl; + + + } else { +std::cout << " straight line!" << std::endl; + return std::make_pair(0.0,0.0); + } + + if( curvORphi == "curvature" ) return std::make_pair(curvature,errorCurvature); + else if( curvORphi == "phi" ) return std::make_pair(phi,0.0); + else return std::make_pair(0.0,0.0); + +} + +float VectorHit::transverseMomentum(const MagneticField* magField){ + + GlobalPoint center(0.0, 0.0, 0.0); + float magnT = magField->inTesla(center).mag(); + double rho = 1./curvatureORphi("curvature").first; + //0.003 is because the curvature (rho) is in cm and not in m + return (0.003*magnT*rho); + +} + +float VectorHit::momentum(const MagneticField* magField){ + return transverseMomentum(magField)/(1.*sin(theta())); +} + +float VectorHit::theta(){ + return globalDirection().theta(); +} + +AlgebraicMatrix VectorHit::projectionMatrix() const { + +// static bool isInitialized=false; + static AlgebraicMatrix the4DProjectionMatrix(4, 5, 0); +/* + static AlgebraicMatrix the2DPhiProjMatrix(2, 5, 0); + static AlgebraicMatrix the2DZProjMatrix(2, 5, 0); + + if (!isInitialized) { + the4DProjectionMatrix[0][1] = 1; + the4DProjectionMatrix[1][2] = 1; + the4DProjectionMatrix[2][3] = 1; + the4DProjectionMatrix[3][4] = 1; + + the2DPhiProjMatrix[0][1] = 1; + the2DPhiProjMatrix[1][3] = 1; + + the2DZProjMatrix[0][2] = 1; + the2DZProjMatrix[1][4] = 1; + + isInitialized= true; + } + + if (dimension()==4) { + return the4DProjectionMatrix; + } else if (theProjection==phi) { + return the2DPhiProjMatrix; + } else if (theProjection==Z) { + return the2DZProjMatrix; + } else { + return AlgebraicMatrix(); + } +*/ return the4DProjectionMatrix; //ERICA:QUESTO NON ESISTEVA!! +} + + +LocalError VectorHit::localPositionError() const { + return LocalError(theCovMatrix[2][2],theCovMatrix[2][3],theCovMatrix[3][3]); +} + + +LocalError VectorHit::localDirectionError() const { + return LocalError(theCovMatrix[0][0],theCovMatrix[0][1],theCovMatrix[1][1]); +} + + + +AlgebraicSymMatrix VectorHit::parametersError() const { + + //think about a more efficient method + AlgebraicSymMatrix result(4); + for(int i = 0; i < theDimension; i++){ + for(int j = 0; j < theDimension; j++){ + result[i][j] = theCovMatrix[i][j]; + } + } + return result; +} + +std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { + + os << " VectorHit create in the DetId#: " << vh.geographicalId() << "\n" << + " Vectorhit local position : " << vh.localPosition() << "\n" << + " Vectorhit local direction : " << vh.localDirection() << "\n" << + " Vectorhit global direction : " << vh.globalDirection() << "\n" << + //" Vectorhit theta : " << vh.theta() << "\n" << + //" Cov: " << vh.parametersError() << "\n" << + //" Dim: " << vh.dimension() << "\n" << + //" chi2/ndof: " << vh.chi2() << "/" << vh.degreesOfFreedom() << "\n" << + " Lower cluster global position : " << vh.lowerGlobalPos() << "\n" << + " Upper cluster global position : " << vh.upperGlobalPos(); + + return os; +} + + +/// Access to component RecHits (if any) +std::vector VectorHit::recHits() const{ + std::vector pointersOfRecHits; + return pointersOfRecHits; +} + + +/// Non-const access to component RecHits (if any) +std::vector VectorHit::recHits(){ + + std::vector pointersOfRecHits; + return pointersOfRecHits; +} + diff --git a/DataFormats/TrackerRecHit2D/src/classes.h b/DataFormats/TrackerRecHit2D/src/classes.h index 45302da925815..44ede301244ff 100644 --- a/DataFormats/TrackerRecHit2D/src/classes.h +++ b/DataFormats/TrackerRecHit2D/src/classes.h @@ -9,9 +9,10 @@ #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h" #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" -#include "DataFormats/Common/interface/RefProd.h" -#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" -#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/RefProd.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/Wrapper.h" #include "DataFormats/Common/interface/Ref.h" #include "DataFormats/Common/interface/RefVector.h" @@ -27,6 +28,118 @@ #include "DataFormats/TrackerRecHit2D/interface/Phase2TrackerRecHit1D.h" #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h" #include "DataFormats/TrackerRecHit2D/interface/MTDTrackingRecHit.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include -#endif // SISTRIPRECHIT_CLASSES_H +namespace DataFormats_TrackerRecHit2D { + struct dictionary { + ProjectedSiStripRecHit2D projHit; + SiStripRecHit2D a1; + SiStripRecHit1D a11; + SiStripMatchedRecHit2D a2; + SiPixelRecHit b1; + + edm::ClonePolicy a4; + edm::ClonePolicy a44; + edm::ClonePolicy a5; + edm::ClonePolicy b2; + edm::ClonePolicy e2; + + edm::OwnVector > a6; + edm::OwnVector >::const_iterator it6; + edm::OwnVector > a66; + edm::OwnVector >::const_iterator it66; + edm::OwnVector > a7; + edm::OwnVector >::const_iterator it7; + edm::OwnVector > b3; + edm::OwnVector >::const_iterator it3; + edm::OwnVector > e3; + edm::OwnVector >::const_iterator it10; + + edm::OwnVector ovbtrh; + edm::Wrapper> wovbtrh; + + edm::Wrapper< edm::RangeMap >, + edm::ClonePolicy > > siStripRecHit2DLocalPosCollectionWrapper; + edm::RangeMap >, + edm::ClonePolicy >::id_iterator it2d; + + edm::Wrapper< edm::RangeMap >, + edm::ClonePolicy > > siStripRecHit1DLocalPosCollectionWrapper; + edm::RangeMap >, + edm::ClonePolicy >::id_iterator it1d; + + + edm::Wrapper< edm::RangeMap >, + edm::ClonePolicy > > siStripRecHit2DMatchedLocalPosCollectionWrapper; + edm::RangeMap >, + edm::ClonePolicy >::id_iterator itmatch; + + edm::Wrapper< edm::RangeMap >, + edm::ClonePolicy > > siPixelRecHitCollectionWrapper; + edm::RangeMap >, + edm::ClonePolicy >::id_iterator itpix; + + edm::Ref >,edm::ClonePolicy >,SiStripRecHit2D,edm::refhelper::FindUsingAdvance >,edm::ClonePolicy >,SiStripRecHit2D> > refRangeMapDetIdOwnVectorSiStripRecHit2D; + edm::RefVector >,edm::ClonePolicy >,SiStripRecHit2D,edm::refhelper::FindUsingAdvance >,edm::ClonePolicy >,SiStripRecHit2D> > refVectorRangeMapDetIdOwnVectorSiStripRecHit2D; + + edm::Ref >,edm::ClonePolicy >,SiStripRecHit1D,edm::refhelper::FindUsingAdvance >,edm::ClonePolicy >,SiStripRecHit1D> > refRangeMapDetIdOwnVectorSiStripRecHit1D; + edm::RefVector >,edm::ClonePolicy >,SiStripRecHit1D,edm::refhelper::FindUsingAdvance >,edm::ClonePolicy >,SiStripRecHit1D> > refVectorRangeMapDetIdOwnVectorSiStripRecHit1D; + + + edm::Wrapper > wdstvDummy1; + edm::Wrapper > wdstvDummy11; + edm::Wrapper > wdstvDummy2; + edm::Wrapper > wdstvDummy3; + + edm::Wrapper clusterRemovalInfo; + + edm::OwnVector > fastsimTrackerRecHitCollection; + edm::Wrapper > > fastsimTrackerRecHitCollection_Wrapper; + + std::vector >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > fastsimTrackerRecHitRefCollection; + + edm::Wrapper >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > > fastsimTrackerRecHitRefCollection_Wrapper; + + std::vector > > fastsimTrackerRecHitCombinations; + edm::Wrapper > > >fastsimTrackerRecHitCombinations_Wrapper; + + std::vector >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > > fastSimTrackerRecHitCombinationCollection; + edm::Wrapper >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > > > fastSimTrackerRecHitCombinationCollection_Wrapper; + + edm::Ref >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > >,vector >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > >,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > >,vector >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > > > fastSimTrackerRecHitCombinationRef; + + VectorHitCollectionNew vhc1_new; + edm::RefProd vhc1_new2; + edm::Wrapper wh1_new; + + }; +} + +#endif // SISTRIPRECHIT_CLASSES_H diff --git a/DataFormats/TrackerRecHit2D/src/classes_def.xml b/DataFormats/TrackerRecHit2D/src/classes_def.xml index e2a6415e917ad..e5527c17265f3 100644 --- a/DataFormats/TrackerRecHit2D/src/classes_def.xml +++ b/DataFormats/TrackerRecHit2D/src/classes_def.xml @@ -189,5 +189,20 @@ + + + + + + + + + + + + + + + diff --git a/Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc b/Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc index 8b75397ba05b3..67b76c66427ee 100644 --- a/Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc +++ b/Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc @@ -257,9 +257,9 @@ void TrackerGeomBuilderFromGeometricDet::buildGeomDet(TrackerGeometry* tracker) } else if (gduTypeName.find("Lower") != std::string::npos) { //FIXME::ERICA: the plane builder is built in the middle... - PlaneBuilderForGluedDet::ResultType plane = gluedplaneBuilder.plane(composed); + Plane* plane = new Plane(dus->surface()); composedDetId = theTopo->stack(gduId[i]); - StackGeomDet* stackDet = new StackGeomDet(&(*plane), dum, dus, composedDetId); + StackGeomDet* stackDet = new StackGeomDet(&(*plane), dus, dum, composedDetId); tracker->addDet((GeomDet*)stackDet); tracker->addDetId(composedDetId); } diff --git a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py index 4d25967bd803f..06ebb798faca2 100644 --- a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py +++ b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py @@ -23,6 +23,7 @@ from RecoLocalTracker.SiPhase2Clusterizer.phase2TrackerClusterizer_cfi import * from RecoLocalTracker.Phase2TrackerRecHits.Phase2StripCPEGeometricESProducer_cfi import * +from RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2RecHitMatcher_cfi import * _pixeltrackerlocalrecoTask_phase2 = pixeltrackerlocalrecoTask.copy() _pixeltrackerlocalrecoTask_phase2.add(siPhase2Clusters) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml b/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml new file mode 100644 index 0000000000000..dde4e31241cc2 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h new file mode 100644 index 0000000000000..6a7b3d39b77c9 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -0,0 +1,80 @@ +//--------------------------------------------------------------------------- +// class VectorHitBuilderAlgorithm +// author: ebrondol,nathera +// date: May, 2015 +//--------------------------------------------------------------------------- + +#ifndef RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitBuilderAlgorithm_H +#define RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitBuilderAlgorithm_H + +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "CommonTools/Statistics/interface/LinearFit.h" + +#include "DataFormats/Common/interface/DetSetVector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + + +class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { + public: + + VectorHitBuilderAlgorithm(const edm::ParameterSet& conf) : + VectorHitBuilderAlgorithmBase(conf), theFitter(new LinearFit()) {}; + ~VectorHitBuilderAlgorithm() { delete theFitter; }; + + void run(edm::Handle< edmNew::DetSetVector > clusters, + VectorHitCollectionNew& vhAcc, VectorHitCollectionNew& vhRej, + edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej ); + + //not implemented yet + bool checkClustersCompatibilityBeforeBuilding(edm::Handle< edmNew::DetSetVector > clusters, + const detset & theLowerDetSet, + const detset & theUpperDetSet); + bool checkClustersCompatibility(Local3DPoint& posinner, Local3DPoint& posouter, LocalError& errinner, LocalError& errouter); + + class LocalPositionSort { + public: + LocalPositionSort(const TrackerGeometry *geometry, const ClusterParameterEstimator* cpe, const GeomDet * geomDet) : geom_(geometry), cpe_(cpe), geomDet_(geomDet) {} + bool operator()(Phase2TrackerCluster1DRef clus1, Phase2TrackerCluster1DRef clus2) const ; + private: + const TrackerGeometry *geom_; + const ClusterParameterEstimator* cpe_; + const GeomDet * geomDet_; + }; + + std::vector> buildVectorHits(const StackGeomDet * stack, + edm::Handle< edmNew::DetSetVector > clusters, + const detset & DSVinner, const detset & DSVouter, + const std::vector& phase2OTClustersToSkip = std::vector()); + + VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, Phase2TrackerCluster1DRef upper); + + // Full I/O in DetSet + //void buildDetUnit( const edm::DetSetVector & input, + // output_t& output); + + void fit2Dzx(const Local3DPoint lpCI, const Local3DPoint lpCO, + const LocalError leCI, const LocalError leCO, + Local3DPoint& pos, Local3DVector& dir, + AlgebraicSymMatrix22& covMatrix, double& chi2); + void fit2Dzy(const Local3DPoint lpCI, const Local3DPoint lpCO, + const LocalError leCI, const LocalError leCO, + Local3DPoint& pos, Local3DVector& dir, + AlgebraicSymMatrix22& covMatrix, double& chi2); + + void fit(const std::vector& x, + const std::vector& y, + const std::vector& sigy, + Local3DPoint& pos, Local3DVector& dir, + AlgebraicSymMatrix22& covMatrix, double& chi2); + +// void build( const edm::DetSet & input, +// output_t::FastFiller& output); + + + private: + LinearFit* theFitter; + +}; + +#endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h new file mode 100644 index 0000000000000..ad873f4508142 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -0,0 +1,75 @@ +#ifndef RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitBuilderAlgorithmBase_H +#define RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitBuilderAlgorithmBase_H + +#include "FWCore/Framework/interface/ESHandle.h" +#include "DataFormats/Common/interface/Handle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/TrackerGeometryBuilder/interface/StackGeomDet.h" +#include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" + +namespace edm { + class ParameterSet; + template class RefGetter; + class EventSetup; +} + +class VectorHitBuilderAlgorithmBase { + + public: + typedef edm::Ref, Phase2TrackerCluster1D> Phase2TrackerCluster1DRef; + typedef edmNew::DetSet detset; + typedef detset::const_iterator const_iterator; + typedef edmNew::DetSetVector output_t; + typedef std::pair< StackGeomDet, std::vector > StackClusters; + + VectorHitBuilderAlgorithmBase(const edm::ParameterSet&); + virtual ~VectorHitBuilderAlgorithmBase() {} + void initialize(const edm::EventSetup&); + void initTkGeom(edm::ESHandle< TrackerGeometry > tkGeomHandle); + void initTkTopo(edm::ESHandle< TrackerTopology > tkTopoHandle); + void initCpe(const ClusterParameterEstimator* cpeProd); + + //FIXME::ERICA::this should be template, return different collection for different algo used!! + virtual void run(edm::Handle< edmNew::DetSetVector > clusters, VectorHitCollectionNew& vhAcc, VectorHitCollectionNew& vhRej, + edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej) = 0; + + virtual std::vector> buildVectorHits (const StackGeomDet * stack, + edm::Handle< edmNew::DetSetVector > clusters, + const detset & DSVinner, const detset & DSVouter, + const std::vector& phase2OTClustersToSkip = std::vector()) = 0; + + virtual VectorHit buildVectorHit(const StackGeomDet * stack, + Phase2TrackerCluster1DRef lower, + Phase2TrackerCluster1DRef upper) = 0; + + double computeParallaxCorrection(const PixelGeomDetUnit*&, const Point3DBase&, const PixelGeomDetUnit*&, const Point3DBase&); + + void printClusters(const edmNew::DetSetVector& clusters); + void printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* cluster); + + void loadDetSetVector( std::map< DetId,std::vector >& theMap, edmNew::DetSetVector& theCollection ) const ; + + const TrackerGeometry* theTkGeom; + const TrackerTopology* theTkTopo; + const ClusterParameterEstimator* cpe; + unsigned int nMaxVHforeachStack; + std::vector< double > barrelCut; + std::vector< double > endcapCut; + +private: + edm::ESInputTag cpeTag_; + + + +// typedef SiStripRecHit2DCollection::FastFiller Collector; + +}; + +#endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h new file mode 100644 index 0000000000000..8adf92f4bc286 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h @@ -0,0 +1,41 @@ +//--------------------------------------------------------------------------- +// class VectorHitBuilderEDProducer +// author: ebrondol,nathera +// date: May, 2015 +//--------------------------------------------------------------------------- + +#ifndef RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitBuilderEDProducer_h +#define RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitBuilderEDProducer_h + +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h" +#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" + +class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> +{ + + public: + + explicit VectorHitBuilderEDProducer(const edm::ParameterSet&); + virtual ~VectorHitBuilderEDProducer(); + virtual void produce(edm::Event&, const edm::EventSetup&) override; + void setupAlgorithm(edm::ParameterSet const& conf); + void run(edm::Handle< edmNew::DetSetVector > clusters, + edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, + VectorHitCollectionNew& outputAcc, VectorHitCollectionNew& outputRej); + VectorHitBuilderAlgorithmBase * algo() const { return stubsBuilder; }; + + private: + + VectorHitBuilderAlgorithmBase * stubsBuilder; + std::string offlinestubsTag; + unsigned int maxOfflinestubs; + std::string algoTag; + edm::EDGetTokenT< edmNew::DetSetVector > clusterProducer; + bool readytobuild; + +}; + +#endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/BuildFile.xml b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/BuildFile.xml new file mode 100644 index 0000000000000..1e43153bea1ba --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/BuildFile.xml @@ -0,0 +1,4 @@ + + + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc new file mode 100644 index 0000000000000..63d60a3d5d6c7 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc @@ -0,0 +1,11 @@ + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Utilities/interface/typelookup.h" +#include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h" + +DEFINE_FWK_EVENTSETUP_MODULE(SiPhase2RecHitMatcherESProducer); +DEFINE_FWK_MODULE(VectorHitBuilderEDProducer); + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc new file mode 100644 index 0000000000000..09093bc89ad65 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -0,0 +1,34 @@ +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h" + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" + +SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet & p) +{ + name = p.getParameter("ComponentName"); + pset_ = p; + setWhatProduced(this,name); +} + +std::shared_ptr SiPhase2RecHitMatcherESProducer:: +produce(const TkPhase2OTCPERecord & iRecord) +{ + if( name == "SiPhase2VectorHitMatcher" ){ + matcher_ = std::make_shared(pset_); + + edm::ESHandle tGeomHandle; + edm::ESHandle tTopoHandle; + + iRecord.getRecord().get(tGeomHandle); + iRecord.getRecord().get(tTopoHandle); + + matcher_->algo()->initTkGeom(tGeomHandle); + matcher_->algo()->initTkTopo(tTopoHandle); + } + return matcher_; +} + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h new file mode 100644 index 0000000000000..80aaf0b36bb1f --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h @@ -0,0 +1,23 @@ +#ifndef RecoLocaltracker_SiPhase2VectorHitBuilder_SiPhase2RecHitMatcherESProducer_h +#define RecoLocaltracker_SiPhase2VectorHitBuilder_SiPhase2RecHitMatcherESProducer_h + +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" +#include + +class SiPhase2RecHitMatcherESProducer: public edm::ESProducer { + public: + SiPhase2RecHitMatcherESProducer(const edm::ParameterSet&); + std::shared_ptr produce(const TkPhase2OTCPERecord&); + private: + std::string name; + std::shared_ptr matcher_; + edm::ParameterSet pset_; +}; +#endif + + + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py new file mode 100644 index 0000000000000..0780d27ef4258 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py @@ -0,0 +1,17 @@ +import FWCore.ParameterSet.Config as cms + +SiPhase2RecHitMatcherESProducer = cms.ESProducer("SiPhase2RecHitMatcherESProducer", + ComponentName = cms.string('SiPhase2VectorHitMatcher'), + Clusters = cms.string('siPhase2Clusters'), + offlinestubs = cms.string('vectorHits'), + maxVectorHits = cms.int32(999999999), + maxVectorHitsInAStack = cms.int32(999), + Algorithm = cms.string('VectorHitBuilderAlgorithm'), + BarrelCut = cms.vdouble( 0., 0.05, 0.06, 0.08, 0.09, 0.12, 0.2), #layers are 6 + EndcapCut = cms.vdouble( 0., 0.1, 0.1, 0.1, 0.1, 0.1), #disks are 5 + CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE"), + Phase2CPE_name = cms.string('Phase2StripCPE') +# NSigmaInside = cms.double(3.0) +) + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py new file mode 100644 index 0000000000000..7949489ba3da8 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py @@ -0,0 +1,12 @@ +import FWCore.ParameterSet.Config as cms + +siPhase2VectorHits = cms.EDProducer("VectorHitBuilderEDProducer", + Clusters = cms.string('siPhase2Clusters'), + offlinestubs = cms.string('vectorHits'), + maxVectorHits = cms.int32(999999999), + maxVectorHitsInAStack = cms.int32(999), + Algorithm = cms.string('VectorHitBuilderAlgorithm'), + BarrelCut = cms.vdouble( 0., 0.05, 0.06, 0.08, 0.09, 0.12, 0.2), #layers are 6 + EndcapCut = cms.vdouble( 0., 0.1, 0.1, 0.1, 0.1, 0.1), #disks are 5 + CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE") +) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc new file mode 100644 index 0000000000000..6e7c2fabef3c9 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -0,0 +1,397 @@ +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonTopologies/interface/PixelTopology.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit2D.h" + + +bool VectorHitBuilderAlgorithm::LocalPositionSort::operator()(Phase2TrackerCluster1DRef clus1, Phase2TrackerCluster1DRef clus2) const +{ + const PixelGeomDetUnit* gdu1 = dynamic_cast< const PixelGeomDetUnit* >(geomDet_); + auto && lparams1 = cpe_->localParameters( *clus1, *gdu1 ); // x, y, z, e2_xx, e2_xy, e2_yy + auto && lparams2 = cpe_->localParameters( *clus2, *gdu1 ); // x, y, z, e2_xx, e2_xy, e2_yy + return lparams1.first.x() < lparams2.first.x(); +} + + +void VectorHitBuilderAlgorithm::run(edm::Handle< edmNew::DetSetVector > clusters, + VectorHitCollectionNew& vhAcc, + VectorHitCollectionNew& vhRej, + edmNew::DetSetVector& clustersAcc, + edmNew::DetSetVector& clustersRej) +{ + + LogDebug("VectorHitBuilderAlgorithm") << "Run VectorHitBuilderAlgorithm ... \n" ; + const edmNew::DetSetVector* ClustersPhase2Collection = clusters.product(); + + + std::map< DetId, std::vector > tempVHAcc, tempVHRej; + std::map< DetId, std::vector >::iterator it_temporary; + + //loop over the DetSetVector + LogDebug("VectorHitBuilderAlgorithm") << "with #clusters : " << ClustersPhase2Collection->size() << std::endl ; + for( auto DSViter : *ClustersPhase2Collection){ + + unsigned int rawDetId1(DSViter.detId()); + DetId detId1(rawDetId1); + DetId lowerDetId, upperDetId; + if( theTkTopo->isLower(detId1) ){ + lowerDetId = detId1; + upperDetId = theTkTopo->partnerDetId(detId1); + } else if (theTkTopo->isUpper(detId1)) { + upperDetId = detId1; + lowerDetId = theTkTopo->partnerDetId(detId1); + } + DetId detIdStack = theTkTopo->stack(detId1); + + //debug + LogDebug("VectorHitBuilderAlgorithm") << " DetId stack : " << detIdStack.rawId() << std::endl; + LogDebug("VectorHitBuilderAlgorithm") << " DetId lower set of clusters : " << lowerDetId.rawId(); + LogDebug("VectorHitBuilderAlgorithm") << " DetId upper set of clusters : " << upperDetId.rawId() << std::endl; + + it_temporary = tempVHAcc.find(detIdStack); + if ( it_temporary != tempVHAcc.end() ) { + LogTrace("VectorHitBuilderAlgorithm") << " this stack has already been analyzed -> skip it "; + continue; + } + + const GeomDet* gd; + const StackGeomDet* stackDet; + edmNew::DetSetVector::const_iterator it_detLower = ClustersPhase2Collection->find( lowerDetId ); + edmNew::DetSetVector::const_iterator it_detUpper = ClustersPhase2Collection->find( upperDetId ); + + if ( it_detLower != ClustersPhase2Collection->end() && it_detUpper != ClustersPhase2Collection->end() ){ + + gd = theTkGeom->idToDet(detIdStack); + stackDet = dynamic_cast(gd); + std::vector vhsInStack_Acc; + std::vector vhsInStack_Rej; + const auto vhsInStack_AccRej = buildVectorHits(stackDet, clusters, *it_detLower, *it_detUpper); + + //storing accepted and rejected VHs + for(auto vh : vhsInStack_AccRej ) { + if(vh.second == true){ + vhsInStack_Acc.push_back(vh.first); + } + else if(vh.second == false){ + vhsInStack_Rej.push_back(vh.first); + } + } + + //ERICA:: to be checked with map! + //sorting vhs for best chi2 + std::sort(vhsInStack_Acc.begin(), vhsInStack_Acc.end()); + + tempVHAcc[detIdStack] = vhsInStack_Acc; + tempVHRej[detIdStack] = vhsInStack_Rej; + + LogTrace("VectorHitBuilderAlgorithm") << "For detId #" << detIdStack.rawId() << " the following VHits have been accepted:"; + for (auto vhIt : vhsInStack_Acc){ + LogTrace("VectorHitBuilderAlgorithm") << "accepted VH: " << vhIt; + } + LogTrace("VectorHitBuilderAlgorithm") << "For detId #" << detIdStack.rawId() << " the following VHits have been rejected:"; + for (auto vhIt : vhsInStack_Rej){ + LogTrace("VectorHitBuilderAlgorithm") << "rejected VH: " << vhIt; + } + + } + + } + + loadDetSetVector(tempVHAcc, vhAcc); + loadDetSetVector(tempVHRej, vhRej); + + LogDebug("VectorHitBuilderAlgorithm") << "End run VectorHitBuilderAlgorithm ... \n" ; + return; + +} + +bool VectorHitBuilderAlgorithm::checkClustersCompatibilityBeforeBuilding(edm::Handle< edmNew::DetSetVector > clusters, + const detset & theLowerDetSet, + const detset & theUpperDetSet) +{ + if(theLowerDetSet.size()==1 && theUpperDetSet.size()==1) return true; + + //order lower clusters in u + std::vector lowerClusters; + if(theLowerDetSet.size()>1) LogDebug("VectorHitBuilderAlgorithm") << " more than 1 lower cluster! " << std::endl; + if(theUpperDetSet.size()>1) LogDebug("VectorHitBuilderAlgorithm") << " more than 1 upper cluster! " << std::endl; + for ( const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++ cil ) { + Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo( clusters, cil ); + lowerClusters.push_back(*clusterLower); + } + return true; +} + +bool VectorHitBuilderAlgorithm::checkClustersCompatibility(Local3DPoint& poslower, + Local3DPoint& posupper, + LocalError& errlower, + LocalError& errupper) +{ + + return true; + +} + +//---------------------------------------------------------------------------- +//ERICA::in the DT code the global position is used to compute the alpha angle and put a cut on that. +std::vector> VectorHitBuilderAlgorithm::buildVectorHits(const StackGeomDet * stack, + edm::Handle< edmNew::DetSetVector > clusters, + const detset & theLowerDetSet, + const detset & theUpperDetSet, + const std::vector& phase2OTClustersToSkip) +{ + + std::vector> result; + if(checkClustersCompatibilityBeforeBuilding(clusters, theLowerDetSet, theUpperDetSet)){ + LogDebug("VectorHitBuilderAlgorithm") << " compatible -> continue ... " << std::endl; + } else { LogTrace("VectorHitBuilderAlgorithm") << " not compatible, going to the next cluster"; } + + std::vector lowerClusters; + for ( const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++ cil ) { + Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo( clusters, cil ); + lowerClusters.push_back(clusterLower); + } + std::vector upperClusters; + for ( const_iterator ciu = theUpperDetSet.begin(); ciu != theUpperDetSet.end(); ++ ciu ) { + Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo( clusters, ciu ); + upperClusters.push_back(clusterUpper); + } + + std::sort(lowerClusters.begin(), lowerClusters.end(), LocalPositionSort(&*theTkGeom,&*cpe,&*stack->lowerDet())); + std::sort(upperClusters.begin(), upperClusters.end(), LocalPositionSort(&*theTkGeom,&*cpe,&*stack->upperDet())); + + for ( auto cluL : lowerClusters){ + LogDebug("VectorHitBuilderAlgorithm") << " lower clusters " << std::endl; + printCluster(stack->lowerDet(),&*cluL); + const PixelGeomDetUnit* gduLow = dynamic_cast< const PixelGeomDetUnit* >(stack->lowerDet()); + auto && lparamsLow = cpe->localParameters( *cluL, *gduLow ); + for ( auto cluU : upperClusters){ + LogDebug("VectorHitBuilderAlgorithm") << "\t upper clusters " << std::endl; + printCluster(stack->upperDet(),&*cluU); + const PixelGeomDetUnit* gduUpp = dynamic_cast< const PixelGeomDetUnit* >(stack->upperDet()); + auto && lparamsUpp = cpe->localParameters( *cluU, *gduUpp ); + + //applying the parallax correction + double pC = computeParallaxCorrection(gduLow,lparamsLow.first,gduUpp,lparamsUpp.first); + LogDebug("VectorHitBuilderAlgorithm") << " \t parallax correction:" << pC << std::endl; + double lpos_upp_corr = 0.0; + double lpos_low_corr = 0.0; + if(lparamsUpp.first.x() > lparamsLow.first.x()){ + if(lparamsUpp.first.x() > 0){ + lpos_low_corr = lparamsLow.first.x(); + lpos_upp_corr = lparamsUpp.first.x() - fabs(pC); + } + if(lparamsUpp.first.x() < 0){ + lpos_low_corr = lparamsLow.first.x() + fabs(pC); + lpos_upp_corr = lparamsUpp.first.x(); + } + } else if( lparamsUpp.first.x() < lparamsLow.first.x() ) { + if(lparamsUpp.first.x() > 0){ + lpos_low_corr = lparamsLow.first.x() - fabs(pC); + lpos_upp_corr = lparamsUpp.first.x(); + } + if(lparamsUpp.first.x() < 0){ + lpos_low_corr = lparamsLow.first.x(); + lpos_upp_corr = lparamsUpp.first.x() + fabs(pC); + } + } else { + if(lparamsUpp.first.x() > 0){ + lpos_low_corr = lparamsLow.first.x(); + lpos_upp_corr = lparamsUpp.first.x() - fabs(pC); + } + if(lparamsUpp.first.x() < 0){ + lpos_low_corr = lparamsLow.first.x(); + lpos_upp_corr = lparamsUpp.first.x() + fabs(pC); + } + } + + LogDebug("VectorHitBuilderAlgorithm") << " \t local pos upper corrected (x):" << lpos_upp_corr << std::endl; + LogDebug("VectorHitBuilderAlgorithm") << " \t local pos lower corrected (x):" << lpos_low_corr << std::endl; + + //building my tolerance : 10*sigma + double delta = 10.0*sqrt(lparamsLow.second.xx()+lparamsUpp.second.xx()); + LogDebug("VectorHitBuilderAlgorithm") << " \t delta: " << delta << std::endl; + + double width = lpos_low_corr - lpos_upp_corr; + LogDebug("VectorHitBuilderAlgorithm") << " \t width: " << width << std::endl; + + + unsigned int layerStack = theTkTopo->layer(stack->geographicalId()); + if(stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB ) LogDebug("VectorHitBuilderAlgorithm") << " \t is barrel. " << std::endl; + if(stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) LogDebug("VectorHitBuilderAlgorithm") << " \t is endcap. " << std::endl; + LogDebug("VectorHitBuilderAlgorithm") << " \t layer is : " << layerStack << std::endl; + + float cut = 0.0; + if(stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB ) cut = barrelCut.at(layerStack); + if(stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) cut = endcapCut.at(layerStack); + LogDebug("VectorHitBuilderAlgorithm") << " \t the cut is:" << cut << std::endl; + + //old cut: indipendent from layer + //if( (lpos_upp_corr < lpos_low_corr + delta) && + // (lpos_upp_corr > lpos_low_corr - delta) ){ + //new cut: dependent on layers + if(fabs(width) < cut){ + LogDebug("VectorHitBuilderAlgorithm") << " accepting VH! " << std::endl; + VectorHit vh = buildVectorHit( stack, cluL, cluU); + //protection: the VH can also be empty!! + if (vh.isValid()){ + result.push_back(std::make_pair(vh, true)); + } + + } else { + LogDebug("VectorHitBuilderAlgorithm") << " rejecting VH: " << std::endl; + //storing vh rejected for combinatiorial studies + VectorHit vh = buildVectorHit( stack, cluL, cluU); + result.push_back(std::make_pair(vh, false)); + } + + } + } + + return result; + +} + +VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet * stack, + Phase2TrackerCluster1DRef lower, + Phase2TrackerCluster1DRef upper) +{ + + LogTrace("VectorHitBuilderAlgorithm") << "Build VH with: "; + //printCluster(stack->lowerDet(),&*lower); + //printCluster(stack->upperDet(),&*upper); + + const PixelGeomDetUnit* geomDetLower = dynamic_cast< const PixelGeomDetUnit* >(stack->lowerDet()); + const PixelGeomDetUnit* geomDetUpper = dynamic_cast< const PixelGeomDetUnit* >(stack->upperDet()); + + auto && lparamsLower = cpe->localParameters( *lower, *geomDetLower ); // x, y, z, e2_xx, e2_xy, e2_yy + Global3DPoint gparamsLower = geomDetLower->surface().toGlobal(lparamsLower.first); + LogTrace("VectorHitBuilderAlgorithm") << "\t lower global pos: " << gparamsLower ; + + auto && lparamsUpper = cpe->localParameters( *upper, *geomDetUpper ); + Global3DPoint gparamsUpper = geomDetUpper->surface().toGlobal(lparamsUpper.first); + LogTrace("VectorHitBuilderAlgorithm") << "\t upper global pos: " << gparamsUpper ; + + //local parameters of upper cluster in lower system of reference + Local3DPoint lparamsUpperInLower = geomDetLower->surface().toLocal(gparamsUpper); + + LogTrace("VectorHitBuilderAlgorithm") << "\t lower global pos: " << gparamsLower ; + LogTrace("VectorHitBuilderAlgorithm") << "\t upper global pos: " << gparamsUpper ; + + LogTrace("VectorHitBuilderAlgorithm") << "A:\t lower local pos: " << lparamsLower.first << " with error: " << lparamsLower.second << std::endl; + LogTrace("VectorHitBuilderAlgorithm") << "A:\t upper local pos in the lower sof " << lparamsUpperInLower << " with error: " << lparamsUpper.second << std::endl; + + bool ok = checkClustersCompatibility(lparamsLower.first, lparamsUpper.first, lparamsLower.second, lparamsUpper.second); + + if(ok){ + + AlgebraicSymMatrix22 covMat2Dzx; + double chi22Dzx = 0.0; + Local3DPoint pos2Dzx; + Local3DVector dir2Dzx; + fit2Dzx(lparamsLower.first, lparamsUpperInLower, lparamsLower.second, lparamsUpper.second, pos2Dzx, dir2Dzx, covMat2Dzx, chi22Dzx); + LogTrace("VectorHitBuilderAlgorithm") << "\t pos2Dzx: " << pos2Dzx; + LogTrace("VectorHitBuilderAlgorithm") << "\t dir2Dzx: " << dir2Dzx; + LogTrace("VectorHitBuilderAlgorithm") << "\t cov2Dzx: " << covMat2Dzx; + VectorHit2D vh2Dzx = VectorHit2D(pos2Dzx, dir2Dzx, covMat2Dzx, chi22Dzx); + + AlgebraicSymMatrix22 covMat2Dzy; + double chi22Dzy = 0.0; + Local3DPoint pos2Dzy; + Local3DVector dir2Dzy; + fit2Dzy(lparamsLower.first, lparamsUpperInLower, lparamsLower.second, lparamsUpper.second, pos2Dzy, dir2Dzy, covMat2Dzy, chi22Dzy); + LogTrace("VectorHitBuilderAlgorithm") << "\t pos2Dzy: " << pos2Dzy; + LogTrace("VectorHitBuilderAlgorithm") << "\t dir2Dzy: " << dir2Dzy; + LogTrace("VectorHitBuilderAlgorithm") << "\t cov2Dzy: " << covMat2Dzy; + VectorHit2D vh2Dzy = VectorHit2D(pos2Dzy, dir2Dzy, covMat2Dzy, chi22Dzy); + + OmniClusterRef lowerOmni(lower); + OmniClusterRef upperOmni(upper); + VectorHit vh = VectorHit(*stack, vh2Dzx, vh2Dzy, lowerOmni, upperOmni); + return vh; + + } + + return VectorHit(); + +} + + + +void VectorHitBuilderAlgorithm::fit2Dzx(const Local3DPoint lpCI, const Local3DPoint lpCO, + const LocalError leCI, const LocalError leCO, + Local3DPoint& pos, Local3DVector& dir, + AlgebraicSymMatrix22& covMatrix, + double& chi2) +{ + std::vector x = {lpCI.z(), lpCO.z()}; + std::vector y = {lpCI.x(), lpCO.x()}; + float sqCI = sqrt(leCI.xx()); + float sqCO = sqrt(leCO.xx()); + std::vector sigy = {sqCI, sqCO}; + + fit(x,y,sigy,pos,dir,covMatrix,chi2); + + return; + +} + +void VectorHitBuilderAlgorithm::fit2Dzy(const Local3DPoint lpCI, const Local3DPoint lpCO, + const LocalError leCI, const LocalError leCO, + Local3DPoint& pos, Local3DVector& dir, + AlgebraicSymMatrix22& covMatrix, + double& chi2) +{ + std::vector x = {lpCI.z(), lpCO.z()}; + std::vector y = {lpCI.y(), lpCO.y()}; + float sqCI = sqrt(leCI.yy()); + float sqCO = sqrt(leCO.yy()); + std::vector sigy = {sqCI, sqCO}; + + fit(x,y,sigy,pos,dir,covMatrix,chi2); + + return; + +} + +void VectorHitBuilderAlgorithm::fit(const std::vector& x, + const std::vector& y, + const std::vector& sigy, + Local3DPoint& pos, Local3DVector& dir, + AlgebraicSymMatrix22& covMatrix, + double& chi2) +{ + + if(x.size() != y.size() || x.size() != sigy.size()){ + edm::LogError("VectorHitBuilderAlgorithm") << "Different size for x,z !! No fit possible."; + return; + } + + float slope = 0.; + float intercept = 0.; + float covss = 0.; + float covii = 0.; + float covsi = 0.; + + theFitter->fit(x,y,x.size(),sigy,slope,intercept,covss,covii,covsi); + + covMatrix[0][0] = covss; // this is var(dy/dz) + covMatrix[1][1] = covii; // this is var(y) + covMatrix[1][0] = covsi; // this is cov(dy/dz,y) + + for (unsigned int j=0; j < x.size(); j++){ + const double ypred = intercept + slope*x[j]; + const double dy = (y[j] - ypred)/sigy[j]; + chi2 += dy*dy; + } + + pos = Local3DPoint(intercept,0.,0.); + if(x.size()==2){ + //difference in z is the difference of the lowermost and the uppermost cluster z pos + float slopeZ = x.at(1) - x.at(0); + dir = LocalVector(slope,0.,slopeZ); + } else { + dir = LocalVector(slope,0.,-1.); + } + +} diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc new file mode 100644 index 0000000000000..df42069d3adf5 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -0,0 +1,151 @@ +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" +#include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" + +#include "Geometry/CommonTopologies/interface/PixelTopology.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" + +VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase(const edm::ParameterSet& conf) : + nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), + barrelCut(conf.getParameter< std::vector< double > >("BarrelCut")), + endcapCut(conf.getParameter< std::vector< double > >("EndcapCut")), + cpeTag_(conf.getParameter("CPE")) +{} + +void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) +{ + //FIXME:ask Vincenzo + /* + uint32_t tk_cache_id = es.get().cacheIdentifier(); + uint32_t c_cache_id = es.get().cacheIdentifier(); + + if(tk_cache_id != tracker_cache_id) { + es.get().get(tracker); + tracker_cache_id = tk_cache_id; + } + if(c_cache_id != cpe_cache_id) { + es.get().get(matcherTag, matcher); + es.get().get(cpeTag, cpe); + cpe_cache_id = c_cache_id; + } + */ + + // get the geometry and topology + edm::ESHandle< TrackerGeometry > geomHandle; + es.get< TrackerDigiGeometryRecord >().get( geomHandle ); + initTkGeom(geomHandle); + + edm::ESHandle< TrackerTopology > tTopoHandle; + es.get< TrackerTopologyRcd >().get(tTopoHandle); + initTkTopo(tTopoHandle); + + // load the cpe via the eventsetup + edm::ESHandle > cpeHandle; + es.get().get(cpeTag_, cpeHandle); + initCpe(cpeHandle.product()); +} + +void VectorHitBuilderAlgorithmBase::initTkGeom(edm::ESHandle< TrackerGeometry > tkGeomHandle){ + theTkGeom = tkGeomHandle.product(); +} +void VectorHitBuilderAlgorithmBase::initTkTopo(edm::ESHandle< TrackerTopology > tkTopoHandle){ + theTkTopo = tkTopoHandle.product(); +} +void VectorHitBuilderAlgorithmBase::initCpe(const ClusterParameterEstimator* cpeProd){ + cpe = cpeProd; +} + +double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomDetUnit*& geomDetUnit_low, const Point3DBase& lPosClu_low, + const PixelGeomDetUnit*& geomDetUnit_upp, const Point3DBase& lPosClu_upp){ + double parallCorr = 0.0; + Global3DPoint origin(0,0,0); + Global3DPoint gPosClu_low = geomDetUnit_low->surface().toGlobal(lPosClu_low); + GlobalVector gV = gPosClu_low - origin; + LogTrace("VectorHitsBuilderValidation") << " global vector passing to the origin:" << gV; + + LocalVector lV = geomDetUnit_low->surface().toLocal(gV); + LogTrace("VectorHitsBuilderValidation") << " local vector passing to the origin (in low sor):" << lV; + LocalVector lV_norm = lV/lV.z(); + LogTrace("VectorHitsBuilderValidation") << " normalized local vector passing to the origin (in low sor):" << lV_norm; + + Global3DPoint gPosClu_upp = geomDetUnit_upp->surface().toGlobal(lPosClu_upp); + Local3DPoint lPosClu_uppInLow = geomDetUnit_low->surface().toLocal(gPosClu_upp); + parallCorr = lV_norm.x() * lPosClu_uppInLow.z(); + + return parallCorr; +} + +void VectorHitBuilderAlgorithmBase::printClusters(const edmNew::DetSetVector& clusters){ + + int nCluster = 0; + int numberOfDSV = 0; + edmNew::DetSetVector::const_iterator DSViter; + for( DSViter = clusters.begin() ; DSViter != clusters.end(); DSViter++){ + + ++numberOfDSV; + + // Loop over the clusters in the detector unit + for (edmNew::DetSet< Phase2TrackerCluster1D >::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); ++clustIt) { + + nCluster++; + + // get the detector unit's id + const GeomDetUnit* geomDetUnit(theTkGeom->idToDetUnit(DSViter->detId())); + if (!geomDetUnit) return; + + printCluster(geomDetUnit, clustIt); + + } + } + LogDebug("VectorHitBuilder") << " Number of input clusters: " << nCluster << std::endl; + +} + + +void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* clustIt){ + + if (!geomDetUnit) return; + const PixelGeomDetUnit* pixelGeomDetUnit = dynamic_cast< const PixelGeomDetUnit* >(geomDetUnit); + const PixelTopology& topol = pixelGeomDetUnit->specificTopology(); + if (!pixelGeomDetUnit) return; + + unsigned int layer = theTkTopo->layer(geomDetUnit->geographicalId()); + unsigned int module = theTkTopo->module(geomDetUnit->geographicalId()); + LogTrace("VectorHitBuilder") << "Layer:" << layer << " and DetId: " << geomDetUnit->geographicalId().rawId() << std::endl; + TrackerGeometry::ModuleType mType = theTkGeom->getDetectorType(geomDetUnit->geographicalId()); + if (mType == TrackerGeometry::ModuleType::Ph2PSP) + LogTrace("VectorHitBuilder") << "Pixel cluster (module:" << module << ") " << std::endl; + else if (mType == TrackerGeometry::ModuleType::Ph2SS || mType == TrackerGeometry::ModuleType::Ph2PSS) + LogTrace("VectorHitBuilder") << "Strip cluster (module:" << module << ") " << std::endl; + else LogTrace("VectorHitBuilder") << "no module?!" << std::endl; + LogTrace("VectorHitBuilder") << "with pitch:" << topol.pitch().first << " , " << topol.pitch().second << std::endl; + LogTrace("VectorHitBuilder") << " and width:" << pixelGeomDetUnit->surface().bounds().width() << " , lenght:" << pixelGeomDetUnit->surface().bounds().length() << std::endl; + + + auto && lparams = cpe->localParameters( *clustIt, *pixelGeomDetUnit ); + Global3DPoint gparams = pixelGeomDetUnit->surface().toGlobal(lparams.first); + + LogTrace("VectorHitBuilder") << "\t global pos " << gparams << std::endl; + LogTrace("VectorHitBuilder") << "\t local pos " << lparams.first << "with err " << lparams.second << std::endl; + LogTrace("VectorHitBuilder") << std::endl; + + return; +} + +void VectorHitBuilderAlgorithmBase::loadDetSetVector( std::map< DetId,std::vector >& theMap, edmNew::DetSetVector& theCollection ) const{ + + std::map >::const_iterator it = theMap.begin(); + std::map >::const_iterator lastDet = theMap.end(); + for( ; it != lastDet ; ++it ) { + edmNew::DetSetVector::FastFiller vh_col(theCollection, it->first); + std::vector::const_iterator vh_it = it->second.begin(); + std::vector::const_iterator vh_end = it->second.end(); + for( ; vh_it != vh_end ; ++vh_it) { + vh_col.push_back(*vh_it); + } + } + +} diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc new file mode 100644 index 0000000000000..60e6f58bc9ff2 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc @@ -0,0 +1,107 @@ +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) + : offlinestubsTag( conf.getParameter( "offlinestubs" ) ), + maxOfflinestubs(conf.getParameter( "maxVectorHits" )), + algoTag(conf.getParameter( "Algorithm" )), + //clusterProducer(conf.getParameter("Clusters")), + readytobuild(false) +{ + + clusterProducer = consumes< edmNew::DetSetVector >(edm::InputTag(conf.getParameter("Clusters"))); + + produces< edmNew::DetSetVector< Phase2TrackerCluster1D > >( "ClustersAccepted" ); + produces< edmNew::DetSetVector< Phase2TrackerCluster1D > >( "ClustersRejected" ); + produces< VectorHitCollectionNew >( offlinestubsTag + "Accepted" ); + produces< VectorHitCollectionNew >( offlinestubsTag + "Rejected" ); + setupAlgorithm(conf); +} + +VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { + delete stubsBuilder; +} + +void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) +{ + LogDebug("VectorHitBuilderEDProducer") << "VectorHitBuilderEDProducer::produce() begin"; + + // get input clusters data + edm::Handle< edmNew::DetSetVector > clustersHandle; + event.getByToken( clusterProducer, clustersHandle); + + // create the final output collection + std::unique_ptr< edmNew::DetSetVector< Phase2TrackerCluster1D > > outputClustersAccepted( new edmNew::DetSetVector< Phase2TrackerCluster1D > ); + std::unique_ptr< edmNew::DetSetVector< Phase2TrackerCluster1D > > outputClustersRejected( new edmNew::DetSetVector< Phase2TrackerCluster1D > ); + std::unique_ptr< VectorHitCollectionNew > outputVHAccepted( new VectorHitCollectionNew() ); + std::unique_ptr< VectorHitCollectionNew > outputVHRejected( new VectorHitCollectionNew() ); + + if(readytobuild) stubsBuilder->initialize(es); + else edm::LogError("VectorHitBuilderEDProducer") << "Impossible initialization of builder!!"; + + // check on the input clusters + stubsBuilder->printClusters(*clustersHandle); + + // running the stub building algorithm + //ERICA::output should be moved in the different algo classes? + run( clustersHandle, *outputClustersAccepted, *outputClustersRejected, *outputVHAccepted, *outputVHRejected); + + unsigned int numberOfVectorHits = 0; + edmNew::DetSetVector::const_iterator DSViter; + for( DSViter = (*outputVHAccepted).begin() ; DSViter != (*outputVHAccepted).end(); DSViter++){ + + edmNew::DetSet< VectorHit >::const_iterator vh; + for ( vh = DSViter->begin(); vh != DSViter->end(); ++vh) { + numberOfVectorHits++; + LogDebug("VectorHitBuilderEDProducer") << "\t vectorhit in output " << *vh << std::endl; + } + + } +/* + if(numberOfVectorHits > maxOfflinestubs) { + edm::LogError("VectorHitBuilderEDProducer") << "Limit on the number of stubs exceeded. An empty output collection will be produced instead.\n"; + VectorHitCollectionNew empty; + empty.swap(outputAcc); + } +*/ + // write output to file + event.put( std::move(outputClustersAccepted), "ClustersAccepted" ); + event.put( std::move(outputClustersRejected), "ClustersRejected" ); + event.put( std::move(outputVHAccepted), offlinestubsTag + "Accepted" ); + event.put( std::move(outputVHRejected), offlinestubsTag + "Rejected" ); + +// LogDebug("VectorHitBuilderEDProducer") << " Executing " << algoTag << " resulted in " << numberOfVectorHits << "."; + LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n" ; + +} + +void VectorHitBuilderEDProducer::setupAlgorithm(edm::ParameterSet const& conf) { + + if ( algoTag == "VectorHitBuilderAlgorithm" ) { + stubsBuilder = new VectorHitBuilderAlgorithm(conf); + readytobuild = true; + } else { + edm::LogError("VectorHitBuilderEDProducer") << " Choice " << algoTag << " is invalid.\n" ; + readytobuild = false; + } + +} + + +void VectorHitBuilderEDProducer::run(edm::Handle< edmNew::DetSetVector > clusters, + edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, + VectorHitCollectionNew& outputAcc, VectorHitCollectionNew& outputRej ){ + + if ( !readytobuild ) { + edm::LogError("VectorHitBuilderEDProducer") << " No stub builder algorithm was found - cannot run!" ; + return; + } + + stubsBuilder->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej); + +} + +#include "FWCore/Utilities/interface/typelookup.h" +TYPELOOKUP_DATA_REG(VectorHitBuilderEDProducer); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml new file mode 100644 index 0000000000000..bd4c0a3c2dc1f --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc new file mode 100644 index 0000000000000..1730009db050a --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc @@ -0,0 +1,584 @@ +#include +#include +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" + +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" +#include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" +#include "DataFormats/SiPixelDigi/interface/PixelDigi.h" + +#include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h" +#include "SimDataFormats/Track/interface/SimTrackContainer.h" +#include "SimDataFormats/Vertex/interface/SimVertexContainer.h" +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" + +#include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "CommonTools/Utils/interface/TFileDirectory.h" + +#include +#include +#include +#include + + + +struct ClusterHistos { + THStack* numberClustersMixed; + TH1F* numberClusterPixel; + TH1F* numberClusterStrip; + + THStack* clustersSizeMixed; + TH1F* clusterSizePixel; + TH1F* clusterSizeStrip; + + TGraph* globalPosXY[3]; + TGraph* localPosXY[3]; + + TH1F* deltaXClusterSimHits[3]; + TH1F* deltaYClusterSimHits[3]; + + TH1F* deltaXClusterSimHits_P[3]; + TH1F* deltaYClusterSimHits_P[3]; + + TH1F* digiEfficiency[3]; + + TH1F* primarySimHits; + TH1F* otherSimHits; +}; + +class Phase2TrackerClusterizerValidationTGraph : public edm::EDAnalyzer { + + public: + + typedef std::map< unsigned int, std::vector< PSimHit > > SimHitsMap; + typedef std::map< unsigned int, SimTrack > SimTracksMap; + + explicit Phase2TrackerClusterizerValidationTGraph(const edm::ParameterSet&); + ~Phase2TrackerClusterizerValidationTGraph(); + void beginJob(); + void endJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + + private: + + std::map< unsigned int, ClusterHistos >::iterator createLayerHistograms(unsigned int); + unsigned int getLayerNumber(const DetId&, const TrackerTopology*); + unsigned int getModuleNumber(const DetId&, const TrackerTopology*); + unsigned int getSimTrackId(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >&, const DetId&, unsigned int); + + edm::EDGetTokenT< edmNew::DetSetVector > srcClu_; + edm::EDGetTokenT< edm::DetSetVector > siphase2OTSimLinksToken_; + edm::EDGetTokenT< edm::PSimHitContainer > simHitsToken_; + edm::EDGetTokenT< edm::SimTrackContainer> simTracksToken_; + edm::EDGetTokenT< edm::SimVertexContainer > simVerticesToken_; + const TrackerGeometry* tkGeom; + const TrackerTopology* tkTopo; + + TTree* tree; + TGraph* trackerLayout_[3]; + TGraph* trackerLayoutXY_[3]; + TGraph* trackerLayoutXYBar_; + TGraph* trackerLayoutXYEC_; + + std::map< unsigned int, ClusterHistos > histograms_; + +}; + +Phase2TrackerClusterizerValidationTGraph::Phase2TrackerClusterizerValidationTGraph(const edm::ParameterSet& conf) { + srcClu_ = consumes< edmNew::DetSetVector >(edm::InputTag(conf.getParameter("src"))); + siphase2OTSimLinksToken_ = consumes >(conf.getParameter("links")); + simHitsToken_ = consumes< edm::PSimHitContainer >(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof")); + simTracksToken_ = consumes< edm::SimTrackContainer >(edm::InputTag("g4SimHits")); + simVerticesToken_ = consumes< edm::SimVertexContainer >(edm::InputTag("g4SimHits")); +} + + Phase2TrackerClusterizerValidationTGraph::~Phase2TrackerClusterizerValidationTGraph() { } + + void Phase2TrackerClusterizerValidationTGraph::beginJob() { + edm::Service fs; + fs->file().cd("/"); + TFileDirectory td = fs->mkdir("Common"); + //Create common ntuple + tree = td.make< TTree >("Phase2TrackerClusters","Phase2TrackerClusters"); + // Create common histograms + trackerLayout_[0] = td.make< TGraph >();//"RVsZ_Mixed", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); + trackerLayout_[0] -> SetName("RVsZ_Mixed"); + trackerLayout_[1] = td.make< TGraph >();//"RVsZ_Pixel", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); + trackerLayout_[1] -> SetName("RVsZ_Pixel"); + trackerLayout_[2] = td.make< TGraph >();//"RVsZ_Strip", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); + trackerLayout_[2] -> SetName("RVsZ_Strip"); + trackerLayoutXY_[0] = td.make< TGraph >();//"XVsY_Mixed", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXY_[0] -> SetName("YVsX_Mixed"); + trackerLayoutXY_[1] = td.make< TGraph >();//"XVsY_Pixel", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXY_[1] -> SetName("YVsX_Pixel"); + trackerLayoutXY_[2] = td.make< TGraph >();//"XVsY_Strip", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXY_[2] -> SetName("YVsX_Strip"); + trackerLayoutXYBar_ = td.make< TGraph >();//"XVsYBar", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXYBar_ -> SetName("YVsXBar"); + trackerLayoutXYEC_ = td.make< TGraph >();//"XVsYEC", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXYEC_ -> SetName("YVsXEC"); + } + +void Phase2TrackerClusterizerValidationTGraph::endJob() {} + +void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) { + + // Get the needed objects + + // Get the clusters + edm::Handle< Phase2TrackerCluster1DCollectionNew > clusters; + event.getByToken(srcClu_, clusters); + + // Get the Phase2 DigiSimLink + edm::Handle > siphase2SimLinks; + event.getByToken(siphase2OTSimLinksToken_, siphase2SimLinks); + + // Get the SimHits + edm::Handle< edm::PSimHitContainer > simHitsRaw; + event.getByToken(simHitsToken_, simHitsRaw); +// edm::Handle< edm::PSimHitContainer > simHitsRawEndcap; +// event.getByLabel("g4SimHits", "TrackerHitsPixelEndcapLowTof", simHitsRawEndcap); + + // Get the SimTracks + edm::Handle< edm::SimTrackContainer > simTracksRaw; + event.getByToken(simTracksToken_, simTracksRaw); + + // Get the SimVertex + edm::Handle< edm::SimVertexContainer > simVertices; + event.getByToken(simVerticesToken_, simVertices); + + // Get the geometry + edm::ESHandle< TrackerGeometry > geomHandle; + eventSetup.get< TrackerDigiGeometryRecord >().get(geomHandle); + tkGeom = &(*geomHandle); + edm::ESHandle< TrackerTopology > tTopoHandle; + eventSetup.get< TrackerTopologyRcd >().get(tTopoHandle); + tkTopo = tTopoHandle.product(); + + //set up for tree + int layer_number; + //int track_id; + int module_id; + int module_number; + int module_type; //1: pixel, 2: strip + float x_global, y_global, z_global; + float x_local, y_local, z_local; + + tree -> Branch("layer_number",&layer_number,"layer_number/I"); + //tree -> Branch("track_id",&track_id,"track_id/I"); + tree -> Branch("module_id",&module_id,"module_id/I"); + tree -> Branch("module_type",&module_type,"module_type/I"); + tree -> Branch("module_number",&module_number,"module_number/I"); + tree -> Branch("x_global",&x_global,"x_global/F"); + tree -> Branch("y_global",&y_global,"y_global/F"); + tree -> Branch("z_global",&z_global,"z_global/F"); + tree -> Branch("x_local",&x_local,"x_local/F"); + tree -> Branch("y_local",&y_local,"y_local/F"); + tree -> Branch("z_local",&z_local,"z_local/F"); + + // Rearrange the simTracks for ease of use + SimTracksMap simTracks; + for (edm::SimTrackContainer::const_iterator simTrackIt(simTracksRaw->begin()); simTrackIt != simTracksRaw->end(); ++simTrackIt) simTracks.insert(std::pair< unsigned int, SimTrack >(simTrackIt->trackId(), *simTrackIt)); + + // Rearrange the simHits by detUnit + + + // Rearrange the simHits for ease of use + SimHitsMap simHitsDetUnit; + SimHitsMap simHitsTrackId; + for (edm::PSimHitContainer::const_iterator simHitIt(simHitsRaw->begin()); simHitIt != simHitsRaw->end(); ++simHitIt) { + SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt->detUnitId())); + if (simHitsDetUnitIt == simHitsDetUnit.end()) { + std::pair< SimHitsMap::iterator, bool > newIt(simHitsDetUnit.insert(std::pair< unsigned int, std::vector< PSimHit > >(simHitIt->detUnitId(), std::vector< PSimHit >()))); + simHitsDetUnitIt = newIt.first; + } + simHitsDetUnitIt->second.push_back(*simHitIt); + SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt->trackId())); + if (simHitsTrackIdIt == simHitsTrackId.end()) { + std::pair< SimHitsMap::iterator, bool > newIt(simHitsTrackId.insert(std::pair< unsigned int, std::vector< PSimHit > >(simHitIt->trackId(), std::vector< PSimHit >()))); + simHitsTrackIdIt = newIt.first; + } + simHitsTrackIdIt->second.push_back(*simHitIt); + } + + + + // ValidationTGraph + unsigned int nClustersTot(0), nClustersPixelTot(0), nClustersStripTot(0); + + // Loop over modules + for (Phase2TrackerCluster1DCollectionNew::const_iterator DSViter = clusters->begin(); DSViter != clusters->end(); ++DSViter) { + + // Get the detector unit's id + unsigned int rawid(DSViter->detId()); + module_id = rawid; + DetId detId(rawid); + + layer_number = getLayerNumber(detId, tkTopo); + module_number = getModuleNumber(detId, tkTopo); + unsigned int layer(getLayerNumber(detId, tkTopo)); + + + // Get the geometry of the tracker + const GeomDetUnit* geomDetUnit(tkGeom->idToDetUnit(detId)); + const PixelGeomDetUnit* theGeomDet = dynamic_cast< const PixelGeomDetUnit* >(geomDetUnit); + const PixelTopology& topol = theGeomDet->specificTopology(); + + if (!geomDetUnit) break; + + // Create histograms for the layer if they do not yet exist + std::map< unsigned int, ClusterHistos >::iterator histogramLayer(histograms_.find(layer)); + if (histogramLayer == histograms_.end()) histogramLayer = createLayerHistograms(layer); + + // Number of clusters + unsigned int nClustersPixel(0), nClustersStrip(0); + + // Loop over the clusters in the detector unit + for (edmNew::DetSet< Phase2TrackerCluster1D >::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); ++clustIt) { + + + // Cluster related variables + MeasurementPoint mpClu(clustIt->center(), clustIt->column() + 0.5); + Local3DPoint localPosClu = geomDetUnit->topology().localPosition(mpClu); + x_local = localPosClu.x(); + y_local = localPosClu.y(); + z_local = localPosClu.z(); + std::cout << localPosClu << std::endl; + + Global3DPoint globalPosClu = geomDetUnit->surface().toGlobal(localPosClu); + x_global = globalPosClu.x(); + y_global = globalPosClu.y(); + z_global = globalPosClu.z(); + //std::cout << globalPosClu << std::endl; + + // Fill the position histograms + trackerLayout_[0]->SetPoint(nClustersTot, globalPosClu.z(), globalPosClu.perp()); + trackerLayoutXY_[0]->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); + + if (layer < 100) trackerLayoutXYBar_->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); + else trackerLayoutXYEC_->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); + + histogramLayer->second.localPosXY[0]->SetPoint(nClustersTot, localPosClu.x(), localPosClu.y()); + histogramLayer->second.globalPosXY[0]->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); + + // Pixel module + if (topol.ncolumns() == 32) { + module_type = 1; + trackerLayout_[1]->SetPoint(nClustersPixelTot, globalPosClu.z(), globalPosClu.perp()); + trackerLayoutXY_[1]->SetPoint(nClustersPixelTot, globalPosClu.x(), globalPosClu.y()); + + histogramLayer->second.localPosXY[1]->SetPoint(nClustersPixelTot, localPosClu.x(), localPosClu.y()); + histogramLayer->second.globalPosXY[1]->SetPoint(nClustersPixelTot, globalPosClu.x(), globalPosClu.y()); + histogramLayer->second.clusterSizePixel->Fill(clustIt->size()); + ++nClustersPixel; + ++nClustersPixelTot; + } + // Strip module + else if (topol.ncolumns() == 2) { + module_type = 2; + trackerLayout_[2]->SetPoint(nClustersStripTot, globalPosClu.z(), globalPosClu.perp()); + trackerLayoutXY_[2]->SetPoint(nClustersStripTot, globalPosClu.x(), globalPosClu.y()); + + histogramLayer->second.localPosXY[2]->SetPoint(nClustersStripTot, localPosClu.x(), localPosClu.y()); + histogramLayer->second.globalPosXY[2]->SetPoint(nClustersStripTot, globalPosClu.x(), globalPosClu.y()); + histogramLayer->second.clusterSizeStrip->Fill(clustIt->size()); + ++nClustersStrip; + ++nClustersStripTot; + } + + + + // * Digis related variables + + + std::vector< unsigned int > clusterSimTrackIds; + + // Get all the simTracks that form the cluster + for (unsigned int i(0); i < clustIt->size(); ++i) { + unsigned int channel(PixelDigi::pixelToChannel(clustIt->firstRow() + i, clustIt->column())); // Here we have to use the old pixelToChannel function (not Phase2TrackerDigi but PixelDigi), change this when using new Digis + unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detId, channel)); + clusterSimTrackIds.push_back(simTrackId); + std::cout << channel << std::endl; + std::cout << simTrackId << std::endl; + std::cout << std::endl; + } + unsigned int InnerChannel = clustIt->firstDigi().channel(); + std::cout << InnerChannel << std::endl; + + +/* + // SimHits related variables + + + + unsigned int primarySimHits(0); + unsigned int otherSimHits(0); + + for (edm::PSimHitContainer::const_iterator hitIt(simHitsRaw->begin()); hitIt != simHitsRaw->end(); ++hitIt) { + if (rawid == hitIt->detUnitId() and std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt->trackId()) != clusterSimTrackIds.end()) { + Local3DPoint localPosHit(hitIt->localPosition()); + + histogramLayer->second.deltaXClusterSimHits[0]->Fill(localPosClu.x() - localPosHit.x()); + histogramLayer->second.deltaYClusterSimHits[0]->Fill(localPosClu.y() - localPosHit.y()); + + // Pixel module + if (topol.ncolumns() == 32) { + histogramLayer->second.deltaXClusterSimHits[1]->Fill(localPosClu.x() - localPosHit.x()); + histogramLayer->second.deltaYClusterSimHits[1]->Fill(localPosClu.y() - localPosHit.y()); + } + // Strip module + else if (topol.ncolumns() == 2) { + histogramLayer->second.deltaXClusterSimHits[2]->Fill(localPosClu.x() - localPosHit.x()); + histogramLayer->second.deltaYClusterSimHits[2]->Fill(localPosClu.y() - localPosHit.y()); + } + + ++otherSimHits; + + std::map< unsigned int, SimTrack >::const_iterator simTrackIt(simTracks.find(hitIt->trackId())); + if (simTrackIt == simTracks.end()) continue; + + // Primary particles only + unsigned int processType(hitIt->processType()); + if (simTrackIt->second.vertIndex() == 0 and (processType == 2 || processType == 7 || processType == 9 || processType == 11 || processType == 13 || processType == 15)) { + histogramLayer->second.deltaXClusterSimHits_P[0]->Fill(localPosClu.x() - localPosHit.x()); + histogramLayer->second.deltaYClusterSimHits_P[0]->Fill(localPosClu.y() - localPosHit.y()); + + // Pixel module + if (topol.ncolumns() == 32) { + histogramLayer->second.deltaXClusterSimHits_P[1]->Fill(localPosClu.x() - localPosHit.x()); + histogramLayer->second.deltaYClusterSimHits_P[1]->Fill(localPosClu.y() - localPosHit.y()); + } + // Strip module + else if (topol.ncolumns() == 2) { + histogramLayer->second.deltaXClusterSimHits_P[2]->Fill(localPosClu.x() - localPosHit.x()); + histogramLayer->second.deltaYClusterSimHits_P[2]->Fill(localPosClu.y() - localPosHit.y()); + } + + ++primarySimHits; + } + } + } + + otherSimHits -= primarySimHits; + + histogramLayer->second.primarySimHits->Fill(primarySimHits); + histogramLayer->second.otherSimHits->Fill(otherSimHits); +*/ + } + + if (nClustersPixel) histogramLayer->second.numberClusterPixel->Fill(nClustersPixel); + if (nClustersStrip) histogramLayer->second.numberClusterStrip->Fill(nClustersStrip); + nClustersTot++; + tree->Fill(); + } + +} + +// Create the histograms +std::map< unsigned int, ClusterHistos >::iterator Phase2TrackerClusterizerValidationTGraph::createLayerHistograms(unsigned int ival) { + std::ostringstream fname1, fname2; + + edm::Service fs; + fs->file().cd("/"); + + std::string tag; + unsigned int id; + if (ival < 100) { + id = ival; + fname1 << "Barrel"; + fname2 << "Layer_" << id; + tag = "_layer_"; + } + else { + int side = ival / 100; + id = ival - side * 100; + fname1 << "EndCap_Side_" << side; + fname2 << "Disc_" << id; + tag = "_disc_"; + } + + TFileDirectory td1 = fs->mkdir(fname1.str().c_str()); + TFileDirectory td = td1.mkdir(fname2.str().c_str()); + + ClusterHistos local_histos; + + std::ostringstream histoName; + + /* + * Number of clusters + */ + + histoName.str(""); histoName << "Number_Clusters_Pixel" << tag.c_str() << id; + local_histos.numberClusterPixel = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberClusterPixel->SetFillColor(kAzure + 7); + + histoName.str(""); histoName << "Number_Clusters_Strip" << tag.c_str() << id; + local_histos.numberClusterStrip = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberClusterStrip->SetFillColor(kOrange - 3); + + histoName.str(""); histoName << "Number_Clusters_Mixed" << tag.c_str() << id; + local_histos.numberClustersMixed = td.make< THStack >(histoName.str().c_str(), histoName.str().c_str()); + local_histos.numberClustersMixed->Add(local_histos.numberClusterPixel); + local_histos.numberClustersMixed->Add(local_histos.numberClusterStrip); + + /* + * Cluster size + */ + + histoName.str(""); histoName << "Cluster_Size_Pixel" << tag.c_str() << id; + local_histos.clusterSizePixel = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + local_histos.clusterSizePixel->SetFillColor(kAzure + 7); + + histoName.str(""); histoName << "Cluster_Size_Strip" << tag.c_str() << id; + local_histos.clusterSizeStrip = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + local_histos.clusterSizeStrip->SetFillColor(kOrange - 3); + + histoName.str(""); histoName << "Cluster_Size_Mixed" << tag.c_str() << id; + local_histos.clustersSizeMixed = td.make< THStack >(histoName.str().c_str(), histoName.str().c_str()); + local_histos.clustersSizeMixed->Add(local_histos.clusterSizePixel); + local_histos.clustersSizeMixed->Add(local_histos.clusterSizeStrip); + + /* + * Local and Global positions + */ + + histoName.str(""); histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; + local_histos.localPosXY[0] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Local_Position_XY_Pixel" << tag.c_str() << id; + local_histos.localPosXY[1] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Local_Position_XY_Strip" << tag.c_str() << id; + local_histos.localPosXY[2] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[2]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; + local_histos.globalPosXY[0] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Global_Position_XY_Pixel" << tag.c_str() << id; + local_histos.globalPosXY[1] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Global_Position_XY_Strip" << tag.c_str() << id; + local_histos.globalPosXY[2] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); + + /* + * Delta positions with SimHits + */ + + histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaXClusterSimHits[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Pixel" << tag.c_str() << id; + local_histos.deltaXClusterSimHits[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Strip" << tag.c_str() << id; + local_histos.deltaXClusterSimHits[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaYClusterSimHits[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Pixel" << tag.c_str() << id; + local_histos.deltaYClusterSimHits[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Strip" << tag.c_str() << id; + local_histos.deltaYClusterSimHits[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + /* + * Delta position with simHits for primary tracks only + */ + + histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaXClusterSimHits_P[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Pixel_P" << tag.c_str() << id; + local_histos.deltaXClusterSimHits_P[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Strip_P" << tag.c_str() << id; + local_histos.deltaXClusterSimHits_P[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaYClusterSimHits_P[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Pixel_P" << tag.c_str() << id; + local_histos.deltaYClusterSimHits_P[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Strip_P" << tag.c_str() << id; + local_histos.deltaYClusterSimHits_P[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + /* + * Information on the Digis per cluster + */ + + histoName.str(""); histoName << "Primary_Digis" << tag.c_str() << id; + local_histos.primarySimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + + histoName.str(""); histoName << "Other_Digis" << tag.c_str() << id; + local_histos.otherSimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + + /* + * End + */ + + std::pair< std::map< unsigned int, ClusterHistos >::iterator, bool > insertedIt(histograms_.insert(std::make_pair(ival, local_histos))); + fs->file().cd("/"); + + return insertedIt.first; +} + +unsigned int Phase2TrackerClusterizerValidationTGraph::getLayerNumber(const DetId& detid, const TrackerTopology* topo) { + if (detid.det() == DetId::Tracker) { + if (detid.subdetId() == PixelSubdetector::PixelBarrel) return (topo->pxbLayer(detid)); + else if (detid.subdetId() == PixelSubdetector::PixelEndcap) return (100 * topo->pxfSide(detid) + topo->pxfDisk(detid)); + else return 999; + } + return 999; +} + +unsigned int Phase2TrackerClusterizerValidationTGraph::getModuleNumber(const DetId& detid, const TrackerTopology* topo) { + if (detid.det() == DetId::Tracker) { + if (detid.subdetId() == PixelSubdetector::PixelBarrel) { + return ( topo->pxbModule(detid) ); + } + else if (detid.subdetId() == PixelSubdetector::PixelEndcap) { + return ( topo->pxfModule(detid) ); + } + else return 999; + } + return 999; +} + +unsigned int Phase2TrackerClusterizerValidationTGraph::getSimTrackId(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& siphase2SimLinks, const DetId& detId, unsigned int channel) { + edm::DetSetVector< PixelDigiSimLink >::const_iterator DSViter(siphase2SimLinks->find(detId)); + if (DSViter == siphase2SimLinks->end()) return 0; + for (edm::DetSet< PixelDigiSimLink >::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { + if (channel == it->channel()) return it->SimTrackId(); + } + return 0; +} + +DEFINE_FWK_MODULE(Phase2TrackerClusterizerValidationTGraph); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py new file mode 100644 index 0000000000000..b257da7431545 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py @@ -0,0 +1,103 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('RECO',eras.Phase2C2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D4Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +#process.load('Configuration.StandardSequences.Validation_cff') +#process.load('DQMOffline.Configuration.DQMOfflineMC_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +#adding only recolocalreco +process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') + +# import VectorHitBuilder +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('/store/relval/CMSSW_9_1_0_pre1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/90X_upgrade2023_realistic_v9_D4Timing-v1/00000/161D8583-1719-E711-BA42-0CC47A7C346E.root'), + secondaryFileNames = cms.untracked.vstring(), + skipEvents = cms.untracked.uint32(0) +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:10'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.RECOSIMoutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-RECO'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + fileName = cms.untracked.string('file:step3_1event.root'), + outputCommands = cms.untracked.vstring( ('keep *') ), + splitLevel = cms.untracked.int32(0) +) + +# debug +process.MessageLogger = cms.Service('MessageLogger', + debugModules = cms.untracked.vstring('siPhase2Clusters'), + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('ERROR') + ) +) + +# Analyzer +# Analyzer +process.analysis = cms.EDAnalyzer('Phase2TrackerClusterizerValidation', + src = cms.InputTag("siPhase2Clusters"), + links = cms.InputTag("simSiPixelDigis", "Tracker") +) + +#process.analysis = cms.EDAnalyzer('Phase2TrackerClusterizerValidationTGraph', +# src = cms.string("siPhase2Clusters"), +# links = cms.InputTag("simSiPixelDigis", "Tracker") +#) +process.TFileService = cms.Service('TFileService', + fileName = cms.string('file:Clusters_validation.root') +) + + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +process.trackerlocalreco_step = cms.Path(process.trackerlocalreco) +process.analysis_step = cms.Path(process.analysis) +process.RECOSIMoutput_step = cms.EndPath(process.RECOSIMoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.trackerlocalreco_step,process.RECOSIMoutput_step, process.analysis_step) + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py new file mode 100644 index 0000000000000..a485506221930 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py @@ -0,0 +1,123 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('RECO',eras.Phase2C2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +#process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('SimGeneral.MixingModule.mix_POISSON_average_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +#adding only recolocalreco +process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') + +# import VectorHitBuilder +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/02ACC76A-C93F-E711-B711-0CC47A4C8EC8.root', + '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/02FD72C1-D53F-E711-BD00-0CC47A7C3420.root', + '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/04EC6BD2-D53F-E711-B2B7-0025905B858E.root', + '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/061B97AF-C93F-E711-A425-0CC47A4C8F12.root', + '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/081DAA75-C93F-E711-8CAF-0025905B85CA.root', + '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0A1C6B0E-C93F-E711-9145-0CC47A7C3412.root', + '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0AE954E1-D53F-E711-AA9C-0CC47A4D7632.root', + '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0C0660A9-CA3F-E711-8583-0CC47A745298.root', + '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0C66279B-CA3F-E711-A4B3-0CC47A7AB7A0.root', + '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0E5BF643-D43F-E711-A64C-0CC47A7C34E6.root'), + #fileNames = cms.untracked.vstring('file:step2.root'), + secondaryFileNames = cms.untracked.vstring(), + skipEvents = cms.untracked.uint32(0) +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:10'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.RECOSIMoutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-RECO'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + fileName = cms.untracked.string('file:step3_PU200.root'), + outputCommands = cms.untracked.vstring( ('keep *') ), + splitLevel = cms.untracked.int32(0) +) + +# debug +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring("debugVH_PU200"), + debugModules = cms.untracked.vstring("*"), + categories = cms.untracked.vstring("VectorHitsBuilderValidation"), + debugVH_PU200 = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), + DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + #VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), + #VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), + VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) + ) + ) + +# Analyzer +process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', + src = cms.string("siPhase2Clusters"), + VH_acc = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), + VH_rej = cms.InputTag("siPhase2VectorHits", "vectorHitsRejected"), + CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE"), + links = cms.InputTag("simSiPixelDigis", "Tracker"), + trackingParticleSrc = cms.InputTag('mix', 'MergedTrackTruth'), +) +process.TFileService = cms.Service('TFileService', + fileName = cms.string('file:VHs_validation_PU200_new.root') +) + + +# Other statements +process.mix.input.nbPileupEvents.averageNumber = cms.double(200.000000) +process.mix.bunchspace = cms.int32(25) +process.mix.minBunch = cms.int32(-3) +process.mix.maxBunch = cms.int32(3) +process.mix.input.fileNames = cms.untracked.vstring(['/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/0A883B39-083F-E711-8B09-0CC47A7C357A.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/22E509DA-053F-E711-AA7A-0025905B85BA.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/3E376DB4-043F-E711-985E-0CC47A74524E.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/509E21AC-023F-E711-A9F3-0025905B8604.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/5E53AC15-0A3F-E711-8965-0025905A60E0.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/62EC67CA-0B3F-E711-81AC-0025905A610C.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/6476C3E7-063F-E711-B412-0025905B855A.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/7256251B-0B3F-E711-BBEF-0CC47A78A3B4.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/8C943DC3-0B3F-E711-BA5F-0CC47A7C34B0.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/C092AF3B-083F-E711-A0EC-0025905A6070.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/DE2E5EC5-013F-E711-BE84-0CC47A78A3EC.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/DE80A4D4-093F-E711-8195-0CC47A4D75F6.root']) +process.mix.playback = True +process.mix.digitizers = cms.PSet() +for a in process.aliases: delattr(process, a) +process.RandomNumberGeneratorService.restoreStateLabel=cms.untracked.string("randomEngineStateProducer") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +process.trackerlocalreco_step = cms.Path(process.trackerlocalreco+process.siPhase2VectorHits) +process.analysis_step = cms.Path(process.analysis) +process.RECOSIMoutput_step = cms.EndPath(process.RECOSIMoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.trackerlocalreco_step,process.RECOSIMoutput_step, process.analysis_step) + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py new file mode 100644 index 0000000000000..fd60e10fcb5dc --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py @@ -0,0 +1,114 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('RECO',eras.Phase2C2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +#adding only recolocalreco +process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') + +# import VectorHitBuilder +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/0A0A27B4-153F-E711-ABC3-0025905A60C6.root', + '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/34817EB0-163F-E711-83C8-0CC47A7C340C.root', + '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/3CC9FD4E-173F-E711-B4DF-0025905A60D6.root', + '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/521169DF-173F-E711-BC3D-0CC47A7C35A4.root', + '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/6E767157-163F-E711-B315-0025905B8560.root', + '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/7A9BAA32-173F-E711-B7CA-0CC47A78A496.root', + '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/BA5F8EE0-173F-E711-97E9-0025905A6122.root', + '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/CA0AE5B2-153F-E711-B1CE-0025905B85EE.root', + '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/DEFFF299-173F-E711-9A88-0CC47A4C8EE2.root', + '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/FA58F15E-163F-E711-B748-0025905A607A.root'), + #fileNames = cms.untracked.vstring('file:step2.root'), + secondaryFileNames = cms.untracked.vstring(), + skipEvents = cms.untracked.uint32(0) +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:10'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.RECOSIMoutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-RECO'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + fileName = cms.untracked.string('file:step3_1event.root'), + outputCommands = cms.untracked.vstring( ('keep *') ), + splitLevel = cms.untracked.int32(0) +) + +# debug +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring("debugVH_tilted"), + debugModules = cms.untracked.vstring("*"), + categories = cms.untracked.vstring("VectorHitBuilderEDProducer","VectorHitBuilderAlgorithm","VectorHitsBuilderValidation","VectorHitBuilder"), + debugVH_tilted = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), + DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + VectorHitBuilder = cms.untracked.PSet(limit = cms.untracked.int32(-1)), + VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), + VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), + VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) + ) + ) + +# Analyzer +process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', + src = cms.string("siPhase2Clusters"), + VH_acc = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), + VH_rej = cms.InputTag("siPhase2VectorHits", "vectorHitsRejected"), + CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE"), + links = cms.InputTag("simSiPixelDigis", "Tracker"), + trackingParticleSrc = cms.InputTag('mix', 'MergedTrackTruth'), +) +process.TFileService = cms.Service('TFileService', + fileName = cms.string('file:VHs_validation.root') +) + + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +process.trackerlocalreco_step = cms.Path(process.trackerlocalreco+process.siPhase2VectorHits) +process.analysis_step = cms.Path(process.analysis) +process.RECOSIMoutput_step = cms.EndPath(process.RECOSIMoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.trackerlocalreco_step,process.RECOSIMoutput_step, process.analysis_step) + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting_TenMuExtendedE_0_200.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting_TenMuExtendedE_0_200.py new file mode 100644 index 0000000000000..45c7942ff29e4 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting_TenMuExtendedE_0_200.py @@ -0,0 +1,105 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('RECO',eras.Phase2C2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +#adding only recolocalreco +process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') + +# import VectorHitBuilder +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1000) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('file:step2_TenMuExtendedE_0_200.root'), + secondaryFileNames = cms.untracked.vstring(), + #skipEvents = cms.untracked.uint32(0), + #eventsToProcess = cms.untracked.VEventRange('1:952-1:952') +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:10'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.RECOSIMoutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-RECO'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + fileName = cms.untracked.string('file:step3_1event.root'), + outputCommands = cms.untracked.vstring( ('keep *') ), + splitLevel = cms.untracked.int32(0) +) + +# debug +#process.MessageLogger = cms.Service("MessageLogger", +# destinations = cms.untracked.vstring("debugVH_tilted"), +# debugModules = cms.untracked.vstring("*"), +# categories = cms.untracked.vstring("VectorHitBuilderEDProducer","VectorHitBuilderAlgorithm","VectorHitsBuilderValidation","VectorHitBuilder"), +# debugVH_tilted = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), +# DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), +# default = cms.untracked.PSet(limit = cms.untracked.int32(0)), +# VectorHitBuilder = cms.untracked.PSet(limit = cms.untracked.int32(-1)), +# VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), +# VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), +# VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) +# ) +# ) + +# Analyzer +process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', + src = cms.string("siPhase2Clusters"), + VH_acc = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), + VH_rej = cms.InputTag("siPhase2VectorHits", "vectorHitsRejected"), + CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE"), + links = cms.InputTag("simSiPixelDigis", "Tracker"), + trackingParticleSrc = cms.InputTag('mix', 'MergedTrackTruth'), +) +process.TFileService = cms.Service('TFileService', + fileName = cms.string('file:VHs_validation_TenMu_new.root') +) + + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +process.trackerlocalreco_step = cms.Path(process.trackerlocalreco+process.siPhase2VectorHits) +process.analysis_step = cms.Path(process.analysis) +process.RECOSIMoutput_step = cms.EndPath(process.RECOSIMoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.trackerlocalreco_step,process.RECOSIMoutput_step, process.analysis_step) + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc new file mode 100644 index 0000000000000..10992b5d94984 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -0,0 +1,1154 @@ +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h" +#include "SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h" +#include "Geometry/TrackerGeometryBuilder/interface/StackGeomDet.h" +#include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" +#include "DataFormats/SiStripDetId/interface/StripSubdetector.h" + +VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet& conf) : + cpeTag_(conf.getParameter("CPE")) +{ + srcClu_ = consumes< edmNew::DetSetVector >(edm::InputTag(conf.getParameter("src"))); + VHacc_ = consumes< VectorHitCollectionNew >(edm::InputTag(conf.getParameter("VH_acc"))); + VHrej_ = consumes< VectorHitCollectionNew >(edm::InputTag(conf.getParameter("VH_rej"))); + siphase2OTSimLinksToken_ = consumes >(conf.getParameter("links")); + simHitsToken_ = consumes< edm::PSimHitContainer >(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof")); + simTracksToken_ = consumes< edm::SimTrackContainer >(edm::InputTag("g4SimHits")); + simVerticesToken_ = consumes< edm::SimVertexContainer >(edm::InputTag("g4SimHits")); + trackingParticleToken_ = consumes< TrackingParticleCollection >(conf.getParameter("trackingParticleSrc")); +} + +VectorHitsBuilderValidation::~VectorHitsBuilderValidation() { +} + +void VectorHitsBuilderValidation::beginJob() { + + edm::Service fs; + fs->file().cd("/"); + TFileDirectory td = fs->mkdir("Common"); + + //Create common ntuple + tree = td.make< TTree >("VectorHits","VectorHits"); + + // Create common graphs + TFileDirectory tdGloPos = td.mkdir("GlobalPositions"); + trackerLayoutRZ_[0] = tdGloPos.make< TGraph >(); + trackerLayoutRZ_[0] -> SetName("RVsZ_Mixed"); + trackerLayoutRZ_[1] = tdGloPos.make< TGraph >(); + trackerLayoutRZ_[1] -> SetName("RVsZ_Pixel"); + trackerLayoutRZ_[2] = tdGloPos.make< TGraph >(); + trackerLayoutRZ_[2] -> SetName("RVsZ_Strip"); + trackerLayoutXY_[0] = tdGloPos.make< TGraph >(); + trackerLayoutXY_[0] -> SetName("YVsX_Mixed"); + trackerLayoutXY_[1] = tdGloPos.make< TGraph >(); + trackerLayoutXY_[1] -> SetName("YVsX_Pixel"); + trackerLayoutXY_[2] = tdGloPos.make< TGraph >(); + trackerLayoutXY_[2] -> SetName("YVsX_Strip"); + trackerLayoutXYBar_ = tdGloPos.make< TGraph >(); + trackerLayoutXYBar_ -> SetName("YVsXBar"); + trackerLayoutXYEC_ = tdGloPos.make< TGraph >(); + trackerLayoutXYEC_ -> SetName("YVsXEC"); + + TFileDirectory tdLocPos = td.mkdir("LocalPositions"); + localPosXvsDeltaX_[0] = tdLocPos.make< TGraph >(); + localPosXvsDeltaX_[0] -> SetName("localPosXvsDeltaX_Mixed"); + localPosXvsDeltaX_[1] = tdLocPos.make< TGraph >(); + localPosXvsDeltaX_[1] -> SetName("localPosXvsDeltaX_Pixel"); + localPosXvsDeltaX_[2] = tdLocPos.make< TGraph >(); + localPosXvsDeltaX_[2] -> SetName("localPosXvsDeltaX_Strip"); + localPosYvsDeltaY_[0] = tdLocPos.make< TGraph >(); + localPosYvsDeltaY_[0] -> SetName("localPosYvsDeltaY_Mixed"); + localPosYvsDeltaY_[1] = tdLocPos.make< TGraph >(); + localPosYvsDeltaY_[1] -> SetName("localPosYvsDeltaY_Pixel"); + localPosYvsDeltaY_[2] = tdLocPos.make< TGraph >(); + localPosYvsDeltaY_[2] -> SetName("localPosYvsDeltaY_Strip"); + + //drawing VHs arrows + TFileDirectory tdArr = td.mkdir("Directions"); + + //VHXY_[0] = tdArr.make< TCanvas >(); VHXY_[0] -> SetName("YVsX_Mixed"); + //VHXY_[1] = tdArr.make< TCanvas >(); VHXY_[1] -> SetName("YVsX_Pixel"); + //VHXY_[2] = tdArr.make< TCanvas >(); VHXY_[2] -> SetName("YVsX_Strip"); + + TFileDirectory tdWid = td.mkdir("CombinatorialStudies"); + ParallaxCorrectionRZ_ = tdWid.make< TH2D >("ParallaxCorrectionRZ","ParallaxCorrectionRZ", 100, 0., 300., 100., 0., 120.); + ParallaxCorrectionRZ_ -> SetName("ParallaxCorrectionFactor"); + VHaccLayer_ = tdWid.make< TH1F >("VHacceptedLayer","VHacceptedLayer", 250, 0., 250.); + VHaccLayer_ -> SetName("VHaccepted"); + VHrejLayer_ = tdWid.make< TH1F >("VHrejectedLayer","VHrejectedLayer", 250, 0., 250.); + VHrejLayer_ -> SetName("VHrejected"); + VHaccTrueLayer_ = tdWid.make< TH1F >("VHaccTrueLayer","VHaccTrueLayer", 250, 0., 250.); + VHaccTrueLayer_ -> SetName("VHaccepted_true"); + VHrejTrueLayer_ = tdWid.make< TH1F >("VHrejTrueLayer","VHrejTrueLayer", 250, 0., 250.); + VHrejTrueLayer_ -> SetName("VHrejected_true"); + VHaccTrue_signal_Layer_ = tdWid.make< TH1F >("VHaccTrueSignalLayer","VHaccTrueSignalLayer", 250, 0., 250.); + VHaccTrue_signal_Layer_ -> SetName("VHaccepted_true_signal"); + VHrejTrue_signal_Layer_ = tdWid.make< TH1F >("VHrejTrueSignalLayer","VHrejTrueSignalLayer", 250, 0., 250.); + VHrejTrue_signal_Layer_ -> SetName("VHrejected_true_signal"); + + VHaccTrueLayer_ratio = tdWid.make< TH1F >("VHaccTrueLayer_ratio","VHaccTrueLayer_ratio", 250, 0., 250.); + VHaccTrueLayer_ratio -> SetName("VHaccepted_true_ratio"); + VHrejTrueLayer_ratio = tdWid.make< TH1F >("VHrejTrueLayer_ratio","VHrejTrueLayer_ratio", 250, 0., 250.); + VHrejTrueLayer_ratio -> SetName("VHrejected_true_ratio"); + + +} + +void VectorHitsBuilderValidation::endJob() {} + +void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) { + + // Get the needed objects + + // Get the clusters + edm::Handle< Phase2TrackerCluster1DCollectionNew > clusters; + event.getByToken(srcClu_, clusters); + + // Get the vector hits + edm::Handle< VectorHitCollectionNew > vhsAcc; + event.getByToken(VHacc_, vhsAcc); + + edm::Handle< VectorHitCollectionNew > vhsRej; + event.getByToken(VHrej_, vhsRej); + + // load the cpe via the eventsetup + edm::ESHandle > cpeHandle; + eventSetup.get().get(cpeTag_, cpeHandle); + cpe = cpeHandle.product(); + + // Get the Phase2 DigiSimLink + edm::Handle > siphase2SimLinks; + event.getByToken(siphase2OTSimLinksToken_, siphase2SimLinks); + + // Get the SimHits + edm::Handle< edm::PSimHitContainer > simHitsRaw; + event.getByToken(simHitsToken_, simHitsRaw); +// edm::Handle< edm::PSimHitContainer > simHitsRawEndcap; +// event.getByLabel("g4SimHits", "TrackerHitsPixelEndcapLowTof", simHitsRawEndcap); + + // Get the SimTracks + edm::Handle< edm::SimTrackContainer > simTracksRaw; + event.getByToken(simTracksToken_, simTracksRaw); + + // Get the SimVertex + edm::Handle< edm::SimVertexContainer > simVertices; + event.getByToken(simVerticesToken_, simVertices); + + // Get the geometry + edm::ESHandle< TrackerGeometry > geomHandle; + eventSetup.get< TrackerDigiGeometryRecord >().get(geomHandle); + tkGeom = &(*geomHandle); + + // Get the Topology + edm::ESHandle< TrackerTopology > tTopoHandle; + eventSetup.get< TrackerTopologyRcd >().get(tTopoHandle); + tkTopo = tTopoHandle.product(); + + edm::ESHandle< MagneticField > magFieldHandle; + eventSetup.get< IdealMagneticFieldRecord >().get(magFieldHandle); + magField = magFieldHandle.product(); + + //Tracking Particle collection + edm::Handle TPCollectionH; + event.getByToken(trackingParticleToken_,TPCollectionH); + + auto clusterTPList = std::make_unique(TPCollectionH); + std::map, TrackingParticleRef> mapping; + + for (TrackingParticleCollection::size_type itp = 0; itp < TPCollectionH.product()->size(); ++itp) { + TrackingParticleRef trackingParticle(TPCollectionH, itp); + EncodedEventId eid(trackingParticle->eventId()); + for (std::vector::const_iterator itrk = trackingParticle->g4Track_begin(); + itrk != trackingParticle->g4Track_end(); ++itrk) { + std::pair trkid(itrk->trackId(), eid); + LogTrace("VectorHitsBuilderValidation") << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key() ; + mapping.insert(std::make_pair(trkid, trackingParticle)); + } + } + + //set up for tree + int eventNum; + int layer; + int module_id; + int module_number; + int module_type; //1: pixel, 2: strip + int VHacc = 0.0; + int VHrej = 0.0; + int vh_isTrue; + + float x_global, y_global, z_global; + float vh_x_local, vh_y_local; + float vh_x_le, vh_y_le; + float curvature, phi; + float QOverPT, QOverP; + float chi2; + + int low_tp_id, upp_tp_id; + float vh_sim_trackPt; + float sim_x_local, sim_y_local; + float sim_x_global, sim_y_global, sim_z_global; + float low_x_global, low_y_global, low_z_global; + float upp_x_global, upp_y_global, upp_z_global; + float low_xx_global_err, low_yy_global_err, low_zz_global_err; + float low_xy_global_err, low_zx_global_err, low_zy_global_err; + float upp_xx_global_err, upp_yy_global_err, upp_zz_global_err; + float upp_xy_global_err, upp_zx_global_err, upp_zy_global_err; + float deltaXVHSimHits, deltaYVHSimHits; + int multiplicity; + float width, deltaXlocal; + unsigned int processType(99); + + tree -> Branch("event",&eventNum,"eventNum/I"); + tree -> Branch("accepted",&VHacc,"VHacc/I"); + tree -> Branch("rejected",&VHrej,"VHrej/I"); + tree -> Branch("layer",&layer,"layer/I"); + tree -> Branch("module_id",&module_id,"module_id/I"); + tree -> Branch("module_type",&module_type,"module_type/I"); + tree -> Branch("module_number",&module_number,"module_number/I"); + tree -> Branch("vh_isTrue",&vh_isTrue,"vh_isTrue/I"); + tree -> Branch("x_global",&x_global,"x_global/F"); + tree -> Branch("y_global",&y_global,"y_global/F"); + tree -> Branch("z_global",&z_global,"z_global/F"); + tree -> Branch("vh_x_local",&vh_x_local,"vh_x_local/F"); + tree -> Branch("vh_y_local",&vh_y_local,"vh_y_local/F"); + tree -> Branch("vh_x_lError",&vh_x_le,"vh_x_le/F"); + tree -> Branch("vh_y_lError",&vh_y_le,"vh_y_le/F"); + tree -> Branch("curvature",&curvature,"curvature/F"); + tree -> Branch("chi2",&chi2,"chi2/F"); + tree -> Branch("phi",&phi,"phi/F"); + tree -> Branch("QOverP",&QOverP,"QOverP/F"); + tree -> Branch("QOverPT",&QOverPT,"QOverPT/F"); + tree -> Branch("low_tp_id",&low_tp_id,"low_tp_id/I"); + tree -> Branch("upp_tp_id",&upp_tp_id,"upp_tp_id/I"); + tree -> Branch("vh_sim_trackPt",&vh_sim_trackPt,"vh_sim_trackPt/F"); + tree -> Branch("sim_x_local",&sim_x_local,"sim_x_local/F"); + tree -> Branch("sim_y_local",&sim_y_local,"sim_y_local/F"); + tree -> Branch("sim_x_global",&sim_x_global,"sim_x_global/F"); + tree -> Branch("sim_y_global",&sim_y_global,"sim_y_global/F"); + tree -> Branch("sim_z_global",&sim_z_global,"sim_z_global/F"); + tree -> Branch("low_x_global",&low_x_global,"low_x_global/F"); + tree -> Branch("low_y_global",&low_y_global,"low_y_global/F"); + tree -> Branch("low_z_global",&low_z_global,"low_z_global/F"); + tree -> Branch("low_xx_global_err",&low_xx_global_err,"low_xx_global_err/F"); + tree -> Branch("low_yy_global_err",&low_yy_global_err,"low_yy_global_err/F"); + tree -> Branch("low_zz_global_err",&low_zz_global_err,"low_zz_global_err/F"); + tree -> Branch("low_xy_global_err",&low_xy_global_err,"low_xy_global_err/F"); + tree -> Branch("low_zx_global_err",&low_zx_global_err,"low_zx_global_err/F"); + tree -> Branch("low_zy_global_err",&low_zy_global_err,"low_zy_global_err/F"); + tree -> Branch("upp_x_global",&upp_x_global,"upp_x_global/F"); + tree -> Branch("upp_y_global",&upp_y_global,"upp_y_global/F"); + tree -> Branch("upp_z_global",&upp_z_global,"upp_z_global/F"); + tree -> Branch("upp_xx_global_err",&upp_xx_global_err,"upp_xx_global_err/F"); + tree -> Branch("upp_yy_global_err",&upp_yy_global_err,"upp_yy_global_err/F"); + tree -> Branch("upp_zz_global_err",&upp_zz_global_err,"upp_zz_global_err/F"); + tree -> Branch("upp_xy_global_err",&upp_xy_global_err,"upp_xy_global_err/F"); + tree -> Branch("upp_zx_global_err",&upp_zx_global_err,"upp_zx_global_err/F"); + tree -> Branch("upp_zy_global_err",&upp_zy_global_err,"upp_zy_global_err/F"); + tree -> Branch("deltaXVHSimHits",&deltaXVHSimHits,"deltaXVHSimHits/F"); + tree -> Branch("deltaYVHSimHits",&deltaYVHSimHits,"deltaYVHSimHits/F"); + tree -> Branch("multiplicity",&multiplicity,"multiplicity/I"); + tree -> Branch("width",&width,"width/F"); + tree -> Branch("deltaXlocal",&deltaXlocal,"deltaXlocal/F"); + tree -> Branch("processType",&processType,"processType/i"); + + // Rearrange the simTracks for ease of use + SimTracksMap simTracks; + for (edm::SimTrackContainer::const_iterator simTrackIt(simTracksRaw->begin()); simTrackIt != simTracksRaw->end(); ++simTrackIt) simTracks.insert(std::pair< unsigned int, SimTrack >(simTrackIt->trackId(), *simTrackIt)); + + // Rearrange the simHits by detUnit for ease of use + SimHitsMap simHitsDetUnit; + SimHitsMap simHitsTrackId; + for (edm::PSimHitContainer::const_iterator simHitIt(simHitsRaw->begin()); simHitIt != simHitsRaw->end(); ++simHitIt) { + SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt->detUnitId())); + if (simHitsDetUnitIt == simHitsDetUnit.end()) { + std::pair< SimHitsMap::iterator, bool > newIt(simHitsDetUnit.insert(std::pair< unsigned int, std::vector< PSimHit > >(simHitIt->detUnitId(), std::vector< PSimHit >()))); + simHitsDetUnitIt = newIt.first; + } + simHitsDetUnitIt->second.push_back(*simHitIt); + + SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt->trackId())); + if (simHitsTrackIdIt == simHitsTrackId.end()) { + std::pair< SimHitsMap::iterator, bool > newIt(simHitsTrackId.insert(std::pair< unsigned int, std::vector< PSimHit > >(simHitIt->trackId(), std::vector< PSimHit >()))); + simHitsTrackIdIt = newIt.first; + } + simHitsTrackIdIt->second.push_back(*simHitIt); + } + + //Printout outer tracker clusters in the event + for (Phase2TrackerCluster1DCollectionNew::const_iterator DSViter = clusters->begin(); DSViter != clusters->end(); ++DSViter) { + unsigned int rawid(DSViter->detId()); DetId detId(rawid); + const GeomDetUnit* geomDetUnit(tkGeom->idToDetUnit(detId)); + const PixelGeomDetUnit* theGeomDet = dynamic_cast< const PixelGeomDetUnit* >(geomDetUnit); + for (edmNew::DetSet< Phase2TrackerCluster1D >::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); ++clustIt) { + auto && lparams = cpe->localParameters( *clustIt, *theGeomDet ); + Global3DPoint gparams = theGeomDet->surface().toGlobal(lparams.first); + LogTrace("VectorHitsBuilderValidation") << "phase2 OT clusters: " << gparams << " DetId: " << rawid; + } + } + + for (VectorHitCollectionNew::const_iterator DSViter = vhsAcc->begin(); DSViter != vhsAcc->end(); ++DSViter) { + for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + LogTrace("VectorHitsBuilderValidation") << "accepted VH: " << *vhIt; + } + } + for (VectorHitCollectionNew::const_iterator DSViter = vhsRej->begin(); DSViter != vhsRej->end(); ++DSViter) { + for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + LogTrace("VectorHitsBuilderValidation") << "rejected VH: " << *vhIt; + } + } + // Validation + eventNum = event.id().event(); + + unsigned int nVHsTot(0), nVHsPSTot(0), nVHs2STot(0); + std::vector glVHs; + std::vector dirVHs; + std::vector detIds; + + // Loop over modules + for (VectorHitCollectionNew::const_iterator DSViter = vhsAcc->begin(); DSViter != vhsAcc->end(); ++DSViter) { + + // Get the detector unit's id + unsigned int rawid(DSViter->detId()); + module_id = rawid; + DetId detId(rawid); + + module_number = getModuleNumber(detId); + layer = getLayerNumber(detId); + + LogDebug("VectorHitsBuilderValidation") << "Layer: " << layer << " det id" << rawid << std::endl; + + // Get the geometry of the tracker + const GeomDet* geomDet(tkGeom->idToDet(detId)); + if (!geomDet) break; + + // Create histograms for the layer if they do not yet exist + std::map< unsigned int, VHHistos >::iterator histogramLayer(histograms_.find(layer)); + if (histogramLayer == histograms_.end()) histogramLayer = createLayerHistograms(layer); + // Number of clusters + unsigned int nVHsPS(0), nVHs2S(0); + + LogDebug("VectorHitsBuilderValidation") << "DSViter size: " << DSViter->size(); + + + // Loop over the vhs in the detector unit + for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + + // vh variables + if( vhIt->isValid() ){ + + LogDebug("VectorHitsBuilderValidation") << " vh analyzing ..." ; + chi2 = vhIt->chi2(); + LogTrace("VectorHitsBuilderValidation") << "VH chi2 " << chi2 << std::endl; + + Local3DPoint localPosVH = vhIt->localPosition(); + vh_x_local = localPosVH.x(); + vh_y_local = localPosVH.y(); + LogTrace("VectorHitsBuilderValidation") << "local VH position " << localPosVH << std::endl; + + LocalError localErrVH = vhIt->localPositionError(); + vh_x_le = localErrVH.xx(); + vh_y_le = localErrVH.yy(); + LogTrace("VectorHitsBuilderValidation") << "local VH error " << localErrVH << std::endl; + + Global3DPoint globalPosVH = geomDet->surface().toGlobal(localPosVH); + x_global = globalPosVH.x(); + y_global = globalPosVH.y(); + z_global = globalPosVH.z(); + glVHs.push_back(globalPosVH); + LogTrace("VectorHitsBuilderValidation") << " global VH position " << globalPosVH << std::endl; + + Local3DVector localDirVH = vhIt->localDirection(); + LogTrace("VectorHitsBuilderValidation") << "local VH direction " << localDirVH << std::endl; + + VectorHit vh = *vhIt; + Global3DVector globalDirVH = vh.globalDelta(); + dirVHs.push_back(globalDirVH); + LogTrace("VectorHitsBuilderValidation") << "global VH direction " << globalDirVH << std::endl; + + // Fill the position histograms + trackerLayoutRZ_[0]->SetPoint(nVHsTot, globalPosVH.z(), globalPosVH.perp()); + trackerLayoutXY_[0]->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + + if (layer < 100) trackerLayoutXYBar_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + else trackerLayoutXYEC_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + + histogramLayer->second.localPosXY[0]->SetPoint(nVHsTot, vh_x_local, vh_y_local); + histogramLayer->second.globalPosXY[0]->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + + localPosXvsDeltaX_[0]->SetPoint(nVHsTot, vh_x_local, localDirVH.x()); + localPosYvsDeltaY_[0]->SetPoint(nVHsTot, vh_y_local, localDirVH.y()); + + // Pixel module + const StackGeomDet* stackDet = dynamic_cast(geomDet); + const PixelGeomDetUnit* geomDetLower = dynamic_cast< const PixelGeomDetUnit* >(stackDet->lowerDet()); + DetId lowerDetId = stackDet->lowerDet()->geographicalId(); + DetId upperDetId = stackDet->upperDet()->geographicalId(); + + + TrackerGeometry::ModuleType mType = tkGeom->getDetectorType(lowerDetId); + module_type = 0; + if (mType == TrackerGeometry::ModuleType::Ph2PSP) { + module_type = 1; + trackerLayoutRZ_[1]->SetPoint(nVHsPSTot, globalPosVH.z(), globalPosVH.perp()); + trackerLayoutXY_[1]->SetPoint(nVHsPSTot, globalPosVH.x(), globalPosVH.y()); + + histogramLayer->second.localPosXY[1]->SetPoint(nVHsPSTot, vh_x_local, vh_y_local); + histogramLayer->second.globalPosXY[1]->SetPoint(nVHsPSTot, globalPosVH.x(), globalPosVH.y()); + + localPosXvsDeltaX_[1]->SetPoint(nVHsPSTot, vh_x_local, localDirVH.x()); + localPosYvsDeltaY_[1]->SetPoint(nVHsPSTot, vh_y_local, localDirVH.y()); + + ++nVHsPS; + ++nVHsPSTot; + } + + // Strip module + else if (mType == TrackerGeometry::ModuleType::Ph2SS) { + module_type = 2; + trackerLayoutRZ_[2]->SetPoint(nVHs2STot, globalPosVH.z(), globalPosVH.perp()); + trackerLayoutXY_[2]->SetPoint(nVHs2STot, globalPosVH.x(), globalPosVH.y()); + + histogramLayer->second.localPosXY[2]->SetPoint(nVHs2STot, vh_x_local, vh_y_local); + histogramLayer->second.globalPosXY[2]->SetPoint(nVHs2STot, globalPosVH.x(), globalPosVH.y()); + + localPosXvsDeltaX_[2]->SetPoint(nVHs2STot, vh_x_local, localDirVH.x()); + localPosYvsDeltaY_[2]->SetPoint(nVHs2STot, vh_y_local, localDirVH.y()); + + ++nVHs2S; + ++nVHs2STot; + } else if (mType == TrackerGeometry::ModuleType::Ph2PSS) { + edm::LogError("VectorHitsBuilderValidation") << "module type " << module_type << " should never happen!"; + } + LogTrace("VectorHitsBuilderValidation") << "module type " << module_type << std::endl; + + // get the geomDetUnit of the clusters + low_x_global = vhIt->lowerGlobalPos().x(); + low_y_global = vhIt->lowerGlobalPos().y(); + low_z_global = vhIt->lowerGlobalPos().z(); + upp_x_global = vhIt->upperGlobalPos().x(); + upp_y_global = vhIt->upperGlobalPos().y(); + upp_z_global = vhIt->upperGlobalPos().z(); + + low_xx_global_err = vhIt->lowerGlobalPosErr().cxx(); + low_yy_global_err = vhIt->lowerGlobalPosErr().cyy(); + low_zz_global_err = vhIt->lowerGlobalPosErr().czz(); + low_xy_global_err = vhIt->lowerGlobalPosErr().cyx(); + low_zx_global_err = vhIt->lowerGlobalPosErr().czx(); + low_zy_global_err = vhIt->lowerGlobalPosErr().czy(); + + upp_xx_global_err = vhIt->upperGlobalPosErr().cxx(); + upp_yy_global_err = vhIt->upperGlobalPosErr().cyy(); + upp_zz_global_err = vhIt->upperGlobalPosErr().czz(); + upp_xy_global_err = vhIt->upperGlobalPosErr().cyx(); + upp_zx_global_err = vhIt->upperGlobalPosErr().czx(); + upp_zy_global_err = vhIt->upperGlobalPosErr().czy(); + + LogDebug("VectorHitsBuilderValidation") << "print Clusters into the VH:" << std::endl; + printCluster(geomDetLower,vhIt->lowerClusterRef()); + LogTrace("VectorHitsBuilderValidation") << "\t global pos lower " << vhIt->lowerGlobalPos() << std::endl; + LogTrace("VectorHitsBuilderValidation") << "\t global posErr lower " << vhIt->lowerGlobalPosErr().cxx() << std::endl; + const GeomDetUnit* geomDetUpper = stackDet->upperDet(); + printCluster(geomDetUpper,vhIt->upperClusterRef()); + LogTrace("VectorHitsBuilderValidation") << "\t global pos upper " << vhIt->upperGlobalPos() << std::endl; + + //comparison with SIM hits + LogDebug("VectorHitsBuilderValidation") << "comparison Clusters with sim hits ... " << std::endl; + std::vector< unsigned int > clusterSimTrackIds; + std::vector< unsigned int > clusterSimTrackIdsUpp; + std::set > simTkIds; + const GeomDetUnit* geomDetUnit_low(tkGeom->idToDetUnit(lowerDetId)); + LogTrace("VectorHitsBuilderValidation") << " lowerDetID : " << lowerDetId.rawId(); + const GeomDetUnit* geomDetUnit_upp(tkGeom->idToDetUnit(upperDetId)); + LogTrace("VectorHitsBuilderValidation") << " upperDetID : " << upperDetId.rawId(); + + for (unsigned int istr(0); istr < (*(vhIt->lowerClusterRef().cluster_phase2OT())).size(); ++istr) { + uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vhIt->lowerClusterRef().cluster_phase2OT())).firstRow() + istr, (*(vhIt->lowerClusterRef().cluster_phase2OT())).column()); + unsigned int LowerSimTrackId(getSimTrackId(siphase2SimLinks, lowerDetId, channel)); + std::vector > trkid(getSimTrackIds(siphase2SimLinks, lowerDetId, channel)); + if (trkid.size()==0) continue; + clusterSimTrackIds.push_back(LowerSimTrackId); + simTkIds.insert(trkid.begin(),trkid.end()); + LogTrace("VectorHitsBuilderValidation") << "LowerSimTrackId " << LowerSimTrackId << std::endl; + } + // In the case of PU, we need the TPs to find the proper SimTrackID + for (std::set >::const_iterator iset = simTkIds.begin(); + iset != simTkIds.end(); iset++) { + auto ipos = mapping.find(*iset); + if (ipos != mapping.end()) { + LogTrace("VectorHitsBuilderValidation") << "lower cluster in detid: " << lowerDetId.rawId() << " from tp: " << ipos->second.key() << " " << iset->first; + LogTrace("VectorHitsBuilderValidation") << "with pt(): " << (*ipos->second).pt(); + low_tp_id = ipos->second.key(); + vh_sim_trackPt = (*ipos->second).pt(); + } + } + + simTkIds.clear(); + for (unsigned int istr(0); istr < (*(vhIt->upperClusterRef().cluster_phase2OT())).size(); ++istr) { + uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vhIt->upperClusterRef().cluster_phase2OT())).firstRow() + istr, (*(vhIt->upperClusterRef().cluster_phase2OT())).column()); + unsigned int UpperSimTrackId(getSimTrackId(siphase2SimLinks, upperDetId, channel)); + std::vector > trkid(getSimTrackIds(siphase2SimLinks, upperDetId, channel)); + if (trkid.size()==0) continue; + clusterSimTrackIdsUpp.push_back(UpperSimTrackId); + simTkIds.insert(trkid.begin(),trkid.end()); + LogTrace("VectorHitsBuilderValidation") << "UpperSimTrackId " << UpperSimTrackId << std::endl; + } + // In the case of PU, we need the TPs to find the proper SimTrackID + for (std::set >::const_iterator iset = simTkIds.begin(); + iset != simTkIds.end(); iset++) { + auto ipos = mapping.find(*iset); + if (ipos != mapping.end()) { + LogTrace("VectorHitsBuilderValidation") << "upper cluster in detid: " << upperDetId.rawId() << " from tp: " << ipos->second.key() << " " << iset->first << std::endl; + upp_tp_id = ipos->second.key(); + } + } + //compute if the vhits is 'true' or 'false' and save sim pT + std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); + vh_isTrue = 0; + if(istrue.first){ + vh_isTrue = 1; + } + + + + // loop over all simHits + unsigned int totalSimHits(0); + unsigned int primarySimHits(0); + unsigned int otherSimHits(0); + + + for (edm::PSimHitContainer::const_iterator hitIt(simHitsRaw->begin()); hitIt != simHitsRaw->end(); ++hitIt) { + + if(hitIt->detUnitId() == geomDetLower->geographicalId()){// || hitIt->detUnitId() == geomDetUpper->geographicalId()){ + + //check clusters track id compatibility + if(std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt->trackId()) != clusterSimTrackIds.end()){ + + Local3DPoint localPosHit(hitIt->localPosition()); + sim_x_local = localPosHit.x(); + sim_y_local = localPosHit.y(); + + deltaXVHSimHits = vh_x_local - sim_x_local; + deltaYVHSimHits = vh_y_local - sim_y_local; + + Global3DPoint globalPosHit = geomDetLower->surface().toGlobal(localPosHit); + sim_x_global = globalPosHit.x(); + sim_y_global = globalPosHit.y(); + sim_z_global = globalPosHit.z(); + + histogramLayer->second.deltaXVHSimHits[0]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits[0]->Fill(vh_y_local - sim_y_local); + + // Pixel module + if (layer == 1 || layer == 2 || layer == 3) { + histogramLayer->second.deltaXVHSimHits[1]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits[1]->Fill(vh_y_local - sim_y_local); + } + // Strip module + else if (layer == 4 || layer == 5 || layer == 6) { + histogramLayer->second.deltaXVHSimHits[2]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits[2]->Fill(vh_y_local - sim_y_local); + } + + ++totalSimHits; + + std::map< unsigned int, SimTrack >::const_iterator simTrackIt(simTracks.find(hitIt->trackId())); + if (simTrackIt == simTracks.end()) continue; + //LogTrace("VectorHitsBuilderValidation") << "--> with hitIt. The SimTrack has p: " << simTrackIt->second.momentum(); + + + // Primary particles only + processType = hitIt->processType(); + + if (simTrackIt->second.vertIndex() == 0 and (processType == 2 || processType == 7 || processType == 9 || processType == 11 || processType == 13 || processType == 15)) { + histogramLayer->second.deltaXVHSimHits_P[0]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits_P[0]->Fill(vh_y_local - sim_y_local); + + // Pixel module + if (layer == 1 || layer == 2 || layer == 3) { + histogramLayer->second.deltaXVHSimHits_P[1]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits_P[1]->Fill(vh_y_local - sim_y_local); + } + // Strip module + else if (layer == 4 || layer == 5 || layer == 6) { + histogramLayer->second.deltaXVHSimHits_P[2]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits_P[2]->Fill(vh_y_local - sim_y_local); + } + + ++primarySimHits; + } + + otherSimHits = totalSimHits - primarySimHits; + + histogramLayer->second.totalSimHits->Fill(totalSimHits); + histogramLayer->second.primarySimHits->Fill(primarySimHits); + histogramLayer->second.otherSimHits->Fill(otherSimHits); + + } + } + }// loop simhits + + nVHsTot++; + //tree->Fill(); + + //****************************** + //combinatorial studies : not filling if more than 1 VH has been produced + //****************************** + multiplicity = DSViter->size(); + if(DSViter->size()>1){ + LogTrace("VectorHitsBuilderValidation") << " not filling if more than 1 VH has been produced"; + width = -100; + deltaXlocal = -100; + tree->Fill(); + continue; + } + + //curvature + curvature = vh.curvatureORphi("curvature").first; + phi = vh.curvatureORphi("phi").first; + QOverPT = vh.transverseMomentum(magField); + QOverP = vh.momentum(magField); + histogramLayer->second.curvature->Fill(curvature); + + //stub width + + auto && lparamsUpp = cpe->localParameters( *vhIt->upperClusterRef().cluster_phase2OT(), *geomDetUnit_upp ); + LogTrace("VectorHitsBuilderValidation") << " upper local pos (in its sor):" << lparamsUpp.first; + Global3DPoint gparamsUpp = geomDetUnit_upp->surface().toGlobal(lparamsUpp.first); + LogTrace("VectorHitsBuilderValidation") << " upper global pos :" << gparamsUpp; + Local3DPoint lparamsUppInLow = geomDetUnit_low->surface().toLocal(gparamsUpp); + LogTrace("VectorHitsBuilderValidation") << " upper local pos (in low sor):" << lparamsUppInLow; + auto && lparamsLow = cpe->localParameters( *vhIt->lowerClusterRef().cluster_phase2OT(), *geomDetUnit_low ); + LogTrace("VectorHitsBuilderValidation") << " lower local pos (in its sor):" << lparamsLow.first; + Global3DPoint gparamsLow = geomDetUnit_low->surface().toGlobal(lparamsLow.first); + LogTrace("VectorHitsBuilderValidation") << " lower global pos :" << gparamsLow; + + //width = difference of centroids in precise coordinate (in low sor) corrected with parallax correction + deltaXlocal = lparamsUppInLow.x() - lparamsLow.first.x(); + histogramLayer->second.deltaXlocal->Fill(deltaXlocal); + LogTrace("VectorHitsBuilderValidation") << " deltaXlocal : " << deltaXlocal; + + double parallCorr = 0.0; + + Global3DPoint origin(0,0,0); + GlobalVector gV = gparamsLow - origin; + //LogTrace("VectorHitsBuilderValidation") << " global vector passing to the origin:" << gV; + LocalVector lV = geomDetUnit_low->surface().toLocal(gV); + //LogTrace("VectorHitsBuilderValidation") << " local vector passing to the origin (in low sor):" << lV; + LocalVector lV_norm = lV/lV.z(); + //LogTrace("VectorHitsBuilderValidation") << " normalized local vector passing to the origin (in low sor):" << lV_norm; + parallCorr = lV_norm.x() * lparamsUppInLow.z(); + LogTrace("VectorHitsBuilderValidation") << " parallalex correction:" << parallCorr; + + double lpos_upp_corr = 0.0; + double lpos_low_corr = 0.0; + if(lparamsUpp.first.x() > lparamsLow.first.x()){ + if(lparamsUpp.first.x() > 0){ + lpos_low_corr = lparamsLow.first.x(); + lpos_upp_corr = lparamsUpp.first.x() - fabs(parallCorr); + } + if(lparamsUpp.first.x() < 0){ + lpos_low_corr = lparamsLow.first.x() + fabs(parallCorr); + lpos_upp_corr = lparamsUpp.first.x(); + } + } else if( lparamsUpp.first.x() < lparamsLow.first.x() ) { + if(lparamsUpp.first.x() > 0){ + lpos_low_corr = lparamsLow.first.x() - fabs(parallCorr); + lpos_upp_corr = lparamsUpp.first.x(); + } + if(lparamsUpp.first.x() < 0){ + lpos_low_corr = lparamsLow.first.x(); + lpos_upp_corr = lparamsUpp.first.x() + fabs(parallCorr); + } + } else { + if(lparamsUpp.first.x() > 0){ + lpos_upp_corr = lparamsUpp.first.x() - fabs(parallCorr); + lpos_low_corr = lparamsLow.first.x(); + } + if(lparamsUpp.first.x() < 0){ + lpos_upp_corr = lparamsUpp.first.x() + fabs(parallCorr); + lpos_low_corr = lparamsLow.first.x(); + } + } + + LogDebug("VectorHitsBuilderValidation") << " \t local pos upper corrected (x):" << lpos_upp_corr << std::endl; + LogDebug("VectorHitsBuilderValidation") << " \t local pos lower corrected (x):" << lpos_low_corr << std::endl; + + width = lpos_low_corr - lpos_upp_corr; + histogramLayer->second.width->Fill(width); + LogTrace("VectorHitsBuilderValidation") << " width:" << width; + + tree->Fill(); + + + }// vh valid + + }// loop vhs + + if (nVHsPS) histogramLayer->second.numberVHsPS->Fill(nVHsPS); + if (nVHs2S) histogramLayer->second.numberVHs2S->Fill(nVHs2S); + LogTrace("VectorHitsBuilderValidation") << "nVHsPS for this layer : " << nVHsPS << ", nVHs2S for this layer : " << nVHs2S << std::endl; + } + + CreateVHsXYGraph(glVHs, dirVHs); + CreateVHsRZGraph(glVHs, dirVHs); + + int VHaccTrue = 0.0; + int VHaccFalse = 0.0; + int VHrejTrue = 0.0; + int VHrejFalse = 0.0; + int VHaccTrue_signal = 0.0; + int VHrejTrue_signal = 0.0; + + // Loop over modules + for (VectorHitCollectionNew::const_iterator DSViter = vhsAcc->begin(); DSViter != vhsAcc->end(); ++DSViter) { + + unsigned int rawid(DSViter->detId()); + DetId detId(rawid); + int layerAcc = getLayerNumber(detId); + LogTrace("VectorHitsBuilderValidation") << "acc Layer: " << layerAcc << " det id" << rawid << std::endl; + for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + if( vhIt->isValid() ){ + VHaccLayer_->Fill(layerAcc); + VHacc++; + + //compute if the vhits is 'true' or 'false' + std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); + if(istrue.first){ + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; + VHaccTrueLayer_->Fill(layerAcc); + //VHaccTrueLayer_ratio->Fill(layerAcc); + VHaccTrue++; + + //saving info of 'signal' track + std::map< unsigned int, SimTrack >::const_iterator simTrackIt(simTracks.find(istrue.second)); + if (simTrackIt == simTracks.end()) continue; + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is associated with SimTrackId: " << istrue.second; + LogTrace("VectorHitsBuilderValidation") << "the SimTrack has pt: " << simTrackIt->second.momentum().pt(); + if (simTrackIt->second.momentum().pt() > 1 ) { + VHaccTrue_signal_Layer_->Fill(layerAcc); + LogTrace("VectorHitsBuilderValidation") << "the vectorhit belongs to signal"; + VHaccTrue_signal++; + } + + } else { + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'false' vhit."; + VHaccFalse++; + } + + } + } + + } + + + //it is not really working.. + //VHaccTrueLayer_ratio->Divide(VHaccLayer_); + + for (VectorHitCollectionNew::const_iterator DSViter = vhsRej->begin(); DSViter != vhsRej->end(); ++DSViter) { + + unsigned int rawid(DSViter->detId()); + DetId detId(rawid); + int layerRej = getLayerNumber(detId); + LogTrace("VectorHitsBuilderValidation") << "rej Layer: " << layerRej << " det id" << rawid << std::endl; + for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + VHrejLayer_->Fill(layerRej); + VHrej++; + + //compute if the vhits is 'true' or 'false' + std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); + if(istrue.first){ + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; + VHrejTrueLayer_->Fill(layerRej); + //VHrejTrueLayer_ratio->Fill(layerRej); + VHrejTrue++; + + //saving info of 'signal' track + std::map< unsigned int, SimTrack >::const_iterator simTrackIt(simTracks.find(istrue.second)); + if (simTrackIt == simTracks.end()) continue; + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is associated with SimTrackId: " << istrue.second; + LogTrace("VectorHitsBuilderValidation") << "the SimTrack has pt: " << simTrackIt->second.momentum().pt(); + if (simTrackIt->second.momentum().pt() > 1 ) { + VHrejTrue_signal_Layer_->Fill(layerRej); + LogTrace("VectorHitsBuilderValidation") << "the vectorhit belongs to signal"; + VHrejTrue_signal++; + } + + } else { + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'false' vhit."; + VHrejFalse++; + } + + } + + } + + //it is not really working.. + //VHrejTrueLayer_ratio->Divide(VHrejLayer_); + + int VHtot = VHacc + VHrej; + LogTrace("VectorHitsBuilderValidation") << "VH total: " << VHtot << " with " << VHacc << " VHs accepted and " << VHrej << " VHs rejected."; + LogTrace("VectorHitsBuilderValidation") << "of the VH accepted, there are " << VHaccTrue << " true and " << VHaccFalse << " false."; + LogTrace("VectorHitsBuilderValidation") << "of the VH rejected, there are " << VHrejTrue << " true and " << VHrejFalse << " false."; + LogTrace("VectorHitsBuilderValidation") << "of the true VH , there are " << VHaccTrue_signal << " accepted belonging to signal and " << VHrejTrue_signal << " rejected belonging to signal."; + +// CreateWindowCorrGraph(); + +} + +// Check if the vector hit is true (both clusters are formed from the same SimTrack +std::pair VectorHitsBuilderValidation::isTrue(const VectorHit vh, const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& siphase2SimLinks, DetId& detId) const{ + + const GeomDet* geomDet(tkGeom->idToDet(detId)); + const StackGeomDet* stackDet = dynamic_cast(geomDet); + const GeomDetUnit* geomDetLower = stackDet->lowerDet(); + const GeomDetUnit* geomDetUpper = stackDet->upperDet(); + + std::vector< unsigned int > lowClusterSimTrackIds; + //std::set > simTkIds; + + for (unsigned int istr(0); istr < (*(vh.lowerClusterRef().cluster_phase2OT())).size(); ++istr) { + uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.lowerClusterRef().cluster_phase2OT())).firstRow() + istr, (*(vh.lowerClusterRef().cluster_phase2OT())).column()); + DetId detIdCluster = geomDetLower->geographicalId(); + unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detIdCluster, channel)); + LogTrace("VectorHitsBuilderValidation") << "LowerSimTrackId " << simTrackId << std::endl; + std::vector > trkid(getSimTrackIds(siphase2SimLinks, detIdCluster, channel)); + if (trkid.size()==0) continue; + lowClusterSimTrackIds.push_back(simTrackId); + //simTkIds.insert(trkid.begin(),trkid.end()); + } + + std::vector< unsigned int >::iterator it_simTrackUpper; + + for (unsigned int istr(0); istr < (*(vh.upperClusterRef().cluster_phase2OT())).size(); ++istr) { + uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.upperClusterRef().cluster_phase2OT())).firstRow() + istr, (*(vh.upperClusterRef().cluster_phase2OT())).column()); + DetId detIdCluster = geomDetUpper->geographicalId(); + unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detIdCluster, channel)); + LogTrace("VectorHitsBuilderValidation") << "UpperSimTrackId " << simTrackId << std::endl; + std::vector > trkid(getSimTrackIds(siphase2SimLinks, detIdCluster, channel)); + if (trkid.size()==0) continue; + it_simTrackUpper = std::find(lowClusterSimTrackIds.begin(), lowClusterSimTrackIds.end(), simTrackId); + if ( it_simTrackUpper != lowClusterSimTrackIds.end() ) { + LogTrace("VectorHitsBuilderValidation") << " UpperSimTrackId found in lowClusterSimTrackIds "; + return std::make_pair(true,simTrackId); + } + //clusterSimTrackIds.push_back(UpperSimTrackId); + //simTkIds.insert(trkid.begin(),trkid.end()); + } + return std::make_pair(false,0); +} + +// Create the histograms +std::map< unsigned int, VHHistos >::iterator VectorHitsBuilderValidation::createLayerHistograms(unsigned int ival) { + std::ostringstream fname1, fname2; + + edm::Service fs; + fs->file().cd("/"); + + std::string tag; + unsigned int id; + if (ival < 100) { + id = ival; + fname1 << "Barrel"; + fname2 << "Layer_" << id; + tag = "_layer_"; + } + else { + int side = ival / 100; + id = ival - side * 100; + fname1 << "EndCap_Side_" << side; + fname2 << "Disc_" << id; + tag = "_disc_"; + } + + TFileDirectory td1 = fs->mkdir(fname1.str().c_str()); + TFileDirectory td = td1.mkdir(fname2.str().c_str()); + + VHHistos local_histos; + + std::ostringstream histoName; + + /* + * Number of clusters + */ + + histoName.str(""); histoName << "Number_VHs_PS" << tag.c_str() << id; + local_histos.numberVHsPS = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberVHsPS->SetFillColor(kAzure + 7); + + histoName.str(""); histoName << "Number_VHs_2S" << tag.c_str() << id; + local_histos.numberVHs2S = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberVHs2S->SetFillColor(kOrange - 3); + + histoName.str(""); histoName << "Number_VHs_Mixed" << tag.c_str() << id; + local_histos.numberVHsMixed = td.make< THStack >(histoName.str().c_str(), histoName.str().c_str()); + local_histos.numberVHsMixed->Add(local_histos.numberVHsPS); + local_histos.numberVHsMixed->Add(local_histos.numberVHs2S); + + /* + * Local and Global positions + */ + + histoName.str(""); histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; + local_histos.localPosXY[0] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Local_Position_XY_PS" << tag.c_str() << id; + local_histos.localPosXY[1] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Local_Position_XY_2S" << tag.c_str() << id; + local_histos.localPosXY[2] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[2]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; + local_histos.globalPosXY[0] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Global_Position_XY_PS" << tag.c_str() << id; + local_histos.globalPosXY[1] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); histoName << "Global_Position_XY_2S" << tag.c_str() << id; + local_histos.globalPosXY[2] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); + + /* + * Delta positions with SimHits + */ + + histoName.str(""); histoName << "Delta_X_VH_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaXVHSimHits[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_X_VH_SimHits_PS" << tag.c_str() << id; + local_histos.deltaXVHSimHits[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_X_VH_SimHits_2S" << tag.c_str() << id; + local_histos.deltaXVHSimHits[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_VH_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaYVHSimHits[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_VH_SimHits_PS" << tag.c_str() << id; + local_histos.deltaYVHSimHits[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_VH_SimHits_2S" << tag.c_str() << id; + local_histos.deltaYVHSimHits[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + /* + * Delta position with simHits for primary tracks only + */ + + histoName.str(""); histoName << "Delta_X_VH_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaXVHSimHits_P[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_X_VH_SimHits_PS_P" << tag.c_str() << id; + local_histos.deltaXVHSimHits_P[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_X_VH_SimHits_2S_P" << tag.c_str() << id; + local_histos.deltaXVHSimHits_P[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_VH_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaYVHSimHits_P[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_VH_SimHits_PS_P" << tag.c_str() << id; + local_histos.deltaYVHSimHits_P[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); histoName << "Delta_Y_VH_SimHits_2S_P" << tag.c_str() << id; + local_histos.deltaYVHSimHits_P[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + /* + * Information on the Digis per cluster + */ + + histoName.str(""); histoName << "Total_Digis" << tag.c_str() << id; + local_histos.totalSimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + + histoName.str(""); histoName << "Primary_Digis" << tag.c_str() << id; + local_histos.primarySimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + + histoName.str(""); histoName << "Other_Digis" << tag.c_str() << id; + local_histos.otherSimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + + /* + * Study on the clusters combinatorial problem + */ + + histoName.str(""); histoName << "DeltaXlocal_clusters" << tag.c_str() << id; + local_histos.deltaXlocal= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); + histoName.str(""); histoName << "Width" << tag.c_str() << id; + local_histos.width= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); + histoName.str(""); histoName << "Curvature" << tag.c_str() << id; + local_histos.curvature= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); + + std::pair< std::map< unsigned int, VHHistos >::iterator, bool > insertedIt(histograms_.insert(std::make_pair(ival, local_histos))); + fs->file().cd("/"); + + return insertedIt.first; +} + +void VectorHitsBuilderValidation::CreateVHsXYGraph(const std::vector glVHs,const std::vector dirVHs){ + + if(glVHs.size() != dirVHs.size()){ + std::cout << "Cannot fullfil the graphs for this event. Return." << std::endl; + return; + } + + // opening canvas and drawing XY TGraph + + //TCanvas * VHXY_ = new TCanvas("RVsY_Mixed","RVsY_Mixed",800,600); + //VHXY_->cd(); + //trackerLayoutXY_[0]->Draw("AP"); + +// float finalposX, finalposY; + + for(unsigned int nVH = 0; nVH < glVHs.size(); nVH++){ + +// finalposX = glVHs.at(nVH).x() + dirVHs.at(nVH).x(); +// finalposY = glVHs.at(nVH).y() + dirVHs.at(nVH).y(); + //std::cout << glVHs.at(nVH) << " " << " \tr: " << glVHs.at(nVH).perp() << std::endl; + //std::cout << dirVHs.at(nVH).x() << "," << dirVHs.at(nVH).y() << std::endl; + + //same r + if((fabs(dirVHs.at(nVH).x()) < 10e-5) && (fabs(dirVHs.at(nVH).y()) < 10e-5)){ + + //std::cout << "same pos!"; + continue; + + } else { + + // TArrow* vh_arrow = new TArrow(glVHs.at(nVH).x(), glVHs.at(nVH).y(), finalposX, finalposY, 0.05, ">"); + // vh_arrow->Draw("same"); + + } + + + } + + return; +} + +void VectorHitsBuilderValidation::CreateVHsRZGraph(const std::vector glVHs,const std::vector dirVHs){ + + if(glVHs.size() != dirVHs.size()){ + std::cout << "Cannot fullfil the graphs for this event. Return." << std::endl; + return; + } + + // opening canvas and drawing RZ TGraph + // + //TCanvas* VHRZ_ = new TCanvas("RVsZ_Mixed","RVsZ_Mixed",800,600); + //VHRZ_->cd(); + //trackerLayoutRZ_[0]->Draw("AP"); + +// float finalposX, finalposY, finalposR, finalposZ; + +// for(unsigned int nVH = 0; nVH < glVHs.size(); nVH++){ + +// finalposX = glVHs.at(nVH).x() + dirVHs.at(nVH).x(); +// finalposY = glVHs.at(nVH).y() + dirVHs.at(nVH).y(); +// finalposR = sqrt( pow(finalposX,2) + pow(finalposY,2) ); +// finalposZ = glVHs.at(nVH).z() + dirVHs.at(nVH).z(); + + //std::cout << dirVHs.at(nVH) " " << " \tr: " << dirVHs.at(nVH).perp() << std::endl; + //std::cout << finalposX << ", " << finalposY << " " << " \tr: " << finalposR << std::endl; + //std::cout << std::endl; + +// TArrow* vh_arrow = new TArrow(glVHs.at(nVH).z(), glVHs.at(nVH).perp(), finalposZ, finalposR, 0.05, "|>"); +// vh_arrow->SetLineWidth(2); +// vh_arrow->Draw("same"); + +// } + + return; +} + +void VectorHitsBuilderValidation::CreateWindowCorrGraph(){ + + //FIXME: This function is not working properly, yet. + + //return if we are not using Phase2 OT + if(!tkGeom->isThere(GeomDetEnumerators::P2OTB) && !tkGeom->isThere(GeomDetEnumerators::P2OTEC)) + return; + + for(auto det : tkGeom->detsTOB()){ +// std::cout << det->geographicalId().rawId() << std::endl; +// std::cout << det->surface().bounds().thickness() << std::endl; + ParallaxCorrectionRZ_->Fill(det->position().z(),det->position().perp(),5.); + } + for(auto det : tkGeom->detsTID()){ + //std::cout << det->geographicalId().rawId() << std::endl; + ParallaxCorrectionRZ_->Fill(det->position().z(),det->position().perp(),10.); + } + ParallaxCorrectionRZ_->Fill(0.,0.,5.); + return; +} + +unsigned int VectorHitsBuilderValidation::getLayerNumber(const DetId& detid) { + if (detid.det() == DetId::Tracker) { + if (detid.subdetId() == StripSubdetector::TOB) return (tkTopo->layer(detid)); + else if (detid.subdetId() == StripSubdetector::TID) return (100 * tkTopo->side(detid) + tkTopo->layer(detid)); + else return 999; + } + return 999; +} + +unsigned int VectorHitsBuilderValidation::getModuleNumber(const DetId& detid) { + return (tkTopo->module(detid)); +} + +std::vector< std::pair > +VectorHitsBuilderValidation::getSimTrackIds(const edm::Handle >& simLinks, + const DetId& detId, uint32_t channel) const +{ + std::vector< std::pair > simTrkId; + auto isearch = simLinks->find(detId); + if (isearch != simLinks->end()) { + // Loop over DigiSimLink in this det unit + edm::DetSet link_detset = (*isearch); + for (typename edm::DetSet::const_iterator it = link_detset.data.begin(); + it != link_detset.data.end(); ++it) { + if (channel == it->channel()) simTrkId.push_back(std::make_pair(it->SimTrackId(), it->eventId())); + } + } + return simTrkId; +} + +unsigned int VectorHitsBuilderValidation::getSimTrackId(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& pixelSimLinks, const DetId& detId, unsigned int channel) const { + edm::DetSetVector< PixelDigiSimLink >::const_iterator DSViter(pixelSimLinks->find(detId)); + if (DSViter == pixelSimLinks->end()) return 0; + for (edm::DetSet< PixelDigiSimLink >::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { + if (channel == it->channel()) return it->SimTrackId(); + } + return 0; +} + +void VectorHitsBuilderValidation::printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster){ + + if (!geomDetUnit) return; + + const PixelGeomDetUnit* theGeomDet = dynamic_cast< const PixelGeomDetUnit* >(geomDetUnit); + const PixelTopology& topol = theGeomDet->specificTopology(); + + unsigned int layer = getLayerNumber(geomDetUnit->geographicalId()); + unsigned int module = getModuleNumber(geomDetUnit->geographicalId()); + LogTrace("VectorHitsBuilderValidation") << "Layer:" << layer << std::endl; + if(topol.ncolumns() == 32) + LogTrace("VectorHitsBuilderValidation") << "Pixel cluster with detId:" << geomDetUnit->geographicalId().rawId() << "(module:" << module << ") " << std::endl; + else if(topol.ncolumns() == 2 ) + LogTrace("VectorHitsBuilderValidation") << "Strip cluster with detId:" << geomDetUnit->geographicalId().rawId() << "(module:" << module << ") " << std::endl; + else std::cout << "no module?!" << std::endl; + LogTrace("VectorHitsBuilderValidation") << "with pitch:" << topol.pitch().first << " , " << topol.pitch().second << std::endl; + LogTrace("VectorHitsBuilderValidation") << " and width:" << theGeomDet->surface().bounds().width() << " , lenght:" << theGeomDet->surface().bounds().length() << std::endl; + + auto && lparams = cpe->localParameters( *cluster.cluster_phase2OT(), *theGeomDet ); + //Global3DPoint gparams = theGeomDet->surface().toGlobal(lparams.first); + + LogTrace("VectorHitsBuilderValidation") << "\t local pos " << lparams.first << "with err " << lparams.second << std::endl; + + return; +} + +DEFINE_FWK_MODULE(VectorHitsBuilderValidation); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h new file mode 100644 index 0000000000000..ba47ba6b3eb74 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -0,0 +1,144 @@ +#include +#include +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" + +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" +#include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" +#include "DataFormats/SiPixelDigi/interface/PixelDigi.h" +#include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" + +#include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h" +#include "SimDataFormats/Track/interface/SimTrackContainer.h" +#include "SimDataFormats/Vertex/interface/SimVertexContainer.h" +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" + +#include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "CommonTools/Utils/interface/TFileDirectory.h" + +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h" + +#include +#include +#include +#include +#include +#include +#include + +struct VHHistos { + THStack* numberVHsMixed; + TH1F* numberVHsPS; + TH1F* numberVHs2S; + + TGraph* globalPosXY[3]; + TGraph* localPosXY[3]; + + TH1F* deltaXVHSimHits[3]; + TH1F* deltaYVHSimHits[3]; + + TH1F* deltaXVHSimHits_P[3]; + TH1F* deltaYVHSimHits_P[3]; + + TH1F* digiEfficiency[3]; + + TH1F* totalSimHits; + TH1F* primarySimHits; + TH1F* otherSimHits; + + TH1F* curvature; + TH1F* width; + TH1F* deltaXlocal; +}; + +class VectorHitsBuilderValidation : public edm::EDAnalyzer { + + public: + typedef edm::Ref, Phase2TrackerCluster1D > Phase2TrackerCluster1DRef; + + typedef std::map< unsigned int, std::vector< PSimHit > > SimHitsMap; + typedef std::map< unsigned int, SimTrack > SimTracksMap; + + explicit VectorHitsBuilderValidation(const edm::ParameterSet&); + ~VectorHitsBuilderValidation(); + void beginJob(); + void endJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + + private: + + std::map< unsigned int, VHHistos >::iterator createLayerHistograms(unsigned int); + void CreateVHsXYGraph( const std::vector,const std::vector ); + void CreateVHsRZGraph( const std::vector,const std::vector ); + void CreateWindowCorrGraph(); + + unsigned int getLayerNumber(const DetId&); + unsigned int getModuleNumber(const DetId& detid); + void printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster); + + std::pair isTrue(const VectorHit vh, const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& siphase2SimLinks, DetId& detId) const; + std::vector< std::pair > getSimTrackIds(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >&, const DetId&, uint32_t) const; + unsigned int getSimTrackId(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& pixelSimLinks, const DetId& detId, unsigned int channel) const; + + edm::EDGetTokenT< edmNew::DetSetVector > srcClu_; + edm::EDGetTokenT< VectorHitCollectionNew > VHacc_; + edm::EDGetTokenT< VectorHitCollectionNew > VHrej_; + edm::ESInputTag cpeTag_; + const ClusterParameterEstimator* cpe; + + edm::EDGetTokenT< edm::DetSetVector > siphase2OTSimLinksToken_; + edm::EDGetTokenT< edm::PSimHitContainer > simHitsToken_; + edm::EDGetTokenT< edm::SimTrackContainer> simTracksToken_; + edm::EDGetTokenT< edm::SimVertexContainer > simVerticesToken_; + edm::EDGetTokenT trackingParticleToken_; + //SiPixelVectorHitBuilderAlgorithmBase *algo; + + const TrackerGeometry* tkGeom; + const TrackerTopology* tkTopo; + const MagneticField* magField; + + TTree* tree; + TGraph* trackerLayoutRZ_[3]; + TGraph* trackerLayoutXY_[3]; + TGraph* trackerLayoutXYBar_; + TGraph* trackerLayoutXYEC_; + TGraph* localPosXvsDeltaX_[3]; + TGraph* localPosYvsDeltaY_[3]; + TCanvas* VHXY_; + TCanvas* VHRZ_; + std::vector arrowVHs; + + TH2D* ParallaxCorrectionRZ_; + TH1F* VHaccLayer_; + TH1F* VHrejLayer_; + TH1F* VHaccTrueLayer_; + TH1F* VHrejTrueLayer_; + TH1F* VHaccTrue_signal_Layer_; + TH1F* VHrejTrue_signal_Layer_; + TH1F* VHaccTrueLayer_ratio; + TH1F* VHrejTrueLayer_ratio; + + std::map< unsigned int, VHHistos > histograms_; + +}; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/step3_SeedingOT_tilted.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/step3_SeedingOT_tilted.py new file mode 100644 index 0000000000000..d91869a0a3f97 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/step3_SeedingOT_tilted.py @@ -0,0 +1,117 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('RECO',eras.Phase2C2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D4Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +#adding only recolocalreco +process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') + +# import VectorHitBuilder +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('file:21207_10events/step2.root'), + #fileNames = cms.untracked.vstring('/store/relval/CMSSW_8_1_0_pre7/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/81X_mcRun2_asymptotic_v0_2023tilted-v1/10000/2E7CB262-1534-E611-BB7A-0CC47A78A496.root'), + secondaryFileNames = cms.untracked.vstring(), + skipEvents = cms.untracked.uint32(0) +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:10'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.RECOSIMoutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-RECO'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + fileName = cms.untracked.string('file:step3_1event.root'), + outputCommands = cms.untracked.vstring( ('keep *') ), + splitLevel = cms.untracked.int32(0) +) + +# Analyzer +process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', + src = cms.string("siPhase2Clusters"), + src2 = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), + links = cms.InputTag("simSiPixelDigis", "Tracker") +) +process.TFileService = cms.Service('TFileService', + fileName = cms.string('file:vh_validation_tilted.root') +) + +from RecoTracker.TkSeedGenerator.SeedingOTEDProducer_cfi import SeedingOTEDProducer as _SeedingOTEDProducer +process.phase2SeedingOTEDProducer = _SeedingOTEDProducer.clone() +process.initialStepSeeds = _SeedingOTEDProducer.clone() + +process.load('RecoLocalTracker.Phase2TrackerRecHits.Phase2StripCPEGeometricESProducer_cfi') + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + + +# debug +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring("debugVH_tilted"), + debugModules = cms.untracked.vstring("*"), + categories = cms.untracked.vstring("VectorHitBuilderEDProducer","VectorHitBuilderAlgorithm","VectorHitsBuilderValidation","CkfPattern"), + debugVH_tilted = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), + DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), + VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), + CkfPattern = cms.untracked.PSet(limit = cms.untracked.int32(-1)), + VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) + ) + ) + + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +process.trackerlocalreco_step = cms.Path(process.trackerlocalreco+process.siPixelClusters+process.siPhase2VectorHits) +process.seedingOT_step = cms.Path(process.MeasurementTrackerEvent+process.offlineBeamSpot+process.phase2SeedingOTEDProducer) +process.analysis_step = cms.Path(process.analysis) +process.RECOSIMoutput_step = cms.EndPath(process.RECOSIMoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.trackerlocalreco_step,process.seedingOT_step,process.RECOSIMoutput_step, process.analysis_step) +#process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.trackerlocalreco_step,process.RECOSIMoutput_step) +#process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.reconstruction_step,process.prevalidation_step,process.validation_step,process.dqmoffline_step,process.FEVTDEBUGHLToutput_step,process.DQMoutput_step) + +# customisation of the process. + + +# End of customisation functions + diff --git a/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc b/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc index e8b4fe68ca477..2a890e3d24a0c 100644 --- a/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc +++ b/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc @@ -11,6 +11,7 @@ #include "DataFormats/TrackerRecHit2D/interface/Phase2TrackerRecHit1D.h" #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h" #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Common/interface/DetSetVector.h" @@ -123,12 +124,39 @@ void SeedClusterRemoverPhase2::process(const TrackingRecHit *hit, float chi2, co OTs[cluster.key()] = false; assert(collectedOuterTrackers_.size() > cluster.key()); - collectedOuterTrackers_[cluster.key()] = true; + collectedOuterTrackers_[cluster.key()]=true; - } else - throw cms::Exception("NOT IMPLEMENTED") - << "I received a hit that was neither SiPixelRecHit nor Phase2TrackerRecHit1D but " << hitType.name() - << " on detid " << detid.rawId() << "\n"; + } else if (hitType == typeid(VectorHit)) { + + if(!doOuterTracker_) return; + + const VectorHit *vhit = static_cast(hit); + LogDebug("SeedClusterRemoverPhase2") << "Plain VectorHit in det " << detid.rawId(); + + //lower cluster + Phase2TrackerRecHit1D::CluRef cluster = vhit->lowerCluster(); + if (cluster.id() != outerTrackerSourceProdID) throw cms::Exception("Inconsistent Data") << + "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id() << + " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n."; + + assert(cluster.id() == outerTrackerSourceProdID); + + OTs[cluster.key()] = false; + assert(collectedOuterTrackers_.size() > cluster.key()); + collectedOuterTrackers_[cluster.key()]=true; + + // upper cluster + cluster = vhit->upperCluster(); + if (cluster.id() != outerTrackerSourceProdID) throw cms::Exception("Inconsistent Data") << + "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id() << + " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n."; + + assert(cluster.id() == outerTrackerSourceProdID); + + OTs[cluster.key()] = false; + assert(collectedOuterTrackers_.size() > cluster.key()); + collectedOuterTrackers_[cluster.key()]=true; + } else throw cms::Exception("NOT IMPLEMENTED") << "I received a hit that was neither SiPixelRecHit nor Phase2TrackerRecHit1D but " << hitType.name() << " on detid " << detid.rawId() << "\n"; } void SeedClusterRemoverPhase2::produce(Event &iEvent, const EventSetup &iSetup) { diff --git a/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc b/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc index a7afaf340eba6..14753707e6e6d 100644 --- a/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc +++ b/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc @@ -18,6 +18,7 @@ #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/TrackerRecHit2D/interface/ClusterRemovalInfo.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "TrackingTools/PatternTools/interface/TrackCollectionTokens.h" @@ -190,6 +191,19 @@ namespace { collectedPixels[cluster.key()] = true; else if (cluster.isPhase2()) collectedPhase2OTs[cluster.key()] = true; + + // Phase 2 OT is defined as Pixel detector (for now) + const auto &hitType = typeid(hit); + if (hitType == typeid(VectorHit)) { + auto const & vectorHit = reinterpret_cast(hit); + auto const & lowCluster = vectorHit.lowerClusterRef(); + auto const & uppCluster = vectorHit.upperClusterRef(); + LogTrace("TrackClusterRemoverPhase2")<<"masking a VHit with lowCluster key: " << lowCluster.key() << " and upper key: " << uppCluster.key(); + if (lowCluster.isPhase2()) collectedPhase2OTs[lowCluster.key()]=true; + if (uppCluster.isPhase2()) collectedPhase2OTs[uppCluster.key()]=true; + } else { + LogTrace("TrackClusterRemoverPhase2")<<"it is not a VHits."; + } } } diff --git a/RecoTracker/CkfPattern/src/PrintoutHelper.cc b/RecoTracker/CkfPattern/src/PrintoutHelper.cc index 807f90e009355..024c28c661d9c 100644 --- a/RecoTracker/CkfPattern/src/PrintoutHelper.cc +++ b/RecoTracker/CkfPattern/src/PrintoutHelper.cc @@ -101,6 +101,14 @@ std::string PrintoutHelper::regressionTest(const TrackerGeometry& tracker, std:: } else buffer << "candidate with invalid last measurement state!" << std::endl; } - buffer << "================================================="; + buffer<<"================================================="; + buffer<<"=========== Traj in details =====================\n"; + for (std::vector::const_iterator it = unsmoothedResult.begin(); + it != unsmoothedResult.end(); it++) { + for(auto hit : it->measurements()){ + buffer<< "measurement : " << hit.recHit()->geographicalId().rawId() << std::endl; + } + buffer<<"================\n"; + } return buffer.str(); } diff --git a/RecoTracker/FinalTrackSelectors/plugins/DuplicateTrackMerger.cc b/RecoTracker/FinalTrackSelectors/plugins/DuplicateTrackMerger.cc index 0bd101844174c..3a20b4671a9ad 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/DuplicateTrackMerger.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/DuplicateTrackMerger.cc @@ -488,6 +488,16 @@ namespace { gbrVals_[7] = tmva_outer_nMissingInner_; gbrVals_[8] = tmva_inner_nMissingOuter_; + IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_ddsz_ : gbrVals_[0] " << gbrVals_[0]; + IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_ddxy_ : gbrVals_[1] " << gbrVals_[1]; + IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_dphi_ : gbrVals_[2] " << gbrVals_[2]; + IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_dlambda_ : gbrVals_[3] " << gbrVals_[3]; + IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_dqoverp_ : gbrVals_[4] " << gbrVals_[4]; + IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_d3dr_ : gbrVals_[5] " << gbrVals_[5]; + IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_d3dz_ : gbrVals_[6] " << gbrVals_[6]; + IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_outer_nMissingInner_ : gbrVals_[7] " << gbrVals_[7]; + IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_inner_nMissingOuter_ : gbrVals_[8] " << gbrVals_[8]; + auto mvaBDTG = forest_->GetClassifier(gbrVals_); IfLogTrace(debug_, "DuplicateTrackMerger") << " mvaBDTG " << mvaBDTG; if (mvaBDTG < minBDTG_) diff --git a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc index ee6462380a982..d014f2be7d47e 100644 --- a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc +++ b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc @@ -28,11 +28,14 @@ class TrackerRecoGeometryESProducer : public edm::ESProducer { private: edm::ESGetToken geomToken_; edm::ESGetToken tTopToken_; + bool _usePhase2Stacks; }; using namespace edm; -TrackerRecoGeometryESProducer::TrackerRecoGeometryESProducer(const edm::ParameterSet &p) { +TrackerRecoGeometryESProducer::TrackerRecoGeometryESProducer(const edm::ParameterSet &p) + : _usePhase2Stacks(p.getParameter("usePhase2Stacks")) +{ auto c = setWhatProduced(this); // 08-Oct-2007 - Patrick Janot @@ -44,18 +47,18 @@ TrackerRecoGeometryESProducer::TrackerRecoGeometryESProducer(const edm::Paramete tTopToken_ = c.consumes(); geomToken_ = c.consumes(edm::ESInputTag("", p.getUntrackedParameter("trackerGeometryLabel"))); } - std::unique_ptr TrackerRecoGeometryESProducer::produce( const TrackerRecoGeometryRecord &iRecord) { TrackerGeometry const &tG = iRecord.get(geomToken_); GeometricSearchTrackerBuilder builder; - return std::unique_ptr(builder.build(tG.trackerDet(), &tG, &iRecord.get(tTopToken_))); + return std::unique_ptr(builder.build(tG.trackerDet(), &tG, &iRecord.get(tTopToken_), _usePhase2Stacks)); } void TrackerRecoGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; + desc.add("usePhase2Stacks"); desc.addUntracked("trackerGeometryLabel", ""); descriptions.addDefault(desc); } diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index fb33c1fff2fc2..22d95e29034d3 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,5 +1,9 @@ import FWCore.ParameterSet.Config as cms -TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer") +TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", + usePhase2Stacks = cms.bool(False) +) +from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) diff --git a/RecoTracker/MeasurementDet/BuildFile.xml b/RecoTracker/MeasurementDet/BuildFile.xml index 5ed4491d1708d..2790eaf681a10 100644 --- a/RecoTracker/MeasurementDet/BuildFile.xml +++ b/RecoTracker/MeasurementDet/BuildFile.xml @@ -22,3 +22,4 @@ + diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc index 9087a115fa534..51e57e85f7075 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc @@ -10,12 +10,14 @@ #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h" #include "RecoTracker/Record/interface/CkfComponentsRecord.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" #include "RecoLocalTracker/Records/interface/TrackerCPERecord.h" +#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" @@ -54,6 +56,7 @@ class dso_hidden MeasurementTrackerESProducer : public edm::ESProducer { edm::ESGetToken trackerGeomToken_; edm::ESGetToken geometricSearchTrackerToken_; edm::ESGetToken, TkPhase2OTCPERecord> phase2TrackerCPEToken_; + edm::ESGetToken phase2matcherToken_; MeasurementTrackerImpl::BadStripCutsDet badStripCuts_; @@ -155,9 +158,11 @@ MeasurementTrackerESProducer::MeasurementTrackerESProducer(const edm::ParameterS //FIXME:: just temporary solution for phase2! auto phase2 = p.getParameter("Phase2StripCPE"); + auto phase2Matcher = p.getParameter("Phase2HitMatcher"); if (not phase2.empty()) { usePhase2_ = true; phase2TrackerCPEToken_ = c.consumes(edm::ESInputTag("", phase2)); + phase2matcherToken_ = c.consumes(edm::ESInputTag("", phase2Matcher)); } } @@ -180,13 +185,16 @@ std::unique_ptr MeasurementTrackerESProducer::produce(const } const ClusterParameterEstimator *ptr_phase2TrackerCPE = nullptr; + const VectorHitBuilderEDProducer *ptr_phase2Matcher = nullptr; if (usePhase2_) { ptr_phase2TrackerCPE = &iRecord.get(phase2TrackerCPEToken_); + ptr_phase2Matcher = &iRecord.get(phase2matcherToken_); } return std::make_unique(badStripCuts_, &iRecord.get(pixelCPEToken_), &iRecord.get(stripCPEToken_), &iRecord.get(hitMatcherToken_), + ptr_phase2Matcher, &iRecord.get(trackerTopologyToken_), &iRecord.get(trackerGeomToken_), &iRecord.get(geometricSearchTrackerToken_), @@ -210,6 +218,7 @@ void MeasurementTrackerESProducer::fillDescriptions(edm::ConfigurationDescriptio desc.add("HitMatcher", "StandardMatcher"); desc.add("Phase2StripCPE", "")->setComment("empty string used to turn off Phase 2"); + desc.add("Phase2HitMatcher", ""); desc.add("SiStripQualityLabel", ""); desc.add("UseStripModuleQualityDB", true); diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc index d8a3b89ae5c97..efdcf7a2e0cde 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc @@ -350,6 +350,9 @@ void MeasurementTrackerEventProducer::updateStrips(const edm::Event& event, //FIXME: just a temporary solution for phase2! void MeasurementTrackerEventProducer::updatePhase2OT(const edm::Event& event, Phase2OTMeasurementDetSet& thePh2OTDets) const { + + thePh2OTDets.setEmpty(); + // Phase2OT Clusters if (isPhase2) { if (thePh2OTClusterLabel.isUninitialized()) { //clusters have not been produced diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index bd7c54e22fa4f..d606cbf28c264 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -77,6 +77,7 @@ MeasurementTrackerImpl::MeasurementTrackerImpl(const BadStripCutsDet& badStripCu const PixelClusterParameterEstimator* pixelCPE, const StripClusterParameterEstimator* stripCPE, const SiStripRecHitMatcher* hitMatcher, + const VectorHitBuilderEDProducer* ph2hitMatcher, const TrackerTopology* trackerTopology, const TrackerGeometry* trackerGeom, const GeometricSearchTracker* geometricSearchTracker, @@ -91,7 +92,7 @@ MeasurementTrackerImpl::MeasurementTrackerImpl(const BadStripCutsDet& badStripCu : MeasurementTracker(trackerGeom, geometricSearchTracker), theStDetConditions(hitMatcher, stripCPE), thePxDetConditions(pixelCPE), - thePhase2DetConditions(phase2OTCPE) { + thePhase2DetConditions(ph2hitMatcher, phase2OTCPE) { this->initialize(trackerTopology); this->initializeStripStatus(badStripCuts, stripQuality, stripQualityFlags, stripQualityDebugFlags); this->initializePixelStatus(pixelQuality, pixelCabling, pixelQualityFlags, pixelQualityDebugFlags); @@ -284,7 +285,7 @@ void MeasurementTrackerImpl::addGluedDet(const GluedGeomDet* gd) { void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd) { //since the Stack will be composed by PS or 2S, //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. - theStackDets.push_back(TkStackMeasurementDet(gd, thePxDetConditions.pixelCPE())); + theStackDets.push_back(TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE() )); } void MeasurementTrackerImpl::initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology) { diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h index 7794f31e5fe94..fd979dbf58005 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h @@ -56,6 +56,7 @@ class dso_hidden MeasurementTrackerImpl final : public MeasurementTracker { const PixelClusterParameterEstimator* pixelCPE, const StripClusterParameterEstimator* stripCPE, const SiStripRecHitMatcher* hitMatcher, + const VectorHitBuilderEDProducer* ph2hitMatcher, const TrackerTopology* trackerTopology, const TrackerGeometry* trackerGeom, const GeometricSearchTracker* geometricSearchTracker, diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index aab7c42efca4c..5fce1d99addba 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -1,17 +1,24 @@ #include "TkStackMeasurementDet.h" #include "TrackingTools/MeasurementDet/interface/MeasurementDetException.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h" using namespace std; -TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet, const PixelClusterParameterEstimator* cpe) - : MeasurementDet(gdet), thePixelCPE(cpe), theInnerDet(nullptr), theOuterDet(nullptr) {} +TkStackMeasurementDet::TkStackMeasurementDet( const StackGeomDet* gdet, + const VectorHitBuilderEDProducer* matcher, + const PixelClusterParameterEstimator* cpe) : + MeasurementDet(gdet), + theMatcher(matcher), + thePixelCPE(cpe), + theLowerDet(nullptr), theUpperDet(nullptr) +{} void TkStackMeasurementDet::init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet) { - theInnerDet = dynamic_cast(lowerDet); - theOuterDet = dynamic_cast(upperDet); + theLowerDet = dynamic_cast(lowerDet); + theUpperDet = dynamic_cast(upperDet); - if ((theInnerDet == nullptr) || (theOuterDet == nullptr)) { + if ((theLowerDet == nullptr) || (theUpperDet == nullptr)) { throw MeasurementDetException( "TkStackMeasurementDet ERROR: Trying to glue a det which is not a TkPhase2OTMeasurementDet"); } @@ -24,12 +31,91 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj HitCollectorForRecHits collector( &fastGeomDet(), theMatcher, theCPE, result ); collectRecHits(ts, collector); */ + if ( isEmpty(data.phase2OTData())== true ) return result; + LogTrace("MeasurementTracker")<<" is not empty"; + if (isActive(data) == false) return result; + LogTrace("MeasurementTracker")<<" and is active"; + + + const Phase2TrackerCluster1D* begin=0; + if (0 != data.phase2OTData().handle()->data().size()) { + begin = &(data.phase2OTData().handle()->data().front()); + } + + VectorHitBuilderAlgorithmBase * algo = theMatcher->algo() ; + //VectorHitBuilderAlgorithm* vhalgo = dynamic_cast(algobase); + LogTrace("MeasurementTracker") << "TkStackMeasurementDet::recHits algo has been set" << std::endl; + + const detset & lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); + const detset & upperDetSet = data.phase2OTData().detSet(upperDet()->index()); + + LogTrace("MeasurementTracker")<<" DetSets set with sizes:" << lowerDetSet.size() << " and " << upperDetSet.size() << "!"; + result.reserve(lowerDetSet.size()>upperDetSet.size() ? lowerDetSet.size() : upperDetSet.size()); + + + for ( const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++ cil ) { + + if (cil < begin){ + edm::LogError("IndexMisMatch")<<"TkStackMeasurementDet cannot create hit because of index mismatch."; + return result; + } + unsigned int indexl = cil-begin; + LogTrace("MeasurementTracker")<<" index cluster lower" << indexl << " on detId " << fastGeomDet().geographicalId().rawId(); + + for ( const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ ciu ) { + + unsigned int indexu = ciu-begin; + if (ciu < begin){ + edm::LogError("IndexMisMatch")<<"TkStackMeasurementDet cannot create hit because of index mismatch."; + return result; + } + LogTrace("VectorHitBuilderAlgorithm")<<" index cluster upper " << indexu; + + if(data.phase2OTClustersToSkip().empty() or ((not data.phase2OTClustersToSkip()[indexl]) and (not data.phase2OTClustersToSkip()[indexu])) ) { + Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo( data.phase2OTData().handle(), cil ); + Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo( data.phase2OTData().handle(), ciu ); + //ERICA:I would have prefer to keep buildVectorHits ... + VectorHit vh = algo->buildVectorHit( &specificGeomDet(), clusterLower, clusterUpper); + LogTrace("MeasurementTracker") << "TkStackMeasurementDet::rechits adding VectorHits!" << std::endl; + LogTrace("MeasurementTracker") << vh << std::endl; + result.push_back( std::make_shared( vh )); + } + } + + } + return result; } -bool TkStackMeasurementDet::measurements(const TrajectoryStateOnSurface& stateOnThisDet, - const MeasurementEstimator& est, - const MeasurementTrackerEvent& data, - TempMeasurements& result) const { - return true; + + +bool TkStackMeasurementDet::measurements( const TrajectoryStateOnSurface& stateOnThisDet, + const MeasurementEstimator& est, const MeasurementTrackerEvent & data, + TempMeasurements & result) const { + LogDebug("MeasurementTracker")<<"TkStackMeasurementDet::measurements"; + + if (!isActive(data)) { + result.add(theInactiveHit, 0.F); + return true; + } + + LogTrace("MeasurementTracker")<<" is active"; + + auto oldSize = result.size(); + MeasurementDet::RecHitContainer && allHits = recHits(stateOnThisDet, data); + + for (auto && hit : allHits) { + std::pair diffEst = est.estimate( stateOnThisDet, *hit); + //LogTrace("MeasurementTracker")<< "State on this Det: " << stateOnThisDet ; + LogDebug("MeasurementTracker")<< "New vh added with chi2: " << diffEst.second ; + if ( diffEst.first) + result.add(std::move(hit), diffEst.second); + } + + if (result.size()>oldSize) return true; + + // create a TrajectoryMeasurement with an invalid RecHit and zero estimate + result.add(theMissingHit, 0.F); + LogDebug("MeasurementTracker")<< "adding missing hit"; + return false; } diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index 91129ab61732c..9d6722e3e464f 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -5,6 +5,7 @@ #include "TkPhase2OTMeasurementDet.h" #include "Geometry/CommonDetUnit/interface/StackGeomDet.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include "FWCore/Utilities/interface/Visibility.h" @@ -13,25 +14,31 @@ class TkStackMeasurementDet final : public MeasurementDet { public: - TkStackMeasurementDet(const StackGeomDet* gdet, const PixelClusterParameterEstimator* cpe); + TkStackMeasurementDet(const StackGeomDet* gdet, const VectorHitBuilderEDProducer* matcher, const PixelClusterParameterEstimator* cpe); void init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet); RecHitContainer recHits(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent& data) const override; const StackGeomDet& specificGeomDet() const { return static_cast(fastGeomDet()); } + typedef edm::Ref, Phase2TrackerCluster1D> Phase2TrackerCluster1DRef; + + typedef edmNew::DetSet detset; + typedef detset::const_iterator const_iterator; bool measurements(const TrajectoryStateOnSurface& stateOnThisDet, const MeasurementEstimator& est, const MeasurementTrackerEvent& data, TempMeasurements& result) const override; - const TkPhase2OTMeasurementDet* lowerDet() const { return theInnerDet; } - const TkPhase2OTMeasurementDet* upperDet() const { return theOuterDet; } + const TkPhase2OTMeasurementDet* lowerDet() const { return theLowerDet; } + const TkPhase2OTMeasurementDet* upperDet() const { return theUpperDet; } + /// return TRUE if both lower and upper components are active bool isActive(const MeasurementTrackerEvent& data) const override { return lowerDet()->isActive(data) && upperDet()->isActive(data); } + bool isEmpty(const Phase2OTMeasurementDetSet & data) const {return data.empty(lowerDet()->index()) || data.empty(upperDet()->index());} /// return TRUE if at least one of the lower and upper components has badChannels bool hasBadComponents(const TrajectoryStateOnSurface& tsos, const MeasurementTrackerEvent& data) const override { @@ -39,9 +46,10 @@ class TkStackMeasurementDet final : public MeasurementDet { } private: + const VectorHitBuilderEDProducer* theMatcher; const PixelClusterParameterEstimator* thePixelCPE; - const TkPhase2OTMeasurementDet* theInnerDet; - const TkPhase2OTMeasurementDet* theOuterDet; + const TkPhase2OTMeasurementDet* theLowerDet; + const TkPhase2OTMeasurementDet* theUpperDet; }; #endif diff --git a/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py b/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py index d5b0dcefdc434..ca5973895e619 100644 --- a/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py +++ b/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py @@ -6,3 +6,4 @@ from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 trackingPhase2PU140.toModify(MeasurementTracker, Phase2StripCPE = 'Phase2StripCPE') +trackingPhase2PU140.toModify(MeasurementTracker, Phase2HitMatcher = 'SiPhase2VectorHitMatcher') diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc index f1dab6b903eff..8c6b86fa37d87 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc @@ -42,4 +42,5 @@ void PxMeasurementConditionSet::init(int size) { void Phase2OTMeasurementConditionSet::init(int size) { activeThisPeriod_.resize(size, true); id_.resize(size); + matcher()->algo()->initCpe(cpe()); } diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h index 6c5f3f89c317a..ccdf22fe6302f 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h @@ -6,6 +6,7 @@ class TkStripMeasurementDet; class TkStripMeasurementDet; class TkPixelMeasurementDet; class SiStripRecHitMatcher; +//class VectorHitBuilderEDProducer; class StripClusterParameterEstimator; class PixelClusterParameterEstimator; class Phase2StripCPE; @@ -20,6 +21,9 @@ class Phase2StripCPE; #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h" #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" + #include // #define VISTAT @@ -404,7 +408,8 @@ class PxMeasurementDetSet { //FIXME:just temporary solution for phase2 OT that works! class Phase2OTMeasurementConditionSet { public: - Phase2OTMeasurementConditionSet(const ClusterParameterEstimator* cpe) : theCPE(cpe) {} + Phase2OTMeasurementConditionSet(const VectorHitBuilderEDProducer* ph2matcher, const ClusterParameterEstimator *cpe) : + thePhase2Matcher(ph2matcher), theCPE(cpe) {} void init(int size); @@ -413,6 +418,7 @@ class Phase2OTMeasurementConditionSet { int find(unsigned int jd, int i = 0) const { return std::lower_bound(id_.begin() + i, id_.end(), jd) - id_.begin(); } const ClusterParameterEstimator* cpe() const { return theCPE; } + const VectorHitBuilderEDProducer* matcher() const { return thePhase2Matcher;} bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; } /** \brief Turn on/off the module for reconstruction, for the full run or lumi (using info from DB, usually). @@ -423,8 +429,9 @@ class Phase2OTMeasurementConditionSet { friend class MeasurementTrackerImpl; // Globals (not-per-event) + const VectorHitBuilderEDProducer* thePhase2Matcher; const ClusterParameterEstimator* theCPE; - + // Locals, per-event std::vector id_; std::vector activeThisPeriod_; diff --git a/RecoTracker/Record/interface/CkfComponentsRecord.h b/RecoTracker/Record/interface/CkfComponentsRecord.h index f6d513f77645f..6d64c5709ced9 100644 --- a/RecoTracker/Record/interface/CkfComponentsRecord.h +++ b/RecoTracker/Record/interface/CkfComponentsRecord.h @@ -39,3 +39,4 @@ class CkfComponentsRecord SiPixelLorentzAngleRcd, SiStripLorentzAngleDepRcd> > {}; #endif + diff --git a/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h b/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h index abe2be323bde5..834ae11b28432 100644 --- a/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h +++ b/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h @@ -17,8 +17,9 @@ class GeometricSearchTrackerBuilder { ~GeometricSearchTrackerBuilder() {} GeometricSearchTracker* build(const GeometricDet* theGeometricTracker, - const TrackerGeometry* theGeomDetGeometry, - const TrackerTopology* tTopo) __attribute__((cold)); + const TrackerGeometry* theGeomDetGeometry, + const TrackerTopology* tTopo, + const bool usePhase2Stacks = false) __attribute__ ((cold)); }; #endif diff --git a/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc b/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc index 9be742143e173..4ed5853b6b67f 100644 --- a/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc +++ b/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc @@ -19,9 +19,14 @@ using namespace std; -GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* theGeometricTracker, - const TrackerGeometry* theGeomDetGeometry, - const TrackerTopology* tTopo) { + +GeometricSearchTracker* +GeometricSearchTrackerBuilder::build(const GeometricDet* theGeometricTracker, + const TrackerGeometry* theGeomDetGeometry, + const TrackerTopology* tTopo, + const bool usePhase2Stacks) +{ + PixelBarrelLayerBuilder aPixelBarrelLayerBuilder; Phase2OTBarrelLayerBuilder aPhase2OTBarrelLayerBuilder; PixelForwardLayerBuilder aPixelForwardLayerBuilder; @@ -41,6 +46,7 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* vector thePosTIDLayers; vector theNegTECLayers; vector thePosTECLayers; + bool useBrothers = !usePhase2Stacks; vector theGeometricDetLayers = theGeometricTracker->components(); for (vector::const_iterator it = theGeometricDetLayers.begin(); @@ -93,10 +99,10 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* if ((*it)->type() == GeometricDet::OTPhase2Barrel) { vector theTOBGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = theTOBGeometricDetLayers.begin(); - it2 != theTOBGeometricDetLayers.end(); - it2++) { - theTOBLayers.push_back(aPhase2OTBarrelLayerBuilder.build(*it2, theGeomDetGeometry)); + + for(vector::const_iterator it2=theTOBGeometricDetLayers.begin(); + it2!=theTOBGeometricDetLayers.end(); it2++){ + theTOBLayers.push_back( aPhase2OTBarrelLayerBuilder.build(*it2,theGeomDetGeometry,useBrothers) ); } } @@ -164,13 +170,14 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* if ((*it)->type() == GeometricDet::OTPhase2EndCap) { vector theTIDGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = theTIDGeometricDetLayers.begin(); - it2 != theTIDGeometricDetLayers.end(); - it2++) { - if ((*it2)->positionBounds().z() < 0) - theNegTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(*it2, theGeomDetGeometry, true)); - if ((*it2)->positionBounds().z() > 0) - thePosTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(*it2, theGeomDetGeometry, true)); + + bool useBrothers = !usePhase2Stacks; + for(vector::const_iterator it2=theTIDGeometricDetLayers.begin(); + it2!=theTIDGeometricDetLayers.end(); it2++){ + if((*it2)->positionBounds().z() < 0) + theNegTIDLayers.push_back( aPhase2EndcapLayerBuilder.build(*it2,theGeomDetGeometry,useBrothers) ); + if((*it2)->positionBounds().z() > 0) + thePosTIDLayers.push_back( aPhase2EndcapLayerBuilder.build(*it2,theGeomDetGeometry,useBrothers) ); } } diff --git a/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.cc index dd794dcab9b87..64be320013f11 100644 --- a/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.cc @@ -5,8 +5,9 @@ using namespace edm; using namespace std; Phase2EndcapLayer* Phase2EndcapLayerBuilder::build(const GeometricDet* aPhase2EndcapLayer, - const TrackerGeometry* theGeomDetGeometry, - const bool isOuterTracker) { + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) +{ LogTrace("TkDetLayers") << "Phase2EndcapLayerBuilder::build"; vector theGeometricRings = aPhase2EndcapLayer->components(); LogTrace("TkDetLayers") << "theGeometricRings.size(): " << theGeometricRings.size(); @@ -14,12 +15,12 @@ Phase2EndcapLayer* Phase2EndcapLayerBuilder::build(const GeometricDet* aPhase2En Phase2EndcapRingBuilder myBuilder; vector thePhase2EndcapRings; - for (vector::const_iterator it = theGeometricRings.begin(); it != theGeometricRings.end(); - it++) { - // if we are in the phaseII OT, it will use the brothers to build pt modules - // if we are in the phaseII pixel detector, it will not - thePhase2EndcapRings.push_back(myBuilder.build(*it, theGeomDetGeometry, isOuterTracker)); + for(vector::const_iterator it=theGeometricRings.begin(); + it!=theGeometricRings.end();it++){ + // if we are in the phaseII OT, it will use the brothers to build pt modules + // if we are in the phaseII pixel detector, it will not + thePhase2EndcapRings.push_back(myBuilder.build( *it,theGeomDetGeometry,useBrothers )); } - return new Phase2EndcapLayer(thePhase2EndcapRings, isOuterTracker); + return new Phase2EndcapLayer(thePhase2EndcapRings,useBrothers); } diff --git a/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.h b/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.h index 5a61c12b4dabe..f695b399f2125 100644 --- a/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.h +++ b/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.h @@ -15,8 +15,8 @@ class Phase2EndcapLayerBuilder { public: Phase2EndcapLayerBuilder(){}; Phase2EndcapLayer* build(const GeometricDet* aPhase2EndcapLayer, - const TrackerGeometry* theGeomDetGeometry, - const bool isOuterTracker) __attribute__((cold)); + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) __attribute__ ((cold)); }; #pragma GCC visibility pop diff --git a/RecoTracker/TkDetLayers/src/Phase2EndcapRingBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2EndcapRingBuilder.cc index 2df7298f9ad94..69bfe5c15ebc9 100644 --- a/RecoTracker/TkDetLayers/src/Phase2EndcapRingBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2EndcapRingBuilder.cc @@ -6,10 +6,11 @@ using namespace edm; using namespace std; Phase2EndcapRing* Phase2EndcapRingBuilder::build(const GeometricDet* aPhase2EndcapRing, - const TrackerGeometry* theGeomDetGeometry, - const bool useBrothers) { - vector allGeometricDets = aPhase2EndcapRing->components(); - vector compGeometricDets; + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) +{ + vector allGeometricDets = aPhase2EndcapRing->components(); + vector compGeometricDets; LogDebug("TkDetLayers") << "Phase2EndcapRingBuilder with #Modules: " << allGeometricDets.size() << std::endl; vector frontGeomDets; diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.cc index b950df541c2b9..66304a77d886b 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.cc @@ -7,8 +7,10 @@ using namespace std; using namespace edm; Phase2OTBarrelLayer* Phase2OTBarrelLayerBuilder::build(const GeometricDet* aPhase2OTBarrelLayer, - const TrackerGeometry* theGeomDetGeometry) { - // This builder is very similar to TOBLayer one. Most of the code should be put in a + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) +{ + // This builder is very similar to TOBLayer one. Most of the code should be put in a // common place. LogTrace("TkDetLayers") << "Phase2OTBarrelLayerBuilder::build"; @@ -40,14 +42,18 @@ Phase2OTBarrelLayer* Phase2OTBarrelLayerBuilder::build(const GeometricDet* aPhas for (unsigned int index = 0; index != theGeometricDetRods.size(); index++) meanR += theGeometricDetRods[index]->positionBounds().perp(); if (!theGeometricDetRods.empty()) - meanR /= (double)theGeometricDetRods.size(); - for (unsigned int index = 0; index != theGeometricDetRods.size(); index++) { - if (theGeometricDetRods[index]->positionBounds().perp() < meanR) - theInnerRods.push_back(myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], theGeomDetGeometry)); + meanR/=(double) theGeometricDetRods.size(); + + for(unsigned int index=0; index!=theGeometricDetRods.size(); index++){ + if(theGeometricDetRods[index]->positionBounds().perp() < meanR) + theInnerRods.push_back(myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], + theGeomDetGeometry, useBrothers) ); + + if(theGeometricDetRods[index]->positionBounds().perp() > meanR) + theOuterRods.push_back(myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], + theGeomDetGeometry, useBrothers) ); - if (theGeometricDetRods[index]->positionBounds().perp() > meanR) - theOuterRods.push_back(myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], theGeomDetGeometry)); } if (theGeometricDetRings.empty()) @@ -63,12 +69,13 @@ Phase2OTBarrelLayer* Phase2OTBarrelLayerBuilder::build(const GeometricDet* aPhas // properly calculate the meanR value to separate rod in inner/outer. double centralZ = 0.0; - for (vector::const_iterator it = theGeometricDetRings.begin(); it != theGeometricDetRings.end(); - it++) { - if ((*it)->positionBounds().z() < centralZ) - theNegativeRings.push_back(myPhase2EndcapRingBuilder.build(*it, theGeomDetGeometry, true)); - if ((*it)->positionBounds().z() > centralZ) - thePositiveRings.push_back(myPhase2EndcapRingBuilder.build(*it, theGeomDetGeometry, true)); + + for(vector::const_iterator it=theGeometricDetRings.begin(); + it!=theGeometricDetRings.end();it++){ + if((*it)->positionBounds().z() < centralZ) + theNegativeRings.push_back(myPhase2EndcapRingBuilder.build( *it,theGeomDetGeometry,useBrothers )); + if((*it)->positionBounds().z() > centralZ) + thePositiveRings.push_back(myPhase2EndcapRingBuilder.build( *it,theGeomDetGeometry,useBrothers )); } return new Phase2OTtiltedBarrelLayer(theInnerRods, theOuterRods, theNegativeRings, thePositiveRings); diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.h b/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.h index aa1ebc03af197..93a57436d3977 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.h +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.h @@ -14,8 +14,11 @@ class Phase2OTBarrelLayerBuilder { public: Phase2OTBarrelLayerBuilder(){}; - Phase2OTBarrelLayer* build(const GeometricDet* aPhase2OTBarrelLayer, const TrackerGeometry* theGeomDetGeometry) - __attribute__((cold)); + Phase2OTBarrelLayer* build(const GeometricDet* aPhase2OTBarrelLayer, + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers = true) __attribute__ ((cold)); + + }; #pragma GCC visibility pop diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.cc index ba4a1bf7f5de2..0e377521e329e 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.cc @@ -26,8 +26,8 @@ namespace { Phase2OTBarrelRod::Phase2OTBarrelRod(vector& innerDets, vector& outerDets, - vector& innerDetBrothers, - vector& outerDetBrothers) + const vector& innerDetBrothers, + const vector& outerDetBrothers) : DetRod(true), theInnerDets(innerDets), theOuterDets(outerDets), @@ -61,6 +61,8 @@ Phase2OTBarrelRod::Phase2OTBarrelRod(vector& innerDets, << " , " << (**i).position().perp() << " , " << (**i).position().eta() << " , " << (**i).position().phi(); } + if(theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) LogDebug("TkDetLayers") << "==== with stacks =====" ; + if(!theInnerDetBrothers.empty() && !theOuterDetBrothers.empty()) LogDebug("TkDetLayers") << "==== without stacks =====" ; for (vector::const_iterator i = theOuterDets.begin(); i != theOuterDets.end(); i++) { LogDebug("TkDetLayers") << "outer Phase2OTBarrelRod's Det pos z,perp,eta,phi: " << (**i).position().z() << " , " @@ -198,6 +200,8 @@ bool Phase2OTBarrelRod::addClosest(const TrajectoryStateOnSurface& tsos, vector& brotherresult) const { const vector& sRod(subRod(crossing.subLayerIndex())); bool firstgroup = CompatibleDetToGroupAdder::add(*sRod[crossing.closestDetIndex()], tsos, prop, est, result); + if(theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) return firstgroup; + // it assumes that the closestDetIndex is ok also for the brother detectors: the crossing is NOT recomputed const vector& sRodBrothers(subRodBrothers(crossing.subLayerIndex())); bool brothergroup = @@ -268,6 +272,7 @@ void Phase2OTBarrelRod::searchNeighbors(const TrajectoryStateOnSurface& tsos, break; if (!Adder::add(*sRod[idet], tsos, prop, est, result)) break; + if(theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) break; // If the two above checks are passed also the brother module will be added with no further checks Adder::add(*sBrotherRod[idet], tsos, prop, est, brotherresult); } @@ -276,6 +281,7 @@ void Phase2OTBarrelRod::searchNeighbors(const TrajectoryStateOnSurface& tsos, break; if (!Adder::add(*sRod[idet], tsos, prop, est, result)) break; + if(theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) break; // If the two above checks are passed also the brother module will be added with no further checks Adder::add(*sBrotherRod[idet], tsos, prop, est, brotherresult); } diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.h b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.h index 3e0b77fcd3ea4..85e97a5a05cee 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.h +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.h @@ -17,8 +17,8 @@ class Phase2OTBarrelRod final : public DetRod { Phase2OTBarrelRod(std::vector& innerDets, std::vector& outerDets, - std::vector& innerDetBrothers, - std::vector& outerDetBrothers) __attribute__((cold)); + const std::vector& innerDetBrothers = std::vector(), + const std::vector& outerDetBrothers = std::vector()) __attribute__((cold)); ~Phase2OTBarrelRod() override __attribute__((cold)); // GeometricSearchDet interface diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc index 786ffc5cd67a7..0719e5980555b 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc @@ -5,10 +5,13 @@ using namespace edm; using namespace std; Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2OTBarrelRod, - const TrackerGeometry* theGeomDetGeometry) { + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) +{ vector allGeometricDets = thePhase2OTBarrelRod->components(); - vector compGeometricDets; +// vector compGeometricDets; LogDebug("TkDetLayers") << "Phase2OTBarrelRodBuilder with #Modules: " << allGeometricDets.size() << std::endl; + LogDebug("TkDetLayers") << " useBrothers: " << useBrothers << std::endl; vector innerGeomDets; vector outerGeomDets; @@ -16,47 +19,83 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 vector outerGeomDetBrothers; double meanR = 0; - double meanRBrothers = 0; - for (vector::const_iterator it = allGeometricDets.begin(); it != allGeometricDets.end(); it++) { - compGeometricDets = (*it)->components(); - if (compGeometricDets.size() != 2) { - LogDebug("TkDetLayers") << " Stack not with two components but with " << compGeometricDets.size() << std::endl; - } else { - //LogTrace("TkDetLayers") << " compGeometricDets[0]->positionBounds().perp() " << compGeometricDets[0]->positionBounds().perp() << std::endl; - //LogTrace("TkDetLayers") << " compGeometricDets[1]->positionBounds().perp() " << compGeometricDets[1]->positionBounds().perp() << std::endl; - meanR = meanR + compGeometricDets[0]->positionBounds().perp(); - meanRBrothers = meanRBrothers + compGeometricDets[1]->positionBounds().perp(); - } - } - meanR = meanR / allGeometricDets.size(); - meanRBrothers = meanRBrothers / allGeometricDets.size(); - LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl; - LogDebug("TkDetLayers") << " meanR Upper " << meanRBrothers << std::endl; - - for (vector::iterator it = allGeometricDets.begin(); it != allGeometricDets.end(); it++) { - compGeometricDets = (*it)->components(); - const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets[0]->geographicalId()); - LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[0]->geographicalId().rawId() << std::endl; - - if (compGeometricDets[0]->positionBounds().perp() < meanR) - innerGeomDets.push_back(theGeomDet); - - if (compGeometricDets[0]->positionBounds().perp() > meanR) - outerGeomDets.push_back(theGeomDet); - const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet(compGeometricDets[1]->geographicalId()); - LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[1]->geographicalId().rawId() << std::endl; - if (compGeometricDets[1]->positionBounds().perp() < meanRBrothers) - innerGeomDetBrothers.push_back(theGeomDetBrother); + if(!useBrothers){ + + for(vector::const_iterator compGeometricDets=allGeometricDets.begin(); compGeometricDets!=allGeometricDets.end();compGeometricDets++){ + //LogTrace("TkDetLayers") << " compGeometricDets.positionBounds().perp() " << (*compGeometricDets)->positionBounds().perp() << std::endl; + meanR = meanR + (*compGeometricDets)->positionBounds().perp(); + } + meanR = meanR/allGeometricDets.size(); + LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl; + + for(vector::const_iterator compGeometricDets=allGeometricDets.begin(); compGeometricDets!=allGeometricDets.end(); compGeometricDets++){ + const GeomDet* theGeomDet = theGeomDetGeometry->idToDet( (*compGeometricDets)->geographicalId() ); + + if( (*compGeometricDets)->positionBounds().perp() < meanR) + innerGeomDets.push_back(theGeomDet); + + if( (*compGeometricDets)->positionBounds().perp() > meanR) + outerGeomDets.push_back(theGeomDet); + } + + LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size() ; + LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size() ; + + return new Phase2OTBarrelRod(innerGeomDets,outerGeomDets,innerGeomDetBrothers,outerGeomDetBrothers); - if (compGeometricDets[1]->positionBounds().perp() > meanRBrothers) - outerGeomDetBrothers.push_back(theGeomDetBrother); + vector compGeometricDets; + + vector innerGeomDetBrothers; + vector outerGeomDetBrothers; + + double meanRBrothers = 0; + for(vector::const_iterator it=allGeometricDets.begin(); it!=allGeometricDets.end();it++){ + compGeometricDets = (*it)->components(); + if (compGeometricDets.size() != 2){ + LogDebug("TkDetLayers") << " Stack not with two components but with " << compGeometricDets.size() << std::endl; + } else { + //LogTrace("TkDetLayers") << " compGeometricDets[0]->positionBounds().perp() " << compGeometricDets[0]->positionBounds().perp() << std::endl; + //LogTrace("TkDetLayers") << " compGeometricDets[1]->positionBounds().perp() " << compGeometricDets[1]->positionBounds().perp() << std::endl; + meanR = meanR + compGeometricDets[0]->positionBounds().perp(); + meanRBrothers = meanRBrothers + compGeometricDets[1]->positionBounds().perp(); + } + + } + meanR = meanR/allGeometricDets.size(); + meanRBrothers = meanRBrothers/allGeometricDets.size(); + LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl; + LogDebug("TkDetLayers") << " meanR Upper " << meanRBrothers << std::endl; + + for(vector::iterator it=allGeometricDets.begin(); it!=allGeometricDets.end(); it++){ + compGeometricDets = (*it)->components(); + const GeomDet* theGeomDet = theGeomDetGeometry->idToDet( compGeometricDets[0]->geographicalId() ); + LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[0]->geographicalId().rawId() << std::endl; + + if( compGeometricDets[0]->positionBounds().perp() < meanR) + innerGeomDets.push_back(theGeomDet); + + if( compGeometricDets[0]->positionBounds().perp() > meanR) + outerGeomDets.push_back(theGeomDet); + + const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet( compGeometricDets[1]->geographicalId() ); + LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[1]->geographicalId().rawId() << std::endl; + if( compGeometricDets[1]->positionBounds().perp() < meanRBrothers) + innerGeomDetBrothers.push_back(theGeomDetBrother); + + if( compGeometricDets[1]->positionBounds().perp() > meanRBrothers) + outerGeomDetBrothers.push_back(theGeomDetBrother); + } + + LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size() ; + LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size() ; + LogDebug("TkDetLayers") << "innerGeomDetsBro.size(): " << innerGeomDetBrothers.size() ; + LogDebug("TkDetLayers") << "outerGeomDetsBro.size(): " << outerGeomDetBrothers.size() ; + + return new Phase2OTBarrelRod(innerGeomDets,outerGeomDets,innerGeomDetBrothers,outerGeomDetBrothers); + } - LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size(); - LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size(); - LogDebug("TkDetLayers") << "innerGeomDetsBro.size(): " << innerGeomDetBrothers.size(); - LogDebug("TkDetLayers") << "outerGeomDetsBro.size(): " << outerGeomDetBrothers.size(); + return new Phase2OTBarrelRod(innerGeomDets,outerGeomDets,innerGeomDetBrothers,outerGeomDetBrothers); - return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers); } diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.h b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.h index 641d04d4e7368..7a6876ec24adc 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.h +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.h @@ -14,8 +14,11 @@ class Phase2OTBarrelRodBuilder { public: Phase2OTBarrelRodBuilder(){}; - Phase2OTBarrelRod* build(const GeometricDet* thePhase2OTBarrelRod, const TrackerGeometry* theGeomDetGeometry) - __attribute__((cold)); + Phase2OTBarrelRod* build(const GeometricDet* thePhase2OTBarrelRod, + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers = true) __attribute__ ((cold)); + + }; #pragma GCC visibility pop diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h new file mode 100644 index 0000000000000..e731e3e595e5c --- /dev/null +++ b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h @@ -0,0 +1,71 @@ +//--------------------------------------------------------------------------- +// class SeedingOTEDProducer +// author: ebrondol +// date: July, 2016 +//--------------------------------------------------------------------------- + +#ifndef RecoTracker_TkSeedGenerator_SeedingOTEDProducer_h +#define RecoTracker_TkSeedGenerator_SeedingOTEDProducer_h + +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/BeamSpot/interface/BeamSpot.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" +#include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" +#include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" + +class TrajectoryStateUpdator; + +class SeedingOTEDProducer : public edm::stream::EDProducer<> +{ + + public: + + explicit SeedingOTEDProducer(const edm::ParameterSet&); + virtual ~SeedingOTEDProducer(); + virtual void produce(edm::Event&, const edm::EventSetup&) override; + + static void fillDescriptions(edm::ConfigurationDescriptions&); + + TrajectorySeedCollection run( edm::Handle< VectorHitCollectionNew > ); + unsigned int checkLayer( unsigned int iidd ); + std::vector collectVHsOnLayer( edm::Handle< VectorHitCollectionNew >, unsigned int ); + void printVHsOnLayer( edm::Handle< VectorHitCollectionNew >, unsigned int ); + const TrajectoryStateOnSurface buildInitialTSOS( VectorHit& ); + AlgebraicSymMatrix assign44To55( AlgebraicSymMatrix ); + std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, const Propagator&, const TrackingRecHit& hit); + float computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot); + float computeInverseMomentumError(VectorHit& vh, const float globalTheta, const MagneticField* magField, const double sigmaZ_beamSpot); + + TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, const DetId& id, const Propagator& prop); + + struct isInvalid { + bool operator()(const TrajectoryMeasurement& measurement) { + return ( ((measurement).recHit() == 0) || !((measurement).recHit()->isValid()) || !((measurement).updatedState().isValid()) ); + } + }; + + private: + + edm::EDGetTokenT< VectorHitCollectionNew > vhProducerToken; + const TrackerTopology* tkTopo; + const MeasurementTracker* measurementTracker; + const LayerMeasurements* layerMeasurements; + const MeasurementEstimator* estimator; + const Propagator* propagator; + const MagneticField* magField; + const TrajectoryStateUpdator* theUpdator; + const edm::EDGetTokenT tkMeasEventToken; + edm::EDGetTokenT beamSpotToken; + const reco::BeamSpot* beamSpot; + std::string updatorName; +}; + +#endif diff --git a/RecoTracker/TkSeedGenerator/plugins/SealModules.cc b/RecoTracker/TkSeedGenerator/plugins/SealModules.cc index 4a64f677fc545..58fa1e15580b3 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SealModules.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SealModules.cc @@ -39,3 +39,6 @@ DEFINE_FWK_MODULE(SeedCreatorFromRegionConsecutiveHitsEDProducer); using SeedCreatorFromRegionConsecutiveHitsTripletOnlyEDProducer = SeedCreatorFromRegionHitsEDProducerT; DEFINE_FWK_MODULE(SeedCreatorFromRegionConsecutiveHitsTripletOnlyEDProducer); + +#include "RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h" +DEFINE_FWK_MODULE(SeedingOTEDProducer); diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc new file mode 100644 index 0000000000000..8606e5e9b27c8 --- /dev/null +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -0,0 +1,445 @@ +#include "RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h" +#include "FWCore/Framework/interface/Event.h" + +#include "Geometry/Records/interface/TrackerTopologyRcd.h" + +#include "RecoTracker/Record/interface/CkfComponentsRecord.h" +#include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" +#include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" +#include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h" +#include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h" + +#include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h" +#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" +#include "TrackingTools/MeasurementDet/interface/TrajectoryMeasurementGroup.h" + +#include "DataFormats/SiStripDetId/interface/StripSubdetector.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf): + theUpdator(nullptr), + tkMeasEventToken( consumes(conf.getParameter("trackerEvent")) ) +{ + vhProducerToken = consumes< VectorHitCollectionNew >(edm::InputTag(conf.getParameter("src"))); + beamSpotToken = consumes< reco::BeamSpot >(conf.getParameter("beamSpotLabel")); + updatorName = conf.getParameter("updator"); + produces(); +} + +SeedingOTEDProducer::~SeedingOTEDProducer() { +} + +void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions){ + edm::ParameterSetDescription desc; + desc.add("src", edm::InputTag("siPhase2VectorHits","vectorHitsAccepted")); + desc.add("trackerEvent", edm::InputTag("MeasurementTrackerEvent")); + desc.add("beamSpotLabel", edm::InputTag("offlineBeamSpot")); + desc.add("updator", std::string("KFUpdator")); + descriptions.add("SeedingOTEDProducer", desc); +} + +void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) +{ + std::cout << "SeedingOT::produce() begin" << std::endl; + std::unique_ptr seedsWithVHs(new TrajectorySeedCollection()); + + edm::ESHandle tTopoHandle; + es.get().get(tTopoHandle); + tkTopo = tTopoHandle.product(); + + edm::ESHandle measurementTrackerHandle; + es.get().get(measurementTrackerHandle); + measurementTracker = measurementTrackerHandle.product(); + edm::Handle measurementTrackerEvent; + event.getByToken(tkMeasEventToken,measurementTrackerEvent); + + layerMeasurements = new LayerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); + + edm::ESHandle est; + es.get().get("Chi2",est); + estimator = est.product(); + + edm::ESHandle prop; + es.get().get("PropagatorWithMaterial",prop); + propagator = prop.product(); + + edm::ESHandle magFieldHandle; + es.get().get(magFieldHandle); + magField = magFieldHandle.product(); + + edm::ESHandle updatorHandle; + es.get().get(updatorName, updatorHandle); + theUpdator = updatorHandle.product(); + + edm::Handle beamSpotH; + event.getByToken(beamSpotToken, beamSpotH); + if (beamSpotH.isValid()) { + std::cout << "BeamSpot Position: " << *(beamSpotH.product()); + beamSpot = beamSpotH.product(); + } + + // Get the vector hits + edm::Handle< VectorHitCollectionNew > vhs; + event.getByToken(vhProducerToken, vhs); +/* + edm::ESHandle< ClusterParameterEstimator > parameterestimator; + es.get().get(cpe, parameterestimator); + const Phase2StripCPEGeometric & cpeOT(*parameterestimator); +*/ + TrajectorySeedCollection const& tempSeeds = run(vhs); + for( TrajectorySeedCollection::const_iterator qIt = tempSeeds.begin(); qIt < tempSeeds.end(); ++qIt ) { + seedsWithVHs->push_back( *qIt ); + } + + seedsWithVHs->shrink_to_fit(); + event.put(std::move(seedsWithVHs)); + + std::cout << "SeedingOT::produce() end" << std::endl; + +} + +TrajectorySeedCollection SeedingOTEDProducer::run( edm::Handle< VectorHitCollectionNew > VHs ){ + + TrajectorySeedCollection result; + + std::cout << "-----------------------------" << std::endl; + printVHsOnLayer(VHs,1); + printVHsOnLayer(VHs,2); + printVHsOnLayer(VHs,3); + printVHsOnLayer(VHs,4); + printVHsOnLayer(VHs,5); + printVHsOnLayer(VHs,6); + std::cout << "-----------------------------" << std::endl; + + //check if all the first three layers have VHs + std::vector VHseedsL1 = collectVHsOnLayer(VHs,1); + std::vector VHseedsL2 = collectVHsOnLayer(VHs,2); + std::vector VHseedsL3 = collectVHsOnLayer(VHs,3); + if(VHseedsL1.empty() || VHseedsL2.empty() || VHseedsL3.empty()){ + std::cout << "------- seeds found: " << result.size() << " ------" << std::endl; + std::cout << "- L1 or L2 or L3 are empty! -" << std::endl; + std::cout << "-----------------------------" << std::endl; + return result; + } + + //seeds are built in the L3 of the OT + const BarrelDetLayer* barrelOTLayer2 = measurementTracker->geometricSearchTracker()->tobLayers().at(1); + std::cout << "VH seeds = " << VHseedsL3.size() << std::endl; + + //the search propag directiondepend on the sign of signZ*signPz, while the building is always the contrary + Propagator* searchingPropagator = &*propagator->clone(); + Propagator* buildingPropagator = &*propagator->clone(); + buildingPropagator->setPropagationDirection(alongMomentum); + + for(auto hitL3 : VHseedsL3){ + + //building a tsos out of a VectorHit + std::cout << "\t1a) Building a seed for the VH: " << hitL3 << std::endl; + const TrajectoryStateOnSurface initialTSOS = buildInitialTSOS(hitL3); + float signZ = copysign(1.0,initialTSOS.globalPosition().z()); + float signPz = copysign(1.0,initialTSOS.globalMomentum().z()); + + std::cout << "\t initialTSOS : " << initialTSOS << std::endl; + + //set the direction of the propagator + std::cout << "\t1b) Set the searchingPropagator direction: " << std::endl; + if(signZ*signPz > 0.0) + searchingPropagator->setPropagationDirection(oppositeToMomentum); + if(signZ*signPz < 0.0) + searchingPropagator->setPropagationDirection(alongMomentum); + + if(searchingPropagator->propagationDirection() == alongMomentum) + std::cout << "\t searchingPropagator along Momentum" << std::endl; + if(searchingPropagator->propagationDirection() == oppositeToMomentum) + std::cout << "\t ropagator opposite To Momentum" << std::endl; + + //find vHits in layer 2 + std::cout << "-----------------------------" << std::endl; + std::cout << "\t1c) Search/find hit in layer 2: " << std::endl; + std::vector measurementsL2 = layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + std::cout << "\t vh compatibles on L2: " << measurementsL2.size() << std::endl; + + //other options + //LayerMeasurements::SimpleHitContainer hits; + //layerMeasurements->recHits(hits, *barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + //std::cout << "\t #try2 vh compatibles with recHits: " << hits.size() << std::endl; + //auto && measurementsL2G = layerMeasurements->groupedMeasurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + //std::cout << "\t #try3 vh grouped compatibles: " << measurementsL2G.size() << std::endl; + + + std::vector::iterator measurementsL2end = std::remove_if(measurementsL2.begin(), measurementsL2.end(), isInvalid()); + measurementsL2.erase(measurementsL2end, measurementsL2.end()); + std::cout << "\t vh compatibles on L2(without invalidHit): " << measurementsL2.size() << std::endl; + std::cout << "-----------------------------" << std::endl; + + if(!measurementsL2.empty()){ + //not sure if building it everytime takes time/memory + const DetLayer* barrelOTLayer1 = measurementTracker->geometricSearchTracker()->tobLayers().at(0); + + for(auto mL2 : measurementsL2){ + + std::cout << "\t2a) Check the searchingPropagator direction: " << std::endl; + if(searchingPropagator->propagationDirection() == alongMomentum) + std::cout << "\t searchingPropagator along Momentum" << std::endl; + if(searchingPropagator->propagationDirection() == oppositeToMomentum) + std::cout << "\t searchingPropagator opposite To Momentum" << std::endl; + + const TrackingRecHit* hitL2 = mL2.recHit().get(); + std::cout << "\t2b) and the VH on layer 2: " << std::endl; + const VectorHit* vhit = dynamic_cast(hitL2); + std::cout << "\t vh is valid >> " << (*vhit) << std::endl; + + //propagate to the L2 and update the TSOS + std::cout << "\t2c) Propagation and update on L2: " << std::endl; + std::pair updatedTSOS = propagateAndUpdate(initialTSOS, *searchingPropagator, *hitL2); + if(!updatedTSOS.first) std::cout << "\t updatedTSOS on L2 is NOT valid : " << updatedTSOS.second << std::endl; + if(!updatedTSOS.first) continue; + std::cout << "\t updatedTSOS is valid : " << updatedTSOS.second << std::endl; + std::cout << "\t chi2 VH/updatedTSOS : " << estimator->estimate(updatedTSOS.second, *hitL2).second << std::endl; + + //searching possible VHs in L1 + std::cout << "\t2d) Search/find hit in layer 1: " << std::endl; + std::vector measurementsL1 = layerMeasurements->measurements(*barrelOTLayer1, updatedTSOS.second, *searchingPropagator, *estimator); + std::cout << "\t vh compatibles on L1: " << measurementsL1.size() << std::endl; + std::vector::iterator measurementsL1end = std::remove_if(measurementsL1.begin(), measurementsL1.end(), isInvalid()); + measurementsL1.erase(measurementsL1end, measurementsL1.end()); + std::cout << "\t vh compatibles on L1(without invalidHit): " << measurementsL1.size() << std::endl; + std::cout << "-----------------------------" << std::endl; + + if(!measurementsL1.empty()){ + + for(auto mL1 : measurementsL1){ + std::cout << "\t3a) Check the searchingPropagator direction: " << std::endl; + if(searchingPropagator->propagationDirection() == alongMomentum) + std::cout << "\t searchingPropagator along Momentum" << std::endl; + if(searchingPropagator->propagationDirection() == oppositeToMomentum) + std::cout << "\t searchingPropagator opposite To Momentum" << std::endl; + + const TrackingRecHit* hitL1 = mL1.recHit().get(); + std::cout << "\t3b) and the VH on layer 1: " << std::endl; + const VectorHit* vhitL1 = dynamic_cast(hitL1); + std::cout << "\t vh is valid >> " << (*vhitL1) << std::endl; + + //propagate to the L1 and update the TSOS + std::cout << "\t3c) Propagation and update on L1: " << std::endl; + std::pair updatedTSOSL1 = propagateAndUpdate(updatedTSOS.second, *searchingPropagator, *hitL1); + if(!updatedTSOSL1.first) std::cout << "\t updatedTSOS on L1 is NOT valid : " << updatedTSOSL1.second << std::endl; + if(!updatedTSOSL1.first) continue; + std::cout << "\t updatedTSOS on L1 : " << updatedTSOSL1.second << std::endl; + std::cout << "\t chi2 VH/updatedTSOS : " << estimator->estimate(updatedTSOSL1.second, *hitL1).second << std::endl; + + + std::cout << "\t3d) Creation of the Seed: " << std::endl; + // passSelection(updatedTSOS) : + // http://cmslxr.fnal.gov/lxr/source/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc?v=CMSSW_8_1_X_2016-09-04-2300#0474 + edm::OwnVector container; + container.push_back(hitL1->clone()); + container.push_back(hitL2->clone()); + container.push_back(hitL3.clone()); + + //building trajectory inside-out + std::cout << "\t3e) Building trajectory inside-out: " << std::endl; + if(searchingPropagator->propagationDirection() == alongMomentum){ + buildingPropagator->setPropagationDirection(oppositeToMomentum); + std::cout << "\t buildingPropagator opposite To Momentum" << std::endl; + } else if(searchingPropagator->propagationDirection() == oppositeToMomentum){ + buildingPropagator->setPropagationDirection(alongMomentum); + std::cout << "\t buildingPropagator along Momentum" << std::endl; + } + + updatedTSOSL1.second.rescaleError(100); + std::cout << "\t updatedTSOS on L1 : " << updatedTSOSL1.second << std::endl; + + TrajectoryStateOnSurface updatedTSOSL1_final = theUpdator->update(updatedTSOSL1.second,*hitL1); + if UNLIKELY(!updatedTSOSL1_final.isValid()) continue; + std::pair updatedTSOSL2_final = propagateAndUpdate(updatedTSOSL1_final, *buildingPropagator, *hitL2); + std::pair updatedTSOSL3_final = propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, hitL3); + std::cout << "\t updatedTSOS final on L3 : " << updatedTSOSL3_final.second << std::endl; + TrajectorySeed ts = createSeed(updatedTSOSL3_final.second, container, hitL3.geographicalId(),*buildingPropagator); + result.push_back(ts); + } + + } + + std::cout << "-----" << std::endl; + } + } + + } + std::cout << "-----------------------------" << std::endl; + std::cout << "------- seeds found: " << result.size() << " ------" << std::endl; + std::cout << "-----------------------------" << std::endl; + + return result; +} + +unsigned int SeedingOTEDProducer::checkLayer( unsigned int iidd ){ + StripSubdetector strip = StripSubdetector(iidd); + unsigned int subid = strip.subdetId(); + if (subid == StripSubdetector::TIB || subid == StripSubdetector::TOB) { + return tkTopo->layer(iidd); + } + return 0; +} + +std::vector SeedingOTEDProducer::collectVHsOnLayer( edm::Handle< VectorHitCollectionNew > VHs, unsigned int layerNumber ){ + + const VectorHitCollectionNew& input = *VHs; + std::vector VHsOnLayer; + if (input.size() > 0 ) { + //std::cout << "initial VH collection size = " << input.size() << std::endl; + for (auto DSViter : input) { + if(checkLayer(DSViter.id()) == layerNumber){ + for(auto vh : DSViter){ + VHsOnLayer.push_back(vh); + } + } + } + } + + //std::cout << "VH in layer " << layerNumber << " collection size = " << VHsOnLayer.size() << std::endl; + + return VHsOnLayer; +} + +void SeedingOTEDProducer::printVHsOnLayer( edm::Handle< VectorHitCollectionNew > VHs, unsigned int layerNumber ){ + const VectorHitCollectionNew& input = *VHs; + if (input.size() > 0 ) { + for (auto DSViter : input) { + for(auto vh : DSViter){ + if(checkLayer(DSViter.id()) == layerNumber) std::cout << " VH in layer " << layerNumber << " >> " << vh << std::endl; + } + } + } else { + std::cout << " No VHs in layer " << layerNumber << "." << std::endl; + } +} + +const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS( VectorHit& vHit ){ + + //FIXME::charge is fine 1 every two times!! + int charge = 1; + //float pT = vHit.transverseMomentum(magField); + float p = vHit.momentum(magField); + float x = vHit.localPosition().x(); + float y = vHit.localPosition().y(); + float dx = vHit.localDirection().x(); + float dy = vHit.localDirection().y(); + // Pz and Dz should have the same sign + float signPz = copysign(1.0,vHit.globalPosition().z()); + + // having fun with theta + Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); + float theta = gv.theta(); + //std::cout << "\tgv : " << gv << std::endl; + //std::cout << "\tgv theta : " << theta << std::endl; + //std::cout << "\tgv theta error : " << computeGlobalThetaError(vHit, beamSpot->sigmaZ()) << std::endl; + //std::cout << "\tgv eta : " << gv.eta() << std::endl; + // gv transform to local (lv) + const Local3DVector lv( vHit.det()->surface().toLocal( gv ) ); + //std::cout << "\tlv : " << lv << std::endl; + // replace dy with second component of the lv renormalized to the z component + dy = lv.y()/lv.z(); + + LocalTrajectoryParameters ltpar2(charge/p, dx, dy, x, y, signPz); + AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); + // set the error on 1/p + mat[0][0] = pow(computeInverseMomentumError(vHit, theta,magField,beamSpot->sigmaZ()),2); + //std::cout << "\tltraj : " << charge << "," << 1./p <<","<< dx <<","<< dy <<","<< x <<","<< y <<","<< signPz << std::endl; + //std::cout << "\tmat : " << mat << std::endl; + + //building tsos + LocalTrajectoryError lterr(asSMatrix<5>(mat)); + const TrajectoryStateOnSurface tsos(ltpar2, lterr, vHit.det()->surface(), magField); + + return tsos; +} + +AlgebraicSymMatrix SeedingOTEDProducer::assign44To55( AlgebraicSymMatrix mat44 ){ + if(mat44.num_row() != 4 || mat44.num_col() != 4) + assert("Wrong dimension! This should be a 4x4 matrix!"); + + AlgebraicSymMatrix result(5,0); + for(int i = 1; i < 5; i++){ + for(int j = 1; j < 5; j++){ + result[i][j] = mat44[i-1][j-1]; + } + } + return result; +} + +std::pair SeedingOTEDProducer::propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit){ + TrajectoryStateOnSurface propTSOS = prop.propagate( initialTSOS, hit.det()->surface()); + TrajectoryStateOnSurface updatedTSOS = theUpdator->update(propTSOS,hit); + //std::cout << "updatedTSOS : " << updatedTSOS << std::endl; + if UNLIKELY(!updatedTSOS.isValid()) return std::make_pair( false, updatedTSOS); + return std::make_pair( true, updatedTSOS); +} + +float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot){ + + double derivative = vh.globalPosition().perp()/(pow(vh.globalPosition().z(),2)+pow(vh.globalPosition().perp(),2)); + double derivative2 = pow(derivative,2); + return pow( derivative2*vh.lowerGlobalPosErr().czz()+derivative2*pow(sigmaZ_beamSpot,2), 0.5); + +} + +float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, const float globalTheta, const MagneticField* magField, const double sigmaZ_beamSpot){ + + //for pT > 2GeV, 1/pT has sigma = 1/sqrt(12) + float varianceInverseTransvMomentum = 1./12; + double derivativeTheta2 = pow(cos(globalTheta)/vh.transverseMomentum(magField),2); + double derivativeInverseTransvMomentum2 = pow(sin(globalTheta),2); + float thetaError = computeGlobalThetaError(vh, sigmaZ_beamSpot); + return pow(derivativeTheta2*pow(thetaError,2)+derivativeInverseTransvMomentum2*varianceInverseTransvMomentum,0.5); + +} + +TrajectorySeed SeedingOTEDProducer::createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, const DetId& id, const Propagator& prop) { +/* + //I have already propagator and updator + //const Propagator* propagator = &(*propagatorHandle); + //KFUpdator updator; + + // Now update initial state track using information from seed hits. + + TrajectoryStateOnSurface updatedState; + edm::OwnVector seedHits; + + for ( unsigned int iHit = 1; iHit < container.size(); iHit++) { + + std::pair state; + if(iHit==1) + state = propagateAndUpdate(tsos, *propagator, container[iHit]); + else + state = propagateAndUpdate(updatedState, *propagator, container[iHit]); + //std::cout << "-------> new state >> " << state.second << std::endl; + if(state.first) + updatedState = state.second; +*/ +/* + TrajectoryStateOnSurface state = (iHit==1) ? propagator->propagate(tsos, container[iHit].det()->surface()) : propagator->propagate(updatedState, container[iHit].det()->surface()); + + std::cout << "-------> new state >> " << state << std::endl; + + if (!state.isValid()) return TrajectorySeed(); + + //SeedingHitSet::ConstRecHitPointer tth = hits[iHit]; + //std::unique_ptr newtth(refitHit( tth, state)); + //if (!checkHit(state,&*newtth)) return; + + std::cout << "-------> updated state >> " << state << std::endl; + updatedState = theUpdator->update(state, container[iHit]); + if (!updatedState.isValid()) return TrajectorySeed(); + + //seedHits.push_back(newtth.release()); +*/ +// } + + //if(!hit) return; + + PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos, id.rawId()); + return TrajectorySeed(seedTSOS,container,prop.propagationDirection()); + //if ( !filter || filter->compatible(seed)) seedCollection.push_back(std::move(seed)); + +} diff --git a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc index 44aa1e9d10cbd..54a96d8d94b96 100644 --- a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc +++ b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc @@ -18,83 +18,72 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "DataFormats/SiStripCluster/interface/SiStripClusterTools.h" -#include +#include -#include +#include using namespace ctfseeding; using namespace std; using namespace edm; -HitExtractorSTRP::HitExtractorSTRP(GeomDetEnumerators::SubDetector subdet, - TrackerDetSide side, - int idLayer, - float iminGoodCharge) - : theLayerSubDet(subdet), - theSide(side), - theIdLayer(idLayer), - minAbsZ(0), - theMinRing(1), - theMaxRing(0), - hasMatchedHits(false), - hasRPhiHits(false), - hasStereoHits(false), - hasRingSelector(false), - hasSimpleRphiHitsCleaner(true) { - minGoodCharge = iminGoodCharge; - if (minGoodCharge > 0) - skipClusters = true; -} +HitExtractorSTRP::HitExtractorSTRP(GeomDetEnumerators::SubDetector subdet, TrackerDetSide side, int idLayer, float iminGoodCharge): + theLayerSubDet(subdet), theSide(side), theIdLayer(idLayer), + minAbsZ(0), theMinRing(1), theMaxRing(0), + hasMatchedHits(false), hasRPhiHits(false), hasStereoHits(false), + hasVectorHits(false), + hasRingSelector(false), hasSimpleRphiHitsCleaner(true) +{ minGoodCharge=iminGoodCharge; if (minGoodCharge>0) skipClusters=true; } -void HitExtractorSTRP::useSkipClusters_(const edm::InputTag& m, edm::ConsumesCollector& iC) { +void HitExtractorSTRP::useSkipClusters_(const edm::InputTag & m, edm::ConsumesCollector& iC) { theSkipClusters = iC.consumes(m); + theSkipPhase2Clusters = iC.consumes(m); } -void HitExtractorSTRP::useRingSelector(int minRing, int maxRing) { - hasRingSelector = true; - theMinRing = minRing; - theMaxRing = maxRing; +void HitExtractorSTRP::useRingSelector(int minRing, int maxRing) +{ + hasRingSelector=true; + theMinRing=minRing; + theMaxRing=maxRing; } -bool HitExtractorSTRP::ringRange(int ring) const { - if (!hasRingSelector) - return true; - return (ring >= theMinRing) & (ring <= theMaxRing); +bool HitExtractorSTRP::ringRange(int ring) const +{ + if (!hasRingSelector) return true; + return (ring >= theMinRing) & (ring <= theMaxRing); } -bool HitExtractorSTRP::skipThis( - DetId id, - OmniClusterRef const& clus, - edm::Handle > >& stripClusterMask) const { - if (maskCluster && (stripClusterMask->mask(clus.key()))) - return true; +bool HitExtractorSTRP::skipThis(DetId id, OmniClusterRef const& clus, + edm::Handle > > & stripClusterMask) const { + + if (maskCluster && (stripClusterMask->mask(clus.key())) ) return true; - if - UNLIKELY(minGoodCharge <= 0) return false; - return siStripClusterTools::chargePerCM(id, *clus.cluster_strip()) <= minGoodCharge; + if UNLIKELY(minGoodCharge<=0) return false; + return siStripClusterTools::chargePerCM(id,*clus.cluster_strip()) <= minGoodCharge; } -std::pair HitExtractorSTRP::skipThis( - const TkTransientTrackingRecHitBuilder& ttrhBuilder, - TkHitRef matched, - edm::Handle > >& stripClusterMask) const { - const SiStripMatchedRecHit2D& hit = (SiStripMatchedRecHit2D const&)(matched); + +std::pair +HitExtractorSTRP::skipThis(const TkTransientTrackingRecHitBuilder& ttrhBuilder, + TkHitRef matched, + edm::Handle > > & stripClusterMask) const { + const SiStripMatchedRecHit2D & hit = (SiStripMatchedRecHit2D const&)(matched); + assert(dynamic_cast(&matched)); - auto id = hit.geographicalId(); - ProjectedSiStripRecHit2D* replaceMe = nullptr; - bool rejectSt = skipThis(id, hit.stereoClusterRef(), stripClusterMask); - bool rejectMono = skipThis(id, hit.monoClusterRef(), stripClusterMask); + auto id = hit.geographicalId(); + ProjectedSiStripRecHit2D * replaceMe = nullptr; + bool rejectSt = skipThis(id,hit.stereoClusterRef(), stripClusterMask); + bool rejectMono = skipThis(id, hit.monoClusterRef(), stripClusterMask); - if ((!rejectSt) & (!rejectMono)) { + if ((!rejectSt)&(!rejectMono)){ // keepit - return std::make_pair(false, replaceMe); + return std::make_pair(false,replaceMe); } - if (failProjection || (rejectSt & rejectMono)) { + if (failProjection || (rejectSt&rejectMono) ){ //only skip if both hits are done - return std::make_pair(true, replaceMe); + return std::make_pair(true,replaceMe); } // replace with one @@ -102,65 +91,78 @@ std::pair HitExtractorSTRP::skipThis( auto cloner = ttrhBuilder.cloner(); replaceMe = cloner.project(hit, rejectSt, TrajectoryStateOnSurface()).release(); if (rejectSt) - LogDebug("HitExtractorSTRP") << "a matched hit is partially masked, and the mono hit got projected onto: " - << replaceMe->geographicalId().rawId() << " key: " << hit.monoClusterRef().key(); - else - LogDebug("HitExtractorSTRP") << "a matched hit is partially masked, and the stereo hit got projected onto: " - << replaceMe->geographicalId().rawId() << " key: " << hit.stereoClusterRef().key(); + LogDebug("HitExtractorSTRP")<<"a matched hit is partially masked, and the mono hit got projected onto: "<geographicalId().rawId()<<" key: "<geographicalId().rawId()<<" key: "< stripClusterMask; - if (maskCluster) - ev.getByToken(theSkipClusters, stripClusterMask); - unsigned int skipped = 0; - unsigned int projected = 0; - for (unsigned int iH = cleanFrom; iH < hits.size(); ++iH) { - assert(hits[iH]->isValid()); - auto id = hits[iH]->geographicalId(); - if (matched) { - bool replace; - ProjectedSiStripRecHit2D* replaceMe; - std::tie(replace, replaceMe) = skipThis(ttrhBuilder, *hits[iH], stripClusterMask); - if (replace) { - if (!replaceMe) { - LogDebug("HitExtractorSTRP") << "skipping a matched hit on :" << hits[iH]->geographicalId().rawId(); - skipped++; - } else - projected++; - hits[iH].reset(replaceMe); - if (replaceMe == nullptr) - assert(hits[iH].empty()); - else - assert(hits[iH].isOwn()); + +void HitExtractorSTRP::cleanedOfClusters( const TkTransientTrackingRecHitBuilder& ttrhBuilder, + const edm::Event& ev, HitExtractor::Hits & hits, + bool matched, + unsigned int cleanFrom) const{ + unsigned int skipped=0; + unsigned int projected=0; + if(hasMatchedHits || hasRPhiHits || hasStereoHits){ + LogTrace("HitExtractorSTRP")<<"getting "< stripClusterMask; + if (maskCluster) ev.getByToken(theSkipClusters,stripClusterMask); + for (unsigned int iH=cleanFrom;iHisValid()); + auto id = hits[iH]->geographicalId(); + if (matched) { + bool replace; ProjectedSiStripRecHit2D * replaceMe; std::tie(replace,replaceMe) = skipThis(ttrhBuilder, *hits[iH],stripClusterMask); + if (replace) { + if (!replaceMe) { + LogTrace("HitExtractorSTRP")<<"skipping a matched hit on :"<geographicalId().rawId(); + skipped++; + } else { projected++; } + hits[iH].reset(replaceMe); + if (replaceMe==nullptr) assert(hits[iH].empty()); + else assert(hits[iH].isOwn()); + } + } + else if (skipThis(id, hits[iH]->firstClusterRef(),stripClusterMask)){ + LogTrace("HitExtractorSTRP")<<"skipping a hit on :"<geographicalId().rawId()<<" key: "; + skipped++; + hits[iH].reset(); + } + } + } + if(hasVectorHits){ + LogTrace("HitExtractorSTRP")<<"getting "< ph2ClusterMask; + if (maskCluster) ev.getByToken(theSkipPhase2Clusters,ph2ClusterMask); + for (unsigned int iH=cleanFrom;iHgeographicalId().rawId(); + assert(hits[iH]->isValid()); + const VectorHit & vhit = dynamic_cast(*hits[iH]); + LogTrace("HitExtractorSTRP")<<" key lower: "<firstClusterRef().key() ; + + //FIXME:: introduce a "projected" version later? + if (maskCluster && (ph2ClusterMask->mask(vhit.lowerClusterRef().key()) || ph2ClusterMask->mask(vhit.upperClusterRef().key())) ){ + LogTrace("HitExtractorSTRP")<<"skipping a vector hit on :"<geographicalId().rawId()<<" key lower: "<firstClusterRef(), stripClusterMask)) { - LogDebug("HitExtractorSTRP") << "skipping a hit on :" << hits[iH]->geographicalId().rawId() << " key: "; - skipped++; - hits[iH].reset(); } } + // remove empty elements... - auto last = std::remove_if(hits.begin() + cleanFrom, hits.end(), [](HitPointer const& p) { return p.empty(); }); - hits.resize(last - hits.begin()); + auto last = std::remove_if(hits.begin()+cleanFrom,hits.end(),[]( HitPointer const & p) {return p.empty();}); + hits.resize(last-hits.begin()); - // std::cout << "HitExtractorSTRP " <<"skipped :"< tTopoHandle; @@ -171,226 +173,237 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder // TIB // if (theLayerSubDet == GeomDetEnumerators::TIB) { + LogTrace("HitExtractorSTRP")<<"Getting hits into the TIB"; if (hasMatchedHits) { edm::Handle matchedHits; - ev.getByToken(theMatchedHits, matchedHits); - if (skipClusters) - cleanFrom = result.size(); - range2SeedingHits(*matchedHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, true, cleanFrom); + ev.getByToken( theMatchedHits, matchedHits); + if (skipClusters) cleanFrom=result.size(); + range2SeedingHits( *matchedHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,true,cleanFrom); } if (hasRPhiHits) { edm::Handle rphiHits; - ev.getByToken(theRPhiHits, rphiHits); - if (hasMatchedHits) { - if (!hasSimpleRphiHitsCleaner) { // this is a brutal "cleaning". Add something smarter in the future - if (skipClusters) - cleanFrom = result.size(); - range2SeedingHits(*rphiHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); - } + ev.getByToken( theRPhiHits, rphiHits); + if (hasMatchedHits){ + if (!hasSimpleRphiHitsCleaner){ // this is a brutal "cleaning". Add something smarter in the future + if (skipClusters) cleanFrom=result.size(); + range2SeedingHits( *rphiHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } } else { - if (skipClusters) - cleanFrom = result.size(); - range2SeedingHits(*rphiHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + if (skipClusters) cleanFrom=result.size(); + range2SeedingHits( *rphiHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); } } if (hasStereoHits) { edm::Handle stereoHits; - ev.getByToken(theStereoHits, stereoHits); - if (skipClusters) - cleanFrom = result.size(); - range2SeedingHits(*stereoHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + ev.getByToken( theStereoHits, stereoHits); + if (skipClusters) cleanFrom=result.size(); + range2SeedingHits( *stereoHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); } + if (hasVectorHits) { + LogError("HitExtractorSTRP")<<"TIB is not supposed to be in Phase2 TRK detector configuration. What follows have never been checked before! "; + edm::Handle vectorHits; + ev.getByToken( theVectorHits, vectorHits); + if (skipClusters) cleanFrom=result.size(); + range2SeedingHits( *vectorHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } + } - + // // TID // else if (theLayerSubDet == GeomDetEnumerators::TID) { + LogTrace("HitExtractorSTRP")<<"Getting hits into the TID"; if (hasMatchedHits) { - edm::Handle matchedHits; - ev.getByToken(theMatchedHits, matchedHits); - if (skipClusters) - cleanFrom = result.size(); - auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide), theIdLayer); - SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); - for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tidRing(it->detId()); - if (!ringRange(ring)) - continue; - for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; - ++hit) { - result.emplace_back(*hit); + edm::Handle matchedHits; + ev.getByToken( theMatchedHits, matchedHits); + if (skipClusters) cleanFrom=result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); + SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); + for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; + for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); + } } - } - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, true, cleanFrom); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,true,cleanFrom); } if (hasRPhiHits) { - edm::Handle rphiHits; - ev.getByToken(theRPhiHits, rphiHits); - if (skipClusters) - cleanFrom = result.size(); - auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide), theIdLayer); - SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second); - for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tidRing(it->detId()); - if (!ringRange(ring)) - continue; - if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) - continue; // this is a brutal "cleaning". Add something smarter in the future - for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); + edm::Handle rphiHits; + ev.getByToken( theRPhiHits, rphiHits); + if (skipClusters) cleanFrom=result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); + SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second); + for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; + if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) continue; // this is a brutal "cleaning". Add something smarter in the future + for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); + } } - } - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); } if (hasStereoHits) { - edm::Handle stereoHits; - ev.getByToken(theStereoHits, stereoHits); - if (skipClusters) - cleanFrom = result.size(); - auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide), theIdLayer); - SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second); - for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tidRing(it->detId()); - if (!ringRange(ring)) - continue; - for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + edm::Handle stereoHits; + ev.getByToken( theStereoHits, stereoHits); + if (skipClusters) cleanFrom=result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); + SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second); + for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; + for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); + } + } + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } + if (hasVectorHits) { + LogTrace("HitExtractorSTRP")<<"Getting vector hits for IdLayer " << theIdLayer; + edm::Handle vectorHits; + ev.getByToken( theVectorHits, vectorHits); + //FIXME: check the skipClusters with VHits + if (skipClusters) cleanFrom=result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); + VectorHitCollection::Range range = vectorHits->equal_range(getter.first, getter.second); + for (VectorHitCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; + for (VectorHitCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { result.emplace_back(*hit); } } - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + LogTrace("HitExtractorSTRP")<<"result size value:" << result.size(); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); } } // // TOB // else if (theLayerSubDet == GeomDetEnumerators::TOB) { + LogTrace("HitExtractorSTRP")<<"Getting hits into the TOB"; if (hasMatchedHits) { edm::Handle matchedHits; - ev.getByToken(theMatchedHits, matchedHits); - if (skipClusters) - cleanFrom = result.size(); - if (minAbsZ > 0.) { - auto getter = tTopo->tobDetIdLayerComparator(theIdLayer); - SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); - for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; - ++hit) { - if (fabs(hit->globalPosition().z()) >= minAbsZ) - result.emplace_back(*hit); - } - } + ev.getByToken( theMatchedHits, matchedHits); + if (skipClusters) cleanFrom=result.size(); + if (minAbsZ>0.) { + auto getter = tTopo->tobDetIdLayerComparator(theIdLayer); + SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); + for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + if (fabs(hit->globalPosition().z())>=minAbsZ) result.emplace_back(*hit); + } + } } else { - range2SeedingHits(*matchedHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + range2SeedingHits( *matchedHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); } - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, true, cleanFrom); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,true,cleanFrom); } if (hasRPhiHits) { edm::Handle rphiHits; - ev.getByToken(theRPhiHits, rphiHits); - if (hasMatchedHits) { - if (!hasSimpleRphiHitsCleaner) { // this is a brutal "cleaning". Add something smarter in the future - if (skipClusters) - cleanFrom = result.size(); - range2SeedingHits(*rphiHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); - } + ev.getByToken( theRPhiHits, rphiHits); + if (hasMatchedHits){ + if (!hasSimpleRphiHitsCleaner){ // this is a brutal "cleaning". Add something smarter in the future + if (skipClusters) cleanFrom=result.size(); + range2SeedingHits( *rphiHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } } else { - if (skipClusters) - cleanFrom = result.size(); - range2SeedingHits(*rphiHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + if (skipClusters) cleanFrom=result.size(); + range2SeedingHits( *rphiHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); } } if (hasStereoHits) { edm::Handle stereoHits; - ev.getByToken(theStereoHits, stereoHits); - if (skipClusters) - cleanFrom = result.size(); - range2SeedingHits(*stereoHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + ev.getByToken( theStereoHits, stereoHits); + if (skipClusters) cleanFrom=result.size(); + range2SeedingHits( *stereoHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); } + if (hasVectorHits) { + LogTrace("HitExtractorSTRP")<<"Getting vector hits for IdLayer " << theIdLayer; + edm::Handle vectorHits; + ev.getByToken( theVectorHits, vectorHits); + //FIXME: check the skipClusters with VHits + if (skipClusters) cleanFrom=result.size(); + range2SeedingHits( *vectorHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } + } // // TEC // else if (theLayerSubDet == GeomDetEnumerators::TEC) { + LogTrace("HitExtractorSTRP")<<"Getting hits into the TEC"; if (hasMatchedHits) { - edm::Handle matchedHits; - ev.getByToken(theMatchedHits, matchedHits); - if (skipClusters) - cleanFrom = result.size(); - auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide), theIdLayer); - SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); - for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tecRing(it->detId()); - if (!ringRange(ring)) - continue; - for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; - ++hit) { - result.emplace_back(*hit); + edm::Handle matchedHits; + ev.getByToken( theMatchedHits, matchedHits); + if (skipClusters) cleanFrom=result.size(); + auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide),theIdLayer); + SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); + for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tecRing( it->detId() ); if (!ringRange(ring)) continue; + for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); + } } - } - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, true, cleanFrom); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,true,cleanFrom); } if (hasRPhiHits) { - edm::Handle rphiHits; - ev.getByToken(theRPhiHits, rphiHits); - if (skipClusters) - cleanFrom = result.size(); - auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide), theIdLayer); - SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second); - for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tecRing(it->detId()); - if (!ringRange(ring)) - continue; - if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) - continue; // this is a brutal "cleaning". Add something smarter in the future - for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); + edm::Handle rphiHits; + ev.getByToken( theRPhiHits, rphiHits); + if (skipClusters) cleanFrom=result.size(); + auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide),theIdLayer); + SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second); + for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tecRing( it->detId() ); if (!ringRange(ring)) continue; + if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) continue; // this is a brutal "cleaning". Add something smarter in the future + for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); + } } - } - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } if (hasStereoHits) { - edm::Handle stereoHits; - ev.getByToken(theStereoHits, stereoHits); - if (skipClusters) - cleanFrom = result.size(); - auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide), theIdLayer); - SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second); - for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tecRing(it->detId()); - if (!ringRange(ring)) - continue; - for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + edm::Handle stereoHits; + ev.getByToken( theStereoHits, stereoHits); + if (skipClusters) cleanFrom=result.size(); + auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide),theIdLayer); + SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second); + for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tecRing( it->detId() ); if (!ringRange(ring)) continue; + for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); + } + } + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } + if (hasVectorHits) { + LogError("HitExtractorSTRP")<<"TEC is not supposed to be in Phase2 TRK detector configuration. What follows have never been checked before! "; + edm::Handle vectorHits; + ev.getByToken( theVectorHits, vectorHits); + if (skipClusters) cleanFrom=result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); + VectorHitCollection::Range range = vectorHits->equal_range(getter.first, getter.second); + for (VectorHitCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; + for (VectorHitCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { result.emplace_back(*hit); } } - if (skipClusters) - cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); } } - LogDebug("HitExtractorSTRP") << " giving: " << result.size() << " out"; - // std::cout << "HitExtractorSTRP "<<" giving: "< #include @@ -44,6 +45,11 @@ namespace ctfseeding { hasStereoHits = true; theStereoHits = iC.consumes(m); } + + void useVectorHits(const edm::InputTag & m, edm::ConsumesCollector& iC) { + hasVectorHits = true; + theVectorHits = iC.consumes(m); + } void useRingSelector(int minRing, int maxRing); void useSimpleRphiHitsCleaner(bool use) { hasSimpleRphiHitsCleaner = use; } @@ -72,6 +78,7 @@ namespace ctfseeding { bool ringRange(int ring) const; typedef edm::ContainerMask > SkipClustersCollection; + typedef edm::ContainerMask< Phase2TrackerCluster1DCollectionNew > SkipPhase2ClustersCollection; void useSkipClusters_(const edm::InputTag& m, edm::ConsumesCollector& iC) override; private: @@ -81,12 +88,15 @@ namespace ctfseeding { double minAbsZ; int theMinRing, theMaxRing; edm::EDGetTokenT theSkipClusters; + edm::EDGetTokenT theSkipPhase2Clusters; edm::EDGetTokenT theMatchedHits; edm::EDGetTokenT theRPhiHits; edm::EDGetTokenT theStereoHits; + edm::EDGetTokenT theVectorHits; bool hasMatchedHits; bool hasRPhiHits; bool hasStereoHits; + bool hasVectorHits; bool hasRingSelector; bool hasSimpleRphiHitsCleaner; bool failProjection; diff --git a/RecoTracker/TkSeedingLayers/src/SeedingLayerSetsBuilder.cc b/RecoTracker/TkSeedingLayers/src/SeedingLayerSetsBuilder.cc index 96b4ed9599a93..4bd23772b1761 100644 --- a/RecoTracker/TkSeedingLayers/src/SeedingLayerSetsBuilder.cc +++ b/RecoTracker/TkSeedingLayers/src/SeedingLayerSetsBuilder.cc @@ -133,6 +133,9 @@ SeedingLayerSetsBuilder::LayerSpec::LayerSpec(unsigned short index, if (cfgLayer.exists("stereoRecHits")) { extr->useStereoHits(cfgLayer.getParameter("stereoRecHits"), iC); } + if (cfgLayer.exists("vectorRecHits")) { + extr->useVectorHits(cfgLayer.getParameter("vectorRecHits"), iC); + } if (cfgLayer.exists("useRingSlector") && cfgLayer.getParameter("useRingSlector")) { extr->useRingSelector(cfgLayer.getParameter("minRing"), cfgLayer.getParameter("maxRing")); } diff --git a/RecoTracker/TransientTrackingRecHit/interface/TkClonerImpl.h b/RecoTracker/TransientTrackingRecHit/interface/TkClonerImpl.h index d12a0bf069028..35f1c418bcb4f 100644 --- a/RecoTracker/TransientTrackingRecHit/interface/TkClonerImpl.h +++ b/RecoTracker/TransientTrackingRecHit/interface/TkClonerImpl.h @@ -33,6 +33,7 @@ class TkClonerImpl final : public TkCloner { TrajectoryStateOnSurface const& tsos) const override; std::unique_ptr operator()(Phase2TrackerRecHit1D const& hit, TrajectoryStateOnSurface const& tsos) const override; + std::unique_ptr operator()(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const override; using TkCloner::makeShared; TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const& hit, @@ -47,7 +48,7 @@ class TkClonerImpl final : public TkCloner { TrajectoryStateOnSurface const& tsos) const override; TrackingRecHit::ConstRecHitPointer makeShared(Phase2TrackerRecHit1D const& hit, TrajectoryStateOnSurface const& tsos) const override; - + TrackingRecHit::ConstRecHitPointer makeShared(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const override; // project either mono or stero hit... std::unique_ptr project(SiStripMatchedRecHit2D const& hit, bool mono, diff --git a/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc b/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc index 84908be991070..9c19f5c63f05a 100644 --- a/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc +++ b/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc @@ -5,6 +5,7 @@ #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" #include "RecoLocalTracker/Records/interface/TrackerCPERecord.h" +#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h" diff --git a/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc b/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc index b8c2b24f19888..9d729a1a1973e 100644 --- a/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc +++ b/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc @@ -6,6 +6,7 @@ #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h" #include "DataFormats/TrackerRecHit2D/interface/Phase2TrackerRecHit1D.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" @@ -56,6 +57,10 @@ std::unique_ptr TkClonerImpl::operator()(Phase2TrackerRec return std::make_unique(params.first, params.second, *hit.det(), hit.cluster()); } +std::unique_ptr TkClonerImpl::operator()(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const { + return std::unique_ptr{new VectorHit(hit)}; +} + TrackingRecHit::ConstRecHitPointer TkClonerImpl::makeShared(SiPixelRecHit const& hit, TrajectoryStateOnSurface const& tsos) const { // std::cout << "cloning " << typeid(hit).name() << std::endl; @@ -92,6 +97,10 @@ TrackingRecHit::ConstRecHitPointer TkClonerImpl::makeShared(Phase2TrackerRecHit1 return std::make_unique(params.first, params.second, *hit.det(), hit.cluster()); } +TrackingRecHit::ConstRecHitPointer TkClonerImpl::makeShared(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const { + return std::make_shared(hit); +} + namespace { #undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitProj #undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitLGL diff --git a/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc b/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc index f22a5c69e4352..fcc5ab60b3e26 100644 --- a/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc +++ b/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc @@ -5,6 +5,13 @@ #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h" +#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h" +#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h" +#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h" +#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h" +#include "DataFormats/TrackerRecHit2D/interface/Phase2TrackerRecHit1D.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "DataFormats/SiStripDetId/interface/SiStripDetId.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/Math/interface/deltaR.h" @@ -800,7 +807,7 @@ double QuickTrackAssociatorByHitsImpl::weightedNumberOfTrackClusters(iter begin, weightedClusters += weight; } } - LogTrace("QuickTrackAssociatorByHitsImpl") << " total weighted clusters: " << weightedClusters; + LogTrace("QuickTrackAssociatorByHitsImpl") << " total weighted clusters: " << weightedClusters; return weightedClusters; } From 9643a44fd81636ad8b7279555ce55cd86ff2426a Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Tue, 1 Oct 2019 18:20:06 +0200 Subject: [PATCH 002/115] fixes after review by Mia --- .../TrackerRecHit2D/interface/VectorHit.h | 5 +-- .../TrackerRecHit2D/interface/VectorHit2D.h | 1 - DataFormats/TrackerRecHit2D/src/VectorHit.cc | 41 +++---------------- .../src/VectorHitBuilderAlgorithmBase.cc | 17 -------- 4 files changed, 7 insertions(+), 57 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 693e332611e51..6b60a684c205c 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -108,9 +108,6 @@ class VectorHit GCC11_FINAL : public BaseTrackerRecHit { /// The projection matrix relates the trajectory state parameters to the segment parameters(). virtual AlgebraicMatrix projectionMatrix() const override; - // Degrees of freedom of the segment fit - virtual int degreesOfFreedom() const { return 0; } //number of hits (2+2) - dimension - // Access to component RecHits (if any) virtual std::vector recHits() const override; virtual std::vector recHits() override ; @@ -149,7 +146,7 @@ class VectorHit GCC11_FINAL : public BaseTrackerRecHit { inline bool operator<( const VectorHit& one, const VectorHit& other) { - if ( one.chi2() > other.chi2() ) { + if ( one.chi2() < other.chi2() ) { return true; } diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index 91438a397746e..c20a9b5d74aa1 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -17,7 +17,6 @@ class VectorHit2D { LocalError localDirectionError() const { return LocalError(theCovMatrix[0][0],theCovMatrix[0][1],theCovMatrix[1][1]); } AlgebraicSymMatrix22 covMatrix() const { return theCovMatrix; } double chi2() const { return theChi2; } - int degreesOfFreedom() const { return 0; } //number of hits (2) - dimension int dimension() const { return 2; } private: diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 83ebea20d2b11..09fce92d3bac7 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -179,9 +179,9 @@ Global3DVector VectorHit::globalDirection() const { std::pair VectorHit::curvatureORphi(std::string curvORphi) const { - double curvature = 0.0; - double errorCurvature = 0.0; - double phi = 0.0; + double curvature = -999.; + double errorCurvature = -999.; + double phi = -999.; //global pos and errors Global3DPoint gPositionLower = lowerGlobalPos(); @@ -361,38 +361,9 @@ float VectorHit::theta(){ } AlgebraicMatrix VectorHit::projectionMatrix() const { - -// static bool isInitialized=false; + // obsolete (for what tracker is concerned...) interface static AlgebraicMatrix the4DProjectionMatrix(4, 5, 0); -/* - static AlgebraicMatrix the2DPhiProjMatrix(2, 5, 0); - static AlgebraicMatrix the2DZProjMatrix(2, 5, 0); - - if (!isInitialized) { - the4DProjectionMatrix[0][1] = 1; - the4DProjectionMatrix[1][2] = 1; - the4DProjectionMatrix[2][3] = 1; - the4DProjectionMatrix[3][4] = 1; - - the2DPhiProjMatrix[0][1] = 1; - the2DPhiProjMatrix[1][3] = 1; - - the2DZProjMatrix[0][2] = 1; - the2DZProjMatrix[1][4] = 1; - - isInitialized= true; - } - - if (dimension()==4) { - return the4DProjectionMatrix; - } else if (theProjection==phi) { - return the2DPhiProjMatrix; - } else if (theProjection==Z) { - return the2DZProjMatrix; - } else { - return AlgebraicMatrix(); - } -*/ return the4DProjectionMatrix; //ERICA:QUESTO NON ESISTEVA!! + return the4DProjectionMatrix; } @@ -428,7 +399,7 @@ std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { //" Vectorhit theta : " << vh.theta() << "\n" << //" Cov: " << vh.parametersError() << "\n" << //" Dim: " << vh.dimension() << "\n" << - //" chi2/ndof: " << vh.chi2() << "/" << vh.degreesOfFreedom() << "\n" << + //" chi2: " << vh.chi2() << "\n" << " Lower cluster global position : " << vh.lowerGlobalPos() << "\n" << " Upper cluster global position : " << vh.upperGlobalPos(); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index df42069d3adf5..864be497f603d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -2,7 +2,6 @@ #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" -#include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" #include "Geometry/CommonTopologies/interface/PixelTopology.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" @@ -17,22 +16,6 @@ VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase(const edm::Paramete void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) { - //FIXME:ask Vincenzo - /* - uint32_t tk_cache_id = es.get().cacheIdentifier(); - uint32_t c_cache_id = es.get().cacheIdentifier(); - - if(tk_cache_id != tracker_cache_id) { - es.get().get(tracker); - tracker_cache_id = tk_cache_id; - } - if(c_cache_id != cpe_cache_id) { - es.get().get(matcherTag, matcher); - es.get().get(cpeTag, cpe); - cpe_cache_id = c_cache_id; - } - */ - // get the geometry and topology edm::ESHandle< TrackerGeometry > geomHandle; es.get< TrackerDigiGeometryRecord >().get( geomHandle ); From 3bc0dde9888d8cd54aa184e5c46c941592016e69 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Tue, 1 Oct 2019 20:39:49 +0200 Subject: [PATCH 003/115] apply code checks --- CommonTools/RecoAlgos/src/ClusterStorer.cc | 2 +- .../interface/BaseTrackerRecHit.h | 7 +- .../TrackerRecHit2D/interface/TkCloner.h | 5 +- .../TrackerRecHit2D/interface/VectorHit.h | 96 +- .../TrackerRecHit2D/interface/VectorHit2D.h | 23 +- .../interface/trackerHitRTTI.h | 2 +- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 415 +++---- DataFormats/TrackerRecHit2D/src/classes.h | 251 ++-- .../interface/VectorHitBuilderAlgorithm.h | 101 +- .../interface/VectorHitBuilderAlgorithmBase.h | 58 +- .../interface/VectorHitBuilderEDProducer.h | 31 +- .../plugins/SealModules.cc | 1 - .../SiPhase2RecHitMatcherESProducer.cc | 18 +- .../plugins/SiPhase2RecHitMatcherESProducer.h | 11 +- .../src/VectorHitBuilderAlgorithm.cc | 339 +++--- .../src/VectorHitBuilderAlgorithmBase.cc | 96 +- .../src/VectorHitBuilderEDProducer.cc | 100 +- .../test/ClustersValidationTGraph.cc | 793 +++++++------ .../test/VectorHitsValidation.cc | 1010 +++++++++-------- .../test/VectorHitsValidation.h | 170 +-- .../src/SeedClusterRemoverPhase2.cc | 37 +- .../src/TrackClusterRemoverPhase2.cc | 21 +- RecoTracker/CkfPattern/src/PrintoutHelper.cc | 13 +- .../plugins/TrackerRecoGeometryESProducer.cc | 8 +- .../MeasurementTrackerEventProducer.cc | 1 - .../plugins/MeasurementTrackerImpl.cc | 4 +- .../plugins/MeasurementTrackerImpl.h | 2 +- .../plugins/TkStackMeasurementDet.cc | 110 +- .../plugins/TkStackMeasurementDet.h | 11 +- .../MeasurementDet/src/TkMeasurementDetSet.h | 9 +- .../Record/interface/CkfComponentsRecord.h | 1 - .../interface/GeometricSearchTrackerBuilder.h | 6 +- .../src/GeometricSearchTrackerBuilder.cc | 32 +- .../src/Phase2EndcapLayerBuilder.cc | 17 +- .../src/Phase2EndcapLayerBuilder.h | 4 +- .../src/Phase2EndcapRingBuilder.cc | 9 +- .../src/Phase2OTBarrelLayerBuilder.cc | 37 +- .../src/Phase2OTBarrelLayerBuilder.h | 6 +- .../TkDetLayers/src/Phase2OTBarrelRod.cc | 15 +- .../TkDetLayers/src/Phase2OTBarrelRod.h | 3 +- .../src/Phase2OTBarrelRodBuilder.cc | 108 +- .../src/Phase2OTBarrelRodBuilder.h | 6 +- .../interface/SeedingOTEDProducer.h | 45 +- .../src/SeedingOTEDProducer.cc | 269 ++--- .../TkSeedingLayers/src/HitExtractorSTRP.cc | 540 +++++---- .../TkSeedingLayers/src/HitExtractorSTRP.h | 8 +- .../interface/TkClonerImpl.h | 5 +- .../src/TkClonerImpl.cc | 5 +- 48 files changed, 2577 insertions(+), 2284 deletions(-) diff --git a/CommonTools/RecoAlgos/src/ClusterStorer.cc b/CommonTools/RecoAlgos/src/ClusterStorer.cc index 820837d660ab1..e015446c7d5be 100644 --- a/CommonTools/RecoAlgos/src/ClusterStorer.cc +++ b/CommonTools/RecoAlgos/src/ClusterStorer.cc @@ -51,7 +51,7 @@ namespace helper { } else if (hit_type == typeid(VectorHit)) { //FIXME:: this is just temporary solution for phase2, //the VectorHit has 2 clusters but just a hit! - phase2OTClusterRecords_.push_back(Phase2OTClusterHitRecord(static_cast(newHit), hits, index)); + phase2OTClusterRecords_.push_back(Phase2OTClusterHitRecord(static_cast(newHit), hits, index)); } else { if (hit_type == typeid(FastTrackerRecHit) || hit_type == typeid(FastProjectedTrackerRecHit) || hit_type == typeid(FastMatchedTrackerRecHit)) { diff --git a/DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h b/DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h index 79a8fdfe4d2bc..3b55cce07b2ea 100644 --- a/DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h +++ b/DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h @@ -23,7 +23,8 @@ class BaseTrackerRecHit : public TrackingRecHit { // no position (as in persistent) BaseTrackerRecHit(DetId id, trackerHitRTTI::RTTI rt) : TrackingRecHit(id, (unsigned int)(rt)), qualWord_(0) {} - BaseTrackerRecHit(const GeomDet & idet, trackerHitRTTI::RTTI rt) : TrackingRecHit(idet,(unsigned int)(rt)),qualWord_(0) {} + BaseTrackerRecHit(const GeomDet& idet, trackerHitRTTI::RTTI rt) + : TrackingRecHit(idet, (unsigned int)(rt)), qualWord_(0) {} BaseTrackerRecHit(const LocalPoint& p, const LocalError& e, GeomDet const& idet, trackerHitRTTI::RTTI rt) : TrackingRecHit(idet, (unsigned int)(rt)), pos_(p), err_(e), qualWord_(0) { @@ -52,12 +53,12 @@ class BaseTrackerRecHit : public TrackingRecHit { bool hasPositionAndError() const override; - LocalPoint localPosition() const override{ + LocalPoint localPosition() const override { check(); return pos_; } - LocalError localPositionError() const override{ + LocalError localPositionError() const override { check(); return err_; } diff --git a/DataFormats/TrackerRecHit2D/interface/TkCloner.h b/DataFormats/TrackerRecHit2D/interface/TkCloner.h index 81412962b97e6..cc98baef4ae8c 100644 --- a/DataFormats/TrackerRecHit2D/interface/TkCloner.h +++ b/DataFormats/TrackerRecHit2D/interface/TkCloner.h @@ -40,7 +40,7 @@ class TkCloner { TrajectoryStateOnSurface const& tsos) const = 0; virtual std::unique_ptr operator()(Phase2TrackerRecHit1D const& hit, TrajectoryStateOnSurface const& tsos) const = 0; - virtual std::unique_ptr operator()(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const=0; + virtual std::unique_ptr operator()(VectorHit const& hit, TrajectoryStateOnSurface const& tsos) const = 0; #ifndef __GCCXML__ virtual TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const& hit, @@ -55,7 +55,8 @@ class TkCloner { TrajectoryStateOnSurface const& tsos) const = 0; virtual TrackingRecHit::ConstRecHitPointer makeShared(Phase2TrackerRecHit1D const& hit, TrajectoryStateOnSurface const& tsos) const = 0; - virtual TrackingRecHit::ConstRecHitPointer makeShared(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const=0; + virtual TrackingRecHit::ConstRecHitPointer makeShared(VectorHit const& hit, + TrajectoryStateOnSurface const& tsos) const = 0; #endif }; #endif diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 6b60a684c205c..83ed6e7b57a15 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -27,58 +27,62 @@ #include "TkCloner.h" class VectorHit GCC11_FINAL : public BaseTrackerRecHit { - - public: - +public: typedef OmniClusterRef::Phase2Cluster1DRef ClusterRef; VectorHit() : thePosition(), theDirection(), theCovMatrix(), theDimension(0) { setType(bad); } - VectorHit(const VectorHit& vh) ; + VectorHit(const VectorHit& vh); - VectorHit(const GeomDet& idet, const LocalPoint& posInner, const LocalVector& dir, - const AlgebraicSymMatrix& covMatrix, const double& Chi2, - OmniClusterRef const& lower, OmniClusterRef const& upper) ; + VectorHit(const GeomDet& idet, + const LocalPoint& posInner, + const LocalVector& dir, + const AlgebraicSymMatrix& covMatrix, + const double& Chi2, + OmniClusterRef const& lower, + OmniClusterRef const& upper); - VectorHit(const GeomDet& idet, const VectorHit2D& vh2Dzx, const VectorHit2D& vh2Dzy, - OmniClusterRef const& lower, OmniClusterRef const& upper) ; + VectorHit(const GeomDet& idet, + const VectorHit2D& vh2Dzx, + const VectorHit2D& vh2Dzy, + OmniClusterRef const& lower, + OmniClusterRef const& upper); - ~VectorHit() ; + ~VectorHit() override; - virtual VectorHit* clone() const override { return new VectorHit(*this);} + VectorHit* clone() const override { return new VectorHit(*this); } #ifndef __GCCXML__ - virtual RecHitPointer cloneSH() const override { return std::make_shared(*this);} + RecHitPointer cloneSH() const override { return std::make_shared(*this); } #endif - virtual bool sharesInput( const TrackingRecHit* other, SharedInputType what) const override; - bool sharesClusters(VectorHit const & h1, VectorHit const & h2, - SharedInputType what) const ; + bool sharesInput(const TrackingRecHit* other, SharedInputType what) const override; + bool sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedInputType what) const; // Parameters of the segment, for the track fit // For a 4D segment: (dx/dz,dy/dz,x,y) - bool hasPositionAndError() const GCC11_FINAL{ - //bool hasPositionAndError() const { + bool hasPositionAndError() const GCC11_FINAL { + //bool hasPositionAndError() const { return true; -// return (err_.xx() != 0) || (err_.yy() != 0) || (err_.xy() != 0) || -// (pos_.x() != 0) || (pos_.y() != 0) || (pos_.z() != 0); + // return (err_.xx() != 0) || (err_.yy() != 0) || (err_.xy() != 0) || + // (pos_.x() != 0) || (pos_.y() != 0) || (pos_.z() != 0); }; - virtual AlgebraicVector parameters() const override; - virtual void getKfComponents( KfComponentsHolder & holder ) const override { getKfComponents4D(holder); } - void getKfComponents4D( KfComponentsHolder & holder ) const ; + AlgebraicVector parameters() const override; + void getKfComponents(KfComponentsHolder& holder) const override { getKfComponents4D(holder); } + void getKfComponents4D(KfComponentsHolder& holder) const; // returning methods LocalPoint localPosition() const GCC11_FINAL { return thePosition; } virtual LocalVector localDirection() const { return theDirection; } - AlgebraicSymMatrix parametersError() const override ; - LocalError localPositionError() const GCC11_FINAL ; - virtual LocalError localDirectionError() const ; + AlgebraicSymMatrix parametersError() const override; + LocalError localPositionError() const GCC11_FINAL; + virtual LocalError localDirectionError() const; Global3DVector globalDirection() const; virtual double chi2() const { return theChi2; } - virtual int dimension() const override { return theDimension; } + int dimension() const override { return theDimension; } - std::pair curvatureORphi(std::string curvORphi = "curvature") const ; + std::pair curvatureORphi(std::string curvORphi = "curvature") const; float transverseMomentum(const MagneticField* magField); float momentum(const MagneticField* magField); @@ -88,42 +92,42 @@ class VectorHit GCC11_FINAL : public BaseTrackerRecHit { OmniClusterRef const upperClusterRef() const { return theUpperCluster; } //FIXME::to update with a proper CPE maybe... - Global3DPoint lowerGlobalPos() const ; - Global3DPoint upperGlobalPos() const ; + Global3DPoint lowerGlobalPos() const; + Global3DPoint upperGlobalPos() const; Global3DPoint phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster) const; - GlobalError lowerGlobalPosErr() const ; - GlobalError upperGlobalPosErr() const ; + GlobalError lowerGlobalPosErr() const; + GlobalError upperGlobalPosErr() const; GlobalError phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet) const; - virtual bool isPhase2() const override { return true; } + bool isPhase2() const override { return true; } //FIXME: I have always two clusters in a VH - virtual OmniClusterRef const & firstClusterRef() const GCC11_FINAL { return theLowerCluster;} - ClusterRef cluster() const { return theLowerCluster.cluster_phase2OT(); } + OmniClusterRef const& firstClusterRef() const GCC11_FINAL { return theLowerCluster; } + ClusterRef cluster() const { return theLowerCluster.cluster_phase2OT(); } //This method returns the delta in global coordinates Global3DVector globalDelta() const; float theta(); /// The projection matrix relates the trajectory state parameters to the segment parameters(). - virtual AlgebraicMatrix projectionMatrix() const override; + AlgebraicMatrix projectionMatrix() const override; // Access to component RecHits (if any) - virtual std::vector recHits() const override; - virtual std::vector recHits() override ; + std::vector recHits() const override; + std::vector recHits() override; // setting methods void setPosition(LocalPoint pos) { thePosition = pos; } void setDirection(LocalVector dir) { theDirection = dir; } void setCovMatrix(AlgebraicSymMatrix mat) { theCovMatrix = mat; } - private: +private: // double dispatch - virtual VectorHit * clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override{ - return cloner(*this,tsos).release(); + VectorHit* clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override { + return cloner(*this, tsos).release(); } - virtual RecHitPointer cloneSH_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override{ - return cloner.makeShared(*this,tsos); + RecHitPointer cloneSH_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override { + return cloner.makeShared(*this, tsos); } LocalPoint thePosition; @@ -141,12 +145,10 @@ class VectorHit GCC11_FINAL : public BaseTrackerRecHit { int theDimension; OmniClusterRef theLowerCluster; OmniClusterRef theUpperCluster; - }; -inline bool operator<( const VectorHit& one, const VectorHit& other) { - - if ( one.chi2() < other.chi2() ) { +inline bool operator<(const VectorHit& one, const VectorHit& other) { + if (one.chi2() < other.chi2()) { return true; } @@ -156,6 +158,6 @@ inline bool operator<( const VectorHit& one, const VectorHit& other) { std::ostream& operator<<(std::ostream& os, const VectorHit& vh); typedef edmNew::DetSetVector VectorHitCollection; -typedef VectorHitCollection VectorHitCollectionNew; +typedef VectorHitCollection VectorHitCollectionNew; #endif diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index c20a9b5d74aa1..7bc0d8eb1c098 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -3,29 +3,28 @@ #include "DataFormats/GeometryVector/interface/LocalVector.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" - -class VectorHit2D { - public: +class VectorHit2D { +public: VectorHit2D() : thePosition(), theDirection(), theCovMatrix(), theChi2(), theDimension(2) {} - VectorHit2D(const LocalPoint& pos, const LocalVector& dir, const AlgebraicSymMatrix22& covMatrix, const double& Chi2) : - thePosition(pos), theDirection(dir), theCovMatrix(covMatrix), theChi2(Chi2), theDimension(2){}; - virtual ~VectorHit2D() {}; + VectorHit2D(const LocalPoint& pos, const LocalVector& dir, const AlgebraicSymMatrix22& covMatrix, const double& Chi2) + : thePosition(pos), theDirection(dir), theCovMatrix(covMatrix), theChi2(Chi2), theDimension(2){}; + virtual ~VectorHit2D(){}; LocalPoint localPosition() const { return thePosition; } LocalVector localDirection() const { return theDirection; } - LocalError localDirectionError() const { return LocalError(theCovMatrix[0][0],theCovMatrix[0][1],theCovMatrix[1][1]); } + LocalError localDirectionError() const { + return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); + } AlgebraicSymMatrix22 covMatrix() const { return theCovMatrix; } - double chi2() const { return theChi2; } + double chi2() const { return theChi2; } int dimension() const { return 2; } - private: +private: LocalPoint thePosition; LocalVector theDirection; AlgebraicSymMatrix22 theCovMatrix; double theChi2; int theDimension; - }; -#endif - +#endif diff --git a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h index 6268b68ca0d8b..db8579d0db982 100644 --- a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h +++ b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h @@ -37,7 +37,7 @@ namespace trackerHitRTTI { inline bool isFast(TrackingRecHit const& hit) { return (rtti(hit) > 5) & (rtti(hit) <= 9); } inline bool isFromDetOrFast(TrackingRecHit const& hit) { return (rtti(hit) > 0) & (rtti(hit) < 10); } inline bool isTiming(TrackingRecHit const& hit) { return rtti(hit) == mipTiming; } - inline bool isVector(TrackingRecHit const & hit) { return rtti(hit)==vector;} + inline bool isVector(TrackingRecHit const& hit) { return rtti(hit) == vector; } inline unsigned int projId(TrackingRecHit const& hit) { return hit.rawId() + int(rtti(hit)) - 1; } } // namespace trackerHitRTTI diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 09fce92d3bac7..307d2afae51d7 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -1,40 +1,38 @@ #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "Geometry/TrackerGeometryBuilder/interface/StackGeomDet.h" -VectorHit::VectorHit(const VectorHit& vh): - BaseTrackerRecHit(*vh.det(), trackerHitRTTI::vector), - thePosition(vh.localPosition()), - theDirection(vh.localDirection()), - theCovMatrix(vh.parametersError()), - theChi2(vh.chi2()), - theDimension(vh.dimension()), - theLowerCluster(vh.lowerClusterRef()), - theUpperCluster(vh.upperClusterRef()) -{} +VectorHit::VectorHit(const VectorHit& vh) + : BaseTrackerRecHit(*vh.det(), trackerHitRTTI::vector), + thePosition(vh.localPosition()), + theDirection(vh.localDirection()), + theCovMatrix(vh.parametersError()), + theChi2(vh.chi2()), + theDimension(vh.dimension()), + theLowerCluster(vh.lowerClusterRef()), + theUpperCluster(vh.upperClusterRef()) {} VectorHit::VectorHit(const GeomDet& idet, const LocalPoint& posLower, const LocalVector& dir, const AlgebraicSymMatrix& covMatrix, - const double& Chi2, - OmniClusterRef const& lower, OmniClusterRef const& upper) : - BaseTrackerRecHit(idet, trackerHitRTTI::vector), - thePosition(posLower), - theDirection(dir), - theCovMatrix(covMatrix), - theChi2(Chi2), - theDimension(4), - theLowerCluster(lower), - theUpperCluster(upper) -{} - -VectorHit::VectorHit(const GeomDet& idet, const VectorHit2D& vh2Dzx, const VectorHit2D& vh2Dzy, - OmniClusterRef const& lower, OmniClusterRef const& upper) : - BaseTrackerRecHit(idet, trackerHitRTTI::vector), - theDimension(4), - theLowerCluster(lower), - theUpperCluster(upper) -{ + const double& Chi2, + OmniClusterRef const& lower, + OmniClusterRef const& upper) + : BaseTrackerRecHit(idet, trackerHitRTTI::vector), + thePosition(posLower), + theDirection(dir), + theCovMatrix(covMatrix), + theChi2(Chi2), + theDimension(4), + theLowerCluster(lower), + theUpperCluster(upper) {} + +VectorHit::VectorHit(const GeomDet& idet, + const VectorHit2D& vh2Dzx, + const VectorHit2D& vh2Dzy, + OmniClusterRef const& lower, + OmniClusterRef const& upper) + : BaseTrackerRecHit(idet, trackerHitRTTI::vector), theDimension(4), theLowerCluster(lower), theUpperCluster(upper) { thePosition = LocalPoint(vh2Dzx.localPosition().x(), vh2Dzy.localPosition().x(), 0.); theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), 1.); @@ -45,140 +43,134 @@ VectorHit::VectorHit(const GeomDet& idet, const VectorHit2D& vh2Dzx, const Vecto AlgebraicSymMatrix22 covMatZX = vh2Dzx.covMatrix(); AlgebraicSymMatrix22 covMatZY = vh2Dzy.covMatrix(); - theCovMatrix=AlgebraicSymMatrix(4); - theCovMatrix[0][0] = covMatZX[0][0]; // var(dx/dz) - theCovMatrix[1][1] = covMatZY[0][0]; // var(dy/dz) - theCovMatrix[2][2] = covMatZX[1][1]; // var(x) - theCovMatrix[3][3] = covMatZY[1][1]; // var(y) - theCovMatrix[0][2] = covMatZX[0][1]; // cov(dx/dz,x) - theCovMatrix[1][3] = covMatZY[0][1]; // cov(dy/dz,y) + theCovMatrix = AlgebraicSymMatrix(4); + theCovMatrix[0][0] = covMatZX[0][0]; // var(dx/dz) + theCovMatrix[1][1] = covMatZY[0][0]; // var(dy/dz) + theCovMatrix[2][2] = covMatZX[1][1]; // var(x) + theCovMatrix[3][3] = covMatZY[1][1]; // var(y) + theCovMatrix[0][2] = covMatZX[0][1]; // cov(dx/dz,x) + theCovMatrix[1][3] = covMatZY[0][1]; // cov(dy/dz,y) theChi2 = vh2Dzx.chi2() + vh2Dzy.chi2(); } -bool VectorHit::sharesInput( const TrackingRecHit* other, SharedInputType what) const -{ - if (what==all && (geographicalId() != other->geographicalId())) return false; - - if (!sameDetModule(*other)) return false; +bool VectorHit::sharesInput(const TrackingRecHit* other, SharedInputType what) const { + if (what == all && (geographicalId() != other->geographicalId())) + return false; - if (trackerHitRTTI::isVector(*other) ) { + if (!sameDetModule(*other)) + return false; + + if (trackerHitRTTI::isVector(*other)) { const VectorHit* otherVh = static_cast(other); return sharesClusters(*this, *otherVh, what); } - - if (what==all) return false; + + if (what == all) + return false; // what about multi??? - auto const & otherClus = reinterpret_cast(other)->firstClusterRef(); - return (otherClus==lowerClusterRef()) || (otherClus==upperClusterRef()); - + auto const& otherClus = reinterpret_cast(other)->firstClusterRef(); + return (otherClus == lowerClusterRef()) || (otherClus == upperClusterRef()); } -bool VectorHit::sharesClusters(VectorHit const & h1, VectorHit const & h2, - SharedInputType what) const { - bool lower = h1.lowerClusterRef()== h2.lowerClusterRef(); - bool upper = h1.upperClusterRef()== h2.upperClusterRef(); - - return (what==TrackingRecHit::all) ? (lower && upper) : (upper||lower); - -} +bool VectorHit::sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedInputType what) const { + bool lower = h1.lowerClusterRef() == h2.lowerClusterRef(); + bool upper = h1.upperClusterRef() == h2.upperClusterRef(); -void VectorHit::getKfComponents4D( KfComponentsHolder & holder ) const { + return (what == TrackingRecHit::all) ? (lower && upper) : (upper || lower); +} + +void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const { //if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents"); - AlgebraicVector4 & pars = holder.params<4>(); + AlgebraicVector4& pars = holder.params<4>(); pars[0] = theDirection.x(); pars[1] = theDirection.y(); pars[2] = thePosition.x(); pars[3] = thePosition.y(); - AlgebraicSymMatrix44 & errs = holder.errors<4>(); - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 4; j++){ - errs(i,j) = theCovMatrix[i][j]; + AlgebraicSymMatrix44& errs = holder.errors<4>(); + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + errs(i, j) = theCovMatrix[i][j]; } } - ProjectMatrix & pf = holder.projFunc<4>(); + ProjectMatrix& pf = holder.projFunc<4>(); pf.index[0] = 1; pf.index[1] = 2; pf.index[2] = 3; pf.index[3] = 4; - holder.measuredParams<4>() = AlgebraicVector4( & holder.tsosLocalParameters().At(1), 4 ); - holder.measuredErrors<4>() = holder.tsosLocalErrors().Sub( 1, 1 ); - + holder.measuredParams<4>() = AlgebraicVector4(&holder.tsosLocalParameters().At(1), 4); + holder.measuredErrors<4>() = holder.tsosLocalErrors().Sub(1, 1); } VectorHit::~VectorHit() {} AlgebraicVector VectorHit::parameters() const { + // (dx/dz,dy/dz,x,y) + AlgebraicVector result(4); - // (dx/dz,dy/dz,x,y) - AlgebraicVector result(4); - - result[0] = theDirection.x(); - result[1] = theDirection.y(); - result[2] = thePosition.x(); - result[3] = thePosition.y(); - return result; - + result[0] = theDirection.x(); + result[1] = theDirection.y(); + result[2] = thePosition.x(); + result[3] = thePosition.y(); + return result; } Global3DPoint VectorHit::lowerGlobalPos() const { - const StackGeomDet* stackDet = dynamic_cast< const StackGeomDet* >(det()); - const PixelGeomDetUnit* geomDetLower = dynamic_cast< const PixelGeomDetUnit* >(stackDet->lowerDet()); + const StackGeomDet* stackDet = dynamic_cast(det()); + const PixelGeomDetUnit* geomDetLower = dynamic_cast(stackDet->lowerDet()); return phase2clusterGlobalPos(geomDetLower, lowerCluster()); } Global3DPoint VectorHit::upperGlobalPos() const { - const StackGeomDet* stackDet = dynamic_cast< const StackGeomDet* >(det()); - const PixelGeomDetUnit* geomDetUpper = dynamic_cast< const PixelGeomDetUnit* >(stackDet->upperDet()); + const StackGeomDet* stackDet = dynamic_cast(det()); + const PixelGeomDetUnit* geomDetUpper = dynamic_cast(stackDet->upperDet()); return phase2clusterGlobalPos(geomDetUpper, upperCluster()); } Global3DPoint VectorHit::phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster) const { - const PixelTopology * topo = &geomDet->specificTopology(); + const PixelTopology* topo = &geomDet->specificTopology(); float ix = cluster->center(); - float iy = cluster->column()+0.5; // halfway the column - LocalPoint lp( topo->localX(ix), topo->localY(iy), 0 ); // x, y, z + float iy = cluster->column() + 0.5; // halfway the column + LocalPoint lp(topo->localX(ix), topo->localY(iy), 0); // x, y, z Global3DPoint gp = geomDet->surface().toGlobal(lp); return gp; } GlobalError VectorHit::lowerGlobalPosErr() const { - const StackGeomDet* stackDet = dynamic_cast< const StackGeomDet* >(det()); - const PixelGeomDetUnit* geomDetLower = dynamic_cast< const PixelGeomDetUnit* >(stackDet->lowerDet()); + const StackGeomDet* stackDet = dynamic_cast(det()); + const PixelGeomDetUnit* geomDetLower = dynamic_cast(stackDet->lowerDet()); return phase2clusterGlobalPosErr(geomDetLower); } GlobalError VectorHit::upperGlobalPosErr() const { - const StackGeomDet* stackDet = dynamic_cast< const StackGeomDet* >(det()); - const PixelGeomDetUnit* geomDetUpper = dynamic_cast< const PixelGeomDetUnit* >(stackDet->upperDet()); + const StackGeomDet* stackDet = dynamic_cast(det()); + const PixelGeomDetUnit* geomDetUpper = dynamic_cast(stackDet->upperDet()); return phase2clusterGlobalPosErr(geomDetUpper); } GlobalError VectorHit::phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet) const { - const PixelTopology * topo = &geomDet->specificTopology(); + const PixelTopology* topo = &geomDet->specificTopology(); float pitchX = topo->pitch().first; float pitchY = topo->pitch().second; - LocalError le( pow(pitchX, 2) / 12., 0, pow(pitchY, 2) / 12.); // e2_xx, e2_xy, e2_yy - GlobalError ge( ErrorFrameTransformer().transform( le, geomDet->surface() )); + LocalError le(pow(pitchX, 2) / 12., 0, pow(pitchY, 2) / 12.); // e2_xx, e2_xy, e2_yy + GlobalError ge(ErrorFrameTransformer().transform(le, geomDet->surface())); return ge; } Global3DVector VectorHit::globalDelta() const { - Local3DVector theLocalDelta = LocalVector(theDirection.x()*theDirection.z(), theDirection.y()*theDirection.z(), theDirection.z()); + Local3DVector theLocalDelta = + LocalVector(theDirection.x() * theDirection.z(), theDirection.y() * theDirection.z(), theDirection.z()); Global3DVector g = det()->surface().toGlobal(theLocalDelta); return g; } -Global3DVector VectorHit::globalDirection() const { - return (det()->surface().toGlobal(localDirection())); -} - -std::pair VectorHit::curvatureORphi(std::string curvORphi) const { +Global3DVector VectorHit::globalDirection() const { return (det()->surface().toGlobal(localDirection())); } +std::pair VectorHit::curvatureORphi(std::string curvORphi) const { double curvature = -999.; double errorCurvature = -999.; double phi = -999.; @@ -191,126 +183,148 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const GlobalError gErrorUpper = upperGlobalPosErr(); //insert lower and upper in the global sor - if(gPositionLower.perp() > gPositionUpper.perp()){ + if (gPositionLower.perp() > gPositionUpper.perp()) { gPositionLower = upperGlobalPos(); gPositionUpper = lowerGlobalPos(); gErrorLower = upperGlobalPosErr(); gErrorUpper = lowerGlobalPosErr(); } - double h1 = gPositionLower.x()*gPositionUpper.y() - gPositionUpper.x()*gPositionLower.y(); + double h1 = gPositionLower.x() * gPositionUpper.y() - gPositionUpper.x() * gPositionLower.y(); //determine sign of curvature AlgebraicVector2 n1; n1[0] = -gPositionLower.y(); n1[1] = gPositionLower.x(); AlgebraicVector2 n2; - n2[0] = gPositionUpper.x()-gPositionLower.x(); - n2[1] = gPositionUpper.y()-gPositionLower.y(); - - double n3 = n1[0]*n2[0] + n1[1]*n2[1]; - double signCurv = -copysign(1.0,n3); - double phi1 = atan2(gPositionUpper.y()-gPositionLower.y(),gPositionUpper.x()-gPositionLower.x()); - - if(h1!=0) { - double h2 = 2*h1; - double r12 = pow(gPositionLower.x(),2) + pow(gPositionLower.y(),2); - double r22 = pow(gPositionUpper.x(),2) + pow(gPositionUpper.y(),2); - double h3 = (pow(gPositionLower.x(),2) - 2.*gPositionLower.x()*gPositionUpper.x() + pow(gPositionUpper.x(),2) + pow(gPositionLower.y(),2) - 2.*gPositionLower.y()*gPositionUpper.y() + pow(gPositionUpper.y(),2)); - double h4 = - pow(gPositionLower.x(),2)*gPositionUpper.x() + gPositionLower.x()*pow(gPositionUpper.x(),2) - + gPositionLower.x()*pow(gPositionUpper.y(),2) - gPositionUpper.x()*pow(gPositionLower.y(),2); - double h5 = pow(gPositionLower.x(),2)*gPositionUpper.y() - pow(gPositionUpper.x(),2)*gPositionLower.y() - + pow(gPositionLower.y(),2)*gPositionUpper.y() - gPositionLower.y()*pow(gPositionUpper.y(),2); + n2[0] = gPositionUpper.x() - gPositionLower.x(); + n2[1] = gPositionUpper.y() - gPositionLower.y(); + + double n3 = n1[0] * n2[0] + n1[1] * n2[1]; + double signCurv = -copysign(1.0, n3); + double phi1 = atan2(gPositionUpper.y() - gPositionLower.y(), gPositionUpper.x() - gPositionLower.x()); + + if (h1 != 0) { + double h2 = 2 * h1; + double r12 = pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2); + double r22 = pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2); + double h3 = + (pow(gPositionLower.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.x(), 2) + + pow(gPositionLower.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y() + pow(gPositionUpper.y(), 2)); + double h4 = -pow(gPositionLower.x(), 2) * gPositionUpper.x() + gPositionLower.x() * pow(gPositionUpper.x(), 2) + + gPositionLower.x() * pow(gPositionUpper.y(), 2) - gPositionUpper.x() * pow(gPositionLower.y(), 2); + double h5 = pow(gPositionLower.x(), 2) * gPositionUpper.y() - pow(gPositionUpper.x(), 2) * gPositionLower.y() + + pow(gPositionLower.y(), 2) * gPositionUpper.y() - gPositionLower.y() * pow(gPositionUpper.y(), 2); //radius of circle - double rho = sqrt(r12*r22*h3)/(2.*h1); - curvature = 1./rho; + double rho = sqrt(r12 * r22 * h3) / (2. * h1); + curvature = 1. / rho; //center of circle - double xcentre = h5/h2; - double ycentre = h4/h2; + double xcentre = h5 / h2; + double ycentre = h4 / h2; //to compute phi at the cluster points double xtg = gPositionLower.y() - ycentre; - double ytg = -( gPositionLower.x() - xcentre); + double ytg = -(gPositionLower.x() - xcentre); //to compute phi at the origin //double xtg = ycentre; //double ytg = -(xcentre); - phi = atan2(ytg,xtg); + phi = atan2(ytg, xtg); - AlgebraicROOTObject<4,4>::Matrix jacobian; - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 4; j++){ + AlgebraicROOTObject<4, 4>::Matrix jacobian; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { jacobian[i][j] = 0.0; } } - jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 - jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 - jacobian[2][0] = (h1*(2.*gPositionLower.x()*r22*h3 + (2.*gPositionLower.x() - 2.*gPositionUpper.x())*r12*r22))/(pow(r12*r22*h3,1.5)) - - (2.*gPositionUpper.y())/sqrt(r12*r22*h3); // dkappa/dx1 - jacobian[2][1] = (2.*gPositionUpper.x())/sqrt(r12*r22*h3) + (h1*(2.*gPositionLower.y()*r22*h3 + r12*r22*(2.*gPositionLower.y() - - 2.*gPositionUpper.y())))/pow(r12*r22*h3,1.5); // dkappa/dy1 - jacobian[2][2] = (2.*gPositionLower.y())/sqrt(r12*r22*h3) + (h1*(2.*gPositionUpper.x()*r12*h3 - - 2.*(gPositionLower.x() - gPositionUpper.x())*r12*r22))/pow(r12*r22*h3,1.5); // dkappa/dx2 - jacobian[2][3] = (h1*(2.*gPositionUpper.y()*r12*h3 - r12*r22*2.*(gPositionLower.y() - gPositionUpper.y())))/pow(r12*r22*h3,1.5) - - (2.*gPositionLower.x())/sqrt(r12*r22*h3); // dkappa/dy2 - - for(int i = 0; i < 4; i++){ + jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 + jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 + jacobian[2][0] = + (h1 * (2. * gPositionLower.x() * r22 * h3 + (2. * gPositionLower.x() - 2. * gPositionUpper.x()) * r12 * r22)) / + (pow(r12 * r22 * h3, 1.5)) - + (2. * gPositionUpper.y()) / sqrt(r12 * r22 * h3); // dkappa/dx1 + jacobian[2][1] = + (2. * gPositionUpper.x()) / sqrt(r12 * r22 * h3) + + (h1 * (2. * gPositionLower.y() * r22 * h3 + r12 * r22 * (2. * gPositionLower.y() - 2. * gPositionUpper.y()))) / + pow(r12 * r22 * h3, 1.5); // dkappa/dy1 + jacobian[2][2] = + (2. * gPositionLower.y()) / sqrt(r12 * r22 * h3) + + (h1 * (2. * gPositionUpper.x() * r12 * h3 - 2. * (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) / + pow(r12 * r22 * h3, 1.5); // dkappa/dx2 + jacobian[2][3] = + (h1 * (2. * gPositionUpper.y() * r12 * h3 - r12 * r22 * 2. * (gPositionLower.y() - gPositionUpper.y()))) / + pow(r12 * r22 * h3, 1.5) - + (2. * gPositionLower.x()) / sqrt(r12 * r22 * h3); // dkappa/dy2 + + for (int i = 0; i < 4; i++) { jacobian[2][i] = -jacobian[2][i]; } AlgebraicVector2 M; //to compute phi at the cluster points - M[0] = (gPositionLower.y() - ycentre)/pow(rho,2); // dphi/dxcentre - M[1] =-(gPositionLower.x() - xcentre)/pow(rho,2); // dphi/dycentre + M[0] = (gPositionLower.y() - ycentre) / pow(rho, 2); // dphi/dxcentre + M[1] = -(gPositionLower.x() - xcentre) / pow(rho, 2); // dphi/dycentre //to compute phi at the origin //float x0 = 0.0; //float y0 = 0.0; //M[0] = (y0 - ycentre)/pow(rho,2); // dphi/dxcentre //M[1] =-(x0 - xcentre)/pow(rho,2); // dphi/dycentre - AlgebraicROOTObject<2,4>::Matrix K; - K[0][0]=(2.*gPositionLower.x()*gPositionUpper.y())/h2 - (2.*gPositionUpper.y()*h5)/pow(h2,2); // dxm/dx1 - K[0][1]=(2.*gPositionUpper.x()*h5)/pow(h2,2) - (pow(gPositionUpper.x(),2) + pow(gPositionUpper.y(),2) - 2.*gPositionLower.y()*gPositionUpper.y())/h2; // dxm/dy1 - K[0][2]=(2.*gPositionLower.y()*h5)/pow(h2,2) - (2.*gPositionUpper.x()*gPositionLower.y())/h2; // dxm/dx2 - K[0][3]=(pow(gPositionLower.x(),2) + pow(gPositionLower.y(),2) - 2.*gPositionUpper.y()*gPositionLower.y())/h2 - (2.*gPositionLower.x()*h5)/pow(h2,2); // dxm/dy2 - K[1][0]=(pow(gPositionUpper.x(),2) - 2.*gPositionLower.x()*gPositionUpper.x() + pow(gPositionUpper.y(),2))/h2 - (2.*gPositionUpper.y()*h4)/pow(h2,2); // dym/dx1 - K[1][1]=(2.*gPositionUpper.x()*h4)/pow(h2,2) - (2.*gPositionUpper.x()*gPositionLower.y())/h2; // dym/dy1 - K[1][2]=(2.*gPositionLower.y()*h4)/pow(h2,2) - (pow(gPositionLower.x(),2) - 2.*gPositionUpper.x()*gPositionLower.x() + pow(gPositionLower.y(),2))/h2; // dym/dx2 - K[1][3]=(2.*gPositionLower.x()*gPositionUpper.y())/h2 - (2.*gPositionLower.x()*h4)/pow(h2,2); // dym/dy2 - - AlgebraicVector4 N = M*K; - jacobian[3][0] = N[0]; // dphi/(dx1,dy1,dx2,dy2) - jacobian[3][1] = N[1]; // dphi/(dx1,dy1,dx2,dy2) - jacobian[3][2] = N[2]; // dphi/(dx1,dy1,dx2,dy2) - jacobian[3][3] = N[3]; // dphi/(dx1,dy1,dx2,dy2) + AlgebraicROOTObject<2, 4>::Matrix K; + K[0][0] = + (2. * gPositionLower.x() * gPositionUpper.y()) / h2 - (2. * gPositionUpper.y() * h5) / pow(h2, 2); // dxm/dx1 + K[0][1] = (2. * gPositionUpper.x() * h5) / pow(h2, 2) - + (pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y()) / + h2; // dxm/dy1 + K[0][2] = + (2. * gPositionLower.y() * h5) / pow(h2, 2) - (2. * gPositionUpper.x() * gPositionLower.y()) / h2; // dxm/dx2 + K[0][3] = + (pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2) - 2. * gPositionUpper.y() * gPositionLower.y()) / h2 - + (2. * gPositionLower.x() * h5) / pow(h2, 2); // dxm/dy2 + K[1][0] = + (pow(gPositionUpper.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.y(), 2)) / h2 - + (2. * gPositionUpper.y() * h4) / pow(h2, 2); // dym/dx1 + K[1][1] = + (2. * gPositionUpper.x() * h4) / pow(h2, 2) - (2. * gPositionUpper.x() * gPositionLower.y()) / h2; // dym/dy1 + K[1][2] = (2. * gPositionLower.y() * h4) / pow(h2, 2) - + (pow(gPositionLower.x(), 2) - 2. * gPositionUpper.x() * gPositionLower.x() + pow(gPositionLower.y(), 2)) / + h2; // dym/dx2 + K[1][3] = + (2. * gPositionLower.x() * gPositionUpper.y()) / h2 - (2. * gPositionLower.x() * h4) / pow(h2, 2); // dym/dy2 + + AlgebraicVector4 N = M * K; + jacobian[3][0] = N[0]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][1] = N[1]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][2] = N[2]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][3] = N[3]; // dphi/(dx1,dy1,dx2,dy2) //assign correct sign to the curvature errors - if( (signCurv < 0 && curvature > 0 ) || (signCurv > 0 && curvature < 0 )){ - curvature=-curvature; - for(int i = 0; i < 4; i++){ + if ((signCurv < 0 && curvature > 0) || (signCurv > 0 && curvature < 0)) { + curvature = -curvature; + for (int i = 0; i < 4; i++) { jacobian[2][i] = -jacobian[2][i]; } } // bring phi in the same quadrant as phi1 - if (abs(phi-phi1) > M_PI/2.){ - phi = phi+M_PI; - if (phi>M_PI) - phi=phi-2.*M_PI; + if (abs(phi - phi1) > M_PI / 2.) { + phi = phi + M_PI; + if (phi > M_PI) + phi = phi - 2. * M_PI; } //computing the curvature error AlgebraicVector4 curvatureJacobian; - for(int i = 0; i < 4; i++){ + for (int i = 0; i < 4; i++) { curvatureJacobian[i] = jacobian[2][i]; } - AlgebraicROOTObject<4,4>::Matrix gErrors; - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 4; j++){ + AlgebraicROOTObject<4, 4>::Matrix gErrors; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { gErrors[i][j] = 0.0; } } @@ -325,40 +339,36 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const gErrors[3][3] = gErrorUpper.cyy(); AlgebraicVector4 temp = curvatureJacobian; - temp = temp*gErrors; - errorCurvature = temp[0]*curvatureJacobian[0] + temp[1]*curvatureJacobian[1] + temp[2]*curvatureJacobian[2] + temp[3]*curvatureJacobian[3]; + temp = temp * gErrors; + errorCurvature = temp[0] * curvatureJacobian[0] + temp[1] * curvatureJacobian[1] + temp[2] * curvatureJacobian[2] + + temp[3] * curvatureJacobian[3]; //if(curvORphi == "curvature") std::cout << "curvature: " << curvature << std::endl; //if(curvORphi == "curvature") std::cout << "curvature error: " << errorCurvature << std::endl; - } else { -std::cout << " straight line!" << std::endl; - return std::make_pair(0.0,0.0); + std::cout << " straight line!" << std::endl; + return std::make_pair(0.0, 0.0); } - - if( curvORphi == "curvature" ) return std::make_pair(curvature,errorCurvature); - else if( curvORphi == "phi" ) return std::make_pair(phi,0.0); - else return std::make_pair(0.0,0.0); + if (curvORphi == "curvature") + return std::make_pair(curvature, errorCurvature); + else if (curvORphi == "phi") + return std::make_pair(phi, 0.0); + else + return std::make_pair(0.0, 0.0); } -float VectorHit::transverseMomentum(const MagneticField* magField){ - +float VectorHit::transverseMomentum(const MagneticField* magField) { GlobalPoint center(0.0, 0.0, 0.0); float magnT = magField->inTesla(center).mag(); - double rho = 1./curvatureORphi("curvature").first; + double rho = 1. / curvatureORphi("curvature").first; //0.003 is because the curvature (rho) is in cm and not in m - return (0.003*magnT*rho); - + return (0.003 * magnT * rho); } -float VectorHit::momentum(const MagneticField* magField){ - return transverseMomentum(magField)/(1.*sin(theta())); -} +float VectorHit::momentum(const MagneticField* magField) { return transverseMomentum(magField) / (1. * sin(theta())); } -float VectorHit::theta(){ - return globalDirection().theta(); -} +float VectorHit::theta() { return globalDirection().theta(); } AlgebraicMatrix VectorHit::projectionMatrix() const { // obsolete (for what tracker is concerned...) interface @@ -366,24 +376,19 @@ AlgebraicMatrix VectorHit::projectionMatrix() const { return the4DProjectionMatrix; } - LocalError VectorHit::localPositionError() const { - return LocalError(theCovMatrix[2][2],theCovMatrix[2][3],theCovMatrix[3][3]); + return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]); } - LocalError VectorHit::localDirectionError() const { - return LocalError(theCovMatrix[0][0],theCovMatrix[0][1],theCovMatrix[1][1]); + return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); } - - AlgebraicSymMatrix VectorHit::parametersError() const { - //think about a more efficient method AlgebraicSymMatrix result(4); - for(int i = 0; i < theDimension; i++){ - for(int j = 0; j < theDimension; j++){ + for (int i = 0; i < theDimension; i++) { + for (int j = 0; j < theDimension; j++) { result[i][j] = theCovMatrix[i][j]; } } @@ -391,33 +396,29 @@ AlgebraicSymMatrix VectorHit::parametersError() const { } std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { - - os << " VectorHit create in the DetId#: " << vh.geographicalId() << "\n" << - " Vectorhit local position : " << vh.localPosition() << "\n" << - " Vectorhit local direction : " << vh.localDirection() << "\n" << - " Vectorhit global direction : " << vh.globalDirection() << "\n" << - //" Vectorhit theta : " << vh.theta() << "\n" << - //" Cov: " << vh.parametersError() << "\n" << - //" Dim: " << vh.dimension() << "\n" << - //" chi2: " << vh.chi2() << "\n" << - " Lower cluster global position : " << vh.lowerGlobalPos() << "\n" << - " Upper cluster global position : " << vh.upperGlobalPos(); + os << " VectorHit create in the DetId#: " << vh.geographicalId() << "\n" + << " Vectorhit local position : " << vh.localPosition() << "\n" + << " Vectorhit local direction : " << vh.localDirection() << "\n" + << " Vectorhit global direction : " << vh.globalDirection() << "\n" + << + //" Vectorhit theta : " << vh.theta() << "\n" << + //" Cov: " << vh.parametersError() << "\n" << + //" Dim: " << vh.dimension() << "\n" << + //" chi2: " << vh.chi2() << "\n" << + " Lower cluster global position : " << vh.lowerGlobalPos() << "\n" + << " Upper cluster global position : " << vh.upperGlobalPos(); return os; } - /// Access to component RecHits (if any) -std::vector VectorHit::recHits() const{ +std::vector VectorHit::recHits() const { std::vector pointersOfRecHits; return pointersOfRecHits; } - /// Non-const access to component RecHits (if any) -std::vector VectorHit::recHits(){ - +std::vector VectorHit::recHits() { std::vector pointersOfRecHits; return pointersOfRecHits; } - diff --git a/DataFormats/TrackerRecHit2D/src/classes.h b/DataFormats/TrackerRecHit2D/src/classes.h index 44ede301244ff..98ba7a9edea20 100644 --- a/DataFormats/TrackerRecHit2D/src/classes.h +++ b/DataFormats/TrackerRecHit2D/src/classes.h @@ -9,9 +9,9 @@ #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h" #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" -#include "DataFormats/Common/interface/RefProd.h" -#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" -#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/RefProd.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" +#include "DataFormats/Common/interface/DetSetVector.h" #include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/Wrapper.h" #include "DataFormats/Common/interface/Ref.h" @@ -33,113 +33,176 @@ namespace DataFormats_TrackerRecHit2D { struct dictionary { - ProjectedSiStripRecHit2D projHit; + ProjectedSiStripRecHit2D projHit; SiStripRecHit2D a1; SiStripRecHit1D a11; SiStripMatchedRecHit2D a2; SiPixelRecHit b1; - edm::ClonePolicy a4; - edm::ClonePolicy a44; - edm::ClonePolicy a5; + edm::ClonePolicy a4; + edm::ClonePolicy a44; + edm::ClonePolicy a5; edm::ClonePolicy b2; - edm::ClonePolicy e2; - - edm::OwnVector > a6; - edm::OwnVector >::const_iterator it6; - edm::OwnVector > a66; - edm::OwnVector >::const_iterator it66; - edm::OwnVector > a7; - edm::OwnVector >::const_iterator it7; - edm::OwnVector > b3; - edm::OwnVector >::const_iterator it3; - edm::OwnVector > e3; - edm::OwnVector >::const_iterator it10; + edm::ClonePolicy e2; + + edm::OwnVector> a6; + edm::OwnVector>::const_iterator it6; + edm::OwnVector> a66; + edm::OwnVector>::const_iterator it66; + edm::OwnVector> a7; + edm::OwnVector>::const_iterator it7; + edm::OwnVector> b3; + edm::OwnVector>::const_iterator it3; + edm::OwnVector> e3; + edm::OwnVector>::const_iterator it10; edm::OwnVector ovbtrh; edm::Wrapper> wovbtrh; - edm::Wrapper< edm::RangeMap >, - edm::ClonePolicy > > siStripRecHit2DLocalPosCollectionWrapper; + edm::Wrapper>, + edm::ClonePolicy>> + siStripRecHit2DLocalPosCollectionWrapper; edm::RangeMap >, - edm::ClonePolicy >::id_iterator it2d; - - edm::Wrapper< edm::RangeMap >, - edm::ClonePolicy > > siStripRecHit1DLocalPosCollectionWrapper; - edm::RangeMap >, - edm::ClonePolicy >::id_iterator it1d; - - - edm::Wrapper< edm::RangeMap >, - edm::ClonePolicy > > siStripRecHit2DMatchedLocalPosCollectionWrapper; - edm::RangeMap >, - edm::ClonePolicy >::id_iterator itmatch; - - edm::Wrapper< edm::RangeMap >, - edm::ClonePolicy > > siPixelRecHitCollectionWrapper; - edm::RangeMap >, - edm::ClonePolicy >::id_iterator itpix; - - edm::Ref >,edm::ClonePolicy >,SiStripRecHit2D,edm::refhelper::FindUsingAdvance >,edm::ClonePolicy >,SiStripRecHit2D> > refRangeMapDetIdOwnVectorSiStripRecHit2D; - edm::RefVector >,edm::ClonePolicy >,SiStripRecHit2D,edm::refhelper::FindUsingAdvance >,edm::ClonePolicy >,SiStripRecHit2D> > refVectorRangeMapDetIdOwnVectorSiStripRecHit2D; + edm::OwnVector>, + edm::ClonePolicy>::id_iterator it2d; - edm::Ref >,edm::ClonePolicy >,SiStripRecHit1D,edm::refhelper::FindUsingAdvance >,edm::ClonePolicy >,SiStripRecHit1D> > refRangeMapDetIdOwnVectorSiStripRecHit1D; - edm::RefVector >,edm::ClonePolicy >,SiStripRecHit1D,edm::refhelper::FindUsingAdvance >,edm::ClonePolicy >,SiStripRecHit1D> > refVectorRangeMapDetIdOwnVectorSiStripRecHit1D; + edm::Wrapper>, + edm::ClonePolicy>> + siStripRecHit1DLocalPosCollectionWrapper; + edm::RangeMap>, + edm::ClonePolicy>::id_iterator it1d; + edm::Wrapper>, + edm::ClonePolicy>> + siStripRecHit2DMatchedLocalPosCollectionWrapper; + edm::RangeMap>, + edm::ClonePolicy>::id_iterator itmatch; - edm::Wrapper > wdstvDummy1; - edm::Wrapper > wdstvDummy11; - edm::Wrapper > wdstvDummy2; - edm::Wrapper > wdstvDummy3; + edm::Wrapper>, + edm::ClonePolicy>> + siPixelRecHitCollectionWrapper; + edm::RangeMap>, + edm::ClonePolicy>::id_iterator itpix; + + edm::Ref>, + edm::ClonePolicy>, + SiStripRecHit2D, + edm::refhelper::FindUsingAdvance< + edm::RangeMap>, + edm::ClonePolicy>, + SiStripRecHit2D>> + refRangeMapDetIdOwnVectorSiStripRecHit2D; + edm::RefVector>, + edm::ClonePolicy>, + SiStripRecHit2D, + edm::refhelper::FindUsingAdvance< + edm::RangeMap>, + edm::ClonePolicy>, + SiStripRecHit2D>> + refVectorRangeMapDetIdOwnVectorSiStripRecHit2D; + + edm::Ref>, + edm::ClonePolicy>, + SiStripRecHit1D, + edm::refhelper::FindUsingAdvance< + edm::RangeMap>, + edm::ClonePolicy>, + SiStripRecHit1D>> + refRangeMapDetIdOwnVectorSiStripRecHit1D; + edm::RefVector>, + edm::ClonePolicy>, + SiStripRecHit1D, + edm::refhelper::FindUsingAdvance< + edm::RangeMap>, + edm::ClonePolicy>, + SiStripRecHit1D>> + refVectorRangeMapDetIdOwnVectorSiStripRecHit1D; + + edm::Wrapper> wdstvDummy1; + edm::Wrapper> wdstvDummy11; + edm::Wrapper> wdstvDummy2; + edm::Wrapper> wdstvDummy3; edm::Wrapper clusterRemovalInfo; - edm::OwnVector > fastsimTrackerRecHitCollection; - edm::Wrapper > > fastsimTrackerRecHitCollection_Wrapper; - - std::vector >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > fastsimTrackerRecHitRefCollection; - - edm::Wrapper >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > > fastsimTrackerRecHitRefCollection_Wrapper; - - std::vector > > fastsimTrackerRecHitCombinations; - edm::Wrapper > > >fastsimTrackerRecHitCombinations_Wrapper; - - std::vector >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > > fastSimTrackerRecHitCombinationCollection; - edm::Wrapper >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > > > fastSimTrackerRecHitCombinationCollection_Wrapper; - - edm::Ref >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > >,vector >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > >,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > >,vector >,FastTrackerRecHit,edm::refhelper::FindUsingAdvance >,FastTrackerRecHit> > > > > fastSimTrackerRecHitCombinationRef; - - VectorHitCollectionNew vhc1_new; - edm::RefProd vhc1_new2; - edm::Wrapper wh1_new; - + edm::OwnVector> fastsimTrackerRecHitCollection; + edm::Wrapper>> + fastsimTrackerRecHitCollection_Wrapper; + + std::vector< + edm::Ref>, + FastTrackerRecHit, + edm::refhelper::FindUsingAdvance>, + FastTrackerRecHit>>> + fastsimTrackerRecHitRefCollection; + + edm::Wrapper>, + FastTrackerRecHit, + edm::refhelper::FindUsingAdvance>, + FastTrackerRecHit>>>> + fastsimTrackerRecHitRefCollection_Wrapper; + + std::vector>> fastsimTrackerRecHitCombinations; + edm::Wrapper>>> + fastsimTrackerRecHitCombinations_Wrapper; + + std::vector>, + FastTrackerRecHit, + edm::refhelper::FindUsingAdvance>, + FastTrackerRecHit>>>> + fastSimTrackerRecHitCombinationCollection; + edm::Wrapper>, + FastTrackerRecHit, + edm::refhelper::FindUsingAdvance>, + FastTrackerRecHit>>>>> + fastSimTrackerRecHitCombinationCollection_Wrapper; + + edm::Ref< + vector>, + FastTrackerRecHit, + edm::refhelper::FindUsingAdvance>, + FastTrackerRecHit>>>>, + vector>, + FastTrackerRecHit, + edm::refhelper::FindUsingAdvance>, + FastTrackerRecHit>>>, + edm::refhelper::FindUsingAdvance< + vector>, + FastTrackerRecHit, + edm::refhelper::FindUsingAdvance>, + FastTrackerRecHit>>>>, + vector>, + FastTrackerRecHit, + edm::refhelper::FindUsingAdvance>, + FastTrackerRecHit>>>>> + fastSimTrackerRecHitCombinationRef; + + VectorHitCollectionNew vhc1_new; + edm::RefProd vhc1_new2; + edm::Wrapper wh1_new; }; -} +} // namespace DataFormats_TrackerRecHit2D -#endif // SISTRIPRECHIT_CLASSES_H +#endif // SISTRIPRECHIT_CLASSES_H diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 6a7b3d39b77c9..754f517aa57be 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -14,67 +14,86 @@ #include "DataFormats/Common/interface/DetSetVector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" - class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { - public: - - VectorHitBuilderAlgorithm(const edm::ParameterSet& conf) : - VectorHitBuilderAlgorithmBase(conf), theFitter(new LinearFit()) {}; - ~VectorHitBuilderAlgorithm() { delete theFitter; }; +public: + VectorHitBuilderAlgorithm(const edm::ParameterSet& conf) + : VectorHitBuilderAlgorithmBase(conf), theFitter(new LinearFit()){}; + ~VectorHitBuilderAlgorithm() override { delete theFitter; }; - void run(edm::Handle< edmNew::DetSetVector > clusters, - VectorHitCollectionNew& vhAcc, VectorHitCollectionNew& vhRej, - edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej ); + void run(edm::Handle> clusters, + VectorHitCollectionNew& vhAcc, + VectorHitCollectionNew& vhRej, + edmNew::DetSetVector& clustersAcc, + edmNew::DetSetVector& clustersRej) override; //not implemented yet - bool checkClustersCompatibilityBeforeBuilding(edm::Handle< edmNew::DetSetVector > clusters, - const detset & theLowerDetSet, - const detset & theUpperDetSet); - bool checkClustersCompatibility(Local3DPoint& posinner, Local3DPoint& posouter, LocalError& errinner, LocalError& errouter); + bool checkClustersCompatibilityBeforeBuilding(edm::Handle> clusters, + const detset& theLowerDetSet, + const detset& theUpperDetSet); + bool checkClustersCompatibility(Local3DPoint& posinner, + Local3DPoint& posouter, + LocalError& errinner, + LocalError& errouter); class LocalPositionSort { - public: - LocalPositionSort(const TrackerGeometry *geometry, const ClusterParameterEstimator* cpe, const GeomDet * geomDet) : geom_(geometry), cpe_(cpe), geomDet_(geomDet) {} - bool operator()(Phase2TrackerCluster1DRef clus1, Phase2TrackerCluster1DRef clus2) const ; - private: - const TrackerGeometry *geom_; - const ClusterParameterEstimator* cpe_; - const GeomDet * geomDet_; + public: + LocalPositionSort(const TrackerGeometry* geometry, + const ClusterParameterEstimator* cpe, + const GeomDet* geomDet) + : geom_(geometry), cpe_(cpe), geomDet_(geomDet) {} + bool operator()(Phase2TrackerCluster1DRef clus1, Phase2TrackerCluster1DRef clus2) const; + + private: + const TrackerGeometry* geom_; + const ClusterParameterEstimator* cpe_; + const GeomDet* geomDet_; }; - std::vector> buildVectorHits(const StackGeomDet * stack, - edm::Handle< edmNew::DetSetVector > clusters, - const detset & DSVinner, const detset & DSVouter, - const std::vector& phase2OTClustersToSkip = std::vector()); + std::vector> buildVectorHits( + const StackGeomDet* stack, + edm::Handle> clusters, + const detset& DSVinner, + const detset& DSVouter, + const std::vector& phase2OTClustersToSkip = std::vector()) override; - VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, Phase2TrackerCluster1DRef upper); + VectorHit buildVectorHit(const StackGeomDet* stack, + Phase2TrackerCluster1DRef lower, + Phase2TrackerCluster1DRef upper) override; // Full I/O in DetSet //void buildDetUnit( const edm::DetSetVector & input, // output_t& output); - void fit2Dzx(const Local3DPoint lpCI, const Local3DPoint lpCO, - const LocalError leCI, const LocalError leCO, - Local3DPoint& pos, Local3DVector& dir, - AlgebraicSymMatrix22& covMatrix, double& chi2); - void fit2Dzy(const Local3DPoint lpCI, const Local3DPoint lpCO, - const LocalError leCI, const LocalError leCO, - Local3DPoint& pos, Local3DVector& dir, - AlgebraicSymMatrix22& covMatrix, double& chi2); + void fit2Dzx(const Local3DPoint lpCI, + const Local3DPoint lpCO, + const LocalError leCI, + const LocalError leCO, + Local3DPoint& pos, + Local3DVector& dir, + AlgebraicSymMatrix22& covMatrix, + double& chi2); + void fit2Dzy(const Local3DPoint lpCI, + const Local3DPoint lpCO, + const LocalError leCI, + const LocalError leCO, + Local3DPoint& pos, + Local3DVector& dir, + AlgebraicSymMatrix22& covMatrix, + double& chi2); void fit(const std::vector& x, const std::vector& y, const std::vector& sigy, - Local3DPoint& pos, Local3DVector& dir, - AlgebraicSymMatrix22& covMatrix, double& chi2); - -// void build( const edm::DetSet & input, -// output_t::FastFiller& output); - + Local3DPoint& pos, + Local3DVector& dir, + AlgebraicSymMatrix22& covMatrix, + double& chi2); - private: - LinearFit* theFitter; + // void build( const edm::DetSet & input, + // output_t::FastFiller& output); +private: + LinearFit* theFitter; }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index ad873f4508142..780b9b474485a 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -15,61 +15,67 @@ #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" namespace edm { - class ParameterSet; - template class RefGetter; - class EventSetup; -} + class ParameterSet; + template + class RefGetter; + class EventSetup; +} // namespace edm class VectorHitBuilderAlgorithmBase { - - public: +public: typedef edm::Ref, Phase2TrackerCluster1D> Phase2TrackerCluster1DRef; typedef edmNew::DetSet detset; typedef detset::const_iterator const_iterator; typedef edmNew::DetSetVector output_t; - typedef std::pair< StackGeomDet, std::vector > StackClusters; + typedef std::pair> StackClusters; VectorHitBuilderAlgorithmBase(const edm::ParameterSet&); virtual ~VectorHitBuilderAlgorithmBase() {} void initialize(const edm::EventSetup&); - void initTkGeom(edm::ESHandle< TrackerGeometry > tkGeomHandle); - void initTkTopo(edm::ESHandle< TrackerTopology > tkTopoHandle); + void initTkGeom(edm::ESHandle tkGeomHandle); + void initTkTopo(edm::ESHandle tkTopoHandle); void initCpe(const ClusterParameterEstimator* cpeProd); //FIXME::ERICA::this should be template, return different collection for different algo used!! - virtual void run(edm::Handle< edmNew::DetSetVector > clusters, VectorHitCollectionNew& vhAcc, VectorHitCollectionNew& vhRej, - edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej) = 0; - - virtual std::vector> buildVectorHits (const StackGeomDet * stack, - edm::Handle< edmNew::DetSetVector > clusters, - const detset & DSVinner, const detset & DSVouter, - const std::vector& phase2OTClustersToSkip = std::vector()) = 0; - - virtual VectorHit buildVectorHit(const StackGeomDet * stack, + virtual void run(edm::Handle> clusters, + VectorHitCollectionNew& vhAcc, + VectorHitCollectionNew& vhRej, + edmNew::DetSetVector& clustersAcc, + edmNew::DetSetVector& clustersRej) = 0; + + virtual std::vector> buildVectorHits( + const StackGeomDet* stack, + edm::Handle> clusters, + const detset& DSVinner, + const detset& DSVouter, + const std::vector& phase2OTClustersToSkip = std::vector()) = 0; + + virtual VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, Phase2TrackerCluster1DRef upper) = 0; - double computeParallaxCorrection(const PixelGeomDetUnit*&, const Point3DBase&, const PixelGeomDetUnit*&, const Point3DBase&); + double computeParallaxCorrection(const PixelGeomDetUnit*&, + const Point3DBase&, + const PixelGeomDetUnit*&, + const Point3DBase&); void printClusters(const edmNew::DetSetVector& clusters); void printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* cluster); - void loadDetSetVector( std::map< DetId,std::vector >& theMap, edmNew::DetSetVector& theCollection ) const ; + void loadDetSetVector(std::map>& theMap, + edmNew::DetSetVector& theCollection) const; const TrackerGeometry* theTkGeom; const TrackerTopology* theTkTopo; const ClusterParameterEstimator* cpe; unsigned int nMaxVHforeachStack; - std::vector< double > barrelCut; - std::vector< double > endcapCut; + std::vector barrelCut; + std::vector endcapCut; private: edm::ESInputTag cpeTag_; - - -// typedef SiStripRecHit2DCollection::FastFiller Collector; - + // typedef SiStripRecHit2DCollection::FastFiller Collector; }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h index 8adf92f4bc286..24ccbf93a3d5f 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h @@ -13,29 +13,26 @@ #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" -class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> -{ - - public: - +class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { +public: explicit VectorHitBuilderEDProducer(const edm::ParameterSet&); - virtual ~VectorHitBuilderEDProducer(); - virtual void produce(edm::Event&, const edm::EventSetup&) override; + ~VectorHitBuilderEDProducer() override; + void produce(edm::Event&, const edm::EventSetup&) override; void setupAlgorithm(edm::ParameterSet const& conf); - void run(edm::Handle< edmNew::DetSetVector > clusters, - edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, - VectorHitCollectionNew& outputAcc, VectorHitCollectionNew& outputRej); - VectorHitBuilderAlgorithmBase * algo() const { return stubsBuilder; }; - - private: - - VectorHitBuilderAlgorithmBase * stubsBuilder; + void run(edm::Handle > clusters, + edmNew::DetSetVector& clustersAcc, + edmNew::DetSetVector& clustersRej, + VectorHitCollectionNew& outputAcc, + VectorHitCollectionNew& outputRej); + VectorHitBuilderAlgorithmBase* algo() const { return stubsBuilder; }; + +private: + VectorHitBuilderAlgorithmBase* stubsBuilder; std::string offlinestubsTag; unsigned int maxOfflinestubs; std::string algoTag; - edm::EDGetTokenT< edmNew::DetSetVector > clusterProducer; + edm::EDGetTokenT > clusterProducer; bool readytobuild; - }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc index 63d60a3d5d6c7..9906f689a4d7f 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc @@ -8,4 +8,3 @@ DEFINE_FWK_EVENTSETUP_MODULE(SiPhase2RecHitMatcherESProducer); DEFINE_FWK_MODULE(VectorHitBuilderEDProducer); - diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 09093bc89ad65..73993fdb3eaed 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -6,22 +6,20 @@ #include "FWCore/Framework/interface/ESProducer.h" #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" -SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet & p) -{ +SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet& p) { name = p.getParameter("ComponentName"); pset_ = p; - setWhatProduced(this,name); + setWhatProduced(this, name); } -std::shared_ptr SiPhase2RecHitMatcherESProducer:: -produce(const TkPhase2OTCPERecord & iRecord) -{ - if( name == "SiPhase2VectorHitMatcher" ){ - matcher_ = std::make_shared(pset_); +std::shared_ptr SiPhase2RecHitMatcherESProducer::produce( + const TkPhase2OTCPERecord& iRecord) { + if (name == "SiPhase2VectorHitMatcher") { + matcher_ = std::make_shared(pset_); edm::ESHandle tGeomHandle; edm::ESHandle tTopoHandle; - + iRecord.getRecord().get(tGeomHandle); iRecord.getRecord().get(tTopoHandle); @@ -30,5 +28,3 @@ produce(const TkPhase2OTCPERecord & iRecord) } return matcher_; } - - diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h index 80aaf0b36bb1f..be680a93c7c5e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h @@ -7,17 +7,14 @@ #include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" #include -class SiPhase2RecHitMatcherESProducer: public edm::ESProducer { - public: +class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { +public: SiPhase2RecHitMatcherESProducer(const edm::ParameterSet&); std::shared_ptr produce(const TkPhase2OTCPERecord&); - private: + +private: std::string name; std::shared_ptr matcher_; edm::ParameterSet pset_; }; #endif - - - - diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 6e7c2fabef3c9..6787bd87f16ee 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -3,38 +3,32 @@ #include "Geometry/CommonTopologies/interface/PixelTopology.h" #include "DataFormats/TrackerRecHit2D/interface/VectorHit2D.h" - -bool VectorHitBuilderAlgorithm::LocalPositionSort::operator()(Phase2TrackerCluster1DRef clus1, Phase2TrackerCluster1DRef clus2) const -{ - const PixelGeomDetUnit* gdu1 = dynamic_cast< const PixelGeomDetUnit* >(geomDet_); - auto && lparams1 = cpe_->localParameters( *clus1, *gdu1 ); // x, y, z, e2_xx, e2_xy, e2_yy - auto && lparams2 = cpe_->localParameters( *clus2, *gdu1 ); // x, y, z, e2_xx, e2_xy, e2_yy +bool VectorHitBuilderAlgorithm::LocalPositionSort::operator()(Phase2TrackerCluster1DRef clus1, + Phase2TrackerCluster1DRef clus2) const { + const PixelGeomDetUnit* gdu1 = dynamic_cast(geomDet_); + auto&& lparams1 = cpe_->localParameters(*clus1, *gdu1); // x, y, z, e2_xx, e2_xy, e2_yy + auto&& lparams2 = cpe_->localParameters(*clus2, *gdu1); // x, y, z, e2_xx, e2_xy, e2_yy return lparams1.first.x() < lparams2.first.x(); } +void VectorHitBuilderAlgorithm::run(edm::Handle> clusters, + VectorHitCollectionNew& vhAcc, + VectorHitCollectionNew& vhRej, + edmNew::DetSetVector& clustersAcc, + edmNew::DetSetVector& clustersRej) { + LogDebug("VectorHitBuilderAlgorithm") << "Run VectorHitBuilderAlgorithm ... \n"; + const edmNew::DetSetVector* ClustersPhase2Collection = clusters.product(); -void VectorHitBuilderAlgorithm::run(edm::Handle< edmNew::DetSetVector > clusters, - VectorHitCollectionNew& vhAcc, - VectorHitCollectionNew& vhRej, - edmNew::DetSetVector& clustersAcc, - edmNew::DetSetVector& clustersRej) -{ - - LogDebug("VectorHitBuilderAlgorithm") << "Run VectorHitBuilderAlgorithm ... \n" ; - const edmNew::DetSetVector* ClustersPhase2Collection = clusters.product(); - - - std::map< DetId, std::vector > tempVHAcc, tempVHRej; - std::map< DetId, std::vector >::iterator it_temporary; + std::map> tempVHAcc, tempVHRej; + std::map>::iterator it_temporary; //loop over the DetSetVector - LogDebug("VectorHitBuilderAlgorithm") << "with #clusters : " << ClustersPhase2Collection->size() << std::endl ; - for( auto DSViter : *ClustersPhase2Collection){ - + LogDebug("VectorHitBuilderAlgorithm") << "with #clusters : " << ClustersPhase2Collection->size() << std::endl; + for (auto DSViter : *ClustersPhase2Collection) { unsigned int rawDetId1(DSViter.detId()); DetId detId1(rawDetId1); DetId lowerDetId, upperDetId; - if( theTkTopo->isLower(detId1) ){ + if (theTkTopo->isLower(detId1)) { lowerDetId = detId1; upperDetId = theTkTopo->partnerDetId(detId1); } else if (theTkTopo->isUpper(detId1)) { @@ -49,30 +43,30 @@ void VectorHitBuilderAlgorithm::run(edm::Handle< edmNew::DetSetVector skip it "; continue; } const GeomDet* gd; const StackGeomDet* stackDet; - edmNew::DetSetVector::const_iterator it_detLower = ClustersPhase2Collection->find( lowerDetId ); - edmNew::DetSetVector::const_iterator it_detUpper = ClustersPhase2Collection->find( upperDetId ); - - if ( it_detLower != ClustersPhase2Collection->end() && it_detUpper != ClustersPhase2Collection->end() ){ + edmNew::DetSetVector::const_iterator it_detLower = + ClustersPhase2Collection->find(lowerDetId); + edmNew::DetSetVector::const_iterator it_detUpper = + ClustersPhase2Collection->find(upperDetId); + if (it_detLower != ClustersPhase2Collection->end() && it_detUpper != ClustersPhase2Collection->end()) { gd = theTkGeom->idToDet(detIdStack); stackDet = dynamic_cast(gd); std::vector vhsInStack_Acc; - std::vector vhsInStack_Rej; + std::vector vhsInStack_Rej; const auto vhsInStack_AccRej = buildVectorHits(stackDet, clusters, *it_detLower, *it_detUpper); //storing accepted and rejected VHs - for(auto vh : vhsInStack_AccRej ) { - if(vh.second == true){ + for (auto vh : vhsInStack_AccRej) { + if (vh.second == true) { vhsInStack_Acc.push_back(vh.first); - } - else if(vh.second == false){ + } else if (vh.second == false) { vhsInStack_Rej.push_back(vh.first); } } @@ -84,122 +78,122 @@ void VectorHitBuilderAlgorithm::run(edm::Handle< edmNew::DetSetVector > clusters, - const detset & theLowerDetSet, - const detset & theUpperDetSet) -{ - if(theLowerDetSet.size()==1 && theUpperDetSet.size()==1) return true; +bool VectorHitBuilderAlgorithm::checkClustersCompatibilityBeforeBuilding( + edm::Handle> clusters, + const detset& theLowerDetSet, + const detset& theUpperDetSet) { + if (theLowerDetSet.size() == 1 && theUpperDetSet.size() == 1) + return true; //order lower clusters in u std::vector lowerClusters; - if(theLowerDetSet.size()>1) LogDebug("VectorHitBuilderAlgorithm") << " more than 1 lower cluster! " << std::endl; - if(theUpperDetSet.size()>1) LogDebug("VectorHitBuilderAlgorithm") << " more than 1 upper cluster! " << std::endl; - for ( const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++ cil ) { - Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo( clusters, cil ); + if (theLowerDetSet.size() > 1) + LogDebug("VectorHitBuilderAlgorithm") << " more than 1 lower cluster! " << std::endl; + if (theUpperDetSet.size() > 1) + LogDebug("VectorHitBuilderAlgorithm") << " more than 1 upper cluster! " << std::endl; + for (const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++cil) { + Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo(clusters, cil); lowerClusters.push_back(*clusterLower); } return true; } -bool VectorHitBuilderAlgorithm::checkClustersCompatibility(Local3DPoint& poslower, - Local3DPoint& posupper, - LocalError& errlower, - LocalError& errupper) -{ - +bool VectorHitBuilderAlgorithm::checkClustersCompatibility(Local3DPoint& poslower, + Local3DPoint& posupper, + LocalError& errlower, + LocalError& errupper) { return true; - } //---------------------------------------------------------------------------- //ERICA::in the DT code the global position is used to compute the alpha angle and put a cut on that. -std::vector> VectorHitBuilderAlgorithm::buildVectorHits(const StackGeomDet * stack, - edm::Handle< edmNew::DetSetVector > clusters, - const detset & theLowerDetSet, - const detset & theUpperDetSet, - const std::vector& phase2OTClustersToSkip) -{ - - std::vector> result; - if(checkClustersCompatibilityBeforeBuilding(clusters, theLowerDetSet, theUpperDetSet)){ +std::vector> VectorHitBuilderAlgorithm::buildVectorHits( + const StackGeomDet* stack, + edm::Handle> clusters, + const detset& theLowerDetSet, + const detset& theUpperDetSet, + const std::vector& phase2OTClustersToSkip) { + std::vector> result; + if (checkClustersCompatibilityBeforeBuilding(clusters, theLowerDetSet, theUpperDetSet)) { LogDebug("VectorHitBuilderAlgorithm") << " compatible -> continue ... " << std::endl; - } else { LogTrace("VectorHitBuilderAlgorithm") << " not compatible, going to the next cluster"; } + } else { + LogTrace("VectorHitBuilderAlgorithm") << " not compatible, going to the next cluster"; + } std::vector lowerClusters; - for ( const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++ cil ) { - Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo( clusters, cil ); + for (const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++cil) { + Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo(clusters, cil); lowerClusters.push_back(clusterLower); } std::vector upperClusters; - for ( const_iterator ciu = theUpperDetSet.begin(); ciu != theUpperDetSet.end(); ++ ciu ) { - Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo( clusters, ciu ); + for (const_iterator ciu = theUpperDetSet.begin(); ciu != theUpperDetSet.end(); ++ciu) { + Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo(clusters, ciu); upperClusters.push_back(clusterUpper); } - std::sort(lowerClusters.begin(), lowerClusters.end(), LocalPositionSort(&*theTkGeom,&*cpe,&*stack->lowerDet())); - std::sort(upperClusters.begin(), upperClusters.end(), LocalPositionSort(&*theTkGeom,&*cpe,&*stack->upperDet())); - - for ( auto cluL : lowerClusters){ + std::sort(lowerClusters.begin(), lowerClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->lowerDet())); + std::sort(upperClusters.begin(), upperClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->upperDet())); + + for (auto cluL : lowerClusters) { LogDebug("VectorHitBuilderAlgorithm") << " lower clusters " << std::endl; - printCluster(stack->lowerDet(),&*cluL); - const PixelGeomDetUnit* gduLow = dynamic_cast< const PixelGeomDetUnit* >(stack->lowerDet()); - auto && lparamsLow = cpe->localParameters( *cluL, *gduLow ); - for ( auto cluU : upperClusters){ + printCluster(stack->lowerDet(), &*cluL); + const PixelGeomDetUnit* gduLow = dynamic_cast(stack->lowerDet()); + auto&& lparamsLow = cpe->localParameters(*cluL, *gduLow); + for (auto cluU : upperClusters) { LogDebug("VectorHitBuilderAlgorithm") << "\t upper clusters " << std::endl; - printCluster(stack->upperDet(),&*cluU); - const PixelGeomDetUnit* gduUpp = dynamic_cast< const PixelGeomDetUnit* >(stack->upperDet()); - auto && lparamsUpp = cpe->localParameters( *cluU, *gduUpp ); + printCluster(stack->upperDet(), &*cluU); + const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); + auto&& lparamsUpp = cpe->localParameters(*cluU, *gduUpp); //applying the parallax correction - double pC = computeParallaxCorrection(gduLow,lparamsLow.first,gduUpp,lparamsUpp.first); + double pC = computeParallaxCorrection(gduLow, lparamsLow.first, gduUpp, lparamsUpp.first); LogDebug("VectorHitBuilderAlgorithm") << " \t parallax correction:" << pC << std::endl; double lpos_upp_corr = 0.0; double lpos_low_corr = 0.0; - if(lparamsUpp.first.x() > lparamsLow.first.x()){ - if(lparamsUpp.first.x() > 0){ + if (lparamsUpp.first.x() > lparamsLow.first.x()) { + if (lparamsUpp.first.x() > 0) { lpos_low_corr = lparamsLow.first.x(); lpos_upp_corr = lparamsUpp.first.x() - fabs(pC); } - if(lparamsUpp.first.x() < 0){ + if (lparamsUpp.first.x() < 0) { lpos_low_corr = lparamsLow.first.x() + fabs(pC); lpos_upp_corr = lparamsUpp.first.x(); } - } else if( lparamsUpp.first.x() < lparamsLow.first.x() ) { - if(lparamsUpp.first.x() > 0){ + } else if (lparamsUpp.first.x() < lparamsLow.first.x()) { + if (lparamsUpp.first.x() > 0) { lpos_low_corr = lparamsLow.first.x() - fabs(pC); lpos_upp_corr = lparamsUpp.first.x(); } - if(lparamsUpp.first.x() < 0){ + if (lparamsUpp.first.x() < 0) { lpos_low_corr = lparamsLow.first.x(); lpos_upp_corr = lparamsUpp.first.x() + fabs(pC); } } else { - if(lparamsUpp.first.x() > 0){ + if (lparamsUpp.first.x() > 0) { lpos_low_corr = lparamsLow.first.x(); lpos_upp_corr = lparamsUpp.first.x() - fabs(pC); } - if(lparamsUpp.first.x() < 0){ + if (lparamsUpp.first.x() < 0) { lpos_low_corr = lparamsLow.first.x(); lpos_upp_corr = lparamsUpp.first.x() + fabs(pC); } @@ -209,87 +203,95 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHit LogDebug("VectorHitBuilderAlgorithm") << " \t local pos lower corrected (x):" << lpos_low_corr << std::endl; //building my tolerance : 10*sigma - double delta = 10.0*sqrt(lparamsLow.second.xx()+lparamsUpp.second.xx()); + double delta = 10.0 * sqrt(lparamsLow.second.xx() + lparamsUpp.second.xx()); LogDebug("VectorHitBuilderAlgorithm") << " \t delta: " << delta << std::endl; double width = lpos_low_corr - lpos_upp_corr; LogDebug("VectorHitBuilderAlgorithm") << " \t width: " << width << std::endl; - unsigned int layerStack = theTkTopo->layer(stack->geographicalId()); - if(stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB ) LogDebug("VectorHitBuilderAlgorithm") << " \t is barrel. " << std::endl; - if(stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) LogDebug("VectorHitBuilderAlgorithm") << " \t is endcap. " << std::endl; + if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) + LogDebug("VectorHitBuilderAlgorithm") << " \t is barrel. " << std::endl; + if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) + LogDebug("VectorHitBuilderAlgorithm") << " \t is endcap. " << std::endl; LogDebug("VectorHitBuilderAlgorithm") << " \t layer is : " << layerStack << std::endl; float cut = 0.0; - if(stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB ) cut = barrelCut.at(layerStack); - if(stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) cut = endcapCut.at(layerStack); + if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) + cut = barrelCut.at(layerStack); + if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) + cut = endcapCut.at(layerStack); LogDebug("VectorHitBuilderAlgorithm") << " \t the cut is:" << cut << std::endl; //old cut: indipendent from layer - //if( (lpos_upp_corr < lpos_low_corr + delta) && + //if( (lpos_upp_corr < lpos_low_corr + delta) && // (lpos_upp_corr > lpos_low_corr - delta) ){ //new cut: dependent on layers - if(fabs(width) < cut){ + if (fabs(width) < cut) { LogDebug("VectorHitBuilderAlgorithm") << " accepting VH! " << std::endl; - VectorHit vh = buildVectorHit( stack, cluL, cluU); + VectorHit vh = buildVectorHit(stack, cluL, cluU); //protection: the VH can also be empty!! - if (vh.isValid()){ + if (vh.isValid()) { result.push_back(std::make_pair(vh, true)); } } else { LogDebug("VectorHitBuilderAlgorithm") << " rejecting VH: " << std::endl; //storing vh rejected for combinatiorial studies - VectorHit vh = buildVectorHit( stack, cluL, cluU); + VectorHit vh = buildVectorHit(stack, cluL, cluU); result.push_back(std::make_pair(vh, false)); } - } } return result; - } -VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet * stack, - Phase2TrackerCluster1DRef lower, - Phase2TrackerCluster1DRef upper) -{ - +VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, + Phase2TrackerCluster1DRef lower, + Phase2TrackerCluster1DRef upper) { LogTrace("VectorHitBuilderAlgorithm") << "Build VH with: "; //printCluster(stack->lowerDet(),&*lower); //printCluster(stack->upperDet(),&*upper); - const PixelGeomDetUnit* geomDetLower = dynamic_cast< const PixelGeomDetUnit* >(stack->lowerDet()); - const PixelGeomDetUnit* geomDetUpper = dynamic_cast< const PixelGeomDetUnit* >(stack->upperDet()); + const PixelGeomDetUnit* geomDetLower = dynamic_cast(stack->lowerDet()); + const PixelGeomDetUnit* geomDetUpper = dynamic_cast(stack->upperDet()); - auto && lparamsLower = cpe->localParameters( *lower, *geomDetLower ); // x, y, z, e2_xx, e2_xy, e2_yy + auto&& lparamsLower = cpe->localParameters(*lower, *geomDetLower); // x, y, z, e2_xx, e2_xy, e2_yy Global3DPoint gparamsLower = geomDetLower->surface().toGlobal(lparamsLower.first); - LogTrace("VectorHitBuilderAlgorithm") << "\t lower global pos: " << gparamsLower ; + LogTrace("VectorHitBuilderAlgorithm") << "\t lower global pos: " << gparamsLower; - auto && lparamsUpper = cpe->localParameters( *upper, *geomDetUpper ); + auto&& lparamsUpper = cpe->localParameters(*upper, *geomDetUpper); Global3DPoint gparamsUpper = geomDetUpper->surface().toGlobal(lparamsUpper.first); - LogTrace("VectorHitBuilderAlgorithm") << "\t upper global pos: " << gparamsUpper ; + LogTrace("VectorHitBuilderAlgorithm") << "\t upper global pos: " << gparamsUpper; //local parameters of upper cluster in lower system of reference Local3DPoint lparamsUpperInLower = geomDetLower->surface().toLocal(gparamsUpper); - LogTrace("VectorHitBuilderAlgorithm") << "\t lower global pos: " << gparamsLower ; - LogTrace("VectorHitBuilderAlgorithm") << "\t upper global pos: " << gparamsUpper ; - - LogTrace("VectorHitBuilderAlgorithm") << "A:\t lower local pos: " << lparamsLower.first << " with error: " << lparamsLower.second << std::endl; - LogTrace("VectorHitBuilderAlgorithm") << "A:\t upper local pos in the lower sof " << lparamsUpperInLower << " with error: " << lparamsUpper.second << std::endl; + LogTrace("VectorHitBuilderAlgorithm") << "\t lower global pos: " << gparamsLower; + LogTrace("VectorHitBuilderAlgorithm") << "\t upper global pos: " << gparamsUpper; - bool ok = checkClustersCompatibility(lparamsLower.first, lparamsUpper.first, lparamsLower.second, lparamsUpper.second); + LogTrace("VectorHitBuilderAlgorithm") << "A:\t lower local pos: " << lparamsLower.first + << " with error: " << lparamsLower.second << std::endl; + LogTrace("VectorHitBuilderAlgorithm") << "A:\t upper local pos in the lower sof " << lparamsUpperInLower + << " with error: " << lparamsUpper.second << std::endl; - if(ok){ + bool ok = + checkClustersCompatibility(lparamsLower.first, lparamsUpper.first, lparamsLower.second, lparamsUpper.second); + if (ok) { AlgebraicSymMatrix22 covMat2Dzx; double chi22Dzx = 0.0; Local3DPoint pos2Dzx; Local3DVector dir2Dzx; - fit2Dzx(lparamsLower.first, lparamsUpperInLower, lparamsLower.second, lparamsUpper.second, pos2Dzx, dir2Dzx, covMat2Dzx, chi22Dzx); + fit2Dzx(lparamsLower.first, + lparamsUpperInLower, + lparamsLower.second, + lparamsUpper.second, + pos2Dzx, + dir2Dzx, + covMat2Dzx, + chi22Dzx); LogTrace("VectorHitBuilderAlgorithm") << "\t pos2Dzx: " << pos2Dzx; LogTrace("VectorHitBuilderAlgorithm") << "\t dir2Dzx: " << dir2Dzx; LogTrace("VectorHitBuilderAlgorithm") << "\t cov2Dzx: " << covMat2Dzx; @@ -299,99 +301,102 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet * stack, double chi22Dzy = 0.0; Local3DPoint pos2Dzy; Local3DVector dir2Dzy; - fit2Dzy(lparamsLower.first, lparamsUpperInLower, lparamsLower.second, lparamsUpper.second, pos2Dzy, dir2Dzy, covMat2Dzy, chi22Dzy); + fit2Dzy(lparamsLower.first, + lparamsUpperInLower, + lparamsLower.second, + lparamsUpper.second, + pos2Dzy, + dir2Dzy, + covMat2Dzy, + chi22Dzy); LogTrace("VectorHitBuilderAlgorithm") << "\t pos2Dzy: " << pos2Dzy; LogTrace("VectorHitBuilderAlgorithm") << "\t dir2Dzy: " << dir2Dzy; LogTrace("VectorHitBuilderAlgorithm") << "\t cov2Dzy: " << covMat2Dzy; VectorHit2D vh2Dzy = VectorHit2D(pos2Dzy, dir2Dzy, covMat2Dzy, chi22Dzy); - OmniClusterRef lowerOmni(lower); - OmniClusterRef upperOmni(upper); + OmniClusterRef lowerOmni(lower); + OmniClusterRef upperOmni(upper); VectorHit vh = VectorHit(*stack, vh2Dzx, vh2Dzy, lowerOmni, upperOmni); return vh; - } return VectorHit(); - } - - -void VectorHitBuilderAlgorithm::fit2Dzx(const Local3DPoint lpCI, const Local3DPoint lpCO, - const LocalError leCI, const LocalError leCO, - Local3DPoint& pos, Local3DVector& dir, +void VectorHitBuilderAlgorithm::fit2Dzx(const Local3DPoint lpCI, + const Local3DPoint lpCO, + const LocalError leCI, + const LocalError leCO, + Local3DPoint& pos, + Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2) -{ + double& chi2) { std::vector x = {lpCI.z(), lpCO.z()}; std::vector y = {lpCI.x(), lpCO.x()}; float sqCI = sqrt(leCI.xx()); float sqCO = sqrt(leCO.xx()); std::vector sigy = {sqCI, sqCO}; - fit(x,y,sigy,pos,dir,covMatrix,chi2); + fit(x, y, sigy, pos, dir, covMatrix, chi2); return; - } -void VectorHitBuilderAlgorithm::fit2Dzy(const Local3DPoint lpCI, const Local3DPoint lpCO, - const LocalError leCI, const LocalError leCO, - Local3DPoint& pos, Local3DVector& dir, +void VectorHitBuilderAlgorithm::fit2Dzy(const Local3DPoint lpCI, + const Local3DPoint lpCO, + const LocalError leCI, + const LocalError leCO, + Local3DPoint& pos, + Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2) -{ + double& chi2) { std::vector x = {lpCI.z(), lpCO.z()}; std::vector y = {lpCI.y(), lpCO.y()}; float sqCI = sqrt(leCI.yy()); float sqCO = sqrt(leCO.yy()); std::vector sigy = {sqCI, sqCO}; - fit(x,y,sigy,pos,dir,covMatrix,chi2); + fit(x, y, sigy, pos, dir, covMatrix, chi2); return; - } void VectorHitBuilderAlgorithm::fit(const std::vector& x, const std::vector& y, const std::vector& sigy, - Local3DPoint& pos, Local3DVector& dir, + Local3DPoint& pos, + Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2) -{ - - if(x.size() != y.size() || x.size() != sigy.size()){ + double& chi2) { + if (x.size() != y.size() || x.size() != sigy.size()) { edm::LogError("VectorHitBuilderAlgorithm") << "Different size for x,z !! No fit possible."; return; } - float slope = 0.; + float slope = 0.; float intercept = 0.; - float covss = 0.; - float covii = 0.; - float covsi = 0.; + float covss = 0.; + float covii = 0.; + float covsi = 0.; - theFitter->fit(x,y,x.size(),sigy,slope,intercept,covss,covii,covsi); + theFitter->fit(x, y, x.size(), sigy, slope, intercept, covss, covii, covsi); - covMatrix[0][0] = covss; // this is var(dy/dz) - covMatrix[1][1] = covii; // this is var(y) - covMatrix[1][0] = covsi; // this is cov(dy/dz,y) + covMatrix[0][0] = covss; // this is var(dy/dz) + covMatrix[1][1] = covii; // this is var(y) + covMatrix[1][0] = covsi; // this is cov(dy/dz,y) - for (unsigned int j=0; j < x.size(); j++){ - const double ypred = intercept + slope*x[j]; - const double dy = (y[j] - ypred)/sigy[j]; - chi2 += dy*dy; - } + for (unsigned int j = 0; j < x.size(); j++) { + const double ypred = intercept + slope * x[j]; + const double dy = (y[j] - ypred) / sigy[j]; + chi2 += dy * dy; + } - pos = Local3DPoint(intercept,0.,0.); - if(x.size()==2){ + pos = Local3DPoint(intercept, 0., 0.); + if (x.size() == 2) { //difference in z is the difference of the lowermost and the uppermost cluster z pos float slopeZ = x.at(1) - x.at(0); - dir = LocalVector(slope,0.,slopeZ); + dir = LocalVector(slope, 0., slopeZ); } else { - dir = LocalVector(slope,0.,-1.); + dir = LocalVector(slope, 0., -1.); } - } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index 864be497f603d..80e027ed13c69 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -7,22 +7,20 @@ #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" -VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase(const edm::ParameterSet& conf) : - nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), - barrelCut(conf.getParameter< std::vector< double > >("BarrelCut")), - endcapCut(conf.getParameter< std::vector< double > >("EndcapCut")), - cpeTag_(conf.getParameter("CPE")) -{} - -void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) -{ +VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase(const edm::ParameterSet& conf) + : nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), + barrelCut(conf.getParameter >("BarrelCut")), + endcapCut(conf.getParameter >("EndcapCut")), + cpeTag_(conf.getParameter("CPE")) {} + +void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) { // get the geometry and topology - edm::ESHandle< TrackerGeometry > geomHandle; - es.get< TrackerDigiGeometryRecord >().get( geomHandle ); + edm::ESHandle geomHandle; + es.get().get(geomHandle); initTkGeom(geomHandle); - edm::ESHandle< TrackerTopology > tTopoHandle; - es.get< TrackerTopologyRcd >().get(tTopoHandle); + edm::ESHandle tTopoHandle; + es.get().get(tTopoHandle); initTkTopo(tTopoHandle); // load the cpe via the eventsetup @@ -31,27 +29,29 @@ void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) initCpe(cpeHandle.product()); } -void VectorHitBuilderAlgorithmBase::initTkGeom(edm::ESHandle< TrackerGeometry > tkGeomHandle){ +void VectorHitBuilderAlgorithmBase::initTkGeom(edm::ESHandle tkGeomHandle) { theTkGeom = tkGeomHandle.product(); } -void VectorHitBuilderAlgorithmBase::initTkTopo(edm::ESHandle< TrackerTopology > tkTopoHandle){ +void VectorHitBuilderAlgorithmBase::initTkTopo(edm::ESHandle tkTopoHandle) { theTkTopo = tkTopoHandle.product(); } -void VectorHitBuilderAlgorithmBase::initCpe(const ClusterParameterEstimator* cpeProd){ +void VectorHitBuilderAlgorithmBase::initCpe(const ClusterParameterEstimator* cpeProd) { cpe = cpeProd; } -double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomDetUnit*& geomDetUnit_low, const Point3DBase& lPosClu_low, - const PixelGeomDetUnit*& geomDetUnit_upp, const Point3DBase& lPosClu_upp){ +double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomDetUnit*& geomDetUnit_low, + const Point3DBase& lPosClu_low, + const PixelGeomDetUnit*& geomDetUnit_upp, + const Point3DBase& lPosClu_upp) { double parallCorr = 0.0; - Global3DPoint origin(0,0,0); + Global3DPoint origin(0, 0, 0); Global3DPoint gPosClu_low = geomDetUnit_low->surface().toGlobal(lPosClu_low); GlobalVector gV = gPosClu_low - origin; LogTrace("VectorHitsBuilderValidation") << " global vector passing to the origin:" << gV; LocalVector lV = geomDetUnit_low->surface().toLocal(gV); LogTrace("VectorHitsBuilderValidation") << " local vector passing to the origin (in low sor):" << lV; - LocalVector lV_norm = lV/lV.z(); + LocalVector lV_norm = lV / lV.z(); LogTrace("VectorHitsBuilderValidation") << " normalized local vector passing to the origin (in low sor):" << lV_norm; Global3DPoint gPosClu_upp = geomDetUnit_upp->surface().toGlobal(lPosClu_upp); @@ -61,54 +61,53 @@ double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomD return parallCorr; } -void VectorHitBuilderAlgorithmBase::printClusters(const edmNew::DetSetVector& clusters){ - +void VectorHitBuilderAlgorithmBase::printClusters(const edmNew::DetSetVector& clusters) { int nCluster = 0; int numberOfDSV = 0; edmNew::DetSetVector::const_iterator DSViter; - for( DSViter = clusters.begin() ; DSViter != clusters.end(); DSViter++){ - + for (DSViter = clusters.begin(); DSViter != clusters.end(); DSViter++) { ++numberOfDSV; // Loop over the clusters in the detector unit - for (edmNew::DetSet< Phase2TrackerCluster1D >::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); ++clustIt) { - + for (edmNew::DetSet::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); + ++clustIt) { nCluster++; // get the detector unit's id const GeomDetUnit* geomDetUnit(theTkGeom->idToDetUnit(DSViter->detId())); - if (!geomDetUnit) return; + if (!geomDetUnit) + return; printCluster(geomDetUnit, clustIt); - } } LogDebug("VectorHitBuilder") << " Number of input clusters: " << nCluster << std::endl; - } - -void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* clustIt){ - - if (!geomDetUnit) return; - const PixelGeomDetUnit* pixelGeomDetUnit = dynamic_cast< const PixelGeomDetUnit* >(geomDetUnit); +void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* clustIt) { + if (!geomDetUnit) + return; + const PixelGeomDetUnit* pixelGeomDetUnit = dynamic_cast(geomDetUnit); const PixelTopology& topol = pixelGeomDetUnit->specificTopology(); - if (!pixelGeomDetUnit) return; + if (!pixelGeomDetUnit) + return; unsigned int layer = theTkTopo->layer(geomDetUnit->geographicalId()); unsigned int module = theTkTopo->module(geomDetUnit->geographicalId()); - LogTrace("VectorHitBuilder") << "Layer:" << layer << " and DetId: " << geomDetUnit->geographicalId().rawId() << std::endl; + LogTrace("VectorHitBuilder") << "Layer:" << layer << " and DetId: " << geomDetUnit->geographicalId().rawId() + << std::endl; TrackerGeometry::ModuleType mType = theTkGeom->getDetectorType(geomDetUnit->geographicalId()); - if (mType == TrackerGeometry::ModuleType::Ph2PSP) + if (mType == TrackerGeometry::ModuleType::Ph2PSP) LogTrace("VectorHitBuilder") << "Pixel cluster (module:" << module << ") " << std::endl; - else if (mType == TrackerGeometry::ModuleType::Ph2SS || mType == TrackerGeometry::ModuleType::Ph2PSS) + else if (mType == TrackerGeometry::ModuleType::Ph2SS || mType == TrackerGeometry::ModuleType::Ph2PSS) LogTrace("VectorHitBuilder") << "Strip cluster (module:" << module << ") " << std::endl; - else LogTrace("VectorHitBuilder") << "no module?!" << std::endl; + else + LogTrace("VectorHitBuilder") << "no module?!" << std::endl; LogTrace("VectorHitBuilder") << "with pitch:" << topol.pitch().first << " , " << topol.pitch().second << std::endl; - LogTrace("VectorHitBuilder") << " and width:" << pixelGeomDetUnit->surface().bounds().width() << " , lenght:" << pixelGeomDetUnit->surface().bounds().length() << std::endl; - + LogTrace("VectorHitBuilder") << " and width:" << pixelGeomDetUnit->surface().bounds().width() + << " , lenght:" << pixelGeomDetUnit->surface().bounds().length() << std::endl; - auto && lparams = cpe->localParameters( *clustIt, *pixelGeomDetUnit ); + auto&& lparams = cpe->localParameters(*clustIt, *pixelGeomDetUnit); Global3DPoint gparams = pixelGeomDetUnit->surface().toGlobal(lparams.first); LogTrace("VectorHitBuilder") << "\t global pos " << gparams << std::endl; @@ -118,17 +117,16 @@ void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, con return; } -void VectorHitBuilderAlgorithmBase::loadDetSetVector( std::map< DetId,std::vector >& theMap, edmNew::DetSetVector& theCollection ) const{ - - std::map >::const_iterator it = theMap.begin(); - std::map >::const_iterator lastDet = theMap.end(); - for( ; it != lastDet ; ++it ) { +void VectorHitBuilderAlgorithmBase::loadDetSetVector(std::map >& theMap, + edmNew::DetSetVector& theCollection) const { + std::map >::const_iterator it = theMap.begin(); + std::map >::const_iterator lastDet = theMap.end(); + for (; it != lastDet; ++it) { edmNew::DetSetVector::FastFiller vh_col(theCollection, it->first); std::vector::const_iterator vh_it = it->second.begin(); std::vector::const_iterator vh_end = it->second.end(); - for( ; vh_it != vh_end ; ++vh_it) { + for (; vh_it != vh_end; ++vh_it) { vh_col.push_back(*vh_it); } } - } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc index 60e6f58bc9ff2..a47ae33526242 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc @@ -4,62 +4,60 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) - : offlinestubsTag( conf.getParameter( "offlinestubs" ) ), - maxOfflinestubs(conf.getParameter( "maxVectorHits" )), - algoTag(conf.getParameter( "Algorithm" )), - //clusterProducer(conf.getParameter("Clusters")), - readytobuild(false) -{ - - clusterProducer = consumes< edmNew::DetSetVector >(edm::InputTag(conf.getParameter("Clusters"))); - - produces< edmNew::DetSetVector< Phase2TrackerCluster1D > >( "ClustersAccepted" ); - produces< edmNew::DetSetVector< Phase2TrackerCluster1D > >( "ClustersRejected" ); - produces< VectorHitCollectionNew >( offlinestubsTag + "Accepted" ); - produces< VectorHitCollectionNew >( offlinestubsTag + "Rejected" ); + : offlinestubsTag(conf.getParameter("offlinestubs")), + maxOfflinestubs(conf.getParameter("maxVectorHits")), + algoTag(conf.getParameter("Algorithm")), + //clusterProducer(conf.getParameter("Clusters")), + readytobuild(false) { + clusterProducer = consumes >( + edm::InputTag(conf.getParameter("Clusters"))); + + produces >("ClustersAccepted"); + produces >("ClustersRejected"); + produces(offlinestubsTag + "Accepted"); + produces(offlinestubsTag + "Rejected"); setupAlgorithm(conf); } -VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { - delete stubsBuilder; -} +VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder; } -void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) -{ +void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { LogDebug("VectorHitBuilderEDProducer") << "VectorHitBuilderEDProducer::produce() begin"; // get input clusters data - edm::Handle< edmNew::DetSetVector > clustersHandle; - event.getByToken( clusterProducer, clustersHandle); + edm::Handle > clustersHandle; + event.getByToken(clusterProducer, clustersHandle); // create the final output collection - std::unique_ptr< edmNew::DetSetVector< Phase2TrackerCluster1D > > outputClustersAccepted( new edmNew::DetSetVector< Phase2TrackerCluster1D > ); - std::unique_ptr< edmNew::DetSetVector< Phase2TrackerCluster1D > > outputClustersRejected( new edmNew::DetSetVector< Phase2TrackerCluster1D > ); - std::unique_ptr< VectorHitCollectionNew > outputVHAccepted( new VectorHitCollectionNew() ); - std::unique_ptr< VectorHitCollectionNew > outputVHRejected( new VectorHitCollectionNew() ); - - if(readytobuild) stubsBuilder->initialize(es); - else edm::LogError("VectorHitBuilderEDProducer") << "Impossible initialization of builder!!"; + std::unique_ptr > outputClustersAccepted( + new edmNew::DetSetVector); + std::unique_ptr > outputClustersRejected( + new edmNew::DetSetVector); + std::unique_ptr outputVHAccepted(new VectorHitCollectionNew()); + std::unique_ptr outputVHRejected(new VectorHitCollectionNew()); + + if (readytobuild) + stubsBuilder->initialize(es); + else + edm::LogError("VectorHitBuilderEDProducer") << "Impossible initialization of builder!!"; // check on the input clusters stubsBuilder->printClusters(*clustersHandle); // running the stub building algorithm //ERICA::output should be moved in the different algo classes? - run( clustersHandle, *outputClustersAccepted, *outputClustersRejected, *outputVHAccepted, *outputVHRejected); + run(clustersHandle, *outputClustersAccepted, *outputClustersRejected, *outputVHAccepted, *outputVHRejected); unsigned int numberOfVectorHits = 0; edmNew::DetSetVector::const_iterator DSViter; - for( DSViter = (*outputVHAccepted).begin() ; DSViter != (*outputVHAccepted).end(); DSViter++){ - - edmNew::DetSet< VectorHit >::const_iterator vh; - for ( vh = DSViter->begin(); vh != DSViter->end(); ++vh) { + for (DSViter = (*outputVHAccepted).begin(); DSViter != (*outputVHAccepted).end(); DSViter++) { + edmNew::DetSet::const_iterator vh; + for (vh = DSViter->begin(); vh != DSViter->end(); ++vh) { numberOfVectorHits++; LogDebug("VectorHitBuilderEDProducer") << "\t vectorhit in output " << *vh << std::endl; } - } -/* + /* if(numberOfVectorHits > maxOfflinestubs) { edm::LogError("VectorHitBuilderEDProducer") << "Limit on the number of stubs exceeded. An empty output collection will be produced instead.\n"; VectorHitCollectionNew empty; @@ -67,40 +65,36 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu } */ // write output to file - event.put( std::move(outputClustersAccepted), "ClustersAccepted" ); - event.put( std::move(outputClustersRejected), "ClustersRejected" ); - event.put( std::move(outputVHAccepted), offlinestubsTag + "Accepted" ); - event.put( std::move(outputVHRejected), offlinestubsTag + "Rejected" ); - -// LogDebug("VectorHitBuilderEDProducer") << " Executing " << algoTag << " resulted in " << numberOfVectorHits << "."; - LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n" ; + event.put(std::move(outputClustersAccepted), "ClustersAccepted"); + event.put(std::move(outputClustersRejected), "ClustersRejected"); + event.put(std::move(outputVHAccepted), offlinestubsTag + "Accepted"); + event.put(std::move(outputVHRejected), offlinestubsTag + "Rejected"); + // LogDebug("VectorHitBuilderEDProducer") << " Executing " << algoTag << " resulted in " << numberOfVectorHits << "."; + LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n"; } void VectorHitBuilderEDProducer::setupAlgorithm(edm::ParameterSet const& conf) { - - if ( algoTag == "VectorHitBuilderAlgorithm" ) { + if (algoTag == "VectorHitBuilderAlgorithm") { stubsBuilder = new VectorHitBuilderAlgorithm(conf); readytobuild = true; } else { - edm::LogError("VectorHitBuilderEDProducer") << " Choice " << algoTag << " is invalid.\n" ; + edm::LogError("VectorHitBuilderEDProducer") << " Choice " << algoTag << " is invalid.\n"; readytobuild = false; } - } - -void VectorHitBuilderEDProducer::run(edm::Handle< edmNew::DetSetVector > clusters, - edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, - VectorHitCollectionNew& outputAcc, VectorHitCollectionNew& outputRej ){ - - if ( !readytobuild ) { - edm::LogError("VectorHitBuilderEDProducer") << " No stub builder algorithm was found - cannot run!" ; +void VectorHitBuilderEDProducer::run(edm::Handle > clusters, + edmNew::DetSetVector& clustersAcc, + edmNew::DetSetVector& clustersRej, + VectorHitCollectionNew& outputAcc, + VectorHitCollectionNew& outputRej) { + if (!readytobuild) { + edm::LogError("VectorHitBuilderEDProducer") << " No stub builder algorithm was found - cannot run!"; return; } stubsBuilder->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej); - } #include "FWCore/Utilities/interface/typelookup.h" diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc index 1730009db050a..3a31e39b56183 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc @@ -40,113 +40,110 @@ #include #include - - struct ClusterHistos { - THStack* numberClustersMixed; - TH1F* numberClusterPixel; - TH1F* numberClusterStrip; + THStack* numberClustersMixed; + TH1F* numberClusterPixel; + TH1F* numberClusterStrip; - THStack* clustersSizeMixed; - TH1F* clusterSizePixel; - TH1F* clusterSizeStrip; + THStack* clustersSizeMixed; + TH1F* clusterSizePixel; + TH1F* clusterSizeStrip; - TGraph* globalPosXY[3]; - TGraph* localPosXY[3]; + TGraph* globalPosXY[3]; + TGraph* localPosXY[3]; - TH1F* deltaXClusterSimHits[3]; - TH1F* deltaYClusterSimHits[3]; + TH1F* deltaXClusterSimHits[3]; + TH1F* deltaYClusterSimHits[3]; - TH1F* deltaXClusterSimHits_P[3]; - TH1F* deltaYClusterSimHits_P[3]; + TH1F* deltaXClusterSimHits_P[3]; + TH1F* deltaYClusterSimHits_P[3]; - TH1F* digiEfficiency[3]; + TH1F* digiEfficiency[3]; - TH1F* primarySimHits; - TH1F* otherSimHits; + TH1F* primarySimHits; + TH1F* otherSimHits; }; class Phase2TrackerClusterizerValidationTGraph : public edm::EDAnalyzer { - - public: - - typedef std::map< unsigned int, std::vector< PSimHit > > SimHitsMap; - typedef std::map< unsigned int, SimTrack > SimTracksMap; - - explicit Phase2TrackerClusterizerValidationTGraph(const edm::ParameterSet&); - ~Phase2TrackerClusterizerValidationTGraph(); - void beginJob(); - void endJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - - private: - - std::map< unsigned int, ClusterHistos >::iterator createLayerHistograms(unsigned int); - unsigned int getLayerNumber(const DetId&, const TrackerTopology*); - unsigned int getModuleNumber(const DetId&, const TrackerTopology*); - unsigned int getSimTrackId(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >&, const DetId&, unsigned int); - - edm::EDGetTokenT< edmNew::DetSetVector > srcClu_; - edm::EDGetTokenT< edm::DetSetVector > siphase2OTSimLinksToken_; - edm::EDGetTokenT< edm::PSimHitContainer > simHitsToken_; - edm::EDGetTokenT< edm::SimTrackContainer> simTracksToken_; - edm::EDGetTokenT< edm::SimVertexContainer > simVerticesToken_; - const TrackerGeometry* tkGeom; - const TrackerTopology* tkTopo; - - TTree* tree; - TGraph* trackerLayout_[3]; - TGraph* trackerLayoutXY_[3]; - TGraph* trackerLayoutXYBar_; - TGraph* trackerLayoutXYEC_; - - std::map< unsigned int, ClusterHistos > histograms_; - +public: + typedef std::map > SimHitsMap; + typedef std::map SimTracksMap; + + explicit Phase2TrackerClusterizerValidationTGraph(const edm::ParameterSet&); + ~Phase2TrackerClusterizerValidationTGraph(); + void beginJob(); + void endJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + +private: + std::map::iterator createLayerHistograms(unsigned int); + unsigned int getLayerNumber(const DetId&, const TrackerTopology*); + unsigned int getModuleNumber(const DetId&, const TrackerTopology*); + unsigned int getSimTrackId(const edm::Handle >&, const DetId&, unsigned int); + + edm::EDGetTokenT > srcClu_; + edm::EDGetTokenT > siphase2OTSimLinksToken_; + edm::EDGetTokenT simHitsToken_; + edm::EDGetTokenT simTracksToken_; + edm::EDGetTokenT simVerticesToken_; + const TrackerGeometry* tkGeom; + const TrackerTopology* tkTopo; + + TTree* tree; + TGraph* trackerLayout_[3]; + TGraph* trackerLayoutXY_[3]; + TGraph* trackerLayoutXYBar_; + TGraph* trackerLayoutXYEC_; + + std::map histograms_; }; Phase2TrackerClusterizerValidationTGraph::Phase2TrackerClusterizerValidationTGraph(const edm::ParameterSet& conf) { - srcClu_ = consumes< edmNew::DetSetVector >(edm::InputTag(conf.getParameter("src"))); + srcClu_ = + consumes >(edm::InputTag(conf.getParameter("src"))); siphase2OTSimLinksToken_ = consumes >(conf.getParameter("links")); - simHitsToken_ = consumes< edm::PSimHitContainer >(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof")); - simTracksToken_ = consumes< edm::SimTrackContainer >(edm::InputTag("g4SimHits")); - simVerticesToken_ = consumes< edm::SimVertexContainer >(edm::InputTag("g4SimHits")); + simHitsToken_ = consumes(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof")); + simTracksToken_ = consumes(edm::InputTag("g4SimHits")); + simVerticesToken_ = consumes(edm::InputTag("g4SimHits")); } - Phase2TrackerClusterizerValidationTGraph::~Phase2TrackerClusterizerValidationTGraph() { } - - void Phase2TrackerClusterizerValidationTGraph::beginJob() { - edm::Service fs; - fs->file().cd("/"); - TFileDirectory td = fs->mkdir("Common"); - //Create common ntuple - tree = td.make< TTree >("Phase2TrackerClusters","Phase2TrackerClusters"); - // Create common histograms - trackerLayout_[0] = td.make< TGraph >();//"RVsZ_Mixed", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); - trackerLayout_[0] -> SetName("RVsZ_Mixed"); - trackerLayout_[1] = td.make< TGraph >();//"RVsZ_Pixel", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); - trackerLayout_[1] -> SetName("RVsZ_Pixel"); - trackerLayout_[2] = td.make< TGraph >();//"RVsZ_Strip", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); - trackerLayout_[2] -> SetName("RVsZ_Strip"); - trackerLayoutXY_[0] = td.make< TGraph >();//"XVsY_Mixed", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); - trackerLayoutXY_[0] -> SetName("YVsX_Mixed"); - trackerLayoutXY_[1] = td.make< TGraph >();//"XVsY_Pixel", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); - trackerLayoutXY_[1] -> SetName("YVsX_Pixel"); - trackerLayoutXY_[2] = td.make< TGraph >();//"XVsY_Strip", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); - trackerLayoutXY_[2] -> SetName("YVsX_Strip"); - trackerLayoutXYBar_ = td.make< TGraph >();//"XVsYBar", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); - trackerLayoutXYBar_ -> SetName("YVsXBar"); - trackerLayoutXYEC_ = td.make< TGraph >();//"XVsYEC", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); - trackerLayoutXYEC_ -> SetName("YVsXEC"); - } +Phase2TrackerClusterizerValidationTGraph::~Phase2TrackerClusterizerValidationTGraph() {} + +void Phase2TrackerClusterizerValidationTGraph::beginJob() { + edm::Service fs; + fs->file().cd("/"); + TFileDirectory td = fs->mkdir("Common"); + //Create common ntuple + tree = td.make("Phase2TrackerClusters", "Phase2TrackerClusters"); + // Create common histograms + trackerLayout_[0] = td.make(); //"RVsZ_Mixed", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); + trackerLayout_[0]->SetName("RVsZ_Mixed"); + trackerLayout_[1] = td.make(); //"RVsZ_Pixel", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); + trackerLayout_[1]->SetName("RVsZ_Pixel"); + trackerLayout_[2] = td.make(); //"RVsZ_Strip", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); + trackerLayout_[2]->SetName("RVsZ_Strip"); + trackerLayoutXY_[0] = + td.make(); //"XVsY_Mixed", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXY_[0]->SetName("YVsX_Mixed"); + trackerLayoutXY_[1] = + td.make(); //"XVsY_Pixel", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXY_[1]->SetName("YVsX_Pixel"); + trackerLayoutXY_[2] = + td.make(); //"XVsY_Strip", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXY_[2]->SetName("YVsX_Strip"); + trackerLayoutXYBar_ = td.make(); //"XVsYBar", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXYBar_->SetName("YVsXBar"); + trackerLayoutXYEC_ = td.make(); //"XVsYEC", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXYEC_->SetName("YVsXEC"); +} void Phase2TrackerClusterizerValidationTGraph::endJob() {} void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) { - - // Get the needed objects + // Get the needed objects // Get the clusters - edm::Handle< Phase2TrackerCluster1DCollectionNew > clusters; + edm::Handle clusters; event.getByToken(srcClu_, clusters); // Get the Phase2 DigiSimLink @@ -154,179 +151,181 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, event.getByToken(siphase2OTSimLinksToken_, siphase2SimLinks); // Get the SimHits - edm::Handle< edm::PSimHitContainer > simHitsRaw; + edm::Handle simHitsRaw; event.getByToken(simHitsToken_, simHitsRaw); -// edm::Handle< edm::PSimHitContainer > simHitsRawEndcap; -// event.getByLabel("g4SimHits", "TrackerHitsPixelEndcapLowTof", simHitsRawEndcap); + // edm::Handle< edm::PSimHitContainer > simHitsRawEndcap; + // event.getByLabel("g4SimHits", "TrackerHitsPixelEndcapLowTof", simHitsRawEndcap); // Get the SimTracks - edm::Handle< edm::SimTrackContainer > simTracksRaw; + edm::Handle simTracksRaw; event.getByToken(simTracksToken_, simTracksRaw); // Get the SimVertex - edm::Handle< edm::SimVertexContainer > simVertices; + edm::Handle simVertices; event.getByToken(simVerticesToken_, simVertices); // Get the geometry - edm::ESHandle< TrackerGeometry > geomHandle; - eventSetup.get< TrackerDigiGeometryRecord >().get(geomHandle); + edm::ESHandle geomHandle; + eventSetup.get().get(geomHandle); tkGeom = &(*geomHandle); - edm::ESHandle< TrackerTopology > tTopoHandle; - eventSetup.get< TrackerTopologyRcd >().get(tTopoHandle); + edm::ESHandle tTopoHandle; + eventSetup.get().get(tTopoHandle); tkTopo = tTopoHandle.product(); - //set up for tree - int layer_number; - //int track_id; - int module_id; - int module_number; - int module_type; //1: pixel, 2: strip - float x_global, y_global, z_global; - float x_local, y_local, z_local; - - tree -> Branch("layer_number",&layer_number,"layer_number/I"); - //tree -> Branch("track_id",&track_id,"track_id/I"); - tree -> Branch("module_id",&module_id,"module_id/I"); - tree -> Branch("module_type",&module_type,"module_type/I"); - tree -> Branch("module_number",&module_number,"module_number/I"); - tree -> Branch("x_global",&x_global,"x_global/F"); - tree -> Branch("y_global",&y_global,"y_global/F"); - tree -> Branch("z_global",&z_global,"z_global/F"); - tree -> Branch("x_local",&x_local,"x_local/F"); - tree -> Branch("y_local",&y_local,"y_local/F"); - tree -> Branch("z_local",&z_local,"z_local/F"); - - // Rearrange the simTracks for ease of use - SimTracksMap simTracks; - for (edm::SimTrackContainer::const_iterator simTrackIt(simTracksRaw->begin()); simTrackIt != simTracksRaw->end(); ++simTrackIt) simTracks.insert(std::pair< unsigned int, SimTrack >(simTrackIt->trackId(), *simTrackIt)); - - // Rearrange the simHits by detUnit - - - // Rearrange the simHits for ease of use - SimHitsMap simHitsDetUnit; - SimHitsMap simHitsTrackId; - for (edm::PSimHitContainer::const_iterator simHitIt(simHitsRaw->begin()); simHitIt != simHitsRaw->end(); ++simHitIt) { - SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt->detUnitId())); - if (simHitsDetUnitIt == simHitsDetUnit.end()) { - std::pair< SimHitsMap::iterator, bool > newIt(simHitsDetUnit.insert(std::pair< unsigned int, std::vector< PSimHit > >(simHitIt->detUnitId(), std::vector< PSimHit >()))); - simHitsDetUnitIt = newIt.first; - } - simHitsDetUnitIt->second.push_back(*simHitIt); - SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt->trackId())); - if (simHitsTrackIdIt == simHitsTrackId.end()) { - std::pair< SimHitsMap::iterator, bool > newIt(simHitsTrackId.insert(std::pair< unsigned int, std::vector< PSimHit > >(simHitIt->trackId(), std::vector< PSimHit >()))); - simHitsTrackIdIt = newIt.first; - } - simHitsTrackIdIt->second.push_back(*simHitIt); + //set up for tree + int layer_number; + //int track_id; + int module_id; + int module_number; + int module_type; //1: pixel, 2: strip + float x_global, y_global, z_global; + float x_local, y_local, z_local; + + tree->Branch("layer_number", &layer_number, "layer_number/I"); + //tree -> Branch("track_id",&track_id,"track_id/I"); + tree->Branch("module_id", &module_id, "module_id/I"); + tree->Branch("module_type", &module_type, "module_type/I"); + tree->Branch("module_number", &module_number, "module_number/I"); + tree->Branch("x_global", &x_global, "x_global/F"); + tree->Branch("y_global", &y_global, "y_global/F"); + tree->Branch("z_global", &z_global, "z_global/F"); + tree->Branch("x_local", &x_local, "x_local/F"); + tree->Branch("y_local", &y_local, "y_local/F"); + tree->Branch("z_local", &z_local, "z_local/F"); + + // Rearrange the simTracks for ease of use + SimTracksMap simTracks; + for (edm::SimTrackContainer::const_iterator simTrackIt(simTracksRaw->begin()); simTrackIt != simTracksRaw->end(); + ++simTrackIt) + simTracks.insert(std::pair(simTrackIt->trackId(), *simTrackIt)); + + // Rearrange the simHits by detUnit + + // Rearrange the simHits for ease of use + SimHitsMap simHitsDetUnit; + SimHitsMap simHitsTrackId; + for (edm::PSimHitContainer::const_iterator simHitIt(simHitsRaw->begin()); simHitIt != simHitsRaw->end(); ++simHitIt) { + SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt->detUnitId())); + if (simHitsDetUnitIt == simHitsDetUnit.end()) { + std::pair newIt(simHitsDetUnit.insert( + std::pair >(simHitIt->detUnitId(), std::vector()))); + simHitsDetUnitIt = newIt.first; } + simHitsDetUnitIt->second.push_back(*simHitIt); + SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt->trackId())); + if (simHitsTrackIdIt == simHitsTrackId.end()) { + std::pair newIt(simHitsTrackId.insert( + std::pair >(simHitIt->trackId(), std::vector()))); + simHitsTrackIdIt = newIt.first; + } + simHitsTrackIdIt->second.push_back(*simHitIt); + } + // ValidationTGraph + unsigned int nClustersTot(0), nClustersPixelTot(0), nClustersStripTot(0); + + // Loop over modules + for (Phase2TrackerCluster1DCollectionNew::const_iterator DSViter = clusters->begin(); DSViter != clusters->end(); + ++DSViter) { + // Get the detector unit's id + unsigned int rawid(DSViter->detId()); + module_id = rawid; + DetId detId(rawid); + + layer_number = getLayerNumber(detId, tkTopo); + module_number = getModuleNumber(detId, tkTopo); + unsigned int layer(getLayerNumber(detId, tkTopo)); + + // Get the geometry of the tracker + const GeomDetUnit* geomDetUnit(tkGeom->idToDetUnit(detId)); + const PixelGeomDetUnit* theGeomDet = dynamic_cast(geomDetUnit); + const PixelTopology& topol = theGeomDet->specificTopology(); + + if (!geomDetUnit) + break; + + // Create histograms for the layer if they do not yet exist + std::map::iterator histogramLayer(histograms_.find(layer)); + if (histogramLayer == histograms_.end()) + histogramLayer = createLayerHistograms(layer); + + // Number of clusters + unsigned int nClustersPixel(0), nClustersStrip(0); + + // Loop over the clusters in the detector unit + for (edmNew::DetSet::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); + ++clustIt) { + // Cluster related variables + MeasurementPoint mpClu(clustIt->center(), clustIt->column() + 0.5); + Local3DPoint localPosClu = geomDetUnit->topology().localPosition(mpClu); + x_local = localPosClu.x(); + y_local = localPosClu.y(); + z_local = localPosClu.z(); + std::cout << localPosClu << std::endl; + + Global3DPoint globalPosClu = geomDetUnit->surface().toGlobal(localPosClu); + x_global = globalPosClu.x(); + y_global = globalPosClu.y(); + z_global = globalPosClu.z(); + //std::cout << globalPosClu << std::endl; + + // Fill the position histograms + trackerLayout_[0]->SetPoint(nClustersTot, globalPosClu.z(), globalPosClu.perp()); + trackerLayoutXY_[0]->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); + + if (layer < 100) + trackerLayoutXYBar_->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); + else + trackerLayoutXYEC_->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); + + histogramLayer->second.localPosXY[0]->SetPoint(nClustersTot, localPosClu.x(), localPosClu.y()); + histogramLayer->second.globalPosXY[0]->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); + + // Pixel module + if (topol.ncolumns() == 32) { + module_type = 1; + trackerLayout_[1]->SetPoint(nClustersPixelTot, globalPosClu.z(), globalPosClu.perp()); + trackerLayoutXY_[1]->SetPoint(nClustersPixelTot, globalPosClu.x(), globalPosClu.y()); + + histogramLayer->second.localPosXY[1]->SetPoint(nClustersPixelTot, localPosClu.x(), localPosClu.y()); + histogramLayer->second.globalPosXY[1]->SetPoint(nClustersPixelTot, globalPosClu.x(), globalPosClu.y()); + histogramLayer->second.clusterSizePixel->Fill(clustIt->size()); + ++nClustersPixel; + ++nClustersPixelTot; + } + // Strip module + else if (topol.ncolumns() == 2) { + module_type = 2; + trackerLayout_[2]->SetPoint(nClustersStripTot, globalPosClu.z(), globalPosClu.perp()); + trackerLayoutXY_[2]->SetPoint(nClustersStripTot, globalPosClu.x(), globalPosClu.y()); + + histogramLayer->second.localPosXY[2]->SetPoint(nClustersStripTot, localPosClu.x(), localPosClu.y()); + histogramLayer->second.globalPosXY[2]->SetPoint(nClustersStripTot, globalPosClu.x(), globalPosClu.y()); + histogramLayer->second.clusterSizeStrip->Fill(clustIt->size()); + ++nClustersStrip; + ++nClustersStripTot; + } + // * Digis related variables + + std::vector clusterSimTrackIds; + + // Get all the simTracks that form the cluster + for (unsigned int i(0); i < clustIt->size(); ++i) { + unsigned int channel(PixelDigi::pixelToChannel( + clustIt->firstRow() + i, + clustIt + ->column())); // Here we have to use the old pixelToChannel function (not Phase2TrackerDigi but PixelDigi), change this when using new Digis + unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detId, channel)); + clusterSimTrackIds.push_back(simTrackId); + std::cout << channel << std::endl; + std::cout << simTrackId << std::endl; + std::cout << std::endl; + } + unsigned int InnerChannel = clustIt->firstDigi().channel(); + std::cout << InnerChannel << std::endl; - // ValidationTGraph - unsigned int nClustersTot(0), nClustersPixelTot(0), nClustersStripTot(0); - - // Loop over modules - for (Phase2TrackerCluster1DCollectionNew::const_iterator DSViter = clusters->begin(); DSViter != clusters->end(); ++DSViter) { - - // Get the detector unit's id - unsigned int rawid(DSViter->detId()); - module_id = rawid; - DetId detId(rawid); - - layer_number = getLayerNumber(detId, tkTopo); - module_number = getModuleNumber(detId, tkTopo); - unsigned int layer(getLayerNumber(detId, tkTopo)); - - - // Get the geometry of the tracker - const GeomDetUnit* geomDetUnit(tkGeom->idToDetUnit(detId)); - const PixelGeomDetUnit* theGeomDet = dynamic_cast< const PixelGeomDetUnit* >(geomDetUnit); - const PixelTopology& topol = theGeomDet->specificTopology(); - - if (!geomDetUnit) break; - - // Create histograms for the layer if they do not yet exist - std::map< unsigned int, ClusterHistos >::iterator histogramLayer(histograms_.find(layer)); - if (histogramLayer == histograms_.end()) histogramLayer = createLayerHistograms(layer); - - // Number of clusters - unsigned int nClustersPixel(0), nClustersStrip(0); - - // Loop over the clusters in the detector unit - for (edmNew::DetSet< Phase2TrackerCluster1D >::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); ++clustIt) { - - - // Cluster related variables - MeasurementPoint mpClu(clustIt->center(), clustIt->column() + 0.5); - Local3DPoint localPosClu = geomDetUnit->topology().localPosition(mpClu); - x_local = localPosClu.x(); - y_local = localPosClu.y(); - z_local = localPosClu.z(); - std::cout << localPosClu << std::endl; - - Global3DPoint globalPosClu = geomDetUnit->surface().toGlobal(localPosClu); - x_global = globalPosClu.x(); - y_global = globalPosClu.y(); - z_global = globalPosClu.z(); - //std::cout << globalPosClu << std::endl; - - // Fill the position histograms - trackerLayout_[0]->SetPoint(nClustersTot, globalPosClu.z(), globalPosClu.perp()); - trackerLayoutXY_[0]->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); - - if (layer < 100) trackerLayoutXYBar_->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); - else trackerLayoutXYEC_->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); - - histogramLayer->second.localPosXY[0]->SetPoint(nClustersTot, localPosClu.x(), localPosClu.y()); - histogramLayer->second.globalPosXY[0]->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y()); - - // Pixel module - if (topol.ncolumns() == 32) { - module_type = 1; - trackerLayout_[1]->SetPoint(nClustersPixelTot, globalPosClu.z(), globalPosClu.perp()); - trackerLayoutXY_[1]->SetPoint(nClustersPixelTot, globalPosClu.x(), globalPosClu.y()); - - histogramLayer->second.localPosXY[1]->SetPoint(nClustersPixelTot, localPosClu.x(), localPosClu.y()); - histogramLayer->second.globalPosXY[1]->SetPoint(nClustersPixelTot, globalPosClu.x(), globalPosClu.y()); - histogramLayer->second.clusterSizePixel->Fill(clustIt->size()); - ++nClustersPixel; - ++nClustersPixelTot; - } - // Strip module - else if (topol.ncolumns() == 2) { - module_type = 2; - trackerLayout_[2]->SetPoint(nClustersStripTot, globalPosClu.z(), globalPosClu.perp()); - trackerLayoutXY_[2]->SetPoint(nClustersStripTot, globalPosClu.x(), globalPosClu.y()); - - histogramLayer->second.localPosXY[2]->SetPoint(nClustersStripTot, localPosClu.x(), localPosClu.y()); - histogramLayer->second.globalPosXY[2]->SetPoint(nClustersStripTot, globalPosClu.x(), globalPosClu.y()); - histogramLayer->second.clusterSizeStrip->Fill(clustIt->size()); - ++nClustersStrip; - ++nClustersStripTot; - } - - - - // * Digis related variables - - - std::vector< unsigned int > clusterSimTrackIds; - - // Get all the simTracks that form the cluster - for (unsigned int i(0); i < clustIt->size(); ++i) { - unsigned int channel(PixelDigi::pixelToChannel(clustIt->firstRow() + i, clustIt->column())); // Here we have to use the old pixelToChannel function (not Phase2TrackerDigi but PixelDigi), change this when using new Digis - unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detId, channel)); - clusterSimTrackIds.push_back(simTrackId); - std::cout << channel << std::endl; - std::cout << simTrackId << std::endl; - std::cout << std::endl; - } - unsigned int InnerChannel = clustIt->firstDigi().channel(); - std::cout << InnerChannel << std::endl; - - -/* + /* // SimHits related variables @@ -384,201 +383,243 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, histogramLayer->second.primarySimHits->Fill(primarySimHits); histogramLayer->second.otherSimHits->Fill(otherSimHits); */ - } - - if (nClustersPixel) histogramLayer->second.numberClusterPixel->Fill(nClustersPixel); - if (nClustersStrip) histogramLayer->second.numberClusterStrip->Fill(nClustersStrip); - nClustersTot++; - tree->Fill(); - } + } + if (nClustersPixel) + histogramLayer->second.numberClusterPixel->Fill(nClustersPixel); + if (nClustersStrip) + histogramLayer->second.numberClusterStrip->Fill(nClustersStrip); + nClustersTot++; + tree->Fill(); + } } // Create the histograms -std::map< unsigned int, ClusterHistos >::iterator Phase2TrackerClusterizerValidationTGraph::createLayerHistograms(unsigned int ival) { - std::ostringstream fname1, fname2; - - edm::Service fs; - fs->file().cd("/"); - - std::string tag; - unsigned int id; - if (ival < 100) { - id = ival; - fname1 << "Barrel"; - fname2 << "Layer_" << id; - tag = "_layer_"; - } - else { - int side = ival / 100; - id = ival - side * 100; - fname1 << "EndCap_Side_" << side; - fname2 << "Disc_" << id; - tag = "_disc_"; - } +std::map::iterator Phase2TrackerClusterizerValidationTGraph::createLayerHistograms( + unsigned int ival) { + std::ostringstream fname1, fname2; + + edm::Service fs; + fs->file().cd("/"); + + std::string tag; + unsigned int id; + if (ival < 100) { + id = ival; + fname1 << "Barrel"; + fname2 << "Layer_" << id; + tag = "_layer_"; + } else { + int side = ival / 100; + id = ival - side * 100; + fname1 << "EndCap_Side_" << side; + fname2 << "Disc_" << id; + tag = "_disc_"; + } - TFileDirectory td1 = fs->mkdir(fname1.str().c_str()); - TFileDirectory td = td1.mkdir(fname2.str().c_str()); + TFileDirectory td1 = fs->mkdir(fname1.str().c_str()); + TFileDirectory td = td1.mkdir(fname2.str().c_str()); - ClusterHistos local_histos; + ClusterHistos local_histos; - std::ostringstream histoName; + std::ostringstream histoName; - /* + /* * Number of clusters */ - histoName.str(""); histoName << "Number_Clusters_Pixel" << tag.c_str() << id; - local_histos.numberClusterPixel = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); - local_histos.numberClusterPixel->SetFillColor(kAzure + 7); + histoName.str(""); + histoName << "Number_Clusters_Pixel" << tag.c_str() << id; + local_histos.numberClusterPixel = td.make(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberClusterPixel->SetFillColor(kAzure + 7); - histoName.str(""); histoName << "Number_Clusters_Strip" << tag.c_str() << id; - local_histos.numberClusterStrip = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); - local_histos.numberClusterStrip->SetFillColor(kOrange - 3); + histoName.str(""); + histoName << "Number_Clusters_Strip" << tag.c_str() << id; + local_histos.numberClusterStrip = td.make(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberClusterStrip->SetFillColor(kOrange - 3); - histoName.str(""); histoName << "Number_Clusters_Mixed" << tag.c_str() << id; - local_histos.numberClustersMixed = td.make< THStack >(histoName.str().c_str(), histoName.str().c_str()); - local_histos.numberClustersMixed->Add(local_histos.numberClusterPixel); - local_histos.numberClustersMixed->Add(local_histos.numberClusterStrip); + histoName.str(""); + histoName << "Number_Clusters_Mixed" << tag.c_str() << id; + local_histos.numberClustersMixed = td.make(histoName.str().c_str(), histoName.str().c_str()); + local_histos.numberClustersMixed->Add(local_histos.numberClusterPixel); + local_histos.numberClustersMixed->Add(local_histos.numberClusterStrip); - /* + /* * Cluster size */ - histoName.str(""); histoName << "Cluster_Size_Pixel" << tag.c_str() << id; - local_histos.clusterSizePixel = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - local_histos.clusterSizePixel->SetFillColor(kAzure + 7); + histoName.str(""); + histoName << "Cluster_Size_Pixel" << tag.c_str() << id; + local_histos.clusterSizePixel = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + local_histos.clusterSizePixel->SetFillColor(kAzure + 7); - histoName.str(""); histoName << "Cluster_Size_Strip" << tag.c_str() << id; - local_histos.clusterSizeStrip = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - local_histos.clusterSizeStrip->SetFillColor(kOrange - 3); + histoName.str(""); + histoName << "Cluster_Size_Strip" << tag.c_str() << id; + local_histos.clusterSizeStrip = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + local_histos.clusterSizeStrip->SetFillColor(kOrange - 3); - histoName.str(""); histoName << "Cluster_Size_Mixed" << tag.c_str() << id; - local_histos.clustersSizeMixed = td.make< THStack >(histoName.str().c_str(), histoName.str().c_str()); - local_histos.clustersSizeMixed->Add(local_histos.clusterSizePixel); - local_histos.clustersSizeMixed->Add(local_histos.clusterSizeStrip); + histoName.str(""); + histoName << "Cluster_Size_Mixed" << tag.c_str() << id; + local_histos.clustersSizeMixed = td.make(histoName.str().c_str(), histoName.str().c_str()); + local_histos.clustersSizeMixed->Add(local_histos.clusterSizePixel); + local_histos.clustersSizeMixed->Add(local_histos.clusterSizeStrip); - /* + /* * Local and Global positions */ - histoName.str(""); histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; - local_histos.localPosXY[0] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); - local_histos.localPosXY[0]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Local_Position_XY_Pixel" << tag.c_str() << id; - local_histos.localPosXY[1] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); - local_histos.localPosXY[1]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Local_Position_XY_Strip" << tag.c_str() << id; - local_histos.localPosXY[2] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); - local_histos.localPosXY[2]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; - local_histos.globalPosXY[0] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); - local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Global_Position_XY_Pixel" << tag.c_str() << id; - local_histos.globalPosXY[1] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); - local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Global_Position_XY_Strip" << tag.c_str() << id; - local_histos.globalPosXY[2] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); - local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); - - /* + histoName.str(""); + histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; + local_histos.localPosXY[0] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Local_Position_XY_Pixel" << tag.c_str() << id; + local_histos.localPosXY[1] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Local_Position_XY_Strip" << tag.c_str() << id; + local_histos.localPosXY[2] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[2]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; + local_histos.globalPosXY[0] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Global_Position_XY_Pixel" << tag.c_str() << id; + local_histos.globalPosXY[1] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Global_Position_XY_Strip" << tag.c_str() << id; + local_histos.globalPosXY[2] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); + + /* * Delta positions with SimHits */ - histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Mixed" << tag.c_str() << id; - local_histos.deltaXClusterSimHits[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_Cluster_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaXClusterSimHits[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Pixel" << tag.c_str() << id; - local_histos.deltaXClusterSimHits[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_Cluster_SimHits_Pixel" << tag.c_str() << id; + local_histos.deltaXClusterSimHits[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Strip" << tag.c_str() << id; - local_histos.deltaXClusterSimHits[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_Cluster_SimHits_Strip" << tag.c_str() << id; + local_histos.deltaXClusterSimHits[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Mixed" << tag.c_str() << id; - local_histos.deltaYClusterSimHits[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_Cluster_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaYClusterSimHits[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Pixel" << tag.c_str() << id; - local_histos.deltaYClusterSimHits[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_Cluster_SimHits_Pixel" << tag.c_str() << id; + local_histos.deltaYClusterSimHits[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Strip" << tag.c_str() << id; - local_histos.deltaYClusterSimHits[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_Cluster_SimHits_Strip" << tag.c_str() << id; + local_histos.deltaYClusterSimHits[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - /* + /* * Delta position with simHits for primary tracks only */ - histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Mixed_P" << tag.c_str() << id; - local_histos.deltaXClusterSimHits_P[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_Cluster_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaXClusterSimHits_P[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Pixel_P" << tag.c_str() << id; - local_histos.deltaXClusterSimHits_P[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_Cluster_SimHits_Pixel_P" << tag.c_str() << id; + local_histos.deltaXClusterSimHits_P[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_X_Cluster_SimHits_Strip_P" << tag.c_str() << id; - local_histos.deltaXClusterSimHits_P[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_Cluster_SimHits_Strip_P" << tag.c_str() << id; + local_histos.deltaXClusterSimHits_P[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Mixed_P" << tag.c_str() << id; - local_histos.deltaYClusterSimHits_P[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_Cluster_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaYClusterSimHits_P[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Pixel_P" << tag.c_str() << id; - local_histos.deltaYClusterSimHits_P[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_Cluster_SimHits_Pixel_P" << tag.c_str() << id; + local_histos.deltaYClusterSimHits_P[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_Cluster_SimHits_Strip_P" << tag.c_str() << id; - local_histos.deltaYClusterSimHits_P[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_Cluster_SimHits_Strip_P" << tag.c_str() << id; + local_histos.deltaYClusterSimHits_P[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - /* + /* * Information on the Digis per cluster */ - histoName.str(""); histoName << "Primary_Digis" << tag.c_str() << id; - local_histos.primarySimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + histoName.str(""); + histoName << "Primary_Digis" << tag.c_str() << id; + local_histos.primarySimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - histoName.str(""); histoName << "Other_Digis" << tag.c_str() << id; - local_histos.otherSimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + histoName.str(""); + histoName << "Other_Digis" << tag.c_str() << id; + local_histos.otherSimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - /* + /* * End */ - std::pair< std::map< unsigned int, ClusterHistos >::iterator, bool > insertedIt(histograms_.insert(std::make_pair(ival, local_histos))); - fs->file().cd("/"); + std::pair::iterator, bool> insertedIt( + histograms_.insert(std::make_pair(ival, local_histos))); + fs->file().cd("/"); - return insertedIt.first; + return insertedIt.first; } unsigned int Phase2TrackerClusterizerValidationTGraph::getLayerNumber(const DetId& detid, const TrackerTopology* topo) { - if (detid.det() == DetId::Tracker) { - if (detid.subdetId() == PixelSubdetector::PixelBarrel) return (topo->pxbLayer(detid)); - else if (detid.subdetId() == PixelSubdetector::PixelEndcap) return (100 * topo->pxfSide(detid) + topo->pxfDisk(detid)); - else return 999; - } - return 999; + if (detid.det() == DetId::Tracker) { + if (detid.subdetId() == PixelSubdetector::PixelBarrel) + return (topo->pxbLayer(detid)); + else if (detid.subdetId() == PixelSubdetector::PixelEndcap) + return (100 * topo->pxfSide(detid) + topo->pxfDisk(detid)); + else + return 999; + } + return 999; } -unsigned int Phase2TrackerClusterizerValidationTGraph::getModuleNumber(const DetId& detid, const TrackerTopology* topo) { +unsigned int Phase2TrackerClusterizerValidationTGraph::getModuleNumber(const DetId& detid, + const TrackerTopology* topo) { if (detid.det() == DetId::Tracker) { - if (detid.subdetId() == PixelSubdetector::PixelBarrel) { - return ( topo->pxbModule(detid) ); - } - else if (detid.subdetId() == PixelSubdetector::PixelEndcap) { - return ( topo->pxfModule(detid) ); - } - else return 999; + if (detid.subdetId() == PixelSubdetector::PixelBarrel) { + return (topo->pxbModule(detid)); + } else if (detid.subdetId() == PixelSubdetector::PixelEndcap) { + return (topo->pxfModule(detid)); + } else + return 999; } return 999; } -unsigned int Phase2TrackerClusterizerValidationTGraph::getSimTrackId(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& siphase2SimLinks, const DetId& detId, unsigned int channel) { - edm::DetSetVector< PixelDigiSimLink >::const_iterator DSViter(siphase2SimLinks->find(detId)); - if (DSViter == siphase2SimLinks->end()) return 0; - for (edm::DetSet< PixelDigiSimLink >::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { - if (channel == it->channel()) return it->SimTrackId(); - } +unsigned int Phase2TrackerClusterizerValidationTGraph::getSimTrackId( + const edm::Handle >& siphase2SimLinks, + const DetId& detId, + unsigned int channel) { + edm::DetSetVector::const_iterator DSViter(siphase2SimLinks->find(detId)); + if (DSViter == siphase2SimLinks->end()) return 0; + for (edm::DetSet::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { + if (channel == it->channel()) + return it->SimTrackId(); + } + return 0; } DEFINE_FWK_MODULE(Phase2TrackerClusterizerValidationTGraph); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 10992b5d94984..6c45bd53236e0 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -8,63 +8,62 @@ #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" -VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet& conf) : - cpeTag_(conf.getParameter("CPE")) -{ - srcClu_ = consumes< edmNew::DetSetVector >(edm::InputTag(conf.getParameter("src"))); - VHacc_ = consumes< VectorHitCollectionNew >(edm::InputTag(conf.getParameter("VH_acc"))); - VHrej_ = consumes< VectorHitCollectionNew >(edm::InputTag(conf.getParameter("VH_rej"))); +VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet& conf) + : cpeTag_(conf.getParameter("CPE")) { + srcClu_ = + consumes >(edm::InputTag(conf.getParameter("src"))); + VHacc_ = consumes(edm::InputTag(conf.getParameter("VH_acc"))); + VHrej_ = consumes(edm::InputTag(conf.getParameter("VH_rej"))); siphase2OTSimLinksToken_ = consumes >(conf.getParameter("links")); - simHitsToken_ = consumes< edm::PSimHitContainer >(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof")); - simTracksToken_ = consumes< edm::SimTrackContainer >(edm::InputTag("g4SimHits")); - simVerticesToken_ = consumes< edm::SimVertexContainer >(edm::InputTag("g4SimHits")); - trackingParticleToken_ = consumes< TrackingParticleCollection >(conf.getParameter("trackingParticleSrc")); + simHitsToken_ = consumes(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof")); + simTracksToken_ = consumes(edm::InputTag("g4SimHits")); + simVerticesToken_ = consumes(edm::InputTag("g4SimHits")); + trackingParticleToken_ = + consumes(conf.getParameter("trackingParticleSrc")); } -VectorHitsBuilderValidation::~VectorHitsBuilderValidation() { -} +VectorHitsBuilderValidation::~VectorHitsBuilderValidation() {} void VectorHitsBuilderValidation::beginJob() { - edm::Service fs; fs->file().cd("/"); TFileDirectory td = fs->mkdir("Common"); //Create common ntuple - tree = td.make< TTree >("VectorHits","VectorHits"); + tree = td.make("VectorHits", "VectorHits"); // Create common graphs TFileDirectory tdGloPos = td.mkdir("GlobalPositions"); - trackerLayoutRZ_[0] = tdGloPos.make< TGraph >(); - trackerLayoutRZ_[0] -> SetName("RVsZ_Mixed"); - trackerLayoutRZ_[1] = tdGloPos.make< TGraph >(); - trackerLayoutRZ_[1] -> SetName("RVsZ_Pixel"); - trackerLayoutRZ_[2] = tdGloPos.make< TGraph >(); - trackerLayoutRZ_[2] -> SetName("RVsZ_Strip"); - trackerLayoutXY_[0] = tdGloPos.make< TGraph >(); - trackerLayoutXY_[0] -> SetName("YVsX_Mixed"); - trackerLayoutXY_[1] = tdGloPos.make< TGraph >(); - trackerLayoutXY_[1] -> SetName("YVsX_Pixel"); - trackerLayoutXY_[2] = tdGloPos.make< TGraph >(); - trackerLayoutXY_[2] -> SetName("YVsX_Strip"); - trackerLayoutXYBar_ = tdGloPos.make< TGraph >(); - trackerLayoutXYBar_ -> SetName("YVsXBar"); - trackerLayoutXYEC_ = tdGloPos.make< TGraph >(); - trackerLayoutXYEC_ -> SetName("YVsXEC"); + trackerLayoutRZ_[0] = tdGloPos.make(); + trackerLayoutRZ_[0]->SetName("RVsZ_Mixed"); + trackerLayoutRZ_[1] = tdGloPos.make(); + trackerLayoutRZ_[1]->SetName("RVsZ_Pixel"); + trackerLayoutRZ_[2] = tdGloPos.make(); + trackerLayoutRZ_[2]->SetName("RVsZ_Strip"); + trackerLayoutXY_[0] = tdGloPos.make(); + trackerLayoutXY_[0]->SetName("YVsX_Mixed"); + trackerLayoutXY_[1] = tdGloPos.make(); + trackerLayoutXY_[1]->SetName("YVsX_Pixel"); + trackerLayoutXY_[2] = tdGloPos.make(); + trackerLayoutXY_[2]->SetName("YVsX_Strip"); + trackerLayoutXYBar_ = tdGloPos.make(); + trackerLayoutXYBar_->SetName("YVsXBar"); + trackerLayoutXYEC_ = tdGloPos.make(); + trackerLayoutXYEC_->SetName("YVsXEC"); TFileDirectory tdLocPos = td.mkdir("LocalPositions"); - localPosXvsDeltaX_[0] = tdLocPos.make< TGraph >(); - localPosXvsDeltaX_[0] -> SetName("localPosXvsDeltaX_Mixed"); - localPosXvsDeltaX_[1] = tdLocPos.make< TGraph >(); - localPosXvsDeltaX_[1] -> SetName("localPosXvsDeltaX_Pixel"); - localPosXvsDeltaX_[2] = tdLocPos.make< TGraph >(); - localPosXvsDeltaX_[2] -> SetName("localPosXvsDeltaX_Strip"); - localPosYvsDeltaY_[0] = tdLocPos.make< TGraph >(); - localPosYvsDeltaY_[0] -> SetName("localPosYvsDeltaY_Mixed"); - localPosYvsDeltaY_[1] = tdLocPos.make< TGraph >(); - localPosYvsDeltaY_[1] -> SetName("localPosYvsDeltaY_Pixel"); - localPosYvsDeltaY_[2] = tdLocPos.make< TGraph >(); - localPosYvsDeltaY_[2] -> SetName("localPosYvsDeltaY_Strip"); + localPosXvsDeltaX_[0] = tdLocPos.make(); + localPosXvsDeltaX_[0]->SetName("localPosXvsDeltaX_Mixed"); + localPosXvsDeltaX_[1] = tdLocPos.make(); + localPosXvsDeltaX_[1]->SetName("localPosXvsDeltaX_Pixel"); + localPosXvsDeltaX_[2] = tdLocPos.make(); + localPosXvsDeltaX_[2]->SetName("localPosXvsDeltaX_Strip"); + localPosYvsDeltaY_[0] = tdLocPos.make(); + localPosYvsDeltaY_[0]->SetName("localPosYvsDeltaY_Mixed"); + localPosYvsDeltaY_[1] = tdLocPos.make(); + localPosYvsDeltaY_[1]->SetName("localPosYvsDeltaY_Pixel"); + localPosYvsDeltaY_[2] = tdLocPos.make(); + localPosYvsDeltaY_[2]->SetName("localPosYvsDeltaY_Strip"); //drawing VHs arrows TFileDirectory tdArr = td.mkdir("Directions"); @@ -74,44 +73,42 @@ void VectorHitsBuilderValidation::beginJob() { //VHXY_[2] = tdArr.make< TCanvas >(); VHXY_[2] -> SetName("YVsX_Strip"); TFileDirectory tdWid = td.mkdir("CombinatorialStudies"); - ParallaxCorrectionRZ_ = tdWid.make< TH2D >("ParallaxCorrectionRZ","ParallaxCorrectionRZ", 100, 0., 300., 100., 0., 120.); - ParallaxCorrectionRZ_ -> SetName("ParallaxCorrectionFactor"); - VHaccLayer_ = tdWid.make< TH1F >("VHacceptedLayer","VHacceptedLayer", 250, 0., 250.); - VHaccLayer_ -> SetName("VHaccepted"); - VHrejLayer_ = tdWid.make< TH1F >("VHrejectedLayer","VHrejectedLayer", 250, 0., 250.); - VHrejLayer_ -> SetName("VHrejected"); - VHaccTrueLayer_ = tdWid.make< TH1F >("VHaccTrueLayer","VHaccTrueLayer", 250, 0., 250.); - VHaccTrueLayer_ -> SetName("VHaccepted_true"); - VHrejTrueLayer_ = tdWid.make< TH1F >("VHrejTrueLayer","VHrejTrueLayer", 250, 0., 250.); - VHrejTrueLayer_ -> SetName("VHrejected_true"); - VHaccTrue_signal_Layer_ = tdWid.make< TH1F >("VHaccTrueSignalLayer","VHaccTrueSignalLayer", 250, 0., 250.); - VHaccTrue_signal_Layer_ -> SetName("VHaccepted_true_signal"); - VHrejTrue_signal_Layer_ = tdWid.make< TH1F >("VHrejTrueSignalLayer","VHrejTrueSignalLayer", 250, 0., 250.); - VHrejTrue_signal_Layer_ -> SetName("VHrejected_true_signal"); - - VHaccTrueLayer_ratio = tdWid.make< TH1F >("VHaccTrueLayer_ratio","VHaccTrueLayer_ratio", 250, 0., 250.); - VHaccTrueLayer_ratio -> SetName("VHaccepted_true_ratio"); - VHrejTrueLayer_ratio = tdWid.make< TH1F >("VHrejTrueLayer_ratio","VHrejTrueLayer_ratio", 250, 0., 250.); - VHrejTrueLayer_ratio -> SetName("VHrejected_true_ratio"); - - + ParallaxCorrectionRZ_ = + tdWid.make("ParallaxCorrectionRZ", "ParallaxCorrectionRZ", 100, 0., 300., 100., 0., 120.); + ParallaxCorrectionRZ_->SetName("ParallaxCorrectionFactor"); + VHaccLayer_ = tdWid.make("VHacceptedLayer", "VHacceptedLayer", 250, 0., 250.); + VHaccLayer_->SetName("VHaccepted"); + VHrejLayer_ = tdWid.make("VHrejectedLayer", "VHrejectedLayer", 250, 0., 250.); + VHrejLayer_->SetName("VHrejected"); + VHaccTrueLayer_ = tdWid.make("VHaccTrueLayer", "VHaccTrueLayer", 250, 0., 250.); + VHaccTrueLayer_->SetName("VHaccepted_true"); + VHrejTrueLayer_ = tdWid.make("VHrejTrueLayer", "VHrejTrueLayer", 250, 0., 250.); + VHrejTrueLayer_->SetName("VHrejected_true"); + VHaccTrue_signal_Layer_ = tdWid.make("VHaccTrueSignalLayer", "VHaccTrueSignalLayer", 250, 0., 250.); + VHaccTrue_signal_Layer_->SetName("VHaccepted_true_signal"); + VHrejTrue_signal_Layer_ = tdWid.make("VHrejTrueSignalLayer", "VHrejTrueSignalLayer", 250, 0., 250.); + VHrejTrue_signal_Layer_->SetName("VHrejected_true_signal"); + + VHaccTrueLayer_ratio = tdWid.make("VHaccTrueLayer_ratio", "VHaccTrueLayer_ratio", 250, 0., 250.); + VHaccTrueLayer_ratio->SetName("VHaccepted_true_ratio"); + VHrejTrueLayer_ratio = tdWid.make("VHrejTrueLayer_ratio", "VHrejTrueLayer_ratio", 250, 0., 250.); + VHrejTrueLayer_ratio->SetName("VHrejected_true_ratio"); } void VectorHitsBuilderValidation::endJob() {} void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) { - // Get the needed objects // Get the clusters - edm::Handle< Phase2TrackerCluster1DCollectionNew > clusters; + edm::Handle clusters; event.getByToken(srcClu_, clusters); // Get the vector hits - edm::Handle< VectorHitCollectionNew > vhsAcc; + edm::Handle vhsAcc; event.getByToken(VHacc_, vhsAcc); - edm::Handle< VectorHitCollectionNew > vhsRej; + edm::Handle vhsRej; event.getByToken(VHrej_, vhsRej); // load the cpe via the eventsetup @@ -124,36 +121,36 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev event.getByToken(siphase2OTSimLinksToken_, siphase2SimLinks); // Get the SimHits - edm::Handle< edm::PSimHitContainer > simHitsRaw; + edm::Handle simHitsRaw; event.getByToken(simHitsToken_, simHitsRaw); -// edm::Handle< edm::PSimHitContainer > simHitsRawEndcap; -// event.getByLabel("g4SimHits", "TrackerHitsPixelEndcapLowTof", simHitsRawEndcap); + // edm::Handle< edm::PSimHitContainer > simHitsRawEndcap; + // event.getByLabel("g4SimHits", "TrackerHitsPixelEndcapLowTof", simHitsRawEndcap); // Get the SimTracks - edm::Handle< edm::SimTrackContainer > simTracksRaw; + edm::Handle simTracksRaw; event.getByToken(simTracksToken_, simTracksRaw); // Get the SimVertex - edm::Handle< edm::SimVertexContainer > simVertices; + edm::Handle simVertices; event.getByToken(simVerticesToken_, simVertices); // Get the geometry - edm::ESHandle< TrackerGeometry > geomHandle; - eventSetup.get< TrackerDigiGeometryRecord >().get(geomHandle); + edm::ESHandle geomHandle; + eventSetup.get().get(geomHandle); tkGeom = &(*geomHandle); // Get the Topology - edm::ESHandle< TrackerTopology > tTopoHandle; - eventSetup.get< TrackerTopologyRcd >().get(tTopoHandle); + edm::ESHandle tTopoHandle; + eventSetup.get().get(tTopoHandle); tkTopo = tTopoHandle.product(); - edm::ESHandle< MagneticField > magFieldHandle; - eventSetup.get< IdealMagneticFieldRecord >().get(magFieldHandle); + edm::ESHandle magFieldHandle; + eventSetup.get().get(magFieldHandle); magField = magFieldHandle.product(); //Tracking Particle collection - edm::Handle TPCollectionH; - event.getByToken(trackingParticleToken_,TPCollectionH); + edm::Handle TPCollectionH; + event.getByToken(trackingParticleToken_, TPCollectionH); auto clusterTPList = std::make_unique(TPCollectionH); std::map, TrackingParticleRef> mapping; @@ -161,10 +158,12 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev for (TrackingParticleCollection::size_type itp = 0; itp < TPCollectionH.product()->size(); ++itp) { TrackingParticleRef trackingParticle(TPCollectionH, itp); EncodedEventId eid(trackingParticle->eventId()); - for (std::vector::const_iterator itrk = trackingParticle->g4Track_begin(); - itrk != trackingParticle->g4Track_end(); ++itrk) { + for (std::vector::const_iterator itrk = trackingParticle->g4Track_begin(); + itrk != trackingParticle->g4Track_end(); + ++itrk) { std::pair trkid(itrk->trackId(), eid); - LogTrace("VectorHitsBuilderValidation") << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key() ; + LogTrace("VectorHitsBuilderValidation") + << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key(); mapping.insert(std::make_pair(trkid, trackingParticle)); } } @@ -174,7 +173,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev int layer; int module_id; int module_number; - int module_type; //1: pixel, 2: strip + int module_type; //1: pixel, 2: strip int VHacc = 0.0; int VHrej = 0.0; int vh_isTrue; @@ -201,62 +200,64 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev float width, deltaXlocal; unsigned int processType(99); - tree -> Branch("event",&eventNum,"eventNum/I"); - tree -> Branch("accepted",&VHacc,"VHacc/I"); - tree -> Branch("rejected",&VHrej,"VHrej/I"); - tree -> Branch("layer",&layer,"layer/I"); - tree -> Branch("module_id",&module_id,"module_id/I"); - tree -> Branch("module_type",&module_type,"module_type/I"); - tree -> Branch("module_number",&module_number,"module_number/I"); - tree -> Branch("vh_isTrue",&vh_isTrue,"vh_isTrue/I"); - tree -> Branch("x_global",&x_global,"x_global/F"); - tree -> Branch("y_global",&y_global,"y_global/F"); - tree -> Branch("z_global",&z_global,"z_global/F"); - tree -> Branch("vh_x_local",&vh_x_local,"vh_x_local/F"); - tree -> Branch("vh_y_local",&vh_y_local,"vh_y_local/F"); - tree -> Branch("vh_x_lError",&vh_x_le,"vh_x_le/F"); - tree -> Branch("vh_y_lError",&vh_y_le,"vh_y_le/F"); - tree -> Branch("curvature",&curvature,"curvature/F"); - tree -> Branch("chi2",&chi2,"chi2/F"); - tree -> Branch("phi",&phi,"phi/F"); - tree -> Branch("QOverP",&QOverP,"QOverP/F"); - tree -> Branch("QOverPT",&QOverPT,"QOverPT/F"); - tree -> Branch("low_tp_id",&low_tp_id,"low_tp_id/I"); - tree -> Branch("upp_tp_id",&upp_tp_id,"upp_tp_id/I"); - tree -> Branch("vh_sim_trackPt",&vh_sim_trackPt,"vh_sim_trackPt/F"); - tree -> Branch("sim_x_local",&sim_x_local,"sim_x_local/F"); - tree -> Branch("sim_y_local",&sim_y_local,"sim_y_local/F"); - tree -> Branch("sim_x_global",&sim_x_global,"sim_x_global/F"); - tree -> Branch("sim_y_global",&sim_y_global,"sim_y_global/F"); - tree -> Branch("sim_z_global",&sim_z_global,"sim_z_global/F"); - tree -> Branch("low_x_global",&low_x_global,"low_x_global/F"); - tree -> Branch("low_y_global",&low_y_global,"low_y_global/F"); - tree -> Branch("low_z_global",&low_z_global,"low_z_global/F"); - tree -> Branch("low_xx_global_err",&low_xx_global_err,"low_xx_global_err/F"); - tree -> Branch("low_yy_global_err",&low_yy_global_err,"low_yy_global_err/F"); - tree -> Branch("low_zz_global_err",&low_zz_global_err,"low_zz_global_err/F"); - tree -> Branch("low_xy_global_err",&low_xy_global_err,"low_xy_global_err/F"); - tree -> Branch("low_zx_global_err",&low_zx_global_err,"low_zx_global_err/F"); - tree -> Branch("low_zy_global_err",&low_zy_global_err,"low_zy_global_err/F"); - tree -> Branch("upp_x_global",&upp_x_global,"upp_x_global/F"); - tree -> Branch("upp_y_global",&upp_y_global,"upp_y_global/F"); - tree -> Branch("upp_z_global",&upp_z_global,"upp_z_global/F"); - tree -> Branch("upp_xx_global_err",&upp_xx_global_err,"upp_xx_global_err/F"); - tree -> Branch("upp_yy_global_err",&upp_yy_global_err,"upp_yy_global_err/F"); - tree -> Branch("upp_zz_global_err",&upp_zz_global_err,"upp_zz_global_err/F"); - tree -> Branch("upp_xy_global_err",&upp_xy_global_err,"upp_xy_global_err/F"); - tree -> Branch("upp_zx_global_err",&upp_zx_global_err,"upp_zx_global_err/F"); - tree -> Branch("upp_zy_global_err",&upp_zy_global_err,"upp_zy_global_err/F"); - tree -> Branch("deltaXVHSimHits",&deltaXVHSimHits,"deltaXVHSimHits/F"); - tree -> Branch("deltaYVHSimHits",&deltaYVHSimHits,"deltaYVHSimHits/F"); - tree -> Branch("multiplicity",&multiplicity,"multiplicity/I"); - tree -> Branch("width",&width,"width/F"); - tree -> Branch("deltaXlocal",&deltaXlocal,"deltaXlocal/F"); - tree -> Branch("processType",&processType,"processType/i"); + tree->Branch("event", &eventNum, "eventNum/I"); + tree->Branch("accepted", &VHacc, "VHacc/I"); + tree->Branch("rejected", &VHrej, "VHrej/I"); + tree->Branch("layer", &layer, "layer/I"); + tree->Branch("module_id", &module_id, "module_id/I"); + tree->Branch("module_type", &module_type, "module_type/I"); + tree->Branch("module_number", &module_number, "module_number/I"); + tree->Branch("vh_isTrue", &vh_isTrue, "vh_isTrue/I"); + tree->Branch("x_global", &x_global, "x_global/F"); + tree->Branch("y_global", &y_global, "y_global/F"); + tree->Branch("z_global", &z_global, "z_global/F"); + tree->Branch("vh_x_local", &vh_x_local, "vh_x_local/F"); + tree->Branch("vh_y_local", &vh_y_local, "vh_y_local/F"); + tree->Branch("vh_x_lError", &vh_x_le, "vh_x_le/F"); + tree->Branch("vh_y_lError", &vh_y_le, "vh_y_le/F"); + tree->Branch("curvature", &curvature, "curvature/F"); + tree->Branch("chi2", &chi2, "chi2/F"); + tree->Branch("phi", &phi, "phi/F"); + tree->Branch("QOverP", &QOverP, "QOverP/F"); + tree->Branch("QOverPT", &QOverPT, "QOverPT/F"); + tree->Branch("low_tp_id", &low_tp_id, "low_tp_id/I"); + tree->Branch("upp_tp_id", &upp_tp_id, "upp_tp_id/I"); + tree->Branch("vh_sim_trackPt", &vh_sim_trackPt, "vh_sim_trackPt/F"); + tree->Branch("sim_x_local", &sim_x_local, "sim_x_local/F"); + tree->Branch("sim_y_local", &sim_y_local, "sim_y_local/F"); + tree->Branch("sim_x_global", &sim_x_global, "sim_x_global/F"); + tree->Branch("sim_y_global", &sim_y_global, "sim_y_global/F"); + tree->Branch("sim_z_global", &sim_z_global, "sim_z_global/F"); + tree->Branch("low_x_global", &low_x_global, "low_x_global/F"); + tree->Branch("low_y_global", &low_y_global, "low_y_global/F"); + tree->Branch("low_z_global", &low_z_global, "low_z_global/F"); + tree->Branch("low_xx_global_err", &low_xx_global_err, "low_xx_global_err/F"); + tree->Branch("low_yy_global_err", &low_yy_global_err, "low_yy_global_err/F"); + tree->Branch("low_zz_global_err", &low_zz_global_err, "low_zz_global_err/F"); + tree->Branch("low_xy_global_err", &low_xy_global_err, "low_xy_global_err/F"); + tree->Branch("low_zx_global_err", &low_zx_global_err, "low_zx_global_err/F"); + tree->Branch("low_zy_global_err", &low_zy_global_err, "low_zy_global_err/F"); + tree->Branch("upp_x_global", &upp_x_global, "upp_x_global/F"); + tree->Branch("upp_y_global", &upp_y_global, "upp_y_global/F"); + tree->Branch("upp_z_global", &upp_z_global, "upp_z_global/F"); + tree->Branch("upp_xx_global_err", &upp_xx_global_err, "upp_xx_global_err/F"); + tree->Branch("upp_yy_global_err", &upp_yy_global_err, "upp_yy_global_err/F"); + tree->Branch("upp_zz_global_err", &upp_zz_global_err, "upp_zz_global_err/F"); + tree->Branch("upp_xy_global_err", &upp_xy_global_err, "upp_xy_global_err/F"); + tree->Branch("upp_zx_global_err", &upp_zx_global_err, "upp_zx_global_err/F"); + tree->Branch("upp_zy_global_err", &upp_zy_global_err, "upp_zy_global_err/F"); + tree->Branch("deltaXVHSimHits", &deltaXVHSimHits, "deltaXVHSimHits/F"); + tree->Branch("deltaYVHSimHits", &deltaYVHSimHits, "deltaYVHSimHits/F"); + tree->Branch("multiplicity", &multiplicity, "multiplicity/I"); + tree->Branch("width", &width, "width/F"); + tree->Branch("deltaXlocal", &deltaXlocal, "deltaXlocal/F"); + tree->Branch("processType", &processType, "processType/i"); // Rearrange the simTracks for ease of use SimTracksMap simTracks; - for (edm::SimTrackContainer::const_iterator simTrackIt(simTracksRaw->begin()); simTrackIt != simTracksRaw->end(); ++simTrackIt) simTracks.insert(std::pair< unsigned int, SimTrack >(simTrackIt->trackId(), *simTrackIt)); + for (edm::SimTrackContainer::const_iterator simTrackIt(simTracksRaw->begin()); simTrackIt != simTracksRaw->end(); + ++simTrackIt) + simTracks.insert(std::pair(simTrackIt->trackId(), *simTrackIt)); // Rearrange the simHits by detUnit for ease of use SimHitsMap simHitsDetUnit; @@ -264,38 +265,43 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev for (edm::PSimHitContainer::const_iterator simHitIt(simHitsRaw->begin()); simHitIt != simHitsRaw->end(); ++simHitIt) { SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt->detUnitId())); if (simHitsDetUnitIt == simHitsDetUnit.end()) { - std::pair< SimHitsMap::iterator, bool > newIt(simHitsDetUnit.insert(std::pair< unsigned int, std::vector< PSimHit > >(simHitIt->detUnitId(), std::vector< PSimHit >()))); - simHitsDetUnitIt = newIt.first; + std::pair newIt(simHitsDetUnit.insert( + std::pair >(simHitIt->detUnitId(), std::vector()))); + simHitsDetUnitIt = newIt.first; } simHitsDetUnitIt->second.push_back(*simHitIt); SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt->trackId())); if (simHitsTrackIdIt == simHitsTrackId.end()) { - std::pair< SimHitsMap::iterator, bool > newIt(simHitsTrackId.insert(std::pair< unsigned int, std::vector< PSimHit > >(simHitIt->trackId(), std::vector< PSimHit >()))); - simHitsTrackIdIt = newIt.first; + std::pair newIt(simHitsTrackId.insert( + std::pair >(simHitIt->trackId(), std::vector()))); + simHitsTrackIdIt = newIt.first; } simHitsTrackIdIt->second.push_back(*simHitIt); } //Printout outer tracker clusters in the event - for (Phase2TrackerCluster1DCollectionNew::const_iterator DSViter = clusters->begin(); DSViter != clusters->end(); ++DSViter) { - unsigned int rawid(DSViter->detId()); DetId detId(rawid); + for (Phase2TrackerCluster1DCollectionNew::const_iterator DSViter = clusters->begin(); DSViter != clusters->end(); + ++DSViter) { + unsigned int rawid(DSViter->detId()); + DetId detId(rawid); const GeomDetUnit* geomDetUnit(tkGeom->idToDetUnit(detId)); - const PixelGeomDetUnit* theGeomDet = dynamic_cast< const PixelGeomDetUnit* >(geomDetUnit); - for (edmNew::DetSet< Phase2TrackerCluster1D >::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); ++clustIt) { - auto && lparams = cpe->localParameters( *clustIt, *theGeomDet ); + const PixelGeomDetUnit* theGeomDet = dynamic_cast(geomDetUnit); + for (edmNew::DetSet::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); + ++clustIt) { + auto&& lparams = cpe->localParameters(*clustIt, *theGeomDet); Global3DPoint gparams = theGeomDet->surface().toGlobal(lparams.first); LogTrace("VectorHitsBuilderValidation") << "phase2 OT clusters: " << gparams << " DetId: " << rawid; } } for (VectorHitCollectionNew::const_iterator DSViter = vhsAcc->begin(); DSViter != vhsAcc->end(); ++DSViter) { - for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { LogTrace("VectorHitsBuilderValidation") << "accepted VH: " << *vhIt; } } for (VectorHitCollectionNew::const_iterator DSViter = vhsRej->begin(); DSViter != vhsRej->end(); ++DSViter) { - for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { LogTrace("VectorHitsBuilderValidation") << "rejected VH: " << *vhIt; } } @@ -309,7 +315,6 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev // Loop over modules for (VectorHitCollectionNew::const_iterator DSViter = vhsAcc->begin(); DSViter != vhsAcc->end(); ++DSViter) { - // Get the detector unit's id unsigned int rawid(DSViter->detId()); module_id = rawid; @@ -322,24 +327,23 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev // Get the geometry of the tracker const GeomDet* geomDet(tkGeom->idToDet(detId)); - if (!geomDet) break; + if (!geomDet) + break; // Create histograms for the layer if they do not yet exist - std::map< unsigned int, VHHistos >::iterator histogramLayer(histograms_.find(layer)); - if (histogramLayer == histograms_.end()) histogramLayer = createLayerHistograms(layer); + std::map::iterator histogramLayer(histograms_.find(layer)); + if (histogramLayer == histograms_.end()) + histogramLayer = createLayerHistograms(layer); // Number of clusters unsigned int nVHsPS(0), nVHs2S(0); LogDebug("VectorHitsBuilderValidation") << "DSViter size: " << DSViter->size(); - // Loop over the vhs in the detector unit - for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { - + for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { // vh variables - if( vhIt->isValid() ){ - - LogDebug("VectorHitsBuilderValidation") << " vh analyzing ..." ; + if (vhIt->isValid()) { + LogDebug("VectorHitsBuilderValidation") << " vh analyzing ..."; chi2 = vhIt->chi2(); LogTrace("VectorHitsBuilderValidation") << "VH chi2 " << chi2 << std::endl; @@ -372,8 +376,10 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev trackerLayoutRZ_[0]->SetPoint(nVHsTot, globalPosVH.z(), globalPosVH.perp()); trackerLayoutXY_[0]->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); - if (layer < 100) trackerLayoutXYBar_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); - else trackerLayoutXYEC_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + if (layer < 100) + trackerLayoutXYBar_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + else + trackerLayoutXYEC_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); histogramLayer->second.localPosXY[0]->SetPoint(nVHsTot, vh_x_local, vh_y_local); histogramLayer->second.globalPosXY[0]->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); @@ -383,11 +389,10 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev // Pixel module const StackGeomDet* stackDet = dynamic_cast(geomDet); - const PixelGeomDetUnit* geomDetLower = dynamic_cast< const PixelGeomDetUnit* >(stackDet->lowerDet()); + const PixelGeomDetUnit* geomDetLower = dynamic_cast(stackDet->lowerDet()); DetId lowerDetId = stackDet->lowerDet()->geographicalId(); DetId upperDetId = stackDet->upperDet()->geographicalId(); - TrackerGeometry::ModuleType mType = tkGeom->getDetectorType(lowerDetId); module_type = 0; if (mType == TrackerGeometry::ModuleType::Ph2PSP) { @@ -447,17 +452,18 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev upp_zy_global_err = vhIt->upperGlobalPosErr().czy(); LogDebug("VectorHitsBuilderValidation") << "print Clusters into the VH:" << std::endl; - printCluster(geomDetLower,vhIt->lowerClusterRef()); + printCluster(geomDetLower, vhIt->lowerClusterRef()); LogTrace("VectorHitsBuilderValidation") << "\t global pos lower " << vhIt->lowerGlobalPos() << std::endl; - LogTrace("VectorHitsBuilderValidation") << "\t global posErr lower " << vhIt->lowerGlobalPosErr().cxx() << std::endl; + LogTrace("VectorHitsBuilderValidation") + << "\t global posErr lower " << vhIt->lowerGlobalPosErr().cxx() << std::endl; const GeomDetUnit* geomDetUpper = stackDet->upperDet(); - printCluster(geomDetUpper,vhIt->upperClusterRef()); + printCluster(geomDetUpper, vhIt->upperClusterRef()); LogTrace("VectorHitsBuilderValidation") << "\t global pos upper " << vhIt->upperGlobalPos() << std::endl; //comparison with SIM hits LogDebug("VectorHitsBuilderValidation") << "comparison Clusters with sim hits ... " << std::endl; - std::vector< unsigned int > clusterSimTrackIds; - std::vector< unsigned int > clusterSimTrackIdsUpp; + std::vector clusterSimTrackIds; + std::vector clusterSimTrackIdsUpp; std::set > simTkIds; const GeomDetUnit* geomDetUnit_low(tkGeom->idToDetUnit(lowerDetId)); LogTrace("VectorHitsBuilderValidation") << " lowerDetID : " << lowerDetId.rawId(); @@ -465,67 +471,77 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev LogTrace("VectorHitsBuilderValidation") << " upperDetID : " << upperDetId.rawId(); for (unsigned int istr(0); istr < (*(vhIt->lowerClusterRef().cluster_phase2OT())).size(); ++istr) { - uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vhIt->lowerClusterRef().cluster_phase2OT())).firstRow() + istr, (*(vhIt->lowerClusterRef().cluster_phase2OT())).column()); + uint32_t channel = + Phase2TrackerDigi::pixelToChannel((*(vhIt->lowerClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vhIt->lowerClusterRef().cluster_phase2OT())).column()); unsigned int LowerSimTrackId(getSimTrackId(siphase2SimLinks, lowerDetId, channel)); - std::vector > trkid(getSimTrackIds(siphase2SimLinks, lowerDetId, channel)); - if (trkid.size()==0) continue; + std::vector > trkid( + getSimTrackIds(siphase2SimLinks, lowerDetId, channel)); + if (trkid.size() == 0) + continue; clusterSimTrackIds.push_back(LowerSimTrackId); - simTkIds.insert(trkid.begin(),trkid.end()); + simTkIds.insert(trkid.begin(), trkid.end()); LogTrace("VectorHitsBuilderValidation") << "LowerSimTrackId " << LowerSimTrackId << std::endl; } // In the case of PU, we need the TPs to find the proper SimTrackID - for (std::set >::const_iterator iset = simTkIds.begin(); - iset != simTkIds.end(); iset++) { - auto ipos = mapping.find(*iset); - if (ipos != mapping.end()) { - LogTrace("VectorHitsBuilderValidation") << "lower cluster in detid: " << lowerDetId.rawId() << " from tp: " << ipos->second.key() << " " << iset->first; - LogTrace("VectorHitsBuilderValidation") << "with pt(): " << (*ipos->second).pt(); + for (std::set >::const_iterator iset = simTkIds.begin(); + iset != simTkIds.end(); + iset++) { + auto ipos = mapping.find(*iset); + if (ipos != mapping.end()) { + LogTrace("VectorHitsBuilderValidation") << "lower cluster in detid: " << lowerDetId.rawId() + << " from tp: " << ipos->second.key() << " " << iset->first; + LogTrace("VectorHitsBuilderValidation") << "with pt(): " << (*ipos->second).pt(); low_tp_id = ipos->second.key(); vh_sim_trackPt = (*ipos->second).pt(); - } + } } - + simTkIds.clear(); for (unsigned int istr(0); istr < (*(vhIt->upperClusterRef().cluster_phase2OT())).size(); ++istr) { - uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vhIt->upperClusterRef().cluster_phase2OT())).firstRow() + istr, (*(vhIt->upperClusterRef().cluster_phase2OT())).column()); + uint32_t channel = + Phase2TrackerDigi::pixelToChannel((*(vhIt->upperClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vhIt->upperClusterRef().cluster_phase2OT())).column()); unsigned int UpperSimTrackId(getSimTrackId(siphase2SimLinks, upperDetId, channel)); - std::vector > trkid(getSimTrackIds(siphase2SimLinks, upperDetId, channel)); - if (trkid.size()==0) continue; + std::vector > trkid( + getSimTrackIds(siphase2SimLinks, upperDetId, channel)); + if (trkid.size() == 0) + continue; clusterSimTrackIdsUpp.push_back(UpperSimTrackId); - simTkIds.insert(trkid.begin(),trkid.end()); + simTkIds.insert(trkid.begin(), trkid.end()); LogTrace("VectorHitsBuilderValidation") << "UpperSimTrackId " << UpperSimTrackId << std::endl; } // In the case of PU, we need the TPs to find the proper SimTrackID - for (std::set >::const_iterator iset = simTkIds.begin(); - iset != simTkIds.end(); iset++) { + for (std::set >::const_iterator iset = simTkIds.begin(); + iset != simTkIds.end(); + iset++) { auto ipos = mapping.find(*iset); if (ipos != mapping.end()) { - LogTrace("VectorHitsBuilderValidation") << "upper cluster in detid: " << upperDetId.rawId() << " from tp: " << ipos->second.key() << " " << iset->first << std::endl; + LogTrace("VectorHitsBuilderValidation") + << "upper cluster in detid: " << upperDetId.rawId() << " from tp: " << ipos->second.key() << " " + << iset->first << std::endl; upp_tp_id = ipos->second.key(); } } //compute if the vhits is 'true' or 'false' and save sim pT - std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); + std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); vh_isTrue = 0; - if(istrue.first){ + if (istrue.first) { vh_isTrue = 1; } - - // loop over all simHits unsigned int totalSimHits(0); unsigned int primarySimHits(0); unsigned int otherSimHits(0); - for (edm::PSimHitContainer::const_iterator hitIt(simHitsRaw->begin()); hitIt != simHitsRaw->end(); ++hitIt) { - - if(hitIt->detUnitId() == geomDetLower->geographicalId()){// || hitIt->detUnitId() == geomDetUpper->geographicalId()){ + if (hitIt->detUnitId() == + geomDetLower->geographicalId()) { // || hitIt->detUnitId() == geomDetUpper->geographicalId()){ //check clusters track id compatibility - if(std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt->trackId()) != clusterSimTrackIds.end()){ - + if (std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt->trackId()) != + clusterSimTrackIds.end()) { Local3DPoint localPosHit(hitIt->localPosition()); sim_x_local = localPosHit.x(); sim_y_local = localPosHit.y(); @@ -542,42 +558,44 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev histogramLayer->second.deltaYVHSimHits[0]->Fill(vh_y_local - sim_y_local); // Pixel module - if (layer == 1 || layer == 2 || layer == 3) { - histogramLayer->second.deltaXVHSimHits[1]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits[1]->Fill(vh_y_local - sim_y_local); + if (layer == 1 || layer == 2 || layer == 3) { + histogramLayer->second.deltaXVHSimHits[1]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits[1]->Fill(vh_y_local - sim_y_local); } // Strip module else if (layer == 4 || layer == 5 || layer == 6) { - histogramLayer->second.deltaXVHSimHits[2]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits[2]->Fill(vh_y_local - sim_y_local); + histogramLayer->second.deltaXVHSimHits[2]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits[2]->Fill(vh_y_local - sim_y_local); } ++totalSimHits; - std::map< unsigned int, SimTrack >::const_iterator simTrackIt(simTracks.find(hitIt->trackId())); - if (simTrackIt == simTracks.end()) continue; + std::map::const_iterator simTrackIt(simTracks.find(hitIt->trackId())); + if (simTrackIt == simTracks.end()) + continue; //LogTrace("VectorHitsBuilderValidation") << "--> with hitIt. The SimTrack has p: " << simTrackIt->second.momentum(); - // Primary particles only processType = hitIt->processType(); - if (simTrackIt->second.vertIndex() == 0 and (processType == 2 || processType == 7 || processType == 9 || processType == 11 || processType == 13 || processType == 15)) { - histogramLayer->second.deltaXVHSimHits_P[0]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits_P[0]->Fill(vh_y_local - sim_y_local); - - // Pixel module - if (layer == 1 || layer == 2 || layer == 3) { - histogramLayer->second.deltaXVHSimHits_P[1]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits_P[1]->Fill(vh_y_local - sim_y_local); - } - // Strip module - else if (layer == 4 || layer == 5 || layer == 6) { - histogramLayer->second.deltaXVHSimHits_P[2]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits_P[2]->Fill(vh_y_local - sim_y_local); - } - - ++primarySimHits; + if (simTrackIt->second.vertIndex() == 0 and + (processType == 2 || processType == 7 || processType == 9 || processType == 11 || processType == 13 || + processType == 15)) { + histogramLayer->second.deltaXVHSimHits_P[0]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits_P[0]->Fill(vh_y_local - sim_y_local); + + // Pixel module + if (layer == 1 || layer == 2 || layer == 3) { + histogramLayer->second.deltaXVHSimHits_P[1]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits_P[1]->Fill(vh_y_local - sim_y_local); + } + // Strip module + else if (layer == 4 || layer == 5 || layer == 6) { + histogramLayer->second.deltaXVHSimHits_P[2]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits_P[2]->Fill(vh_y_local - sim_y_local); + } + + ++primarySimHits; } otherSimHits = totalSimHits - primarySimHits; @@ -585,10 +603,9 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev histogramLayer->second.totalSimHits->Fill(totalSimHits); histogramLayer->second.primarySimHits->Fill(primarySimHits); histogramLayer->second.otherSimHits->Fill(otherSimHits); - } } - }// loop simhits + } // loop simhits nVHsTot++; //tree->Fill(); @@ -597,7 +614,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev //combinatorial studies : not filling if more than 1 VH has been produced //****************************** multiplicity = DSViter->size(); - if(DSViter->size()>1){ + if (DSViter->size() > 1) { LogTrace("VectorHitsBuilderValidation") << " not filling if more than 1 VH has been produced"; width = -100; deltaXlocal = -100; @@ -614,13 +631,13 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev //stub width - auto && lparamsUpp = cpe->localParameters( *vhIt->upperClusterRef().cluster_phase2OT(), *geomDetUnit_upp ); + auto&& lparamsUpp = cpe->localParameters(*vhIt->upperClusterRef().cluster_phase2OT(), *geomDetUnit_upp); LogTrace("VectorHitsBuilderValidation") << " upper local pos (in its sor):" << lparamsUpp.first; Global3DPoint gparamsUpp = geomDetUnit_upp->surface().toGlobal(lparamsUpp.first); LogTrace("VectorHitsBuilderValidation") << " upper global pos :" << gparamsUpp; Local3DPoint lparamsUppInLow = geomDetUnit_low->surface().toLocal(gparamsUpp); LogTrace("VectorHitsBuilderValidation") << " upper local pos (in low sor):" << lparamsUppInLow; - auto && lparamsLow = cpe->localParameters( *vhIt->lowerClusterRef().cluster_phase2OT(), *geomDetUnit_low ); + auto&& lparamsLow = cpe->localParameters(*vhIt->lowerClusterRef().cluster_phase2OT(), *geomDetUnit_low); LogTrace("VectorHitsBuilderValidation") << " lower local pos (in its sor):" << lparamsLow.first; Global3DPoint gparamsLow = geomDetUnit_low->surface().toGlobal(lparamsLow.first); LogTrace("VectorHitsBuilderValidation") << " lower global pos :" << gparamsLow; @@ -632,42 +649,42 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev double parallCorr = 0.0; - Global3DPoint origin(0,0,0); + Global3DPoint origin(0, 0, 0); GlobalVector gV = gparamsLow - origin; //LogTrace("VectorHitsBuilderValidation") << " global vector passing to the origin:" << gV; LocalVector lV = geomDetUnit_low->surface().toLocal(gV); //LogTrace("VectorHitsBuilderValidation") << " local vector passing to the origin (in low sor):" << lV; - LocalVector lV_norm = lV/lV.z(); + LocalVector lV_norm = lV / lV.z(); //LogTrace("VectorHitsBuilderValidation") << " normalized local vector passing to the origin (in low sor):" << lV_norm; parallCorr = lV_norm.x() * lparamsUppInLow.z(); LogTrace("VectorHitsBuilderValidation") << " parallalex correction:" << parallCorr; double lpos_upp_corr = 0.0; double lpos_low_corr = 0.0; - if(lparamsUpp.first.x() > lparamsLow.first.x()){ - if(lparamsUpp.first.x() > 0){ + if (lparamsUpp.first.x() > lparamsLow.first.x()) { + if (lparamsUpp.first.x() > 0) { lpos_low_corr = lparamsLow.first.x(); lpos_upp_corr = lparamsUpp.first.x() - fabs(parallCorr); } - if(lparamsUpp.first.x() < 0){ + if (lparamsUpp.first.x() < 0) { lpos_low_corr = lparamsLow.first.x() + fabs(parallCorr); lpos_upp_corr = lparamsUpp.first.x(); } - } else if( lparamsUpp.first.x() < lparamsLow.first.x() ) { - if(lparamsUpp.first.x() > 0){ + } else if (lparamsUpp.first.x() < lparamsLow.first.x()) { + if (lparamsUpp.first.x() > 0) { lpos_low_corr = lparamsLow.first.x() - fabs(parallCorr); lpos_upp_corr = lparamsUpp.first.x(); } - if(lparamsUpp.first.x() < 0){ + if (lparamsUpp.first.x() < 0) { lpos_low_corr = lparamsLow.first.x(); lpos_upp_corr = lparamsUpp.first.x() + fabs(parallCorr); } } else { - if(lparamsUpp.first.x() > 0){ + if (lparamsUpp.first.x() > 0) { lpos_upp_corr = lparamsUpp.first.x() - fabs(parallCorr); lpos_low_corr = lparamsLow.first.x(); } - if(lparamsUpp.first.x() < 0){ + if (lparamsUpp.first.x() < 0) { lpos_upp_corr = lparamsUpp.first.x() + fabs(parallCorr); lpos_low_corr = lparamsLow.first.x(); } @@ -682,53 +699,55 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev tree->Fill(); + } // vh valid - }// vh valid + } // loop vhs - }// loop vhs - - if (nVHsPS) histogramLayer->second.numberVHsPS->Fill(nVHsPS); - if (nVHs2S) histogramLayer->second.numberVHs2S->Fill(nVHs2S); - LogTrace("VectorHitsBuilderValidation") << "nVHsPS for this layer : " << nVHsPS << ", nVHs2S for this layer : " << nVHs2S << std::endl; + if (nVHsPS) + histogramLayer->second.numberVHsPS->Fill(nVHsPS); + if (nVHs2S) + histogramLayer->second.numberVHs2S->Fill(nVHs2S); + LogTrace("VectorHitsBuilderValidation") + << "nVHsPS for this layer : " << nVHsPS << ", nVHs2S for this layer : " << nVHs2S << std::endl; } CreateVHsXYGraph(glVHs, dirVHs); CreateVHsRZGraph(glVHs, dirVHs); - int VHaccTrue = 0.0; + int VHaccTrue = 0.0; int VHaccFalse = 0.0; - int VHrejTrue = 0.0; + int VHrejTrue = 0.0; int VHrejFalse = 0.0; - int VHaccTrue_signal = 0.0; - int VHrejTrue_signal = 0.0; + int VHaccTrue_signal = 0.0; + int VHrejTrue_signal = 0.0; // Loop over modules for (VectorHitCollectionNew::const_iterator DSViter = vhsAcc->begin(); DSViter != vhsAcc->end(); ++DSViter) { - unsigned int rawid(DSViter->detId()); DetId detId(rawid); int layerAcc = getLayerNumber(detId); LogTrace("VectorHitsBuilderValidation") << "acc Layer: " << layerAcc << " det id" << rawid << std::endl; - for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { - if( vhIt->isValid() ){ - VHaccLayer_->Fill(layerAcc); + for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + if (vhIt->isValid()) { + VHaccLayer_->Fill(layerAcc); VHacc++; //compute if the vhits is 'true' or 'false' - std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); - if(istrue.first){ + std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); + if (istrue.first) { LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; - VHaccTrueLayer_->Fill(layerAcc); + VHaccTrueLayer_->Fill(layerAcc); //VHaccTrueLayer_ratio->Fill(layerAcc); VHaccTrue++; //saving info of 'signal' track - std::map< unsigned int, SimTrack >::const_iterator simTrackIt(simTracks.find(istrue.second)); - if (simTrackIt == simTracks.end()) continue; + std::map::const_iterator simTrackIt(simTracks.find(istrue.second)); + if (simTrackIt == simTracks.end()) + continue; LogTrace("VectorHitsBuilderValidation") << "this vectorhit is associated with SimTrackId: " << istrue.second; LogTrace("VectorHitsBuilderValidation") << "the SimTrack has pt: " << simTrackIt->second.momentum().pt(); - if (simTrackIt->second.momentum().pt() > 1 ) { - VHaccTrue_signal_Layer_->Fill(layerAcc); + if (simTrackIt->second.momentum().pt() > 1) { + VHaccTrue_signal_Layer_->Fill(layerAcc); LogTrace("VectorHitsBuilderValidation") << "the vectorhit belongs to signal"; VHaccTrue_signal++; } @@ -737,416 +756,457 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'false' vhit."; VHaccFalse++; } - } } - - } - + } //it is not really working.. //VHaccTrueLayer_ratio->Divide(VHaccLayer_); for (VectorHitCollectionNew::const_iterator DSViter = vhsRej->begin(); DSViter != vhsRej->end(); ++DSViter) { - unsigned int rawid(DSViter->detId()); DetId detId(rawid); int layerRej = getLayerNumber(detId); LogTrace("VectorHitsBuilderValidation") << "rej Layer: " << layerRej << " det id" << rawid << std::endl; - for (edmNew::DetSet< VectorHit >::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { VHrejLayer_->Fill(layerRej); VHrej++; //compute if the vhits is 'true' or 'false' - std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); - if(istrue.first){ + std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); + if (istrue.first) { LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; VHrejTrueLayer_->Fill(layerRej); //VHrejTrueLayer_ratio->Fill(layerRej); VHrejTrue++; //saving info of 'signal' track - std::map< unsigned int, SimTrack >::const_iterator simTrackIt(simTracks.find(istrue.second)); - if (simTrackIt == simTracks.end()) continue; + std::map::const_iterator simTrackIt(simTracks.find(istrue.second)); + if (simTrackIt == simTracks.end()) + continue; LogTrace("VectorHitsBuilderValidation") << "this vectorhit is associated with SimTrackId: " << istrue.second; - LogTrace("VectorHitsBuilderValidation") << "the SimTrack has pt: " << simTrackIt->second.momentum().pt(); - if (simTrackIt->second.momentum().pt() > 1 ) { - VHrejTrue_signal_Layer_->Fill(layerRej); - LogTrace("VectorHitsBuilderValidation") << "the vectorhit belongs to signal"; - VHrejTrue_signal++; - } + LogTrace("VectorHitsBuilderValidation") << "the SimTrack has pt: " << simTrackIt->second.momentum().pt(); + if (simTrackIt->second.momentum().pt() > 1) { + VHrejTrue_signal_Layer_->Fill(layerRej); + LogTrace("VectorHitsBuilderValidation") << "the vectorhit belongs to signal"; + VHrejTrue_signal++; + } } else { LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'false' vhit."; VHrejFalse++; } - } - } //it is not really working.. //VHrejTrueLayer_ratio->Divide(VHrejLayer_); int VHtot = VHacc + VHrej; - LogTrace("VectorHitsBuilderValidation") << "VH total: " << VHtot << " with " << VHacc << " VHs accepted and " << VHrej << " VHs rejected."; - LogTrace("VectorHitsBuilderValidation") << "of the VH accepted, there are " << VHaccTrue << " true and " << VHaccFalse << " false."; - LogTrace("VectorHitsBuilderValidation") << "of the VH rejected, there are " << VHrejTrue << " true and " << VHrejFalse << " false."; - LogTrace("VectorHitsBuilderValidation") << "of the true VH , there are " << VHaccTrue_signal << " accepted belonging to signal and " << VHrejTrue_signal << " rejected belonging to signal."; - -// CreateWindowCorrGraph(); - + LogTrace("VectorHitsBuilderValidation") + << "VH total: " << VHtot << " with " << VHacc << " VHs accepted and " << VHrej << " VHs rejected."; + LogTrace("VectorHitsBuilderValidation") + << "of the VH accepted, there are " << VHaccTrue << " true and " << VHaccFalse << " false."; + LogTrace("VectorHitsBuilderValidation") + << "of the VH rejected, there are " << VHrejTrue << " true and " << VHrejFalse << " false."; + LogTrace("VectorHitsBuilderValidation") + << "of the true VH , there are " << VHaccTrue_signal << " accepted belonging to signal and " + << VHrejTrue_signal << " rejected belonging to signal."; + + // CreateWindowCorrGraph(); } // Check if the vector hit is true (both clusters are formed from the same SimTrack -std::pair VectorHitsBuilderValidation::isTrue(const VectorHit vh, const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& siphase2SimLinks, DetId& detId) const{ - +std::pair VectorHitsBuilderValidation::isTrue( + const VectorHit vh, const edm::Handle >& siphase2SimLinks, DetId& detId) const { const GeomDet* geomDet(tkGeom->idToDet(detId)); const StackGeomDet* stackDet = dynamic_cast(geomDet); const GeomDetUnit* geomDetLower = stackDet->lowerDet(); const GeomDetUnit* geomDetUpper = stackDet->upperDet(); - std::vector< unsigned int > lowClusterSimTrackIds; + std::vector lowClusterSimTrackIds; //std::set > simTkIds; for (unsigned int istr(0); istr < (*(vh.lowerClusterRef().cluster_phase2OT())).size(); ++istr) { - uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.lowerClusterRef().cluster_phase2OT())).firstRow() + istr, (*(vh.lowerClusterRef().cluster_phase2OT())).column()); + uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.lowerClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vh.lowerClusterRef().cluster_phase2OT())).column()); DetId detIdCluster = geomDetLower->geographicalId(); unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detIdCluster, channel)); LogTrace("VectorHitsBuilderValidation") << "LowerSimTrackId " << simTrackId << std::endl; std::vector > trkid(getSimTrackIds(siphase2SimLinks, detIdCluster, channel)); - if (trkid.size()==0) continue; + if (trkid.size() == 0) + continue; lowClusterSimTrackIds.push_back(simTrackId); //simTkIds.insert(trkid.begin(),trkid.end()); } - std::vector< unsigned int >::iterator it_simTrackUpper; + std::vector::iterator it_simTrackUpper; for (unsigned int istr(0); istr < (*(vh.upperClusterRef().cluster_phase2OT())).size(); ++istr) { - uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.upperClusterRef().cluster_phase2OT())).firstRow() + istr, (*(vh.upperClusterRef().cluster_phase2OT())).column()); + uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.upperClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vh.upperClusterRef().cluster_phase2OT())).column()); DetId detIdCluster = geomDetUpper->geographicalId(); unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detIdCluster, channel)); LogTrace("VectorHitsBuilderValidation") << "UpperSimTrackId " << simTrackId << std::endl; std::vector > trkid(getSimTrackIds(siphase2SimLinks, detIdCluster, channel)); - if (trkid.size()==0) continue; + if (trkid.size() == 0) + continue; it_simTrackUpper = std::find(lowClusterSimTrackIds.begin(), lowClusterSimTrackIds.end(), simTrackId); - if ( it_simTrackUpper != lowClusterSimTrackIds.end() ) { + if (it_simTrackUpper != lowClusterSimTrackIds.end()) { LogTrace("VectorHitsBuilderValidation") << " UpperSimTrackId found in lowClusterSimTrackIds "; - return std::make_pair(true,simTrackId); + return std::make_pair(true, simTrackId); } //clusterSimTrackIds.push_back(UpperSimTrackId); //simTkIds.insert(trkid.begin(),trkid.end()); } - return std::make_pair(false,0); + return std::make_pair(false, 0); } // Create the histograms -std::map< unsigned int, VHHistos >::iterator VectorHitsBuilderValidation::createLayerHistograms(unsigned int ival) { - std::ostringstream fname1, fname2; - - edm::Service fs; - fs->file().cd("/"); - - std::string tag; - unsigned int id; - if (ival < 100) { - id = ival; - fname1 << "Barrel"; - fname2 << "Layer_" << id; - tag = "_layer_"; - } - else { - int side = ival / 100; - id = ival - side * 100; - fname1 << "EndCap_Side_" << side; - fname2 << "Disc_" << id; - tag = "_disc_"; - } +std::map::iterator VectorHitsBuilderValidation::createLayerHistograms(unsigned int ival) { + std::ostringstream fname1, fname2; - TFileDirectory td1 = fs->mkdir(fname1.str().c_str()); - TFileDirectory td = td1.mkdir(fname2.str().c_str()); + edm::Service fs; + fs->file().cd("/"); + + std::string tag; + unsigned int id; + if (ival < 100) { + id = ival; + fname1 << "Barrel"; + fname2 << "Layer_" << id; + tag = "_layer_"; + } else { + int side = ival / 100; + id = ival - side * 100; + fname1 << "EndCap_Side_" << side; + fname2 << "Disc_" << id; + tag = "_disc_"; + } - VHHistos local_histos; + TFileDirectory td1 = fs->mkdir(fname1.str().c_str()); + TFileDirectory td = td1.mkdir(fname2.str().c_str()); - std::ostringstream histoName; + VHHistos local_histos; - /* + std::ostringstream histoName; + + /* * Number of clusters */ - histoName.str(""); histoName << "Number_VHs_PS" << tag.c_str() << id; - local_histos.numberVHsPS = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); - local_histos.numberVHsPS->SetFillColor(kAzure + 7); + histoName.str(""); + histoName << "Number_VHs_PS" << tag.c_str() << id; + local_histos.numberVHsPS = td.make(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberVHsPS->SetFillColor(kAzure + 7); - histoName.str(""); histoName << "Number_VHs_2S" << tag.c_str() << id; - local_histos.numberVHs2S = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); - local_histos.numberVHs2S->SetFillColor(kOrange - 3); + histoName.str(""); + histoName << "Number_VHs_2S" << tag.c_str() << id; + local_histos.numberVHs2S = td.make(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberVHs2S->SetFillColor(kOrange - 3); - histoName.str(""); histoName << "Number_VHs_Mixed" << tag.c_str() << id; - local_histos.numberVHsMixed = td.make< THStack >(histoName.str().c_str(), histoName.str().c_str()); - local_histos.numberVHsMixed->Add(local_histos.numberVHsPS); - local_histos.numberVHsMixed->Add(local_histos.numberVHs2S); + histoName.str(""); + histoName << "Number_VHs_Mixed" << tag.c_str() << id; + local_histos.numberVHsMixed = td.make(histoName.str().c_str(), histoName.str().c_str()); + local_histos.numberVHsMixed->Add(local_histos.numberVHsPS); + local_histos.numberVHsMixed->Add(local_histos.numberVHs2S); - /* + /* * Local and Global positions */ - histoName.str(""); histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; - local_histos.localPosXY[0] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); - local_histos.localPosXY[0]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Local_Position_XY_PS" << tag.c_str() << id; - local_histos.localPosXY[1] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); - local_histos.localPosXY[1]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Local_Position_XY_2S" << tag.c_str() << id; - local_histos.localPosXY[2] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); - local_histos.localPosXY[2]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; - local_histos.globalPosXY[0] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); - local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Global_Position_XY_PS" << tag.c_str() << id; - local_histos.globalPosXY[1] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); - local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); - - histoName.str(""); histoName << "Global_Position_XY_2S" << tag.c_str() << id; - local_histos.globalPosXY[2] = td.make< TGraph >();//histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); - local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); - - /* + histoName.str(""); + histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; + local_histos.localPosXY[0] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Local_Position_XY_PS" << tag.c_str() << id; + local_histos.localPosXY[1] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Local_Position_XY_2S" << tag.c_str() << id; + local_histos.localPosXY[2] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + local_histos.localPosXY[2]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; + local_histos.globalPosXY[0] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Global_Position_XY_PS" << tag.c_str() << id; + local_histos.globalPosXY[1] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Global_Position_XY_2S" << tag.c_str() << id; + local_histos.globalPosXY[2] = + td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); + + /* * Delta positions with SimHits */ - histoName.str(""); histoName << "Delta_X_VH_SimHits_Mixed" << tag.c_str() << id; - local_histos.deltaXVHSimHits[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_VH_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaXVHSimHits[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_X_VH_SimHits_PS" << tag.c_str() << id; - local_histos.deltaXVHSimHits[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_VH_SimHits_PS" << tag.c_str() << id; + local_histos.deltaXVHSimHits[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_X_VH_SimHits_2S" << tag.c_str() << id; - local_histos.deltaXVHSimHits[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_VH_SimHits_2S" << tag.c_str() << id; + local_histos.deltaXVHSimHits[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_VH_SimHits_Mixed" << tag.c_str() << id; - local_histos.deltaYVHSimHits[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaYVHSimHits[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_VH_SimHits_PS" << tag.c_str() << id; - local_histos.deltaYVHSimHits[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_PS" << tag.c_str() << id; + local_histos.deltaYVHSimHits[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_VH_SimHits_2S" << tag.c_str() << id; - local_histos.deltaYVHSimHits[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_2S" << tag.c_str() << id; + local_histos.deltaYVHSimHits[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - /* + /* * Delta position with simHits for primary tracks only */ - histoName.str(""); histoName << "Delta_X_VH_SimHits_Mixed_P" << tag.c_str() << id; - local_histos.deltaXVHSimHits_P[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_VH_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaXVHSimHits_P[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_X_VH_SimHits_PS_P" << tag.c_str() << id; - local_histos.deltaXVHSimHits_P[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_VH_SimHits_PS_P" << tag.c_str() << id; + local_histos.deltaXVHSimHits_P[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_X_VH_SimHits_2S_P" << tag.c_str() << id; - local_histos.deltaXVHSimHits_P[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_X_VH_SimHits_2S_P" << tag.c_str() << id; + local_histos.deltaXVHSimHits_P[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_VH_SimHits_Mixed_P" << tag.c_str() << id; - local_histos.deltaYVHSimHits_P[0] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaYVHSimHits_P[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_VH_SimHits_PS_P" << tag.c_str() << id; - local_histos.deltaYVHSimHits_P[1] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_PS_P" << tag.c_str() << id; + local_histos.deltaYVHSimHits_P[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - histoName.str(""); histoName << "Delta_Y_VH_SimHits_2S_P" << tag.c_str() << id; - local_histos.deltaYVHSimHits_P[2] = td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_2S_P" << tag.c_str() << id; + local_histos.deltaYVHSimHits_P[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - /* + /* * Information on the Digis per cluster */ - histoName.str(""); histoName << "Total_Digis" << tag.c_str() << id; - local_histos.totalSimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + histoName.str(""); + histoName << "Total_Digis" << tag.c_str() << id; + local_histos.totalSimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - histoName.str(""); histoName << "Primary_Digis" << tag.c_str() << id; - local_histos.primarySimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + histoName.str(""); + histoName << "Primary_Digis" << tag.c_str() << id; + local_histos.primarySimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - histoName.str(""); histoName << "Other_Digis" << tag.c_str() << id; - local_histos.otherSimHits= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + histoName.str(""); + histoName << "Other_Digis" << tag.c_str() << id; + local_histos.otherSimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - /* + /* * Study on the clusters combinatorial problem */ - histoName.str(""); histoName << "DeltaXlocal_clusters" << tag.c_str() << id; - local_histos.deltaXlocal= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); - histoName.str(""); histoName << "Width" << tag.c_str() << id; - local_histos.width= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); - histoName.str(""); histoName << "Curvature" << tag.c_str() << id; - local_histos.curvature= td.make< TH1F >(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); - - std::pair< std::map< unsigned int, VHHistos >::iterator, bool > insertedIt(histograms_.insert(std::make_pair(ival, local_histos))); - fs->file().cd("/"); + histoName.str(""); + histoName << "DeltaXlocal_clusters" << tag.c_str() << id; + local_histos.deltaXlocal = td.make(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); + histoName.str(""); + histoName << "Width" << tag.c_str() << id; + local_histos.width = td.make(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); + histoName.str(""); + histoName << "Curvature" << tag.c_str() << id; + local_histos.curvature = td.make(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); + + std::pair::iterator, bool> insertedIt( + histograms_.insert(std::make_pair(ival, local_histos))); + fs->file().cd("/"); - return insertedIt.first; + return insertedIt.first; } -void VectorHitsBuilderValidation::CreateVHsXYGraph(const std::vector glVHs,const std::vector dirVHs){ - - if(glVHs.size() != dirVHs.size()){ +void VectorHitsBuilderValidation::CreateVHsXYGraph(const std::vector glVHs, + const std::vector dirVHs) { + if (glVHs.size() != dirVHs.size()) { std::cout << "Cannot fullfil the graphs for this event. Return." << std::endl; return; } // opening canvas and drawing XY TGraph - + //TCanvas * VHXY_ = new TCanvas("RVsY_Mixed","RVsY_Mixed",800,600); //VHXY_->cd(); //trackerLayoutXY_[0]->Draw("AP"); -// float finalposX, finalposY; - - for(unsigned int nVH = 0; nVH < glVHs.size(); nVH++){ + // float finalposX, finalposY; -// finalposX = glVHs.at(nVH).x() + dirVHs.at(nVH).x(); -// finalposY = glVHs.at(nVH).y() + dirVHs.at(nVH).y(); + for (unsigned int nVH = 0; nVH < glVHs.size(); nVH++) { + // finalposX = glVHs.at(nVH).x() + dirVHs.at(nVH).x(); + // finalposY = glVHs.at(nVH).y() + dirVHs.at(nVH).y(); //std::cout << glVHs.at(nVH) << " " << " \tr: " << glVHs.at(nVH).perp() << std::endl; //std::cout << dirVHs.at(nVH).x() << "," << dirVHs.at(nVH).y() << std::endl; //same r - if((fabs(dirVHs.at(nVH).x()) < 10e-5) && (fabs(dirVHs.at(nVH).y()) < 10e-5)){ - + if ((fabs(dirVHs.at(nVH).x()) < 10e-5) && (fabs(dirVHs.at(nVH).y()) < 10e-5)) { //std::cout << "same pos!"; continue; } else { - - // TArrow* vh_arrow = new TArrow(glVHs.at(nVH).x(), glVHs.at(nVH).y(), finalposX, finalposY, 0.05, ">"); - // vh_arrow->Draw("same"); - + // TArrow* vh_arrow = new TArrow(glVHs.at(nVH).x(), glVHs.at(nVH).y(), finalposX, finalposY, 0.05, ">"); + // vh_arrow->Draw("same"); } - - } return; } -void VectorHitsBuilderValidation::CreateVHsRZGraph(const std::vector glVHs,const std::vector dirVHs){ - - if(glVHs.size() != dirVHs.size()){ +void VectorHitsBuilderValidation::CreateVHsRZGraph(const std::vector glVHs, + const std::vector dirVHs) { + if (glVHs.size() != dirVHs.size()) { std::cout << "Cannot fullfil the graphs for this event. Return." << std::endl; return; } // opening canvas and drawing RZ TGraph // - //TCanvas* VHRZ_ = new TCanvas("RVsZ_Mixed","RVsZ_Mixed",800,600); + //TCanvas* VHRZ_ = new TCanvas("RVsZ_Mixed","RVsZ_Mixed",800,600); //VHRZ_->cd(); //trackerLayoutRZ_[0]->Draw("AP"); -// float finalposX, finalposY, finalposR, finalposZ; + // float finalposX, finalposY, finalposR, finalposZ; -// for(unsigned int nVH = 0; nVH < glVHs.size(); nVH++){ + // for(unsigned int nVH = 0; nVH < glVHs.size(); nVH++){ -// finalposX = glVHs.at(nVH).x() + dirVHs.at(nVH).x(); -// finalposY = glVHs.at(nVH).y() + dirVHs.at(nVH).y(); -// finalposR = sqrt( pow(finalposX,2) + pow(finalposY,2) ); -// finalposZ = glVHs.at(nVH).z() + dirVHs.at(nVH).z(); + // finalposX = glVHs.at(nVH).x() + dirVHs.at(nVH).x(); + // finalposY = glVHs.at(nVH).y() + dirVHs.at(nVH).y(); + // finalposR = sqrt( pow(finalposX,2) + pow(finalposY,2) ); + // finalposZ = glVHs.at(nVH).z() + dirVHs.at(nVH).z(); - //std::cout << dirVHs.at(nVH) " " << " \tr: " << dirVHs.at(nVH).perp() << std::endl; - //std::cout << finalposX << ", " << finalposY << " " << " \tr: " << finalposR << std::endl; - //std::cout << std::endl; + //std::cout << dirVHs.at(nVH) " " << " \tr: " << dirVHs.at(nVH).perp() << std::endl; + //std::cout << finalposX << ", " << finalposY << " " << " \tr: " << finalposR << std::endl; + //std::cout << std::endl; -// TArrow* vh_arrow = new TArrow(glVHs.at(nVH).z(), glVHs.at(nVH).perp(), finalposZ, finalposR, 0.05, "|>"); -// vh_arrow->SetLineWidth(2); -// vh_arrow->Draw("same"); + // TArrow* vh_arrow = new TArrow(glVHs.at(nVH).z(), glVHs.at(nVH).perp(), finalposZ, finalposR, 0.05, "|>"); + // vh_arrow->SetLineWidth(2); + // vh_arrow->Draw("same"); -// } + // } return; } -void VectorHitsBuilderValidation::CreateWindowCorrGraph(){ - +void VectorHitsBuilderValidation::CreateWindowCorrGraph() { //FIXME: This function is not working properly, yet. //return if we are not using Phase2 OT - if(!tkGeom->isThere(GeomDetEnumerators::P2OTB) && !tkGeom->isThere(GeomDetEnumerators::P2OTEC)) + if (!tkGeom->isThere(GeomDetEnumerators::P2OTB) && !tkGeom->isThere(GeomDetEnumerators::P2OTEC)) return; - for(auto det : tkGeom->detsTOB()){ -// std::cout << det->geographicalId().rawId() << std::endl; -// std::cout << det->surface().bounds().thickness() << std::endl; - ParallaxCorrectionRZ_->Fill(det->position().z(),det->position().perp(),5.); + for (auto det : tkGeom->detsTOB()) { + // std::cout << det->geographicalId().rawId() << std::endl; + // std::cout << det->surface().bounds().thickness() << std::endl; + ParallaxCorrectionRZ_->Fill(det->position().z(), det->position().perp(), 5.); } - for(auto det : tkGeom->detsTID()){ + for (auto det : tkGeom->detsTID()) { //std::cout << det->geographicalId().rawId() << std::endl; - ParallaxCorrectionRZ_->Fill(det->position().z(),det->position().perp(),10.); + ParallaxCorrectionRZ_->Fill(det->position().z(), det->position().perp(), 10.); } - ParallaxCorrectionRZ_->Fill(0.,0.,5.); + ParallaxCorrectionRZ_->Fill(0., 0., 5.); return; } unsigned int VectorHitsBuilderValidation::getLayerNumber(const DetId& detid) { if (detid.det() == DetId::Tracker) { - if (detid.subdetId() == StripSubdetector::TOB) return (tkTopo->layer(detid)); - else if (detid.subdetId() == StripSubdetector::TID) return (100 * tkTopo->side(detid) + tkTopo->layer(detid)); - else return 999; + if (detid.subdetId() == StripSubdetector::TOB) + return (tkTopo->layer(detid)); + else if (detid.subdetId() == StripSubdetector::TID) + return (100 * tkTopo->side(detid) + tkTopo->layer(detid)); + else + return 999; } return 999; } -unsigned int VectorHitsBuilderValidation::getModuleNumber(const DetId& detid) { - return (tkTopo->module(detid)); -} +unsigned int VectorHitsBuilderValidation::getModuleNumber(const DetId& detid) { return (tkTopo->module(detid)); } -std::vector< std::pair > -VectorHitsBuilderValidation::getSimTrackIds(const edm::Handle >& simLinks, - const DetId& detId, uint32_t channel) const -{ - std::vector< std::pair > simTrkId; +std::vector > VectorHitsBuilderValidation::getSimTrackIds( + const edm::Handle >& simLinks, const DetId& detId, uint32_t channel) const { + std::vector > simTrkId; auto isearch = simLinks->find(detId); if (isearch != simLinks->end()) { // Loop over DigiSimLink in this det unit edm::DetSet link_detset = (*isearch); - for (typename edm::DetSet::const_iterator it = link_detset.data.begin(); - it != link_detset.data.end(); ++it) { - if (channel == it->channel()) simTrkId.push_back(std::make_pair(it->SimTrackId(), it->eventId())); - } + for (typename edm::DetSet::const_iterator it = link_detset.data.begin(); + it != link_detset.data.end(); + ++it) { + if (channel == it->channel()) + simTrkId.push_back(std::make_pair(it->SimTrackId(), it->eventId())); + } } return simTrkId; } -unsigned int VectorHitsBuilderValidation::getSimTrackId(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& pixelSimLinks, const DetId& detId, unsigned int channel) const { - edm::DetSetVector< PixelDigiSimLink >::const_iterator DSViter(pixelSimLinks->find(detId)); - if (DSViter == pixelSimLinks->end()) return 0; - for (edm::DetSet< PixelDigiSimLink >::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { - if (channel == it->channel()) return it->SimTrackId(); - } +unsigned int VectorHitsBuilderValidation::getSimTrackId( + const edm::Handle >& pixelSimLinks, + const DetId& detId, + unsigned int channel) const { + edm::DetSetVector::const_iterator DSViter(pixelSimLinks->find(detId)); + if (DSViter == pixelSimLinks->end()) return 0; + for (edm::DetSet::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { + if (channel == it->channel()) + return it->SimTrackId(); + } + return 0; } -void VectorHitsBuilderValidation::printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster){ +void VectorHitsBuilderValidation::printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster) { + if (!geomDetUnit) + return; - if (!geomDetUnit) return; - - const PixelGeomDetUnit* theGeomDet = dynamic_cast< const PixelGeomDetUnit* >(geomDetUnit); + const PixelGeomDetUnit* theGeomDet = dynamic_cast(geomDetUnit); const PixelTopology& topol = theGeomDet->specificTopology(); unsigned int layer = getLayerNumber(geomDetUnit->geographicalId()); unsigned int module = getModuleNumber(geomDetUnit->geographicalId()); LogTrace("VectorHitsBuilderValidation") << "Layer:" << layer << std::endl; - if(topol.ncolumns() == 32) - LogTrace("VectorHitsBuilderValidation") << "Pixel cluster with detId:" << geomDetUnit->geographicalId().rawId() << "(module:" << module << ") " << std::endl; - else if(topol.ncolumns() == 2 ) - LogTrace("VectorHitsBuilderValidation") << "Strip cluster with detId:" << geomDetUnit->geographicalId().rawId() << "(module:" << module << ") " << std::endl; - else std::cout << "no module?!" << std::endl; - LogTrace("VectorHitsBuilderValidation") << "with pitch:" << topol.pitch().first << " , " << topol.pitch().second << std::endl; - LogTrace("VectorHitsBuilderValidation") << " and width:" << theGeomDet->surface().bounds().width() << " , lenght:" << theGeomDet->surface().bounds().length() << std::endl; - - auto && lparams = cpe->localParameters( *cluster.cluster_phase2OT(), *theGeomDet ); + if (topol.ncolumns() == 32) + LogTrace("VectorHitsBuilderValidation") << "Pixel cluster with detId:" << geomDetUnit->geographicalId().rawId() + << "(module:" << module << ") " << std::endl; + else if (topol.ncolumns() == 2) + LogTrace("VectorHitsBuilderValidation") << "Strip cluster with detId:" << geomDetUnit->geographicalId().rawId() + << "(module:" << module << ") " << std::endl; + else + std::cout << "no module?!" << std::endl; + LogTrace("VectorHitsBuilderValidation") + << "with pitch:" << topol.pitch().first << " , " << topol.pitch().second << std::endl; + LogTrace("VectorHitsBuilderValidation") << " and width:" << theGeomDet->surface().bounds().width() + << " , lenght:" << theGeomDet->surface().bounds().length() << std::endl; + + auto&& lparams = cpe->localParameters(*cluster.cluster_phase2OT(), *theGeomDet); //Global3DPoint gparams = theGeomDet->surface().toGlobal(lparams.first); - LogTrace("VectorHitsBuilderValidation") << "\t local pos " << lparams.first << "with err " << lparams.second << std::endl; + LogTrace("VectorHitsBuilderValidation") + << "\t local pos " << lparams.first << "with err " << lparams.second << std::endl; return; } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index ba47ba6b3eb74..313e0aa78388b 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -48,97 +48,99 @@ #include struct VHHistos { - THStack* numberVHsMixed; - TH1F* numberVHsPS; - TH1F* numberVHs2S; + THStack* numberVHsMixed; + TH1F* numberVHsPS; + TH1F* numberVHs2S; - TGraph* globalPosXY[3]; - TGraph* localPosXY[3]; + TGraph* globalPosXY[3]; + TGraph* localPosXY[3]; - TH1F* deltaXVHSimHits[3]; - TH1F* deltaYVHSimHits[3]; + TH1F* deltaXVHSimHits[3]; + TH1F* deltaYVHSimHits[3]; - TH1F* deltaXVHSimHits_P[3]; - TH1F* deltaYVHSimHits_P[3]; + TH1F* deltaXVHSimHits_P[3]; + TH1F* deltaYVHSimHits_P[3]; - TH1F* digiEfficiency[3]; + TH1F* digiEfficiency[3]; - TH1F* totalSimHits; - TH1F* primarySimHits; - TH1F* otherSimHits; + TH1F* totalSimHits; + TH1F* primarySimHits; + TH1F* otherSimHits; - TH1F* curvature; - TH1F* width; - TH1F* deltaXlocal; + TH1F* curvature; + TH1F* width; + TH1F* deltaXlocal; }; class VectorHitsBuilderValidation : public edm::EDAnalyzer { - - public: - typedef edm::Ref, Phase2TrackerCluster1D > Phase2TrackerCluster1DRef; - - typedef std::map< unsigned int, std::vector< PSimHit > > SimHitsMap; - typedef std::map< unsigned int, SimTrack > SimTracksMap; - - explicit VectorHitsBuilderValidation(const edm::ParameterSet&); - ~VectorHitsBuilderValidation(); - void beginJob(); - void endJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - - private: - - std::map< unsigned int, VHHistos >::iterator createLayerHistograms(unsigned int); - void CreateVHsXYGraph( const std::vector,const std::vector ); - void CreateVHsRZGraph( const std::vector,const std::vector ); - void CreateWindowCorrGraph(); - - unsigned int getLayerNumber(const DetId&); - unsigned int getModuleNumber(const DetId& detid); - void printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster); - - std::pair isTrue(const VectorHit vh, const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& siphase2SimLinks, DetId& detId) const; - std::vector< std::pair > getSimTrackIds(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >&, const DetId&, uint32_t) const; - unsigned int getSimTrackId(const edm::Handle< edm::DetSetVector< PixelDigiSimLink > >& pixelSimLinks, const DetId& detId, unsigned int channel) const; - - edm::EDGetTokenT< edmNew::DetSetVector > srcClu_; - edm::EDGetTokenT< VectorHitCollectionNew > VHacc_; - edm::EDGetTokenT< VectorHitCollectionNew > VHrej_; - edm::ESInputTag cpeTag_; - const ClusterParameterEstimator* cpe; - - edm::EDGetTokenT< edm::DetSetVector > siphase2OTSimLinksToken_; - edm::EDGetTokenT< edm::PSimHitContainer > simHitsToken_; - edm::EDGetTokenT< edm::SimTrackContainer> simTracksToken_; - edm::EDGetTokenT< edm::SimVertexContainer > simVerticesToken_; - edm::EDGetTokenT trackingParticleToken_; - //SiPixelVectorHitBuilderAlgorithmBase *algo; - - const TrackerGeometry* tkGeom; - const TrackerTopology* tkTopo; - const MagneticField* magField; - - TTree* tree; - TGraph* trackerLayoutRZ_[3]; - TGraph* trackerLayoutXY_[3]; - TGraph* trackerLayoutXYBar_; - TGraph* trackerLayoutXYEC_; - TGraph* localPosXvsDeltaX_[3]; - TGraph* localPosYvsDeltaY_[3]; - TCanvas* VHXY_; - TCanvas* VHRZ_; - std::vector arrowVHs; - - TH2D* ParallaxCorrectionRZ_; - TH1F* VHaccLayer_; - TH1F* VHrejLayer_; - TH1F* VHaccTrueLayer_; - TH1F* VHrejTrueLayer_; - TH1F* VHaccTrue_signal_Layer_; - TH1F* VHrejTrue_signal_Layer_; - TH1F* VHaccTrueLayer_ratio; - TH1F* VHrejTrueLayer_ratio; - - std::map< unsigned int, VHHistos > histograms_; - +public: + typedef edm::Ref, Phase2TrackerCluster1D> Phase2TrackerCluster1DRef; + + typedef std::map > SimHitsMap; + typedef std::map SimTracksMap; + + explicit VectorHitsBuilderValidation(const edm::ParameterSet&); + ~VectorHitsBuilderValidation(); + void beginJob(); + void endJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + +private: + std::map::iterator createLayerHistograms(unsigned int); + void CreateVHsXYGraph(const std::vector, const std::vector); + void CreateVHsRZGraph(const std::vector, const std::vector); + void CreateWindowCorrGraph(); + + unsigned int getLayerNumber(const DetId&); + unsigned int getModuleNumber(const DetId& detid); + void printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster); + + std::pair isTrue(const VectorHit vh, + const edm::Handle >& siphase2SimLinks, + DetId& detId) const; + std::vector > getSimTrackIds( + const edm::Handle >&, const DetId&, uint32_t) const; + unsigned int getSimTrackId(const edm::Handle >& pixelSimLinks, + const DetId& detId, + unsigned int channel) const; + + edm::EDGetTokenT > srcClu_; + edm::EDGetTokenT VHacc_; + edm::EDGetTokenT VHrej_; + edm::ESInputTag cpeTag_; + const ClusterParameterEstimator* cpe; + + edm::EDGetTokenT > siphase2OTSimLinksToken_; + edm::EDGetTokenT simHitsToken_; + edm::EDGetTokenT simTracksToken_; + edm::EDGetTokenT simVerticesToken_; + edm::EDGetTokenT trackingParticleToken_; + //SiPixelVectorHitBuilderAlgorithmBase *algo; + + const TrackerGeometry* tkGeom; + const TrackerTopology* tkTopo; + const MagneticField* magField; + + TTree* tree; + TGraph* trackerLayoutRZ_[3]; + TGraph* trackerLayoutXY_[3]; + TGraph* trackerLayoutXYBar_; + TGraph* trackerLayoutXYEC_; + TGraph* localPosXvsDeltaX_[3]; + TGraph* localPosYvsDeltaY_[3]; + TCanvas* VHXY_; + TCanvas* VHRZ_; + std::vector arrowVHs; + + TH2D* ParallaxCorrectionRZ_; + TH1F* VHaccLayer_; + TH1F* VHrejLayer_; + TH1F* VHaccTrueLayer_; + TH1F* VHrejTrueLayer_; + TH1F* VHaccTrue_signal_Layer_; + TH1F* VHrejTrue_signal_Layer_; + TH1F* VHaccTrueLayer_ratio; + TH1F* VHrejTrueLayer_ratio; + + std::map histograms_; }; diff --git a/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc b/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc index 2a890e3d24a0c..c3946d8f19c8f 100644 --- a/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc +++ b/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc @@ -124,39 +124,44 @@ void SeedClusterRemoverPhase2::process(const TrackingRecHit *hit, float chi2, co OTs[cluster.key()] = false; assert(collectedOuterTrackers_.size() > cluster.key()); - collectedOuterTrackers_[cluster.key()]=true; + collectedOuterTrackers_[cluster.key()] = true; } else if (hitType == typeid(VectorHit)) { + if (!doOuterTracker_) + return; - if(!doOuterTracker_) return; - - const VectorHit *vhit = static_cast(hit); + const VectorHit *vhit = static_cast(hit); LogDebug("SeedClusterRemoverPhase2") << "Plain VectorHit in det " << detid.rawId(); //lower cluster Phase2TrackerRecHit1D::CluRef cluster = vhit->lowerCluster(); - if (cluster.id() != outerTrackerSourceProdID) throw cms::Exception("Inconsistent Data") << - "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id() << - " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n."; - + if (cluster.id() != outerTrackerSourceProdID) + throw cms::Exception("Inconsistent Data") + << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id() + << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n."; + assert(cluster.id() == outerTrackerSourceProdID); OTs[cluster.key()] = false; assert(collectedOuterTrackers_.size() > cluster.key()); - collectedOuterTrackers_[cluster.key()]=true; + collectedOuterTrackers_[cluster.key()] = true; - // upper cluster + // upper cluster cluster = vhit->upperCluster(); - if (cluster.id() != outerTrackerSourceProdID) throw cms::Exception("Inconsistent Data") << - "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id() << - " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n."; - + if (cluster.id() != outerTrackerSourceProdID) + throw cms::Exception("Inconsistent Data") + << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id() + << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n."; + assert(cluster.id() == outerTrackerSourceProdID); OTs[cluster.key()] = false; assert(collectedOuterTrackers_.size() > cluster.key()); - collectedOuterTrackers_[cluster.key()]=true; - } else throw cms::Exception("NOT IMPLEMENTED") << "I received a hit that was neither SiPixelRecHit nor Phase2TrackerRecHit1D but " << hitType.name() << " on detid " << detid.rawId() << "\n"; + collectedOuterTrackers_[cluster.key()] = true; + } else + throw cms::Exception("NOT IMPLEMENTED") + << "I received a hit that was neither SiPixelRecHit nor Phase2TrackerRecHit1D but " << hitType.name() + << " on detid " << detid.rawId() << "\n"; } void SeedClusterRemoverPhase2::produce(Event &iEvent, const EventSetup &iSetup) { diff --git a/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc b/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc index 14753707e6e6d..4ca48e1308910 100644 --- a/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc +++ b/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc @@ -193,17 +193,20 @@ namespace { collectedPhase2OTs[cluster.key()] = true; // Phase 2 OT is defined as Pixel detector (for now) - const auto &hitType = typeid(hit); + const auto& hitType = typeid(hit); if (hitType == typeid(VectorHit)) { - auto const & vectorHit = reinterpret_cast(hit); - auto const & lowCluster = vectorHit.lowerClusterRef(); - auto const & uppCluster = vectorHit.upperClusterRef(); - LogTrace("TrackClusterRemoverPhase2")<<"masking a VHit with lowCluster key: " << lowCluster.key() << " and upper key: " << uppCluster.key(); - if (lowCluster.isPhase2()) collectedPhase2OTs[lowCluster.key()]=true; - if (uppCluster.isPhase2()) collectedPhase2OTs[uppCluster.key()]=true; + auto const& vectorHit = reinterpret_cast(hit); + auto const& lowCluster = vectorHit.lowerClusterRef(); + auto const& uppCluster = vectorHit.upperClusterRef(); + LogTrace("TrackClusterRemoverPhase2") + << "masking a VHit with lowCluster key: " << lowCluster.key() << " and upper key: " << uppCluster.key(); + if (lowCluster.isPhase2()) + collectedPhase2OTs[lowCluster.key()] = true; + if (uppCluster.isPhase2()) + collectedPhase2OTs[uppCluster.key()] = true; } else { - LogTrace("TrackClusterRemoverPhase2")<<"it is not a VHits."; - } + LogTrace("TrackClusterRemoverPhase2") << "it is not a VHits."; + } } } diff --git a/RecoTracker/CkfPattern/src/PrintoutHelper.cc b/RecoTracker/CkfPattern/src/PrintoutHelper.cc index 024c28c661d9c..3fa643655cb1d 100644 --- a/RecoTracker/CkfPattern/src/PrintoutHelper.cc +++ b/RecoTracker/CkfPattern/src/PrintoutHelper.cc @@ -101,14 +101,13 @@ std::string PrintoutHelper::regressionTest(const TrackerGeometry& tracker, std:: } else buffer << "candidate with invalid last measurement state!" << std::endl; } - buffer<<"================================================="; - buffer<<"=========== Traj in details =====================\n"; - for (std::vector::const_iterator it = unsmoothedResult.begin(); - it != unsmoothedResult.end(); it++) { - for(auto hit : it->measurements()){ - buffer<< "measurement : " << hit.recHit()->geographicalId().rawId() << std::endl; + buffer << "================================================="; + buffer << "=========== Traj in details =====================\n"; + for (std::vector::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) { + for (auto hit : it->measurements()) { + buffer << "measurement : " << hit.recHit()->geographicalId().rawId() << std::endl; } - buffer<<"================\n"; + buffer << "================\n"; } return buffer.str(); } diff --git a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc index d014f2be7d47e..d3e89db5e9ec2 100644 --- a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc +++ b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc @@ -33,9 +33,8 @@ class TrackerRecoGeometryESProducer : public edm::ESProducer { using namespace edm; -TrackerRecoGeometryESProducer::TrackerRecoGeometryESProducer(const edm::ParameterSet &p) - : _usePhase2Stacks(p.getParameter("usePhase2Stacks")) -{ +TrackerRecoGeometryESProducer::TrackerRecoGeometryESProducer(const edm::ParameterSet &p) + : _usePhase2Stacks(p.getParameter("usePhase2Stacks")) { auto c = setWhatProduced(this); // 08-Oct-2007 - Patrick Janot @@ -52,7 +51,8 @@ std::unique_ptr TrackerRecoGeometryESProducer::produce( TrackerGeometry const &tG = iRecord.get(geomToken_); GeometricSearchTrackerBuilder builder; - return std::unique_ptr(builder.build(tG.trackerDet(), &tG, &iRecord.get(tTopToken_), _usePhase2Stacks)); + return std::unique_ptr( + builder.build(tG.trackerDet(), &tG, &iRecord.get(tTopToken_), _usePhase2Stacks)); } void TrackerRecoGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc index efdcf7a2e0cde..364f91ee33896 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc @@ -350,7 +350,6 @@ void MeasurementTrackerEventProducer::updateStrips(const edm::Event& event, //FIXME: just a temporary solution for phase2! void MeasurementTrackerEventProducer::updatePhase2OT(const edm::Event& event, Phase2OTMeasurementDetSet& thePh2OTDets) const { - thePh2OTDets.setEmpty(); // Phase2OT Clusters diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index d606cbf28c264..d4426e2242f7c 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -77,7 +77,7 @@ MeasurementTrackerImpl::MeasurementTrackerImpl(const BadStripCutsDet& badStripCu const PixelClusterParameterEstimator* pixelCPE, const StripClusterParameterEstimator* stripCPE, const SiStripRecHitMatcher* hitMatcher, - const VectorHitBuilderEDProducer* ph2hitMatcher, + const VectorHitBuilderEDProducer* ph2hitMatcher, const TrackerTopology* trackerTopology, const TrackerGeometry* trackerGeom, const GeometricSearchTracker* geometricSearchTracker, @@ -285,7 +285,7 @@ void MeasurementTrackerImpl::addGluedDet(const GluedGeomDet* gd) { void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd) { //since the Stack will be composed by PS or 2S, //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. - theStackDets.push_back(TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE() )); + theStackDets.push_back(TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE())); } void MeasurementTrackerImpl::initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology) { diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h index fd979dbf58005..858dc57fb319d 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h @@ -56,7 +56,7 @@ class dso_hidden MeasurementTrackerImpl final : public MeasurementTracker { const PixelClusterParameterEstimator* pixelCPE, const StripClusterParameterEstimator* stripCPE, const SiStripRecHitMatcher* hitMatcher, - const VectorHitBuilderEDProducer* ph2hitMatcher, + const VectorHitBuilderEDProducer* ph2hitMatcher, const TrackerTopology* trackerTopology, const TrackerGeometry* trackerGeom, const GeometricSearchTracker* geometricSearchTracker, diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index 5fce1d99addba..e54e929f97224 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -5,14 +5,10 @@ using namespace std; -TkStackMeasurementDet::TkStackMeasurementDet( const StackGeomDet* gdet, - const VectorHitBuilderEDProducer* matcher, - const PixelClusterParameterEstimator* cpe) : - MeasurementDet(gdet), - theMatcher(matcher), - thePixelCPE(cpe), - theLowerDet(nullptr), theUpperDet(nullptr) -{} +TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet, + const VectorHitBuilderEDProducer* matcher, + const PixelClusterParameterEstimator* cpe) + : MeasurementDet(gdet), theMatcher(matcher), thePixelCPE(cpe), theLowerDet(nullptr), theUpperDet(nullptr) {} void TkStackMeasurementDet::init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet) { theLowerDet = dynamic_cast(lowerDet); @@ -31,91 +27,91 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj HitCollectorForRecHits collector( &fastGeomDet(), theMatcher, theCPE, result ); collectRecHits(ts, collector); */ - if ( isEmpty(data.phase2OTData())== true ) return result; - LogTrace("MeasurementTracker")<<" is not empty"; - if (isActive(data) == false) return result; - LogTrace("MeasurementTracker")<<" and is active"; - - - const Phase2TrackerCluster1D* begin=0; - if (0 != data.phase2OTData().handle()->data().size()) { - begin = &(data.phase2OTData().handle()->data().front()); + if (isEmpty(data.phase2OTData()) == true) + return result; + LogTrace("MeasurementTracker") << " is not empty"; + if (isActive(data) == false) + return result; + LogTrace("MeasurementTracker") << " and is active"; + + const Phase2TrackerCluster1D* begin = nullptr; + if (!data.phase2OTData().handle()->data().empty()) { + begin = &(data.phase2OTData().handle()->data().front()); } - VectorHitBuilderAlgorithmBase * algo = theMatcher->algo() ; + VectorHitBuilderAlgorithmBase* algo = theMatcher->algo(); //VectorHitBuilderAlgorithm* vhalgo = dynamic_cast(algobase); LogTrace("MeasurementTracker") << "TkStackMeasurementDet::recHits algo has been set" << std::endl; - const detset & lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); - const detset & upperDetSet = data.phase2OTData().detSet(upperDet()->index()); - - LogTrace("MeasurementTracker")<<" DetSets set with sizes:" << lowerDetSet.size() << " and " << upperDetSet.size() << "!"; - result.reserve(lowerDetSet.size()>upperDetSet.size() ? lowerDetSet.size() : upperDetSet.size()); + const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); + const detset& upperDetSet = data.phase2OTData().detSet(upperDet()->index()); + LogTrace("MeasurementTracker") << " DetSets set with sizes:" << lowerDetSet.size() << " and " << upperDetSet.size() + << "!"; + result.reserve(lowerDetSet.size() > upperDetSet.size() ? lowerDetSet.size() : upperDetSet.size()); - for ( const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++ cil ) { - - if (cil < begin){ - edm::LogError("IndexMisMatch")<<"TkStackMeasurementDet cannot create hit because of index mismatch."; + for (const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++cil) { + if (cil < begin) { + edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; return result; } - unsigned int indexl = cil-begin; - LogTrace("MeasurementTracker")<<" index cluster lower" << indexl << " on detId " << fastGeomDet().geographicalId().rawId(); - - for ( const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ ciu ) { - - unsigned int indexu = ciu-begin; - if (ciu < begin){ - edm::LogError("IndexMisMatch")<<"TkStackMeasurementDet cannot create hit because of index mismatch."; + unsigned int indexl = cil - begin; + LogTrace("MeasurementTracker") << " index cluster lower" << indexl << " on detId " + << fastGeomDet().geographicalId().rawId(); + + for (const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ciu) { + unsigned int indexu = ciu - begin; + if (ciu < begin) { + edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; return result; } - LogTrace("VectorHitBuilderAlgorithm")<<" index cluster upper " << indexu; + LogTrace("VectorHitBuilderAlgorithm") << " index cluster upper " << indexu; - if(data.phase2OTClustersToSkip().empty() or ((not data.phase2OTClustersToSkip()[indexl]) and (not data.phase2OTClustersToSkip()[indexu])) ) { - Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo( data.phase2OTData().handle(), cil ); - Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo( data.phase2OTData().handle(), ciu ); + if (data.phase2OTClustersToSkip().empty() or + ((not data.phase2OTClustersToSkip()[indexl]) and (not data.phase2OTClustersToSkip()[indexu]))) { + Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo(data.phase2OTData().handle(), cil); + Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo(data.phase2OTData().handle(), ciu); //ERICA:I would have prefer to keep buildVectorHits ... - VectorHit vh = algo->buildVectorHit( &specificGeomDet(), clusterLower, clusterUpper); + VectorHit vh = algo->buildVectorHit(&specificGeomDet(), clusterLower, clusterUpper); LogTrace("MeasurementTracker") << "TkStackMeasurementDet::rechits adding VectorHits!" << std::endl; LogTrace("MeasurementTracker") << vh << std::endl; - result.push_back( std::make_shared( vh )); + result.push_back(std::make_shared(vh)); } } - } return result; } - - -bool TkStackMeasurementDet::measurements( const TrajectoryStateOnSurface& stateOnThisDet, - const MeasurementEstimator& est, const MeasurementTrackerEvent & data, - TempMeasurements & result) const { - LogDebug("MeasurementTracker")<<"TkStackMeasurementDet::measurements"; +bool TkStackMeasurementDet::measurements(const TrajectoryStateOnSurface& stateOnThisDet, + const MeasurementEstimator& est, + const MeasurementTrackerEvent& data, + TempMeasurements& result) const { + LogDebug("MeasurementTracker") << "TkStackMeasurementDet::measurements"; if (!isActive(data)) { result.add(theInactiveHit, 0.F); return true; } - - LogTrace("MeasurementTracker")<<" is active"; + + LogTrace("MeasurementTracker") << " is active"; auto oldSize = result.size(); - MeasurementDet::RecHitContainer && allHits = recHits(stateOnThisDet, data); + MeasurementDet::RecHitContainer&& allHits = recHits(stateOnThisDet, data); - for (auto && hit : allHits) { - std::pair diffEst = est.estimate( stateOnThisDet, *hit); + for (auto&& hit : allHits) { + std::pair diffEst = est.estimate(stateOnThisDet, *hit); //LogTrace("MeasurementTracker")<< "State on this Det: " << stateOnThisDet ; - LogDebug("MeasurementTracker")<< "New vh added with chi2: " << diffEst.second ; - if ( diffEst.first) + LogDebug("MeasurementTracker") << "New vh added with chi2: " << diffEst.second; + if (diffEst.first) result.add(std::move(hit), diffEst.second); } - if (result.size()>oldSize) return true; + if (result.size() > oldSize) + return true; // create a TrajectoryMeasurement with an invalid RecHit and zero estimate result.add(theMissingHit, 0.F); - LogDebug("MeasurementTracker")<< "adding missing hit"; + LogDebug("MeasurementTracker") << "adding missing hit"; return false; } diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index 9d6722e3e464f..df1e1af4c48b1 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -14,14 +14,16 @@ class TkStackMeasurementDet final : public MeasurementDet { public: - TkStackMeasurementDet(const StackGeomDet* gdet, const VectorHitBuilderEDProducer* matcher, const PixelClusterParameterEstimator* cpe); + TkStackMeasurementDet(const StackGeomDet* gdet, + const VectorHitBuilderEDProducer* matcher, + const PixelClusterParameterEstimator* cpe); void init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet); RecHitContainer recHits(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent& data) const override; const StackGeomDet& specificGeomDet() const { return static_cast(fastGeomDet()); } typedef edm::Ref, Phase2TrackerCluster1D> Phase2TrackerCluster1DRef; - + typedef edmNew::DetSet detset; typedef detset::const_iterator const_iterator; @@ -33,12 +35,13 @@ class TkStackMeasurementDet final : public MeasurementDet { const TkPhase2OTMeasurementDet* lowerDet() const { return theLowerDet; } const TkPhase2OTMeasurementDet* upperDet() const { return theUpperDet; } - /// return TRUE if both lower and upper components are active bool isActive(const MeasurementTrackerEvent& data) const override { return lowerDet()->isActive(data) && upperDet()->isActive(data); } - bool isEmpty(const Phase2OTMeasurementDetSet & data) const {return data.empty(lowerDet()->index()) || data.empty(upperDet()->index());} + bool isEmpty(const Phase2OTMeasurementDetSet& data) const { + return data.empty(lowerDet()->index()) || data.empty(upperDet()->index()); + } /// return TRUE if at least one of the lower and upper components has badChannels bool hasBadComponents(const TrajectoryStateOnSurface& tsos, const MeasurementTrackerEvent& data) const override { diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h index ccdf22fe6302f..2a2fc822a318c 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h @@ -408,8 +408,9 @@ class PxMeasurementDetSet { //FIXME:just temporary solution for phase2 OT that works! class Phase2OTMeasurementConditionSet { public: - Phase2OTMeasurementConditionSet(const VectorHitBuilderEDProducer* ph2matcher, const ClusterParameterEstimator *cpe) : - thePhase2Matcher(ph2matcher), theCPE(cpe) {} + Phase2OTMeasurementConditionSet(const VectorHitBuilderEDProducer* ph2matcher, + const ClusterParameterEstimator* cpe) + : thePhase2Matcher(ph2matcher), theCPE(cpe) {} void init(int size); @@ -418,7 +419,7 @@ class Phase2OTMeasurementConditionSet { int find(unsigned int jd, int i = 0) const { return std::lower_bound(id_.begin() + i, id_.end(), jd) - id_.begin(); } const ClusterParameterEstimator* cpe() const { return theCPE; } - const VectorHitBuilderEDProducer* matcher() const { return thePhase2Matcher;} + const VectorHitBuilderEDProducer* matcher() const { return thePhase2Matcher; } bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; } /** \brief Turn on/off the module for reconstruction, for the full run or lumi (using info from DB, usually). @@ -431,7 +432,7 @@ class Phase2OTMeasurementConditionSet { // Globals (not-per-event) const VectorHitBuilderEDProducer* thePhase2Matcher; const ClusterParameterEstimator* theCPE; - + // Locals, per-event std::vector id_; std::vector activeThisPeriod_; diff --git a/RecoTracker/Record/interface/CkfComponentsRecord.h b/RecoTracker/Record/interface/CkfComponentsRecord.h index 6d64c5709ced9..f6d513f77645f 100644 --- a/RecoTracker/Record/interface/CkfComponentsRecord.h +++ b/RecoTracker/Record/interface/CkfComponentsRecord.h @@ -39,4 +39,3 @@ class CkfComponentsRecord SiPixelLorentzAngleRcd, SiStripLorentzAngleDepRcd> > {}; #endif - diff --git a/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h b/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h index 834ae11b28432..893f7fdf1b2b9 100644 --- a/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h +++ b/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h @@ -17,9 +17,9 @@ class GeometricSearchTrackerBuilder { ~GeometricSearchTrackerBuilder() {} GeometricSearchTracker* build(const GeometricDet* theGeometricTracker, - const TrackerGeometry* theGeomDetGeometry, - const TrackerTopology* tTopo, - const bool usePhase2Stacks = false) __attribute__ ((cold)); + const TrackerGeometry* theGeomDetGeometry, + const TrackerTopology* tTopo, + const bool usePhase2Stacks = false) __attribute__((cold)); }; #endif diff --git a/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc b/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc index 4ed5853b6b67f..51cd455a23717 100644 --- a/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc +++ b/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc @@ -19,14 +19,10 @@ using namespace std; - -GeometricSearchTracker* -GeometricSearchTrackerBuilder::build(const GeometricDet* theGeometricTracker, - const TrackerGeometry* theGeomDetGeometry, - const TrackerTopology* tTopo, - const bool usePhase2Stacks) -{ - +GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* theGeometricTracker, + const TrackerGeometry* theGeomDetGeometry, + const TrackerTopology* tTopo, + const bool usePhase2Stacks) { PixelBarrelLayerBuilder aPixelBarrelLayerBuilder; Phase2OTBarrelLayerBuilder aPhase2OTBarrelLayerBuilder; PixelForwardLayerBuilder aPixelForwardLayerBuilder; @@ -100,9 +96,10 @@ GeometricSearchTrackerBuilder::build(const GeometricDet* theGeometricTracker, if ((*it)->type() == GeometricDet::OTPhase2Barrel) { vector theTOBGeometricDetLayers = (*it)->components(); - for(vector::const_iterator it2=theTOBGeometricDetLayers.begin(); - it2!=theTOBGeometricDetLayers.end(); it2++){ - theTOBLayers.push_back( aPhase2OTBarrelLayerBuilder.build(*it2,theGeomDetGeometry,useBrothers) ); + for (vector::const_iterator it2 = theTOBGeometricDetLayers.begin(); + it2 != theTOBGeometricDetLayers.end(); + it2++) { + theTOBLayers.push_back(aPhase2OTBarrelLayerBuilder.build(*it2, theGeomDetGeometry, useBrothers)); } } @@ -172,12 +169,13 @@ GeometricSearchTrackerBuilder::build(const GeometricDet* theGeometricTracker, vector theTIDGeometricDetLayers = (*it)->components(); bool useBrothers = !usePhase2Stacks; - for(vector::const_iterator it2=theTIDGeometricDetLayers.begin(); - it2!=theTIDGeometricDetLayers.end(); it2++){ - if((*it2)->positionBounds().z() < 0) - theNegTIDLayers.push_back( aPhase2EndcapLayerBuilder.build(*it2,theGeomDetGeometry,useBrothers) ); - if((*it2)->positionBounds().z() > 0) - thePosTIDLayers.push_back( aPhase2EndcapLayerBuilder.build(*it2,theGeomDetGeometry,useBrothers) ); + for (vector::const_iterator it2 = theTIDGeometricDetLayers.begin(); + it2 != theTIDGeometricDetLayers.end(); + it2++) { + if ((*it2)->positionBounds().z() < 0) + theNegTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(*it2, theGeomDetGeometry, useBrothers)); + if ((*it2)->positionBounds().z() > 0) + thePosTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(*it2, theGeomDetGeometry, useBrothers)); } } diff --git a/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.cc index 64be320013f11..bd8beefb265dd 100644 --- a/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.cc @@ -5,9 +5,8 @@ using namespace edm; using namespace std; Phase2EndcapLayer* Phase2EndcapLayerBuilder::build(const GeometricDet* aPhase2EndcapLayer, - const TrackerGeometry* theGeomDetGeometry, - const bool useBrothers) -{ + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) { LogTrace("TkDetLayers") << "Phase2EndcapLayerBuilder::build"; vector theGeometricRings = aPhase2EndcapLayer->components(); LogTrace("TkDetLayers") << "theGeometricRings.size(): " << theGeometricRings.size(); @@ -15,12 +14,12 @@ Phase2EndcapLayer* Phase2EndcapLayerBuilder::build(const GeometricDet* aPhase2En Phase2EndcapRingBuilder myBuilder; vector thePhase2EndcapRings; - for(vector::const_iterator it=theGeometricRings.begin(); - it!=theGeometricRings.end();it++){ - // if we are in the phaseII OT, it will use the brothers to build pt modules - // if we are in the phaseII pixel detector, it will not - thePhase2EndcapRings.push_back(myBuilder.build( *it,theGeomDetGeometry,useBrothers )); + for (vector::const_iterator it = theGeometricRings.begin(); it != theGeometricRings.end(); + it++) { + // if we are in the phaseII OT, it will use the brothers to build pt modules + // if we are in the phaseII pixel detector, it will not + thePhase2EndcapRings.push_back(myBuilder.build(*it, theGeomDetGeometry, useBrothers)); } - return new Phase2EndcapLayer(thePhase2EndcapRings,useBrothers); + return new Phase2EndcapLayer(thePhase2EndcapRings, useBrothers); } diff --git a/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.h b/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.h index f695b399f2125..b577b5b8c6380 100644 --- a/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.h +++ b/RecoTracker/TkDetLayers/src/Phase2EndcapLayerBuilder.h @@ -15,8 +15,8 @@ class Phase2EndcapLayerBuilder { public: Phase2EndcapLayerBuilder(){}; Phase2EndcapLayer* build(const GeometricDet* aPhase2EndcapLayer, - const TrackerGeometry* theGeomDetGeometry, - const bool useBrothers) __attribute__ ((cold)); + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) __attribute__((cold)); }; #pragma GCC visibility pop diff --git a/RecoTracker/TkDetLayers/src/Phase2EndcapRingBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2EndcapRingBuilder.cc index 69bfe5c15ebc9..2df7298f9ad94 100644 --- a/RecoTracker/TkDetLayers/src/Phase2EndcapRingBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2EndcapRingBuilder.cc @@ -6,11 +6,10 @@ using namespace edm; using namespace std; Phase2EndcapRing* Phase2EndcapRingBuilder::build(const GeometricDet* aPhase2EndcapRing, - const TrackerGeometry* theGeomDetGeometry, - const bool useBrothers) -{ - vector allGeometricDets = aPhase2EndcapRing->components(); - vector compGeometricDets; + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) { + vector allGeometricDets = aPhase2EndcapRing->components(); + vector compGeometricDets; LogDebug("TkDetLayers") << "Phase2EndcapRingBuilder with #Modules: " << allGeometricDets.size() << std::endl; vector frontGeomDets; diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.cc index 66304a77d886b..81c43d72e3158 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.cc @@ -7,10 +7,9 @@ using namespace std; using namespace edm; Phase2OTBarrelLayer* Phase2OTBarrelLayerBuilder::build(const GeometricDet* aPhase2OTBarrelLayer, - const TrackerGeometry* theGeomDetGeometry, - const bool useBrothers) -{ - // This builder is very similar to TOBLayer one. Most of the code should be put in a + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) { + // This builder is very similar to TOBLayer one. Most of the code should be put in a // common place. LogTrace("TkDetLayers") << "Phase2OTBarrelLayerBuilder::build"; @@ -43,17 +42,16 @@ Phase2OTBarrelLayer* Phase2OTBarrelLayerBuilder::build(const GeometricDet* aPhas meanR += theGeometricDetRods[index]->positionBounds().perp(); if (!theGeometricDetRods.empty()) - meanR/=(double) theGeometricDetRods.size(); - - for(unsigned int index=0; index!=theGeometricDetRods.size(); index++){ - if(theGeometricDetRods[index]->positionBounds().perp() < meanR) - theInnerRods.push_back(myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], - theGeomDetGeometry, useBrothers) ); + meanR /= (double)theGeometricDetRods.size(); - if(theGeometricDetRods[index]->positionBounds().perp() > meanR) - theOuterRods.push_back(myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], - theGeomDetGeometry, useBrothers) ); + for (unsigned int index = 0; index != theGeometricDetRods.size(); index++) { + if (theGeometricDetRods[index]->positionBounds().perp() < meanR) + theInnerRods.push_back( + myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], theGeomDetGeometry, useBrothers)); + if (theGeometricDetRods[index]->positionBounds().perp() > meanR) + theOuterRods.push_back( + myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], theGeomDetGeometry, useBrothers)); } if (theGeometricDetRings.empty()) @@ -69,13 +67,12 @@ Phase2OTBarrelLayer* Phase2OTBarrelLayerBuilder::build(const GeometricDet* aPhas // properly calculate the meanR value to separate rod in inner/outer. double centralZ = 0.0; - - for(vector::const_iterator it=theGeometricDetRings.begin(); - it!=theGeometricDetRings.end();it++){ - if((*it)->positionBounds().z() < centralZ) - theNegativeRings.push_back(myPhase2EndcapRingBuilder.build( *it,theGeomDetGeometry,useBrothers )); - if((*it)->positionBounds().z() > centralZ) - thePositiveRings.push_back(myPhase2EndcapRingBuilder.build( *it,theGeomDetGeometry,useBrothers )); + for (vector::const_iterator it = theGeometricDetRings.begin(); it != theGeometricDetRings.end(); + it++) { + if ((*it)->positionBounds().z() < centralZ) + theNegativeRings.push_back(myPhase2EndcapRingBuilder.build(*it, theGeomDetGeometry, useBrothers)); + if ((*it)->positionBounds().z() > centralZ) + thePositiveRings.push_back(myPhase2EndcapRingBuilder.build(*it, theGeomDetGeometry, useBrothers)); } return new Phase2OTtiltedBarrelLayer(theInnerRods, theOuterRods, theNegativeRings, thePositiveRings); diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.h b/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.h index 93a57436d3977..340193c50cc71 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.h +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelLayerBuilder.h @@ -15,10 +15,8 @@ class Phase2OTBarrelLayerBuilder { public: Phase2OTBarrelLayerBuilder(){}; Phase2OTBarrelLayer* build(const GeometricDet* aPhase2OTBarrelLayer, - const TrackerGeometry* theGeomDetGeometry, - const bool useBrothers = true) __attribute__ ((cold)); - - + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers = true) __attribute__((cold)); }; #pragma GCC visibility pop diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.cc index 0e377521e329e..b9cb3e4a22185 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.cc @@ -61,8 +61,10 @@ Phase2OTBarrelRod::Phase2OTBarrelRod(vector& innerDets, << " , " << (**i).position().perp() << " , " << (**i).position().eta() << " , " << (**i).position().phi(); } - if(theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) LogDebug("TkDetLayers") << "==== with stacks =====" ; - if(!theInnerDetBrothers.empty() && !theOuterDetBrothers.empty()) LogDebug("TkDetLayers") << "==== without stacks =====" ; + if (theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) + LogDebug("TkDetLayers") << "==== with stacks ====="; + if (!theInnerDetBrothers.empty() && !theOuterDetBrothers.empty()) + LogDebug("TkDetLayers") << "==== without stacks ====="; for (vector::const_iterator i = theOuterDets.begin(); i != theOuterDets.end(); i++) { LogDebug("TkDetLayers") << "outer Phase2OTBarrelRod's Det pos z,perp,eta,phi: " << (**i).position().z() << " , " @@ -200,7 +202,8 @@ bool Phase2OTBarrelRod::addClosest(const TrajectoryStateOnSurface& tsos, vector& brotherresult) const { const vector& sRod(subRod(crossing.subLayerIndex())); bool firstgroup = CompatibleDetToGroupAdder::add(*sRod[crossing.closestDetIndex()], tsos, prop, est, result); - if(theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) return firstgroup; + if (theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) + return firstgroup; // it assumes that the closestDetIndex is ok also for the brother detectors: the crossing is NOT recomputed const vector& sRodBrothers(subRodBrothers(crossing.subLayerIndex())); @@ -272,7 +275,8 @@ void Phase2OTBarrelRod::searchNeighbors(const TrajectoryStateOnSurface& tsos, break; if (!Adder::add(*sRod[idet], tsos, prop, est, result)) break; - if(theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) break; + if (theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) + break; // If the two above checks are passed also the brother module will be added with no further checks Adder::add(*sBrotherRod[idet], tsos, prop, est, brotherresult); } @@ -281,7 +285,8 @@ void Phase2OTBarrelRod::searchNeighbors(const TrajectoryStateOnSurface& tsos, break; if (!Adder::add(*sRod[idet], tsos, prop, est, result)) break; - if(theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) break; + if (theInnerDetBrothers.empty() && theOuterDetBrothers.empty()) + break; // If the two above checks are passed also the brother module will be added with no further checks Adder::add(*sBrotherRod[idet], tsos, prop, est, brotherresult); } diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.h b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.h index 85e97a5a05cee..cf14dec6ac06d 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.h +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRod.h @@ -18,7 +18,8 @@ class Phase2OTBarrelRod final : public DetRod { Phase2OTBarrelRod(std::vector& innerDets, std::vector& outerDets, const std::vector& innerDetBrothers = std::vector(), - const std::vector& outerDetBrothers = std::vector()) __attribute__((cold)); + const std::vector& outerDetBrothers = std::vector()) + __attribute__((cold)); ~Phase2OTBarrelRod() override __attribute__((cold)); // GeometricSearchDet interface diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc index 0719e5980555b..0153f2bab2861 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc @@ -5,11 +5,10 @@ using namespace edm; using namespace std; Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2OTBarrelRod, - const TrackerGeometry* theGeomDetGeometry, - const bool useBrothers) -{ + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers) { vector allGeometricDets = thePhase2OTBarrelRod->components(); -// vector compGeometricDets; + // vector compGeometricDets; LogDebug("TkDetLayers") << "Phase2OTBarrelRodBuilder with #Modules: " << allGeometricDets.size() << std::endl; LogDebug("TkDetLayers") << " useBrothers: " << useBrothers << std::endl; @@ -20,39 +19,55 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 double meanR = 0; - if(!useBrothers){ - - for(vector::const_iterator compGeometricDets=allGeometricDets.begin(); compGeometricDets!=allGeometricDets.end();compGeometricDets++){ + if (!useBrothers) { + for (vector::const_iterator compGeometricDets = allGeometricDets.begin(); + compGeometricDets != allGeometricDets.end(); + compGeometricDets++) { //LogTrace("TkDetLayers") << " compGeometricDets.positionBounds().perp() " << (*compGeometricDets)->positionBounds().perp() << std::endl; meanR = meanR + (*compGeometricDets)->positionBounds().perp(); } - meanR = meanR/allGeometricDets.size(); + meanR = meanR / allGeometricDets.size(); LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl; +<<<<<<< HEAD for(vector::const_iterator compGeometricDets=allGeometricDets.begin(); compGeometricDets!=allGeometricDets.end(); compGeometricDets++){ const GeomDet* theGeomDet = theGeomDetGeometry->idToDet( (*compGeometricDets)->geographicalId() ); if( (*compGeometricDets)->positionBounds().perp() < meanR) +======= + + for (vector::const_iterator compGeometricDets = allGeometricDets.begin(); + compGeometricDets != allGeometricDets.end(); + compGeometricDets++) { + const GeomDet* theGeomDet = theGeomDetGeometry->idToDet((*compGeometricDets)->geographicalID()); + + if ((*compGeometricDets)->positionBounds().perp() < meanR) +>>>>>>> apply code checks innerGeomDets.push_back(theGeomDet); - - if( (*compGeometricDets)->positionBounds().perp() > meanR) + + if ((*compGeometricDets)->positionBounds().perp() > meanR) outerGeomDets.push_back(theGeomDet); } - - LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size() ; - LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size() ; - - return new Phase2OTBarrelRod(innerGeomDets,outerGeomDets,innerGeomDetBrothers,outerGeomDetBrothers); +<<<<<<< HEAD +======= + LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size(); + LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size(); + + return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers); + + } else { +>>>>>>> apply code checks vector compGeometricDets; - + vector innerGeomDetBrothers; vector outerGeomDetBrothers; - + double meanRBrothers = 0; - for(vector::const_iterator it=allGeometricDets.begin(); it!=allGeometricDets.end();it++){ - compGeometricDets = (*it)->components(); - if (compGeometricDets.size() != 2){ + for (vector::const_iterator it = allGeometricDets.begin(); it != allGeometricDets.end(); + it++) { + compGeometricDets = (*it)->components(); + if (compGeometricDets.size() != 2) { LogDebug("TkDetLayers") << " Stack not with two components but with " << compGeometricDets.size() << std::endl; } else { //LogTrace("TkDetLayers") << " compGeometricDets[0]->positionBounds().perp() " << compGeometricDets[0]->positionBounds().perp() << std::endl; @@ -60,42 +75,39 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 meanR = meanR + compGeometricDets[0]->positionBounds().perp(); meanRBrothers = meanRBrothers + compGeometricDets[1]->positionBounds().perp(); } - } - meanR = meanR/allGeometricDets.size(); - meanRBrothers = meanRBrothers/allGeometricDets.size(); + meanR = meanR / allGeometricDets.size(); + meanRBrothers = meanRBrothers / allGeometricDets.size(); LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl; LogDebug("TkDetLayers") << " meanR Upper " << meanRBrothers << std::endl; - - for(vector::iterator it=allGeometricDets.begin(); it!=allGeometricDets.end(); it++){ - compGeometricDets = (*it)->components(); - const GeomDet* theGeomDet = theGeomDetGeometry->idToDet( compGeometricDets[0]->geographicalId() ); - LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[0]->geographicalId().rawId() << std::endl; - - if( compGeometricDets[0]->positionBounds().perp() < meanR) + + for (vector::iterator it = allGeometricDets.begin(); it != allGeometricDets.end(); it++) { + compGeometricDets = (*it)->components(); + const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets[0]->geographicalID()); + LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[0]->geographicalID().rawId() << std::endl; + + if (compGeometricDets[0]->positionBounds().perp() < meanR) innerGeomDets.push_back(theGeomDet); - - if( compGeometricDets[0]->positionBounds().perp() > meanR) + + if (compGeometricDets[0]->positionBounds().perp() > meanR) outerGeomDets.push_back(theGeomDet); - - const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet( compGeometricDets[1]->geographicalId() ); - LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[1]->geographicalId().rawId() << std::endl; - if( compGeometricDets[1]->positionBounds().perp() < meanRBrothers) + + const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet(compGeometricDets[1]->geographicalID()); + LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[1]->geographicalID().rawId() << std::endl; + if (compGeometricDets[1]->positionBounds().perp() < meanRBrothers) innerGeomDetBrothers.push_back(theGeomDetBrother); - - if( compGeometricDets[1]->positionBounds().perp() > meanRBrothers) + + if (compGeometricDets[1]->positionBounds().perp() > meanRBrothers) outerGeomDetBrothers.push_back(theGeomDetBrother); } - - LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size() ; - LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size() ; - LogDebug("TkDetLayers") << "innerGeomDetsBro.size(): " << innerGeomDetBrothers.size() ; - LogDebug("TkDetLayers") << "outerGeomDetsBro.size(): " << outerGeomDetBrothers.size() ; - - return new Phase2OTBarrelRod(innerGeomDets,outerGeomDets,innerGeomDetBrothers,outerGeomDetBrothers); - - } - return new Phase2OTBarrelRod(innerGeomDets,outerGeomDets,innerGeomDetBrothers,outerGeomDetBrothers); + LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size(); + LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size(); + LogDebug("TkDetLayers") << "innerGeomDetsBro.size(): " << innerGeomDetBrothers.size(); + LogDebug("TkDetLayers") << "outerGeomDetsBro.size(): " << outerGeomDetBrothers.size(); + + return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers); + } + return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers); } diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.h b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.h index 7a6876ec24adc..f51e0852451bb 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.h +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.h @@ -15,10 +15,8 @@ class Phase2OTBarrelRodBuilder { public: Phase2OTBarrelRodBuilder(){}; Phase2OTBarrelRod* build(const GeometricDet* thePhase2OTBarrelRod, - const TrackerGeometry* theGeomDetGeometry, - const bool useBrothers = true) __attribute__ ((cold)); - - + const TrackerGeometry* theGeomDetGeometry, + const bool useBrothers = true) __attribute__((cold)); }; #pragma GCC visibility pop diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h index e731e3e595e5c..92857dd689d7a 100644 --- a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h +++ b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h @@ -23,38 +23,43 @@ class TrajectoryStateUpdator; -class SeedingOTEDProducer : public edm::stream::EDProducer<> -{ - - public: - +class SeedingOTEDProducer : public edm::stream::EDProducer<> { +public: explicit SeedingOTEDProducer(const edm::ParameterSet&); - virtual ~SeedingOTEDProducer(); - virtual void produce(edm::Event&, const edm::EventSetup&) override; + ~SeedingOTEDProducer() override; + void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions&); - TrajectorySeedCollection run( edm::Handle< VectorHitCollectionNew > ); - unsigned int checkLayer( unsigned int iidd ); - std::vector collectVHsOnLayer( edm::Handle< VectorHitCollectionNew >, unsigned int ); - void printVHsOnLayer( edm::Handle< VectorHitCollectionNew >, unsigned int ); - const TrajectoryStateOnSurface buildInitialTSOS( VectorHit& ); - AlgebraicSymMatrix assign44To55( AlgebraicSymMatrix ); - std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, const Propagator&, const TrackingRecHit& hit); + TrajectorySeedCollection run(edm::Handle); + unsigned int checkLayer(unsigned int iidd); + std::vector collectVHsOnLayer(edm::Handle, unsigned int); + void printVHsOnLayer(edm::Handle, unsigned int); + const TrajectoryStateOnSurface buildInitialTSOS(VectorHit&); + AlgebraicSymMatrix assign44To55(AlgebraicSymMatrix); + std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, + const Propagator&, + const TrackingRecHit& hit); float computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot); - float computeInverseMomentumError(VectorHit& vh, const float globalTheta, const MagneticField* magField, const double sigmaZ_beamSpot); + float computeInverseMomentumError(VectorHit& vh, + const float globalTheta, + const MagneticField* magField, + const double sigmaZ_beamSpot); - TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, const DetId& id, const Propagator& prop); + TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, + const edm::OwnVector& container, + const DetId& id, + const Propagator& prop); struct isInvalid { bool operator()(const TrajectoryMeasurement& measurement) { - return ( ((measurement).recHit() == 0) || !((measurement).recHit()->isValid()) || !((measurement).updatedState().isValid()) ); + return (((measurement).recHit() == nullptr) || !((measurement).recHit()->isValid()) || + !((measurement).updatedState().isValid())); } }; - private: - - edm::EDGetTokenT< VectorHitCollectionNew > vhProducerToken; +private: + edm::EDGetTokenT vhProducerToken; const TrackerTopology* tkTopo; const MeasurementTracker* measurementTracker; const LayerMeasurements* layerMeasurements; diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 8606e5e9b27c8..d048057a51a17 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -16,30 +16,27 @@ #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf): - theUpdator(nullptr), - tkMeasEventToken( consumes(conf.getParameter("trackerEvent")) ) -{ - vhProducerToken = consumes< VectorHitCollectionNew >(edm::InputTag(conf.getParameter("src"))); - beamSpotToken = consumes< reco::BeamSpot >(conf.getParameter("beamSpotLabel")); +SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) + : theUpdator(nullptr), + tkMeasEventToken(consumes(conf.getParameter("trackerEvent"))) { + vhProducerToken = consumes(edm::InputTag(conf.getParameter("src"))); + beamSpotToken = consumes(conf.getParameter("beamSpotLabel")); updatorName = conf.getParameter("updator"); produces(); } - -SeedingOTEDProducer::~SeedingOTEDProducer() { -} -void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions){ +SeedingOTEDProducer::~SeedingOTEDProducer() {} + +void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("src", edm::InputTag("siPhase2VectorHits","vectorHitsAccepted")); + desc.add("src", edm::InputTag("siPhase2VectorHits", "vectorHitsAccepted")); desc.add("trackerEvent", edm::InputTag("MeasurementTrackerEvent")); desc.add("beamSpotLabel", edm::InputTag("offlineBeamSpot")); desc.add("updator", std::string("KFUpdator")); descriptions.add("SeedingOTEDProducer", desc); } - -void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) -{ + +void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { std::cout << "SeedingOT::produce() begin" << std::endl; std::unique_ptr seedsWithVHs(new TrajectorySeedCollection()); @@ -51,16 +48,16 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) es.get().get(measurementTrackerHandle); measurementTracker = measurementTrackerHandle.product(); edm::Handle measurementTrackerEvent; - event.getByToken(tkMeasEventToken,measurementTrackerEvent); + event.getByToken(tkMeasEventToken, measurementTrackerEvent); layerMeasurements = new LayerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); - + edm::ESHandle est; - es.get().get("Chi2",est); + es.get().get("Chi2", est); estimator = est.product(); edm::ESHandle prop; - es.get().get("PropagatorWithMaterial",prop); + es.get().get("PropagatorWithMaterial", prop); propagator = prop.product(); edm::ESHandle magFieldHandle; @@ -79,49 +76,47 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) } // Get the vector hits - edm::Handle< VectorHitCollectionNew > vhs; + edm::Handle vhs; event.getByToken(vhProducerToken, vhs); -/* + /* edm::ESHandle< ClusterParameterEstimator > parameterestimator; es.get().get(cpe, parameterestimator); const Phase2StripCPEGeometric & cpeOT(*parameterestimator); */ TrajectorySeedCollection const& tempSeeds = run(vhs); - for( TrajectorySeedCollection::const_iterator qIt = tempSeeds.begin(); qIt < tempSeeds.end(); ++qIt ) { - seedsWithVHs->push_back( *qIt ); + for (TrajectorySeedCollection::const_iterator qIt = tempSeeds.begin(); qIt < tempSeeds.end(); ++qIt) { + seedsWithVHs->push_back(*qIt); } seedsWithVHs->shrink_to_fit(); event.put(std::move(seedsWithVHs)); std::cout << "SeedingOT::produce() end" << std::endl; - } -TrajectorySeedCollection SeedingOTEDProducer::run( edm::Handle< VectorHitCollectionNew > VHs ){ - +TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { TrajectorySeedCollection result; std::cout << "-----------------------------" << std::endl; - printVHsOnLayer(VHs,1); - printVHsOnLayer(VHs,2); - printVHsOnLayer(VHs,3); - printVHsOnLayer(VHs,4); - printVHsOnLayer(VHs,5); - printVHsOnLayer(VHs,6); + printVHsOnLayer(VHs, 1); + printVHsOnLayer(VHs, 2); + printVHsOnLayer(VHs, 3); + printVHsOnLayer(VHs, 4); + printVHsOnLayer(VHs, 5); + printVHsOnLayer(VHs, 6); std::cout << "-----------------------------" << std::endl; //check if all the first three layers have VHs - std::vector VHseedsL1 = collectVHsOnLayer(VHs,1); - std::vector VHseedsL2 = collectVHsOnLayer(VHs,2); - std::vector VHseedsL3 = collectVHsOnLayer(VHs,3); - if(VHseedsL1.empty() || VHseedsL2.empty() || VHseedsL3.empty()){ + std::vector VHseedsL1 = collectVHsOnLayer(VHs, 1); + std::vector VHseedsL2 = collectVHsOnLayer(VHs, 2); + std::vector VHseedsL3 = collectVHsOnLayer(VHs, 3); + if (VHseedsL1.empty() || VHseedsL2.empty() || VHseedsL3.empty()) { std::cout << "------- seeds found: " << result.size() << " ------" << std::endl; std::cout << "- L1 or L2 or L3 are empty! -" << std::endl; std::cout << "-----------------------------" << std::endl; return result; } - + //seeds are built in the L3 of the OT const BarrelDetLayer* barrelOTLayer2 = measurementTracker->geometricSearchTracker()->tobLayers().at(1); std::cout << "VH seeds = " << VHseedsL3.size() << std::endl; @@ -131,32 +126,32 @@ TrajectorySeedCollection SeedingOTEDProducer::run( edm::Handle< VectorHitCollect Propagator* buildingPropagator = &*propagator->clone(); buildingPropagator->setPropagationDirection(alongMomentum); - for(auto hitL3 : VHseedsL3){ - + for (auto hitL3 : VHseedsL3) { //building a tsos out of a VectorHit std::cout << "\t1a) Building a seed for the VH: " << hitL3 << std::endl; const TrajectoryStateOnSurface initialTSOS = buildInitialTSOS(hitL3); - float signZ = copysign(1.0,initialTSOS.globalPosition().z()); - float signPz = copysign(1.0,initialTSOS.globalMomentum().z()); + float signZ = copysign(1.0, initialTSOS.globalPosition().z()); + float signPz = copysign(1.0, initialTSOS.globalMomentum().z()); std::cout << "\t initialTSOS : " << initialTSOS << std::endl; //set the direction of the propagator std::cout << "\t1b) Set the searchingPropagator direction: " << std::endl; - if(signZ*signPz > 0.0) + if (signZ * signPz > 0.0) searchingPropagator->setPropagationDirection(oppositeToMomentum); - if(signZ*signPz < 0.0) + if (signZ * signPz < 0.0) searchingPropagator->setPropagationDirection(alongMomentum); - if(searchingPropagator->propagationDirection() == alongMomentum) + if (searchingPropagator->propagationDirection() == alongMomentum) std::cout << "\t searchingPropagator along Momentum" << std::endl; - if(searchingPropagator->propagationDirection() == oppositeToMomentum) + if (searchingPropagator->propagationDirection() == oppositeToMomentum) std::cout << "\t ropagator opposite To Momentum" << std::endl; //find vHits in layer 2 std::cout << "-----------------------------" << std::endl; std::cout << "\t1c) Search/find hit in layer 2: " << std::endl; - std::vector measurementsL2 = layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + std::vector measurementsL2 = + layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); std::cout << "\t vh compatibles on L2: " << measurementsL2.size() << std::endl; //other options @@ -166,53 +161,57 @@ TrajectorySeedCollection SeedingOTEDProducer::run( edm::Handle< VectorHitCollect //auto && measurementsL2G = layerMeasurements->groupedMeasurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); //std::cout << "\t #try3 vh grouped compatibles: " << measurementsL2G.size() << std::endl; - - std::vector::iterator measurementsL2end = std::remove_if(measurementsL2.begin(), measurementsL2.end(), isInvalid()); + std::vector::iterator measurementsL2end = + std::remove_if(measurementsL2.begin(), measurementsL2.end(), isInvalid()); measurementsL2.erase(measurementsL2end, measurementsL2.end()); std::cout << "\t vh compatibles on L2(without invalidHit): " << measurementsL2.size() << std::endl; std::cout << "-----------------------------" << std::endl; - if(!measurementsL2.empty()){ + if (!measurementsL2.empty()) { //not sure if building it everytime takes time/memory const DetLayer* barrelOTLayer1 = measurementTracker->geometricSearchTracker()->tobLayers().at(0); - - for(auto mL2 : measurementsL2){ + for (auto mL2 : measurementsL2) { std::cout << "\t2a) Check the searchingPropagator direction: " << std::endl; - if(searchingPropagator->propagationDirection() == alongMomentum) + if (searchingPropagator->propagationDirection() == alongMomentum) std::cout << "\t searchingPropagator along Momentum" << std::endl; - if(searchingPropagator->propagationDirection() == oppositeToMomentum) + if (searchingPropagator->propagationDirection() == oppositeToMomentum) std::cout << "\t searchingPropagator opposite To Momentum" << std::endl; const TrackingRecHit* hitL2 = mL2.recHit().get(); std::cout << "\t2b) and the VH on layer 2: " << std::endl; const VectorHit* vhit = dynamic_cast(hitL2); std::cout << "\t vh is valid >> " << (*vhit) << std::endl; - + //propagate to the L2 and update the TSOS std::cout << "\t2c) Propagation and update on L2: " << std::endl; - std::pair updatedTSOS = propagateAndUpdate(initialTSOS, *searchingPropagator, *hitL2); - if(!updatedTSOS.first) std::cout << "\t updatedTSOS on L2 is NOT valid : " << updatedTSOS.second << std::endl; - if(!updatedTSOS.first) continue; + std::pair updatedTSOS = + propagateAndUpdate(initialTSOS, *searchingPropagator, *hitL2); + if (!updatedTSOS.first) + std::cout << "\t updatedTSOS on L2 is NOT valid : " << updatedTSOS.second << std::endl; + if (!updatedTSOS.first) + continue; std::cout << "\t updatedTSOS is valid : " << updatedTSOS.second << std::endl; - std::cout << "\t chi2 VH/updatedTSOS : " << estimator->estimate(updatedTSOS.second, *hitL2).second << std::endl; - + std::cout << "\t chi2 VH/updatedTSOS : " << estimator->estimate(updatedTSOS.second, *hitL2).second + << std::endl; + //searching possible VHs in L1 std::cout << "\t2d) Search/find hit in layer 1: " << std::endl; - std::vector measurementsL1 = layerMeasurements->measurements(*barrelOTLayer1, updatedTSOS.second, *searchingPropagator, *estimator); + std::vector measurementsL1 = + layerMeasurements->measurements(*barrelOTLayer1, updatedTSOS.second, *searchingPropagator, *estimator); std::cout << "\t vh compatibles on L1: " << measurementsL1.size() << std::endl; - std::vector::iterator measurementsL1end = std::remove_if(measurementsL1.begin(), measurementsL1.end(), isInvalid()); + std::vector::iterator measurementsL1end = + std::remove_if(measurementsL1.begin(), measurementsL1.end(), isInvalid()); measurementsL1.erase(measurementsL1end, measurementsL1.end()); std::cout << "\t vh compatibles on L1(without invalidHit): " << measurementsL1.size() << std::endl; std::cout << "-----------------------------" << std::endl; - if(!measurementsL1.empty()){ - - for(auto mL1 : measurementsL1){ + if (!measurementsL1.empty()) { + for (auto mL1 : measurementsL1) { std::cout << "\t3a) Check the searchingPropagator direction: " << std::endl; - if(searchingPropagator->propagationDirection() == alongMomentum) + if (searchingPropagator->propagationDirection() == alongMomentum) std::cout << "\t searchingPropagator along Momentum" << std::endl; - if(searchingPropagator->propagationDirection() == oppositeToMomentum) + if (searchingPropagator->propagationDirection() == oppositeToMomentum) std::cout << "\t searchingPropagator opposite To Momentum" << std::endl; const TrackingRecHit* hitL1 = mL1.recHit().get(); @@ -222,12 +221,15 @@ TrajectorySeedCollection SeedingOTEDProducer::run( edm::Handle< VectorHitCollect //propagate to the L1 and update the TSOS std::cout << "\t3c) Propagation and update on L1: " << std::endl; - std::pair updatedTSOSL1 = propagateAndUpdate(updatedTSOS.second, *searchingPropagator, *hitL1); - if(!updatedTSOSL1.first) std::cout << "\t updatedTSOS on L1 is NOT valid : " << updatedTSOSL1.second << std::endl; - if(!updatedTSOSL1.first) continue; + std::pair updatedTSOSL1 = + propagateAndUpdate(updatedTSOS.second, *searchingPropagator, *hitL1); + if (!updatedTSOSL1.first) + std::cout << "\t updatedTSOS on L1 is NOT valid : " << updatedTSOSL1.second << std::endl; + if (!updatedTSOSL1.first) + continue; std::cout << "\t updatedTSOS on L1 : " << updatedTSOSL1.second << std::endl; - std::cout << "\t chi2 VH/updatedTSOS : " << estimator->estimate(updatedTSOSL1.second, *hitL1).second << std::endl; - + std::cout << "\t chi2 VH/updatedTSOS : " << estimator->estimate(updatedTSOSL1.second, *hitL1).second + << std::endl; std::cout << "\t3d) Creation of the Seed: " << std::endl; // passSelection(updatedTSOS) : @@ -239,10 +241,10 @@ TrajectorySeedCollection SeedingOTEDProducer::run( edm::Handle< VectorHitCollect //building trajectory inside-out std::cout << "\t3e) Building trajectory inside-out: " << std::endl; - if(searchingPropagator->propagationDirection() == alongMomentum){ + if (searchingPropagator->propagationDirection() == alongMomentum) { buildingPropagator->setPropagationDirection(oppositeToMomentum); std::cout << "\t buildingPropagator opposite To Momentum" << std::endl; - } else if(searchingPropagator->propagationDirection() == oppositeToMomentum){ + } else if (searchingPropagator->propagationDirection() == oppositeToMomentum) { buildingPropagator->setPropagationDirection(alongMomentum); std::cout << "\t buildingPropagator along Momentum" << std::endl; } @@ -250,21 +252,23 @@ TrajectorySeedCollection SeedingOTEDProducer::run( edm::Handle< VectorHitCollect updatedTSOSL1.second.rescaleError(100); std::cout << "\t updatedTSOS on L1 : " << updatedTSOSL1.second << std::endl; - TrajectoryStateOnSurface updatedTSOSL1_final = theUpdator->update(updatedTSOSL1.second,*hitL1); - if UNLIKELY(!updatedTSOSL1_final.isValid()) continue; - std::pair updatedTSOSL2_final = propagateAndUpdate(updatedTSOSL1_final, *buildingPropagator, *hitL2); - std::pair updatedTSOSL3_final = propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, hitL3); + TrajectoryStateOnSurface updatedTSOSL1_final = theUpdator->update(updatedTSOSL1.second, *hitL1); + if + UNLIKELY(!updatedTSOSL1_final.isValid()) continue; + std::pair updatedTSOSL2_final = + propagateAndUpdate(updatedTSOSL1_final, *buildingPropagator, *hitL2); + std::pair updatedTSOSL3_final = + propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, hitL3); std::cout << "\t updatedTSOS final on L3 : " << updatedTSOSL3_final.second << std::endl; - TrajectorySeed ts = createSeed(updatedTSOSL3_final.second, container, hitL3.geographicalId(),*buildingPropagator); + TrajectorySeed ts = + createSeed(updatedTSOSL3_final.second, container, hitL3.geographicalId(), *buildingPropagator); result.push_back(ts); } - } - + std::cout << "-----" << std::endl; } } - } std::cout << "-----------------------------" << std::endl; std::cout << "------- seeds found: " << result.size() << " ------" << std::endl; @@ -273,24 +277,24 @@ TrajectorySeedCollection SeedingOTEDProducer::run( edm::Handle< VectorHitCollect return result; } -unsigned int SeedingOTEDProducer::checkLayer( unsigned int iidd ){ +unsigned int SeedingOTEDProducer::checkLayer(unsigned int iidd) { StripSubdetector strip = StripSubdetector(iidd); unsigned int subid = strip.subdetId(); - if (subid == StripSubdetector::TIB || subid == StripSubdetector::TOB) { + if (subid == StripSubdetector::TIB || subid == StripSubdetector::TOB) { return tkTopo->layer(iidd); } return 0; } -std::vector SeedingOTEDProducer::collectVHsOnLayer( edm::Handle< VectorHitCollectionNew > VHs, unsigned int layerNumber ){ - +std::vector SeedingOTEDProducer::collectVHsOnLayer(edm::Handle VHs, + unsigned int layerNumber) { const VectorHitCollectionNew& input = *VHs; std::vector VHsOnLayer; - if (input.size() > 0 ) { + if (!input.empty()) { //std::cout << "initial VH collection size = " << input.size() << std::endl; for (auto DSViter : input) { - if(checkLayer(DSViter.id()) == layerNumber){ - for(auto vh : DSViter){ + if (checkLayer(DSViter.id()) == layerNumber) { + for (auto vh : DSViter) { VHsOnLayer.push_back(vh); } } @@ -302,12 +306,13 @@ std::vector SeedingOTEDProducer::collectVHsOnLayer( edm::Handle< Vect return VHsOnLayer; } -void SeedingOTEDProducer::printVHsOnLayer( edm::Handle< VectorHitCollectionNew > VHs, unsigned int layerNumber ){ +void SeedingOTEDProducer::printVHsOnLayer(edm::Handle VHs, unsigned int layerNumber) { const VectorHitCollectionNew& input = *VHs; - if (input.size() > 0 ) { + if (!input.empty()) { for (auto DSViter : input) { - for(auto vh : DSViter){ - if(checkLayer(DSViter.id()) == layerNumber) std::cout << " VH in layer " << layerNumber << " >> " << vh << std::endl; + for (auto vh : DSViter) { + if (checkLayer(DSViter.id()) == layerNumber) + std::cout << " VH in layer " << layerNumber << " >> " << vh << std::endl; } } } else { @@ -315,8 +320,7 @@ void SeedingOTEDProducer::printVHsOnLayer( edm::Handle< VectorHitCollectionNew > } } -const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS( VectorHit& vHit ){ - +const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& vHit) { //FIXME::charge is fine 1 every two times!! int charge = 1; //float pT = vHit.transverseMomentum(magField); @@ -324,9 +328,9 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS( VectorHit& float x = vHit.localPosition().x(); float y = vHit.localPosition().y(); float dx = vHit.localDirection().x(); - float dy = vHit.localDirection().y(); + float dy = vHit.localDirection().y(); // Pz and Dz should have the same sign - float signPz = copysign(1.0,vHit.globalPosition().z()); + float signPz = copysign(1.0, vHit.globalPosition().z()); // having fun with theta Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); @@ -336,15 +340,15 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS( VectorHit& //std::cout << "\tgv theta error : " << computeGlobalThetaError(vHit, beamSpot->sigmaZ()) << std::endl; //std::cout << "\tgv eta : " << gv.eta() << std::endl; // gv transform to local (lv) - const Local3DVector lv( vHit.det()->surface().toLocal( gv ) ); + const Local3DVector lv(vHit.det()->surface().toLocal(gv)); //std::cout << "\tlv : " << lv << std::endl; // replace dy with second component of the lv renormalized to the z component - dy = lv.y()/lv.z(); + dy = lv.y() / lv.z(); - LocalTrajectoryParameters ltpar2(charge/p, dx, dy, x, y, signPz); + LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p - mat[0][0] = pow(computeInverseMomentumError(vHit, theta,magField,beamSpot->sigmaZ()),2); + mat[0][0] = pow(computeInverseMomentumError(vHit, theta, magField, beamSpot->sigmaZ()), 2); //std::cout << "\tltraj : " << charge << "," << 1./p <<","<< dx <<","<< dy <<","<< x <<","<< y <<","<< signPz << std::endl; //std::cout << "\tmat : " << mat << std::endl; @@ -355,48 +359,54 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS( VectorHit& return tsos; } -AlgebraicSymMatrix SeedingOTEDProducer::assign44To55( AlgebraicSymMatrix mat44 ){ - if(mat44.num_row() != 4 || mat44.num_col() != 4) +AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) { + if (mat44.num_row() != 4 || mat44.num_col() != 4) assert("Wrong dimension! This should be a 4x4 matrix!"); - AlgebraicSymMatrix result(5,0); - for(int i = 1; i < 5; i++){ - for(int j = 1; j < 5; j++){ - result[i][j] = mat44[i-1][j-1]; + AlgebraicSymMatrix result(5, 0); + for (int i = 1; i < 5; i++) { + for (int j = 1; j < 5; j++) { + result[i][j] = mat44[i - 1][j - 1]; } } return result; } -std::pair SeedingOTEDProducer::propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit){ - TrajectoryStateOnSurface propTSOS = prop.propagate( initialTSOS, hit.det()->surface()); - TrajectoryStateOnSurface updatedTSOS = theUpdator->update(propTSOS,hit); +std::pair SeedingOTEDProducer::propagateAndUpdate( + const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit) { + TrajectoryStateOnSurface propTSOS = prop.propagate(initialTSOS, hit.det()->surface()); + TrajectoryStateOnSurface updatedTSOS = theUpdator->update(propTSOS, hit); //std::cout << "updatedTSOS : " << updatedTSOS << std::endl; - if UNLIKELY(!updatedTSOS.isValid()) return std::make_pair( false, updatedTSOS); - return std::make_pair( true, updatedTSOS); + if + UNLIKELY(!updatedTSOS.isValid()) return std::make_pair(false, updatedTSOS); + return std::make_pair(true, updatedTSOS); } -float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot){ - - double derivative = vh.globalPosition().perp()/(pow(vh.globalPosition().z(),2)+pow(vh.globalPosition().perp(),2)); - double derivative2 = pow(derivative,2); - return pow( derivative2*vh.lowerGlobalPosErr().czz()+derivative2*pow(sigmaZ_beamSpot,2), 0.5); - +float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot) { + double derivative = + vh.globalPosition().perp() / (pow(vh.globalPosition().z(), 2) + pow(vh.globalPosition().perp(), 2)); + double derivative2 = pow(derivative, 2); + return pow(derivative2 * vh.lowerGlobalPosErr().czz() + derivative2 * pow(sigmaZ_beamSpot, 2), 0.5); } -float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, const float globalTheta, const MagneticField* magField, const double sigmaZ_beamSpot){ - +float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, + const float globalTheta, + const MagneticField* magField, + const double sigmaZ_beamSpot) { //for pT > 2GeV, 1/pT has sigma = 1/sqrt(12) - float varianceInverseTransvMomentum = 1./12; - double derivativeTheta2 = pow(cos(globalTheta)/vh.transverseMomentum(magField),2); - double derivativeInverseTransvMomentum2 = pow(sin(globalTheta),2); + float varianceInverseTransvMomentum = 1. / 12; + double derivativeTheta2 = pow(cos(globalTheta) / vh.transverseMomentum(magField), 2); + double derivativeInverseTransvMomentum2 = pow(sin(globalTheta), 2); float thetaError = computeGlobalThetaError(vh, sigmaZ_beamSpot); - return pow(derivativeTheta2*pow(thetaError,2)+derivativeInverseTransvMomentum2*varianceInverseTransvMomentum,0.5); - + return pow(derivativeTheta2 * pow(thetaError, 2) + derivativeInverseTransvMomentum2 * varianceInverseTransvMomentum, + 0.5); } -TrajectorySeed SeedingOTEDProducer::createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, const DetId& id, const Propagator& prop) { -/* +TrajectorySeed SeedingOTEDProducer::createSeed(const TrajectoryStateOnSurface& tsos, + const edm::OwnVector& container, + const DetId& id, + const Propagator& prop) { + /* //I have already propagator and updator //const Propagator* propagator = &(*propagatorHandle); //KFUpdator updator; @@ -417,7 +427,7 @@ TrajectorySeed SeedingOTEDProducer::createSeed(const TrajectoryStateOnSurface& t if(state.first) updatedState = state.second; */ -/* + /* TrajectoryStateOnSurface state = (iHit==1) ? propagator->propagate(tsos, container[iHit].det()->surface()) : propagator->propagate(updatedState, container[iHit].det()->surface()); std::cout << "-------> new state >> " << state << std::endl; @@ -433,13 +443,12 @@ TrajectorySeed SeedingOTEDProducer::createSeed(const TrajectoryStateOnSurface& t if (!updatedState.isValid()) return TrajectorySeed(); //seedHits.push_back(newtth.release()); -*/ -// } +*/ + // } //if(!hit) return; PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos, id.rawId()); - return TrajectorySeed(seedTSOS,container,prop.propagationDirection()); + return TrajectorySeed(seedTSOS, container, prop.propagationDirection()); //if ( !filter || filter->compatible(seed)) seedCollection.push_back(std::move(seed)); - } diff --git a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc index 54a96d8d94b96..c1ea40b32ef31 100644 --- a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc +++ b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc @@ -18,72 +18,85 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "DataFormats/SiStripCluster/interface/SiStripClusterTools.h" -#include +#include -#include +#include using namespace ctfseeding; using namespace std; using namespace edm; -HitExtractorSTRP::HitExtractorSTRP(GeomDetEnumerators::SubDetector subdet, TrackerDetSide side, int idLayer, float iminGoodCharge): - theLayerSubDet(subdet), theSide(side), theIdLayer(idLayer), - minAbsZ(0), theMinRing(1), theMaxRing(0), - hasMatchedHits(false), hasRPhiHits(false), hasStereoHits(false), - hasVectorHits(false), - hasRingSelector(false), hasSimpleRphiHitsCleaner(true) -{ minGoodCharge=iminGoodCharge; if (minGoodCharge>0) skipClusters=true; } +HitExtractorSTRP::HitExtractorSTRP(GeomDetEnumerators::SubDetector subdet, + TrackerDetSide side, + int idLayer, + float iminGoodCharge) + : theLayerSubDet(subdet), + theSide(side), + theIdLayer(idLayer), + minAbsZ(0), + theMinRing(1), + theMaxRing(0), + hasMatchedHits(false), + hasRPhiHits(false), + hasStereoHits(false), + hasVectorHits(false), + hasRingSelector(false), + hasSimpleRphiHitsCleaner(true) { + minGoodCharge = iminGoodCharge; + if (minGoodCharge > 0) + skipClusters = true; +} -void HitExtractorSTRP::useSkipClusters_(const edm::InputTag & m, edm::ConsumesCollector& iC) { +void HitExtractorSTRP::useSkipClusters_(const edm::InputTag& m, edm::ConsumesCollector& iC) { theSkipClusters = iC.consumes(m); theSkipPhase2Clusters = iC.consumes(m); } -void HitExtractorSTRP::useRingSelector(int minRing, int maxRing) -{ - hasRingSelector=true; - theMinRing=minRing; - theMaxRing=maxRing; +void HitExtractorSTRP::useRingSelector(int minRing, int maxRing) { + hasRingSelector = true; + theMinRing = minRing; + theMaxRing = maxRing; } -bool HitExtractorSTRP::ringRange(int ring) const -{ - if (!hasRingSelector) return true; - return (ring >= theMinRing) & (ring <= theMaxRing); +bool HitExtractorSTRP::ringRange(int ring) const { + if (!hasRingSelector) + return true; + return (ring >= theMinRing) & (ring <= theMaxRing); } -bool HitExtractorSTRP::skipThis(DetId id, OmniClusterRef const& clus, - edm::Handle > > & stripClusterMask) const { - - if (maskCluster && (stripClusterMask->mask(clus.key())) ) return true; +bool HitExtractorSTRP::skipThis( + DetId id, + OmniClusterRef const& clus, + edm::Handle > >& stripClusterMask) const { + if (maskCluster && (stripClusterMask->mask(clus.key()))) + return true; - if UNLIKELY(minGoodCharge<=0) return false; - return siStripClusterTools::chargePerCM(id,*clus.cluster_strip()) <= minGoodCharge; + if + UNLIKELY(minGoodCharge <= 0) return false; + return siStripClusterTools::chargePerCM(id, *clus.cluster_strip()) <= minGoodCharge; } +std::pair HitExtractorSTRP::skipThis( + const TkTransientTrackingRecHitBuilder& ttrhBuilder, + TkHitRef matched, + edm::Handle > >& stripClusterMask) const { + const SiStripMatchedRecHit2D& hit = (SiStripMatchedRecHit2D const&)(matched); - -std::pair -HitExtractorSTRP::skipThis(const TkTransientTrackingRecHitBuilder& ttrhBuilder, - TkHitRef matched, - edm::Handle > > & stripClusterMask) const { - const SiStripMatchedRecHit2D & hit = (SiStripMatchedRecHit2D const&)(matched); - assert(dynamic_cast(&matched)); - auto id = hit.geographicalId(); - ProjectedSiStripRecHit2D * replaceMe = nullptr; - bool rejectSt = skipThis(id,hit.stereoClusterRef(), stripClusterMask); - bool rejectMono = skipThis(id, hit.monoClusterRef(), stripClusterMask); + auto id = hit.geographicalId(); + ProjectedSiStripRecHit2D* replaceMe = nullptr; + bool rejectSt = skipThis(id, hit.stereoClusterRef(), stripClusterMask); + bool rejectMono = skipThis(id, hit.monoClusterRef(), stripClusterMask); - if ((!rejectSt)&(!rejectMono)){ + if ((!rejectSt) & (!rejectMono)) { // keepit - return std::make_pair(false,replaceMe); + return std::make_pair(false, replaceMe); } - if (failProjection || (rejectSt&rejectMono) ){ + if (failProjection || (rejectSt & rejectMono)) { //only skip if both hits are done - return std::make_pair(true,replaceMe); + return std::make_pair(true, replaceMe); } // replace with one @@ -91,60 +104,73 @@ HitExtractorSTRP::skipThis(const TkTransientTrackingRecHitBuilder& ttrhBuilder, auto cloner = ttrhBuilder.cloner(); replaceMe = cloner.project(hit, rejectSt, TrajectoryStateOnSurface()).release(); if (rejectSt) - LogDebug("HitExtractorSTRP")<<"a matched hit is partially masked, and the mono hit got projected onto: "<geographicalId().rawId()<<" key: "<geographicalId().rawId()<<" key: "<geographicalId().rawId() << " key: " << hit.monoClusterRef().key(); + else + LogDebug("HitExtractorSTRP") << "a matched hit is partially masked, and the stereo hit got projected onto: " + << replaceMe->geographicalId().rawId() << " key: " << hit.stereoClusterRef().key(); - return std::make_pair(true,replaceMe); + return std::make_pair(true, replaceMe); } - -void HitExtractorSTRP::cleanedOfClusters( const TkTransientTrackingRecHitBuilder& ttrhBuilder, - const edm::Event& ev, HitExtractor::Hits & hits, - bool matched, - unsigned int cleanFrom) const{ - unsigned int skipped=0; - unsigned int projected=0; - if(hasMatchedHits || hasRPhiHits || hasStereoHits){ - LogTrace("HitExtractorSTRP")<<"getting "< stripClusterMask; - if (maskCluster) ev.getByToken(theSkipClusters,stripClusterMask); - for (unsigned int iH=cleanFrom;iHisValid()); auto id = hits[iH]->geographicalId(); if (matched) { - bool replace; ProjectedSiStripRecHit2D * replaceMe; std::tie(replace,replaceMe) = skipThis(ttrhBuilder, *hits[iH],stripClusterMask); + bool replace; + ProjectedSiStripRecHit2D* replaceMe; + std::tie(replace, replaceMe) = skipThis(ttrhBuilder, *hits[iH], stripClusterMask); if (replace) { - if (!replaceMe) { - LogTrace("HitExtractorSTRP")<<"skipping a matched hit on :"<geographicalId().rawId(); - skipped++; - } else { projected++; } - hits[iH].reset(replaceMe); - if (replaceMe==nullptr) assert(hits[iH].empty()); - else assert(hits[iH].isOwn()); + if (!replaceMe) { + LogTrace("HitExtractorSTRP") << "skipping a matched hit on :" << hits[iH]->geographicalId().rawId(); + skipped++; + } else { + projected++; + } + hits[iH].reset(replaceMe); + if (replaceMe == nullptr) + assert(hits[iH].empty()); + else + assert(hits[iH].isOwn()); } - } - else if (skipThis(id, hits[iH]->firstClusterRef(),stripClusterMask)){ - LogTrace("HitExtractorSTRP")<<"skipping a hit on :"<geographicalId().rawId()<<" key: "; + } else if (skipThis(id, hits[iH]->firstClusterRef(), stripClusterMask)) { + LogTrace("HitExtractorSTRP") << "skipping a hit on :" << hits[iH]->geographicalId().rawId() << " key: "; skipped++; hits[iH].reset(); } } } - if(hasVectorHits){ - LogTrace("HitExtractorSTRP")<<"getting "< ph2ClusterMask; - if (maskCluster) ev.getByToken(theSkipPhase2Clusters,ph2ClusterMask); - for (unsigned int iH=cleanFrom;iHgeographicalId().rawId(); + if (maskCluster) + ev.getByToken(theSkipPhase2Clusters, ph2ClusterMask); + for (unsigned int iH = cleanFrom; iH < hits.size(); ++iH) { + LogTrace("HitExtractorSTRP") << "analizing hit on :" << hits[iH]->geographicalId().rawId(); assert(hits[iH]->isValid()); - const VectorHit & vhit = dynamic_cast(*hits[iH]); - LogTrace("HitExtractorSTRP")<<" key lower: "<firstClusterRef().key() ; + const VectorHit& vhit = dynamic_cast(*hits[iH]); + LogTrace("HitExtractorSTRP") << " key lower: " << vhit.lowerClusterRef().key() + << " and key upper: " << vhit.upperClusterRef().key(); + LogTrace("HitExtractorSTRP") << " key lower: " << hits[iH]->firstClusterRef().key(); //FIXME:: introduce a "projected" version later? - if (maskCluster && (ph2ClusterMask->mask(vhit.lowerClusterRef().key()) || ph2ClusterMask->mask(vhit.upperClusterRef().key())) ){ - LogTrace("HitExtractorSTRP")<<"skipping a vector hit on :"<geographicalId().rawId()<<" key lower: "<mask(vhit.lowerClusterRef().key()) || ph2ClusterMask->mask(vhit.upperClusterRef().key()))) { + LogTrace("HitExtractorSTRP") << "skipping a vector hit on :" << hits[iH]->geographicalId().rawId() + << " key lower: " << vhit.lowerClusterRef().key() + << " and key upper: " << vhit.upperClusterRef().key(); skipped++; hits[iH].reset(); } @@ -152,17 +178,18 @@ void HitExtractorSTRP::cleanedOfClusters( const TkTransientTrackingRecHitBuilder } // remove empty elements... - auto last = std::remove_if(hits.begin()+cleanFrom,hits.end(),[]( HitPointer const & p) {return p.empty();}); - hits.resize(last-hits.begin()); + auto last = std::remove_if(hits.begin() + cleanFrom, hits.end(), [](HitPointer const& p) { return p.empty(); }); + hits.resize(last - hits.begin()); - LogTrace("HitExtractorSTRP")<<"skipped :"< tTopoHandle; @@ -173,165 +200,206 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder // TIB // if (theLayerSubDet == GeomDetEnumerators::TIB) { - LogTrace("HitExtractorSTRP")<<"Getting hits into the TIB"; + LogTrace("HitExtractorSTRP") << "Getting hits into the TIB"; if (hasMatchedHits) { edm::Handle matchedHits; - ev.getByToken( theMatchedHits, matchedHits); - if (skipClusters) cleanFrom=result.size(); - range2SeedingHits( *matchedHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,true,cleanFrom); + ev.getByToken(theMatchedHits, matchedHits); + if (skipClusters) + cleanFrom = result.size(); + range2SeedingHits(*matchedHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, true, cleanFrom); } if (hasRPhiHits) { edm::Handle rphiHits; - ev.getByToken( theRPhiHits, rphiHits); - if (hasMatchedHits){ - if (!hasSimpleRphiHitsCleaner){ // this is a brutal "cleaning". Add something smarter in the future - if (skipClusters) cleanFrom=result.size(); - range2SeedingHits( *rphiHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); - } + ev.getByToken(theRPhiHits, rphiHits); + if (hasMatchedHits) { + if (!hasSimpleRphiHitsCleaner) { // this is a brutal "cleaning". Add something smarter in the future + if (skipClusters) + cleanFrom = result.size(); + range2SeedingHits(*rphiHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + } } else { - if (skipClusters) cleanFrom=result.size(); - range2SeedingHits( *rphiHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + if (skipClusters) + cleanFrom = result.size(); + range2SeedingHits(*rphiHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } } if (hasStereoHits) { edm::Handle stereoHits; - ev.getByToken( theStereoHits, stereoHits); - if (skipClusters) cleanFrom=result.size(); - range2SeedingHits( *stereoHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + ev.getByToken(theStereoHits, stereoHits); + if (skipClusters) + cleanFrom = result.size(); + range2SeedingHits(*stereoHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } if (hasVectorHits) { - LogError("HitExtractorSTRP")<<"TIB is not supposed to be in Phase2 TRK detector configuration. What follows have never been checked before! "; + LogError("HitExtractorSTRP") << "TIB is not supposed to be in Phase2 TRK detector configuration. What follows " + "have never been checked before! "; edm::Handle vectorHits; - ev.getByToken( theVectorHits, vectorHits); - if (skipClusters) cleanFrom=result.size(); - range2SeedingHits( *vectorHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + ev.getByToken(theVectorHits, vectorHits); + if (skipClusters) + cleanFrom = result.size(); + range2SeedingHits(*vectorHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } - + } - + // // TID // else if (theLayerSubDet == GeomDetEnumerators::TID) { - LogTrace("HitExtractorSTRP")<<"Getting hits into the TID"; + LogTrace("HitExtractorSTRP") << "Getting hits into the TID"; if (hasMatchedHits) { - edm::Handle matchedHits; - ev.getByToken( theMatchedHits, matchedHits); - if (skipClusters) cleanFrom=result.size(); - auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); - SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); - for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; - for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); - } + edm::Handle matchedHits; + ev.getByToken(theMatchedHits, matchedHits); + if (skipClusters) + cleanFrom = result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide), theIdLayer); + SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); + for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tidRing(it->detId()); + if (!ringRange(ring)) + continue; + for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; + ++hit) { + result.emplace_back(*hit); } - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,true,cleanFrom); + } + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, true, cleanFrom); } if (hasRPhiHits) { - edm::Handle rphiHits; - ev.getByToken( theRPhiHits, rphiHits); - if (skipClusters) cleanFrom=result.size(); - auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); - SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second); - for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; - if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) continue; // this is a brutal "cleaning". Add something smarter in the future - for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); - } + edm::Handle rphiHits; + ev.getByToken(theRPhiHits, rphiHits); + if (skipClusters) + cleanFrom = result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide), theIdLayer); + SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second); + for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tidRing(it->detId()); + if (!ringRange(ring)) + continue; + if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) + continue; // this is a brutal "cleaning". Add something smarter in the future + for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); } - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } if (hasStereoHits) { - edm::Handle stereoHits; - ev.getByToken( theStereoHits, stereoHits); - if (skipClusters) cleanFrom=result.size(); - auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); - SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second); - for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; - for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); - } + edm::Handle stereoHits; + ev.getByToken(theStereoHits, stereoHits); + if (skipClusters) + cleanFrom = result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide), theIdLayer); + SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second); + for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tidRing(it->detId()); + if (!ringRange(ring)) + continue; + for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); } - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } if (hasVectorHits) { - LogTrace("HitExtractorSTRP")<<"Getting vector hits for IdLayer " << theIdLayer; + LogTrace("HitExtractorSTRP") << "Getting vector hits for IdLayer " << theIdLayer; edm::Handle vectorHits; - ev.getByToken( theVectorHits, vectorHits); + ev.getByToken(theVectorHits, vectorHits); //FIXME: check the skipClusters with VHits - if (skipClusters) cleanFrom=result.size(); - auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); + if (skipClusters) + cleanFrom = result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide), theIdLayer); VectorHitCollection::Range range = vectorHits->equal_range(getter.first, getter.second); for (VectorHitCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; + int ring = tTopo->tidRing(it->detId()); + if (!ringRange(ring)) + continue; for (VectorHitCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { result.emplace_back(*hit); } } - LogTrace("HitExtractorSTRP")<<"result size value:" << result.size(); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + LogTrace("HitExtractorSTRP") << "result size value:" << result.size(); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } } // // TOB // else if (theLayerSubDet == GeomDetEnumerators::TOB) { - LogTrace("HitExtractorSTRP")<<"Getting hits into the TOB"; + LogTrace("HitExtractorSTRP") << "Getting hits into the TOB"; if (hasMatchedHits) { edm::Handle matchedHits; - ev.getByToken( theMatchedHits, matchedHits); - if (skipClusters) cleanFrom=result.size(); - if (minAbsZ>0.) { - auto getter = tTopo->tobDetIdLayerComparator(theIdLayer); - SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); - for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - if (fabs(hit->globalPosition().z())>=minAbsZ) result.emplace_back(*hit); - } - } + ev.getByToken(theMatchedHits, matchedHits); + if (skipClusters) + cleanFrom = result.size(); + if (minAbsZ > 0.) { + auto getter = tTopo->tobDetIdLayerComparator(theIdLayer); + SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); + for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; + ++hit) { + if (fabs(hit->globalPosition().z()) >= minAbsZ) + result.emplace_back(*hit); + } + } } else { - range2SeedingHits( *matchedHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + range2SeedingHits(*matchedHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); } - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,true,cleanFrom); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, true, cleanFrom); } if (hasRPhiHits) { edm::Handle rphiHits; - ev.getByToken( theRPhiHits, rphiHits); - if (hasMatchedHits){ - if (!hasSimpleRphiHitsCleaner){ // this is a brutal "cleaning". Add something smarter in the future - if (skipClusters) cleanFrom=result.size(); - range2SeedingHits( *rphiHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); - } + ev.getByToken(theRPhiHits, rphiHits); + if (hasMatchedHits) { + if (!hasSimpleRphiHitsCleaner) { // this is a brutal "cleaning". Add something smarter in the future + if (skipClusters) + cleanFrom = result.size(); + range2SeedingHits(*rphiHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); + } } else { - if (skipClusters) cleanFrom=result.size(); - range2SeedingHits( *rphiHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + if (skipClusters) + cleanFrom = result.size(); + range2SeedingHits(*rphiHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } } if (hasStereoHits) { edm::Handle stereoHits; - ev.getByToken( theStereoHits, stereoHits); - if (skipClusters) cleanFrom=result.size(); - range2SeedingHits( *stereoHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + ev.getByToken(theStereoHits, stereoHits); + if (skipClusters) + cleanFrom = result.size(); + range2SeedingHits(*stereoHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } if (hasVectorHits) { - LogTrace("HitExtractorSTRP")<<"Getting vector hits for IdLayer " << theIdLayer; + LogTrace("HitExtractorSTRP") << "Getting vector hits for IdLayer " << theIdLayer; edm::Handle vectorHits; - ev.getByToken( theVectorHits, vectorHits); + ev.getByToken(theVectorHits, vectorHits); //FIXME: check the skipClusters with VHits - if (skipClusters) cleanFrom=result.size(); - range2SeedingHits( *vectorHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + if (skipClusters) + cleanFrom = result.size(); + range2SeedingHits(*vectorHits, result, tTopo->tobDetIdLayerComparator(theIdLayer)); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } } @@ -340,70 +408,86 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder // TEC // else if (theLayerSubDet == GeomDetEnumerators::TEC) { - LogTrace("HitExtractorSTRP")<<"Getting hits into the TEC"; + LogTrace("HitExtractorSTRP") << "Getting hits into the TEC"; if (hasMatchedHits) { - edm::Handle matchedHits; - ev.getByToken( theMatchedHits, matchedHits); - if (skipClusters) cleanFrom=result.size(); - auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide),theIdLayer); - SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); - for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tecRing( it->detId() ); if (!ringRange(ring)) continue; - for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); - } + edm::Handle matchedHits; + ev.getByToken(theMatchedHits, matchedHits); + if (skipClusters) + cleanFrom = result.size(); + auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide), theIdLayer); + SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second); + for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tecRing(it->detId()); + if (!ringRange(ring)) + continue; + for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; + ++hit) { + result.emplace_back(*hit); } - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,true,cleanFrom); + } + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, true, cleanFrom); } if (hasRPhiHits) { - edm::Handle rphiHits; - ev.getByToken( theRPhiHits, rphiHits); - if (skipClusters) cleanFrom=result.size(); - auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide),theIdLayer); - SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second); - for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tecRing( it->detId() ); if (!ringRange(ring)) continue; - if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) continue; // this is a brutal "cleaning". Add something smarter in the future - for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); - } + edm::Handle rphiHits; + ev.getByToken(theRPhiHits, rphiHits); + if (skipClusters) + cleanFrom = result.size(); + auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide), theIdLayer); + SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second); + for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tecRing(it->detId()); + if (!ringRange(ring)) + continue; + if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) + continue; // this is a brutal "cleaning". Add something smarter in the future + for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); } - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); - + } + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } if (hasStereoHits) { - edm::Handle stereoHits; - ev.getByToken( theStereoHits, stereoHits); - if (skipClusters) cleanFrom=result.size(); - auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide),theIdLayer); - SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second); - for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tecRing( it->detId() ); if (!ringRange(ring)) continue; - for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); - } + edm::Handle stereoHits; + ev.getByToken(theStereoHits, stereoHits); + if (skipClusters) + cleanFrom = result.size(); + auto getter = tTopo->tecDetIdWheelComparator(static_cast(theSide), theIdLayer); + SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second); + for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) { + int ring = tTopo->tecRing(it->detId()); + if (!ringRange(ring)) + continue; + for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { + result.emplace_back(*hit); } - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + } + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } if (hasVectorHits) { - LogError("HitExtractorSTRP")<<"TEC is not supposed to be in Phase2 TRK detector configuration. What follows have never been checked before! "; + LogError("HitExtractorSTRP") << "TEC is not supposed to be in Phase2 TRK detector configuration. What follows " + "have never been checked before! "; edm::Handle vectorHits; - ev.getByToken( theVectorHits, vectorHits); - if (skipClusters) cleanFrom=result.size(); - auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide),theIdLayer); + ev.getByToken(theVectorHits, vectorHits); + if (skipClusters) + cleanFrom = result.size(); + auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide), theIdLayer); VectorHitCollection::Range range = vectorHits->equal_range(getter.first, getter.second); for (VectorHitCollection::const_iterator it = range.first; it != range.second; ++it) { - int ring = tTopo->tidRing( it->detId() ); if (!ringRange(ring)) continue; + int ring = tTopo->tidRing(it->detId()); + if (!ringRange(ring)) + continue; for (VectorHitCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { result.emplace_back(*hit); } } - if (skipClusters) cleanedOfClusters(ttrhBuilder, ev,result,false,cleanFrom); + if (skipClusters) + cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } } - LogDebug("HitExtractorSTRP")<<" giving: "<(m); } - void useVectorHits(const edm::InputTag & m, edm::ConsumesCollector& iC) { - hasVectorHits = true; - theVectorHits = iC.consumes(m); + void useVectorHits(const edm::InputTag& m, edm::ConsumesCollector& iC) { + hasVectorHits = true; + theVectorHits = iC.consumes(m); } void useRingSelector(int minRing, int maxRing); void useSimpleRphiHitsCleaner(bool use) { hasSimpleRphiHitsCleaner = use; } @@ -78,7 +78,7 @@ namespace ctfseeding { bool ringRange(int ring) const; typedef edm::ContainerMask > SkipClustersCollection; - typedef edm::ContainerMask< Phase2TrackerCluster1DCollectionNew > SkipPhase2ClustersCollection; + typedef edm::ContainerMask SkipPhase2ClustersCollection; void useSkipClusters_(const edm::InputTag& m, edm::ConsumesCollector& iC) override; private: diff --git a/RecoTracker/TransientTrackingRecHit/interface/TkClonerImpl.h b/RecoTracker/TransientTrackingRecHit/interface/TkClonerImpl.h index 35f1c418bcb4f..9fdecece36a57 100644 --- a/RecoTracker/TransientTrackingRecHit/interface/TkClonerImpl.h +++ b/RecoTracker/TransientTrackingRecHit/interface/TkClonerImpl.h @@ -33,7 +33,7 @@ class TkClonerImpl final : public TkCloner { TrajectoryStateOnSurface const& tsos) const override; std::unique_ptr operator()(Phase2TrackerRecHit1D const& hit, TrajectoryStateOnSurface const& tsos) const override; - std::unique_ptr operator()(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const override; + std::unique_ptr operator()(VectorHit const& hit, TrajectoryStateOnSurface const& tsos) const override; using TkCloner::makeShared; TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const& hit, @@ -48,7 +48,8 @@ class TkClonerImpl final : public TkCloner { TrajectoryStateOnSurface const& tsos) const override; TrackingRecHit::ConstRecHitPointer makeShared(Phase2TrackerRecHit1D const& hit, TrajectoryStateOnSurface const& tsos) const override; - TrackingRecHit::ConstRecHitPointer makeShared(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const override; + TrackingRecHit::ConstRecHitPointer makeShared(VectorHit const& hit, + TrajectoryStateOnSurface const& tsos) const override; // project either mono or stero hit... std::unique_ptr project(SiStripMatchedRecHit2D const& hit, bool mono, diff --git a/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc b/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc index 9d729a1a1973e..b35f6a2c4b9d2 100644 --- a/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc +++ b/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc @@ -57,7 +57,7 @@ std::unique_ptr TkClonerImpl::operator()(Phase2TrackerRec return std::make_unique(params.first, params.second, *hit.det(), hit.cluster()); } -std::unique_ptr TkClonerImpl::operator()(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const { +std::unique_ptr TkClonerImpl::operator()(VectorHit const& hit, TrajectoryStateOnSurface const& tsos) const { return std::unique_ptr{new VectorHit(hit)}; } @@ -97,7 +97,8 @@ TrackingRecHit::ConstRecHitPointer TkClonerImpl::makeShared(Phase2TrackerRecHit1 return std::make_unique(params.first, params.second, *hit.det(), hit.cluster()); } -TrackingRecHit::ConstRecHitPointer TkClonerImpl::makeShared(VectorHit const & hit, TrajectoryStateOnSurface const& tsos) const { +TrackingRecHit::ConstRecHitPointer TkClonerImpl::makeShared(VectorHit const& hit, + TrajectoryStateOnSurface const& tsos) const { return std::make_shared(hit); } From 09136ad90ad80dc611c09cf5a3e9c6897c246dc8 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 2 Oct 2019 01:45:07 +0200 Subject: [PATCH 004/115] address Iannas comments part 1 --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 11 --- .../TrackerRecHit2D/src/classes_def.xml | 1 - .../python/RecoLocalTracker_cff.py | 1 - .../interface/VectorHitBuilderEDProducer.h | 18 +++-- .../plugins/SealModules.cc | 2 - .../SiPhase2RecHitMatcherESProducer.cc | 57 +++++++++++++- .../plugins/SiPhase2RecHitMatcherESProducer.h | 20 ----- .../python/SiPhase2RecHitMatcher_cfi.py | 17 ----- .../python/SiPhase2VectorHitBuilder_cfi.py | 12 --- .../src/VectorHitBuilderEDProducer.cc | 76 +++++++++++++------ 10 files changed, 116 insertions(+), 99 deletions(-) delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 307d2afae51d7..e7e163857e7a8 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -36,8 +36,6 @@ VectorHit::VectorHit(const GeomDet& idet, thePosition = LocalPoint(vh2Dzx.localPosition().x(), vh2Dzy.localPosition().x(), 0.); theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), 1.); - //theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), vh2Dzy.localDirection().z()); - //theDirection = theDirection.unit(); //building the cov matrix 4x4 starting from the 2x2 AlgebraicSymMatrix22 covMatZX = vh2Dzx.covMatrix(); @@ -82,7 +80,6 @@ bool VectorHit::sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedI } void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const { - //if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents"); AlgebraicVector4& pars = holder.params<4>(); pars[0] = theDirection.x(); pars[1] = theDirection.y(); @@ -229,8 +226,6 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const double ytg = -(gPositionLower.x() - xcentre); //to compute phi at the origin - //double xtg = ycentre; - //double ytg = -(xcentre); phi = atan2(ytg, xtg); AlgebraicROOTObject<4, 4>::Matrix jacobian; @@ -268,10 +263,6 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const M[0] = (gPositionLower.y() - ycentre) / pow(rho, 2); // dphi/dxcentre M[1] = -(gPositionLower.x() - xcentre) / pow(rho, 2); // dphi/dycentre //to compute phi at the origin - //float x0 = 0.0; - //float y0 = 0.0; - //M[0] = (y0 - ycentre)/pow(rho,2); // dphi/dxcentre - //M[1] =-(x0 - xcentre)/pow(rho,2); // dphi/dycentre AlgebraicROOTObject<2, 4>::Matrix K; K[0][0] = @@ -342,8 +333,6 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const temp = temp * gErrors; errorCurvature = temp[0] * curvatureJacobian[0] + temp[1] * curvatureJacobian[1] + temp[2] * curvatureJacobian[2] + temp[3] * curvatureJacobian[3]; - //if(curvORphi == "curvature") std::cout << "curvature: " << curvature << std::endl; - //if(curvORphi == "curvature") std::cout << "curvature error: " << errorCurvature << std::endl; } else { std::cout << " straight line!" << std::endl; diff --git a/DataFormats/TrackerRecHit2D/src/classes_def.xml b/DataFormats/TrackerRecHit2D/src/classes_def.xml index e5527c17265f3..d10e52aaa4d6d 100644 --- a/DataFormats/TrackerRecHit2D/src/classes_def.xml +++ b/DataFormats/TrackerRecHit2D/src/classes_def.xml @@ -196,7 +196,6 @@ - diff --git a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py index 06ebb798faca2..4d25967bd803f 100644 --- a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py +++ b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py @@ -23,7 +23,6 @@ from RecoLocalTracker.SiPhase2Clusterizer.phase2TrackerClusterizer_cfi import * from RecoLocalTracker.Phase2TrackerRecHits.Phase2StripCPEGeometricESProducer_cfi import * -from RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2RecHitMatcher_cfi import * _pixeltrackerlocalrecoTask_phase2 = pixeltrackerlocalrecoTask.copy() _pixeltrackerlocalrecoTask_phase2.add(siPhase2Clusters) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h index 24ccbf93a3d5f..be5ae1ee0f4fd 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h @@ -13,6 +13,9 @@ #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include +#include + class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { public: explicit VectorHitBuilderEDProducer(const edm::ParameterSet&); @@ -24,15 +27,16 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { edmNew::DetSetVector& clustersRej, VectorHitCollectionNew& outputAcc, VectorHitCollectionNew& outputRej); - VectorHitBuilderAlgorithmBase* algo() const { return stubsBuilder; }; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + VectorHitBuilderAlgorithmBase* algo() const { return stubsBuilder_; }; private: - VectorHitBuilderAlgorithmBase* stubsBuilder; - std::string offlinestubsTag; - unsigned int maxOfflinestubs; - std::string algoTag; - edm::EDGetTokenT > clusterProducer; - bool readytobuild; + VectorHitBuilderAlgorithmBase* stubsBuilder_; + std::string offlinestubsTag_; + unsigned int maxOfflinestubs_; + std::string algoTag_; + edm::EDGetTokenT > clusterProducer_; + bool readytobuild_; }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc index 9906f689a4d7f..784c27e17a331 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc @@ -4,7 +4,5 @@ #include "FWCore/Framework/interface/ModuleFactory.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h" -DEFINE_FWK_EVENTSETUP_MODULE(SiPhase2RecHitMatcherESProducer); DEFINE_FWK_MODULE(VectorHitBuilderEDProducer); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 73993fdb3eaed..66d5528781366 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -1,4 +1,3 @@ -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -6,15 +5,32 @@ #include "FWCore/Framework/interface/ESProducer.h" #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" +#include + +class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { +public: + SiPhase2RecHitMatcherESProducer(const edm::ParameterSet&); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + std::shared_ptr produce(const TkPhase2OTCPERecord&); + +private: + std::string name_; + std::shared_ptr matcher_; + edm::ParameterSet pset_; +}; + SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet& p) { - name = p.getParameter("ComponentName"); + name_ = p.getParameter("ComponentName"); pset_ = p; - setWhatProduced(this, name); + setWhatProduced(this, name_); } std::shared_ptr SiPhase2RecHitMatcherESProducer::produce( const TkPhase2OTCPERecord& iRecord) { - if (name == "SiPhase2VectorHitMatcher") { + if (name_ == "SiPhase2VectorHitMatcher") { matcher_ = std::make_shared(pset_); edm::ESHandle tGeomHandle; @@ -28,3 +44,36 @@ std::shared_ptr SiPhase2RecHitMatcherESProducer::pro } return matcher_; } + +void +SiPhase2RecHitMatcherESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("offlinestubs", "vectorHits"); + desc.add("maxVectorHits", 999999999); + desc.add("Algorithm", "VectorHitBuilderAlgorithm"); + desc.add("ComponentName", "SiPhase2VectorHitMatcher"); + desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer","Phase2StripCPE")); + desc.add>("BarrelCut", { + 0.0, + 0.05, + 0.06, + 0.08, + 0.09, + 0.12, + 0.2, + }); + desc.add("Phase2CPE_name", "Phase2StripCPE"); + desc.add("Clusters", "siPhase2Clusters"); + desc.add("maxVectorHitsInAStack", 999); + desc.add>("EndcapCut", { + 0.0, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + }); + descriptions.add("SiPhase2RecHitMatcherESProducer", desc); +} + +DEFINE_FWK_EVENTSETUP_MODULE(SiPhase2RecHitMatcherESProducer); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h deleted file mode 100644 index be680a93c7c5e..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef RecoLocaltracker_SiPhase2VectorHitBuilder_SiPhase2RecHitMatcherESProducer_h -#define RecoLocaltracker_SiPhase2VectorHitBuilder_SiPhase2RecHitMatcherESProducer_h - -#include "FWCore/Framework/interface/ESProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" -#include - -class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { -public: - SiPhase2RecHitMatcherESProducer(const edm::ParameterSet&); - std::shared_ptr produce(const TkPhase2OTCPERecord&); - -private: - std::string name; - std::shared_ptr matcher_; - edm::ParameterSet pset_; -}; -#endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py deleted file mode 100644 index 0780d27ef4258..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py +++ /dev/null @@ -1,17 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -SiPhase2RecHitMatcherESProducer = cms.ESProducer("SiPhase2RecHitMatcherESProducer", - ComponentName = cms.string('SiPhase2VectorHitMatcher'), - Clusters = cms.string('siPhase2Clusters'), - offlinestubs = cms.string('vectorHits'), - maxVectorHits = cms.int32(999999999), - maxVectorHitsInAStack = cms.int32(999), - Algorithm = cms.string('VectorHitBuilderAlgorithm'), - BarrelCut = cms.vdouble( 0., 0.05, 0.06, 0.08, 0.09, 0.12, 0.2), #layers are 6 - EndcapCut = cms.vdouble( 0., 0.1, 0.1, 0.1, 0.1, 0.1), #disks are 5 - CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE"), - Phase2CPE_name = cms.string('Phase2StripCPE') -# NSigmaInside = cms.double(3.0) -) - - diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py deleted file mode 100644 index 7949489ba3da8..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py +++ /dev/null @@ -1,12 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -siPhase2VectorHits = cms.EDProducer("VectorHitBuilderEDProducer", - Clusters = cms.string('siPhase2Clusters'), - offlinestubs = cms.string('vectorHits'), - maxVectorHits = cms.int32(999999999), - maxVectorHitsInAStack = cms.int32(999), - Algorithm = cms.string('VectorHitBuilderAlgorithm'), - BarrelCut = cms.vdouble( 0., 0.05, 0.06, 0.08, 0.09, 0.12, 0.2), #layers are 6 - EndcapCut = cms.vdouble( 0., 0.1, 0.1, 0.1, 0.1, 0.1), #disks are 5 - CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE") -) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc index a47ae33526242..0fabf89f2187b 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc @@ -4,29 +4,29 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) - : offlinestubsTag(conf.getParameter("offlinestubs")), - maxOfflinestubs(conf.getParameter("maxVectorHits")), - algoTag(conf.getParameter("Algorithm")), - //clusterProducer(conf.getParameter("Clusters")), - readytobuild(false) { - clusterProducer = consumes >( + : offlinestubsTag_(conf.getParameter("offlinestubs")), + maxOfflinestubs_(conf.getParameter("maxVectorHits")), + algoTag_(conf.getParameter("Algorithm")), + //_clusterProducer(conf.getParameter("Clusters")), + readytobuild_(false) { + clusterProducer_ = consumes >( edm::InputTag(conf.getParameter("Clusters"))); produces >("ClustersAccepted"); produces >("ClustersRejected"); - produces(offlinestubsTag + "Accepted"); - produces(offlinestubsTag + "Rejected"); + produces(offlinestubsTag_ + "Accepted"); + produces(offlinestubsTag_ + "Rejected"); setupAlgorithm(conf); } -VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder; } +VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; } void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { LogDebug("VectorHitBuilderEDProducer") << "VectorHitBuilderEDProducer::produce() begin"; // get input clusters data edm::Handle > clustersHandle; - event.getByToken(clusterProducer, clustersHandle); + event.getByToken(clusterProducer_, clustersHandle); // create the final output collection std::unique_ptr > outputClustersAccepted( @@ -36,13 +36,13 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu std::unique_ptr outputVHAccepted(new VectorHitCollectionNew()); std::unique_ptr outputVHRejected(new VectorHitCollectionNew()); - if (readytobuild) - stubsBuilder->initialize(es); + if (readytobuild_) + stubsBuilder_->initialize(es); else edm::LogError("VectorHitBuilderEDProducer") << "Impossible initialization of builder!!"; // check on the input clusters - stubsBuilder->printClusters(*clustersHandle); + stubsBuilder_->printClusters(*clustersHandle); // running the stub building algorithm //ERICA::output should be moved in the different algo classes? @@ -58,7 +58,7 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu } } /* - if(numberOfVectorHits > maxOfflinestubs) { + if(numberOfVectorHits > _maxOfflinestubs) { edm::LogError("VectorHitBuilderEDProducer") << "Limit on the number of stubs exceeded. An empty output collection will be produced instead.\n"; VectorHitCollectionNew empty; empty.swap(outputAcc); @@ -67,20 +67,20 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu // write output to file event.put(std::move(outputClustersAccepted), "ClustersAccepted"); event.put(std::move(outputClustersRejected), "ClustersRejected"); - event.put(std::move(outputVHAccepted), offlinestubsTag + "Accepted"); - event.put(std::move(outputVHRejected), offlinestubsTag + "Rejected"); + event.put(std::move(outputVHAccepted), offlinestubsTag_ + "Accepted"); + event.put(std::move(outputVHRejected), offlinestubsTag_ + "Rejected"); - // LogDebug("VectorHitBuilderEDProducer") << " Executing " << algoTag << " resulted in " << numberOfVectorHits << "."; + // LogDebug("VectorHitBuilderEDProducer") << " Executing " << _algoTag << " resulted in " << numberOfVectorHits << "."; LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n"; } void VectorHitBuilderEDProducer::setupAlgorithm(edm::ParameterSet const& conf) { - if (algoTag == "VectorHitBuilderAlgorithm") { - stubsBuilder = new VectorHitBuilderAlgorithm(conf); - readytobuild = true; + if (algoTag_ == "VectorHitBuilderAlgorithm") { + stubsBuilder_ = new VectorHitBuilderAlgorithm(conf); + readytobuild_ = true; } else { - edm::LogError("VectorHitBuilderEDProducer") << " Choice " << algoTag << " is invalid.\n"; - readytobuild = false; + edm::LogError("VectorHitBuilderEDProducer") << " Choice " << algoTag_ << " is invalid.\n"; + readytobuild_ = false; } } @@ -89,12 +89,40 @@ void VectorHitBuilderEDProducer::run(edm::Handle& clustersRej, VectorHitCollectionNew& outputAcc, VectorHitCollectionNew& outputRej) { - if (!readytobuild) { + if (!readytobuild_) { edm::LogError("VectorHitBuilderEDProducer") << " No stub builder algorithm was found - cannot run!"; return; } - stubsBuilder->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej); + stubsBuilder_->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej); +} +void +VectorHitBuilderEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("offlinestubs", "vectorHits"); + desc.add("maxVectorHits", 999999999); + desc.add("Algorithm", "VectorHitBuilderAlgorithm"); + desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer","Phase2StripCPE")); + desc.add>("BarrelCut", { + 0.0, + 0.05, + 0.06, + 0.08, + 0.09, + 0.12, + 0.2, + }); + desc.add("Clusters", "siPhase2Clusters"); + desc.add("maxVectorHitsInAStack", 999); + desc.add>("EndcapCut", { + 0.0, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + }); + descriptions.add("siPhase2VectorHits", desc); } #include "FWCore/Utilities/interface/typelookup.h" From e0a73fd8657a52c9b47d9c5ebf401463bc236f39 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 2 Oct 2019 02:06:42 +0200 Subject: [PATCH 005/115] code checks --- .../SiPhase2RecHitMatcherESProducer.cc | 41 ++++++------- .../src/VectorHitBuilderEDProducer.cc | 57 ++++++++++--------- 2 files changed, 50 insertions(+), 48 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 66d5528781366..154c88423ad64 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -45,34 +45,35 @@ std::shared_ptr SiPhase2RecHitMatcherESProducer::pro return matcher_; } -void -SiPhase2RecHitMatcherESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void SiPhase2RecHitMatcherESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("offlinestubs", "vectorHits"); desc.add("maxVectorHits", 999999999); desc.add("Algorithm", "VectorHitBuilderAlgorithm"); desc.add("ComponentName", "SiPhase2VectorHitMatcher"); - desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer","Phase2StripCPE")); - desc.add>("BarrelCut", { - 0.0, - 0.05, - 0.06, - 0.08, - 0.09, - 0.12, - 0.2, - }); + desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); + desc.add>("BarrelCut", + { + 0.0, + 0.05, + 0.06, + 0.08, + 0.09, + 0.12, + 0.2, + }); desc.add("Phase2CPE_name", "Phase2StripCPE"); desc.add("Clusters", "siPhase2Clusters"); desc.add("maxVectorHitsInAStack", 999); - desc.add>("EndcapCut", { - 0.0, - 0.1, - 0.1, - 0.1, - 0.1, - 0.1, - }); + desc.add>("EndcapCut", + { + 0.0, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + }); descriptions.add("SiPhase2RecHitMatcherESProducer", desc); } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc index 0fabf89f2187b..0f8ce6b7fac77 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc @@ -9,11 +9,11 @@ VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& algoTag_(conf.getParameter("Algorithm")), //_clusterProducer(conf.getParameter("Clusters")), readytobuild_(false) { - clusterProducer_ = consumes >( - edm::InputTag(conf.getParameter("Clusters"))); + clusterProducer_ = + consumes>(edm::InputTag(conf.getParameter("Clusters"))); - produces >("ClustersAccepted"); - produces >("ClustersRejected"); + produces>("ClustersAccepted"); + produces>("ClustersRejected"); produces(offlinestubsTag_ + "Accepted"); produces(offlinestubsTag_ + "Rejected"); setupAlgorithm(conf); @@ -25,13 +25,13 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu LogDebug("VectorHitBuilderEDProducer") << "VectorHitBuilderEDProducer::produce() begin"; // get input clusters data - edm::Handle > clustersHandle; + edm::Handle> clustersHandle; event.getByToken(clusterProducer_, clustersHandle); // create the final output collection - std::unique_ptr > outputClustersAccepted( + std::unique_ptr> outputClustersAccepted( new edmNew::DetSetVector); - std::unique_ptr > outputClustersRejected( + std::unique_ptr> outputClustersRejected( new edmNew::DetSetVector); std::unique_ptr outputVHAccepted(new VectorHitCollectionNew()); std::unique_ptr outputVHRejected(new VectorHitCollectionNew()); @@ -84,7 +84,7 @@ void VectorHitBuilderEDProducer::setupAlgorithm(edm::ParameterSet const& conf) { } } -void VectorHitBuilderEDProducer::run(edm::Handle > clusters, +void VectorHitBuilderEDProducer::run(edm::Handle> clusters, edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, VectorHitCollectionNew& outputAcc, @@ -96,32 +96,33 @@ void VectorHitBuilderEDProducer::run(edm::Handlerun(clusters, outputAcc, outputRej, clustersAcc, clustersRej); } -void -VectorHitBuilderEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void VectorHitBuilderEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("offlinestubs", "vectorHits"); desc.add("maxVectorHits", 999999999); desc.add("Algorithm", "VectorHitBuilderAlgorithm"); - desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer","Phase2StripCPE")); - desc.add>("BarrelCut", { - 0.0, - 0.05, - 0.06, - 0.08, - 0.09, - 0.12, - 0.2, - }); + desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); + desc.add>("BarrelCut", + { + 0.0, + 0.05, + 0.06, + 0.08, + 0.09, + 0.12, + 0.2, + }); desc.add("Clusters", "siPhase2Clusters"); desc.add("maxVectorHitsInAStack", 999); - desc.add>("EndcapCut", { - 0.0, - 0.1, - 0.1, - 0.1, - 0.1, - 0.1, - }); + desc.add>("EndcapCut", + { + 0.0, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + }); descriptions.add("siPhase2VectorHits", desc); } From 3e0523b5537e2d2833df6e784d307583c708a3af Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 2 Oct 2019 02:15:04 +0200 Subject: [PATCH 006/115] set usePhase2Stacks to false by default in the fillDescription of TrackerRecoGeometryESProducer --- .../GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc index d3e89db5e9ec2..c3ba3660e7431 100644 --- a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc +++ b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc @@ -58,7 +58,7 @@ std::unique_ptr TrackerRecoGeometryESProducer::produce( void TrackerRecoGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.add("usePhase2Stacks"); + desc.add("usePhase2Stacks",false); desc.addUntracked("trackerGeometryLabel", ""); descriptions.addDefault(desc); } From 00ad9bb6a0663c87ce09e1fba11cdda3a39b265a Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 2 Oct 2019 17:39:08 +0200 Subject: [PATCH 007/115] try to fix header issues and fix missing import broken by the last commit --- DataFormats/TrackerRecHit2D/interface/VectorHit2D.h | 1 + DataFormats/TrackerRecHit2D/src/VectorHit.cc | 2 +- RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index 7bc0d8eb1c098..2ed4c5fd9b911 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -3,6 +3,7 @@ #include "DataFormats/GeometryVector/interface/LocalVector.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" +#include "DataFormats/CLHEP/interface/AlgebraicObjects.h" class VectorHit2D { public: diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index e7e163857e7a8..2f915c6f6187f 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -361,7 +361,7 @@ float VectorHit::theta() { return globalDirection().theta(); } AlgebraicMatrix VectorHit::projectionMatrix() const { // obsolete (for what tracker is concerned...) interface - static AlgebraicMatrix the4DProjectionMatrix(4, 5, 0); + static const AlgebraicMatrix the4DProjectionMatrix(4, 5, 0); return the4DProjectionMatrix; } diff --git a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py index 4d25967bd803f..06ebb798faca2 100644 --- a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py +++ b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py @@ -23,6 +23,7 @@ from RecoLocalTracker.SiPhase2Clusterizer.phase2TrackerClusterizer_cfi import * from RecoLocalTracker.Phase2TrackerRecHits.Phase2StripCPEGeometricESProducer_cfi import * +from RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2RecHitMatcher_cfi import * _pixeltrackerlocalrecoTask_phase2 = pixeltrackerlocalrecoTask.copy() _pixeltrackerlocalrecoTask_phase2.add(siPhase2Clusters) From e652383db425917262926ac0b2a781343cafab7a Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 2 Oct 2019 17:48:44 +0200 Subject: [PATCH 008/115] code checkes --- .../GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc index c3ba3660e7431..52a299f1eb172 100644 --- a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc +++ b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc @@ -58,7 +58,7 @@ std::unique_ptr TrackerRecoGeometryESProducer::produce( void TrackerRecoGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.add("usePhase2Stacks",false); + desc.add("usePhase2Stacks", false); desc.addUntracked("trackerGeometryLabel", ""); descriptions.addDefault(desc); } From 5ad296d1abf299d2148b2048dfb700de19ad9599 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 2 Oct 2019 18:24:27 +0200 Subject: [PATCH 009/115] restructure code in VectorHit.cc to satisfy static analyzer --- .../src/TrackerGeomBuilderFromGeometricDet.cc | 2 +- .../src/SeedingOTEDProducer.cc | 26 +++++++------------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc b/Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc index 67b76c66427ee..ccd079e61e6ea 100644 --- a/Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc +++ b/Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc @@ -256,7 +256,7 @@ void TrackerGeomBuilderFromGeometricDet::buildGeomDet(TrackerGeometry* tracker) tracker->addDetId(composedDetId); } else if (gduTypeName.find("Lower") != std::string::npos) { - //FIXME::ERICA: the plane builder is built in the middle... + //The plane is *not* built in the middle, but on the Lower surface Plane* plane = new Plane(dus->surface()); composedDetId = theTopo->stack(gduId[i]); StackGeomDet* stackDet = new StackGeomDet(&(*plane), dus, dum, composedDetId); diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index d048057a51a17..829f3bcc14d21 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -321,36 +321,30 @@ void SeedingOTEDProducer::printVHsOnLayer(edm::Handle VH } const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& vHit) { + + // having fun with theta + Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); + float theta = gv.theta(); + // gv transform to local (lv) + const Local3DVector lv(vHit.det()->surface().toLocal(gv)); + //FIXME::charge is fine 1 every two times!! int charge = 1; - //float pT = vHit.transverseMomentum(magField); float p = vHit.momentum(magField); float x = vHit.localPosition().x(); float y = vHit.localPosition().y(); float dx = vHit.localDirection().x(); - float dy = vHit.localDirection().y(); + // for dy use second component of the lv renormalized to the z component + float dy = lv.y() / lv.z(); + // Pz and Dz should have the same sign float signPz = copysign(1.0, vHit.globalPosition().z()); - // having fun with theta - Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); - float theta = gv.theta(); - //std::cout << "\tgv : " << gv << std::endl; - //std::cout << "\tgv theta : " << theta << std::endl; - //std::cout << "\tgv theta error : " << computeGlobalThetaError(vHit, beamSpot->sigmaZ()) << std::endl; - //std::cout << "\tgv eta : " << gv.eta() << std::endl; - // gv transform to local (lv) - const Local3DVector lv(vHit.det()->surface().toLocal(gv)); - //std::cout << "\tlv : " << lv << std::endl; - // replace dy with second component of the lv renormalized to the z component - dy = lv.y() / lv.z(); LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p mat[0][0] = pow(computeInverseMomentumError(vHit, theta, magField, beamSpot->sigmaZ()), 2); - //std::cout << "\tltraj : " << charge << "," << 1./p <<","<< dx <<","<< dy <<","<< x <<","<< y <<","<< signPz << std::endl; - //std::cout << "\tmat : " << mat << std::endl; //building tsos LocalTrajectoryError lterr(asSMatrix<5>(mat)); From 05858c25a5f26a188bd8ca45c9f2b70de6670e8f Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 2 Oct 2019 20:37:18 +0200 Subject: [PATCH 010/115] code format --- RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 829f3bcc14d21..cecbbfe9a2393 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -321,7 +321,6 @@ void SeedingOTEDProducer::printVHsOnLayer(edm::Handle VH } const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& vHit) { - // having fun with theta Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); float theta = gv.theta(); @@ -340,7 +339,6 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& // Pz and Dz should have the same sign float signPz = copysign(1.0, vHit.globalPosition().z()); - LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p From 0ffda002e3337cc4bbba70718d000c692a2d716c Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Thu, 3 Oct 2019 21:30:08 +0200 Subject: [PATCH 011/115] fix most of the issues making the tests fail --- DataFormats/TrackerRecHit2D/interface/VectorHit2D.h | 1 + .../python/SiPhase2RecHitMatcher_cfi.py | 4 ++++ .../python/SiPhase2VectorHitBuilder_cfi.py | 4 ++++ RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index 2ed4c5fd9b911..2ae8a3893ab28 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -4,6 +4,7 @@ #include "DataFormats/GeometryVector/interface/LocalVector.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" #include "DataFormats/CLHEP/interface/AlgebraicObjects.h" +#include "DataFormats/GeometrySurface/interface/LocalError.h" class VectorHit2D { public: diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py new file mode 100644 index 0000000000000..b10e94e6c8b96 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +SiPhase2RecHitMatcherESProducer = cms.ESProducer("SiPhase2RecHitMatcherESProducer", +) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py new file mode 100644 index 0000000000000..d885267371172 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +siPhase2VectorHits = cms.EDProducer("VectorHitBuilderEDProducer", +) diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc index 8c6b86fa37d87..f8b9ede21b188 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc @@ -42,5 +42,5 @@ void PxMeasurementConditionSet::init(int size) { void Phase2OTMeasurementConditionSet::init(int size) { activeThisPeriod_.resize(size, true); id_.resize(size); - matcher()->algo()->initCpe(cpe()); + if (size > 0) matcher()->algo()->initCpe(cpe()); } From 7c1b91110b9533e3875176ded97acb83d990b9cf Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Thu, 3 Oct 2019 21:59:47 +0200 Subject: [PATCH 012/115] code checks --- RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc index f8b9ede21b188..ca70930c5e707 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc @@ -42,5 +42,6 @@ void PxMeasurementConditionSet::init(int size) { void Phase2OTMeasurementConditionSet::init(int size) { activeThisPeriod_.resize(size, true); id_.resize(size); - if (size > 0) matcher()->algo()->initCpe(cpe()); + if (size > 0) + matcher()->algo()->initCpe(cpe()); } From 872a25c335f4ed4ee7b67ddf90fe310a2cb9ecc0 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 9 Oct 2019 01:16:12 +0200 Subject: [PATCH 013/115] apply comments by andrea --- CommonTools/RecoAlgos/src/ClusterStorer.cc | 1 - .../TrackerRecHit2D/interface/VectorHit2D.h | 4 +- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 32 +++-- .../TrackerRecHit2D/src/classes_def.xml | 4 +- .../test/ClustersValidationTGraph.cc | 7 -- .../plugins/TkStackMeasurementDet.cc | 4 +- .../MeasurementDet/src/TkMeasurementDetSet.h | 2 - .../src/SeedingOTEDProducer.cc | 119 +----------------- .../plugins/QuickTrackAssociatorByHitsImpl.cc | 7 -- 9 files changed, 22 insertions(+), 158 deletions(-) diff --git a/CommonTools/RecoAlgos/src/ClusterStorer.cc b/CommonTools/RecoAlgos/src/ClusterStorer.cc index e015446c7d5be..760be3efc6c0b 100644 --- a/CommonTools/RecoAlgos/src/ClusterStorer.cc +++ b/CommonTools/RecoAlgos/src/ClusterStorer.cc @@ -45,7 +45,6 @@ namespace helper { } else if (hit_type == typeid(Phase2TrackerRecHit1D)) { //FIXME:: this is just temporary solution for phase2, //it is not really running in the phase2 tracking wf - yet... - //std::cout << "| It is a Phase2TrackerRecHit1D hit !!" << std::endl; phase2OTClusterRecords_.push_back( Phase2OTClusterHitRecord(static_cast(newHit), hits, index)); } else if (hit_type == typeid(VectorHit)) { diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index 2ae8a3893ab28..88cea12308bf7 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -1,5 +1,5 @@ -#ifndef TrackingRecHit_VectorHit2D_h -#define TrackingRecHit_VectorHit2D_h +#ifndef TrackerRecHit2D_VectorHit2D_h +#define TrackerRecHit2D_VectorHit2D_h #include "DataFormats/GeometryVector/interface/LocalVector.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 2f915c6f6187f..32f71c58baf1c 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -214,8 +214,8 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const pow(gPositionLower.y(), 2) * gPositionUpper.y() - gPositionLower.y() * pow(gPositionUpper.y(), 2); //radius of circle - double rho = sqrt(r12 * r22 * h3) / (2. * h1); - curvature = 1. / rho; + double invRho2 = (2. * h1)/(r12 * r22 * h3); + curvature = sqrt(invRho2); //center of circle double xcentre = h5 / h2; @@ -234,25 +234,22 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const jacobian[i][j] = 0.0; } } - + double denom1 = 1./sqrt(r12 * r22 * h3); + double denom2 = 1./(pow(r12 * r22 * h3, 1.5)); jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 jacobian[2][0] = - (h1 * (2. * gPositionLower.x() * r22 * h3 + (2. * gPositionLower.x() - 2. * gPositionUpper.x()) * r12 * r22)) / - (pow(r12 * r22 * h3, 1.5)) - - (2. * gPositionUpper.y()) / sqrt(r12 * r22 * h3); // dkappa/dx1 + (h1 * (2. * gPositionLower.x() * r22 * h3 + (2. * gPositionLower.x() - 2. * gPositionUpper.x()) * r12 * r22)) * denom2 - + (2. * gPositionUpper.y()) * denom1; // dkappa/dx1 jacobian[2][1] = - (2. * gPositionUpper.x()) / sqrt(r12 * r22 * h3) + - (h1 * (2. * gPositionLower.y() * r22 * h3 + r12 * r22 * (2. * gPositionLower.y() - 2. * gPositionUpper.y()))) / - pow(r12 * r22 * h3, 1.5); // dkappa/dy1 + (2. * gPositionUpper.x()) * denom1 + + (h1 * (2. * gPositionLower.y() * r22 * h3 + r12 * r22 * (2. * gPositionLower.y() - 2. * gPositionUpper.y()))) * denom2; // dkappa/dy1 jacobian[2][2] = - (2. * gPositionLower.y()) / sqrt(r12 * r22 * h3) + - (h1 * (2. * gPositionUpper.x() * r12 * h3 - 2. * (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) / - pow(r12 * r22 * h3, 1.5); // dkappa/dx2 + (2. * gPositionLower.y()) * denom1 + + (h1 * (2. * gPositionUpper.x() * r12 * h3 - 2. * (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2; // dkappa/dx2 jacobian[2][3] = - (h1 * (2. * gPositionUpper.y() * r12 * h3 - r12 * r22 * 2. * (gPositionLower.y() - gPositionUpper.y()))) / - pow(r12 * r22 * h3, 1.5) - - (2. * gPositionLower.x()) / sqrt(r12 * r22 * h3); // dkappa/dy2 + (h1 * (2. * gPositionUpper.y() * r12 * h3 - r12 * r22 * 2. * (gPositionLower.y() - gPositionUpper.y()))) * denom2 - + (2. * gPositionLower.x()) * denom1; // dkappa/dy2 for (int i = 0; i < 4; i++) { jacobian[2][i] = -jacobian[2][i]; @@ -260,8 +257,8 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const AlgebraicVector2 M; //to compute phi at the cluster points - M[0] = (gPositionLower.y() - ycentre) / pow(rho, 2); // dphi/dxcentre - M[1] = -(gPositionLower.x() - xcentre) / pow(rho, 2); // dphi/dycentre + M[0] = (gPositionLower.y() - ycentre) * invRho2; // dphi/dxcentre + M[1] = -(gPositionLower.x() - xcentre) * invRho2; // dphi/dycentre //to compute phi at the origin AlgebraicROOTObject<2, 4>::Matrix K; @@ -335,7 +332,6 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const temp[3] * curvatureJacobian[3]; } else { - std::cout << " straight line!" << std::endl; return std::make_pair(0.0, 0.0); } diff --git a/DataFormats/TrackerRecHit2D/src/classes_def.xml b/DataFormats/TrackerRecHit2D/src/classes_def.xml index d10e52aaa4d6d..87a581c22987b 100644 --- a/DataFormats/TrackerRecHit2D/src/classes_def.xml +++ b/DataFormats/TrackerRecHit2D/src/classes_def.xml @@ -192,8 +192,8 @@ - - + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc index 3a31e39b56183..9f34cc8bbb199 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc @@ -261,13 +261,11 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, x_local = localPosClu.x(); y_local = localPosClu.y(); z_local = localPosClu.z(); - std::cout << localPosClu << std::endl; Global3DPoint globalPosClu = geomDetUnit->surface().toGlobal(localPosClu); x_global = globalPosClu.x(); y_global = globalPosClu.y(); z_global = globalPosClu.z(); - //std::cout << globalPosClu << std::endl; // Fill the position histograms trackerLayout_[0]->SetPoint(nClustersTot, globalPosClu.z(), globalPosClu.perp()); @@ -318,12 +316,7 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, ->column())); // Here we have to use the old pixelToChannel function (not Phase2TrackerDigi but PixelDigi), change this when using new Digis unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detId, channel)); clusterSimTrackIds.push_back(simTrackId); - std::cout << channel << std::endl; - std::cout << simTrackId << std::endl; - std::cout << std::endl; } - unsigned int InnerChannel = clustIt->firstDigi().channel(); - std::cout << InnerChannel << std::endl; /* // SimHits related variables diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index e54e929f97224..eca45f74b3fc0 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -27,10 +27,10 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj HitCollectorForRecHits collector( &fastGeomDet(), theMatcher, theCPE, result ); collectRecHits(ts, collector); */ - if (isEmpty(data.phase2OTData()) == true) + if (isEmpty(data.phase2OTData())) return result; LogTrace("MeasurementTracker") << " is not empty"; - if (isActive(data) == false) + if (!isActive(data)) return result; LogTrace("MeasurementTracker") << " and is active"; diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h index 2a2fc822a318c..58189318ec154 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h @@ -6,7 +6,6 @@ class TkStripMeasurementDet; class TkStripMeasurementDet; class TkPixelMeasurementDet; class SiStripRecHitMatcher; -//class VectorHitBuilderEDProducer; class StripClusterParameterEstimator; class PixelClusterParameterEstimator; class Phase2StripCPE; @@ -21,7 +20,6 @@ class Phase2StripCPE; #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h" #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" #include diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index cecbbfe9a2393..ad44f8df5fdcc 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -37,7 +37,6 @@ void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descr } void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { - std::cout << "SeedingOT::produce() begin" << std::endl; std::unique_ptr seedsWithVHs(new TrajectorySeedCollection()); edm::ESHandle tTopoHandle; @@ -71,7 +70,6 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) edm::Handle beamSpotH; event.getByToken(beamSpotToken, beamSpotH); if (beamSpotH.isValid()) { - std::cout << "BeamSpot Position: " << *(beamSpotH.product()); beamSpot = beamSpotH.product(); } @@ -91,35 +89,21 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) seedsWithVHs->shrink_to_fit(); event.put(std::move(seedsWithVHs)); - std::cout << "SeedingOT::produce() end" << std::endl; } TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { TrajectorySeedCollection result; - std::cout << "-----------------------------" << std::endl; - printVHsOnLayer(VHs, 1); - printVHsOnLayer(VHs, 2); - printVHsOnLayer(VHs, 3); - printVHsOnLayer(VHs, 4); - printVHsOnLayer(VHs, 5); - printVHsOnLayer(VHs, 6); - std::cout << "-----------------------------" << std::endl; - //check if all the first three layers have VHs std::vector VHseedsL1 = collectVHsOnLayer(VHs, 1); std::vector VHseedsL2 = collectVHsOnLayer(VHs, 2); std::vector VHseedsL3 = collectVHsOnLayer(VHs, 3); if (VHseedsL1.empty() || VHseedsL2.empty() || VHseedsL3.empty()) { - std::cout << "------- seeds found: " << result.size() << " ------" << std::endl; - std::cout << "- L1 or L2 or L3 are empty! -" << std::endl; - std::cout << "-----------------------------" << std::endl; return result; } //seeds are built in the L3 of the OT const BarrelDetLayer* barrelOTLayer2 = measurementTracker->geometricSearchTracker()->tobLayers().at(1); - std::cout << "VH seeds = " << VHseedsL3.size() << std::endl; //the search propag directiondepend on the sign of signZ*signPz, while the building is always the contrary Propagator* searchingPropagator = &*propagator->clone(); @@ -128,129 +112,80 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle 0.0) searchingPropagator->setPropagationDirection(oppositeToMomentum); if (signZ * signPz < 0.0) searchingPropagator->setPropagationDirection(alongMomentum); if (searchingPropagator->propagationDirection() == alongMomentum) - std::cout << "\t searchingPropagator along Momentum" << std::endl; if (searchingPropagator->propagationDirection() == oppositeToMomentum) - std::cout << "\t ropagator opposite To Momentum" << std::endl; //find vHits in layer 2 - std::cout << "-----------------------------" << std::endl; - std::cout << "\t1c) Search/find hit in layer 2: " << std::endl; std::vector measurementsL2 = layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); - std::cout << "\t vh compatibles on L2: " << measurementsL2.size() << std::endl; //other options //LayerMeasurements::SimpleHitContainer hits; //layerMeasurements->recHits(hits, *barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); - //std::cout << "\t #try2 vh compatibles with recHits: " << hits.size() << std::endl; //auto && measurementsL2G = layerMeasurements->groupedMeasurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); - //std::cout << "\t #try3 vh grouped compatibles: " << measurementsL2G.size() << std::endl; + std::vector measurementsL2 = + layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); std::vector::iterator measurementsL2end = std::remove_if(measurementsL2.begin(), measurementsL2.end(), isInvalid()); measurementsL2.erase(measurementsL2end, measurementsL2.end()); - std::cout << "\t vh compatibles on L2(without invalidHit): " << measurementsL2.size() << std::endl; - std::cout << "-----------------------------" << std::endl; if (!measurementsL2.empty()) { //not sure if building it everytime takes time/memory const DetLayer* barrelOTLayer1 = measurementTracker->geometricSearchTracker()->tobLayers().at(0); for (auto mL2 : measurementsL2) { - std::cout << "\t2a) Check the searchingPropagator direction: " << std::endl; - if (searchingPropagator->propagationDirection() == alongMomentum) - std::cout << "\t searchingPropagator along Momentum" << std::endl; - if (searchingPropagator->propagationDirection() == oppositeToMomentum) - std::cout << "\t searchingPropagator opposite To Momentum" << std::endl; const TrackingRecHit* hitL2 = mL2.recHit().get(); - std::cout << "\t2b) and the VH on layer 2: " << std::endl; - const VectorHit* vhit = dynamic_cast(hitL2); - std::cout << "\t vh is valid >> " << (*vhit) << std::endl; //propagate to the L2 and update the TSOS - std::cout << "\t2c) Propagation and update on L2: " << std::endl; std::pair updatedTSOS = propagateAndUpdate(initialTSOS, *searchingPropagator, *hitL2); - if (!updatedTSOS.first) - std::cout << "\t updatedTSOS on L2 is NOT valid : " << updatedTSOS.second << std::endl; if (!updatedTSOS.first) continue; - std::cout << "\t updatedTSOS is valid : " << updatedTSOS.second << std::endl; - std::cout << "\t chi2 VH/updatedTSOS : " << estimator->estimate(updatedTSOS.second, *hitL2).second - << std::endl; //searching possible VHs in L1 - std::cout << "\t2d) Search/find hit in layer 1: " << std::endl; std::vector measurementsL1 = layerMeasurements->measurements(*barrelOTLayer1, updatedTSOS.second, *searchingPropagator, *estimator); - std::cout << "\t vh compatibles on L1: " << measurementsL1.size() << std::endl; std::vector::iterator measurementsL1end = std::remove_if(measurementsL1.begin(), measurementsL1.end(), isInvalid()); measurementsL1.erase(measurementsL1end, measurementsL1.end()); - std::cout << "\t vh compatibles on L1(without invalidHit): " << measurementsL1.size() << std::endl; - std::cout << "-----------------------------" << std::endl; if (!measurementsL1.empty()) { for (auto mL1 : measurementsL1) { - std::cout << "\t3a) Check the searchingPropagator direction: " << std::endl; - if (searchingPropagator->propagationDirection() == alongMomentum) - std::cout << "\t searchingPropagator along Momentum" << std::endl; - if (searchingPropagator->propagationDirection() == oppositeToMomentum) - std::cout << "\t searchingPropagator opposite To Momentum" << std::endl; const TrackingRecHit* hitL1 = mL1.recHit().get(); - std::cout << "\t3b) and the VH on layer 1: " << std::endl; - const VectorHit* vhitL1 = dynamic_cast(hitL1); - std::cout << "\t vh is valid >> " << (*vhitL1) << std::endl; //propagate to the L1 and update the TSOS - std::cout << "\t3c) Propagation and update on L1: " << std::endl; std::pair updatedTSOSL1 = propagateAndUpdate(updatedTSOS.second, *searchingPropagator, *hitL1); - if (!updatedTSOSL1.first) - std::cout << "\t updatedTSOS on L1 is NOT valid : " << updatedTSOSL1.second << std::endl; if (!updatedTSOSL1.first) continue; - std::cout << "\t updatedTSOS on L1 : " << updatedTSOSL1.second << std::endl; - std::cout << "\t chi2 VH/updatedTSOS : " << estimator->estimate(updatedTSOSL1.second, *hitL1).second - << std::endl; - std::cout << "\t3d) Creation of the Seed: " << std::endl; - // passSelection(updatedTSOS) : - // http://cmslxr.fnal.gov/lxr/source/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc?v=CMSSW_8_1_X_2016-09-04-2300#0474 edm::OwnVector container; container.push_back(hitL1->clone()); container.push_back(hitL2->clone()); container.push_back(hitL3.clone()); //building trajectory inside-out - std::cout << "\t3e) Building trajectory inside-out: " << std::endl; if (searchingPropagator->propagationDirection() == alongMomentum) { buildingPropagator->setPropagationDirection(oppositeToMomentum); - std::cout << "\t buildingPropagator opposite To Momentum" << std::endl; } else if (searchingPropagator->propagationDirection() == oppositeToMomentum) { buildingPropagator->setPropagationDirection(alongMomentum); - std::cout << "\t buildingPropagator along Momentum" << std::endl; } updatedTSOSL1.second.rescaleError(100); - std::cout << "\t updatedTSOS on L1 : " << updatedTSOSL1.second << std::endl; TrajectoryStateOnSurface updatedTSOSL1_final = theUpdator->update(updatedTSOSL1.second, *hitL1); if @@ -259,20 +194,15 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle updatedTSOSL3_final = propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, hitL3); - std::cout << "\t updatedTSOS final on L3 : " << updatedTSOSL3_final.second << std::endl; TrajectorySeed ts = createSeed(updatedTSOSL3_final.second, container, hitL3.geographicalId(), *buildingPropagator); result.push_back(ts); } } - std::cout << "-----" << std::endl; } } } - std::cout << "-----------------------------" << std::endl; - std::cout << "------- seeds found: " << result.size() << " ------" << std::endl; - std::cout << "-----------------------------" << std::endl; return result; } @@ -291,7 +221,6 @@ std::vector SeedingOTEDProducer::collectVHsOnLayer(edm::Handle VHsOnLayer; if (!input.empty()) { - //std::cout << "initial VH collection size = " << input.size() << std::endl; for (auto DSViter : input) { if (checkLayer(DSViter.id()) == layerNumber) { for (auto vh : DSViter) { @@ -301,7 +230,6 @@ std::vector SeedingOTEDProducer::collectVHsOnLayer(edm::Handle& container, const DetId& id, const Propagator& prop) { - /* - //I have already propagator and updator - //const Propagator* propagator = &(*propagatorHandle); - //KFUpdator updator; - - // Now update initial state track using information from seed hits. - - TrajectoryStateOnSurface updatedState; - edm::OwnVector seedHits; - - for ( unsigned int iHit = 1; iHit < container.size(); iHit++) { - - std::pair state; - if(iHit==1) - state = propagateAndUpdate(tsos, *propagator, container[iHit]); - else - state = propagateAndUpdate(updatedState, *propagator, container[iHit]); - //std::cout << "-------> new state >> " << state.second << std::endl; - if(state.first) - updatedState = state.second; -*/ - /* - TrajectoryStateOnSurface state = (iHit==1) ? propagator->propagate(tsos, container[iHit].det()->surface()) : propagator->propagate(updatedState, container[iHit].det()->surface()); - - std::cout << "-------> new state >> " << state << std::endl; - - if (!state.isValid()) return TrajectorySeed(); - - //SeedingHitSet::ConstRecHitPointer tth = hits[iHit]; - //std::unique_ptr newtth(refitHit( tth, state)); - //if (!checkHit(state,&*newtth)) return; - - std::cout << "-------> updated state >> " << state << std::endl; - updatedState = theUpdator->update(state, container[iHit]); - if (!updatedState.isValid()) return TrajectorySeed(); - - //seedHits.push_back(newtth.release()); -*/ - // } - - //if(!hit) return; PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos, id.rawId()); return TrajectorySeed(seedTSOS, container, prop.propagationDirection()); - //if ( !filter || filter->compatible(seed)) seedCollection.push_back(std::move(seed)); } diff --git a/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc b/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc index fcc5ab60b3e26..3b49cff70bd7b 100644 --- a/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc +++ b/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc @@ -5,13 +5,6 @@ #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h" -#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h" -#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h" -#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h" -#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h" -#include "DataFormats/TrackerRecHit2D/interface/Phase2TrackerRecHit1D.h" -#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" -#include "DataFormats/SiStripDetId/interface/SiStripDetId.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/Math/interface/deltaR.h" From ac8f3be934e02f4f95d221b255d5d7bc375d193c Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 9 Oct 2019 01:27:46 +0200 Subject: [PATCH 014/115] apply code checks --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 20 +++++++++++-------- .../src/SeedingOTEDProducer.cc | 15 ++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 32f71c58baf1c..1aa1f7a1dae9d 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -214,7 +214,7 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const pow(gPositionLower.y(), 2) * gPositionUpper.y() - gPositionLower.y() * pow(gPositionUpper.y(), 2); //radius of circle - double invRho2 = (2. * h1)/(r12 * r22 * h3); + double invRho2 = (2. * h1) / (r12 * r22 * h3); curvature = sqrt(invRho2); //center of circle @@ -234,21 +234,25 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const jacobian[i][j] = 0.0; } } - double denom1 = 1./sqrt(r12 * r22 * h3); - double denom2 = 1./(pow(r12 * r22 * h3, 1.5)); + double denom1 = 1. / sqrt(r12 * r22 * h3); + double denom2 = 1. / (pow(r12 * r22 * h3, 1.5)); jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 jacobian[2][0] = - (h1 * (2. * gPositionLower.x() * r22 * h3 + (2. * gPositionLower.x() - 2. * gPositionUpper.x()) * r12 * r22)) * denom2 - - (2. * gPositionUpper.y()) * denom1; // dkappa/dx1 + (h1 * (2. * gPositionLower.x() * r22 * h3 + (2. * gPositionLower.x() - 2. * gPositionUpper.x()) * r12 * r22)) * + denom2 - + (2. * gPositionUpper.y()) * denom1; // dkappa/dx1 jacobian[2][1] = (2. * gPositionUpper.x()) * denom1 + - (h1 * (2. * gPositionLower.y() * r22 * h3 + r12 * r22 * (2. * gPositionLower.y() - 2. * gPositionUpper.y()))) * denom2; // dkappa/dy1 + (h1 * (2. * gPositionLower.y() * r22 * h3 + r12 * r22 * (2. * gPositionLower.y() - 2. * gPositionUpper.y()))) * + denom2; // dkappa/dy1 jacobian[2][2] = (2. * gPositionLower.y()) * denom1 + - (h1 * (2. * gPositionUpper.x() * r12 * h3 - 2. * (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2; // dkappa/dx2 + (h1 * (2. * gPositionUpper.x() * r12 * h3 - 2. * (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * + denom2; // dkappa/dx2 jacobian[2][3] = - (h1 * (2. * gPositionUpper.y() * r12 * h3 - r12 * r22 * 2. * (gPositionLower.y() - gPositionUpper.y()))) * denom2 - + (h1 * (2. * gPositionUpper.y() * r12 * h3 - r12 * r22 * 2. * (gPositionLower.y() - gPositionUpper.y()))) * + denom2 - (2. * gPositionLower.x()) * denom1; // dkappa/dy2 for (int i = 0; i < 4; i++) { diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index ad44f8df5fdcc..2aaa01760cc34 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -88,7 +88,6 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) seedsWithVHs->shrink_to_fit(); event.put(std::move(seedsWithVHs)); - } TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { @@ -116,7 +115,6 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle 0.0) searchingPropagator->setPropagationDirection(oppositeToMomentum); @@ -124,11 +122,11 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::HandlesetPropagationDirection(alongMomentum); if (searchingPropagator->propagationDirection() == alongMomentum) - if (searchingPropagator->propagationDirection() == oppositeToMomentum) + if (searchingPropagator->propagationDirection() == oppositeToMomentum) - //find vHits in layer 2 - std::vector measurementsL2 = - layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + //find vHits in layer 2 + std::vector measurementsL2 = + layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); //other options //LayerMeasurements::SimpleHitContainer hits; @@ -146,7 +144,6 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::HandlegeometricSearchTracker()->tobLayers().at(0); for (auto mL2 : measurementsL2) { - const TrackingRecHit* hitL2 = mL2.recHit().get(); //propagate to the L2 and update the TSOS @@ -164,7 +161,6 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle SeedingOTEDProducer::collectVHsOnLayer(edm::Handle& container, const DetId& id, const Propagator& prop) { - PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos, id.rawId()); return TrajectorySeed(seedTSOS, container, prop.propagationDirection()); } From 35bc979aaac984fdce3c01a6095fd9374715009d Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 9 Oct 2019 01:34:38 +0200 Subject: [PATCH 015/115] fix things broken in SeedingOTEDProducer.cc by last commit --- RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 2aaa01760cc34..2e4b5347a4558 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -121,19 +121,15 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::HandlesetPropagationDirection(alongMomentum); - if (searchingPropagator->propagationDirection() == alongMomentum) - if (searchingPropagator->propagationDirection() == oppositeToMomentum) - //find vHits in layer 2 - std::vector measurementsL2 = - layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + //find vHits in layer 2 + std::vector measurementsL2 = + layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); //other options //LayerMeasurements::SimpleHitContainer hits; //layerMeasurements->recHits(hits, *barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); //auto && measurementsL2G = layerMeasurements->groupedMeasurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); - std::vector measurementsL2 = - layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); std::vector::iterator measurementsL2end = std::remove_if(measurementsL2.begin(), measurementsL2.end(), isInvalid()); From 672156a45e30a483280cb43cd8322198a5e6219a Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 9 Oct 2019 07:22:52 +0200 Subject: [PATCH 016/115] fix the fixes --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 1aa1f7a1dae9d..a3256a2f969a0 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -214,7 +214,7 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const pow(gPositionLower.y(), 2) * gPositionUpper.y() - gPositionLower.y() * pow(gPositionUpper.y(), 2); //radius of circle - double invRho2 = (2. * h1) / (r12 * r22 * h3); + double invRho2 = (4. * h1 * h1) / (r12 * r22 * h3); curvature = sqrt(invRho2); //center of circle From 2dd7bf8229a85f279ff67eb89ef0f3edfe6b9dbd Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 9 Oct 2019 07:38:05 +0200 Subject: [PATCH 017/115] code formates --- RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 2e4b5347a4558..5c1f381df6122 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -121,10 +121,9 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::HandlesetPropagationDirection(alongMomentum); - //find vHits in layer 2 std::vector measurementsL2 = - layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); //other options //LayerMeasurements::SimpleHitContainer hits; From d5c6cb4df2f188d35c547367e249b401c0f5ab33 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 14 Oct 2019 18:40:37 +0200 Subject: [PATCH 018/115] resolve conflict in TkStackMeasurementDet.h --- .../python/RecoLocalTracker_cff.py | 2 +- .../SiPhase2RecHitMatcherESProducer.cc | 25 ++++++++----------- .../python/SiPhase2RecHitMatcher_cfi.py | 4 --- .../TrackerRecoGeometryESProducer_cfi.py | 2 +- 4 files changed, 13 insertions(+), 20 deletions(-) delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py diff --git a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py index 06ebb798faca2..7050eb08bdb14 100644 --- a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py +++ b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py @@ -23,7 +23,7 @@ from RecoLocalTracker.SiPhase2Clusterizer.phase2TrackerClusterizer_cfi import * from RecoLocalTracker.Phase2TrackerRecHits.Phase2StripCPEGeometricESProducer_cfi import * -from RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2RecHitMatcher_cfi import * +from RecoLocalTracker.SiPhase2VectorHitBuilder.siPhase2RecHitMatcherESProducer_cfi import * _pixeltrackerlocalrecoTask_phase2 = pixeltrackerlocalrecoTask.copy() _pixeltrackerlocalrecoTask_phase2.add(siPhase2Clusters) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 154c88423ad64..3ad78c6a587d9 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -15,33 +15,30 @@ class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { SiPhase2RecHitMatcherESProducer(const edm::ParameterSet&); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); std::shared_ptr produce(const TkPhase2OTCPERecord&); + edm::ESGetToken tGeomToken_; + edm::ESGetToken tTopoToken_; private: std::string name_; - std::shared_ptr matcher_; edm::ParameterSet pset_; }; SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet& p) { name_ = p.getParameter("ComponentName"); pset_ = p; - setWhatProduced(this, name_); + auto cc = setWhatProduced(this, name_); + tGeomToken_ = cc.consumes(); + tTopoToken_ = cc.consumes(); } std::shared_ptr SiPhase2RecHitMatcherESProducer::produce( const TkPhase2OTCPERecord& iRecord) { - if (name_ == "SiPhase2VectorHitMatcher") { - matcher_ = std::make_shared(pset_); +// if (name_ == "SiPhase2VectorHitMatcher") { + std::shared_ptr matcher_ = std::make_shared(pset_); - edm::ESHandle tGeomHandle; - edm::ESHandle tTopoHandle; - - iRecord.getRecord().get(tGeomHandle); - iRecord.getRecord().get(tTopoHandle); - - matcher_->algo()->initTkGeom(tGeomHandle); - matcher_->algo()->initTkTopo(tTopoHandle); - } + matcher_->algo()->initTkGeom(iRecord.getHandle(tGeomToken_)); + matcher_->algo()->initTkTopo(iRecord.getHandle(tTopoToken_)); +// } return matcher_; } @@ -74,7 +71,7 @@ void SiPhase2RecHitMatcherESProducer::fillDescriptions(edm::ConfigurationDescrip 0.1, 0.1, }); - descriptions.add("SiPhase2RecHitMatcherESProducer", desc); + descriptions.add("siPhase2RecHitMatcherESProducer", desc); } DEFINE_FWK_EVENTSETUP_MODULE(SiPhase2RecHitMatcherESProducer); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py deleted file mode 100644 index b10e94e6c8b96..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py +++ /dev/null @@ -1,4 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -SiPhase2RecHitMatcherESProducer = cms.ESProducer("SiPhase2RecHitMatcherESProducer", -) diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 22d95e29034d3..a89b539106034 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -5,5 +5,5 @@ ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) From 428127c40fc924c91f340e46176fb330bde458ed Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 14 Oct 2019 18:43:44 +0200 Subject: [PATCH 019/115] Revert "resolve conflict in TkStackMeasurementDet.h" This reverts commit a411999f99937e5d00ae323f7853adeb52144eb5. --- .../python/RecoLocalTracker_cff.py | 2 +- .../SiPhase2RecHitMatcherESProducer.cc | 25 +++++++++++-------- .../python/SiPhase2RecHitMatcher_cfi.py | 4 +++ .../TrackerRecoGeometryESProducer_cfi.py | 2 +- .../plugins/TkStackMeasurementDet.h | 2 +- 5 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py diff --git a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py index 7050eb08bdb14..06ebb798faca2 100644 --- a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py +++ b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py @@ -23,7 +23,7 @@ from RecoLocalTracker.SiPhase2Clusterizer.phase2TrackerClusterizer_cfi import * from RecoLocalTracker.Phase2TrackerRecHits.Phase2StripCPEGeometricESProducer_cfi import * -from RecoLocalTracker.SiPhase2VectorHitBuilder.siPhase2RecHitMatcherESProducer_cfi import * +from RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2RecHitMatcher_cfi import * _pixeltrackerlocalrecoTask_phase2 = pixeltrackerlocalrecoTask.copy() _pixeltrackerlocalrecoTask_phase2.add(siPhase2Clusters) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 3ad78c6a587d9..154c88423ad64 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -15,30 +15,33 @@ class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { SiPhase2RecHitMatcherESProducer(const edm::ParameterSet&); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); std::shared_ptr produce(const TkPhase2OTCPERecord&); - edm::ESGetToken tGeomToken_; - edm::ESGetToken tTopoToken_; private: std::string name_; + std::shared_ptr matcher_; edm::ParameterSet pset_; }; SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet& p) { name_ = p.getParameter("ComponentName"); pset_ = p; - auto cc = setWhatProduced(this, name_); - tGeomToken_ = cc.consumes(); - tTopoToken_ = cc.consumes(); + setWhatProduced(this, name_); } std::shared_ptr SiPhase2RecHitMatcherESProducer::produce( const TkPhase2OTCPERecord& iRecord) { -// if (name_ == "SiPhase2VectorHitMatcher") { - std::shared_ptr matcher_ = std::make_shared(pset_); + if (name_ == "SiPhase2VectorHitMatcher") { + matcher_ = std::make_shared(pset_); - matcher_->algo()->initTkGeom(iRecord.getHandle(tGeomToken_)); - matcher_->algo()->initTkTopo(iRecord.getHandle(tTopoToken_)); -// } + edm::ESHandle tGeomHandle; + edm::ESHandle tTopoHandle; + + iRecord.getRecord().get(tGeomHandle); + iRecord.getRecord().get(tTopoHandle); + + matcher_->algo()->initTkGeom(tGeomHandle); + matcher_->algo()->initTkTopo(tTopoHandle); + } return matcher_; } @@ -71,7 +74,7 @@ void SiPhase2RecHitMatcherESProducer::fillDescriptions(edm::ConfigurationDescrip 0.1, 0.1, }); - descriptions.add("siPhase2RecHitMatcherESProducer", desc); + descriptions.add("SiPhase2RecHitMatcherESProducer", desc); } DEFINE_FWK_EVENTSETUP_MODULE(SiPhase2RecHitMatcherESProducer); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py new file mode 100644 index 0000000000000..b10e94e6c8b96 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +SiPhase2RecHitMatcherESProducer = cms.ESProducer("SiPhase2RecHitMatcherESProducer", +) diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index a89b539106034..22d95e29034d3 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -5,5 +5,5 @@ ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index df1e1af4c48b1..4d8d0e04c2b37 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -4,7 +4,7 @@ #include "TrackingTools/MeasurementDet/interface/MeasurementDet.h" #include "TkPhase2OTMeasurementDet.h" -#include "Geometry/CommonDetUnit/interface/StackGeomDet.h" +#include "Geometry/TrackerGeometryBuilder/interface/StackGeomDet.h" #include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" From 236113f6d297d1c8cdaa0a1fae20aa1db7d8be9b Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 14 Oct 2019 18:48:09 +0200 Subject: [PATCH 020/115] resolve merge conflict in kStackMeasurementDet.h --- RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index 4d8d0e04c2b37..df1e1af4c48b1 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -4,7 +4,7 @@ #include "TrackingTools/MeasurementDet/interface/MeasurementDet.h" #include "TkPhase2OTMeasurementDet.h" -#include "Geometry/TrackerGeometryBuilder/interface/StackGeomDet.h" +#include "Geometry/CommonDetUnit/interface/StackGeomDet.h" #include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" From ee3a1946c3437dbcd34fa90ec35f91d3e8c2bc50 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 14 Oct 2019 19:43:34 +0200 Subject: [PATCH 021/115] adapt includes to match changes in PR 28127 --- DataFormats/TrackerRecHit2D/interface/VectorHit.h | 2 +- .../interface/VectorHitBuilderAlgorithmBase.h | 4 ++-- .../src/VectorHitBuilderAlgorithmBase.cc | 2 +- .../SiPhase2VectorHitBuilder/test/VectorHitsValidation.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 83ed6e7b57a15..ef937d820ee2a 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -19,7 +19,7 @@ #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" #include "DataFormats/GeometryVector/interface/LocalVector.h" -#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" #include "MagneticField/Engine/interface/MagneticField.h" #include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h" diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index 780b9b474485a..71d480b750b90 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -9,10 +9,10 @@ #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" -#include "Geometry/TrackerGeometryBuilder/interface/StackGeomDet.h" +#include "Geometry/CommonDetUnit/interface/StackGeomDet.h" #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" -#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" namespace edm { class ParameterSet; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index 80e027ed13c69..9c892f46af67b 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -5,7 +5,7 @@ #include "Geometry/CommonTopologies/interface/PixelTopology.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase(const edm::ParameterSet& conf) : nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index 313e0aa78388b..89f0e93acea6a 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -15,7 +15,7 @@ #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" From c9eace11015f149bc077e4a436394052840d2ec1 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 16 Oct 2019 16:37:03 +0200 Subject: [PATCH 022/115] rebase to latest IB --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 2 +- .../SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc | 2 +- .../SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index a3256a2f969a0..05ba87ecba7ec 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -1,5 +1,5 @@ #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" -#include "Geometry/TrackerGeometryBuilder/interface/StackGeomDet.h" +#include "Geometry/CommonDetUnit/interface/StackGeomDet.h" VectorHit::VectorHit(const VectorHit& vh) : BaseTrackerRecHit(*vh.det(), trackerHitRTTI::vector), diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc index 9f34cc8bbb199..b6ffb8e031f64 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc @@ -15,7 +15,7 @@ #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 6c45bd53236e0..a75172161e98d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -2,7 +2,7 @@ #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h" #include "SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h" #include "RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h" -#include "Geometry/TrackerGeometryBuilder/interface/StackGeomDet.h" +#include "Geometry/CommonDetUnit/interface/StackGeomDet.h" #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" From 8bdb8a4e097bd2655b0d72661436dcfb3f4b94f7 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 28 Aug 2020 11:02:33 -0500 Subject: [PATCH 023/115] refactor code to not use EDProducer as product of ESProducer - part I --- .../TrackerRecHit2D/interface/VectorHit.h | 10 +++---- .../Records/interface/TkPhase2OTCPERecord.h | 2 +- .../interface/VectorHitBuilderAlgorithm.h | 10 +++---- .../interface/VectorHitBuilderAlgorithmBase.h | 2 +- .../SiPhase2RecHitMatcherESProducer.cc | 29 ++++++++++--------- .../src/VectorHitBuilderAlgorithm.cc | 14 +++++---- .../plugins/MeasurementTrackerESProducer.cc | 6 ++-- .../plugins/MeasurementTrackerImpl.cc | 3 +- .../plugins/MeasurementTrackerImpl.h | 3 +- .../plugins/TkStackMeasurementDet.cc | 8 ++--- .../plugins/TkStackMeasurementDet.h | 6 ++-- .../MeasurementDet/src/TkMeasurementDetSet.cc | 2 +- .../MeasurementDet/src/TkMeasurementDetSet.h | 8 ++--- 13 files changed, 54 insertions(+), 49 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index ef937d820ee2a..b25c8ace397a4 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -26,7 +26,7 @@ #include "TkCloner.h" -class VectorHit GCC11_FINAL : public BaseTrackerRecHit { +class VectorHit : public BaseTrackerRecHit { public: typedef OmniClusterRef::Phase2Cluster1DRef ClusterRef; @@ -60,7 +60,7 @@ class VectorHit GCC11_FINAL : public BaseTrackerRecHit { // Parameters of the segment, for the track fit // For a 4D segment: (dx/dz,dy/dz,x,y) - bool hasPositionAndError() const GCC11_FINAL { + bool hasPositionAndError() const { //bool hasPositionAndError() const { return true; // return (err_.xx() != 0) || (err_.yy() != 0) || (err_.xy() != 0) || @@ -72,10 +72,10 @@ class VectorHit GCC11_FINAL : public BaseTrackerRecHit { void getKfComponents4D(KfComponentsHolder& holder) const; // returning methods - LocalPoint localPosition() const GCC11_FINAL { return thePosition; } + LocalPoint localPosition() const { return thePosition; } virtual LocalVector localDirection() const { return theDirection; } AlgebraicSymMatrix parametersError() const override; - LocalError localPositionError() const GCC11_FINAL; + LocalError localPositionError() const; virtual LocalError localDirectionError() const; Global3DVector globalDirection() const; @@ -102,7 +102,7 @@ class VectorHit GCC11_FINAL : public BaseTrackerRecHit { bool isPhase2() const override { return true; } //FIXME: I have always two clusters in a VH - OmniClusterRef const& firstClusterRef() const GCC11_FINAL { return theLowerCluster; } + OmniClusterRef const& firstClusterRef() const { return theLowerCluster; } ClusterRef cluster() const { return theLowerCluster.cluster_phase2OT(); } //This method returns the delta in global coordinates diff --git a/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h b/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h index 44fea80269a6a..bb6a9ec9a4634 100644 --- a/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h +++ b/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h @@ -12,7 +12,7 @@ class TkPhase2OTCPERecord : public edm::eventsetup::DependentRecordImplementation< TkPhase2OTCPERecord, - edm::mpl::Vector > { + edm::mpl::Vector > { }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 754f517aa57be..72eb5c688aef6 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -33,7 +33,7 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { bool checkClustersCompatibility(Local3DPoint& posinner, Local3DPoint& posouter, LocalError& errinner, - LocalError& errouter); + LocalError& errouter) const; class LocalPositionSort { public: @@ -58,7 +58,7 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, - Phase2TrackerCluster1DRef upper) override; + Phase2TrackerCluster1DRef upper) const override; // Full I/O in DetSet //void buildDetUnit( const edm::DetSetVector & input, @@ -71,7 +71,7 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2); + double& chi2) const; void fit2Dzy(const Local3DPoint lpCI, const Local3DPoint lpCO, const LocalError leCI, @@ -79,7 +79,7 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2); + double& chi2) const; void fit(const std::vector& x, const std::vector& y, @@ -87,7 +87,7 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2); + double& chi2) const; // void build( const edm::DetSet & input, // output_t::FastFiller& output); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index 71d480b750b90..faf6769ecc578 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -52,7 +52,7 @@ class VectorHitBuilderAlgorithmBase { virtual VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, - Phase2TrackerCluster1DRef upper) = 0; + Phase2TrackerCluster1DRef upper) const = 0; double computeParallaxCorrection(const PixelGeomDetUnit*&, const Point3DBase&, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 154c88423ad64..7da1c8d474961 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -7,40 +7,41 @@ #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { public: SiPhase2RecHitMatcherESProducer(const edm::ParameterSet&); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - std::shared_ptr produce(const TkPhase2OTCPERecord&); + std::shared_ptr produce(const TkPhase2OTCPERecord&); private: std::string name_; - std::shared_ptr matcher_; + std::shared_ptr matcher_; edm::ParameterSet pset_; + edm::ESGetToken geometryToken_; + edm::ESGetToken trackerTopoToken_; }; SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet& p) { name_ = p.getParameter("ComponentName"); pset_ = p; - setWhatProduced(this, name_); + auto cc = setWhatProduced(this, name_); + geometryToken_ = cc.consumesFrom(); + trackerTopoToken_ = cc.consumesFrom(); } -std::shared_ptr SiPhase2RecHitMatcherESProducer::produce( +std::shared_ptr SiPhase2RecHitMatcherESProducer::produce( const TkPhase2OTCPERecord& iRecord) { if (name_ == "SiPhase2VectorHitMatcher") { - matcher_ = std::make_shared(pset_); + matcher_ = std::make_shared(pset_); - edm::ESHandle tGeomHandle; - edm::ESHandle tTopoHandle; - - iRecord.getRecord().get(tGeomHandle); - iRecord.getRecord().get(tTopoHandle); - - matcher_->algo()->initTkGeom(tGeomHandle); - matcher_->algo()->initTkTopo(tTopoHandle); + edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); + edm::ESHandle tTopoHandle = iRecord.getHandle(trackerTopoToken_); + + matcher_->initTkGeom(tGeomHandle); + matcher_->initTkTopo(tTopoHandle); } return matcher_; } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 6787bd87f16ee..a84a73019fd64 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -121,7 +121,7 @@ bool VectorHitBuilderAlgorithm::checkClustersCompatibilityBeforeBuilding( bool VectorHitBuilderAlgorithm::checkClustersCompatibility(Local3DPoint& poslower, Local3DPoint& posupper, LocalError& errlower, - LocalError& errupper) { + LocalError& errupper) const{ return true; } @@ -247,9 +247,9 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi return result; } -VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, + VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, - Phase2TrackerCluster1DRef upper) { + Phase2TrackerCluster1DRef upper) const { LogTrace("VectorHitBuilderAlgorithm") << "Build VH with: "; //printCluster(stack->lowerDet(),&*lower); //printCluster(stack->upperDet(),&*upper); @@ -330,7 +330,7 @@ void VectorHitBuilderAlgorithm::fit2Dzx(const Local3DPoint lpCI, Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2) { + double& chi2) const{ std::vector x = {lpCI.z(), lpCO.z()}; std::vector y = {lpCI.x(), lpCO.x()}; float sqCI = sqrt(leCI.xx()); @@ -349,7 +349,7 @@ void VectorHitBuilderAlgorithm::fit2Dzy(const Local3DPoint lpCI, Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2) { + double& chi2) const{ std::vector x = {lpCI.z(), lpCO.z()}; std::vector y = {lpCI.y(), lpCO.y()}; float sqCI = sqrt(leCI.yy()); @@ -367,7 +367,7 @@ void VectorHitBuilderAlgorithm::fit(const std::vector& x, Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2) { + double& chi2) const{ if (x.size() != y.size() || x.size() != sigy.size()) { edm::LogError("VectorHitBuilderAlgorithm") << "Different size for x,z !! No fit possible."; return; @@ -400,3 +400,5 @@ void VectorHitBuilderAlgorithm::fit(const std::vector& x, dir = LocalVector(slope, 0., -1.); } } +#include "FWCore/Utilities/interface/typelookup.h" +TYPELOOKUP_DATA_REG(VectorHitBuilderAlgorithm); diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc index 51e57e85f7075..36cca63a0fdce 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc @@ -10,7 +10,7 @@ #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h" #include "RecoTracker/Record/interface/CkfComponentsRecord.h" @@ -56,7 +56,7 @@ class dso_hidden MeasurementTrackerESProducer : public edm::ESProducer { edm::ESGetToken trackerGeomToken_; edm::ESGetToken geometricSearchTrackerToken_; edm::ESGetToken, TkPhase2OTCPERecord> phase2TrackerCPEToken_; - edm::ESGetToken phase2matcherToken_; + edm::ESGetToken phase2matcherToken_; MeasurementTrackerImpl::BadStripCutsDet badStripCuts_; @@ -185,7 +185,7 @@ std::unique_ptr MeasurementTrackerESProducer::produce(const } const ClusterParameterEstimator *ptr_phase2TrackerCPE = nullptr; - const VectorHitBuilderEDProducer *ptr_phase2Matcher = nullptr; + const VectorHitBuilderAlgorithm *ptr_phase2Matcher = nullptr; if (usePhase2_) { ptr_phase2TrackerCPE = &iRecord.get(phase2TrackerCPEToken_); ptr_phase2Matcher = &iRecord.get(phase2matcherToken_); diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index d4426e2242f7c..337082baf5e7d 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -25,6 +25,7 @@ #include "RecoLocalTracker/Records/interface/TrackerCPERecord.h" #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h" #include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPE.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h" #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" @@ -77,7 +78,7 @@ MeasurementTrackerImpl::MeasurementTrackerImpl(const BadStripCutsDet& badStripCu const PixelClusterParameterEstimator* pixelCPE, const StripClusterParameterEstimator* stripCPE, const SiStripRecHitMatcher* hitMatcher, - const VectorHitBuilderEDProducer* ph2hitMatcher, + const VectorHitBuilderAlgorithm* ph2hitMatcher, const TrackerTopology* trackerTopology, const TrackerGeometry* trackerGeom, const GeometricSearchTracker* geometricSearchTracker, diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h index 858dc57fb319d..69c6a0e97d5ba 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h @@ -9,6 +9,7 @@ #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -56,7 +57,7 @@ class dso_hidden MeasurementTrackerImpl final : public MeasurementTracker { const PixelClusterParameterEstimator* pixelCPE, const StripClusterParameterEstimator* stripCPE, const SiStripRecHitMatcher* hitMatcher, - const VectorHitBuilderEDProducer* ph2hitMatcher, + const VectorHitBuilderAlgorithm* ph2hitMatcher, const TrackerTopology* trackerTopology, const TrackerGeometry* trackerGeom, const GeometricSearchTracker* geometricSearchTracker, diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index eca45f74b3fc0..ed13d52d1e0de 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -1,12 +1,12 @@ #include "TkStackMeasurementDet.h" #include "TrackingTools/MeasurementDet/interface/MeasurementDetException.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" using namespace std; TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet, - const VectorHitBuilderEDProducer* matcher, + const VectorHitBuilderAlgorithm* matcher, const PixelClusterParameterEstimator* cpe) : MeasurementDet(gdet), theMatcher(matcher), thePixelCPE(cpe), theLowerDet(nullptr), theUpperDet(nullptr) {} @@ -39,7 +39,7 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj begin = &(data.phase2OTData().handle()->data().front()); } - VectorHitBuilderAlgorithmBase* algo = theMatcher->algo(); + //VectorHitBuilderAlgorithm* algo = theMatcher; //VectorHitBuilderAlgorithm* vhalgo = dynamic_cast(algobase); LogTrace("MeasurementTracker") << "TkStackMeasurementDet::recHits algo has been set" << std::endl; @@ -72,7 +72,7 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo(data.phase2OTData().handle(), cil); Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo(data.phase2OTData().handle(), ciu); //ERICA:I would have prefer to keep buildVectorHits ... - VectorHit vh = algo->buildVectorHit(&specificGeomDet(), clusterLower, clusterUpper); + VectorHit vh = theMatcher->buildVectorHit(&specificGeomDet(), clusterLower, clusterUpper); LogTrace("MeasurementTracker") << "TkStackMeasurementDet::rechits adding VectorHits!" << std::endl; LogTrace("MeasurementTracker") << vh << std::endl; result.push_back(std::make_shared(vh)); diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index df1e1af4c48b1..a5bbfde36414f 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -5,7 +5,7 @@ #include "TkPhase2OTMeasurementDet.h" #include "Geometry/CommonDetUnit/interface/StackGeomDet.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include "FWCore/Utilities/interface/Visibility.h" @@ -15,7 +15,7 @@ class TkStackMeasurementDet final : public MeasurementDet { public: TkStackMeasurementDet(const StackGeomDet* gdet, - const VectorHitBuilderEDProducer* matcher, + const VectorHitBuilderAlgorithm* matcher, const PixelClusterParameterEstimator* cpe); void init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet); @@ -49,7 +49,7 @@ class TkStackMeasurementDet final : public MeasurementDet { } private: - const VectorHitBuilderEDProducer* theMatcher; + const VectorHitBuilderAlgorithm* theMatcher; const PixelClusterParameterEstimator* thePixelCPE; const TkPhase2OTMeasurementDet* theLowerDet; const TkPhase2OTMeasurementDet* theUpperDet; diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc index ca70930c5e707..dbc45685cb95e 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc @@ -43,5 +43,5 @@ void Phase2OTMeasurementConditionSet::init(int size) { activeThisPeriod_.resize(size, true); id_.resize(size); if (size > 0) - matcher()->algo()->initCpe(cpe()); + matcher()->initCpe(cpe()); } diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h index 58189318ec154..cfbfefbe3e471 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h @@ -20,7 +20,7 @@ class Phase2StripCPE; #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h" #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include @@ -406,7 +406,7 @@ class PxMeasurementDetSet { //FIXME:just temporary solution for phase2 OT that works! class Phase2OTMeasurementConditionSet { public: - Phase2OTMeasurementConditionSet(const VectorHitBuilderEDProducer* ph2matcher, + Phase2OTMeasurementConditionSet(const VectorHitBuilderAlgorithm* ph2matcher, const ClusterParameterEstimator* cpe) : thePhase2Matcher(ph2matcher), theCPE(cpe) {} @@ -417,7 +417,7 @@ class Phase2OTMeasurementConditionSet { int find(unsigned int jd, int i = 0) const { return std::lower_bound(id_.begin() + i, id_.end(), jd) - id_.begin(); } const ClusterParameterEstimator* cpe() const { return theCPE; } - const VectorHitBuilderEDProducer* matcher() const { return thePhase2Matcher; } + const VectorHitBuilderAlgorithm* matcher() const { return thePhase2Matcher; } bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; } /** \brief Turn on/off the module for reconstruction, for the full run or lumi (using info from DB, usually). @@ -428,7 +428,7 @@ class Phase2OTMeasurementConditionSet { friend class MeasurementTrackerImpl; // Globals (not-per-event) - const VectorHitBuilderEDProducer* thePhase2Matcher; + const VectorHitBuilderAlgorithm* thePhase2Matcher; const ClusterParameterEstimator* theCPE; // Locals, per-event From 9e38c4c02eaed9318a2f5385c8c33c45821bac43 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 28 Aug 2020 14:17:53 -0500 Subject: [PATCH 024/115] refactor code to not use EDProducer as product of ESProducer - part II --- RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml | 1 + .../plugins/SiPhase2RecHitMatcherESProducer.cc | 8 +++++++- RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc | 2 -- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml b/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml index dde4e31241cc2..b6e203a920b44 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml @@ -11,6 +11,7 @@ + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 7da1c8d474961..9cb0d7c599f74 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -4,6 +4,7 @@ #include "FWCore/Framework/interface/ModuleFactory.h" #include "FWCore/Framework/interface/ESProducer.h" #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" +#include "RecoTracker/Record/interface/CkfComponentsRecord.h" #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -22,6 +23,7 @@ class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { edm::ParameterSet pset_; edm::ESGetToken geometryToken_; edm::ESGetToken trackerTopoToken_; + edm::ESGetToken, TkPhase2OTCPERecord> cpeToken_; }; SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet& p) { @@ -30,6 +32,7 @@ SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::Para auto cc = setWhatProduced(this, name_); geometryToken_ = cc.consumesFrom(); trackerTopoToken_ = cc.consumesFrom(); + cpeToken_ = cc.consumesFrom, TkPhase2OTCPERecord>(); } std::shared_ptr SiPhase2RecHitMatcherESProducer::produce( @@ -39,9 +42,12 @@ std::shared_ptr SiPhase2RecHitMatcherESProducer::prod edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); edm::ESHandle tTopoHandle = iRecord.getHandle(trackerTopoToken_); - + + edm::ESHandle > cpeHandle= iRecord.getHandle(cpeToken_); + matcher_->initTkGeom(tGeomHandle); matcher_->initTkTopo(tTopoHandle); + matcher_->initCpe(cpeHandle.product()); } return matcher_; } diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc index dbc45685cb95e..f1dab6b903eff 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc @@ -42,6 +42,4 @@ void PxMeasurementConditionSet::init(int size) { void Phase2OTMeasurementConditionSet::init(int size) { activeThisPeriod_.resize(size, true); id_.resize(size); - if (size > 0) - matcher()->initCpe(cpe()); } From 4391753b32a22df971ead7456a3cd76a7c8020a7 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Sat, 29 Aug 2020 08:49:07 -0500 Subject: [PATCH 025/115] refactor code to not use EDProducer as product of ESProducer - part III --- .../plugins/SiPhase2RecHitMatcherESProducer.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 9cb0d7c599f74..8a5bb5afecfbd 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -32,7 +32,8 @@ SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::Para auto cc = setWhatProduced(this, name_); geometryToken_ = cc.consumesFrom(); trackerTopoToken_ = cc.consumesFrom(); - cpeToken_ = cc.consumesFrom, TkPhase2OTCPERecord>(); + auto const P2otname = p.getParameter("CPE"); + cpeToken_ = cc.consumesFrom, TkPhase2OTCPERecord>(P2otname); } std::shared_ptr SiPhase2RecHitMatcherESProducer::produce( @@ -42,12 +43,12 @@ std::shared_ptr SiPhase2RecHitMatcherESProducer::prod edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); edm::ESHandle tTopoHandle = iRecord.getHandle(trackerTopoToken_); - - edm::ESHandle > cpeHandle= iRecord.getHandle(cpeToken_); + + auto ptr_phase2TrackerCPE = &iRecord.get(cpeToken_); matcher_->initTkGeom(tGeomHandle); matcher_->initTkTopo(tTopoHandle); - matcher_->initCpe(cpeHandle.product()); + matcher_->initCpe(ptr_phase2TrackerCPE); } return matcher_; } @@ -58,7 +59,7 @@ void SiPhase2RecHitMatcherESProducer::fillDescriptions(edm::ConfigurationDescrip desc.add("maxVectorHits", 999999999); desc.add("Algorithm", "VectorHitBuilderAlgorithm"); desc.add("ComponentName", "SiPhase2VectorHitMatcher"); - desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); + desc.add("CPE", edm::ESInputTag("", "Phase2StripCPE")); desc.add>("BarrelCut", { 0.0, From 7b018f727723edd486eab1e501014eef989acf6c Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Sat, 29 Aug 2020 15:01:43 -0500 Subject: [PATCH 026/115] slight cleanup of diff --- DataFormats/TrackerRecHit2D/BuildFile.xml | 20 +++++++------- .../SiPhase2VectorHitBuilder/BuildFile.xml | 27 +++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/BuildFile.xml b/DataFormats/TrackerRecHit2D/BuildFile.xml index 085dd084880ff..f767813f2bbfc 100644 --- a/DataFormats/TrackerRecHit2D/BuildFile.xml +++ b/DataFormats/TrackerRecHit2D/BuildFile.xml @@ -1,13 +1,13 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml b/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml index b6e203a920b44..c5630c284bb8a 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml @@ -1,17 +1,16 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + From cb8050bf6a3851e37a440a07f68718bb2cc83dfb Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Tue, 1 Sep 2020 17:40:58 +0200 Subject: [PATCH 027/115] apply code checks --- .../TrackerRecHit2D/interface/VectorHit.h | 8 ++++---- .../Records/interface/TkPhase2OTCPERecord.h | 9 +++++---- .../SiPhase2RecHitMatcherESProducer.cc | 11 +++++----- .../src/VectorHitBuilderAlgorithm.cc | 20 +++++++++---------- RecoTracker/CkfPattern/src/PrintoutHelper.cc | 2 +- .../src/SeedingOTEDProducer.cc | 16 +++++++-------- .../TkSeedingLayers/src/HitExtractorSTRP.cc | 4 ++-- .../src/TkClonerImpl.cc | 2 +- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index b25c8ace397a4..20427b4778759 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -60,7 +60,7 @@ class VectorHit : public BaseTrackerRecHit { // Parameters of the segment, for the track fit // For a 4D segment: (dx/dz,dy/dz,x,y) - bool hasPositionAndError() const { + bool hasPositionAndError() const override { //bool hasPositionAndError() const { return true; // return (err_.xx() != 0) || (err_.yy() != 0) || (err_.xy() != 0) || @@ -72,10 +72,10 @@ class VectorHit : public BaseTrackerRecHit { void getKfComponents4D(KfComponentsHolder& holder) const; // returning methods - LocalPoint localPosition() const { return thePosition; } + LocalPoint localPosition() const override { return thePosition; } virtual LocalVector localDirection() const { return theDirection; } AlgebraicSymMatrix parametersError() const override; - LocalError localPositionError() const; + LocalError localPositionError() const override; virtual LocalError localDirectionError() const; Global3DVector globalDirection() const; @@ -102,7 +102,7 @@ class VectorHit : public BaseTrackerRecHit { bool isPhase2() const override { return true; } //FIXME: I have always two clusters in a VH - OmniClusterRef const& firstClusterRef() const { return theLowerCluster; } + OmniClusterRef const& firstClusterRef() const override { return theLowerCluster; } ClusterRef cluster() const { return theLowerCluster.cluster_phase2OT(); } //This method returns the delta in global coordinates diff --git a/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h b/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h index bb6a9ec9a4634..9423e0188ff5d 100644 --- a/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h +++ b/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h @@ -10,9 +10,10 @@ #include "FWCore/Utilities/interface/mplVector.h" class TkPhase2OTCPERecord - : public edm::eventsetup::DependentRecordImplementation< - TkPhase2OTCPERecord, - edm::mpl::Vector > { -}; + : public edm::eventsetup::DependentRecordImplementation > {}; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 8a5bb5afecfbd..dce044097bc78 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -30,22 +30,21 @@ SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::Para name_ = p.getParameter("ComponentName"); pset_ = p; auto cc = setWhatProduced(this, name_); - geometryToken_ = cc.consumesFrom(); - trackerTopoToken_ = cc.consumesFrom(); + geometryToken_ = cc.consumesFrom(); + trackerTopoToken_ = cc.consumesFrom(); auto const P2otname = p.getParameter("CPE"); cpeToken_ = cc.consumesFrom, TkPhase2OTCPERecord>(P2otname); } -std::shared_ptr SiPhase2RecHitMatcherESProducer::produce( - const TkPhase2OTCPERecord& iRecord) { +std::shared_ptr SiPhase2RecHitMatcherESProducer::produce(const TkPhase2OTCPERecord& iRecord) { if (name_ == "SiPhase2VectorHitMatcher") { matcher_ = std::make_shared(pset_); edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); edm::ESHandle tTopoHandle = iRecord.getHandle(trackerTopoToken_); - auto ptr_phase2TrackerCPE = &iRecord.get(cpeToken_); - + auto ptr_phase2TrackerCPE = &iRecord.get(cpeToken_); + matcher_->initTkGeom(tGeomHandle); matcher_->initTkTopo(tTopoHandle); matcher_->initCpe(ptr_phase2TrackerCPE); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index a84a73019fd64..fe3ccb1e35536 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -63,7 +63,7 @@ void VectorHitBuilderAlgorithm::run(edm::Handle> VectorHitBuilderAlgorithm::buildVectorHi std::sort(lowerClusters.begin(), lowerClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->lowerDet())); std::sort(upperClusters.begin(), upperClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->upperDet())); - for (auto cluL : lowerClusters) { + for (const auto& cluL : lowerClusters) { LogDebug("VectorHitBuilderAlgorithm") << " lower clusters " << std::endl; printCluster(stack->lowerDet(), &*cluL); const PixelGeomDetUnit* gduLow = dynamic_cast(stack->lowerDet()); auto&& lparamsLow = cpe->localParameters(*cluL, *gduLow); - for (auto cluU : upperClusters) { + for (const auto& cluU : upperClusters) { LogDebug("VectorHitBuilderAlgorithm") << "\t upper clusters " << std::endl; printCluster(stack->upperDet(), &*cluU); const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); @@ -247,7 +247,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi return result; } - VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, +VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, Phase2TrackerCluster1DRef upper) const { LogTrace("VectorHitBuilderAlgorithm") << "Build VH with: "; @@ -330,7 +330,7 @@ void VectorHitBuilderAlgorithm::fit2Dzx(const Local3DPoint lpCI, Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2) const{ + double& chi2) const { std::vector x = {lpCI.z(), lpCO.z()}; std::vector y = {lpCI.x(), lpCO.x()}; float sqCI = sqrt(leCI.xx()); @@ -349,7 +349,7 @@ void VectorHitBuilderAlgorithm::fit2Dzy(const Local3DPoint lpCI, Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2) const{ + double& chi2) const { std::vector x = {lpCI.z(), lpCO.z()}; std::vector y = {lpCI.y(), lpCO.y()}; float sqCI = sqrt(leCI.yy()); @@ -367,7 +367,7 @@ void VectorHitBuilderAlgorithm::fit(const std::vector& x, Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, - double& chi2) const{ + double& chi2) const { if (x.size() != y.size() || x.size() != sigy.size()) { edm::LogError("VectorHitBuilderAlgorithm") << "Different size for x,z !! No fit possible."; return; diff --git a/RecoTracker/CkfPattern/src/PrintoutHelper.cc b/RecoTracker/CkfPattern/src/PrintoutHelper.cc index 3fa643655cb1d..96a598b1354b2 100644 --- a/RecoTracker/CkfPattern/src/PrintoutHelper.cc +++ b/RecoTracker/CkfPattern/src/PrintoutHelper.cc @@ -104,7 +104,7 @@ std::string PrintoutHelper::regressionTest(const TrackerGeometry& tracker, std:: buffer << "================================================="; buffer << "=========== Traj in details =====================\n"; for (std::vector::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) { - for (auto hit : it->measurements()) { + for (const auto& hit : it->measurements()) { buffer << "measurement : " << hit.recHit()->geographicalId().rawId() << std::endl; } buffer << "================\n"; diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 5c1f381df6122..75696f84e7487 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -138,7 +138,7 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::HandlegeometricSearchTracker()->tobLayers().at(0); - for (auto mL2 : measurementsL2) { + for (const auto& mL2 : measurementsL2) { const TrackingRecHit* hitL2 = mL2.recHit().get(); //propagate to the L2 and update the TSOS @@ -155,7 +155,7 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handleupdate(updatedTSOSL1.second, *hitL1); - if - UNLIKELY(!updatedTSOSL1_final.isValid()) continue; + if UNLIKELY (!updatedTSOSL1_final.isValid()) + continue; std::pair updatedTSOSL2_final = propagateAndUpdate(updatedTSOSL1_final, *buildingPropagator, *hitL2); std::pair updatedTSOSL3_final = @@ -213,7 +213,7 @@ std::vector SeedingOTEDProducer::collectVHsOnLayer(edm::Handle VH const VectorHitCollectionNew& input = *VHs; if (!input.empty()) { for (auto DSViter : input) { - for (auto vh : DSViter) { + for (const auto& vh : DSViter) { if (checkLayer(DSViter.id()) == layerNumber) std::cout << " VH in layer " << layerNumber << " >> " << vh << std::endl; } @@ -285,8 +285,8 @@ std::pair SeedingOTEDProducer::propagateAndUpdat const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit) { TrajectoryStateOnSurface propTSOS = prop.propagate(initialTSOS, hit.det()->surface()); TrajectoryStateOnSurface updatedTSOS = theUpdator->update(propTSOS, hit); - if - UNLIKELY(!updatedTSOS.isValid()) return std::make_pair(false, updatedTSOS); + if UNLIKELY (!updatedTSOS.isValid()) + return std::make_pair(false, updatedTSOS); return std::make_pair(true, updatedTSOS); } diff --git a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc index c1ea40b32ef31..09087a243275a 100644 --- a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc +++ b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc @@ -71,8 +71,8 @@ bool HitExtractorSTRP::skipThis( if (maskCluster && (stripClusterMask->mask(clus.key()))) return true; - if - UNLIKELY(minGoodCharge <= 0) return false; + if UNLIKELY (minGoodCharge <= 0) + return false; return siStripClusterTools::chargePerCM(id, *clus.cluster_strip()) <= minGoodCharge; } diff --git a/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc b/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc index b35f6a2c4b9d2..8c396591f7a96 100644 --- a/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc +++ b/RecoTracker/TransientTrackingRecHit/src/TkClonerImpl.cc @@ -58,7 +58,7 @@ std::unique_ptr TkClonerImpl::operator()(Phase2TrackerRec } std::unique_ptr TkClonerImpl::operator()(VectorHit const& hit, TrajectoryStateOnSurface const& tsos) const { - return std::unique_ptr{new VectorHit(hit)}; + return std::make_unique(hit); } TrackingRecHit::ConstRecHitPointer TkClonerImpl::makeShared(SiPixelRecHit const& hit, From 4e69b00a618dfc9f235b99c81c0c1ceb41ab5c36 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 2 Sep 2020 14:23:59 -0500 Subject: [PATCH 028/115] remove unnecessary dependencies in build files --- DataFormats/TrackerRecHit2D/BuildFile.xml | 1 - RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/BuildFile.xml b/DataFormats/TrackerRecHit2D/BuildFile.xml index f767813f2bbfc..17ee9fb29a2e0 100644 --- a/DataFormats/TrackerRecHit2D/BuildFile.xml +++ b/DataFormats/TrackerRecHit2D/BuildFile.xml @@ -7,7 +7,6 @@ - diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml index bd4c0a3c2dc1f..3270d03161a4b 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml @@ -17,7 +17,6 @@ - From 728f0d0bf1cf6479447e51e0ce67f57008c6925f Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 2 Sep 2020 16:30:46 -0500 Subject: [PATCH 029/115] add VectorHitMomentumHelper to avoid include of MagenticField.h in DataFormats --- .../TrackerRecHit2D/interface/VectorHit.h | 3 --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 10 -------- .../interface/VectorHitMomentumHelper.h | 25 +++++++++++++++++++ .../test/VectorHitsValidation.cc | 6 +++-- .../interface/SeedingOTEDProducer.h | 4 +-- .../src/SeedingOTEDProducer.cc | 16 ++++++++---- 6 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 20427b4778759..3f9d0277befa9 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -20,7 +20,6 @@ #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" #include "DataFormats/GeometryVector/interface/LocalVector.h" #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" -#include "MagneticField/Engine/interface/MagneticField.h" #include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h" @@ -83,8 +82,6 @@ class VectorHit : public BaseTrackerRecHit { int dimension() const override { return theDimension; } std::pair curvatureORphi(std::string curvORphi = "curvature") const; - float transverseMomentum(const MagneticField* magField); - float momentum(const MagneticField* magField); ClusterRef lowerCluster() const { return theLowerCluster.cluster_phase2OT(); } ClusterRef upperCluster() const { return theUpperCluster.cluster_phase2OT(); } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 05ba87ecba7ec..9cd3fe81a3ea1 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -347,16 +347,6 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const return std::make_pair(0.0, 0.0); } -float VectorHit::transverseMomentum(const MagneticField* magField) { - GlobalPoint center(0.0, 0.0, 0.0); - float magnT = magField->inTesla(center).mag(); - double rho = 1. / curvatureORphi("curvature").first; - //0.003 is because the curvature (rho) is in cm and not in m - return (0.003 * magnT * rho); -} - -float VectorHit::momentum(const MagneticField* magField) { return transverseMomentum(magField) / (1. * sin(theta())); } - float VectorHit::theta() { return globalDirection().theta(); } AlgebraicMatrix VectorHit::projectionMatrix() const { diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h new file mode 100644 index 0000000000000..d524c3ad19099 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h @@ -0,0 +1,25 @@ +#ifndef VectorHitMomentumHelper_H +#define VectorHitMomentumHelper_H + +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "MagneticField/Engine/interface/MagneticField.h" + +class VectorHitMomentumHelper { +public: + VectorHitMomentumHelper(); + ~VectorHitMomentumHelper() { + } + + float transverseMomentum(VectorHit& vh,const MagneticField* magField){ + GlobalPoint center(0.0, 0.0, 0.0); + float magnT = magField->inTesla(center).mag(); + double rho = 1. / vh.curvatureORphi("curvature").first; + //0.003 is because the curvature (rho) is in cm and not in m + return (0.003 * magnT * rho); + } + float momentum(VectorHit& vh, const MagneticField* magField) { return transverseMomentum(vh , magField) / (1. * sin(vh.theta())); } + +private: +}; + +#endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index a75172161e98d..2d8911258ff7d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -7,6 +7,7 @@ #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet& conf) : cpeTag_(conf.getParameter("CPE")) { @@ -623,10 +624,11 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } //curvature + VectorHitMomentumHelper* vhMomHelper; curvature = vh.curvatureORphi("curvature").first; phi = vh.curvatureORphi("phi").first; - QOverPT = vh.transverseMomentum(magField); - QOverP = vh.momentum(magField); + QOverPT = vhMomHelper->transverseMomentum(vh,magField); + QOverP = vhMomHelper->momentum(vh,magField); histogramLayer->second.curvature->Fill(curvature); //stub width diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h index 92857dd689d7a..b790c7415eb9d 100644 --- a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h +++ b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h @@ -43,8 +43,8 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { float computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot); float computeInverseMomentumError(VectorHit& vh, const float globalTheta, - const MagneticField* magField, - const double sigmaZ_beamSpot); + const double sigmaZ_beamSpot, + const double transverseMomentum); TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 75696f84e7487..95ca85becbdcc 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -16,6 +16,8 @@ #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" + SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) : theUpdator(nullptr), tkMeasEventToken(consumes(conf.getParameter("trackerEvent"))) { @@ -244,9 +246,13 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& // gv transform to local (lv) const Local3DVector lv(vHit.det()->surface().toLocal(gv)); + //Helper class to access momentum of VH + VectorHitMomentumHelper* vhMomHelper; + + //FIXME::charge is fine 1 every two times!! int charge = 1; - float p = vHit.momentum(magField); + float p = vhMomHelper->momentum(vHit,magField); float x = vHit.localPosition().x(); float y = vHit.localPosition().y(); float dx = vHit.localDirection().x(); @@ -259,7 +265,7 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p - mat[0][0] = pow(computeInverseMomentumError(vHit, theta, magField, beamSpot->sigmaZ()), 2); + mat[0][0] = pow(computeInverseMomentumError(vHit, theta, beamSpot->sigmaZ(),vhMomHelper->transverseMomentum(vHit,magField)), 2); //building tsos LocalTrajectoryError lterr(asSMatrix<5>(mat)); @@ -299,11 +305,11 @@ float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const do float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, const float globalTheta, - const MagneticField* magField, - const double sigmaZ_beamSpot) { + const double sigmaZ_beamSpot, + const double transverseMomentum) { //for pT > 2GeV, 1/pT has sigma = 1/sqrt(12) float varianceInverseTransvMomentum = 1. / 12; - double derivativeTheta2 = pow(cos(globalTheta) / vh.transverseMomentum(magField), 2); + double derivativeTheta2 = pow(cos(globalTheta) / transverseMomentum, 2); double derivativeInverseTransvMomentum2 = pow(sin(globalTheta), 2); float thetaError = computeGlobalThetaError(vh, sigmaZ_beamSpot); return pow(derivativeTheta2 * pow(thetaError, 2) + derivativeInverseTransvMomentum2 * varianceInverseTransvMomentum, From 8b43243bc87f7d78ae2481dc051ea1ae15d0dd47 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 2 Sep 2020 16:40:19 -0500 Subject: [PATCH 030/115] apply code formats --- .../interface/VectorHitMomentumHelper.h | 19 ++++++++++--------- .../test/VectorHitsValidation.cc | 4 ++-- .../interface/SeedingOTEDProducer.h | 2 +- .../src/SeedingOTEDProducer.cc | 8 ++++---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h index d524c3ad19099..eb33c3e090368 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h @@ -7,17 +7,18 @@ class VectorHitMomentumHelper { public: VectorHitMomentumHelper(); - ~VectorHitMomentumHelper() { - } + ~VectorHitMomentumHelper() {} - float transverseMomentum(VectorHit& vh,const MagneticField* magField){ - GlobalPoint center(0.0, 0.0, 0.0); - float magnT = magField->inTesla(center).mag(); - double rho = 1. / vh.curvatureORphi("curvature").first; - //0.003 is because the curvature (rho) is in cm and not in m - return (0.003 * magnT * rho); + float transverseMomentum(VectorHit& vh, const MagneticField* magField) { + GlobalPoint center(0.0, 0.0, 0.0); + float magnT = magField->inTesla(center).mag(); + double rho = 1. / vh.curvatureORphi("curvature").first; + //0.003 is because the curvature (rho) is in cm and not in m + return (0.003 * magnT * rho); + } + float momentum(VectorHit& vh, const MagneticField* magField) { + return transverseMomentum(vh, magField) / (1. * sin(vh.theta())); } - float momentum(VectorHit& vh, const MagneticField* magField) { return transverseMomentum(vh , magField) / (1. * sin(vh.theta())); } private: }; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 2d8911258ff7d..095022ddfd498 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -627,8 +627,8 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev VectorHitMomentumHelper* vhMomHelper; curvature = vh.curvatureORphi("curvature").first; phi = vh.curvatureORphi("phi").first; - QOverPT = vhMomHelper->transverseMomentum(vh,magField); - QOverP = vhMomHelper->momentum(vh,magField); + QOverPT = vhMomHelper->transverseMomentum(vh, magField); + QOverP = vhMomHelper->momentum(vh, magField); histogramLayer->second.curvature->Fill(curvature); //stub width diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h index b790c7415eb9d..1c140a9235c28 100644 --- a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h +++ b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h @@ -44,7 +44,7 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { float computeInverseMomentumError(VectorHit& vh, const float globalTheta, const double sigmaZ_beamSpot, - const double transverseMomentum); + const double transverseMomentum); TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 95ca85becbdcc..87f010f69eaaf 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -249,10 +249,9 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& //Helper class to access momentum of VH VectorHitMomentumHelper* vhMomHelper; - //FIXME::charge is fine 1 every two times!! int charge = 1; - float p = vhMomHelper->momentum(vHit,magField); + float p = vhMomHelper->momentum(vHit, magField); float x = vHit.localPosition().x(); float y = vHit.localPosition().y(); float dx = vHit.localDirection().x(); @@ -265,7 +264,8 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p - mat[0][0] = pow(computeInverseMomentumError(vHit, theta, beamSpot->sigmaZ(),vhMomHelper->transverseMomentum(vHit,magField)), 2); + mat[0][0] = pow( + computeInverseMomentumError(vHit, theta, beamSpot->sigmaZ(), vhMomHelper->transverseMomentum(vHit, magField)), 2); //building tsos LocalTrajectoryError lterr(asSMatrix<5>(mat)); @@ -306,7 +306,7 @@ float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const do float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, const float globalTheta, const double sigmaZ_beamSpot, - const double transverseMomentum) { + const double transverseMomentum) { //for pT > 2GeV, 1/pT has sigma = 1/sqrt(12) float varianceInverseTransvMomentum = 1. / 12; double derivativeTheta2 = pow(cos(globalTheta) / transverseMomentum, 2); From 472b65acbeb2bbdb583617b41ecb30d0f85a7ad5 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Thu, 3 Sep 2020 06:49:25 -0500 Subject: [PATCH 031/115] fix missing initializations --- .../interface/VectorHitMomentumHelper.h | 2 +- .../SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc | 2 +- RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h index eb33c3e090368..eaa42ff4da6d1 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h @@ -6,7 +6,7 @@ class VectorHitMomentumHelper { public: - VectorHitMomentumHelper(); + VectorHitMomentumHelper() {} ~VectorHitMomentumHelper() {} float transverseMomentum(VectorHit& vh, const MagneticField* magField) { diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 095022ddfd498..03a8fae76734e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -624,7 +624,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } //curvature - VectorHitMomentumHelper* vhMomHelper; + VectorHitMomentumHelper* vhMomHelper = new VectorHitMomentumHelper; curvature = vh.curvatureORphi("curvature").first; phi = vh.curvatureORphi("phi").first; QOverPT = vhMomHelper->transverseMomentum(vh, magField); diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 87f010f69eaaf..4fa5d68979303 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -247,7 +247,7 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& const Local3DVector lv(vHit.det()->surface().toLocal(gv)); //Helper class to access momentum of VH - VectorHitMomentumHelper* vhMomHelper; + VectorHitMomentumHelper* vhMomHelper = new VectorHitMomentumHelper; //FIXME::charge is fine 1 every two times!! int charge = 1; From 7725ff0678c73ac1f12ed5b2cbb34a070ee54c97 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Thu, 3 Sep 2020 08:54:54 -0500 Subject: [PATCH 032/115] trying to work around memory leaks --- .../interface/VectorHitMomentumHelper.h | 4 ++-- .../test/VectorHitsValidation.cc | 7 ++++--- .../SiPhase2VectorHitBuilder/test/VectorHitsValidation.h | 3 +++ .../TkSeedGenerator/interface/SeedingOTEDProducer.h | 5 +++++ RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc | 9 ++++----- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h index eaa42ff4da6d1..3959b0df1c04e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h @@ -9,14 +9,14 @@ class VectorHitMomentumHelper { VectorHitMomentumHelper() {} ~VectorHitMomentumHelper() {} - float transverseMomentum(VectorHit& vh, const MagneticField* magField) { + float transverseMomentum(VectorHit& vh, const MagneticField* magField) const { GlobalPoint center(0.0, 0.0, 0.0); float magnT = magField->inTesla(center).mag(); double rho = 1. / vh.curvatureORphi("curvature").first; //0.003 is because the curvature (rho) is in cm and not in m return (0.003 * magnT * rho); } - float momentum(VectorHit& vh, const MagneticField* magField) { + float momentum(VectorHit& vh, const MagneticField* magField) const { return transverseMomentum(vh, magField) / (1. * sin(vh.theta())); } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 03a8fae76734e..df918af05c770 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -7,7 +7,6 @@ #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet& conf) : cpeTag_(conf.getParameter("CPE")) { @@ -21,9 +20,12 @@ VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet simVerticesToken_ = consumes(edm::InputTag("g4SimHits")); trackingParticleToken_ = consumes(conf.getParameter("trackingParticleSrc")); + vhMomHelper = new VectorHitMomentumHelper(); } -VectorHitsBuilderValidation::~VectorHitsBuilderValidation() {} +VectorHitsBuilderValidation::~VectorHitsBuilderValidation() { + delete vhMomHelper; +} void VectorHitsBuilderValidation::beginJob() { edm::Service fs; @@ -624,7 +626,6 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } //curvature - VectorHitMomentumHelper* vhMomHelper = new VectorHitMomentumHelper; curvature = vh.curvatureORphi("curvature").first; phi = vh.curvatureORphi("phi").first; QOverPT = vhMomHelper->transverseMomentum(vh, magField); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index 89f0e93acea6a..99f2c967bee6b 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -27,6 +27,7 @@ #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" #include "DataFormats/SiPixelDigi/interface/PixelDigi.h" #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" #include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h" #include "SimDataFormats/Track/interface/SimTrackContainer.h" @@ -143,4 +144,6 @@ class VectorHitsBuilderValidation : public edm::EDAnalyzer { TH1F* VHrejTrueLayer_ratio; std::map histograms_; + + const VectorHitMomentumHelper* vhMomHelper; }; diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h index 1c140a9235c28..41a99f54178fe 100644 --- a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h +++ b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h @@ -16,6 +16,7 @@ #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" #include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -71,6 +72,10 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT beamSpotToken; const reco::BeamSpot* beamSpot; std::string updatorName; + //Helper class to access momentum of VH + const VectorHitMomentumHelper* vhMomHelper; + + }; #endif diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 4fa5d68979303..8f4bf93132930 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -16,7 +16,6 @@ #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) : theUpdator(nullptr), @@ -24,10 +23,13 @@ SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) vhProducerToken = consumes(edm::InputTag(conf.getParameter("src"))); beamSpotToken = consumes(conf.getParameter("beamSpotLabel")); updatorName = conf.getParameter("updator"); + vhMomHelper = new VectorHitMomentumHelper(); produces(); } -SeedingOTEDProducer::~SeedingOTEDProducer() {} +SeedingOTEDProducer::~SeedingOTEDProducer() { + delete vhMomHelper; +} void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -246,9 +248,6 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& // gv transform to local (lv) const Local3DVector lv(vHit.det()->surface().toLocal(gv)); - //Helper class to access momentum of VH - VectorHitMomentumHelper* vhMomHelper = new VectorHitMomentumHelper; - //FIXME::charge is fine 1 every two times!! int charge = 1; float p = vhMomHelper->momentum(vHit, magField); From ac77617a19b371c75a5dc6e24b2cc34fe0b5f530 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Thu, 3 Sep 2020 09:04:12 -0500 Subject: [PATCH 033/115] apply code format --- .../SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc | 4 +--- .../TkSeedGenerator/interface/SeedingOTEDProducer.h | 2 -- RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc | 7 ++----- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index df918af05c770..42a499ef409db 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -23,9 +23,7 @@ VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet vhMomHelper = new VectorHitMomentumHelper(); } -VectorHitsBuilderValidation::~VectorHitsBuilderValidation() { - delete vhMomHelper; -} +VectorHitsBuilderValidation::~VectorHitsBuilderValidation() { delete vhMomHelper; } void VectorHitsBuilderValidation::beginJob() { edm::Service fs; diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h index 41a99f54178fe..f1936acf5ed9a 100644 --- a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h +++ b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h @@ -74,8 +74,6 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { std::string updatorName; //Helper class to access momentum of VH const VectorHitMomentumHelper* vhMomHelper; - - }; #endif diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 8f4bf93132930..0523d38b222d5 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -16,20 +16,17 @@ #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" - SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) : theUpdator(nullptr), tkMeasEventToken(consumes(conf.getParameter("trackerEvent"))) { vhProducerToken = consumes(edm::InputTag(conf.getParameter("src"))); beamSpotToken = consumes(conf.getParameter("beamSpotLabel")); updatorName = conf.getParameter("updator"); - vhMomHelper = new VectorHitMomentumHelper(); + vhMomHelper = new VectorHitMomentumHelper(); produces(); } -SeedingOTEDProducer::~SeedingOTEDProducer() { - delete vhMomHelper; -} +SeedingOTEDProducer::~SeedingOTEDProducer() { delete vhMomHelper; } void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; From 5f6110a05c5db5dba32317ceabc5ac5a57224480 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Thu, 3 Sep 2020 14:28:29 -0500 Subject: [PATCH 034/115] register consumes of ES products in SeedingOTEDProducer --- .../interface/SeedingOTEDProducer.h | 18 +++++++++ .../src/SeedingOTEDProducer.cc | 39 +++++++------------ 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h index f1936acf5ed9a..12cd02d30b944 100644 --- a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h +++ b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h @@ -18,6 +18,16 @@ #include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" #include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" +#include "RecoTracker/Record/interface/CkfComponentsRecord.h" +#include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" +#include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" +#include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h" +#include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h" + +#include "Geometry/Records/interface/TrackerTopologyRcd.h" + +#include "FWCore/Utilities/interface/ESGetToken.h" + #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -74,6 +84,14 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { std::string updatorName; //Helper class to access momentum of VH const VectorHitMomentumHelper* vhMomHelper; + + edm::ESGetToken topoToken_; + edm::ESGetToken propagatorToken_; + edm::ESGetToken magFieldToken_; + edm::ESGetToken updatorToken_; + edm::ESGetToken measurementTrackerToken_; + edm::ESGetToken estToken_; + }; #endif diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 0523d38b222d5..9e9f15110008f 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -1,13 +1,6 @@ #include "RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h" #include "FWCore/Framework/interface/Event.h" -#include "Geometry/Records/interface/TrackerTopologyRcd.h" - -#include "RecoTracker/Record/interface/CkfComponentsRecord.h" -#include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" -#include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" -#include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h" -#include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h" #include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" @@ -18,7 +11,13 @@ SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) : theUpdator(nullptr), - tkMeasEventToken(consumes(conf.getParameter("trackerEvent"))) { + tkMeasEventToken(consumes(conf.getParameter("trackerEvent"))), + topoToken_(esConsumes()), + propagatorToken_(esConsumes(edm::ESInputTag("", "PropagatorWithMaterial" ))), + magFieldToken_(esConsumes()), + updatorToken_(esConsumes()), + measurementTrackerToken_(esConsumes()), + estToken_(esConsumes(edm::ESInputTag("","Chi2"))) { vhProducerToken = consumes(edm::InputTag(conf.getParameter("src"))); beamSpotToken = consumes(conf.getParameter("beamSpotLabel")); updatorName = conf.getParameter("updator"); @@ -40,33 +39,25 @@ void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descr void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { std::unique_ptr seedsWithVHs(new TrajectorySeedCollection()); - edm::ESHandle tTopoHandle; - es.get().get(tTopoHandle); - tkTopo = tTopoHandle.product(); + + tkTopo = &es.getData(topoToken_); edm::ESHandle measurementTrackerHandle; - es.get().get(measurementTrackerHandle); + measurementTrackerHandle = es.getHandle(measurementTrackerToken_); measurementTracker = measurementTrackerHandle.product(); + edm::Handle measurementTrackerEvent; event.getByToken(tkMeasEventToken, measurementTrackerEvent); layerMeasurements = new LayerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); - edm::ESHandle est; - es.get().get("Chi2", est); - estimator = est.product(); + estimator = &es.getData(estToken_); - edm::ESHandle prop; - es.get().get("PropagatorWithMaterial", prop); - propagator = prop.product(); + propagator = &es.getData(propagatorToken_); - edm::ESHandle magFieldHandle; - es.get().get(magFieldHandle); - magField = magFieldHandle.product(); + magField = &es.getData(magFieldToken_); - edm::ESHandle updatorHandle; - es.get().get(updatorName, updatorHandle); - theUpdator = updatorHandle.product(); + theUpdator = &es.getData(updatorToken_); edm::Handle beamSpotH; event.getByToken(beamSpotToken, beamSpotH); From b77526666614a8ca0603e488066e3cf2d19cf2da Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Thu, 3 Sep 2020 18:11:30 -0500 Subject: [PATCH 035/115] addressing PR comments part I --- .../TrackerRecHit2D/interface/VectorHit.h | 30 ++- .../TrackerRecHit2D/interface/VectorHit2D.h | 24 ++- .../interface/trackerHitRTTI.h | 4 +- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 36 ++-- DataFormats/TrackerRecHit2D/src/classes.h | 174 ------------------ .../TrackerRecHit2D/src/classes_def.xml | 8 +- .../interface/VectorHitMomentumHelper.h | 22 ++- .../test/VectorHitsValidation.cc | 12 +- .../test/VectorHitsValidation.h | 1 - .../interface/SeedingOTEDProducer.h | 2 - .../src/SeedingOTEDProducer.cc | 15 +- 11 files changed, 80 insertions(+), 248 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 3f9d0277befa9..712cee801d461 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -1,5 +1,5 @@ -#ifndef TrackerRecHit2D_VectorHit_h -#define TrackerRecHit2D_VectorHit_h +#ifndef DataFormats_TrackerRecHit2D_VectorHit_h +#define DataFormats_TrackerRecHit2D_VectorHit_h /** \class VectorHit * @@ -23,9 +23,9 @@ #include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h" -#include "TkCloner.h" +#include "DataFormats/TrackerRecHit2D/interface/TkCloner.h" -class VectorHit : public BaseTrackerRecHit { +class VectorHit final : public BaseTrackerRecHit { public: typedef OmniClusterRef::Phase2Cluster1DRef ClusterRef; @@ -37,7 +37,7 @@ class VectorHit : public BaseTrackerRecHit { const LocalPoint& posInner, const LocalVector& dir, const AlgebraicSymMatrix& covMatrix, - const double& Chi2, + const float chi2, OmniClusterRef const& lower, OmniClusterRef const& upper); @@ -50,9 +50,7 @@ class VectorHit : public BaseTrackerRecHit { ~VectorHit() override; VectorHit* clone() const override { return new VectorHit(*this); } -#ifndef __GCCXML__ RecHitPointer cloneSH() const override { return std::make_shared(*this); } -#endif bool sharesInput(const TrackingRecHit* other, SharedInputType what) const override; bool sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedInputType what) const; @@ -78,11 +76,15 @@ class VectorHit : public BaseTrackerRecHit { virtual LocalError localDirectionError() const; Global3DVector globalDirection() const; - virtual double chi2() const { return theChi2; } + virtual float chi2() const { return theChi2; } int dimension() const override { return theDimension; } - std::pair curvatureORphi(std::string curvORphi = "curvature") const; + + enum curvatureOrPhi { curvatureMode, phiMode }; + + std::pair curvatureORphi(curvatureOrPhi curvatureMode) const; + /// "lower" is logical, not geometrically lower; in pixel-strip modules the "lower" is always a pixel ClusterRef lowerCluster() const { return theLowerCluster.cluster_phase2OT(); } ClusterRef upperCluster() const { return theUpperCluster.cluster_phase2OT(); } OmniClusterRef const lowerClusterRef() const { return theLowerCluster; } @@ -104,7 +106,7 @@ class VectorHit : public BaseTrackerRecHit { //This method returns the delta in global coordinates Global3DVector globalDelta() const; - float theta(); + float theta() const; /// The projection matrix relates the trajectory state parameters to the segment parameters(). AlgebraicMatrix projectionMatrix() const override; @@ -138,18 +140,14 @@ class VectorHit : public BaseTrackerRecHit { // mat[0][2]=cov(dx/dz,x) // mat[1][3]=cov(dy/dz,y) AlgebraicSymMatrix theCovMatrix; - double theChi2; + float theChi2; int theDimension; OmniClusterRef theLowerCluster; OmniClusterRef theUpperCluster; }; inline bool operator<(const VectorHit& one, const VectorHit& other) { - if (one.chi2() < other.chi2()) { - return true; - } - - return false; + return (one.chi2() < other.chi2()); } std::ostream& operator<<(std::ostream& os, const VectorHit& vh); diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index 88cea12308bf7..a30c92f2e20ad 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -1,32 +1,36 @@ -#ifndef TrackerRecHit2D_VectorHit2D_h -#define TrackerRecHit2D_VectorHit2D_h +#ifndef DataFormats_TrackerRecHit2D_VectorHit2D_h +#define DataFormats_TrackerRecHit2D_VectorHit2D_h #include "DataFormats/GeometryVector/interface/LocalVector.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" #include "DataFormats/CLHEP/interface/AlgebraicObjects.h" #include "DataFormats/GeometrySurface/interface/LocalError.h" +//Stores geometric information about VectorHits, their convariance matrix and chi2 of the compatability of the two hits + class VectorHit2D { public: VectorHit2D() : thePosition(), theDirection(), theCovMatrix(), theChi2(), theDimension(2) {} VectorHit2D(const LocalPoint& pos, const LocalVector& dir, const AlgebraicSymMatrix22& covMatrix, const double& Chi2) - : thePosition(pos), theDirection(dir), theCovMatrix(covMatrix), theChi2(Chi2), theDimension(2){}; + : thePosition(pos), theDirection(dir), theCovMatrix(covMatrix), theLocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]), theChi2(Chi2), theDimension(2){}; virtual ~VectorHit2D(){}; - LocalPoint localPosition() const { return thePosition; } - LocalVector localDirection() const { return theDirection; } - LocalError localDirectionError() const { - return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); + const LocalPoint* localPosition() const { return &thePosition; } + const LocalVector* localDirection() const { return &theDirection; } + const LocalError* localDirectionError() const { + //return &LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); + return &theLocalError; } - AlgebraicSymMatrix22 covMatrix() const { return theCovMatrix; } - double chi2() const { return theChi2; } + const AlgebraicSymMatrix22* covMatrix() const { return &theCovMatrix; } + float chi2() const { return theChi2; } int dimension() const { return 2; } private: LocalPoint thePosition; LocalVector theDirection; AlgebraicSymMatrix22 theCovMatrix; - double theChi2; + LocalError theLocalError; + float theChi2; int theDimension; }; #endif diff --git a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h index db8579d0db982..62c10afc74ee8 100644 --- a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h +++ b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h @@ -33,9 +33,9 @@ namespace trackerHitRTTI { inline bool isMatched(TrackingRecHit const& hit) { return rtti(hit) == match || rtti(hit) == fastMatch; } inline bool isMulti(TrackingRecHit const& hit) { return rtti(hit) == multi; } inline bool isSingleType(TrackingRecHit const& hit) { return (rtti(hit) > 0) & (rtti(hit) < 4); } - inline bool isFromDet(TrackingRecHit const& hit) { return (rtti(hit) > 0) & (rtti(hit) < 6); } + inline bool isFromDet(TrackingRecHit const& hit) { return ((rtti(hit) > 0) & (rtti(hit) < 6) || (rtti(hit) == 12)); } inline bool isFast(TrackingRecHit const& hit) { return (rtti(hit) > 5) & (rtti(hit) <= 9); } - inline bool isFromDetOrFast(TrackingRecHit const& hit) { return (rtti(hit) > 0) & (rtti(hit) < 10); } + inline bool isFromDetOrFast(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 10)) || (rtti(hit) == 12)); } inline bool isTiming(TrackingRecHit const& hit) { return rtti(hit) == mipTiming; } inline bool isVector(TrackingRecHit const& hit) { return rtti(hit) == vector; } inline unsigned int projId(TrackingRecHit const& hit) { return hit.rawId() + int(rtti(hit)) - 1; } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 9cd3fe81a3ea1..dbb169193922c 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -15,14 +15,14 @@ VectorHit::VectorHit(const GeomDet& idet, const LocalPoint& posLower, const LocalVector& dir, const AlgebraicSymMatrix& covMatrix, - const double& Chi2, + const float chi2, OmniClusterRef const& lower, OmniClusterRef const& upper) : BaseTrackerRecHit(idet, trackerHitRTTI::vector), thePosition(posLower), theDirection(dir), theCovMatrix(covMatrix), - theChi2(Chi2), + theChi2(chi2), theDimension(4), theLowerCluster(lower), theUpperCluster(upper) {} @@ -33,13 +33,13 @@ VectorHit::VectorHit(const GeomDet& idet, OmniClusterRef const& lower, OmniClusterRef const& upper) : BaseTrackerRecHit(idet, trackerHitRTTI::vector), theDimension(4), theLowerCluster(lower), theUpperCluster(upper) { - thePosition = LocalPoint(vh2Dzx.localPosition().x(), vh2Dzy.localPosition().x(), 0.); + thePosition = LocalPoint(vh2Dzx.localPosition()->x(), vh2Dzy.localPosition()->x(), 0.); - theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), 1.); + theDirection = LocalVector(vh2Dzx.localDirection()->x(), vh2Dzy.localDirection()->x(), 1.); //building the cov matrix 4x4 starting from the 2x2 - AlgebraicSymMatrix22 covMatZX = vh2Dzx.covMatrix(); - AlgebraicSymMatrix22 covMatZY = vh2Dzy.covMatrix(); + const AlgebraicSymMatrix22 covMatZX = *vh2Dzx.covMatrix(); + const AlgebraicSymMatrix22 covMatZY = *vh2Dzy.covMatrix(); theCovMatrix = AlgebraicSymMatrix(4); theCovMatrix[0][0] = covMatZX[0][0]; // var(dx/dz) @@ -167,10 +167,10 @@ Global3DVector VectorHit::globalDelta() const { Global3DVector VectorHit::globalDirection() const { return (det()->surface().toGlobal(localDirection())); } -std::pair VectorHit::curvatureORphi(std::string curvORphi) const { - double curvature = -999.; - double errorCurvature = -999.; - double phi = -999.; +std::pair VectorHit::curvatureORphi(curvatureOrPhi curvORphi) const { + float curvature = -999.; + float errorCurvature = -999.; + float phi = -999.; //global pos and errors Global3DPoint gPositionLower = lowerGlobalPos(); @@ -187,7 +187,7 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const gErrorUpper = lowerGlobalPosErr(); } - double h1 = gPositionLower.x() * gPositionUpper.y() - gPositionUpper.x() * gPositionLower.y(); + float h1 = gPositionLower.x() * gPositionUpper.y() - gPositionUpper.x() * gPositionLower.y(); //determine sign of curvature AlgebraicVector2 n1; @@ -338,16 +338,14 @@ std::pair VectorHit::curvatureORphi(std::string curvORphi) const } else { return std::make_pair(0.0, 0.0); } - - if (curvORphi == "curvature") - return std::make_pair(curvature, errorCurvature); - else if (curvORphi == "phi") - return std::make_pair(phi, 0.0); - else - return std::make_pair(0.0, 0.0); + switch(curvORphi){ + case curvatureMode : return std::make_pair(curvature, errorCurvature); + case phiMode : return std::make_pair(phi, 0.0); + } + return std::make_pair(0.0, 0.0); } -float VectorHit::theta() { return globalDirection().theta(); } +float VectorHit::theta() const { return globalDirection().theta(); } AlgebraicMatrix VectorHit::projectionMatrix() const { // obsolete (for what tracker is concerned...) interface diff --git a/DataFormats/TrackerRecHit2D/src/classes.h b/DataFormats/TrackerRecHit2D/src/classes.h index 98ba7a9edea20..03140aa37a5bb 100644 --- a/DataFormats/TrackerRecHit2D/src/classes.h +++ b/DataFormats/TrackerRecHit2D/src/classes.h @@ -31,178 +31,4 @@ #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include -namespace DataFormats_TrackerRecHit2D { - struct dictionary { - ProjectedSiStripRecHit2D projHit; - SiStripRecHit2D a1; - SiStripRecHit1D a11; - SiStripMatchedRecHit2D a2; - SiPixelRecHit b1; - - edm::ClonePolicy a4; - edm::ClonePolicy a44; - edm::ClonePolicy a5; - edm::ClonePolicy b2; - edm::ClonePolicy e2; - - edm::OwnVector> a6; - edm::OwnVector>::const_iterator it6; - edm::OwnVector> a66; - edm::OwnVector>::const_iterator it66; - edm::OwnVector> a7; - edm::OwnVector>::const_iterator it7; - edm::OwnVector> b3; - edm::OwnVector>::const_iterator it3; - edm::OwnVector> e3; - edm::OwnVector>::const_iterator it10; - - edm::OwnVector ovbtrh; - edm::Wrapper> wovbtrh; - - edm::Wrapper>, - edm::ClonePolicy>> - siStripRecHit2DLocalPosCollectionWrapper; - edm::RangeMap>, - edm::ClonePolicy>::id_iterator it2d; - - edm::Wrapper>, - edm::ClonePolicy>> - siStripRecHit1DLocalPosCollectionWrapper; - edm::RangeMap>, - edm::ClonePolicy>::id_iterator it1d; - - edm::Wrapper>, - edm::ClonePolicy>> - siStripRecHit2DMatchedLocalPosCollectionWrapper; - edm::RangeMap>, - edm::ClonePolicy>::id_iterator itmatch; - - edm::Wrapper>, - edm::ClonePolicy>> - siPixelRecHitCollectionWrapper; - edm::RangeMap>, - edm::ClonePolicy>::id_iterator itpix; - - edm::Ref>, - edm::ClonePolicy>, - SiStripRecHit2D, - edm::refhelper::FindUsingAdvance< - edm::RangeMap>, - edm::ClonePolicy>, - SiStripRecHit2D>> - refRangeMapDetIdOwnVectorSiStripRecHit2D; - edm::RefVector>, - edm::ClonePolicy>, - SiStripRecHit2D, - edm::refhelper::FindUsingAdvance< - edm::RangeMap>, - edm::ClonePolicy>, - SiStripRecHit2D>> - refVectorRangeMapDetIdOwnVectorSiStripRecHit2D; - - edm::Ref>, - edm::ClonePolicy>, - SiStripRecHit1D, - edm::refhelper::FindUsingAdvance< - edm::RangeMap>, - edm::ClonePolicy>, - SiStripRecHit1D>> - refRangeMapDetIdOwnVectorSiStripRecHit1D; - edm::RefVector>, - edm::ClonePolicy>, - SiStripRecHit1D, - edm::refhelper::FindUsingAdvance< - edm::RangeMap>, - edm::ClonePolicy>, - SiStripRecHit1D>> - refVectorRangeMapDetIdOwnVectorSiStripRecHit1D; - - edm::Wrapper> wdstvDummy1; - edm::Wrapper> wdstvDummy11; - edm::Wrapper> wdstvDummy2; - edm::Wrapper> wdstvDummy3; - - edm::Wrapper clusterRemovalInfo; - - edm::OwnVector> fastsimTrackerRecHitCollection; - edm::Wrapper>> - fastsimTrackerRecHitCollection_Wrapper; - - std::vector< - edm::Ref>, - FastTrackerRecHit, - edm::refhelper::FindUsingAdvance>, - FastTrackerRecHit>>> - fastsimTrackerRecHitRefCollection; - - edm::Wrapper>, - FastTrackerRecHit, - edm::refhelper::FindUsingAdvance>, - FastTrackerRecHit>>>> - fastsimTrackerRecHitRefCollection_Wrapper; - - std::vector>> fastsimTrackerRecHitCombinations; - edm::Wrapper>>> - fastsimTrackerRecHitCombinations_Wrapper; - - std::vector>, - FastTrackerRecHit, - edm::refhelper::FindUsingAdvance>, - FastTrackerRecHit>>>> - fastSimTrackerRecHitCombinationCollection; - edm::Wrapper>, - FastTrackerRecHit, - edm::refhelper::FindUsingAdvance>, - FastTrackerRecHit>>>>> - fastSimTrackerRecHitCombinationCollection_Wrapper; - - edm::Ref< - vector>, - FastTrackerRecHit, - edm::refhelper::FindUsingAdvance>, - FastTrackerRecHit>>>>, - vector>, - FastTrackerRecHit, - edm::refhelper::FindUsingAdvance>, - FastTrackerRecHit>>>, - edm::refhelper::FindUsingAdvance< - vector>, - FastTrackerRecHit, - edm::refhelper::FindUsingAdvance>, - FastTrackerRecHit>>>>, - vector>, - FastTrackerRecHit, - edm::refhelper::FindUsingAdvance>, - FastTrackerRecHit>>>>> - fastSimTrackerRecHitCombinationRef; - - VectorHitCollectionNew vhc1_new; - edm::RefProd vhc1_new2; - edm::Wrapper wh1_new; - }; -} // namespace DataFormats_TrackerRecHit2D - #endif // SISTRIPRECHIT_CLASSES_H diff --git a/DataFormats/TrackerRecHit2D/src/classes_def.xml b/DataFormats/TrackerRecHit2D/src/classes_def.xml index 87a581c22987b..569ec40801614 100644 --- a/DataFormats/TrackerRecHit2D/src/classes_def.xml +++ b/DataFormats/TrackerRecHit2D/src/classes_def.xml @@ -189,11 +189,11 @@ - - + + - - + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h index 3959b0df1c04e..ecbae466fa2fb 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h @@ -6,21 +6,25 @@ class VectorHitMomentumHelper { public: - VectorHitMomentumHelper() {} + VectorHitMomentumHelper(const MagneticField* magField) { + GlobalPoint center(0.0, 0.0, 0.0); + intermediate = magField->inTesla(center).mag() * 0.003; + //0.003 is because the curvature (rho) is in cm and not in m +} ~VectorHitMomentumHelper() {} - float transverseMomentum(VectorHit& vh, const MagneticField* magField) const { - GlobalPoint center(0.0, 0.0, 0.0); - float magnT = magField->inTesla(center).mag(); - double rho = 1. / vh.curvatureORphi("curvature").first; - //0.003 is because the curvature (rho) is in cm and not in m - return (0.003 * magnT * rho); + float transverseMomentum(VectorHit& vh) const { + float rho = 1. / vh.curvatureORphi(VectorHit::curvatureMode).first; + return (intermediate * rho); } - float momentum(VectorHit& vh, const MagneticField* magField) const { - return transverseMomentum(vh, magField) / (1. * sin(vh.theta())); + float momentum(VectorHit& vh) const { + return transverseMomentum(vh) / (1. * sin(vh.theta())); } private: + + float intermediate; + }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 42a499ef409db..957dd83bd1f49 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -20,10 +20,9 @@ VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet simVerticesToken_ = consumes(edm::InputTag("g4SimHits")); trackingParticleToken_ = consumes(conf.getParameter("trackingParticleSrc")); - vhMomHelper = new VectorHitMomentumHelper(); } -VectorHitsBuilderValidation::~VectorHitsBuilderValidation() { delete vhMomHelper; } +VectorHitsBuilderValidation::~VectorHitsBuilderValidation() { } void VectorHitsBuilderValidation::beginJob() { edm::Service fs; @@ -623,11 +622,12 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev continue; } + VectorHitMomentumHelper vhMomHelper(magField); //curvature - curvature = vh.curvatureORphi("curvature").first; - phi = vh.curvatureORphi("phi").first; - QOverPT = vhMomHelper->transverseMomentum(vh, magField); - QOverP = vhMomHelper->momentum(vh, magField); + curvature = vh.curvatureORphi(VectorHit::curvatureMode).first; + phi = vh.curvatureORphi(VectorHit::phiMode).first; + QOverPT = vhMomHelper.transverseMomentum(vh); + QOverP = vhMomHelper.momentum(vh); histogramLayer->second.curvature->Fill(curvature); //stub width diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index 99f2c967bee6b..c8789005d222e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -145,5 +145,4 @@ class VectorHitsBuilderValidation : public edm::EDAnalyzer { std::map histograms_; - const VectorHitMomentumHelper* vhMomHelper; }; diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h index 12cd02d30b944..c74506255a9c2 100644 --- a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h +++ b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h @@ -82,8 +82,6 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT beamSpotToken; const reco::BeamSpot* beamSpot; std::string updatorName; - //Helper class to access momentum of VH - const VectorHitMomentumHelper* vhMomHelper; edm::ESGetToken topoToken_; edm::ESGetToken propagatorToken_; diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 9e9f15110008f..1bc7657c39386 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -21,11 +21,10 @@ SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) vhProducerToken = consumes(edm::InputTag(conf.getParameter("src"))); beamSpotToken = consumes(conf.getParameter("beamSpotLabel")); updatorName = conf.getParameter("updator"); - vhMomHelper = new VectorHitMomentumHelper(); produces(); } -SeedingOTEDProducer::~SeedingOTEDProducer() { delete vhMomHelper; } +SeedingOTEDProducer::~SeedingOTEDProducer() { } void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -49,7 +48,8 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) edm::Handle measurementTrackerEvent; event.getByToken(tkMeasEventToken, measurementTrackerEvent); - layerMeasurements = new LayerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); + //layerMeasurements = new LayerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); + LayerMeasurements layerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); estimator = &es.getData(estToken_); @@ -236,9 +236,14 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& // gv transform to local (lv) const Local3DVector lv(vHit.det()->surface().toLocal(gv)); + //Helper class to access momentum of VH + VectorHitMomentumHelper vhMomHelper(magField); + + + //FIXME::charge is fine 1 every two times!! int charge = 1; - float p = vhMomHelper->momentum(vHit, magField); + float p = vhMomHelper.momentum(vHit); float x = vHit.localPosition().x(); float y = vHit.localPosition().y(); float dx = vHit.localDirection().x(); @@ -252,7 +257,7 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p mat[0][0] = pow( - computeInverseMomentumError(vHit, theta, beamSpot->sigmaZ(), vhMomHelper->transverseMomentum(vHit, magField)), 2); + computeInverseMomentumError(vHit, theta, beamSpot->sigmaZ(), vhMomHelper.transverseMomentum(vHit)), 2); //building tsos LocalTrajectoryError lterr(asSMatrix<5>(mat)); From 142acec79464758ec2a431f7b24dc5126f8ca328 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 4 Sep 2020 12:11:50 -0500 Subject: [PATCH 036/115] addressing PR comments part II --- .../interface/trackerHitRTTI.h | 6 +- .../Records/interface/TkPhase2OTCPERecord.h | 2 +- .../SiPhase2RecHitMatcherESProducer.cc | 2 +- .../test/Clusters_productionAndTesting.py | 13 +++- .../test/VHs_combinatorialStudies_PU200.py | 4 +- .../plugins/TrackerRecoGeometryESProducer.cc | 6 +- .../TrackerRecoGeometryESProducer_cfi.py | 4 +- .../MeasurementTrackerESProducer_cfi.py | 6 +- .../interface/SeedingOTEDProducer.h | 24 +++--- .../src/SeedingOTEDProducer.cc | 77 +++++++++---------- 10 files changed, 74 insertions(+), 70 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h index 62c10afc74ee8..9d0a6bab0403d 100644 --- a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h +++ b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h @@ -33,9 +33,11 @@ namespace trackerHitRTTI { inline bool isMatched(TrackingRecHit const& hit) { return rtti(hit) == match || rtti(hit) == fastMatch; } inline bool isMulti(TrackingRecHit const& hit) { return rtti(hit) == multi; } inline bool isSingleType(TrackingRecHit const& hit) { return (rtti(hit) > 0) & (rtti(hit) < 4); } - inline bool isFromDet(TrackingRecHit const& hit) { return ((rtti(hit) > 0) & (rtti(hit) < 6) || (rtti(hit) == 12)); } + //inline bool isFromDet(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 6)) | (rtti(hit) == 12)); } + inline bool isFromDet(TrackingRecHit const& hit) { return ((rtti(hit) > 0) & (rtti(hit) < 6)); } inline bool isFast(TrackingRecHit const& hit) { return (rtti(hit) > 5) & (rtti(hit) <= 9); } - inline bool isFromDetOrFast(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 10)) || (rtti(hit) == 12)); } + inline bool isFromDetOrFast(TrackingRecHit const& hit) { return ((rtti(hit) > 0) & (rtti(hit) < 10)); } + //inline bool isFromDetOrFast(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 10)) | (rtti(hit) == 12)); } inline bool isTiming(TrackingRecHit const& hit) { return rtti(hit) == mipTiming; } inline bool isVector(TrackingRecHit const& hit) { return rtti(hit) == vector; } inline unsigned int projId(TrackingRecHit const& hit) { return hit.rawId() + int(rtti(hit)) - 1; } diff --git a/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h b/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h index 9423e0188ff5d..3a6925080a227 100644 --- a/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h +++ b/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h @@ -12,7 +12,7 @@ class TkPhase2OTCPERecord : public edm::eventsetup::DependentRecordImplementation > {}; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index dce044097bc78..3cb618a0c297c 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -41,7 +41,7 @@ std::shared_ptr SiPhase2RecHitMatcherESProducer::prod matcher_ = std::make_shared(pset_); edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); - edm::ESHandle tTopoHandle = iRecord.getHandle(trackerTopoToken_); + edm::ESHandle tTopoHandle = iRecord.getRecord().getHandle(trackerTopoToken_); auto ptr_phase2TrackerCPE = &iRecord.get(cpeToken_); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py index b257da7431545..7728a15e402a2 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py @@ -2,7 +2,7 @@ from Configuration.StandardSequences.Eras import eras -process = cms.Process('RECO',eras.Phase2C2) +process = cms.Process('RECO',eras.Phase2C9) # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') @@ -10,7 +10,7 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Configuration.Geometry.GeometryExtended2023D4Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.RawToDigi_cff') process.load('Configuration.StandardSequences.L1Reco_cff') @@ -33,7 +33,7 @@ # Input source process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('/store/relval/CMSSW_9_1_0_pre1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/90X_upgrade2023_realistic_v9_D4Timing-v1/00000/161D8583-1719-E711-BA42-0CC47A7C346E.root'), + fileNames = cms.untracked.vstring('/store/relval/CMSSW_11_1_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/FF928A27-31CB-9C4D-93E0-475E2E73326E.root'), secondaryFileNames = cms.untracked.vstring(), skipEvents = cms.untracked.uint32(0) ) @@ -75,7 +75,12 @@ # Analyzer process.analysis = cms.EDAnalyzer('Phase2TrackerClusterizerValidation', src = cms.InputTag("siPhase2Clusters"), - links = cms.InputTag("simSiPixelDigis", "Tracker") + links = cms.InputTag("simSiPixelDigis", "Tracker"), + simhitsbarrel = cms.InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof"), + simhitsendcap = cms.InputTag("g4SimHits", "TrackerHitsPixelEndcapLowTof"), + simtracks = cms.InputTag("g4SimHits"), + ECasRings = cms.bool(True), + SimTrackMinPt = cms.double(2.) ) #process.analysis = cms.EDAnalyzer('Phase2TrackerClusterizerValidationTGraph', diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py index a485506221930..70c46e4ea1d2e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py @@ -2,7 +2,7 @@ from Configuration.StandardSequences.Eras import eras -process = cms.Process('RECO',eras.Phase2C2) +process = cms.Process('RECO',eras.Phase2C9) # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') @@ -11,7 +11,7 @@ process.load('Configuration.EventContent.EventContent_cff') #process.load('SimGeneral.MixingModule.mixNoPU_cfi') process.load('SimGeneral.MixingModule.mix_POISSON_average_cfi') -process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.RawToDigi_cff') process.load('Configuration.StandardSequences.L1Reco_cff') diff --git a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc index 52a299f1eb172..5242ff422eef2 100644 --- a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc +++ b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc @@ -28,13 +28,13 @@ class TrackerRecoGeometryESProducer : public edm::ESProducer { private: edm::ESGetToken geomToken_; edm::ESGetToken tTopToken_; - bool _usePhase2Stacks; + bool usePhase2Stacks_; }; using namespace edm; TrackerRecoGeometryESProducer::TrackerRecoGeometryESProducer(const edm::ParameterSet &p) - : _usePhase2Stacks(p.getParameter("usePhase2Stacks")) { + : usePhase2Stacks_(p.getParameter("usePhase2Stacks")) { auto c = setWhatProduced(this); // 08-Oct-2007 - Patrick Janot @@ -52,7 +52,7 @@ std::unique_ptr TrackerRecoGeometryESProducer::produce( GeometricSearchTrackerBuilder builder; return std::unique_ptr( - builder.build(tG.trackerDet(), &tG, &iRecord.get(tTopToken_), _usePhase2Stacks)); + builder.build(tG.trackerDet(), &tG, &iRecord.get(tTopToken_), usePhase2Stacks_)); } void TrackerRecoGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 22d95e29034d3..9a87a93207ed2 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", - usePhase2Stacks = cms.bool(False) + usePhase2Stacks = cms.bool(True) ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) diff --git a/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py b/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py index ca5973895e619..a09c7c51b6597 100644 --- a/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py +++ b/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py @@ -5,5 +5,7 @@ MeasurementTracker = _MeasurementTrackerESProducer_default.clone() from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(MeasurementTracker, Phase2StripCPE = 'Phase2StripCPE') -trackingPhase2PU140.toModify(MeasurementTracker, Phase2HitMatcher = 'SiPhase2VectorHitMatcher') +trackingPhase2PU140.toModify(MeasurementTracker, + Phase2StripCPE = 'Phase2StripCPE', + Phase2HitMatcher = 'SiPhase2VectorHitMatcher' +) diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h index c74506255a9c2..76ef523f69194 100644 --- a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h +++ b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h @@ -70,18 +70,18 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { }; private: - edm::EDGetTokenT vhProducerToken; - const TrackerTopology* tkTopo; - const MeasurementTracker* measurementTracker; - const LayerMeasurements* layerMeasurements; - const MeasurementEstimator* estimator; - const Propagator* propagator; - const MagneticField* magField; - const TrajectoryStateUpdator* theUpdator; - const edm::EDGetTokenT tkMeasEventToken; - edm::EDGetTokenT beamSpotToken; - const reco::BeamSpot* beamSpot; - std::string updatorName; + edm::EDGetTokenT vhProducerToken_; + const TrackerTopology* tkTopo_; + const MeasurementTracker* measurementTracker_; + const LayerMeasurements* layerMeasurements_; + const MeasurementEstimator* estimator_; + const Propagator* propagator_; + const MagneticField* magField_; + const TrajectoryStateUpdator* updator_; + const edm::EDGetTokenT tkMeasEventToken_; + edm::EDGetTokenT beamSpotToken_; + const reco::BeamSpot* beamSpot_; + std::string updatorName_; edm::ESGetToken topoToken_; edm::ESGetToken propagatorToken_; diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc index 1bc7657c39386..d2ca0fa2ab34b 100644 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc @@ -10,17 +10,17 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) - : theUpdator(nullptr), - tkMeasEventToken(consumes(conf.getParameter("trackerEvent"))), + : updator_(nullptr), + tkMeasEventToken_(consumes(conf.getParameter("trackerEvent"))), topoToken_(esConsumes()), propagatorToken_(esConsumes(edm::ESInputTag("", "PropagatorWithMaterial" ))), magFieldToken_(esConsumes()), updatorToken_(esConsumes()), measurementTrackerToken_(esConsumes()), estToken_(esConsumes(edm::ESInputTag("","Chi2"))) { - vhProducerToken = consumes(edm::InputTag(conf.getParameter("src"))); - beamSpotToken = consumes(conf.getParameter("beamSpotLabel")); - updatorName = conf.getParameter("updator"); + vhProducerToken_ = consumes(edm::InputTag(conf.getParameter("src"))); + beamSpotToken_ = consumes(conf.getParameter("beamSpotLabel")); + updatorName_ = conf.getParameter("updator"); produces(); } @@ -39,40 +39,35 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) std::unique_ptr seedsWithVHs(new TrajectorySeedCollection()); - tkTopo = &es.getData(topoToken_); + tkTopo_ = &es.getData(topoToken_); edm::ESHandle measurementTrackerHandle; measurementTrackerHandle = es.getHandle(measurementTrackerToken_); - measurementTracker = measurementTrackerHandle.product(); + measurementTracker_ = measurementTrackerHandle.product(); edm::Handle measurementTrackerEvent; - event.getByToken(tkMeasEventToken, measurementTrackerEvent); + event.getByToken(tkMeasEventToken_, measurementTrackerEvent); - //layerMeasurements = new LayerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); - LayerMeasurements layerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); + LayerMeasurements layerMeasurements_(*measurementTrackerHandle, *measurementTrackerEvent); - estimator = &es.getData(estToken_); + estimator_ = &es.getData(estToken_); - propagator = &es.getData(propagatorToken_); + propagator_ = &es.getData(propagatorToken_); - magField = &es.getData(magFieldToken_); + magField_ = &es.getData(magFieldToken_); - theUpdator = &es.getData(updatorToken_); + updator_ = &es.getData(updatorToken_); edm::Handle beamSpotH; - event.getByToken(beamSpotToken, beamSpotH); + event.getByToken(beamSpotToken_, beamSpotH); if (beamSpotH.isValid()) { - beamSpot = beamSpotH.product(); + beamSpot_ = beamSpotH.product(); } // Get the vector hits edm::Handle vhs; - event.getByToken(vhProducerToken, vhs); - /* - edm::ESHandle< ClusterParameterEstimator > parameterestimator; - es.get().get(cpe, parameterestimator); - const Phase2StripCPEGeometric & cpeOT(*parameterestimator); -*/ + event.getByToken(vhProducerToken_, vhs); + TrajectorySeedCollection const& tempSeeds = run(vhs); for (TrajectorySeedCollection::const_iterator qIt = tempSeeds.begin(); qIt < tempSeeds.end(); ++qIt) { seedsWithVHs->push_back(*qIt); @@ -86,22 +81,22 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHseedsL1 = collectVHsOnLayer(VHs, 1); - std::vector VHseedsL2 = collectVHsOnLayer(VHs, 2); - std::vector VHseedsL3 = collectVHsOnLayer(VHs, 3); - if (VHseedsL1.empty() || VHseedsL2.empty() || VHseedsL3.empty()) { + std::vector vhSeedsL1 = collectVHsOnLayer(VHs, 1); + std::vector vhSeedsL2 = collectVHsOnLayer(VHs, 2); + std::vector vhSeedsL3 = collectVHsOnLayer(VHs, 3); + if (vhSeedsL1.empty() || vhSeedsL2.empty() || vhSeedsL3.empty()) { return result; } //seeds are built in the L3 of the OT - const BarrelDetLayer* barrelOTLayer2 = measurementTracker->geometricSearchTracker()->tobLayers().at(1); + const BarrelDetLayer* barrelOTLayer2 = measurementTracker_->geometricSearchTracker()->tobLayers().at(1); //the search propag directiondepend on the sign of signZ*signPz, while the building is always the contrary - Propagator* searchingPropagator = &*propagator->clone(); - Propagator* buildingPropagator = &*propagator->clone(); + Propagator* searchingPropagator = &*propagator_->clone(); + Propagator* buildingPropagator = &*propagator_->clone(); buildingPropagator->setPropagationDirection(alongMomentum); - for (auto hitL3 : VHseedsL3) { + for (auto hitL3 : vhSeedsL3) { //building a tsos out of a VectorHit const TrajectoryStateOnSurface initialTSOS = buildInitialTSOS(hitL3); float signZ = copysign(1.0, initialTSOS.globalPosition().z()); @@ -115,7 +110,7 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle measurementsL2 = - layerMeasurements->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + layerMeasurements_->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator_); //other options //LayerMeasurements::SimpleHitContainer hits; @@ -128,7 +123,7 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::HandlegeometricSearchTracker()->tobLayers().at(0); + const DetLayer* barrelOTLayer1 = measurementTracker_->geometricSearchTracker()->tobLayers().at(0); for (const auto& mL2 : measurementsL2) { const TrackingRecHit* hitL2 = mL2.recHit().get(); @@ -141,7 +136,7 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle measurementsL1 = - layerMeasurements->measurements(*barrelOTLayer1, updatedTSOS.second, *searchingPropagator, *estimator); + layerMeasurements_->measurements(*barrelOTLayer1, updatedTSOS.second, *searchingPropagator, *estimator_); std::vector::iterator measurementsL1end = std::remove_if(measurementsL1.begin(), measurementsL1.end(), isInvalid()); measurementsL1.erase(measurementsL1end, measurementsL1.end()); @@ -170,7 +165,7 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handleupdate(updatedTSOSL1.second, *hitL1); + TrajectoryStateOnSurface updatedTSOSL1_final = updator_->update(updatedTSOSL1.second, *hitL1); if UNLIKELY (!updatedTSOSL1_final.isValid()) continue; std::pair updatedTSOSL2_final = @@ -193,7 +188,7 @@ unsigned int SeedingOTEDProducer::checkLayer(unsigned int iidd) { StripSubdetector strip = StripSubdetector(iidd); unsigned int subid = strip.subdetId(); if (subid == StripSubdetector::TIB || subid == StripSubdetector::TOB) { - return tkTopo->layer(iidd); + return tkTopo_->layer(iidd); } return 0; } @@ -237,7 +232,7 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& const Local3DVector lv(vHit.det()->surface().toLocal(gv)); //Helper class to access momentum of VH - VectorHitMomentumHelper vhMomHelper(magField); + VectorHitMomentumHelper vhMomHelper(magField_); @@ -257,11 +252,11 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p mat[0][0] = pow( - computeInverseMomentumError(vHit, theta, beamSpot->sigmaZ(), vhMomHelper.transverseMomentum(vHit)), 2); + computeInverseMomentumError(vHit, theta, beamSpot_->sigmaZ(), vhMomHelper.transverseMomentum(vHit)), 2); //building tsos LocalTrajectoryError lterr(asSMatrix<5>(mat)); - const TrajectoryStateOnSurface tsos(ltpar2, lterr, vHit.det()->surface(), magField); + const TrajectoryStateOnSurface tsos(ltpar2, lterr, vHit.det()->surface(), magField_); return tsos; } @@ -282,7 +277,7 @@ AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) { std::pair SeedingOTEDProducer::propagateAndUpdate( const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit) { TrajectoryStateOnSurface propTSOS = prop.propagate(initialTSOS, hit.det()->surface()); - TrajectoryStateOnSurface updatedTSOS = theUpdator->update(propTSOS, hit); + TrajectoryStateOnSurface updatedTSOS = updator_->update(propTSOS, hit); if UNLIKELY (!updatedTSOS.isValid()) return std::make_pair(false, updatedTSOS); return std::make_pair(true, updatedTSOS); @@ -301,8 +296,8 @@ float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, const double transverseMomentum) { //for pT > 2GeV, 1/pT has sigma = 1/sqrt(12) float varianceInverseTransvMomentum = 1. / 12; - double derivativeTheta2 = pow(cos(globalTheta) / transverseMomentum, 2); - double derivativeInverseTransvMomentum2 = pow(sin(globalTheta), 2); + float derivativeTheta2 = pow(cos(globalTheta) / transverseMomentum, 2); + float derivativeInverseTransvMomentum2 = pow(sin(globalTheta), 2); float thetaError = computeGlobalThetaError(vh, sigmaZ_beamSpot); return pow(derivativeTheta2 * pow(thetaError, 2) + derivativeInverseTransvMomentum2 * varianceInverseTransvMomentum, 0.5); From ce1a3eabff4e0a05c9604fdc24155a9c58f9ba91 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 4 Sep 2020 12:57:55 -0500 Subject: [PATCH 037/115] addressing PR comments part III --- .../interface/VectorHitBuilderAlgorithmBase.h | 8 +--- .../SiPhase2RecHitMatcherESProducer.cc | 37 ++++++++++--------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index faf6769ecc578..ea72094901a29 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -13,13 +13,7 @@ #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" - -namespace edm { - class ParameterSet; - template - class RefGetter; - class EventSetup; -} // namespace edm +#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h" class VectorHitBuilderAlgorithmBase { public: diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 3cb618a0c297c..3d8f3dd9d3575 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -3,6 +3,7 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ModuleFactory.h" #include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Utilities/interface/EDMException.h" #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "RecoTracker/Record/interface/CkfComponentsRecord.h" @@ -15,11 +16,10 @@ class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { public: SiPhase2RecHitMatcherESProducer(const edm::ParameterSet&); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - std::shared_ptr produce(const TkPhase2OTCPERecord&); + std::unique_ptr produce(const TkPhase2OTCPERecord&); private: std::string name_; - std::shared_ptr matcher_; edm::ParameterSet pset_; edm::ESGetToken geometryToken_; edm::ESGetToken trackerTopoToken_; @@ -28,28 +28,31 @@ class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet& p) { name_ = p.getParameter("ComponentName"); + if (!(name_ == "SiPhase2VectorHitMatcher")){ + throw cms::Exception("ConfigurationError") + << "Configuration specifies unknown ComponentName .\n" + << "Currently only 'SiPhase2VectorHitMatcher' is supported\n"; + } pset_ = p; auto cc = setWhatProduced(this, name_); - geometryToken_ = cc.consumesFrom(); - trackerTopoToken_ = cc.consumesFrom(); - auto const P2otname = p.getParameter("CPE"); - cpeToken_ = cc.consumesFrom, TkPhase2OTCPERecord>(P2otname); + geometryToken_ = cc.consumes(); + trackerTopoToken_ = cc.consumes(); + cpeToken_ = cc.consumes(p.getParameter("CPE")); } -std::shared_ptr SiPhase2RecHitMatcherESProducer::produce(const TkPhase2OTCPERecord& iRecord) { - if (name_ == "SiPhase2VectorHitMatcher") { - matcher_ = std::make_shared(pset_); +std::unique_ptr SiPhase2RecHitMatcherESProducer::produce(const TkPhase2OTCPERecord& iRecord) { + std::unique_ptr matcher = std::make_unique(pset_); - edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); - edm::ESHandle tTopoHandle = iRecord.getRecord().getHandle(trackerTopoToken_); + edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); + edm::ESHandle tTopoHandle = iRecord.getRecord().getHandle(trackerTopoToken_); - auto ptr_phase2TrackerCPE = &iRecord.get(cpeToken_); + auto ptr_phase2TrackerCPE = &iRecord.get(cpeToken_); - matcher_->initTkGeom(tGeomHandle); - matcher_->initTkTopo(tTopoHandle); - matcher_->initCpe(ptr_phase2TrackerCPE); - } - return matcher_; + matcher->initTkGeom(tGeomHandle); + matcher->initTkTopo(tTopoHandle); + matcher->initCpe(ptr_phase2TrackerCPE); + + return matcher; } void SiPhase2RecHitMatcherESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { From 59037885d2bfe47ceb1ad70b23a71f38b803b9b5 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 4 Sep 2020 14:42:35 -0500 Subject: [PATCH 038/115] restructure constructor of VectorHitBuilderAlgorithm and changed VectorHitBuilderEDProdcuer to use VectorHitBuilderAlgorithm via the EventSetup --- .../interface/VectorHitBuilderAlgorithm.h | 10 ++--- .../interface/VectorHitBuilderAlgorithmBase.h | 21 ++++++----- .../interface/VectorHitBuilderEDProducer.h | 13 ++++--- .../SiPhase2RecHitMatcherESProducer.cc | 9 +++-- .../src/VectorHitBuilderAlgorithm.cc | 6 +-- .../src/VectorHitBuilderAlgorithmBase.cc | 31 ++++++++++------ .../src/VectorHitBuilderEDProducer.cc | 37 +++---------------- 7 files changed, 58 insertions(+), 69 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 72eb5c688aef6..32806969c560c 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -16,20 +16,20 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { public: - VectorHitBuilderAlgorithm(const edm::ParameterSet& conf) - : VectorHitBuilderAlgorithmBase(conf), theFitter(new LinearFit()){}; + VectorHitBuilderAlgorithm(const edm::ParameterSet& conf, const TrackerGeometry* tkGeomProd, const TrackerTopology* tkTopoProd, const ClusterParameterEstimator* cpeProd) + : VectorHitBuilderAlgorithmBase(conf, tkGeomProd, tkTopoProd, cpeProd ), theFitter(new LinearFit()){}; ~VectorHitBuilderAlgorithm() override { delete theFitter; }; void run(edm::Handle> clusters, VectorHitCollectionNew& vhAcc, VectorHitCollectionNew& vhRej, edmNew::DetSetVector& clustersAcc, - edmNew::DetSetVector& clustersRej) override; + edmNew::DetSetVector& clustersRej) const override; //not implemented yet bool checkClustersCompatibilityBeforeBuilding(edm::Handle> clusters, const detset& theLowerDetSet, - const detset& theUpperDetSet); + const detset& theUpperDetSet) const; bool checkClustersCompatibility(Local3DPoint& posinner, Local3DPoint& posouter, LocalError& errinner, @@ -54,7 +54,7 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { edm::Handle> clusters, const detset& DSVinner, const detset& DSVouter, - const std::vector& phase2OTClustersToSkip = std::vector()) override; + const std::vector& phase2OTClustersToSkip = std::vector()) const override; VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index ea72094901a29..8fd95d97096ba 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -23,11 +23,14 @@ class VectorHitBuilderAlgorithmBase { typedef edmNew::DetSetVector output_t; typedef std::pair> StackClusters; - VectorHitBuilderAlgorithmBase(const edm::ParameterSet&); + VectorHitBuilderAlgorithmBase(const edm::ParameterSet&, + const TrackerGeometry*, + const TrackerTopology*, + const ClusterParameterEstimator*); virtual ~VectorHitBuilderAlgorithmBase() {} - void initialize(const edm::EventSetup&); - void initTkGeom(edm::ESHandle tkGeomHandle); - void initTkTopo(edm::ESHandle tkTopoHandle); +// void initialize(const edm::EventSetup&); + void initTkGeom(const TrackerGeometry* tkGeomProd); + void initTkTopo(const TrackerTopology* tkTopoProd); void initCpe(const ClusterParameterEstimator* cpeProd); //FIXME::ERICA::this should be template, return different collection for different algo used!! @@ -35,14 +38,14 @@ class VectorHitBuilderAlgorithmBase { VectorHitCollectionNew& vhAcc, VectorHitCollectionNew& vhRej, edmNew::DetSetVector& clustersAcc, - edmNew::DetSetVector& clustersRej) = 0; + edmNew::DetSetVector& clustersRej) const = 0; virtual std::vector> buildVectorHits( const StackGeomDet* stack, edm::Handle> clusters, const detset& DSVinner, const detset& DSVouter, - const std::vector& phase2OTClustersToSkip = std::vector()) = 0; + const std::vector& phase2OTClustersToSkip = std::vector()) const = 0; virtual VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, @@ -51,10 +54,10 @@ class VectorHitBuilderAlgorithmBase { double computeParallaxCorrection(const PixelGeomDetUnit*&, const Point3DBase&, const PixelGeomDetUnit*&, - const Point3DBase&); + const Point3DBase&) const; - void printClusters(const edmNew::DetSetVector& clusters); - void printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* cluster); + void printClusters(const edmNew::DetSetVector& clusters) const; + void printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* cluster) const; void loadDetSetVector(std::map>& theMap, edmNew::DetSetVector& theCollection) const; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h index be5ae1ee0f4fd..0bbc94142534d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h @@ -11,7 +11,9 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h" #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include #include @@ -20,23 +22,22 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { public: explicit VectorHitBuilderEDProducer(const edm::ParameterSet&); ~VectorHitBuilderEDProducer() override; - void produce(edm::Event&, const edm::EventSetup&) override; - void setupAlgorithm(edm::ParameterSet const& conf); + void produce(edm::Event&, const edm::EventSetup&) override; void run(edm::Handle > clusters, edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, VectorHitCollectionNew& outputAcc, VectorHitCollectionNew& outputRej); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - VectorHitBuilderAlgorithmBase* algo() const { return stubsBuilder_; }; + const VectorHitBuilderAlgorithm* algo() const { return stubsBuilder_; }; private: - VectorHitBuilderAlgorithmBase* stubsBuilder_; + const VectorHitBuilderAlgorithm * stubsBuilder_; std::string offlinestubsTag_; unsigned int maxOfflinestubs_; - std::string algoTag_; + edm::ESGetToken stubsBuilderToken_; edm::EDGetTokenT > clusterProducer_; - bool readytobuild_; + }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 3d8f3dd9d3575..ac3d944ba5307 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -41,16 +41,19 @@ SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::Para } std::unique_ptr SiPhase2RecHitMatcherESProducer::produce(const TkPhase2OTCPERecord& iRecord) { - std::unique_ptr matcher = std::make_unique(pset_); + std::unique_ptr matcher = std::make_unique(pset_, + &iRecord.get(geometryToken_), + &iRecord.getRecord().get(trackerTopoToken_), + &iRecord.get(cpeToken_)); - edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); +/* edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); edm::ESHandle tTopoHandle = iRecord.getRecord().getHandle(trackerTopoToken_); auto ptr_phase2TrackerCPE = &iRecord.get(cpeToken_); matcher->initTkGeom(tGeomHandle); matcher->initTkTopo(tTopoHandle); - matcher->initCpe(ptr_phase2TrackerCPE); + matcher->initCpe(ptr_phase2TrackerCPE); */ return matcher; } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index fe3ccb1e35536..6448adf6be951 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -15,7 +15,7 @@ void VectorHitBuilderAlgorithm::run(edm::Handle& clustersAcc, - edmNew::DetSetVector& clustersRej) { + edmNew::DetSetVector& clustersRej) const { LogDebug("VectorHitBuilderAlgorithm") << "Run VectorHitBuilderAlgorithm ... \n"; const edmNew::DetSetVector* ClustersPhase2Collection = clusters.product(); @@ -101,7 +101,7 @@ void VectorHitBuilderAlgorithm::run(edm::Handle> clusters, const detset& theLowerDetSet, - const detset& theUpperDetSet) { + const detset& theUpperDetSet) const { if (theLowerDetSet.size() == 1 && theUpperDetSet.size() == 1) return true; @@ -132,7 +132,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi edm::Handle> clusters, const detset& theLowerDetSet, const detset& theUpperDetSet, - const std::vector& phase2OTClustersToSkip) { + const std::vector& phase2OTClustersToSkip) const { std::vector> result; if (checkClustersCompatibilityBeforeBuilding(clusters, theLowerDetSet, theUpperDetSet)) { LogDebug("VectorHitBuilderAlgorithm") << " compatible -> continue ... " << std::endl; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index 9c892f46af67b..fa54c5bd8a5d7 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -7,13 +7,22 @@ #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" -VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase(const edm::ParameterSet& conf) +VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase(const edm::ParameterSet& conf, + const TrackerGeometry* tkGeomProd, + const TrackerTopology* tkTopoProd, + const ClusterParameterEstimator* cpeProd) : nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), barrelCut(conf.getParameter >("BarrelCut")), endcapCut(conf.getParameter >("EndcapCut")), - cpeTag_(conf.getParameter("CPE")) {} + cpeTag_(conf.getParameter("CPE")) { -void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) { + initTkGeom(tkGeomProd); + initTkTopo(tkTopoProd); + initCpe(cpeProd); + +} + +/*void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) { // get the geometry and topology edm::ESHandle geomHandle; es.get().get(geomHandle); @@ -28,12 +37,12 @@ void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) { es.get().get(cpeTag_, cpeHandle); initCpe(cpeHandle.product()); } - -void VectorHitBuilderAlgorithmBase::initTkGeom(edm::ESHandle tkGeomHandle) { - theTkGeom = tkGeomHandle.product(); +*/ +void VectorHitBuilderAlgorithmBase::initTkGeom(const TrackerGeometry* tkGeomProd) { + theTkGeom = tkGeomProd; } -void VectorHitBuilderAlgorithmBase::initTkTopo(edm::ESHandle tkTopoHandle) { - theTkTopo = tkTopoHandle.product(); +void VectorHitBuilderAlgorithmBase::initTkTopo(const TrackerTopology* tkTopoProd) { + theTkTopo = tkTopoProd; } void VectorHitBuilderAlgorithmBase::initCpe(const ClusterParameterEstimator* cpeProd) { cpe = cpeProd; @@ -42,7 +51,7 @@ void VectorHitBuilderAlgorithmBase::initCpe(const ClusterParameterEstimator& lPosClu_low, const PixelGeomDetUnit*& geomDetUnit_upp, - const Point3DBase& lPosClu_upp) { + const Point3DBase& lPosClu_upp) const { double parallCorr = 0.0; Global3DPoint origin(0, 0, 0); Global3DPoint gPosClu_low = geomDetUnit_low->surface().toGlobal(lPosClu_low); @@ -61,7 +70,7 @@ double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomD return parallCorr; } -void VectorHitBuilderAlgorithmBase::printClusters(const edmNew::DetSetVector& clusters) { +void VectorHitBuilderAlgorithmBase::printClusters (const edmNew::DetSetVector& clusters) const { int nCluster = 0; int numberOfDSV = 0; edmNew::DetSetVector::const_iterator DSViter; @@ -84,7 +93,7 @@ void VectorHitBuilderAlgorithmBase::printClusters(const edmNew::DetSetVector(geomDetUnit); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc index 0f8ce6b7fac77..0e2f0f172e89c 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc @@ -1,14 +1,11 @@ #include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) : offlinestubsTag_(conf.getParameter("offlinestubs")), maxOfflinestubs_(conf.getParameter("maxVectorHits")), - algoTag_(conf.getParameter("Algorithm")), - //_clusterProducer(conf.getParameter("Clusters")), - readytobuild_(false) { + stubsBuilderToken_(esConsumes(conf.getParameter("Algorithm"))){ clusterProducer_ = consumes>(edm::InputTag(conf.getParameter("Clusters"))); @@ -16,7 +13,8 @@ VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& produces>("ClustersRejected"); produces(offlinestubsTag_ + "Accepted"); produces(offlinestubsTag_ + "Rejected"); - setupAlgorithm(conf); + + } VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; } @@ -36,11 +34,8 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu std::unique_ptr outputVHAccepted(new VectorHitCollectionNew()); std::unique_ptr outputVHRejected(new VectorHitCollectionNew()); - if (readytobuild_) - stubsBuilder_->initialize(es); - else - edm::LogError("VectorHitBuilderEDProducer") << "Impossible initialization of builder!!"; + stubsBuilder_ = &es.getData(stubsBuilderToken_); // check on the input clusters stubsBuilder_->printClusters(*clustersHandle); @@ -57,42 +52,20 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu LogDebug("VectorHitBuilderEDProducer") << "\t vectorhit in output " << *vh << std::endl; } } - /* - if(numberOfVectorHits > _maxOfflinestubs) { - edm::LogError("VectorHitBuilderEDProducer") << "Limit on the number of stubs exceeded. An empty output collection will be produced instead.\n"; - VectorHitCollectionNew empty; - empty.swap(outputAcc); - } -*/ // write output to file event.put(std::move(outputClustersAccepted), "ClustersAccepted"); event.put(std::move(outputClustersRejected), "ClustersRejected"); event.put(std::move(outputVHAccepted), offlinestubsTag_ + "Accepted"); event.put(std::move(outputVHRejected), offlinestubsTag_ + "Rejected"); - // LogDebug("VectorHitBuilderEDProducer") << " Executing " << _algoTag << " resulted in " << numberOfVectorHits << "."; LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n"; } -void VectorHitBuilderEDProducer::setupAlgorithm(edm::ParameterSet const& conf) { - if (algoTag_ == "VectorHitBuilderAlgorithm") { - stubsBuilder_ = new VectorHitBuilderAlgorithm(conf); - readytobuild_ = true; - } else { - edm::LogError("VectorHitBuilderEDProducer") << " Choice " << algoTag_ << " is invalid.\n"; - readytobuild_ = false; - } -} - void VectorHitBuilderEDProducer::run(edm::Handle> clusters, edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, VectorHitCollectionNew& outputAcc, VectorHitCollectionNew& outputRej) { - if (!readytobuild_) { - edm::LogError("VectorHitBuilderEDProducer") << " No stub builder algorithm was found - cannot run!"; - return; - } stubsBuilder_->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej); } @@ -100,7 +73,7 @@ void VectorHitBuilderEDProducer::fillDescriptions(edm::ConfigurationDescriptions edm::ParameterSetDescription desc; desc.add("offlinestubs", "vectorHits"); desc.add("maxVectorHits", 999999999); - desc.add("Algorithm", "VectorHitBuilderAlgorithm"); + desc.add("Algorithm", edm::ESInputTag("","SiPhase2VectorHitMatcher")); desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); desc.add>("BarrelCut", { From efcebdeb203586d49c1fa58e3af5d5b9637c041d Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 4 Sep 2020 17:17:38 -0500 Subject: [PATCH 039/115] clean file structure of the EDProducers --- .../interface/VectorHitBuilderEDProducer.h | 43 --- .../plugins/SealModules.cc | 8 - .../src/VectorHitBuilderAlgorithm.cc | 4 +- .../src/VectorHitBuilderEDProducer.cc | 103 ------ .../test/BuildFile.xml | 2 - .../test/ClustersValidationTGraph.cc | 14 +- .../test/VectorHitsValidation.cc | 15 + .../test/VectorHitsValidation.h | 4 + .../interface/SeedingOTEDProducer.h | 95 ------ .../TkSeedGenerator/plugins/SealModules.cc | 2 - .../src/SeedingOTEDProducer.cc | 312 ------------------ 11 files changed, 33 insertions(+), 569 deletions(-) delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc delete mode 100644 RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h delete mode 100644 RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h deleted file mode 100644 index 0bbc94142534d..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h +++ /dev/null @@ -1,43 +0,0 @@ -//--------------------------------------------------------------------------- -// class VectorHitBuilderEDProducer -// author: ebrondol,nathera -// date: May, 2015 -//--------------------------------------------------------------------------- - -#ifndef RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitBuilderEDProducer_h -#define RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitBuilderEDProducer_h - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h" -#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" -#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" -#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" - -#include -#include - -class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { -public: - explicit VectorHitBuilderEDProducer(const edm::ParameterSet&); - ~VectorHitBuilderEDProducer() override; - void produce(edm::Event&, const edm::EventSetup&) override; - void run(edm::Handle > clusters, - edmNew::DetSetVector& clustersAcc, - edmNew::DetSetVector& clustersRej, - VectorHitCollectionNew& outputAcc, - VectorHitCollectionNew& outputRej); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - const VectorHitBuilderAlgorithm* algo() const { return stubsBuilder_; }; - -private: - const VectorHitBuilderAlgorithm * stubsBuilder_; - std::string offlinestubsTag_; - unsigned int maxOfflinestubs_; - edm::ESGetToken stubsBuilderToken_; - edm::EDGetTokenT > clusterProducer_; - -}; - -#endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc deleted file mode 100644 index 784c27e17a331..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SealModules.cc +++ /dev/null @@ -1,8 +0,0 @@ - -#include "FWCore/PluginManager/interface/ModuleDef.h" -#include "FWCore/Utilities/interface/typelookup.h" -#include "FWCore/Framework/interface/ModuleFactory.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" - -DEFINE_FWK_MODULE(VectorHitBuilderEDProducer); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 6448adf6be951..efe23608bdfe3 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -254,7 +254,7 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, //printCluster(stack->lowerDet(),&*lower); //printCluster(stack->upperDet(),&*upper); - const PixelGeomDetUnit* geomDetLower = dynamic_cast(stack->lowerDet()); + const PixelGeomDetUnit* geomDetLower = static_cast(stack->lowerDet()); const PixelGeomDetUnit* geomDetUpper = dynamic_cast(stack->upperDet()); auto&& lparamsLower = cpe->localParameters(*lower, *geomDetLower); // x, y, z, e2_xx, e2_xy, e2_yy @@ -400,5 +400,3 @@ void VectorHitBuilderAlgorithm::fit(const std::vector& x, dir = LocalVector(slope, 0., -1.); } } -#include "FWCore/Utilities/interface/typelookup.h" -TYPELOOKUP_DATA_REG(VectorHitBuilderAlgorithm); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc deleted file mode 100644 index 0e2f0f172e89c..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderEDProducer.cc +++ /dev/null @@ -1,103 +0,0 @@ -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) - : offlinestubsTag_(conf.getParameter("offlinestubs")), - maxOfflinestubs_(conf.getParameter("maxVectorHits")), - stubsBuilderToken_(esConsumes(conf.getParameter("Algorithm"))){ - clusterProducer_ = - consumes>(edm::InputTag(conf.getParameter("Clusters"))); - - produces>("ClustersAccepted"); - produces>("ClustersRejected"); - produces(offlinestubsTag_ + "Accepted"); - produces(offlinestubsTag_ + "Rejected"); - - -} - -VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; } - -void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { - LogDebug("VectorHitBuilderEDProducer") << "VectorHitBuilderEDProducer::produce() begin"; - - // get input clusters data - edm::Handle> clustersHandle; - event.getByToken(clusterProducer_, clustersHandle); - - // create the final output collection - std::unique_ptr> outputClustersAccepted( - new edmNew::DetSetVector); - std::unique_ptr> outputClustersRejected( - new edmNew::DetSetVector); - std::unique_ptr outputVHAccepted(new VectorHitCollectionNew()); - std::unique_ptr outputVHRejected(new VectorHitCollectionNew()); - - - stubsBuilder_ = &es.getData(stubsBuilderToken_); - // check on the input clusters - stubsBuilder_->printClusters(*clustersHandle); - - // running the stub building algorithm - //ERICA::output should be moved in the different algo classes? - run(clustersHandle, *outputClustersAccepted, *outputClustersRejected, *outputVHAccepted, *outputVHRejected); - - unsigned int numberOfVectorHits = 0; - edmNew::DetSetVector::const_iterator DSViter; - for (DSViter = (*outputVHAccepted).begin(); DSViter != (*outputVHAccepted).end(); DSViter++) { - edmNew::DetSet::const_iterator vh; - for (vh = DSViter->begin(); vh != DSViter->end(); ++vh) { - numberOfVectorHits++; - LogDebug("VectorHitBuilderEDProducer") << "\t vectorhit in output " << *vh << std::endl; - } - } - // write output to file - event.put(std::move(outputClustersAccepted), "ClustersAccepted"); - event.put(std::move(outputClustersRejected), "ClustersRejected"); - event.put(std::move(outputVHAccepted), offlinestubsTag_ + "Accepted"); - event.put(std::move(outputVHRejected), offlinestubsTag_ + "Rejected"); - - LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n"; -} - -void VectorHitBuilderEDProducer::run(edm::Handle> clusters, - edmNew::DetSetVector& clustersAcc, - edmNew::DetSetVector& clustersRej, - VectorHitCollectionNew& outputAcc, - VectorHitCollectionNew& outputRej) { - - stubsBuilder_->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej); -} -void VectorHitBuilderEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add("offlinestubs", "vectorHits"); - desc.add("maxVectorHits", 999999999); - desc.add("Algorithm", edm::ESInputTag("","SiPhase2VectorHitMatcher")); - desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); - desc.add>("BarrelCut", - { - 0.0, - 0.05, - 0.06, - 0.08, - 0.09, - 0.12, - 0.2, - }); - desc.add("Clusters", "siPhase2Clusters"); - desc.add("maxVectorHitsInAStack", 999); - desc.add>("EndcapCut", - { - 0.0, - 0.1, - 0.1, - 0.1, - 0.1, - 0.1, - }); - descriptions.add("siPhase2VectorHits", desc); -} - -#include "FWCore/Utilities/interface/typelookup.h" -TYPELOOKUP_DATA_REG(VectorHitBuilderEDProducer); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml index 3270d03161a4b..104d876b608e1 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml @@ -24,9 +24,7 @@ - - diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc index b6ffb8e031f64..2c27178e0e6a9 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc @@ -12,6 +12,9 @@ #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" + #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" @@ -74,13 +77,13 @@ class Phase2TrackerClusterizerValidationTGraph : public edm::EDAnalyzer { void beginJob(); void endJob(); void analyze(const edm::Event&, const edm::EventSetup&); + static void fillDescriptions(edm::ConfigurationDescriptions&); private: std::map::iterator createLayerHistograms(unsigned int); unsigned int getLayerNumber(const DetId&, const TrackerTopology*); unsigned int getModuleNumber(const DetId&, const TrackerTopology*); unsigned int getSimTrackId(const edm::Handle >&, const DetId&, unsigned int); - edm::EDGetTokenT > srcClu_; edm::EDGetTokenT > siphase2OTSimLinksToken_; edm::EDGetTokenT simHitsToken_; @@ -615,4 +618,13 @@ unsigned int Phase2TrackerClusterizerValidationTGraph::getSimTrackId( return 0; } +void Phase2TrackerClusterizerValidationTGraph::fillDescriptions(edm::ConfigurationDescriptions & descriptions){ + + edm::ParameterSetDescription desc; + desc.add("src","siPhase2Clusters"); + desc.add("links",edm::InputTag("simSiPixelDigis", "Tracker")); + descriptions.add("phase2TrackerClusterizerValidationTGraph",desc); +} + + DEFINE_FWK_MODULE(Phase2TrackerClusterizerValidationTGraph); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 957dd83bd1f49..f555338604e0e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -1212,4 +1212,19 @@ void VectorHitsBuilderValidation::printCluster(const GeomDetUnit* geomDetUnit, c return; } +void VectorHitsBuilderValidation::fillDescriptions(edm::ConfigurationDescriptions & descriptions){ + + edm::ParameterSetDescription desc; + desc.add("src","siPhase2Clusters"); + desc.add("links",edm::InputTag("simSiPixelDigis", "Tracker")); + desc.add("VH_acc",edm::InputTag("siPhase2VectorHits", "vectorHitsAccepted")); + desc.add("VH_rej",edm::InputTag("siPhase2VectorHits", "vectorHitsRejected")); + desc.add("CPE",edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); + desc.add("trackingParticleSrc",edm::InputTag("mix", "MergedTrackTruth")); + descriptions.add("vectorHitsBuilderValidation",desc); +} + + + + DEFINE_FWK_MODULE(VectorHitsBuilderValidation); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index c8789005d222e..c29d5849a1d81 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -12,6 +12,9 @@ #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" + #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" @@ -86,6 +89,7 @@ class VectorHitsBuilderValidation : public edm::EDAnalyzer { void endJob(); void analyze(const edm::Event&, const edm::EventSetup&); + static void fillDescriptions(edm::ConfigurationDescriptions&); private: std::map::iterator createLayerHistograms(unsigned int); void CreateVHsXYGraph(const std::vector, const std::vector); diff --git a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h b/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h deleted file mode 100644 index 76ef523f69194..0000000000000 --- a/RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h +++ /dev/null @@ -1,95 +0,0 @@ -//--------------------------------------------------------------------------- -// class SeedingOTEDProducer -// author: ebrondol -// date: July, 2016 -//--------------------------------------------------------------------------- - -#ifndef RecoTracker_TkSeedGenerator_SeedingOTEDProducer_h -#define RecoTracker_TkSeedGenerator_SeedingOTEDProducer_h - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/BeamSpot/interface/BeamSpot.h" -#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" -#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" -#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" -#include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" -#include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" - -#include "RecoTracker/Record/interface/CkfComponentsRecord.h" -#include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" -#include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" -#include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h" -#include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h" - -#include "Geometry/Records/interface/TrackerTopologyRcd.h" - -#include "FWCore/Utilities/interface/ESGetToken.h" - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/EventSetup.h" - -class TrajectoryStateUpdator; - -class SeedingOTEDProducer : public edm::stream::EDProducer<> { -public: - explicit SeedingOTEDProducer(const edm::ParameterSet&); - ~SeedingOTEDProducer() override; - void produce(edm::Event&, const edm::EventSetup&) override; - - static void fillDescriptions(edm::ConfigurationDescriptions&); - - TrajectorySeedCollection run(edm::Handle); - unsigned int checkLayer(unsigned int iidd); - std::vector collectVHsOnLayer(edm::Handle, unsigned int); - void printVHsOnLayer(edm::Handle, unsigned int); - const TrajectoryStateOnSurface buildInitialTSOS(VectorHit&); - AlgebraicSymMatrix assign44To55(AlgebraicSymMatrix); - std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, - const Propagator&, - const TrackingRecHit& hit); - float computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot); - float computeInverseMomentumError(VectorHit& vh, - const float globalTheta, - const double sigmaZ_beamSpot, - const double transverseMomentum); - - TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, - const edm::OwnVector& container, - const DetId& id, - const Propagator& prop); - - struct isInvalid { - bool operator()(const TrajectoryMeasurement& measurement) { - return (((measurement).recHit() == nullptr) || !((measurement).recHit()->isValid()) || - !((measurement).updatedState().isValid())); - } - }; - -private: - edm::EDGetTokenT vhProducerToken_; - const TrackerTopology* tkTopo_; - const MeasurementTracker* measurementTracker_; - const LayerMeasurements* layerMeasurements_; - const MeasurementEstimator* estimator_; - const Propagator* propagator_; - const MagneticField* magField_; - const TrajectoryStateUpdator* updator_; - const edm::EDGetTokenT tkMeasEventToken_; - edm::EDGetTokenT beamSpotToken_; - const reco::BeamSpot* beamSpot_; - std::string updatorName_; - - edm::ESGetToken topoToken_; - edm::ESGetToken propagatorToken_; - edm::ESGetToken magFieldToken_; - edm::ESGetToken updatorToken_; - edm::ESGetToken measurementTrackerToken_; - edm::ESGetToken estToken_; - -}; - -#endif diff --git a/RecoTracker/TkSeedGenerator/plugins/SealModules.cc b/RecoTracker/TkSeedGenerator/plugins/SealModules.cc index 58fa1e15580b3..ee7dd08cc5e6c 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SealModules.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SealModules.cc @@ -40,5 +40,3 @@ using SeedCreatorFromRegionConsecutiveHitsTripletOnlyEDProducer = SeedCreatorFromRegionHitsEDProducerT; DEFINE_FWK_MODULE(SeedCreatorFromRegionConsecutiveHitsTripletOnlyEDProducer); -#include "RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h" -DEFINE_FWK_MODULE(SeedingOTEDProducer); diff --git a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc deleted file mode 100644 index d2ca0fa2ab34b..0000000000000 --- a/RecoTracker/TkSeedGenerator/src/SeedingOTEDProducer.cc +++ /dev/null @@ -1,312 +0,0 @@ -#include "RecoTracker/TkSeedGenerator/interface/SeedingOTEDProducer.h" -#include "FWCore/Framework/interface/Event.h" - - -#include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h" -#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" -#include "TrackingTools/MeasurementDet/interface/TrajectoryMeasurementGroup.h" - -#include "DataFormats/SiStripDetId/interface/StripSubdetector.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) - : updator_(nullptr), - tkMeasEventToken_(consumes(conf.getParameter("trackerEvent"))), - topoToken_(esConsumes()), - propagatorToken_(esConsumes(edm::ESInputTag("", "PropagatorWithMaterial" ))), - magFieldToken_(esConsumes()), - updatorToken_(esConsumes()), - measurementTrackerToken_(esConsumes()), - estToken_(esConsumes(edm::ESInputTag("","Chi2"))) { - vhProducerToken_ = consumes(edm::InputTag(conf.getParameter("src"))); - beamSpotToken_ = consumes(conf.getParameter("beamSpotLabel")); - updatorName_ = conf.getParameter("updator"); - produces(); -} - -SeedingOTEDProducer::~SeedingOTEDProducer() { } - -void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add("src", edm::InputTag("siPhase2VectorHits", "vectorHitsAccepted")); - desc.add("trackerEvent", edm::InputTag("MeasurementTrackerEvent")); - desc.add("beamSpotLabel", edm::InputTag("offlineBeamSpot")); - desc.add("updator", std::string("KFUpdator")); - descriptions.add("SeedingOTEDProducer", desc); -} - -void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { - std::unique_ptr seedsWithVHs(new TrajectorySeedCollection()); - - - tkTopo_ = &es.getData(topoToken_); - - edm::ESHandle measurementTrackerHandle; - measurementTrackerHandle = es.getHandle(measurementTrackerToken_); - measurementTracker_ = measurementTrackerHandle.product(); - - edm::Handle measurementTrackerEvent; - event.getByToken(tkMeasEventToken_, measurementTrackerEvent); - - LayerMeasurements layerMeasurements_(*measurementTrackerHandle, *measurementTrackerEvent); - - estimator_ = &es.getData(estToken_); - - propagator_ = &es.getData(propagatorToken_); - - magField_ = &es.getData(magFieldToken_); - - updator_ = &es.getData(updatorToken_); - - edm::Handle beamSpotH; - event.getByToken(beamSpotToken_, beamSpotH); - if (beamSpotH.isValid()) { - beamSpot_ = beamSpotH.product(); - } - - // Get the vector hits - edm::Handle vhs; - event.getByToken(vhProducerToken_, vhs); - - TrajectorySeedCollection const& tempSeeds = run(vhs); - for (TrajectorySeedCollection::const_iterator qIt = tempSeeds.begin(); qIt < tempSeeds.end(); ++qIt) { - seedsWithVHs->push_back(*qIt); - } - - seedsWithVHs->shrink_to_fit(); - event.put(std::move(seedsWithVHs)); -} - -TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { - TrajectorySeedCollection result; - - //check if all the first three layers have VHs - std::vector vhSeedsL1 = collectVHsOnLayer(VHs, 1); - std::vector vhSeedsL2 = collectVHsOnLayer(VHs, 2); - std::vector vhSeedsL3 = collectVHsOnLayer(VHs, 3); - if (vhSeedsL1.empty() || vhSeedsL2.empty() || vhSeedsL3.empty()) { - return result; - } - - //seeds are built in the L3 of the OT - const BarrelDetLayer* barrelOTLayer2 = measurementTracker_->geometricSearchTracker()->tobLayers().at(1); - - //the search propag directiondepend on the sign of signZ*signPz, while the building is always the contrary - Propagator* searchingPropagator = &*propagator_->clone(); - Propagator* buildingPropagator = &*propagator_->clone(); - buildingPropagator->setPropagationDirection(alongMomentum); - - for (auto hitL3 : vhSeedsL3) { - //building a tsos out of a VectorHit - const TrajectoryStateOnSurface initialTSOS = buildInitialTSOS(hitL3); - float signZ = copysign(1.0, initialTSOS.globalPosition().z()); - float signPz = copysign(1.0, initialTSOS.globalMomentum().z()); - - //set the direction of the propagator - if (signZ * signPz > 0.0) - searchingPropagator->setPropagationDirection(oppositeToMomentum); - if (signZ * signPz < 0.0) - searchingPropagator->setPropagationDirection(alongMomentum); - - //find vHits in layer 2 - std::vector measurementsL2 = - layerMeasurements_->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator_); - - //other options - //LayerMeasurements::SimpleHitContainer hits; - //layerMeasurements->recHits(hits, *barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); - //auto && measurementsL2G = layerMeasurements->groupedMeasurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); - - std::vector::iterator measurementsL2end = - std::remove_if(measurementsL2.begin(), measurementsL2.end(), isInvalid()); - measurementsL2.erase(measurementsL2end, measurementsL2.end()); - - if (!measurementsL2.empty()) { - //not sure if building it everytime takes time/memory - const DetLayer* barrelOTLayer1 = measurementTracker_->geometricSearchTracker()->tobLayers().at(0); - - for (const auto& mL2 : measurementsL2) { - const TrackingRecHit* hitL2 = mL2.recHit().get(); - - //propagate to the L2 and update the TSOS - std::pair updatedTSOS = - propagateAndUpdate(initialTSOS, *searchingPropagator, *hitL2); - if (!updatedTSOS.first) - continue; - - //searching possible VHs in L1 - std::vector measurementsL1 = - layerMeasurements_->measurements(*barrelOTLayer1, updatedTSOS.second, *searchingPropagator, *estimator_); - std::vector::iterator measurementsL1end = - std::remove_if(measurementsL1.begin(), measurementsL1.end(), isInvalid()); - measurementsL1.erase(measurementsL1end, measurementsL1.end()); - - if (!measurementsL1.empty()) { - for (const auto& mL1 : measurementsL1) { - const TrackingRecHit* hitL1 = mL1.recHit().get(); - - //propagate to the L1 and update the TSOS - std::pair updatedTSOSL1 = - propagateAndUpdate(updatedTSOS.second, *searchingPropagator, *hitL1); - if (!updatedTSOSL1.first) - continue; - - edm::OwnVector container; - container.push_back(hitL1->clone()); - container.push_back(hitL2->clone()); - container.push_back(hitL3.clone()); - - //building trajectory inside-out - if (searchingPropagator->propagationDirection() == alongMomentum) { - buildingPropagator->setPropagationDirection(oppositeToMomentum); - } else if (searchingPropagator->propagationDirection() == oppositeToMomentum) { - buildingPropagator->setPropagationDirection(alongMomentum); - } - - updatedTSOSL1.second.rescaleError(100); - - TrajectoryStateOnSurface updatedTSOSL1_final = updator_->update(updatedTSOSL1.second, *hitL1); - if UNLIKELY (!updatedTSOSL1_final.isValid()) - continue; - std::pair updatedTSOSL2_final = - propagateAndUpdate(updatedTSOSL1_final, *buildingPropagator, *hitL2); - std::pair updatedTSOSL3_final = - propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, hitL3); - TrajectorySeed ts = - createSeed(updatedTSOSL3_final.second, container, hitL3.geographicalId(), *buildingPropagator); - result.push_back(ts); - } - } - } - } - } - - return result; -} - -unsigned int SeedingOTEDProducer::checkLayer(unsigned int iidd) { - StripSubdetector strip = StripSubdetector(iidd); - unsigned int subid = strip.subdetId(); - if (subid == StripSubdetector::TIB || subid == StripSubdetector::TOB) { - return tkTopo_->layer(iidd); - } - return 0; -} - -std::vector SeedingOTEDProducer::collectVHsOnLayer(edm::Handle VHs, - unsigned int layerNumber) { - const VectorHitCollectionNew& input = *VHs; - std::vector VHsOnLayer; - if (!input.empty()) { - for (auto DSViter : input) { - if (checkLayer(DSViter.id()) == layerNumber) { - for (const auto& vh : DSViter) { - VHsOnLayer.push_back(vh); - } - } - } - } - - return VHsOnLayer; -} - -void SeedingOTEDProducer::printVHsOnLayer(edm::Handle VHs, unsigned int layerNumber) { - const VectorHitCollectionNew& input = *VHs; - if (!input.empty()) { - for (auto DSViter : input) { - for (const auto& vh : DSViter) { - if (checkLayer(DSViter.id()) == layerNumber) - std::cout << " VH in layer " << layerNumber << " >> " << vh << std::endl; - } - } - } else { - std::cout << " No VHs in layer " << layerNumber << "." << std::endl; - } -} - -const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& vHit) { - // having fun with theta - Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); - float theta = gv.theta(); - // gv transform to local (lv) - const Local3DVector lv(vHit.det()->surface().toLocal(gv)); - - //Helper class to access momentum of VH - VectorHitMomentumHelper vhMomHelper(magField_); - - - - //FIXME::charge is fine 1 every two times!! - int charge = 1; - float p = vhMomHelper.momentum(vHit); - float x = vHit.localPosition().x(); - float y = vHit.localPosition().y(); - float dx = vHit.localDirection().x(); - // for dy use second component of the lv renormalized to the z component - float dy = lv.y() / lv.z(); - - // Pz and Dz should have the same sign - float signPz = copysign(1.0, vHit.globalPosition().z()); - - LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); - AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); - // set the error on 1/p - mat[0][0] = pow( - computeInverseMomentumError(vHit, theta, beamSpot_->sigmaZ(), vhMomHelper.transverseMomentum(vHit)), 2); - - //building tsos - LocalTrajectoryError lterr(asSMatrix<5>(mat)); - const TrajectoryStateOnSurface tsos(ltpar2, lterr, vHit.det()->surface(), magField_); - - return tsos; -} - -AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) { - if (mat44.num_row() != 4 || mat44.num_col() != 4) - assert("Wrong dimension! This should be a 4x4 matrix!"); - - AlgebraicSymMatrix result(5, 0); - for (int i = 1; i < 5; i++) { - for (int j = 1; j < 5; j++) { - result[i][j] = mat44[i - 1][j - 1]; - } - } - return result; -} - -std::pair SeedingOTEDProducer::propagateAndUpdate( - const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit) { - TrajectoryStateOnSurface propTSOS = prop.propagate(initialTSOS, hit.det()->surface()); - TrajectoryStateOnSurface updatedTSOS = updator_->update(propTSOS, hit); - if UNLIKELY (!updatedTSOS.isValid()) - return std::make_pair(false, updatedTSOS); - return std::make_pair(true, updatedTSOS); -} - -float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot) { - double derivative = - vh.globalPosition().perp() / (pow(vh.globalPosition().z(), 2) + pow(vh.globalPosition().perp(), 2)); - double derivative2 = pow(derivative, 2); - return pow(derivative2 * vh.lowerGlobalPosErr().czz() + derivative2 * pow(sigmaZ_beamSpot, 2), 0.5); -} - -float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, - const float globalTheta, - const double sigmaZ_beamSpot, - const double transverseMomentum) { - //for pT > 2GeV, 1/pT has sigma = 1/sqrt(12) - float varianceInverseTransvMomentum = 1. / 12; - float derivativeTheta2 = pow(cos(globalTheta) / transverseMomentum, 2); - float derivativeInverseTransvMomentum2 = pow(sin(globalTheta), 2); - float thetaError = computeGlobalThetaError(vh, sigmaZ_beamSpot); - return pow(derivativeTheta2 * pow(thetaError, 2) + derivativeInverseTransvMomentum2 * varianceInverseTransvMomentum, - 0.5); -} - -TrajectorySeed SeedingOTEDProducer::createSeed(const TrajectoryStateOnSurface& tsos, - const edm::OwnVector& container, - const DetId& id, - const Propagator& prop) { - PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos, id.rawId()); - return TrajectorySeed(seedTSOS, container, prop.propagationDirection()); -} From 727cb464776fa5b6332b670b6bd41b656c9fc6ae Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 4 Sep 2020 17:18:04 -0500 Subject: [PATCH 040/115] add new files from last step --- .../plugins/VectorHitBuilderEDProducer.cc | 138 ++++++ .../src/ES_VectorHitBuilderAlgorithm.cc | 4 + .../plugins/SeedingOTEDProducer.cc | 397 ++++++++++++++++++ 3 files changed, 539 insertions(+) create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/src/ES_VectorHitBuilderAlgorithm.cc create mode 100644 RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc new file mode 100644 index 0000000000000..321f034532631 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -0,0 +1,138 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h" +#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" + +#include +#include + +class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { +public: + explicit VectorHitBuilderEDProducer(const edm::ParameterSet&); + ~VectorHitBuilderEDProducer( ) override; + void produce(edm::Event&, const edm::EventSetup&) override; + void run(edm::Handle > clusters, + edmNew::DetSetVector& clustersAcc, + edmNew::DetSetVector& clustersRej, + VectorHitCollectionNew& outputAcc, + VectorHitCollectionNew& outputRej); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + const VectorHitBuilderAlgorithm* algo() const { return stubsBuilder_; }; + +private: + const VectorHitBuilderAlgorithm * stubsBuilder_; + std::string offlinestubsTag_; + unsigned int maxOfflinestubs_; + edm::ESGetToken stubsBuilderToken_; + edm::EDGetTokenT > clusterProducer_; + +}; + +VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; } + + +VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) + : offlinestubsTag_(conf.getParameter("offlinestubs")), + maxOfflinestubs_(conf.getParameter("maxVectorHits")), + stubsBuilderToken_(esConsumes(conf.getParameter("Algorithm"))){ + clusterProducer_ = + consumes>(edm::InputTag(conf.getParameter("Clusters"))); + + produces>("ClustersAccepted"); + produces>("ClustersRejected"); + produces(offlinestubsTag_ + "Accepted"); + produces(offlinestubsTag_ + "Rejected"); + + +} + + +void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { + LogDebug("VectorHitBuilderEDProducer") << "VectorHitBuilderEDProducer::produce() begin"; + + // get input clusters data + edm::Handle> clustersHandle; + event.getByToken(clusterProducer_, clustersHandle); + + // create the final output collection + std::unique_ptr> outputClustersAccepted( + new edmNew::DetSetVector); + std::unique_ptr> outputClustersRejected( + new edmNew::DetSetVector); + std::unique_ptr outputVHAccepted(new VectorHitCollectionNew()); + std::unique_ptr outputVHRejected(new VectorHitCollectionNew()); + + + stubsBuilder_ = &es.getData(stubsBuilderToken_); + // check on the input clusters + stubsBuilder_->printClusters(*clustersHandle); + + // running the stub building algorithm + //ERICA::output should be moved in the different algo classes? + run(clustersHandle, *outputClustersAccepted, *outputClustersRejected, *outputVHAccepted, *outputVHRejected); + + unsigned int numberOfVectorHits = 0; + edmNew::DetSetVector::const_iterator DSViter; + for (DSViter = (*outputVHAccepted).begin(); DSViter != (*outputVHAccepted).end(); DSViter++) { + edmNew::DetSet::const_iterator vh; + for (vh = DSViter->begin(); vh != DSViter->end(); ++vh) { + numberOfVectorHits++; + LogDebug("VectorHitBuilderEDProducer") << "\t vectorhit in output " << *vh << std::endl; + } + } + // write output to file + event.put(std::move(outputClustersAccepted), "ClustersAccepted"); + event.put(std::move(outputClustersRejected), "ClustersRejected"); + event.put(std::move(outputVHAccepted), offlinestubsTag_ + "Accepted"); + event.put(std::move(outputVHRejected), offlinestubsTag_ + "Rejected"); + + LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n"; +} + +void VectorHitBuilderEDProducer::run(edm::Handle> clusters, + edmNew::DetSetVector& clustersAcc, + edmNew::DetSetVector& clustersRej, + VectorHitCollectionNew& outputAcc, + VectorHitCollectionNew& outputRej) { + + stubsBuilder_->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej); +} +void VectorHitBuilderEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("offlinestubs", "vectorHits"); + desc.add("maxVectorHits", 999999999); + desc.add("Algorithm", edm::ESInputTag("","SiPhase2VectorHitMatcher")); + desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); + desc.add>("BarrelCut", + { + 0.0, + 0.05, + 0.06, + 0.08, + 0.09, + 0.12, + 0.2, + }); + desc.add("Clusters", "siPhase2Clusters"); + desc.add("maxVectorHitsInAStack", 999); + desc.add>("EndcapCut", + { + 0.0, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + }); + descriptions.add("siPhase2VectorHits", desc); +} +DEFINE_FWK_MODULE(VectorHitBuilderEDProducer); +#include "FWCore/Utilities/interface/typelookup.h" +TYPELOOKUP_DATA_REG(VectorHitBuilderEDProducer); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/ES_VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/ES_VectorHitBuilderAlgorithm.cc new file mode 100644 index 0000000000000..7bbb14a2b4f16 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/ES_VectorHitBuilderAlgorithm.cc @@ -0,0 +1,4 @@ +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(VectorHitBuilderAlgorithm); diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc new file mode 100644 index 0000000000000..6a298388a85eb --- /dev/null +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -0,0 +1,397 @@ + +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/Event.h" + +#include "DataFormats/BeamSpot/interface/BeamSpot.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" +#include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" +#include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" + +#include "RecoTracker/Record/interface/CkfComponentsRecord.h" +#include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" +#include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" +#include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h" +#include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h" + +#include "Geometry/Records/interface/TrackerTopologyRcd.h" + +#include "FWCore/Utilities/interface/ESGetToken.h" + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" + + +#include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h" +#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" +#include "TrackingTools/MeasurementDet/interface/TrajectoryMeasurementGroup.h" + +#include "DataFormats/SiStripDetId/interface/StripSubdetector.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +class TrajectoryStateUpdator; + +class SeedingOTEDProducer : public edm::stream::EDProducer<> { +public: + explicit SeedingOTEDProducer(const edm::ParameterSet&); + ~SeedingOTEDProducer() override; + void produce(edm::Event&, const edm::EventSetup&) override; + + static void fillDescriptions(edm::ConfigurationDescriptions&); + + TrajectorySeedCollection run(edm::Handle); + unsigned int checkLayer(unsigned int iidd); + std::vector collectVHsOnLayer(edm::Handle, unsigned int); + void printVHsOnLayer(edm::Handle, unsigned int); + const TrajectoryStateOnSurface buildInitialTSOS(VectorHit&); + AlgebraicSymMatrix assign44To55(AlgebraicSymMatrix); + std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, + const Propagator&, + const TrackingRecHit& hit); + float computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot); + float computeInverseMomentumError(VectorHit& vh, + const float globalTheta, + const double sigmaZ_beamSpot, + const double transverseMomentum); + + TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, + const edm::OwnVector& container, + const DetId& id, + const Propagator& prop); + + struct isInvalid { + bool operator()(const TrajectoryMeasurement& measurement) { + return (((measurement).recHit() == nullptr) || !((measurement).recHit()->isValid()) || + !((measurement).updatedState().isValid())); + } + }; + +private: + edm::EDGetTokenT vhProducerToken_; + const TrackerTopology* tkTopo_; + const MeasurementTracker* measurementTracker_; + const LayerMeasurements* layerMeasurements_; + const MeasurementEstimator* estimator_; + const Propagator* propagator_; + const MagneticField* magField_; + const TrajectoryStateUpdator* updator_; + const edm::EDGetTokenT tkMeasEventToken_; + edm::EDGetTokenT beamSpotToken_; + const reco::BeamSpot* beamSpot_; + std::string updatorName_; + + edm::ESGetToken topoToken_; + edm::ESGetToken propagatorToken_; + edm::ESGetToken magFieldToken_; + edm::ESGetToken updatorToken_; + edm::ESGetToken measurementTrackerToken_; + edm::ESGetToken estToken_; + +}; + +SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) + : updator_(nullptr), + tkMeasEventToken_(consumes(conf.getParameter("trackerEvent"))), + topoToken_(esConsumes()), + propagatorToken_(esConsumes(edm::ESInputTag("", "PropagatorWithMaterial" ))), + magFieldToken_(esConsumes()), + updatorToken_(esConsumes()), + measurementTrackerToken_(esConsumes()), + estToken_(esConsumes(edm::ESInputTag("","Chi2"))) { + vhProducerToken_ = consumes(edm::InputTag(conf.getParameter("src"))); + beamSpotToken_ = consumes(conf.getParameter("beamSpotLabel")); + updatorName_ = conf.getParameter("updator"); + produces(); +} + +SeedingOTEDProducer::~SeedingOTEDProducer() { } + +void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("src", edm::InputTag("siPhase2VectorHits", "vectorHitsAccepted")); + desc.add("trackerEvent", edm::InputTag("MeasurementTrackerEvent")); + desc.add("beamSpotLabel", edm::InputTag("offlineBeamSpot")); + desc.add("updator", std::string("KFUpdator")); + descriptions.add("SeedingOTEDProducer", desc); +} + +void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { + std::unique_ptr seedsWithVHs(new TrajectorySeedCollection()); + + + tkTopo_ = &es.getData(topoToken_); + + edm::ESHandle measurementTrackerHandle; + measurementTrackerHandle = es.getHandle(measurementTrackerToken_); + measurementTracker_ = measurementTrackerHandle.product(); + + edm::Handle measurementTrackerEvent; + event.getByToken(tkMeasEventToken_, measurementTrackerEvent); + + LayerMeasurements layerMeasurements_(*measurementTrackerHandle, *measurementTrackerEvent); + + estimator_ = &es.getData(estToken_); + + propagator_ = &es.getData(propagatorToken_); + + magField_ = &es.getData(magFieldToken_); + + updator_ = &es.getData(updatorToken_); + + edm::Handle beamSpotH; + event.getByToken(beamSpotToken_, beamSpotH); + if (beamSpotH.isValid()) { + beamSpot_ = beamSpotH.product(); + } + + // Get the vector hits + edm::Handle vhs; + event.getByToken(vhProducerToken_, vhs); + + TrajectorySeedCollection const& tempSeeds = run(vhs); + for (TrajectorySeedCollection::const_iterator qIt = tempSeeds.begin(); qIt < tempSeeds.end(); ++qIt) { + seedsWithVHs->push_back(*qIt); + } + + seedsWithVHs->shrink_to_fit(); + event.put(std::move(seedsWithVHs)); +} + +TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { + TrajectorySeedCollection result; + + //check if all the first three layers have VHs + std::vector vhSeedsL1 = collectVHsOnLayer(VHs, 1); + std::vector vhSeedsL2 = collectVHsOnLayer(VHs, 2); + std::vector vhSeedsL3 = collectVHsOnLayer(VHs, 3); + if (vhSeedsL1.empty() || vhSeedsL2.empty() || vhSeedsL3.empty()) { + return result; + } + + //seeds are built in the L3 of the OT + const BarrelDetLayer* barrelOTLayer2 = measurementTracker_->geometricSearchTracker()->tobLayers().at(1); + + //the search propag directiondepend on the sign of signZ*signPz, while the building is always the contrary + Propagator* searchingPropagator = &*propagator_->clone(); + Propagator* buildingPropagator = &*propagator_->clone(); + buildingPropagator->setPropagationDirection(alongMomentum); + + for (auto hitL3 : vhSeedsL3) { + //building a tsos out of a VectorHit + const TrajectoryStateOnSurface initialTSOS = buildInitialTSOS(hitL3); + float signZ = copysign(1.0, initialTSOS.globalPosition().z()); + float signPz = copysign(1.0, initialTSOS.globalMomentum().z()); + + //set the direction of the propagator + if (signZ * signPz > 0.0) + searchingPropagator->setPropagationDirection(oppositeToMomentum); + if (signZ * signPz < 0.0) + searchingPropagator->setPropagationDirection(alongMomentum); + + //find vHits in layer 2 + std::vector measurementsL2 = + layerMeasurements_->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator_); + + //other options + //LayerMeasurements::SimpleHitContainer hits; + //layerMeasurements->recHits(hits, *barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + //auto && measurementsL2G = layerMeasurements->groupedMeasurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); + + std::vector::iterator measurementsL2end = + std::remove_if(measurementsL2.begin(), measurementsL2.end(), isInvalid()); + measurementsL2.erase(measurementsL2end, measurementsL2.end()); + + if (!measurementsL2.empty()) { + //not sure if building it everytime takes time/memory + const DetLayer* barrelOTLayer1 = measurementTracker_->geometricSearchTracker()->tobLayers().at(0); + + for (const auto& mL2 : measurementsL2) { + const TrackingRecHit* hitL2 = mL2.recHit().get(); + + //propagate to the L2 and update the TSOS + std::pair updatedTSOS = + propagateAndUpdate(initialTSOS, *searchingPropagator, *hitL2); + if (!updatedTSOS.first) + continue; + + //searching possible VHs in L1 + std::vector measurementsL1 = + layerMeasurements_->measurements(*barrelOTLayer1, updatedTSOS.second, *searchingPropagator, *estimator_); + std::vector::iterator measurementsL1end = + std::remove_if(measurementsL1.begin(), measurementsL1.end(), isInvalid()); + measurementsL1.erase(measurementsL1end, measurementsL1.end()); + + if (!measurementsL1.empty()) { + for (const auto& mL1 : measurementsL1) { + const TrackingRecHit* hitL1 = mL1.recHit().get(); + + //propagate to the L1 and update the TSOS + std::pair updatedTSOSL1 = + propagateAndUpdate(updatedTSOS.second, *searchingPropagator, *hitL1); + if (!updatedTSOSL1.first) + continue; + + edm::OwnVector container; + container.push_back(hitL1->clone()); + container.push_back(hitL2->clone()); + container.push_back(hitL3.clone()); + + //building trajectory inside-out + if (searchingPropagator->propagationDirection() == alongMomentum) { + buildingPropagator->setPropagationDirection(oppositeToMomentum); + } else if (searchingPropagator->propagationDirection() == oppositeToMomentum) { + buildingPropagator->setPropagationDirection(alongMomentum); + } + + updatedTSOSL1.second.rescaleError(100); + + TrajectoryStateOnSurface updatedTSOSL1_final = updator_->update(updatedTSOSL1.second, *hitL1); + if UNLIKELY (!updatedTSOSL1_final.isValid()) + continue; + std::pair updatedTSOSL2_final = + propagateAndUpdate(updatedTSOSL1_final, *buildingPropagator, *hitL2); + std::pair updatedTSOSL3_final = + propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, hitL3); + TrajectorySeed ts = + createSeed(updatedTSOSL3_final.second, container, hitL3.geographicalId(), *buildingPropagator); + result.push_back(ts); + } + } + } + } + } + + return result; +} + +unsigned int SeedingOTEDProducer::checkLayer(unsigned int iidd) { + StripSubdetector strip = StripSubdetector(iidd); + unsigned int subid = strip.subdetId(); + if (subid == StripSubdetector::TIB || subid == StripSubdetector::TOB) { + return tkTopo_->layer(iidd); + } + return 0; +} + +std::vector SeedingOTEDProducer::collectVHsOnLayer(edm::Handle VHs, + unsigned int layerNumber) { + const VectorHitCollectionNew& input = *VHs; + std::vector VHsOnLayer; + if (!input.empty()) { + for (auto DSViter : input) { + if (checkLayer(DSViter.id()) == layerNumber) { + for (const auto& vh : DSViter) { + VHsOnLayer.push_back(vh); + } + } + } + } + + return VHsOnLayer; +} + +void SeedingOTEDProducer::printVHsOnLayer(edm::Handle VHs, unsigned int layerNumber) { + const VectorHitCollectionNew& input = *VHs; + if (!input.empty()) { + for (auto DSViter : input) { + for (const auto& vh : DSViter) { + if (checkLayer(DSViter.id()) == layerNumber) + std::cout << " VH in layer " << layerNumber << " >> " << vh << std::endl; + } + } + } else { + std::cout << " No VHs in layer " << layerNumber << "." << std::endl; + } +} + +const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& vHit) { + // having fun with theta + Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); + float theta = gv.theta(); + // gv transform to local (lv) + const Local3DVector lv(vHit.det()->surface().toLocal(gv)); + + //Helper class to access momentum of VH + VectorHitMomentumHelper vhMomHelper(magField_); + + + + //FIXME::charge is fine 1 every two times!! + int charge = 1; + float p = vhMomHelper.momentum(vHit); + float x = vHit.localPosition().x(); + float y = vHit.localPosition().y(); + float dx = vHit.localDirection().x(); + // for dy use second component of the lv renormalized to the z component + float dy = lv.y() / lv.z(); + + // Pz and Dz should have the same sign + float signPz = copysign(1.0, vHit.globalPosition().z()); + + LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); + AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); + // set the error on 1/p + mat[0][0] = pow( + computeInverseMomentumError(vHit, theta, beamSpot_->sigmaZ(), vhMomHelper.transverseMomentum(vHit)), 2); + + //building tsos + LocalTrajectoryError lterr(asSMatrix<5>(mat)); + const TrajectoryStateOnSurface tsos(ltpar2, lterr, vHit.det()->surface(), magField_); + + return tsos; +} + +AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) { + if (mat44.num_row() != 4 || mat44.num_col() != 4) + assert("Wrong dimension! This should be a 4x4 matrix!"); + + AlgebraicSymMatrix result(5, 0); + for (int i = 1; i < 5; i++) { + for (int j = 1; j < 5; j++) { + result[i][j] = mat44[i - 1][j - 1]; + } + } + return result; +} + +std::pair SeedingOTEDProducer::propagateAndUpdate( + const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit) { + TrajectoryStateOnSurface propTSOS = prop.propagate(initialTSOS, hit.det()->surface()); + TrajectoryStateOnSurface updatedTSOS = updator_->update(propTSOS, hit); + if UNLIKELY (!updatedTSOS.isValid()) + return std::make_pair(false, updatedTSOS); + return std::make_pair(true, updatedTSOS); +} + +float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot) { + double derivative = + vh.globalPosition().perp() / (pow(vh.globalPosition().z(), 2) + pow(vh.globalPosition().perp(), 2)); + double derivative2 = pow(derivative, 2); + return pow(derivative2 * vh.lowerGlobalPosErr().czz() + derivative2 * pow(sigmaZ_beamSpot, 2), 0.5); +} + +float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, + const float globalTheta, + const double sigmaZ_beamSpot, + const double transverseMomentum) { + //for pT > 2GeV, 1/pT has sigma = 1/sqrt(12) + float varianceInverseTransvMomentum = 1. / 12; + float derivativeTheta2 = pow(cos(globalTheta) / transverseMomentum, 2); + float derivativeInverseTransvMomentum2 = pow(sin(globalTheta), 2); + float thetaError = computeGlobalThetaError(vh, sigmaZ_beamSpot); + return pow(derivativeTheta2 * pow(thetaError, 2) + derivativeInverseTransvMomentum2 * varianceInverseTransvMomentum, + 0.5); +} + +TrajectorySeed SeedingOTEDProducer::createSeed(const TrajectoryStateOnSurface& tsos, + const edm::OwnVector& container, + const DetId& id, + const Propagator& prop) { + PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos, id.rawId()); + return TrajectorySeed(seedTSOS, container, prop.propagationDirection()); +} +DEFINE_FWK_MODULE(SeedingOTEDProducer); From 17bbbd6678edae0d2ea3477e2970dfa72078e45f Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 4 Sep 2020 17:33:57 -0500 Subject: [PATCH 041/115] use det() --- DataFormats/TrackerRecHit2D/interface/VectorHit.h | 7 +++---- DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 712cee801d461..f03fc066c6581 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -58,10 +58,9 @@ class VectorHit final : public BaseTrackerRecHit { // Parameters of the segment, for the track fit // For a 4D segment: (dx/dz,dy/dz,x,y) bool hasPositionAndError() const override { - //bool hasPositionAndError() const { - return true; - // return (err_.xx() != 0) || (err_.yy() != 0) || (err_.xy() != 0) || - // (pos_.x() != 0) || (pos_.y() != 0) || (pos_.z() != 0); + //if det is present pose&err are available as well. + //if det() is not present (null) the hit ihas been read from file and not updated + return det(); }; AlgebraicVector parameters() const override; diff --git a/DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc b/DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc index 4b1d7c60c8051..672b3aeb55e6d 100644 --- a/DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc +++ b/DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc @@ -27,10 +27,9 @@ void BaseTrackerRecHit::check() const { #endif bool BaseTrackerRecHit::hasPositionAndError() const { + //if det is present pose&err are available as well. + // //if det() is not present (null) the hit ihas been read from file and not updated return det(); - - // return (err_.xx() != 0) || (err_.yy() != 0) || (err_.xy() != 0) || - // (pos_.x() != 0) || (pos_.y() != 0) || (pos_.z() != 0); } void BaseTrackerRecHit::getKfComponents1D(KfComponentsHolder &holder) const { From d06cd10e643e97d840d5c8fabf99c7da80062a36 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 4 Sep 2020 17:47:26 -0500 Subject: [PATCH 042/115] remove uncessary cfi files --- .../python/SiPhase2RecHitMatcher_cfi.py | 4 ---- .../python/SiPhase2VectorHitBuilder_cfi.py | 4 ---- 2 files changed, 8 deletions(-) delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py deleted file mode 100644 index b10e94e6c8b96..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2RecHitMatcher_cfi.py +++ /dev/null @@ -1,4 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -SiPhase2RecHitMatcherESProducer = cms.ESProducer("SiPhase2RecHitMatcherESProducer", -) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py deleted file mode 100644 index d885267371172..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/python/SiPhase2VectorHitBuilder_cfi.py +++ /dev/null @@ -1,4 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -siPhase2VectorHits = cms.EDProducer("VectorHitBuilderEDProducer", -) From 9e1ca77b024b44afbc1735766fde6367c64e9227 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Fri, 4 Sep 2020 18:06:36 -0500 Subject: [PATCH 043/115] code checks and format --- .../TrackerRecHit2D/interface/VectorHit.h | 7 ++--- .../TrackerRecHit2D/interface/VectorHit2D.h | 7 ++++- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 12 ++++---- .../interface/VectorHitBuilderAlgorithm.h | 7 +++-- .../interface/VectorHitBuilderAlgorithmBase.h | 8 ++--- .../interface/VectorHitMomentumHelper.h | 14 ++++----- .../SiPhase2RecHitMatcherESProducer.cc | 18 +++++------ .../plugins/VectorHitBuilderEDProducer.cc | 21 +++++-------- .../src/VectorHitBuilderAlgorithmBase.cc | 30 ++++++++----------- .../test/ClustersValidationTGraph.cc | 12 ++++---- .../test/VectorHitsValidation.cc | 24 +++++++-------- .../test/VectorHitsValidation.h | 2 +- .../TkSeedGenerator/plugins/SealModules.cc | 1 - .../plugins/SeedingOTEDProducer.cc | 15 ++++------ 14 files changed, 79 insertions(+), 99 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index f03fc066c6581..7f726e4149533 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -78,8 +78,7 @@ class VectorHit final : public BaseTrackerRecHit { virtual float chi2() const { return theChi2; } int dimension() const override { return theDimension; } - - enum curvatureOrPhi { curvatureMode, phiMode }; + enum curvatureOrPhi { curvatureMode, phiMode }; std::pair curvatureORphi(curvatureOrPhi curvatureMode) const; @@ -145,9 +144,7 @@ class VectorHit final : public BaseTrackerRecHit { OmniClusterRef theUpperCluster; }; -inline bool operator<(const VectorHit& one, const VectorHit& other) { - return (one.chi2() < other.chi2()); -} +inline bool operator<(const VectorHit& one, const VectorHit& other) { return (one.chi2() < other.chi2()); } std::ostream& operator<<(std::ostream& os, const VectorHit& vh); diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index a30c92f2e20ad..e7fd9bfb6f953 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -12,7 +12,12 @@ class VectorHit2D { public: VectorHit2D() : thePosition(), theDirection(), theCovMatrix(), theChi2(), theDimension(2) {} VectorHit2D(const LocalPoint& pos, const LocalVector& dir, const AlgebraicSymMatrix22& covMatrix, const double& Chi2) - : thePosition(pos), theDirection(dir), theCovMatrix(covMatrix), theLocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]), theChi2(Chi2), theDimension(2){}; + : thePosition(pos), + theDirection(dir), + theCovMatrix(covMatrix), + theLocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]), + theChi2(Chi2), + theDimension(2){}; virtual ~VectorHit2D(){}; const LocalPoint* localPosition() const { return &thePosition; } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index dbb169193922c..e01d9969999a6 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -38,8 +38,8 @@ VectorHit::VectorHit(const GeomDet& idet, theDirection = LocalVector(vh2Dzx.localDirection()->x(), vh2Dzy.localDirection()->x(), 1.); //building the cov matrix 4x4 starting from the 2x2 - const AlgebraicSymMatrix22 covMatZX = *vh2Dzx.covMatrix(); - const AlgebraicSymMatrix22 covMatZY = *vh2Dzy.covMatrix(); + const AlgebraicSymMatrix22 covMatZX = *vh2Dzx.covMatrix(); + const AlgebraicSymMatrix22 covMatZY = *vh2Dzy.covMatrix(); theCovMatrix = AlgebraicSymMatrix(4); theCovMatrix[0][0] = covMatZX[0][0]; // var(dx/dz) @@ -338,9 +338,11 @@ std::pair VectorHit::curvatureORphi(curvatureOrPhi curvORphi) cons } else { return std::make_pair(0.0, 0.0); } - switch(curvORphi){ - case curvatureMode : return std::make_pair(curvature, errorCurvature); - case phiMode : return std::make_pair(phi, 0.0); + switch (curvORphi) { + case curvatureMode: + return std::make_pair(curvature, errorCurvature); + case phiMode: + return std::make_pair(phi, 0.0); } return std::make_pair(0.0, 0.0); } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 32806969c560c..082293459902d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -16,8 +16,11 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { public: - VectorHitBuilderAlgorithm(const edm::ParameterSet& conf, const TrackerGeometry* tkGeomProd, const TrackerTopology* tkTopoProd, const ClusterParameterEstimator* cpeProd) - : VectorHitBuilderAlgorithmBase(conf, tkGeomProd, tkTopoProd, cpeProd ), theFitter(new LinearFit()){}; + VectorHitBuilderAlgorithm(const edm::ParameterSet& conf, + const TrackerGeometry* tkGeomProd, + const TrackerTopology* tkTopoProd, + const ClusterParameterEstimator* cpeProd) + : VectorHitBuilderAlgorithmBase(conf, tkGeomProd, tkTopoProd, cpeProd), theFitter(new LinearFit()){}; ~VectorHitBuilderAlgorithm() override { delete theFitter; }; void run(edm::Handle> clusters, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index 8fd95d97096ba..b3154600a23e1 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -24,11 +24,11 @@ class VectorHitBuilderAlgorithmBase { typedef std::pair> StackClusters; VectorHitBuilderAlgorithmBase(const edm::ParameterSet&, - const TrackerGeometry*, - const TrackerTopology*, - const ClusterParameterEstimator*); + const TrackerGeometry*, + const TrackerTopology*, + const ClusterParameterEstimator*); virtual ~VectorHitBuilderAlgorithmBase() {} -// void initialize(const edm::EventSetup&); + // void initialize(const edm::EventSetup&); void initTkGeom(const TrackerGeometry* tkGeomProd); void initTkTopo(const TrackerTopology* tkTopoProd); void initCpe(const ClusterParameterEstimator* cpeProd); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h index ecbae466fa2fb..f0c37453093fe 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h @@ -7,24 +7,20 @@ class VectorHitMomentumHelper { public: VectorHitMomentumHelper(const MagneticField* magField) { - GlobalPoint center(0.0, 0.0, 0.0); - intermediate = magField->inTesla(center).mag() * 0.003; - //0.003 is because the curvature (rho) is in cm and not in m -} + GlobalPoint center(0.0, 0.0, 0.0); + intermediate = magField->inTesla(center).mag() * 0.003; + //0.003 is because the curvature (rho) is in cm and not in m + } ~VectorHitMomentumHelper() {} float transverseMomentum(VectorHit& vh) const { float rho = 1. / vh.curvatureORphi(VectorHit::curvatureMode).first; return (intermediate * rho); } - float momentum(VectorHit& vh) const { - return transverseMomentum(vh) / (1. * sin(vh.theta())); - } + float momentum(VectorHit& vh) const { return transverseMomentum(vh) / (1. * sin(vh.theta())); } private: - float intermediate; - }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index ac3d944ba5307..e9197ae107b5c 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -28,10 +28,9 @@ class SiPhase2RecHitMatcherESProducer : public edm::ESProducer { SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet& p) { name_ = p.getParameter("ComponentName"); - if (!(name_ == "SiPhase2VectorHitMatcher")){ - throw cms::Exception("ConfigurationError") - << "Configuration specifies unknown ComponentName .\n" - << "Currently only 'SiPhase2VectorHitMatcher' is supported\n"; + if (!(name_ == "SiPhase2VectorHitMatcher")) { + throw cms::Exception("ConfigurationError") << "Configuration specifies unknown ComponentName .\n" + << "Currently only 'SiPhase2VectorHitMatcher' is supported\n"; } pset_ = p; auto cc = setWhatProduced(this, name_); @@ -41,12 +40,13 @@ SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::Para } std::unique_ptr SiPhase2RecHitMatcherESProducer::produce(const TkPhase2OTCPERecord& iRecord) { - std::unique_ptr matcher = std::make_unique(pset_, - &iRecord.get(geometryToken_), - &iRecord.getRecord().get(trackerTopoToken_), - &iRecord.get(cpeToken_)); + std::unique_ptr matcher = std::make_unique( + pset_, + &iRecord.get(geometryToken_), + &iRecord.getRecord().get(trackerTopoToken_), + &iRecord.get(cpeToken_)); -/* edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); + /* edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); edm::ESHandle tTopoHandle = iRecord.getRecord().getHandle(trackerTopoToken_); auto ptr_phase2TrackerCPE = &iRecord.get(cpeToken_); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc index 321f034532631..6a7f8427e5631 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -16,9 +16,9 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { public: explicit VectorHitBuilderEDProducer(const edm::ParameterSet&); - ~VectorHitBuilderEDProducer( ) override; - void produce(edm::Event&, const edm::EventSetup&) override; - void run(edm::Handle > clusters, + ~VectorHitBuilderEDProducer() override; + void produce(edm::Event&, const edm::EventSetup&) override; + void run(edm::Handle> clusters, edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, VectorHitCollectionNew& outputAcc, @@ -27,21 +27,19 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { const VectorHitBuilderAlgorithm* algo() const { return stubsBuilder_; }; private: - const VectorHitBuilderAlgorithm * stubsBuilder_; + const VectorHitBuilderAlgorithm* stubsBuilder_; std::string offlinestubsTag_; unsigned int maxOfflinestubs_; edm::ESGetToken stubsBuilderToken_; - edm::EDGetTokenT > clusterProducer_; - + edm::EDGetTokenT> clusterProducer_; }; VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; } - VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) : offlinestubsTag_(conf.getParameter("offlinestubs")), maxOfflinestubs_(conf.getParameter("maxVectorHits")), - stubsBuilderToken_(esConsumes(conf.getParameter("Algorithm"))){ + stubsBuilderToken_(esConsumes(conf.getParameter("Algorithm"))) { clusterProducer_ = consumes>(edm::InputTag(conf.getParameter("Clusters"))); @@ -49,11 +47,8 @@ VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& produces>("ClustersRejected"); produces(offlinestubsTag_ + "Accepted"); produces(offlinestubsTag_ + "Rejected"); - - } - void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { LogDebug("VectorHitBuilderEDProducer") << "VectorHitBuilderEDProducer::produce() begin"; @@ -69,7 +64,6 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu std::unique_ptr outputVHAccepted(new VectorHitCollectionNew()); std::unique_ptr outputVHRejected(new VectorHitCollectionNew()); - stubsBuilder_ = &es.getData(stubsBuilderToken_); // check on the input clusters stubsBuilder_->printClusters(*clustersHandle); @@ -101,14 +95,13 @@ void VectorHitBuilderEDProducer::run(edm::Handle& clustersRej, VectorHitCollectionNew& outputAcc, VectorHitCollectionNew& outputRej) { - stubsBuilder_->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej); } void VectorHitBuilderEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("offlinestubs", "vectorHits"); desc.add("maxVectorHits", 999999999); - desc.add("Algorithm", edm::ESInputTag("","SiPhase2VectorHitMatcher")); + desc.add("Algorithm", edm::ESInputTag("", "SiPhase2VectorHitMatcher")); desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); desc.add>("BarrelCut", { diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index fa54c5bd8a5d7..6e5bc1ee39805 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -7,19 +7,18 @@ #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" -VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase(const edm::ParameterSet& conf, - const TrackerGeometry* tkGeomProd, - const TrackerTopology* tkTopoProd, - const ClusterParameterEstimator* cpeProd) +VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase( + const edm::ParameterSet& conf, + const TrackerGeometry* tkGeomProd, + const TrackerTopology* tkTopoProd, + const ClusterParameterEstimator* cpeProd) : nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), barrelCut(conf.getParameter >("BarrelCut")), endcapCut(conf.getParameter >("EndcapCut")), cpeTag_(conf.getParameter("CPE")) { - - initTkGeom(tkGeomProd); - initTkTopo(tkTopoProd); - initCpe(cpeProd); - + initTkGeom(tkGeomProd); + initTkTopo(tkTopoProd); + initCpe(cpeProd); } /*void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) { @@ -38,12 +37,8 @@ VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase(const edm::Paramete initCpe(cpeHandle.product()); } */ -void VectorHitBuilderAlgorithmBase::initTkGeom(const TrackerGeometry* tkGeomProd) { - theTkGeom = tkGeomProd; -} -void VectorHitBuilderAlgorithmBase::initTkTopo(const TrackerTopology* tkTopoProd) { - theTkTopo = tkTopoProd; -} +void VectorHitBuilderAlgorithmBase::initTkGeom(const TrackerGeometry* tkGeomProd) { theTkGeom = tkGeomProd; } +void VectorHitBuilderAlgorithmBase::initTkTopo(const TrackerTopology* tkTopoProd) { theTkTopo = tkTopoProd; } void VectorHitBuilderAlgorithmBase::initCpe(const ClusterParameterEstimator* cpeProd) { cpe = cpeProd; } @@ -70,7 +65,7 @@ double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomD return parallCorr; } -void VectorHitBuilderAlgorithmBase::printClusters (const edmNew::DetSetVector& clusters) const { +void VectorHitBuilderAlgorithmBase::printClusters(const edmNew::DetSetVector& clusters) const { int nCluster = 0; int numberOfDSV = 0; edmNew::DetSetVector::const_iterator DSViter; @@ -93,7 +88,8 @@ void VectorHitBuilderAlgorithmBase::printClusters (const edmNew::DetSetVector(geomDetUnit); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc index 2c27178e0e6a9..bdd97131c2c34 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc @@ -618,13 +618,11 @@ unsigned int Phase2TrackerClusterizerValidationTGraph::getSimTrackId( return 0; } -void Phase2TrackerClusterizerValidationTGraph::fillDescriptions(edm::ConfigurationDescriptions & descriptions){ - - edm::ParameterSetDescription desc; - desc.add("src","siPhase2Clusters"); - desc.add("links",edm::InputTag("simSiPixelDigis", "Tracker")); - descriptions.add("phase2TrackerClusterizerValidationTGraph",desc); +void Phase2TrackerClusterizerValidationTGraph::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("src", "siPhase2Clusters"); + desc.add("links", edm::InputTag("simSiPixelDigis", "Tracker")); + descriptions.add("phase2TrackerClusterizerValidationTGraph", desc); } - DEFINE_FWK_MODULE(Phase2TrackerClusterizerValidationTGraph); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index f555338604e0e..73fe206403763 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -22,7 +22,7 @@ VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet consumes(conf.getParameter("trackingParticleSrc")); } -VectorHitsBuilderValidation::~VectorHitsBuilderValidation() { } +VectorHitsBuilderValidation::~VectorHitsBuilderValidation() {} void VectorHitsBuilderValidation::beginJob() { edm::Service fs; @@ -1212,19 +1212,15 @@ void VectorHitsBuilderValidation::printCluster(const GeomDetUnit* geomDetUnit, c return; } -void VectorHitsBuilderValidation::fillDescriptions(edm::ConfigurationDescriptions & descriptions){ - - edm::ParameterSetDescription desc; - desc.add("src","siPhase2Clusters"); - desc.add("links",edm::InputTag("simSiPixelDigis", "Tracker")); - desc.add("VH_acc",edm::InputTag("siPhase2VectorHits", "vectorHitsAccepted")); - desc.add("VH_rej",edm::InputTag("siPhase2VectorHits", "vectorHitsRejected")); - desc.add("CPE",edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); - desc.add("trackingParticleSrc",edm::InputTag("mix", "MergedTrackTruth")); - descriptions.add("vectorHitsBuilderValidation",desc); +void VectorHitsBuilderValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("src", "siPhase2Clusters"); + desc.add("links", edm::InputTag("simSiPixelDigis", "Tracker")); + desc.add("VH_acc", edm::InputTag("siPhase2VectorHits", "vectorHitsAccepted")); + desc.add("VH_rej", edm::InputTag("siPhase2VectorHits", "vectorHitsRejected")); + desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); + desc.add("trackingParticleSrc", edm::InputTag("mix", "MergedTrackTruth")); + descriptions.add("vectorHitsBuilderValidation", desc); } - - - DEFINE_FWK_MODULE(VectorHitsBuilderValidation); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index c29d5849a1d81..87b92e8054ef3 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -90,6 +90,7 @@ class VectorHitsBuilderValidation : public edm::EDAnalyzer { void analyze(const edm::Event&, const edm::EventSetup&); static void fillDescriptions(edm::ConfigurationDescriptions&); + private: std::map::iterator createLayerHistograms(unsigned int); void CreateVHsXYGraph(const std::vector, const std::vector); @@ -148,5 +149,4 @@ class VectorHitsBuilderValidation : public edm::EDAnalyzer { TH1F* VHrejTrueLayer_ratio; std::map histograms_; - }; diff --git a/RecoTracker/TkSeedGenerator/plugins/SealModules.cc b/RecoTracker/TkSeedGenerator/plugins/SealModules.cc index ee7dd08cc5e6c..4a64f677fc545 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SealModules.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SealModules.cc @@ -39,4 +39,3 @@ DEFINE_FWK_MODULE(SeedCreatorFromRegionConsecutiveHitsEDProducer); using SeedCreatorFromRegionConsecutiveHitsTripletOnlyEDProducer = SeedCreatorFromRegionHitsEDProducerT; DEFINE_FWK_MODULE(SeedCreatorFromRegionConsecutiveHitsTripletOnlyEDProducer); - diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 6a298388a85eb..e0878442d1ba2 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -25,7 +25,6 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/EventSetup.h" - #include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" #include "TrackingTools/MeasurementDet/interface/TrajectoryMeasurementGroup.h" @@ -90,25 +89,24 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { edm::ESGetToken updatorToken_; edm::ESGetToken measurementTrackerToken_; edm::ESGetToken estToken_; - }; SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) : updator_(nullptr), tkMeasEventToken_(consumes(conf.getParameter("trackerEvent"))), topoToken_(esConsumes()), - propagatorToken_(esConsumes(edm::ESInputTag("", "PropagatorWithMaterial" ))), + propagatorToken_(esConsumes(edm::ESInputTag("", "PropagatorWithMaterial"))), magFieldToken_(esConsumes()), updatorToken_(esConsumes()), measurementTrackerToken_(esConsumes()), - estToken_(esConsumes(edm::ESInputTag("","Chi2"))) { + estToken_(esConsumes(edm::ESInputTag("", "Chi2"))) { vhProducerToken_ = consumes(edm::InputTag(conf.getParameter("src"))); beamSpotToken_ = consumes(conf.getParameter("beamSpotLabel")); updatorName_ = conf.getParameter("updator"); produces(); } -SeedingOTEDProducer::~SeedingOTEDProducer() { } +SeedingOTEDProducer::~SeedingOTEDProducer() {} void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -122,7 +120,6 @@ void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descr void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { std::unique_ptr seedsWithVHs(new TrajectorySeedCollection()); - tkTopo_ = &es.getData(topoToken_); edm::ESHandle measurementTrackerHandle; @@ -318,8 +315,6 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& //Helper class to access momentum of VH VectorHitMomentumHelper vhMomHelper(magField_); - - //FIXME::charge is fine 1 every two times!! int charge = 1; float p = vhMomHelper.momentum(vHit); @@ -335,8 +330,8 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p - mat[0][0] = pow( - computeInverseMomentumError(vHit, theta, beamSpot_->sigmaZ(), vhMomHelper.transverseMomentum(vHit)), 2); + mat[0][0] = + pow(computeInverseMomentumError(vHit, theta, beamSpot_->sigmaZ(), vhMomHelper.transverseMomentum(vHit)), 2); //building tsos LocalTrajectoryError lterr(asSMatrix<5>(mat)); From 6fa22296d674519e6fc6c0b30d551f5f87329581 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Sat, 5 Sep 2020 09:51:26 -0500 Subject: [PATCH 044/115] turn VHs off again and fix capitilization of import name --- .../Configuration/python/RecoLocalTracker_cff.py | 2 +- .../interface/VectorHitBuilderAlgorithmBase.h | 1 - .../plugins/SiPhase2RecHitMatcherESProducer.cc | 9 --------- .../python/TrackerRecoGeometryESProducer_cfi.py | 4 ++-- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py index 06ebb798faca2..3cae176059b3b 100644 --- a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py +++ b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py @@ -23,7 +23,7 @@ from RecoLocalTracker.SiPhase2Clusterizer.phase2TrackerClusterizer_cfi import * from RecoLocalTracker.Phase2TrackerRecHits.Phase2StripCPEGeometricESProducer_cfi import * -from RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2RecHitMatcher_cfi import * +from RecoLocalTracker.SiPhase2VectorHitBuilder.siPhase2RecHitMatcher_cfi import * _pixeltrackerlocalrecoTask_phase2 = pixeltrackerlocalrecoTask.copy() _pixeltrackerlocalrecoTask_phase2.add(siPhase2Clusters) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index b3154600a23e1..9850c3a043095 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -28,7 +28,6 @@ class VectorHitBuilderAlgorithmBase { const TrackerTopology*, const ClusterParameterEstimator*); virtual ~VectorHitBuilderAlgorithmBase() {} - // void initialize(const edm::EventSetup&); void initTkGeom(const TrackerGeometry* tkGeomProd); void initTkTopo(const TrackerTopology* tkTopoProd); void initCpe(const ClusterParameterEstimator* cpeProd); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index e9197ae107b5c..5151870c930bb 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -46,15 +46,6 @@ std::unique_ptr SiPhase2RecHitMatcherESProducer::prod &iRecord.getRecord().get(trackerTopoToken_), &iRecord.get(cpeToken_)); - /* edm::ESHandle tGeomHandle = iRecord.getHandle(geometryToken_); - edm::ESHandle tTopoHandle = iRecord.getRecord().getHandle(trackerTopoToken_); - - auto ptr_phase2TrackerCPE = &iRecord.get(cpeToken_); - - matcher->initTkGeom(tGeomHandle); - matcher->initTkTopo(tTopoHandle); - matcher->initCpe(ptr_phase2TrackerCPE); */ - return matcher; } diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 9a87a93207ed2..22d95e29034d3 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", - usePhase2Stacks = cms.bool(True) + usePhase2Stacks = cms.bool(False) ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) From 2536365f3374283e15155b56f9fccbca11611c71 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Sat, 5 Sep 2020 11:40:56 -0500 Subject: [PATCH 045/115] fix overlooked switch from dynamic to static cast --- .../SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index efe23608bdfe3..cbbd5771ba0d2 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -255,7 +255,7 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, //printCluster(stack->upperDet(),&*upper); const PixelGeomDetUnit* geomDetLower = static_cast(stack->lowerDet()); - const PixelGeomDetUnit* geomDetUpper = dynamic_cast(stack->upperDet()); + const PixelGeomDetUnit* geomDetUpper = static_cast(stack->upperDet()); auto&& lparamsLower = cpe->localParameters(*lower, *geomDetLower); // x, y, z, e2_xx, e2_xy, e2_yy Global3DPoint gparamsLower = geomDetLower->surface().toGlobal(lparamsLower.first); From 1009a209cb769101cee17df18ce5bdf95e32b7ab Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Sat, 5 Sep 2020 13:34:05 -0500 Subject: [PATCH 046/115] add vector hits to isFromDet and isFromDataOrFast in trackerHitRTTI --- DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h | 6 ++---- .../plugins/SiPhase2RecHitMatcherESProducer.cc | 2 +- .../TrackAssociation/interface/trackHitsToClusterRefs.h | 8 ++++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h index 9d0a6bab0403d..d3bf716b24409 100644 --- a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h +++ b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h @@ -33,11 +33,9 @@ namespace trackerHitRTTI { inline bool isMatched(TrackingRecHit const& hit) { return rtti(hit) == match || rtti(hit) == fastMatch; } inline bool isMulti(TrackingRecHit const& hit) { return rtti(hit) == multi; } inline bool isSingleType(TrackingRecHit const& hit) { return (rtti(hit) > 0) & (rtti(hit) < 4); } - //inline bool isFromDet(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 6)) | (rtti(hit) == 12)); } - inline bool isFromDet(TrackingRecHit const& hit) { return ((rtti(hit) > 0) & (rtti(hit) < 6)); } + inline bool isFromDet(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 6)) | (rtti(hit) == 12)); } inline bool isFast(TrackingRecHit const& hit) { return (rtti(hit) > 5) & (rtti(hit) <= 9); } - inline bool isFromDetOrFast(TrackingRecHit const& hit) { return ((rtti(hit) > 0) & (rtti(hit) < 10)); } - //inline bool isFromDetOrFast(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 10)) | (rtti(hit) == 12)); } + inline bool isFromDetOrFast(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 10)) | (rtti(hit) == 12)); } inline bool isTiming(TrackingRecHit const& hit) { return rtti(hit) == mipTiming; } inline bool isVector(TrackingRecHit const& hit) { return rtti(hit) == vector; } inline unsigned int projId(TrackingRecHit const& hit) { return hit.rawId() + int(rtti(hit)) - 1; } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc index 5151870c930bb..974a59fc59682 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.cc @@ -78,7 +78,7 @@ void SiPhase2RecHitMatcherESProducer::fillDescriptions(edm::ConfigurationDescrip 0.1, 0.1, }); - descriptions.add("SiPhase2RecHitMatcherESProducer", desc); + descriptions.add("siPhase2RecHitMatcher", desc); } DEFINE_FWK_EVENTSETUP_MODULE(SiPhase2RecHitMatcherESProducer); diff --git a/SimTracker/TrackAssociation/interface/trackHitsToClusterRefs.h b/SimTracker/TrackAssociation/interface/trackHitsToClusterRefs.h index 3a17d4ab3e874..76a56e9f0ebd4 100644 --- a/SimTracker/TrackAssociation/interface/trackHitsToClusterRefs.h +++ b/SimTracker/TrackAssociation/interface/trackHitsToClusterRefs.h @@ -8,6 +8,7 @@ #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h" namespace track_associator { @@ -56,6 +57,13 @@ namespace track_associator { edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!" << " file: " << __FILE__ << " line: " << __LINE__; returnValue.push_back(ph2Hit->omniClusterRef()); + } else if (tid == typeid(VectorHit)) { + const VectorHit *vectorHit = dynamic_cast(rhit); + if (!vectorHit->cluster().isNonnull()) + edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!" + << " file: " << __FILE__ << " line: " << __LINE__; + returnValue.push_back(vectorHit->firstClusterRef()); + } else { auto const &thit = static_cast(*rhit); if (thit.isProjected()) { From b17261dbe4fa3eee252443b21b09540d2d868f90 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Sat, 5 Sep 2020 13:45:59 -0500 Subject: [PATCH 047/115] code format --- DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h index d3bf716b24409..b26198b498f69 100644 --- a/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h +++ b/DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h @@ -35,7 +35,9 @@ namespace trackerHitRTTI { inline bool isSingleType(TrackingRecHit const& hit) { return (rtti(hit) > 0) & (rtti(hit) < 4); } inline bool isFromDet(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 6)) | (rtti(hit) == 12)); } inline bool isFast(TrackingRecHit const& hit) { return (rtti(hit) > 5) & (rtti(hit) <= 9); } - inline bool isFromDetOrFast(TrackingRecHit const& hit) { return (((rtti(hit) > 0) & (rtti(hit) < 10)) | (rtti(hit) == 12)); } + inline bool isFromDetOrFast(TrackingRecHit const& hit) { + return (((rtti(hit) > 0) & (rtti(hit) < 10)) | (rtti(hit) == 12)); + } inline bool isTiming(TrackingRecHit const& hit) { return rtti(hit) == mipTiming; } inline bool isVector(TrackingRecHit const& hit) { return rtti(hit) == vector; } inline unsigned int projId(TrackingRecHit const& hit) { return hit.rawId() + int(rtti(hit)) - 1; } From 01114c04d224e6aabd54028709cbcb6bd33aa94b Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Mon, 7 Sep 2020 21:18:15 -0500 Subject: [PATCH 048/115] small improvements requested by Vincenzo --- .../src/VectorHitBuilderAlgorithm.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index cbbd5771ba0d2..c20a651520f9d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -73,7 +73,7 @@ void VectorHitBuilderAlgorithm::run(edm::Handle lowerClusters; + lowerClusters.reserve(theLowerDetSet.size()); if (theLowerDetSet.size() > 1) LogDebug("VectorHitBuilderAlgorithm") << " more than 1 lower cluster! " << std::endl; if (theUpperDetSet.size() > 1) @@ -151,8 +152,8 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi upperClusters.push_back(clusterUpper); } - std::sort(lowerClusters.begin(), lowerClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->lowerDet())); - std::sort(upperClusters.begin(), upperClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->upperDet())); + std::sort_heap(lowerClusters.begin(), lowerClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->lowerDet())); + std::sort_heap(upperClusters.begin(), upperClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->upperDet())); for (const auto& cluL : lowerClusters) { LogDebug("VectorHitBuilderAlgorithm") << " lower clusters " << std::endl; From 2cdd767fd338dda8470426e075ba655aa2371961 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 8 Sep 2020 14:08:44 -0500 Subject: [PATCH 049/115] protect against invalid TSOSs when propagating between layers --- ...oductionAndTesting_TenMuExtendedE_0_200.py | 105 ------------------ .../plugins/SeedingOTEDProducer.cc | 21 +++- 2 files changed, 15 insertions(+), 111 deletions(-) delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting_TenMuExtendedE_0_200.py diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting_TenMuExtendedE_0_200.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting_TenMuExtendedE_0_200.py deleted file mode 100644 index 45c7942ff29e4..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting_TenMuExtendedE_0_200.py +++ /dev/null @@ -1,105 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('RECO',eras.Phase2C2) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') -process.load('Configuration.StandardSequences.MagneticField_cff') -process.load('Configuration.StandardSequences.RawToDigi_cff') -process.load('Configuration.StandardSequences.L1Reco_cff') -process.load('Configuration.StandardSequences.Reconstruction_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -#adding only recolocalreco -process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') - -# import VectorHitBuilder -process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') - - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1000) -) - -# Input source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('file:step2_TenMuExtendedE_0_200.root'), - secondaryFileNames = cms.untracked.vstring(), - #skipEvents = cms.untracked.uint32(0), - #eventsToProcess = cms.untracked.VEventRange('1:952-1:952') -) - -process.options = cms.untracked.PSet( - -) - -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('step3 nevts:10'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Output definition - -process.RECOSIMoutput = cms.OutputModule("PoolOutputModule", - dataset = cms.untracked.PSet( - dataTier = cms.untracked.string('GEN-SIM-RECO'), - filterName = cms.untracked.string('') - ), - eventAutoFlushCompressedSize = cms.untracked.int32(5242880), - fileName = cms.untracked.string('file:step3_1event.root'), - outputCommands = cms.untracked.vstring( ('keep *') ), - splitLevel = cms.untracked.int32(0) -) - -# debug -#process.MessageLogger = cms.Service("MessageLogger", -# destinations = cms.untracked.vstring("debugVH_tilted"), -# debugModules = cms.untracked.vstring("*"), -# categories = cms.untracked.vstring("VectorHitBuilderEDProducer","VectorHitBuilderAlgorithm","VectorHitsBuilderValidation","VectorHitBuilder"), -# debugVH_tilted = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), -# DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), -# default = cms.untracked.PSet(limit = cms.untracked.int32(0)), -# VectorHitBuilder = cms.untracked.PSet(limit = cms.untracked.int32(-1)), -# VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), -# VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), -# VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) -# ) -# ) - -# Analyzer -process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', - src = cms.string("siPhase2Clusters"), - VH_acc = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), - VH_rej = cms.InputTag("siPhase2VectorHits", "vectorHitsRejected"), - CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE"), - links = cms.InputTag("simSiPixelDigis", "Tracker"), - trackingParticleSrc = cms.InputTag('mix', 'MergedTrackTruth'), -) -process.TFileService = cms.Service('TFileService', - fileName = cms.string('file:VHs_validation_TenMu_new.root') -) - - -# Other statements -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') - -# Path and EndPath definitions -process.raw2digi_step = cms.Path(process.RawToDigi) -process.L1Reco_step = cms.Path(process.L1Reco) -process.trackerlocalreco_step = cms.Path(process.trackerlocalreco+process.siPhase2VectorHits) -process.analysis_step = cms.Path(process.analysis) -process.RECOSIMoutput_step = cms.EndPath(process.RECOSIMoutput) - -# Schedule definition -process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.trackerlocalreco_step,process.RECOSIMoutput_step, process.analysis_step) - diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index e0878442d1ba2..e4a18f53b17dc 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -92,12 +92,12 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { }; SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) - : updator_(nullptr), - tkMeasEventToken_(consumes(conf.getParameter("trackerEvent"))), + //: updator_(nullptr), + : tkMeasEventToken_(consumes(conf.getParameter("trackerEvent"))), topoToken_(esConsumes()), propagatorToken_(esConsumes(edm::ESInputTag("", "PropagatorWithMaterial"))), magFieldToken_(esConsumes()), - updatorToken_(esConsumes()), + updatorToken_(esConsumes(edm::ESInputTag("","KFUpdator"))), measurementTrackerToken_(esConsumes()), estToken_(esConsumes(edm::ESInputTag("", "Chi2"))) { vhProducerToken_ = consumes(edm::InputTag(conf.getParameter("src"))); @@ -122,14 +122,17 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) tkTopo_ = &es.getData(topoToken_); - edm::ESHandle measurementTrackerHandle; +/* edm::ESHandle measurementTrackerHandle; measurementTrackerHandle = es.getHandle(measurementTrackerToken_); + measurementTracker_ = measurementTrackerHandel.product();*/ + edm::ESHandle measurementTrackerHandle = es.getHandle(measurementTrackerToken_); measurementTracker_ = measurementTrackerHandle.product(); edm::Handle measurementTrackerEvent; event.getByToken(tkMeasEventToken_, measurementTrackerEvent); - LayerMeasurements layerMeasurements_(*measurementTrackerHandle, *measurementTrackerEvent); + //LayerMeasurements layerMeasurements_(*measurementTrackerHandle, *measurementTrackerEvent); + layerMeasurements_ = new LayerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); estimator_ = &es.getData(estToken_); @@ -251,8 +254,12 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle updatedTSOSL2_final = propagateAndUpdate(updatedTSOSL1_final, *buildingPropagator, *hitL2); - std::pair updatedTSOSL3_final = + if (!updatedTSOSL2_final.first) + continue; + std::pair updatedTSOSL3_final = propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, hitL3); + if (!updatedTSOSL3_final.first) + continue; TrajectorySeed ts = createSeed(updatedTSOSL3_final.second, container, hitL3.geographicalId(), *buildingPropagator); result.push_back(ts); @@ -356,6 +363,8 @@ AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) { std::pair SeedingOTEDProducer::propagateAndUpdate( const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit) { TrajectoryStateOnSurface propTSOS = prop.propagate(initialTSOS, hit.det()->surface()); + if UNLIKELY (!propTSOS.isValid()) + return std::make_pair(false, propTSOS); TrajectoryStateOnSurface updatedTSOS = updator_->update(propTSOS, hit); if UNLIKELY (!updatedTSOS.isValid()) return std::make_pair(false, updatedTSOS); From ccf9e94eb1a9900cfecfd103a45db4b3b3b367ab Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 8 Sep 2020 14:29:48 -0500 Subject: [PATCH 050/115] update validation configs to run on current RelVals --- .../plugins/VectorHitBuilderEDProducer.cc | 3 +- .../test/Clusters_productionAndTesting.py | 17 ++++++-- ... => VHs_SeedingOT_productionAndTesting.py} | 25 +++++++---- .../test/VHs_combinatorialStudies_PU200.py | 42 ++++++++++++------- .../test/VHs_productionAndTesting.py | 30 ++++++------- .../TrackerRecoGeometryESProducer_cfi.py | 4 +- 6 files changed, 76 insertions(+), 45 deletions(-) rename RecoLocalTracker/SiPhase2VectorHitBuilder/test/{step3_SeedingOT_tilted.py => VHs_SeedingOT_productionAndTesting.py} (69%) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc index 6a7f8427e5631..d313d4bc920c9 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -34,7 +34,8 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT> clusterProducer_; }; -VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; } +//VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; } +VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { } VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) : offlinestubsTag_(conf.getParameter("offlinestubs")), diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py index 7728a15e402a2..cac36312ac6a7 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/Clusters_productionAndTesting.py @@ -24,7 +24,7 @@ process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') # import VectorHitBuilder -process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.siPhase2VectorHits_cfi') process.maxEvents = cms.untracked.PSet( @@ -33,7 +33,17 @@ # Input source process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('/store/relval/CMSSW_11_1_0_pre6/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/FF928A27-31CB-9C4D-93E0-475E2E73326E.root'), + fileNames = cms.untracked.vstring('/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/863B48BB-03ED-0548-AA60-1269291ED1E6.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/9B6E3A66-B330-8E42-B85E-96A9952A002E.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/29706FE9-16C9-CE4F-B744-66E07B250D1E.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/AAB16BEE-B0CE-644A-8E96-35236D793C04.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/36F89E35-DE2F-174B-95B7-7A9423DED2D8.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/1BE0A565-4F64-8D42-A5D5-62692F64F0A5.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/8671B5C9-DE1F-8B4C-8A1C-9C99898FE191.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/6CA0E490-73F4-1147-906D-050B8B3A3134.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/AFAB961F-E31F-064D-9031-BEAA10702345.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/2AB6718E-EEA6-494B-AC25-B59CF36DF941.root', + ), secondaryFileNames = cms.untracked.vstring(), skipEvents = cms.untracked.uint32(0) ) @@ -58,7 +68,8 @@ ), eventAutoFlushCompressedSize = cms.untracked.int32(5242880), fileName = cms.untracked.string('file:step3_1event.root'), - outputCommands = cms.untracked.vstring( ('keep *') ), + outputCommands = process.RECOSIMEventContent.outputCommands, + #outputCommands = cms.untracked.vstring( ('keep *') ), splitLevel = cms.untracked.int32(0) ) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/step3_SeedingOT_tilted.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py similarity index 69% rename from RecoLocalTracker/SiPhase2VectorHitBuilder/test/step3_SeedingOT_tilted.py rename to RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py index d91869a0a3f97..2b8480df625d5 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/step3_SeedingOT_tilted.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py @@ -2,7 +2,7 @@ from Configuration.StandardSequences.Eras import eras -process = cms.Process('RECO',eras.Phase2C2) +process = cms.Process('RECO',eras.Phase2C9) # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') @@ -10,7 +10,7 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Configuration.Geometry.GeometryExtended2023D4Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.RawToDigi_cff') process.load('Configuration.StandardSequences.L1Reco_cff') @@ -21,7 +21,7 @@ process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') # import VectorHitBuilder -process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.siPhase2VectorHits_cfi') process.maxEvents = cms.untracked.PSet( @@ -30,8 +30,17 @@ # Input source process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('file:21207_10events/step2.root'), - #fileNames = cms.untracked.vstring('/store/relval/CMSSW_8_1_0_pre7/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/81X_mcRun2_asymptotic_v0_2023tilted-v1/10000/2E7CB262-1534-E611-BB7A-0CC47A78A496.root'), + fileNames = cms.untracked.vstring('/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/863B48BB-03ED-0548-AA60-1269291ED1E6.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/9B6E3A66-B330-8E42-B85E-96A9952A002E.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/29706FE9-16C9-CE4F-B744-66E07B250D1E.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/AAB16BEE-B0CE-644A-8E96-35236D793C04.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/36F89E35-DE2F-174B-95B7-7A9423DED2D8.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/1BE0A565-4F64-8D42-A5D5-62692F64F0A5.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/8671B5C9-DE1F-8B4C-8A1C-9C99898FE191.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/6CA0E490-73F4-1147-906D-050B8B3A3134.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/AFAB961F-E31F-064D-9031-BEAA10702345.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/2AB6718E-EEA6-494B-AC25-B59CF36DF941.root', + ), secondaryFileNames = cms.untracked.vstring(), skipEvents = cms.untracked.uint32(0) ) @@ -56,14 +65,14 @@ ), eventAutoFlushCompressedSize = cms.untracked.int32(5242880), fileName = cms.untracked.string('file:step3_1event.root'), - outputCommands = cms.untracked.vstring( ('keep *') ), + outputCommands = process.RECOSIMEventContent.outputCommands, splitLevel = cms.untracked.int32(0) ) # Analyzer process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', src = cms.string("siPhase2Clusters"), - src2 = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), + VH_acc = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), links = cms.InputTag("simSiPixelDigis", "Tracker") ) process.TFileService = cms.Service('TFileService', @@ -107,8 +116,6 @@ # Schedule definition process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.trackerlocalreco_step,process.seedingOT_step,process.RECOSIMoutput_step, process.analysis_step) -#process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.trackerlocalreco_step,process.RECOSIMoutput_step) -#process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.reconstruction_step,process.prevalidation_step,process.validation_step,process.dqmoffline_step,process.FEVTDEBUGHLToutput_step,process.DQMoutput_step) # customisation of the process. diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py index 70c46e4ea1d2e..88e0af4c221fa 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py @@ -22,7 +22,7 @@ process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') # import VectorHitBuilder -process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.siPhase2VectorHits_cfi') process.maxEvents = cms.untracked.PSet( @@ -31,16 +31,18 @@ # Input source process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/02ACC76A-C93F-E711-B711-0CC47A4C8EC8.root', - '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/02FD72C1-D53F-E711-BD00-0CC47A7C3420.root', - '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/04EC6BD2-D53F-E711-B2B7-0025905B858E.root', - '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/061B97AF-C93F-E711-A425-0CC47A4C8F12.root', - '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/081DAA75-C93F-E711-8CAF-0025905B85CA.root', - '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0A1C6B0E-C93F-E711-9145-0CC47A7C3412.root', - '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0AE954E1-D53F-E711-AA9C-0CC47A4D7632.root', - '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0C0660A9-CA3F-E711-8583-0CC47A745298.root', - '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0C66279B-CA3F-E711-A4B3-0CC47A7AB7A0.root', - '/store/relval/CMSSW_9_1_1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/0E5BF643-D43F-E711-A64C-0CC47A7C34E6.root'), + fileNames = cms.untracked.vstring( +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/C7A95D39-8FAB-D746-8C06-B11AECA047DD.root', +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/E4D19FDC-9192-2F44-A4FA-21AB5A93344C.root', +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/04E557E8-C456-B148-9EC6-2E5E40BD03C6.root', +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/284ACE29-A506-CD40-9059-899981D7931C.root', +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/5ACFC231-EBF6-2B4F-A88F-D01171F506CE.root', +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/8E76FEBA-FF9B-544D-9C17-C5B31777FE39.root', +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/2958EE82-39A5-154A-9650-5E97AAD44B3E.root', +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/943CFE41-83ED-F04B-AA74-435821572336.root', +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/01D965C0-05A4-C543-A676-7C6C67DC2175.root', +'/store/relval/CMSSW_11_2_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/20000/7D171FAD-4E5B-824A-A0DF-07175F0A9550.root', +), #fileNames = cms.untracked.vstring('file:step2.root'), secondaryFileNames = cms.untracked.vstring(), skipEvents = cms.untracked.uint32(0) @@ -66,7 +68,8 @@ ), eventAutoFlushCompressedSize = cms.untracked.int32(5242880), fileName = cms.untracked.string('file:step3_PU200.root'), - outputCommands = cms.untracked.vstring( ('keep *') ), + outputCommands = process.RECOSIMEventContent.outputCommands, + #outputCommands = cms.untracked.vstring( ('keep *') ), splitLevel = cms.untracked.int32(0) ) @@ -78,8 +81,6 @@ debugVH_PU200 = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), default = cms.untracked.PSet(limit = cms.untracked.int32(0)), - #VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), - #VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) ) ) @@ -103,7 +104,18 @@ process.mix.bunchspace = cms.int32(25) process.mix.minBunch = cms.int32(-3) process.mix.maxBunch = cms.int32(3) -process.mix.input.fileNames = cms.untracked.vstring(['/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/0A883B39-083F-E711-8B09-0CC47A7C357A.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/22E509DA-053F-E711-AA7A-0025905B85BA.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/3E376DB4-043F-E711-985E-0CC47A74524E.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/509E21AC-023F-E711-A9F3-0025905B8604.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/5E53AC15-0A3F-E711-8965-0025905A60E0.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/62EC67CA-0B3F-E711-81AC-0025905A610C.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/6476C3E7-063F-E711-B412-0025905B855A.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/7256251B-0B3F-E711-BBEF-0CC47A78A3B4.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/8C943DC3-0B3F-E711-BA5F-0CC47A7C34B0.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/C092AF3B-083F-E711-A0EC-0025905A6070.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/DE2E5EC5-013F-E711-BE84-0CC47A78A3EC.root', '/store/relval/CMSSW_9_1_1/RelValMinBias_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D17-v1/10000/DE80A4D4-093F-E711-8195-0CC47A4D75F6.root']) +process.mix.input.fileNames = cms.untracked.vstring([ +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/09AA31DF-737A-B142-A82B-6E48B4B965CD.root', +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/A18897B2-7509-C845-B83A-CEE4AC55FF86.root', +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/184F91C7-EA57-2B49-9E85-D1F494152CDD.root', +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/A505AC6C-6DEA-484C-8FFC-1EA4B54892F5.root', +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/5636AD91-D035-0B44-8D53-2B4FFE6A7722.root', +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/03D1F17E-33EE-A94C-A869-00071F1F45C7.root', +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/EB99E4B3-838A-CC4C-B1B2-8A9D1E1EB453.root', +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/7F44A9B9-38C1-484F-9B4B-DCD0FD7224A8.root', +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/2A3CCF08-CDD1-6246-827F-27CD0CC42478.root', +'/store/relval/CMSSW_11_2_0_pre5/RelValMinBias_14TeV/GEN-SIM-DIGI-RAW/110X_mcRun4_realistic_v3_2026D49noPU-v1/20000/0745B823-5DB0-B74F-B0A6-78E24ED39EE5.root', +]) process.mix.playback = True process.mix.digitizers = cms.PSet() for a in process.aliases: delattr(process, a) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py index fd60e10fcb5dc..0618b7982446a 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py @@ -2,7 +2,7 @@ from Configuration.StandardSequences.Eras import eras -process = cms.Process('RECO',eras.Phase2C2) +process = cms.Process('RECO',eras.Phase2C9) # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') @@ -10,7 +10,7 @@ process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.RawToDigi_cff') process.load('Configuration.StandardSequences.L1Reco_cff') @@ -21,7 +21,7 @@ process.load('RecoLocalTracker.Configuration.RecoLocalTracker_cff') # import VectorHitBuilder -process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2VectorHitBuilder_cfi') +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.siPhase2VectorHits_cfi') process.maxEvents = cms.untracked.PSet( @@ -30,17 +30,17 @@ # Input source process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/0A0A27B4-153F-E711-ABC3-0025905A60C6.root', - '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/34817EB0-163F-E711-83C8-0CC47A7C340C.root', - '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/3CC9FD4E-173F-E711-B4DF-0025905A60D6.root', - '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/521169DF-173F-E711-BC3D-0CC47A7C35A4.root', - '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/6E767157-163F-E711-B315-0025905B8560.root', - '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/7A9BAA32-173F-E711-B7CA-0CC47A78A496.root', - '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/BA5F8EE0-173F-E711-97E9-0025905A6122.root', - '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/CA0AE5B2-153F-E711-B1CE-0025905B85EE.root', - '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/DEFFF299-173F-E711-9A88-0CC47A4C8EE2.root', - '/store/relval/CMSSW_9_1_1/RelValSingleMuPt10Extended/GEN-SIM-DIGI-RAW/91X_upgrade2023_realistic_v1_D17-v1/10000/FA58F15E-163F-E711-B748-0025905A607A.root'), - #fileNames = cms.untracked.vstring('file:step2.root'), + fileNames = cms.untracked.vstring('/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/863B48BB-03ED-0548-AA60-1269291ED1E6.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/9B6E3A66-B330-8E42-B85E-96A9952A002E.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/29706FE9-16C9-CE4F-B744-66E07B250D1E.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/AAB16BEE-B0CE-644A-8E96-35236D793C04.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/36F89E35-DE2F-174B-95B7-7A9423DED2D8.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/1BE0A565-4F64-8D42-A5D5-62692F64F0A5.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/8671B5C9-DE1F-8B4C-8A1C-9C99898FE191.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/6CA0E490-73F4-1147-906D-050B8B3A3134.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/AFAB961F-E31F-064D-9031-BEAA10702345.root', + '/store/relval/CMSSW_11_2_0_pre3/RelValSingleMuFlatPt2To100/GEN-SIM-DIGI-RAW/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/2AB6718E-EEA6-494B-AC25-B59CF36DF941.root', + ), secondaryFileNames = cms.untracked.vstring(), skipEvents = cms.untracked.uint32(0) ) @@ -65,7 +65,7 @@ ), eventAutoFlushCompressedSize = cms.untracked.int32(5242880), fileName = cms.untracked.string('file:step3_1event.root'), - outputCommands = cms.untracked.vstring( ('keep *') ), + outputCommands = process.RECOSIMEventContent.outputCommands, splitLevel = cms.untracked.int32(0) ) diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 22d95e29034d3..9a87a93207ed2 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", - usePhase2Stacks = cms.bool(False) + usePhase2Stacks = cms.bool(True) ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) From 33bbeff0a76a8cbfb91d6f2459b795b9ae6dd898 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 8 Sep 2020 16:38:00 -0500 Subject: [PATCH 051/115] made a lot of functions const --- .../plugins/SeedingOTEDProducer.cc | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index e4a18f53b17dc..7213cb57758e9 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -46,21 +46,21 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { unsigned int checkLayer(unsigned int iidd); std::vector collectVHsOnLayer(edm::Handle, unsigned int); void printVHsOnLayer(edm::Handle, unsigned int); - const TrajectoryStateOnSurface buildInitialTSOS(VectorHit&); - AlgebraicSymMatrix assign44To55(AlgebraicSymMatrix); + const TrajectoryStateOnSurface buildInitialTSOS(VectorHit&) const; + AlgebraicSymMatrix assign44To55(AlgebraicSymMatrix) const; std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, const Propagator&, - const TrackingRecHit& hit); - float computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot); + const TrackingRecHit& hit) const; + float computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot) const; float computeInverseMomentumError(VectorHit& vh, const float globalTheta, const double sigmaZ_beamSpot, - const double transverseMomentum); + const double transverseMomentum) const; TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, const DetId& id, - const Propagator& prop); + const Propagator& prop) const; struct isInvalid { bool operator()(const TrajectoryMeasurement& measurement) { @@ -73,7 +73,7 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT vhProducerToken_; const TrackerTopology* tkTopo_; const MeasurementTracker* measurementTracker_; - const LayerMeasurements* layerMeasurements_; + std::unique_ptr layerMeasurements_; const MeasurementEstimator* estimator_; const Propagator* propagator_; const MagneticField* magField_; @@ -132,7 +132,7 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) event.getByToken(tkMeasEventToken_, measurementTrackerEvent); //LayerMeasurements layerMeasurements_(*measurementTrackerHandle, *measurementTrackerEvent); - layerMeasurements_ = new LayerMeasurements(*measurementTrackerHandle, *measurementTrackerEvent); + layerMeasurements_ = std::make_unique(*measurementTrackerHandle, *measurementTrackerEvent); estimator_ = &es.getData(estToken_); @@ -312,7 +312,7 @@ void SeedingOTEDProducer::printVHsOnLayer(edm::Handle VH } } -const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& vHit) { +const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& vHit) const { // having fun with theta Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); float theta = gv.theta(); @@ -347,7 +347,7 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& return tsos; } -AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) { +AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) const{ if (mat44.num_row() != 4 || mat44.num_col() != 4) assert("Wrong dimension! This should be a 4x4 matrix!"); @@ -361,7 +361,7 @@ AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) { } std::pair SeedingOTEDProducer::propagateAndUpdate( - const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit) { + const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit) const { TrajectoryStateOnSurface propTSOS = prop.propagate(initialTSOS, hit.det()->surface()); if UNLIKELY (!propTSOS.isValid()) return std::make_pair(false, propTSOS); @@ -371,7 +371,7 @@ std::pair SeedingOTEDProducer::propagateAndUpdat return std::make_pair(true, updatedTSOS); } -float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot) { +float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot) const { double derivative = vh.globalPosition().perp() / (pow(vh.globalPosition().z(), 2) + pow(vh.globalPosition().perp(), 2)); double derivative2 = pow(derivative, 2); @@ -381,7 +381,7 @@ float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const do float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, const float globalTheta, const double sigmaZ_beamSpot, - const double transverseMomentum) { + const double transverseMomentum) const { //for pT > 2GeV, 1/pT has sigma = 1/sqrt(12) float varianceInverseTransvMomentum = 1. / 12; float derivativeTheta2 = pow(cos(globalTheta) / transverseMomentum, 2); @@ -394,7 +394,7 @@ float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, TrajectorySeed SeedingOTEDProducer::createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, const DetId& id, - const Propagator& prop) { + const Propagator& prop) const { PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos, id.rawId()); return TrajectorySeed(seedTSOS, container, prop.propagationDirection()); } From 758d273d7a94c91825f9c188f930c9f9d2f93ee1 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 8 Sep 2020 17:21:37 -0500 Subject: [PATCH 052/115] more improvements to SeedingOTEDProducer --- .../interface/VectorHitMomentumHelper.h | 4 +- .../plugins/SeedingOTEDProducer.cc | 39 ++++++++----------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h index f0c37453093fe..dbe8b1096fc2c 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h @@ -13,11 +13,11 @@ class VectorHitMomentumHelper { } ~VectorHitMomentumHelper() {} - float transverseMomentum(VectorHit& vh) const { + float transverseMomentum(const VectorHit& vh) const { float rho = 1. / vh.curvatureORphi(VectorHit::curvatureMode).first; return (intermediate * rho); } - float momentum(VectorHit& vh) const { return transverseMomentum(vh) / (1. * sin(vh.theta())); } + float momentum(const VectorHit& vh) const { return transverseMomentum(vh) / (1. * sin(vh.theta())); } private: float intermediate; diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 7213cb57758e9..330a44eeb88f6 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -44,15 +44,15 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { TrajectorySeedCollection run(edm::Handle); unsigned int checkLayer(unsigned int iidd); - std::vector collectVHsOnLayer(edm::Handle, unsigned int); - void printVHsOnLayer(edm::Handle, unsigned int); - const TrajectoryStateOnSurface buildInitialTSOS(VectorHit&) const; + std::vector collectVHsOnLayer(const edmNew::DetSetVector&, unsigned int); + void printVHsOnLayer(const edmNew::DetSetVector&, unsigned int); + const TrajectoryStateOnSurface buildInitialTSOS(const VectorHit&) const; AlgebraicSymMatrix assign44To55(AlgebraicSymMatrix) const; std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, const Propagator&, const TrackingRecHit& hit) const; float computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot) const; - float computeInverseMomentumError(VectorHit& vh, + float computeInverseMomentumError(const VectorHit& vh, const float globalTheta, const double sigmaZ_beamSpot, const double transverseMomentum) const; @@ -165,9 +165,9 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle vhSeedsL1 = collectVHsOnLayer(VHs, 1); - std::vector vhSeedsL2 = collectVHsOnLayer(VHs, 2); - std::vector vhSeedsL3 = collectVHsOnLayer(VHs, 3); + std::vector vhSeedsL1 = collectVHsOnLayer(*(VHs.product()), 1); + std::vector vhSeedsL2 = collectVHsOnLayer(*(VHs.product()), 2); + std::vector vhSeedsL3 = collectVHsOnLayer(*(VHs.product()), 3); if (vhSeedsL1.empty() || vhSeedsL2.empty() || vhSeedsL3.empty()) { return result; } @@ -180,7 +180,7 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handleclone(); buildingPropagator->setPropagationDirection(alongMomentum); - for (auto hitL3 : vhSeedsL3) { + for (const auto& hitL3 : vhSeedsL3) { //building a tsos out of a VectorHit const TrajectoryStateOnSurface initialTSOS = buildInitialTSOS(hitL3); float signZ = copysign(1.0, initialTSOS.globalPosition().z()); @@ -196,11 +196,6 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle measurementsL2 = layerMeasurements_->measurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator_); - //other options - //LayerMeasurements::SimpleHitContainer hits; - //layerMeasurements->recHits(hits, *barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); - //auto && measurementsL2G = layerMeasurements->groupedMeasurements(*barrelOTLayer2, initialTSOS, *searchingPropagator, *estimator); - std::vector::iterator measurementsL2end = std::remove_if(measurementsL2.begin(), measurementsL2.end(), isInvalid()); measurementsL2.erase(measurementsL2end, measurementsL2.end()); @@ -281,12 +276,11 @@ unsigned int SeedingOTEDProducer::checkLayer(unsigned int iidd) { return 0; } -std::vector SeedingOTEDProducer::collectVHsOnLayer(edm::Handle VHs, +std::vector SeedingOTEDProducer::collectVHsOnLayer(const edmNew::DetSetVector& input, unsigned int layerNumber) { - const VectorHitCollectionNew& input = *VHs; std::vector VHsOnLayer; if (!input.empty()) { - for (auto DSViter : input) { + for (const auto& DSViter : input) { if (checkLayer(DSViter.id()) == layerNumber) { for (const auto& vh : DSViter) { VHsOnLayer.push_back(vh); @@ -298,21 +292,20 @@ std::vector SeedingOTEDProducer::collectVHsOnLayer(edm::Handle VHs, unsigned int layerNumber) { - const VectorHitCollectionNew& input = *VHs; +void SeedingOTEDProducer::printVHsOnLayer(const edmNew::DetSetVector& input, unsigned int layerNumber) { if (!input.empty()) { - for (auto DSViter : input) { + for (const auto& DSViter : input) { for (const auto& vh : DSViter) { if (checkLayer(DSViter.id()) == layerNumber) - std::cout << " VH in layer " << layerNumber << " >> " << vh << std::endl; + LogTrace("SeedingOTEDProducer") << " VH in layer " << layerNumber << " >> " << vh; } } } else { - std::cout << " No VHs in layer " << layerNumber << "." << std::endl; + LogTrace("SeedingOTEDProducer") << " No VHs in layer " << layerNumber << "."; } } -const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(VectorHit& vHit) const { +const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const VectorHit& vHit) const { // having fun with theta Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); float theta = gv.theta(); @@ -378,7 +371,7 @@ float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const do return pow(derivative2 * vh.lowerGlobalPosErr().czz() + derivative2 * pow(sigmaZ_beamSpot, 2), 0.5); } -float SeedingOTEDProducer::computeInverseMomentumError(VectorHit& vh, +float SeedingOTEDProducer::computeInverseMomentumError(const VectorHit& vh, const float globalTheta, const double sigmaZ_beamSpot, const double transverseMomentum) const { From 754d08c0b093ced8aab9810ee8bb8f765694144e Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 8 Sep 2020 17:44:02 -0500 Subject: [PATCH 053/115] more improvements to SeedingOTEDProducer and Phase2OTBarrelRodBuilder --- .../plugins/TkStackMeasurementDet.cc | 3 --- .../TkDetLayers/src/Phase2OTBarrelRodBuilder.cc | 16 ++++++---------- .../plugins/SeedingOTEDProducer.cc | 10 +++------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index ed13d52d1e0de..176211395063c 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -39,8 +39,6 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj begin = &(data.phase2OTData().handle()->data().front()); } - //VectorHitBuilderAlgorithm* algo = theMatcher; - //VectorHitBuilderAlgorithm* vhalgo = dynamic_cast(algobase); LogTrace("MeasurementTracker") << "TkStackMeasurementDet::recHits algo has been set" << std::endl; const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); @@ -101,7 +99,6 @@ bool TkStackMeasurementDet::measurements(const TrajectoryStateOnSurface& stateOn for (auto&& hit : allHits) { std::pair diffEst = est.estimate(stateOnThisDet, *hit); - //LogTrace("MeasurementTracker")<< "State on this Det: " << stateOnThisDet ; LogDebug("MeasurementTracker") << "New vh added with chi2: " << diffEst.second; if (diffEst.first) result.add(std::move(hit), diffEst.second); diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc index 0153f2bab2861..6ac4e8c0248fb 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc @@ -23,7 +23,6 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 for (vector::const_iterator compGeometricDets = allGeometricDets.begin(); compGeometricDets != allGeometricDets.end(); compGeometricDets++) { - //LogTrace("TkDetLayers") << " compGeometricDets.positionBounds().perp() " << (*compGeometricDets)->positionBounds().perp() << std::endl; meanR = meanR + (*compGeometricDets)->positionBounds().perp(); } meanR = meanR / allGeometricDets.size(); @@ -64,14 +63,11 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 vector outerGeomDetBrothers; double meanRBrothers = 0; - for (vector::const_iterator it = allGeometricDets.begin(); it != allGeometricDets.end(); - it++) { - compGeometricDets = (*it)->components(); + for (auto& it : allGeometricDets) { + compGeometricDets = it->components(); if (compGeometricDets.size() != 2) { LogDebug("TkDetLayers") << " Stack not with two components but with " << compGeometricDets.size() << std::endl; } else { - //LogTrace("TkDetLayers") << " compGeometricDets[0]->positionBounds().perp() " << compGeometricDets[0]->positionBounds().perp() << std::endl; - //LogTrace("TkDetLayers") << " compGeometricDets[1]->positionBounds().perp() " << compGeometricDets[1]->positionBounds().perp() << std::endl; meanR = meanR + compGeometricDets[0]->positionBounds().perp(); meanRBrothers = meanRBrothers + compGeometricDets[1]->positionBounds().perp(); } @@ -81,10 +77,10 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl; LogDebug("TkDetLayers") << " meanR Upper " << meanRBrothers << std::endl; - for (vector::iterator it = allGeometricDets.begin(); it != allGeometricDets.end(); it++) { - compGeometricDets = (*it)->components(); + for (auto& it : allGeometricDets) { + compGeometricDets = it->components(); const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets[0]->geographicalID()); - LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[0]->geographicalID().rawId() << std::endl; + LogTrace("TkDetLayers") << " inserting " << compGeometricDets[0]->geographicalID().rawId() << std::endl; if (compGeometricDets[0]->positionBounds().perp() < meanR) innerGeomDets.push_back(theGeomDet); @@ -93,7 +89,7 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 outerGeomDets.push_back(theGeomDet); const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet(compGeometricDets[1]->geographicalID()); - LogTrace("TkDetLayers") << " inserisco " << compGeometricDets[1]->geographicalID().rawId() << std::endl; + LogTrace("TkDetLayers") << " inserting " << compGeometricDets[1]->geographicalID().rawId() << std::endl; if (compGeometricDets[1]->positionBounds().perp() < meanRBrothers) innerGeomDetBrothers.push_back(theGeomDetBrother); diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 330a44eeb88f6..600bab3ea71c0 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -118,20 +118,16 @@ void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descr } void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { - std::unique_ptr seedsWithVHs(new TrajectorySeedCollection()); + auto seedsWithVHs = std::make_unique(); tkTopo_ = &es.getData(topoToken_); -/* edm::ESHandle measurementTrackerHandle; - measurementTrackerHandle = es.getHandle(measurementTrackerToken_); - measurementTracker_ = measurementTrackerHandel.product();*/ edm::ESHandle measurementTrackerHandle = es.getHandle(measurementTrackerToken_); measurementTracker_ = measurementTrackerHandle.product(); edm::Handle measurementTrackerEvent; event.getByToken(tkMeasEventToken_, measurementTrackerEvent); - //LayerMeasurements layerMeasurements_(*measurementTrackerHandle, *measurementTrackerEvent); layerMeasurements_ = std::make_unique(*measurementTrackerHandle, *measurementTrackerEvent); estimator_ = &es.getData(estToken_); @@ -153,8 +149,8 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) event.getByToken(vhProducerToken_, vhs); TrajectorySeedCollection const& tempSeeds = run(vhs); - for (TrajectorySeedCollection::const_iterator qIt = tempSeeds.begin(); qIt < tempSeeds.end(); ++qIt) { - seedsWithVHs->push_back(*qIt); + for (auto& qIt : tempSeeds) { + seedsWithVHs->push_back(qIt); } seedsWithVHs->shrink_to_fit(); From 403ac04cf093c516186d6b156246c199f26c788b Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 8 Sep 2020 19:22:14 -0500 Subject: [PATCH 054/115] Kevin's comments on a couple of files --- .../test/ClustersValidationTGraph.cc | 186 +++----- .../test/VectorHitsValidation.cc | 429 ++++++++---------- .../test/VectorHitsValidation.h | 18 +- .../src/TrackClusterRemoverPhase2.cc | 2 +- RecoTracker/CkfPattern/src/PrintoutHelper.cc | 5 +- RecoTracker/MeasurementDet/BuildFile.xml | 2 +- 6 files changed, 249 insertions(+), 393 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc index bdd97131c2c34..e55abd65260f7 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc @@ -3,7 +3,7 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -67,7 +67,7 @@ struct ClusterHistos { TH1F* otherSimHits; }; -class Phase2TrackerClusterizerValidationTGraph : public edm::EDAnalyzer { +class Phase2TrackerClusterizerValidationTGraph : public edm::one::EDAnalyzer { public: typedef std::map > SimHitsMap; typedef std::map SimTracksMap; @@ -89,10 +89,10 @@ class Phase2TrackerClusterizerValidationTGraph : public edm::EDAnalyzer { edm::EDGetTokenT simHitsToken_; edm::EDGetTokenT simTracksToken_; edm::EDGetTokenT simVerticesToken_; - const TrackerGeometry* tkGeom; - const TrackerTopology* tkTopo; + const TrackerGeometry* tkGeom_; + const TrackerTopology* tkTopo_; - TTree* tree; + TTree* tree_; TGraph* trackerLayout_[3]; TGraph* trackerLayoutXY_[3]; TGraph* trackerLayoutXYBar_; @@ -117,26 +117,26 @@ void Phase2TrackerClusterizerValidationTGraph::beginJob() { fs->file().cd("/"); TFileDirectory td = fs->mkdir("Common"); //Create common ntuple - tree = td.make("Phase2TrackerClusters", "Phase2TrackerClusters"); + tree_ = td.make("Phase2TrackerClusters", "Phase2TrackerClusters"); // Create common histograms - trackerLayout_[0] = td.make(); //"RVsZ_Mixed", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); + trackerLayout_[0] = td.make(); trackerLayout_[0]->SetName("RVsZ_Mixed"); - trackerLayout_[1] = td.make(); //"RVsZ_Pixel", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); + trackerLayout_[1] = td.make(); trackerLayout_[1]->SetName("RVsZ_Pixel"); - trackerLayout_[2] = td.make(); //"RVsZ_Strip", "R vs. z position", 6000, -300.0, 300.0, 1200, 0.0, 120.0); + trackerLayout_[2] = td.make(); trackerLayout_[2]->SetName("RVsZ_Strip"); trackerLayoutXY_[0] = - td.make(); //"XVsY_Mixed", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + td.make(); trackerLayoutXY_[0]->SetName("YVsX_Mixed"); trackerLayoutXY_[1] = - td.make(); //"XVsY_Pixel", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + td.make(); trackerLayoutXY_[1]->SetName("YVsX_Pixel"); trackerLayoutXY_[2] = - td.make(); //"XVsY_Strip", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + td.make(); trackerLayoutXY_[2]->SetName("YVsX_Strip"); - trackerLayoutXYBar_ = td.make(); //"XVsYBar", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXYBar_ = td.make(); trackerLayoutXYBar_->SetName("YVsXBar"); - trackerLayoutXYEC_ = td.make(); //"XVsYEC", "x vs. y position", 2400, -120.0, 120.0, 2400, -120.0, 120.0); + trackerLayoutXYEC_ = td.make(); trackerLayoutXYEC_->SetName("YVsXEC"); } @@ -156,8 +156,6 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, // Get the SimHits edm::Handle simHitsRaw; event.getByToken(simHitsToken_, simHitsRaw); - // edm::Handle< edm::PSimHitContainer > simHitsRawEndcap; - // event.getByLabel("g4SimHits", "TrackerHitsPixelEndcapLowTof", simHitsRawEndcap); // Get the SimTracks edm::Handle simTracksRaw; @@ -170,77 +168,73 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, // Get the geometry edm::ESHandle geomHandle; eventSetup.get().get(geomHandle); - tkGeom = &(*geomHandle); + tkGeom_ = &(*geomHandle); edm::ESHandle tTopoHandle; eventSetup.get().get(tTopoHandle); - tkTopo = tTopoHandle.product(); + tkTopo_ = tTopoHandle.product(); //set up for tree int layer_number; - //int track_id; int module_id; int module_number; int module_type; //1: pixel, 2: strip float x_global, y_global, z_global; float x_local, y_local, z_local; - tree->Branch("layer_number", &layer_number, "layer_number/I"); - //tree -> Branch("track_id",&track_id,"track_id/I"); - tree->Branch("module_id", &module_id, "module_id/I"); - tree->Branch("module_type", &module_type, "module_type/I"); - tree->Branch("module_number", &module_number, "module_number/I"); - tree->Branch("x_global", &x_global, "x_global/F"); - tree->Branch("y_global", &y_global, "y_global/F"); - tree->Branch("z_global", &z_global, "z_global/F"); - tree->Branch("x_local", &x_local, "x_local/F"); - tree->Branch("y_local", &y_local, "y_local/F"); - tree->Branch("z_local", &z_local, "z_local/F"); + tree_->Branch("layer_number", &layer_number, "layer_number/I"); + tree_->Branch("module_id", &module_id, "module_id/I"); + tree_->Branch("module_type", &module_type, "module_type/I"); + tree_->Branch("module_number", &module_number, "module_number/I"); + tree_->Branch("x_global", &x_global, "x_global/F"); + tree_->Branch("y_global", &y_global, "y_global/F"); + tree_->Branch("z_global", &z_global, "z_global/F"); + tree_->Branch("x_local", &x_local, "x_local/F"); + tree_->Branch("y_local", &y_local, "y_local/F"); + tree_->Branch("z_local", &z_local, "z_local/F"); // Rearrange the simTracks for ease of use SimTracksMap simTracks; - for (edm::SimTrackContainer::const_iterator simTrackIt(simTracksRaw->begin()); simTrackIt != simTracksRaw->end(); - ++simTrackIt) - simTracks.insert(std::pair(simTrackIt->trackId(), *simTrackIt)); + for (const auto& simTrackIt : *simTracksRaw) + simTracks.emplace(std::pair(simTrackIt.trackId(), simTrackIt)); // Rearrange the simHits by detUnit // Rearrange the simHits for ease of use SimHitsMap simHitsDetUnit; SimHitsMap simHitsTrackId; - for (edm::PSimHitContainer::const_iterator simHitIt(simHitsRaw->begin()); simHitIt != simHitsRaw->end(); ++simHitIt) { - SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt->detUnitId())); + for (const auto& simHitIt: *simHitsRaw) { + SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt.detUnitId())); if (simHitsDetUnitIt == simHitsDetUnit.end()) { std::pair newIt(simHitsDetUnit.insert( - std::pair >(simHitIt->detUnitId(), std::vector()))); + std::pair >(simHitIt.detUnitId(), std::vector()))); simHitsDetUnitIt = newIt.first; } - simHitsDetUnitIt->second.push_back(*simHitIt); - SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt->trackId())); + simHitsDetUnitIt->second.push_back(simHitIt); + SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt.trackId())); if (simHitsTrackIdIt == simHitsTrackId.end()) { std::pair newIt(simHitsTrackId.insert( - std::pair >(simHitIt->trackId(), std::vector()))); + std::pair >(simHitIt.trackId(), std::vector()))); simHitsTrackIdIt = newIt.first; } - simHitsTrackIdIt->second.push_back(*simHitIt); + simHitsTrackIdIt->second.push_back(simHitIt); } // ValidationTGraph unsigned int nClustersTot(0), nClustersPixelTot(0), nClustersStripTot(0); // Loop over modules - for (Phase2TrackerCluster1DCollectionNew::const_iterator DSViter = clusters->begin(); DSViter != clusters->end(); - ++DSViter) { + for (const auto& DSViter : *clusters) { // Get the detector unit's id - unsigned int rawid(DSViter->detId()); + unsigned int rawid(DSViter.detId()); module_id = rawid; DetId detId(rawid); - layer_number = getLayerNumber(detId, tkTopo); - module_number = getModuleNumber(detId, tkTopo); - unsigned int layer(getLayerNumber(detId, tkTopo)); + layer_number = getLayerNumber(detId, tkTopo_); + module_number = getModuleNumber(detId, tkTopo_); + unsigned int layer(getLayerNumber(detId, tkTopo_)); // Get the geometry of the tracker - const GeomDetUnit* geomDetUnit(tkGeom->idToDetUnit(detId)); + const GeomDetUnit* geomDetUnit(tkGeom_->idToDetUnit(detId)); const PixelGeomDetUnit* theGeomDet = dynamic_cast(geomDetUnit); const PixelTopology& topol = theGeomDet->specificTopology(); @@ -256,10 +250,9 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, unsigned int nClustersPixel(0), nClustersStrip(0); // Loop over the clusters in the detector unit - for (edmNew::DetSet::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); - ++clustIt) { + for (const auto& clustIt : DSViter) { // Cluster related variables - MeasurementPoint mpClu(clustIt->center(), clustIt->column() + 0.5); + MeasurementPoint mpClu(clustIt.center(), clustIt.column() + 0.5); Local3DPoint localPosClu = geomDetUnit->topology().localPosition(mpClu); x_local = localPosClu.x(); y_local = localPosClu.y(); @@ -290,7 +283,7 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, histogramLayer->second.localPosXY[1]->SetPoint(nClustersPixelTot, localPosClu.x(), localPosClu.y()); histogramLayer->second.globalPosXY[1]->SetPoint(nClustersPixelTot, globalPosClu.x(), globalPosClu.y()); - histogramLayer->second.clusterSizePixel->Fill(clustIt->size()); + histogramLayer->second.clusterSizePixel->Fill(clustIt.size()); ++nClustersPixel; ++nClustersPixelTot; } @@ -302,7 +295,7 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, histogramLayer->second.localPosXY[2]->SetPoint(nClustersStripTot, localPosClu.x(), localPosClu.y()); histogramLayer->second.globalPosXY[2]->SetPoint(nClustersStripTot, globalPosClu.x(), globalPosClu.y()); - histogramLayer->second.clusterSizeStrip->Fill(clustIt->size()); + histogramLayer->second.clusterSizeStrip->Fill(clustIt.size()); ++nClustersStrip; ++nClustersStripTot; } @@ -312,81 +305,22 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, std::vector clusterSimTrackIds; // Get all the simTracks that form the cluster - for (unsigned int i(0); i < clustIt->size(); ++i) { + for (unsigned int i(0); i < clustIt.size(); ++i) { unsigned int channel(PixelDigi::pixelToChannel( - clustIt->firstRow() + i, - clustIt - ->column())); // Here we have to use the old pixelToChannel function (not Phase2TrackerDigi but PixelDigi), change this when using new Digis + clustIt.firstRow() + i, + clustIt.column())); // Here we have to use the old pixelToChannel function (not Phase2TrackerDigi but PixelDigi), change this when using new Digis unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detId, channel)); clusterSimTrackIds.push_back(simTrackId); } - /* - // SimHits related variables - - - - unsigned int primarySimHits(0); - unsigned int otherSimHits(0); - - for (edm::PSimHitContainer::const_iterator hitIt(simHitsRaw->begin()); hitIt != simHitsRaw->end(); ++hitIt) { - if (rawid == hitIt->detUnitId() and std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt->trackId()) != clusterSimTrackIds.end()) { - Local3DPoint localPosHit(hitIt->localPosition()); - - histogramLayer->second.deltaXClusterSimHits[0]->Fill(localPosClu.x() - localPosHit.x()); - histogramLayer->second.deltaYClusterSimHits[0]->Fill(localPosClu.y() - localPosHit.y()); - - // Pixel module - if (topol.ncolumns() == 32) { - histogramLayer->second.deltaXClusterSimHits[1]->Fill(localPosClu.x() - localPosHit.x()); - histogramLayer->second.deltaYClusterSimHits[1]->Fill(localPosClu.y() - localPosHit.y()); - } - // Strip module - else if (topol.ncolumns() == 2) { - histogramLayer->second.deltaXClusterSimHits[2]->Fill(localPosClu.x() - localPosHit.x()); - histogramLayer->second.deltaYClusterSimHits[2]->Fill(localPosClu.y() - localPosHit.y()); - } - - ++otherSimHits; - - std::map< unsigned int, SimTrack >::const_iterator simTrackIt(simTracks.find(hitIt->trackId())); - if (simTrackIt == simTracks.end()) continue; - - // Primary particles only - unsigned int processType(hitIt->processType()); - if (simTrackIt->second.vertIndex() == 0 and (processType == 2 || processType == 7 || processType == 9 || processType == 11 || processType == 13 || processType == 15)) { - histogramLayer->second.deltaXClusterSimHits_P[0]->Fill(localPosClu.x() - localPosHit.x()); - histogramLayer->second.deltaYClusterSimHits_P[0]->Fill(localPosClu.y() - localPosHit.y()); - - // Pixel module - if (topol.ncolumns() == 32) { - histogramLayer->second.deltaXClusterSimHits_P[1]->Fill(localPosClu.x() - localPosHit.x()); - histogramLayer->second.deltaYClusterSimHits_P[1]->Fill(localPosClu.y() - localPosHit.y()); - } - // Strip module - else if (topol.ncolumns() == 2) { - histogramLayer->second.deltaXClusterSimHits_P[2]->Fill(localPosClu.x() - localPosHit.x()); - histogramLayer->second.deltaYClusterSimHits_P[2]->Fill(localPosClu.y() - localPosHit.y()); - } - - ++primarySimHits; - } - } - } - - otherSimHits -= primarySimHits; - - histogramLayer->second.primarySimHits->Fill(primarySimHits); - histogramLayer->second.otherSimHits->Fill(otherSimHits); -*/ - } + } if (nClustersPixel) histogramLayer->second.numberClusterPixel->Fill(nClustersPixel); if (nClustersStrip) histogramLayer->second.numberClusterStrip->Fill(nClustersStrip); nClustersTot++; - tree->Fill(); + tree_->Fill(); } } @@ -467,37 +401,37 @@ std::map::iterator Phase2TrackerClusterizerValidati histoName.str(""); histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; local_histos.localPosXY[0] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + td.make(); local_histos.localPosXY[0]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Local_Position_XY_Pixel" << tag.c_str() << id; local_histos.localPosXY[1] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + td.make(); local_histos.localPosXY[1]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Local_Position_XY_Strip" << tag.c_str() << id; local_histos.localPosXY[2] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + td.make(); local_histos.localPosXY[2]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; local_histos.globalPosXY[0] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + td.make(); local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_Pixel" << tag.c_str() << id; local_histos.globalPosXY[1] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + td.make(); local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_Strip" << tag.c_str() << id; local_histos.globalPosXY[2] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + td.make(); local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); /* @@ -585,8 +519,6 @@ unsigned int Phase2TrackerClusterizerValidationTGraph::getLayerNumber(const DetI return (topo->pxbLayer(detid)); else if (detid.subdetId() == PixelSubdetector::PixelEndcap) return (100 * topo->pxfSide(detid) + topo->pxfDisk(detid)); - else - return 999; } return 999; } @@ -611,9 +543,9 @@ unsigned int Phase2TrackerClusterizerValidationTGraph::getSimTrackId( edm::DetSetVector::const_iterator DSViter(siphase2SimLinks->find(detId)); if (DSViter == siphase2SimLinks->end()) return 0; - for (edm::DetSet::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { - if (channel == it->channel()) - return it->SimTrackId(); + for (const auto& it : DSViter->data) { + if (channel == it.channel()) + return it.SimTrackId(); } return 0; } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 73fe206403763..548bac202e449 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -30,7 +30,7 @@ void VectorHitsBuilderValidation::beginJob() { TFileDirectory td = fs->mkdir("Common"); //Create common ntuple - tree = td.make("VectorHits", "VectorHits"); + tree_ = td.make("VectorHits", "VectorHits"); // Create common graphs TFileDirectory tdGloPos = td.mkdir("GlobalPositions"); @@ -68,10 +68,6 @@ void VectorHitsBuilderValidation::beginJob() { //drawing VHs arrows TFileDirectory tdArr = td.mkdir("Directions"); - //VHXY_[0] = tdArr.make< TCanvas >(); VHXY_[0] -> SetName("YVsX_Mixed"); - //VHXY_[1] = tdArr.make< TCanvas >(); VHXY_[1] -> SetName("YVsX_Pixel"); - //VHXY_[2] = tdArr.make< TCanvas >(); VHXY_[2] -> SetName("YVsX_Strip"); - TFileDirectory tdWid = td.mkdir("CombinatorialStudies"); ParallaxCorrectionRZ_ = tdWid.make("ParallaxCorrectionRZ", "ParallaxCorrectionRZ", 100, 0., 300., 100., 0., 120.); @@ -89,10 +85,6 @@ void VectorHitsBuilderValidation::beginJob() { VHrejTrue_signal_Layer_ = tdWid.make("VHrejTrueSignalLayer", "VHrejTrueSignalLayer", 250, 0., 250.); VHrejTrue_signal_Layer_->SetName("VHrejected_true_signal"); - VHaccTrueLayer_ratio = tdWid.make("VHaccTrueLayer_ratio", "VHaccTrueLayer_ratio", 250, 0., 250.); - VHaccTrueLayer_ratio->SetName("VHaccepted_true_ratio"); - VHrejTrueLayer_ratio = tdWid.make("VHrejTrueLayer_ratio", "VHrejTrueLayer_ratio", 250, 0., 250.); - VHrejTrueLayer_ratio->SetName("VHrejected_true_ratio"); } void VectorHitsBuilderValidation::endJob() {} @@ -114,7 +106,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev // load the cpe via the eventsetup edm::ESHandle > cpeHandle; eventSetup.get().get(cpeTag_, cpeHandle); - cpe = cpeHandle.product(); + cpe_ = cpeHandle.product(); // Get the Phase2 DigiSimLink edm::Handle > siphase2SimLinks; @@ -123,8 +115,6 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev // Get the SimHits edm::Handle simHitsRaw; event.getByToken(simHitsToken_, simHitsRaw); - // edm::Handle< edm::PSimHitContainer > simHitsRawEndcap; - // event.getByLabel("g4SimHits", "TrackerHitsPixelEndcapLowTof", simHitsRawEndcap); // Get the SimTracks edm::Handle simTracksRaw; @@ -137,16 +127,16 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev // Get the geometry edm::ESHandle geomHandle; eventSetup.get().get(geomHandle); - tkGeom = &(*geomHandle); + tkGeom_ = &(*geomHandle); // Get the Topology edm::ESHandle tTopoHandle; eventSetup.get().get(tTopoHandle); - tkTopo = tTopoHandle.product(); + tkTopo_ = tTopoHandle.product(); edm::ESHandle magFieldHandle; eventSetup.get().get(magFieldHandle); - magField = magFieldHandle.product(); + magField_ = magFieldHandle.product(); //Tracking Particle collection edm::Handle TPCollectionH; @@ -200,109 +190,106 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev float width, deltaXlocal; unsigned int processType(99); - tree->Branch("event", &eventNum, "eventNum/I"); - tree->Branch("accepted", &VHacc, "VHacc/I"); - tree->Branch("rejected", &VHrej, "VHrej/I"); - tree->Branch("layer", &layer, "layer/I"); - tree->Branch("module_id", &module_id, "module_id/I"); - tree->Branch("module_type", &module_type, "module_type/I"); - tree->Branch("module_number", &module_number, "module_number/I"); - tree->Branch("vh_isTrue", &vh_isTrue, "vh_isTrue/I"); - tree->Branch("x_global", &x_global, "x_global/F"); - tree->Branch("y_global", &y_global, "y_global/F"); - tree->Branch("z_global", &z_global, "z_global/F"); - tree->Branch("vh_x_local", &vh_x_local, "vh_x_local/F"); - tree->Branch("vh_y_local", &vh_y_local, "vh_y_local/F"); - tree->Branch("vh_x_lError", &vh_x_le, "vh_x_le/F"); - tree->Branch("vh_y_lError", &vh_y_le, "vh_y_le/F"); - tree->Branch("curvature", &curvature, "curvature/F"); - tree->Branch("chi2", &chi2, "chi2/F"); - tree->Branch("phi", &phi, "phi/F"); - tree->Branch("QOverP", &QOverP, "QOverP/F"); - tree->Branch("QOverPT", &QOverPT, "QOverPT/F"); - tree->Branch("low_tp_id", &low_tp_id, "low_tp_id/I"); - tree->Branch("upp_tp_id", &upp_tp_id, "upp_tp_id/I"); - tree->Branch("vh_sim_trackPt", &vh_sim_trackPt, "vh_sim_trackPt/F"); - tree->Branch("sim_x_local", &sim_x_local, "sim_x_local/F"); - tree->Branch("sim_y_local", &sim_y_local, "sim_y_local/F"); - tree->Branch("sim_x_global", &sim_x_global, "sim_x_global/F"); - tree->Branch("sim_y_global", &sim_y_global, "sim_y_global/F"); - tree->Branch("sim_z_global", &sim_z_global, "sim_z_global/F"); - tree->Branch("low_x_global", &low_x_global, "low_x_global/F"); - tree->Branch("low_y_global", &low_y_global, "low_y_global/F"); - tree->Branch("low_z_global", &low_z_global, "low_z_global/F"); - tree->Branch("low_xx_global_err", &low_xx_global_err, "low_xx_global_err/F"); - tree->Branch("low_yy_global_err", &low_yy_global_err, "low_yy_global_err/F"); - tree->Branch("low_zz_global_err", &low_zz_global_err, "low_zz_global_err/F"); - tree->Branch("low_xy_global_err", &low_xy_global_err, "low_xy_global_err/F"); - tree->Branch("low_zx_global_err", &low_zx_global_err, "low_zx_global_err/F"); - tree->Branch("low_zy_global_err", &low_zy_global_err, "low_zy_global_err/F"); - tree->Branch("upp_x_global", &upp_x_global, "upp_x_global/F"); - tree->Branch("upp_y_global", &upp_y_global, "upp_y_global/F"); - tree->Branch("upp_z_global", &upp_z_global, "upp_z_global/F"); - tree->Branch("upp_xx_global_err", &upp_xx_global_err, "upp_xx_global_err/F"); - tree->Branch("upp_yy_global_err", &upp_yy_global_err, "upp_yy_global_err/F"); - tree->Branch("upp_zz_global_err", &upp_zz_global_err, "upp_zz_global_err/F"); - tree->Branch("upp_xy_global_err", &upp_xy_global_err, "upp_xy_global_err/F"); - tree->Branch("upp_zx_global_err", &upp_zx_global_err, "upp_zx_global_err/F"); - tree->Branch("upp_zy_global_err", &upp_zy_global_err, "upp_zy_global_err/F"); - tree->Branch("deltaXVHSimHits", &deltaXVHSimHits, "deltaXVHSimHits/F"); - tree->Branch("deltaYVHSimHits", &deltaYVHSimHits, "deltaYVHSimHits/F"); - tree->Branch("multiplicity", &multiplicity, "multiplicity/I"); - tree->Branch("width", &width, "width/F"); - tree->Branch("deltaXlocal", &deltaXlocal, "deltaXlocal/F"); - tree->Branch("processType", &processType, "processType/i"); + tree_->Branch("event", &eventNum, "eventNum/I"); + tree_->Branch("accepted", &VHacc, "VHacc/I"); + tree_->Branch("rejected", &VHrej, "VHrej/I"); + tree_->Branch("layer", &layer, "layer/I"); + tree_->Branch("module_id", &module_id, "module_id/I"); + tree_->Branch("module_type", &module_type, "module_type/I"); + tree_->Branch("module_number", &module_number, "module_number/I"); + tree_->Branch("vh_isTrue", &vh_isTrue, "vh_isTrue/I"); + tree_->Branch("x_global", &x_global, "x_global/F"); + tree_->Branch("y_global", &y_global, "y_global/F"); + tree_->Branch("z_global", &z_global, "z_global/F"); + tree_->Branch("vh_x_local", &vh_x_local, "vh_x_local/F"); + tree_->Branch("vh_y_local", &vh_y_local, "vh_y_local/F"); + tree_->Branch("vh_x_lError", &vh_x_le, "vh_x_le/F"); + tree_->Branch("vh_y_lError", &vh_y_le, "vh_y_le/F"); + tree_->Branch("curvature", &curvature, "curvature/F"); + tree_->Branch("chi2", &chi2, "chi2/F"); + tree_->Branch("phi", &phi, "phi/F"); + tree_->Branch("QOverP", &QOverP, "QOverP/F"); + tree_->Branch("QOverPT", &QOverPT, "QOverPT/F"); + tree_->Branch("low_tp_id", &low_tp_id, "low_tp_id/I"); + tree_->Branch("upp_tp_id", &upp_tp_id, "upp_tp_id/I"); + tree_->Branch("vh_sim_trackPt", &vh_sim_trackPt, "vh_sim_trackPt/F"); + tree_->Branch("sim_x_local", &sim_x_local, "sim_x_local/F"); + tree_->Branch("sim_y_local", &sim_y_local, "sim_y_local/F"); + tree_->Branch("sim_x_global", &sim_x_global, "sim_x_global/F"); + tree_->Branch("sim_y_global", &sim_y_global, "sim_y_global/F"); + tree_->Branch("sim_z_global", &sim_z_global, "sim_z_global/F"); + tree_->Branch("low_x_global", &low_x_global, "low_x_global/F"); + tree_->Branch("low_y_global", &low_y_global, "low_y_global/F"); + tree_->Branch("low_z_global", &low_z_global, "low_z_global/F"); + tree_->Branch("low_xx_global_err", &low_xx_global_err, "low_xx_global_err/F"); + tree_->Branch("low_yy_global_err", &low_yy_global_err, "low_yy_global_err/F"); + tree_->Branch("low_zz_global_err", &low_zz_global_err, "low_zz_global_err/F"); + tree_->Branch("low_xy_global_err", &low_xy_global_err, "low_xy_global_err/F"); + tree_->Branch("low_zx_global_err", &low_zx_global_err, "low_zx_global_err/F"); + tree_->Branch("low_zy_global_err", &low_zy_global_err, "low_zy_global_err/F"); + tree_->Branch("upp_x_global", &upp_x_global, "upp_x_global/F"); + tree_->Branch("upp_y_global", &upp_y_global, "upp_y_global/F"); + tree_->Branch("upp_z_global", &upp_z_global, "upp_z_global/F"); + tree_->Branch("upp_xx_global_err", &upp_xx_global_err, "upp_xx_global_err/F"); + tree_->Branch("upp_yy_global_err", &upp_yy_global_err, "upp_yy_global_err/F"); + tree_->Branch("upp_zz_global_err", &upp_zz_global_err, "upp_zz_global_err/F"); + tree_->Branch("upp_xy_global_err", &upp_xy_global_err, "upp_xy_global_err/F"); + tree_->Branch("upp_zx_global_err", &upp_zx_global_err, "upp_zx_global_err/F"); + tree_->Branch("upp_zy_global_err", &upp_zy_global_err, "upp_zy_global_err/F"); + tree_->Branch("deltaXVHSimHits", &deltaXVHSimHits, "deltaXVHSimHits/F"); + tree_->Branch("deltaYVHSimHits", &deltaYVHSimHits, "deltaYVHSimHits/F"); + tree_->Branch("multiplicity", &multiplicity, "multiplicity/I"); + tree_->Branch("width", &width, "width/F"); + tree_->Branch("deltaXlocal", &deltaXlocal, "deltaXlocal/F"); + tree_->Branch("processType", &processType, "processType/i"); // Rearrange the simTracks for ease of use SimTracksMap simTracks; - for (edm::SimTrackContainer::const_iterator simTrackIt(simTracksRaw->begin()); simTrackIt != simTracksRaw->end(); - ++simTrackIt) - simTracks.insert(std::pair(simTrackIt->trackId(), *simTrackIt)); + for (const auto& simTrackIt : *simTracksRaw.product()) + simTracks.emplace(std::pair(simTrackIt.trackId(), simTrackIt)); // Rearrange the simHits by detUnit for ease of use SimHitsMap simHitsDetUnit; SimHitsMap simHitsTrackId; - for (edm::PSimHitContainer::const_iterator simHitIt(simHitsRaw->begin()); simHitIt != simHitsRaw->end(); ++simHitIt) { - SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt->detUnitId())); + for (const auto& simHitIt : *simHitsRaw.product()) { + SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt.detUnitId())); if (simHitsDetUnitIt == simHitsDetUnit.end()) { std::pair newIt(simHitsDetUnit.insert( - std::pair >(simHitIt->detUnitId(), std::vector()))); + std::pair >(simHitIt.detUnitId(), std::vector()))); simHitsDetUnitIt = newIt.first; } - simHitsDetUnitIt->second.push_back(*simHitIt); + simHitsDetUnitIt->second.push_back(simHitIt); - SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt->trackId())); + SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt.trackId())); if (simHitsTrackIdIt == simHitsTrackId.end()) { std::pair newIt(simHitsTrackId.insert( - std::pair >(simHitIt->trackId(), std::vector()))); + std::pair >(simHitIt.trackId(), std::vector()))); simHitsTrackIdIt = newIt.first; } - simHitsTrackIdIt->second.push_back(*simHitIt); + simHitsTrackIdIt->second.push_back(simHitIt); } //Printout outer tracker clusters in the event - for (Phase2TrackerCluster1DCollectionNew::const_iterator DSViter = clusters->begin(); DSViter != clusters->end(); - ++DSViter) { - unsigned int rawid(DSViter->detId()); + for (const auto& DSViter : *clusters) { + unsigned int rawid(DSViter.detId()); DetId detId(rawid); - const GeomDetUnit* geomDetUnit(tkGeom->idToDetUnit(detId)); + const GeomDetUnit* geomDetUnit(tkGeom_->idToDetUnit(detId)); const PixelGeomDetUnit* theGeomDet = dynamic_cast(geomDetUnit); - for (edmNew::DetSet::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); - ++clustIt) { - auto&& lparams = cpe->localParameters(*clustIt, *theGeomDet); + for (const auto& clustIt : DSViter) { + auto&& lparams = cpe_->localParameters(clustIt, *theGeomDet); Global3DPoint gparams = theGeomDet->surface().toGlobal(lparams.first); LogTrace("VectorHitsBuilderValidation") << "phase2 OT clusters: " << gparams << " DetId: " << rawid; } } - for (VectorHitCollectionNew::const_iterator DSViter = vhsAcc->begin(); DSViter != vhsAcc->end(); ++DSViter) { - for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { - LogTrace("VectorHitsBuilderValidation") << "accepted VH: " << *vhIt; + for (const auto& DSViter : *vhsAcc) { + for (const auto& vhIt : DSViter) { + LogTrace("VectorHitsBuilderValidation") << "accepted VH: " << vhIt; } } - for (VectorHitCollectionNew::const_iterator DSViter = vhsRej->begin(); DSViter != vhsRej->end(); ++DSViter) { - for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { - LogTrace("VectorHitsBuilderValidation") << "rejected VH: " << *vhIt; + for (const auto& DSViter : *vhsRej) { + for (const auto& vhIt :DSViter) { + LogTrace("VectorHitsBuilderValidation") << "rejected VH: " << vhIt; } } // Validation @@ -314,9 +301,9 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev std::vector detIds; // Loop over modules - for (VectorHitCollectionNew::const_iterator DSViter = vhsAcc->begin(); DSViter != vhsAcc->end(); ++DSViter) { + for (const auto DSViter : *vhsAcc) { // Get the detector unit's id - unsigned int rawid(DSViter->detId()); + unsigned int rawid(DSViter.detId()); module_id = rawid; DetId detId(rawid); @@ -326,7 +313,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev LogDebug("VectorHitsBuilderValidation") << "Layer: " << layer << " det id" << rawid << std::endl; // Get the geometry of the tracker - const GeomDet* geomDet(tkGeom->idToDet(detId)); + const GeomDet* geomDet(tkGeom_->idToDet(detId)); if (!geomDet) break; @@ -337,22 +324,22 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev // Number of clusters unsigned int nVHsPS(0), nVHs2S(0); - LogDebug("VectorHitsBuilderValidation") << "DSViter size: " << DSViter->size(); + LogDebug("VectorHitsBuilderValidation") << "DSViter size: " << DSViter.size(); // Loop over the vhs in the detector unit - for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + for (const auto& vhIt : DSViter) { // vh variables - if (vhIt->isValid()) { + if (vhIt.isValid()) { LogDebug("VectorHitsBuilderValidation") << " vh analyzing ..."; - chi2 = vhIt->chi2(); + chi2 = vhIt.chi2(); LogTrace("VectorHitsBuilderValidation") << "VH chi2 " << chi2 << std::endl; - Local3DPoint localPosVH = vhIt->localPosition(); + Local3DPoint localPosVH = vhIt.localPosition(); vh_x_local = localPosVH.x(); vh_y_local = localPosVH.y(); LogTrace("VectorHitsBuilderValidation") << "local VH position " << localPosVH << std::endl; - LocalError localErrVH = vhIt->localPositionError(); + LocalError localErrVH = vhIt.localPositionError(); vh_x_le = localErrVH.xx(); vh_y_le = localErrVH.yy(); LogTrace("VectorHitsBuilderValidation") << "local VH error " << localErrVH << std::endl; @@ -364,10 +351,10 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev glVHs.push_back(globalPosVH); LogTrace("VectorHitsBuilderValidation") << " global VH position " << globalPosVH << std::endl; - Local3DVector localDirVH = vhIt->localDirection(); + Local3DVector localDirVH = vhIt.localDirection(); LogTrace("VectorHitsBuilderValidation") << "local VH direction " << localDirVH << std::endl; - VectorHit vh = *vhIt; + VectorHit vh = vhIt; Global3DVector globalDirVH = vh.globalDelta(); dirVHs.push_back(globalDirVH); LogTrace("VectorHitsBuilderValidation") << "global VH direction " << globalDirVH << std::endl; @@ -393,7 +380,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev DetId lowerDetId = stackDet->lowerDet()->geographicalId(); DetId upperDetId = stackDet->upperDet()->geographicalId(); - TrackerGeometry::ModuleType mType = tkGeom->getDetectorType(lowerDetId); + TrackerGeometry::ModuleType mType = tkGeom_->getDetectorType(lowerDetId); module_type = 0; if (mType == TrackerGeometry::ModuleType::Ph2PSP) { module_type = 1; @@ -430,50 +417,50 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev LogTrace("VectorHitsBuilderValidation") << "module type " << module_type << std::endl; // get the geomDetUnit of the clusters - low_x_global = vhIt->lowerGlobalPos().x(); - low_y_global = vhIt->lowerGlobalPos().y(); - low_z_global = vhIt->lowerGlobalPos().z(); - upp_x_global = vhIt->upperGlobalPos().x(); - upp_y_global = vhIt->upperGlobalPos().y(); - upp_z_global = vhIt->upperGlobalPos().z(); - - low_xx_global_err = vhIt->lowerGlobalPosErr().cxx(); - low_yy_global_err = vhIt->lowerGlobalPosErr().cyy(); - low_zz_global_err = vhIt->lowerGlobalPosErr().czz(); - low_xy_global_err = vhIt->lowerGlobalPosErr().cyx(); - low_zx_global_err = vhIt->lowerGlobalPosErr().czx(); - low_zy_global_err = vhIt->lowerGlobalPosErr().czy(); - - upp_xx_global_err = vhIt->upperGlobalPosErr().cxx(); - upp_yy_global_err = vhIt->upperGlobalPosErr().cyy(); - upp_zz_global_err = vhIt->upperGlobalPosErr().czz(); - upp_xy_global_err = vhIt->upperGlobalPosErr().cyx(); - upp_zx_global_err = vhIt->upperGlobalPosErr().czx(); - upp_zy_global_err = vhIt->upperGlobalPosErr().czy(); + low_x_global = vhIt.lowerGlobalPos().x(); + low_y_global = vhIt.lowerGlobalPos().y(); + low_z_global = vhIt.lowerGlobalPos().z(); + upp_x_global = vhIt.upperGlobalPos().x(); + upp_y_global = vhIt.upperGlobalPos().y(); + upp_z_global = vhIt.upperGlobalPos().z(); + + low_xx_global_err = vhIt.lowerGlobalPosErr().cxx(); + low_yy_global_err = vhIt.lowerGlobalPosErr().cyy(); + low_zz_global_err = vhIt.lowerGlobalPosErr().czz(); + low_xy_global_err = vhIt.lowerGlobalPosErr().cyx(); + low_zx_global_err = vhIt.lowerGlobalPosErr().czx(); + low_zy_global_err = vhIt.lowerGlobalPosErr().czy(); + + upp_xx_global_err = vhIt.upperGlobalPosErr().cxx(); + upp_yy_global_err = vhIt.upperGlobalPosErr().cyy(); + upp_zz_global_err = vhIt.upperGlobalPosErr().czz(); + upp_xy_global_err = vhIt.upperGlobalPosErr().cyx(); + upp_zx_global_err = vhIt.upperGlobalPosErr().czx(); + upp_zy_global_err = vhIt.upperGlobalPosErr().czy(); LogDebug("VectorHitsBuilderValidation") << "print Clusters into the VH:" << std::endl; - printCluster(geomDetLower, vhIt->lowerClusterRef()); - LogTrace("VectorHitsBuilderValidation") << "\t global pos lower " << vhIt->lowerGlobalPos() << std::endl; + printCluster(geomDetLower, vhIt.lowerClusterRef()); + LogTrace("VectorHitsBuilderValidation") << "\t global pos lower " << vhIt.lowerGlobalPos() << std::endl; LogTrace("VectorHitsBuilderValidation") - << "\t global posErr lower " << vhIt->lowerGlobalPosErr().cxx() << std::endl; + << "\t global posErr lower " << vhIt.lowerGlobalPosErr().cxx() << std::endl; const GeomDetUnit* geomDetUpper = stackDet->upperDet(); - printCluster(geomDetUpper, vhIt->upperClusterRef()); - LogTrace("VectorHitsBuilderValidation") << "\t global pos upper " << vhIt->upperGlobalPos() << std::endl; + printCluster(geomDetUpper, vhIt.upperClusterRef()); + LogTrace("VectorHitsBuilderValidation") << "\t global pos upper " << vhIt.upperGlobalPos() << std::endl; //comparison with SIM hits LogDebug("VectorHitsBuilderValidation") << "comparison Clusters with sim hits ... " << std::endl; std::vector clusterSimTrackIds; std::vector clusterSimTrackIdsUpp; std::set > simTkIds; - const GeomDetUnit* geomDetUnit_low(tkGeom->idToDetUnit(lowerDetId)); + const GeomDetUnit* geomDetUnit_low(tkGeom_->idToDetUnit(lowerDetId)); LogTrace("VectorHitsBuilderValidation") << " lowerDetID : " << lowerDetId.rawId(); - const GeomDetUnit* geomDetUnit_upp(tkGeom->idToDetUnit(upperDetId)); + const GeomDetUnit* geomDetUnit_upp(tkGeom_->idToDetUnit(upperDetId)); LogTrace("VectorHitsBuilderValidation") << " upperDetID : " << upperDetId.rawId(); - for (unsigned int istr(0); istr < (*(vhIt->lowerClusterRef().cluster_phase2OT())).size(); ++istr) { + for (unsigned int istr(0); istr < (*(vhIt.lowerClusterRef().cluster_phase2OT())).size(); ++istr) { uint32_t channel = - Phase2TrackerDigi::pixelToChannel((*(vhIt->lowerClusterRef().cluster_phase2OT())).firstRow() + istr, - (*(vhIt->lowerClusterRef().cluster_phase2OT())).column()); + Phase2TrackerDigi::pixelToChannel((*(vhIt.lowerClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vhIt.lowerClusterRef().cluster_phase2OT())).column()); unsigned int LowerSimTrackId(getSimTrackId(siphase2SimLinks, lowerDetId, channel)); std::vector > trkid( getSimTrackIds(siphase2SimLinks, lowerDetId, channel)); @@ -484,13 +471,11 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev LogTrace("VectorHitsBuilderValidation") << "LowerSimTrackId " << LowerSimTrackId << std::endl; } // In the case of PU, we need the TPs to find the proper SimTrackID - for (std::set >::const_iterator iset = simTkIds.begin(); - iset != simTkIds.end(); - iset++) { - auto ipos = mapping.find(*iset); + for (const auto& iset : simTkIds) { + auto ipos = mapping.find(iset); if (ipos != mapping.end()) { LogTrace("VectorHitsBuilderValidation") << "lower cluster in detid: " << lowerDetId.rawId() - << " from tp: " << ipos->second.key() << " " << iset->first; + << " from tp: " << ipos->second.key() << " " << iset.first; LogTrace("VectorHitsBuilderValidation") << "with pt(): " << (*ipos->second).pt(); low_tp_id = ipos->second.key(); vh_sim_trackPt = (*ipos->second).pt(); @@ -498,10 +483,10 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } simTkIds.clear(); - for (unsigned int istr(0); istr < (*(vhIt->upperClusterRef().cluster_phase2OT())).size(); ++istr) { + for (unsigned int istr(0); istr < (*(vhIt.upperClusterRef().cluster_phase2OT())).size(); ++istr) { uint32_t channel = - Phase2TrackerDigi::pixelToChannel((*(vhIt->upperClusterRef().cluster_phase2OT())).firstRow() + istr, - (*(vhIt->upperClusterRef().cluster_phase2OT())).column()); + Phase2TrackerDigi::pixelToChannel((*(vhIt.upperClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vhIt.upperClusterRef().cluster_phase2OT())).column()); unsigned int UpperSimTrackId(getSimTrackId(siphase2SimLinks, upperDetId, channel)); std::vector > trkid( getSimTrackIds(siphase2SimLinks, upperDetId, channel)); @@ -512,19 +497,17 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev LogTrace("VectorHitsBuilderValidation") << "UpperSimTrackId " << UpperSimTrackId << std::endl; } // In the case of PU, we need the TPs to find the proper SimTrackID - for (std::set >::const_iterator iset = simTkIds.begin(); - iset != simTkIds.end(); - iset++) { - auto ipos = mapping.find(*iset); + for (const auto& iset : simTkIds) { + auto ipos = mapping.find(iset); if (ipos != mapping.end()) { LogTrace("VectorHitsBuilderValidation") << "upper cluster in detid: " << upperDetId.rawId() << " from tp: " << ipos->second.key() << " " - << iset->first << std::endl; + << iset.first << std::endl; upp_tp_id = ipos->second.key(); } } //compute if the vhits is 'true' or 'false' and save sim pT - std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); + std::pair istrue = isTrue(vhIt, siphase2SimLinks, detId); vh_isTrue = 0; if (istrue.first) { vh_isTrue = 1; @@ -535,14 +518,14 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev unsigned int primarySimHits(0); unsigned int otherSimHits(0); - for (edm::PSimHitContainer::const_iterator hitIt(simHitsRaw->begin()); hitIt != simHitsRaw->end(); ++hitIt) { - if (hitIt->detUnitId() == - geomDetLower->geographicalId()) { // || hitIt->detUnitId() == geomDetUpper->geographicalId()){ + for (const auto hitIt : *simHitsRaw) { + if (hitIt.detUnitId() == + geomDetLower->geographicalId()) { //check clusters track id compatibility - if (std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt->trackId()) != + if (std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt.trackId()) != clusterSimTrackIds.end()) { - Local3DPoint localPosHit(hitIt->localPosition()); + Local3DPoint localPosHit(hitIt.localPosition()); sim_x_local = localPosHit.x(); sim_y_local = localPosHit.y(); @@ -570,13 +553,12 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev ++totalSimHits; - std::map::const_iterator simTrackIt(simTracks.find(hitIt->trackId())); + std::map::const_iterator simTrackIt(simTracks.find(hitIt.trackId())); if (simTrackIt == simTracks.end()) continue; - //LogTrace("VectorHitsBuilderValidation") << "--> with hitIt. The SimTrack has p: " << simTrackIt->second.momentum(); // Primary particles only - processType = hitIt->processType(); + processType = hitIt.processType(); if (simTrackIt->second.vertIndex() == 0 and (processType == 2 || processType == 7 || processType == 9 || processType == 11 || processType == 13 || @@ -608,21 +590,21 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } // loop simhits nVHsTot++; - //tree->Fill(); + //tree_->Fill(); //****************************** //combinatorial studies : not filling if more than 1 VH has been produced //****************************** - multiplicity = DSViter->size(); - if (DSViter->size() > 1) { + multiplicity = DSViter.size(); + if (DSViter.size() > 1) { LogTrace("VectorHitsBuilderValidation") << " not filling if more than 1 VH has been produced"; width = -100; deltaXlocal = -100; - tree->Fill(); + tree_->Fill(); continue; } - VectorHitMomentumHelper vhMomHelper(magField); + VectorHitMomentumHelper vhMomHelper(magField_); //curvature curvature = vh.curvatureORphi(VectorHit::curvatureMode).first; phi = vh.curvatureORphi(VectorHit::phiMode).first; @@ -632,18 +614,17 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev //stub width - auto&& lparamsUpp = cpe->localParameters(*vhIt->upperClusterRef().cluster_phase2OT(), *geomDetUnit_upp); + auto&& lparamsUpp = cpe_->localParameters(*vhIt.upperClusterRef().cluster_phase2OT(), *geomDetUnit_upp); LogTrace("VectorHitsBuilderValidation") << " upper local pos (in its sor):" << lparamsUpp.first; Global3DPoint gparamsUpp = geomDetUnit_upp->surface().toGlobal(lparamsUpp.first); LogTrace("VectorHitsBuilderValidation") << " upper global pos :" << gparamsUpp; Local3DPoint lparamsUppInLow = geomDetUnit_low->surface().toLocal(gparamsUpp); LogTrace("VectorHitsBuilderValidation") << " upper local pos (in low sor):" << lparamsUppInLow; - auto&& lparamsLow = cpe->localParameters(*vhIt->lowerClusterRef().cluster_phase2OT(), *geomDetUnit_low); + auto&& lparamsLow = cpe_->localParameters(*vhIt.lowerClusterRef().cluster_phase2OT(), *geomDetUnit_low); LogTrace("VectorHitsBuilderValidation") << " lower local pos (in its sor):" << lparamsLow.first; Global3DPoint gparamsLow = geomDetUnit_low->surface().toGlobal(lparamsLow.first); LogTrace("VectorHitsBuilderValidation") << " lower global pos :" << gparamsLow; - //width = difference of centroids in precise coordinate (in low sor) corrected with parallax correction deltaXlocal = lparamsUppInLow.x() - lparamsLow.first.x(); histogramLayer->second.deltaXlocal->Fill(deltaXlocal); LogTrace("VectorHitsBuilderValidation") << " deltaXlocal : " << deltaXlocal; @@ -652,11 +633,8 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev Global3DPoint origin(0, 0, 0); GlobalVector gV = gparamsLow - origin; - //LogTrace("VectorHitsBuilderValidation") << " global vector passing to the origin:" << gV; LocalVector lV = geomDetUnit_low->surface().toLocal(gV); - //LogTrace("VectorHitsBuilderValidation") << " local vector passing to the origin (in low sor):" << lV; LocalVector lV_norm = lV / lV.z(); - //LogTrace("VectorHitsBuilderValidation") << " normalized local vector passing to the origin (in low sor):" << lV_norm; parallCorr = lV_norm.x() * lparamsUppInLow.z(); LogTrace("VectorHitsBuilderValidation") << " parallalex correction:" << parallCorr; @@ -698,7 +676,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev histogramLayer->second.width->Fill(width); LogTrace("VectorHitsBuilderValidation") << " width:" << width; - tree->Fill(); + tree_->Fill(); } // vh valid @@ -723,22 +701,21 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev int VHrejTrue_signal = 0.0; // Loop over modules - for (VectorHitCollectionNew::const_iterator DSViter = vhsAcc->begin(); DSViter != vhsAcc->end(); ++DSViter) { - unsigned int rawid(DSViter->detId()); + for (const auto& DSViter : *vhsAcc) { + unsigned int rawid(DSViter.detId()); DetId detId(rawid); int layerAcc = getLayerNumber(detId); LogTrace("VectorHitsBuilderValidation") << "acc Layer: " << layerAcc << " det id" << rawid << std::endl; - for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { - if (vhIt->isValid()) { + for (const auto& vhIt : DSViter) { + if (vhIt.isValid()) { VHaccLayer_->Fill(layerAcc); VHacc++; //compute if the vhits is 'true' or 'false' - std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); + std::pair istrue = isTrue(vhIt, siphase2SimLinks, detId); if (istrue.first) { LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; VHaccTrueLayer_->Fill(layerAcc); - //VHaccTrueLayer_ratio->Fill(layerAcc); VHaccTrue++; //saving info of 'signal' track @@ -761,24 +738,21 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } } - //it is not really working.. - //VHaccTrueLayer_ratio->Divide(VHaccLayer_); - for (VectorHitCollectionNew::const_iterator DSViter = vhsRej->begin(); DSViter != vhsRej->end(); ++DSViter) { - unsigned int rawid(DSViter->detId()); + for (const auto& DSViter : *vhsRej) { + unsigned int rawid(DSViter.detId()); DetId detId(rawid); int layerRej = getLayerNumber(detId); LogTrace("VectorHitsBuilderValidation") << "rej Layer: " << layerRej << " det id" << rawid << std::endl; - for (edmNew::DetSet::const_iterator vhIt = DSViter->begin(); vhIt != DSViter->end(); ++vhIt) { + for (const auto& vhIt : DSViter) { VHrejLayer_->Fill(layerRej); VHrej++; //compute if the vhits is 'true' or 'false' - std::pair istrue = isTrue(*vhIt, siphase2SimLinks, detId); + std::pair istrue = isTrue(vhIt, siphase2SimLinks, detId); if (istrue.first) { LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; VHrejTrueLayer_->Fill(layerRej); - //VHrejTrueLayer_ratio->Fill(layerRej); VHrejTrue++; //saving info of 'signal' track @@ -800,8 +774,6 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } } - //it is not really working.. - //VHrejTrueLayer_ratio->Divide(VHrejLayer_); int VHtot = VHacc + VHrej; LogTrace("VectorHitsBuilderValidation") @@ -820,13 +792,12 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev // Check if the vector hit is true (both clusters are formed from the same SimTrack std::pair VectorHitsBuilderValidation::isTrue( const VectorHit vh, const edm::Handle >& siphase2SimLinks, DetId& detId) const { - const GeomDet* geomDet(tkGeom->idToDet(detId)); + const GeomDet* geomDet(tkGeom_->idToDet(detId)); const StackGeomDet* stackDet = dynamic_cast(geomDet); const GeomDetUnit* geomDetLower = stackDet->lowerDet(); const GeomDetUnit* geomDetUpper = stackDet->upperDet(); std::vector lowClusterSimTrackIds; - //std::set > simTkIds; for (unsigned int istr(0); istr < (*(vh.lowerClusterRef().cluster_phase2OT())).size(); ++istr) { uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.lowerClusterRef().cluster_phase2OT())).firstRow() + istr, @@ -838,7 +809,6 @@ std::pair VectorHitsBuilderValidation::isTrue( if (trkid.size() == 0) continue; lowClusterSimTrackIds.push_back(simTrackId); - //simTkIds.insert(trkid.begin(),trkid.end()); } std::vector::iterator it_simTrackUpper; @@ -857,8 +827,6 @@ std::pair VectorHitsBuilderValidation::isTrue( LogTrace("VectorHitsBuilderValidation") << " UpperSimTrackId found in lowClusterSimTrackIds "; return std::make_pair(true, simTrackId); } - //clusterSimTrackIds.push_back(UpperSimTrackId); - //simTkIds.insert(trkid.begin(),trkid.end()); } return std::make_pair(false, 0); } @@ -919,37 +887,37 @@ std::map::iterator VectorHitsBuilderValidation::createLa histoName.str(""); histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; local_histos.localPosXY[0] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + td.make(); local_histos.localPosXY[0]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Local_Position_XY_PS" << tag.c_str() << id; local_histos.localPosXY[1] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + td.make(); local_histos.localPosXY[1]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Local_Position_XY_2S" << tag.c_str() << id; local_histos.localPosXY[2] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2000, 0., 0., 2000, 0., 0.); + td.make(); local_histos.localPosXY[2]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; local_histos.globalPosXY[0] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + td.make(); local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_PS" << tag.c_str() << id; local_histos.globalPosXY[1] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + td.make(); local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_2S" << tag.c_str() << id; local_histos.globalPosXY[2] = - td.make(); //histoName.str().c_str(), histoName.str().c_str(), 2400, -120.0, 120.0, 2400, -120.0, 120.0); + td.make(); local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); /* @@ -1054,27 +1022,13 @@ void VectorHitsBuilderValidation::CreateVHsXYGraph(const std::vectorcd(); - //trackerLayoutXY_[0]->Draw("AP"); - - // float finalposX, finalposY; - for (unsigned int nVH = 0; nVH < glVHs.size(); nVH++) { - // finalposX = glVHs.at(nVH).x() + dirVHs.at(nVH).x(); - // finalposY = glVHs.at(nVH).y() + dirVHs.at(nVH).y(); - //std::cout << glVHs.at(nVH) << " " << " \tr: " << glVHs.at(nVH).perp() << std::endl; - //std::cout << dirVHs.at(nVH).x() << "," << dirVHs.at(nVH).y() << std::endl; - - //same r + //same r if ((fabs(dirVHs.at(nVH).x()) < 10e-5) && (fabs(dirVHs.at(nVH).y()) < 10e-5)) { - //std::cout << "same pos!"; continue; } else { - // TArrow* vh_arrow = new TArrow(glVHs.at(nVH).x(), glVHs.at(nVH).y(), finalposX, finalposY, 0.05, ">"); - // vh_arrow->Draw("same"); - } + } } return; @@ -1087,31 +1041,6 @@ void VectorHitsBuilderValidation::CreateVHsRZGraph(const std::vectorcd(); - //trackerLayoutRZ_[0]->Draw("AP"); - - // float finalposX, finalposY, finalposR, finalposZ; - - // for(unsigned int nVH = 0; nVH < glVHs.size(); nVH++){ - - // finalposX = glVHs.at(nVH).x() + dirVHs.at(nVH).x(); - // finalposY = glVHs.at(nVH).y() + dirVHs.at(nVH).y(); - // finalposR = sqrt( pow(finalposX,2) + pow(finalposY,2) ); - // finalposZ = glVHs.at(nVH).z() + dirVHs.at(nVH).z(); - - //std::cout << dirVHs.at(nVH) " " << " \tr: " << dirVHs.at(nVH).perp() << std::endl; - //std::cout << finalposX << ", " << finalposY << " " << " \tr: " << finalposR << std::endl; - //std::cout << std::endl; - - // TArrow* vh_arrow = new TArrow(glVHs.at(nVH).z(), glVHs.at(nVH).perp(), finalposZ, finalposR, 0.05, "|>"); - // vh_arrow->SetLineWidth(2); - // vh_arrow->Draw("same"); - - // } - return; } @@ -1119,16 +1048,13 @@ void VectorHitsBuilderValidation::CreateWindowCorrGraph() { //FIXME: This function is not working properly, yet. //return if we are not using Phase2 OT - if (!tkGeom->isThere(GeomDetEnumerators::P2OTB) && !tkGeom->isThere(GeomDetEnumerators::P2OTEC)) + if (!tkGeom_->isThere(GeomDetEnumerators::P2OTB) && !tkGeom_->isThere(GeomDetEnumerators::P2OTEC)) return; - for (auto det : tkGeom->detsTOB()) { - // std::cout << det->geographicalId().rawId() << std::endl; - // std::cout << det->surface().bounds().thickness() << std::endl; + for (auto det : tkGeom_->detsTOB()) { ParallaxCorrectionRZ_->Fill(det->position().z(), det->position().perp(), 5.); } - for (auto det : tkGeom->detsTID()) { - //std::cout << det->geographicalId().rawId() << std::endl; + for (auto det : tkGeom_->detsTID()) { ParallaxCorrectionRZ_->Fill(det->position().z(), det->position().perp(), 10.); } ParallaxCorrectionRZ_->Fill(0., 0., 5.); @@ -1138,16 +1064,16 @@ void VectorHitsBuilderValidation::CreateWindowCorrGraph() { unsigned int VectorHitsBuilderValidation::getLayerNumber(const DetId& detid) { if (detid.det() == DetId::Tracker) { if (detid.subdetId() == StripSubdetector::TOB) - return (tkTopo->layer(detid)); + return (tkTopo_->layer(detid)); else if (detid.subdetId() == StripSubdetector::TID) - return (100 * tkTopo->side(detid) + tkTopo->layer(detid)); + return (100 * tkTopo_->side(detid) + tkTopo_->layer(detid)); else return 999; } return 999; } -unsigned int VectorHitsBuilderValidation::getModuleNumber(const DetId& detid) { return (tkTopo->module(detid)); } +unsigned int VectorHitsBuilderValidation::getModuleNumber(const DetId& detid) { return (tkTopo_->module(detid)); } std::vector > VectorHitsBuilderValidation::getSimTrackIds( const edm::Handle >& simLinks, const DetId& detId, uint32_t channel) const { @@ -1156,11 +1082,10 @@ std::vector > VectorHitsBuilderValidation::g if (isearch != simLinks->end()) { // Loop over DigiSimLink in this det unit edm::DetSet link_detset = (*isearch); - for (typename edm::DetSet::const_iterator it = link_detset.data.begin(); - it != link_detset.data.end(); - ++it) { - if (channel == it->channel()) - simTrkId.push_back(std::make_pair(it->SimTrackId(), it->eventId())); + //for (typename edm::DetSet::const_iterator it = link_detset.data.begin(); it != link_detset.data.end(); ++it) { + for (const auto& it : link_detset.data) { + if (channel == it.channel()) + simTrkId.push_back(std::make_pair(it.SimTrackId(), it.eventId())); } } return simTrkId; @@ -1173,9 +1098,10 @@ unsigned int VectorHitsBuilderValidation::getSimTrackId( edm::DetSetVector::const_iterator DSViter(pixelSimLinks->find(detId)); if (DSViter == pixelSimLinks->end()) return 0; - for (edm::DetSet::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { - if (channel == it->channel()) - return it->SimTrackId(); + //for (edm::DetSet::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { + for (const auto& it : DSViter->data) { + if (channel == it.channel()) + return it.SimTrackId(); } return 0; } @@ -1203,8 +1129,7 @@ void VectorHitsBuilderValidation::printCluster(const GeomDetUnit* geomDetUnit, c LogTrace("VectorHitsBuilderValidation") << " and width:" << theGeomDet->surface().bounds().width() << " , lenght:" << theGeomDet->surface().bounds().length() << std::endl; - auto&& lparams = cpe->localParameters(*cluster.cluster_phase2OT(), *theGeomDet); - //Global3DPoint gparams = theGeomDet->surface().toGlobal(lparams.first); + auto&& lparams = cpe_->localParameters(*cluster.cluster_phase2OT(), *theGeomDet); LogTrace("VectorHitsBuilderValidation") << "\t local pos " << lparams.first << "with err " << lparams.second << std::endl; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index 87b92e8054ef3..074433bf3a96c 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -3,7 +3,7 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -76,7 +76,7 @@ struct VHHistos { TH1F* deltaXlocal; }; -class VectorHitsBuilderValidation : public edm::EDAnalyzer { +class VectorHitsBuilderValidation : public edm::one::EDAnalyzer { public: typedef edm::Ref, Phase2TrackerCluster1D> Phase2TrackerCluster1DRef; @@ -114,7 +114,7 @@ class VectorHitsBuilderValidation : public edm::EDAnalyzer { edm::EDGetTokenT VHacc_; edm::EDGetTokenT VHrej_; edm::ESInputTag cpeTag_; - const ClusterParameterEstimator* cpe; + const ClusterParameterEstimator* cpe_; edm::EDGetTokenT > siphase2OTSimLinksToken_; edm::EDGetTokenT simHitsToken_; @@ -123,11 +123,11 @@ class VectorHitsBuilderValidation : public edm::EDAnalyzer { edm::EDGetTokenT trackingParticleToken_; //SiPixelVectorHitBuilderAlgorithmBase *algo; - const TrackerGeometry* tkGeom; - const TrackerTopology* tkTopo; - const MagneticField* magField; + const TrackerGeometry* tkGeom_; + const TrackerTopology* tkTopo_; + const MagneticField* magField_; - TTree* tree; + TTree* tree_; TGraph* trackerLayoutRZ_[3]; TGraph* trackerLayoutXY_[3]; TGraph* trackerLayoutXYBar_; @@ -136,7 +136,7 @@ class VectorHitsBuilderValidation : public edm::EDAnalyzer { TGraph* localPosYvsDeltaY_[3]; TCanvas* VHXY_; TCanvas* VHRZ_; - std::vector arrowVHs; + std::vector arrowVHs_; TH2D* ParallaxCorrectionRZ_; TH1F* VHaccLayer_; @@ -145,8 +145,6 @@ class VectorHitsBuilderValidation : public edm::EDAnalyzer { TH1F* VHrejTrueLayer_; TH1F* VHaccTrue_signal_Layer_; TH1F* VHrejTrue_signal_Layer_; - TH1F* VHaccTrueLayer_ratio; - TH1F* VHrejTrueLayer_ratio; std::map histograms_; }; diff --git a/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc b/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc index 4ca48e1308910..18e356a0520b8 100644 --- a/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc +++ b/RecoLocalTracker/SubCollectionProducers/src/TrackClusterRemoverPhase2.cc @@ -205,7 +205,7 @@ namespace { if (uppCluster.isPhase2()) collectedPhase2OTs[uppCluster.key()] = true; } else { - LogTrace("TrackClusterRemoverPhase2") << "it is not a VHits."; + LogTrace("TrackClusterRemoverPhase2") << "it is not a VHit."; } } } diff --git a/RecoTracker/CkfPattern/src/PrintoutHelper.cc b/RecoTracker/CkfPattern/src/PrintoutHelper.cc index 96a598b1354b2..82885a3dc03bc 100644 --- a/RecoTracker/CkfPattern/src/PrintoutHelper.cc +++ b/RecoTracker/CkfPattern/src/PrintoutHelper.cc @@ -103,8 +103,9 @@ std::string PrintoutHelper::regressionTest(const TrackerGeometry& tracker, std:: } buffer << "================================================="; buffer << "=========== Traj in details =====================\n"; - for (std::vector::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) { - for (const auto& hit : it->measurements()) { + //for (std::vector::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) { + for (const auto& it : unsmoothedResult) { + for (const auto& hit : it.measurements()) { buffer << "measurement : " << hit.recHit()->geographicalId().rawId() << std::endl; } buffer << "================\n"; diff --git a/RecoTracker/MeasurementDet/BuildFile.xml b/RecoTracker/MeasurementDet/BuildFile.xml index 2790eaf681a10..a7ea54e101d9b 100644 --- a/RecoTracker/MeasurementDet/BuildFile.xml +++ b/RecoTracker/MeasurementDet/BuildFile.xml @@ -22,4 +22,4 @@ - + From 7c64d658ba0d7e7c58c138ee2810b45f05ca9937 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 8 Sep 2020 19:54:51 -0500 Subject: [PATCH 055/115] Kevin's comment to VectorHitBuilderAlgorithmBase --- .../src/VectorHitBuilderAlgorithmBase.cc | 58 ++++--------------- 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index 6e5bc1ee39805..9575020313679 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -12,36 +12,13 @@ VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase( const TrackerGeometry* tkGeomProd, const TrackerTopology* tkTopoProd, const ClusterParameterEstimator* cpeProd) - : nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), + : theTkGeom(tkGeomProd), + theTkTopo(tkTopoProd), + cpe(cpeProd), + nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), barrelCut(conf.getParameter >("BarrelCut")), endcapCut(conf.getParameter >("EndcapCut")), - cpeTag_(conf.getParameter("CPE")) { - initTkGeom(tkGeomProd); - initTkTopo(tkTopoProd); - initCpe(cpeProd); -} - -/*void VectorHitBuilderAlgorithmBase::initialize(const edm::EventSetup& es) { - // get the geometry and topology - edm::ESHandle geomHandle; - es.get().get(geomHandle); - initTkGeom(geomHandle); - - edm::ESHandle tTopoHandle; - es.get().get(tTopoHandle); - initTkTopo(tTopoHandle); - - // load the cpe via the eventsetup - edm::ESHandle > cpeHandle; - es.get().get(cpeTag_, cpeHandle); - initCpe(cpeHandle.product()); -} -*/ -void VectorHitBuilderAlgorithmBase::initTkGeom(const TrackerGeometry* tkGeomProd) { theTkGeom = tkGeomProd; } -void VectorHitBuilderAlgorithmBase::initTkTopo(const TrackerTopology* tkTopoProd) { theTkTopo = tkTopoProd; } -void VectorHitBuilderAlgorithmBase::initCpe(const ClusterParameterEstimator* cpeProd) { - cpe = cpeProd; -} + cpeTag_(conf.getParameter("CPE")){ } double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomDetUnit*& geomDetUnit_low, const Point3DBase& lPosClu_low, @@ -68,21 +45,16 @@ double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomD void VectorHitBuilderAlgorithmBase::printClusters(const edmNew::DetSetVector& clusters) const { int nCluster = 0; int numberOfDSV = 0; - edmNew::DetSetVector::const_iterator DSViter; - for (DSViter = clusters.begin(); DSViter != clusters.end(); DSViter++) { + for (const auto& DSViter : clusters){ ++numberOfDSV; - // Loop over the clusters in the detector unit - for (edmNew::DetSet::const_iterator clustIt = DSViter->begin(); clustIt != DSViter->end(); - ++clustIt) { + for (const auto& clustIt :DSViter) { nCluster++; - // get the detector unit's id - const GeomDetUnit* geomDetUnit(theTkGeom->idToDetUnit(DSViter->detId())); + const GeomDetUnit* geomDetUnit(theTkGeom->idToDetUnit(DSViter.detId())); if (!geomDetUnit) return; - - printCluster(geomDetUnit, clustIt); + printCluster(geomDetUnit, &clustIt); } } LogDebug("VectorHitBuilder") << " Number of input clusters: " << nCluster << std::endl; @@ -124,14 +96,8 @@ void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, void VectorHitBuilderAlgorithmBase::loadDetSetVector(std::map >& theMap, edmNew::DetSetVector& theCollection) const { - std::map >::const_iterator it = theMap.begin(); - std::map >::const_iterator lastDet = theMap.end(); - for (; it != lastDet; ++it) { - edmNew::DetSetVector::FastFiller vh_col(theCollection, it->first); - std::vector::const_iterator vh_it = it->second.begin(); - std::vector::const_iterator vh_end = it->second.end(); - for (; vh_it != vh_end; ++vh_it) { - vh_col.push_back(*vh_it); - } + for (const auto& it : theMap) { + edmNew::DetSetVector::FastFiller vh_col(theCollection, it.first); + for (const auto& vh_it: it.second) vh_col.push_back(vh_it); } } From 424df27fbed2af269e5a17625185f55d538aaa30 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 8 Sep 2020 23:45:07 -0500 Subject: [PATCH 056/115] most of Kevin's remaining comments --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 86 +++++++-------- .../Records/interface/TkPhase2OTCPERecord.h | 9 +- .../interface/VectorHitBuilderAlgorithm.h | 18 +--- .../interface/VectorHitBuilderAlgorithmBase.h | 9 +- .../plugins/VectorHitBuilderEDProducer.cc | 10 +- .../src/VectorHitBuilderAlgorithm.cc | 100 +++++++++--------- .../src/VectorHitBuilderAlgorithmBase.cc | 15 +-- .../test/ClustersValidationTGraph.cc | 35 +++--- .../VHs_SeedingOT_productionAndTesting.py | 26 ++--- .../test/VectorHitsValidation.cc | 31 ++---- .../TrackerRecoGeometryESProducer_cfi.py | 4 +- .../plugins/SeedingOTEDProducer.cc | 35 +++--- .../TkSeedingLayers/src/HitExtractorSTRP.cc | 4 +- 13 files changed, 167 insertions(+), 215 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index e01d9969999a6..b8e5d895e7c12 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -80,27 +80,28 @@ bool VectorHit::sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedI } void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const { - AlgebraicVector4& pars = holder.params<4>(); + constexpr int four = 4; + AlgebraicVector4& pars = holder.params(); pars[0] = theDirection.x(); pars[1] = theDirection.y(); pars[2] = thePosition.x(); pars[3] = thePosition.y(); - AlgebraicSymMatrix44& errs = holder.errors<4>(); - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { + AlgebraicSymMatrix44& errs = holder.errors(); + for (int i = 0; i < four; i++) { + for (int j = 0; j < four; j++) { errs(i, j) = theCovMatrix[i][j]; } } - ProjectMatrix& pf = holder.projFunc<4>(); + ProjectMatrix& pf = holder.projFunc(); pf.index[0] = 1; pf.index[1] = 2; pf.index[2] = 3; pf.index[3] = 4; - holder.measuredParams<4>() = AlgebraicVector4(&holder.tsosLocalParameters().At(1), 4); - holder.measuredErrors<4>() = holder.tsosLocalErrors().Sub(1, 1); + holder.measuredParams() = AlgebraicVector4(&holder.tsosLocalParameters().At(1), four); + holder.measuredErrors() = holder.tsosLocalErrors().Sub(1, 1); } VectorHit::~VectorHit() {} @@ -153,7 +154,8 @@ GlobalError VectorHit::phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet const PixelTopology* topo = &geomDet->specificTopology(); float pitchX = topo->pitch().first; float pitchY = topo->pitch().second; - LocalError le(pow(pitchX, 2) / 12., 0, pow(pitchY, 2) / 12.); // e2_xx, e2_xy, e2_yy + constexpr float invTwelve = 1. / 12; + LocalError le(pow(pitchX, 2) * invTwelve, 0, pow(pitchY, 2) * invTwelve); // e2_xx, e2_xy, e2_yy GlobalError ge(ErrorFrameTransformer().transform(le, geomDet->surface())); return ge; } @@ -203,6 +205,7 @@ std::pair VectorHit::curvatureORphi(curvatureOrPhi curvORphi) cons if (h1 != 0) { double h2 = 2 * h1; + double h2Inf = 1. / (2 * h1); double r12 = pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2); double r22 = pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2); double h3 = @@ -229,35 +232,25 @@ std::pair VectorHit::curvatureORphi(curvatureOrPhi curvORphi) cons phi = atan2(ytg, xtg); AlgebraicROOTObject<4, 4>::Matrix jacobian; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - jacobian[i][j] = 0.0; - } - } + double denom1 = 1. / sqrt(r12 * r22 * h3); double denom2 = 1. / (pow(r12 * r22 * h3, 1.5)); jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 jacobian[2][0] = - (h1 * (2. * gPositionLower.x() * r22 * h3 + (2. * gPositionLower.x() - 2. * gPositionUpper.x()) * r12 * r22)) * - denom2 - - (2. * gPositionUpper.y()) * denom1; // dkappa/dx1 + -2. * ((h1 * (gPositionLower.x() * r22 * h3 + (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2 - + (gPositionUpper.y()) * denom1); // dkappa/dx1 jacobian[2][1] = - (2. * gPositionUpper.x()) * denom1 + - (h1 * (2. * gPositionLower.y() * r22 * h3 + r12 * r22 * (2. * gPositionLower.y() - 2. * gPositionUpper.y()))) * - denom2; // dkappa/dy1 + -2. * ((gPositionUpper.x()) * denom1 + + (h1 * (gPositionLower.y() * r22 * h3 + r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * + denom2); // dkappa/dy1 jacobian[2][2] = - (2. * gPositionLower.y()) * denom1 + - (h1 * (2. * gPositionUpper.x() * r12 * h3 - 2. * (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * - denom2; // dkappa/dx2 + -2. * ((gPositionLower.y()) * denom1 + + (h1 * (gPositionUpper.x() * r12 * h3 - (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * + denom2); // dkappa/dx2 jacobian[2][3] = - (h1 * (2. * gPositionUpper.y() * r12 * h3 - r12 * r22 * 2. * (gPositionLower.y() - gPositionUpper.y()))) * - denom2 - - (2. * gPositionLower.x()) * denom1; // dkappa/dy2 - - for (int i = 0; i < 4; i++) { - jacobian[2][i] = -jacobian[2][i]; - } + -2. * ((h1 * (gPositionUpper.y() * r12 * h3 - r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * denom2 - + (gPositionLower.x()) * denom1); // dkappa/dy2 AlgebraicVector2 M; //to compute phi at the cluster points @@ -267,25 +260,25 @@ std::pair VectorHit::curvatureORphi(curvatureOrPhi curvORphi) cons AlgebraicROOTObject<2, 4>::Matrix K; K[0][0] = - (2. * gPositionLower.x() * gPositionUpper.y()) / h2 - (2. * gPositionUpper.y() * h5) / pow(h2, 2); // dxm/dx1 + 2. * ((gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionUpper.y() * h5) / pow(h2, 2)); // dxm/dx1 K[0][1] = (2. * gPositionUpper.x() * h5) / pow(h2, 2) - - (pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y()) / - h2; // dxm/dy1 + (pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y()) * + h2Inf; // dxm/dy1 K[0][2] = - (2. * gPositionLower.y() * h5) / pow(h2, 2) - (2. * gPositionUpper.x() * gPositionLower.y()) / h2; // dxm/dx2 - K[0][3] = - (pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2) - 2. * gPositionUpper.y() * gPositionLower.y()) / h2 - - (2. * gPositionLower.x() * h5) / pow(h2, 2); // dxm/dy2 - K[1][0] = - (pow(gPositionUpper.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.y(), 2)) / h2 - - (2. * gPositionUpper.y() * h4) / pow(h2, 2); // dym/dx1 + 2. * ((gPositionLower.y() * h5) / pow(h2, 2) - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dxm/dx2 + K[0][3] = (pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2) - 2. * gPositionUpper.y() * gPositionLower.y()) * + h2Inf - + (2. * gPositionLower.x() * h5) / pow(h2, 2); // dxm/dy2 + K[1][0] = (pow(gPositionUpper.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.y(), 2)) * + h2Inf - + (2. * gPositionUpper.y() * h4) / pow(h2, 2); // dym/dx1 K[1][1] = - (2. * gPositionUpper.x() * h4) / pow(h2, 2) - (2. * gPositionUpper.x() * gPositionLower.y()) / h2; // dym/dy1 + 2. * ((gPositionUpper.x() * h4) / pow(h2, 2) - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dym/dy1 K[1][2] = (2. * gPositionLower.y() * h4) / pow(h2, 2) - - (pow(gPositionLower.x(), 2) - 2. * gPositionUpper.x() * gPositionLower.x() + pow(gPositionLower.y(), 2)) / - h2; // dym/dx2 + (pow(gPositionLower.x(), 2) - 2. * gPositionUpper.x() * gPositionLower.x() + pow(gPositionLower.y(), 2)) * + h2Inf; // dym/dx2 K[1][3] = - (2. * gPositionLower.x() * gPositionUpper.y()) / h2 - (2. * gPositionLower.x() * h4) / pow(h2, 2); // dym/dy2 + 2. * (gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionLower.x() * h4) / pow(h2, 2); // dym/dy2 AlgebraicVector4 N = M * K; jacobian[3][0] = N[0]; // dphi/(dx1,dy1,dx2,dy2) @@ -302,7 +295,7 @@ std::pair VectorHit::curvatureORphi(curvatureOrPhi curvORphi) cons } // bring phi in the same quadrant as phi1 - if (abs(phi - phi1) > M_PI / 2.) { + if (deltaPhi(phi, phi1) > M_PI / 2.) { phi = phi + M_PI; if (phi > M_PI) phi = phi - 2. * M_PI; @@ -315,11 +308,6 @@ std::pair VectorHit::curvatureORphi(curvatureOrPhi curvORphi) cons } AlgebraicROOTObject<4, 4>::Matrix gErrors; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - gErrors[i][j] = 0.0; - } - } gErrors[0][0] = gErrorLower.cxx(); gErrors[0][1] = gErrorLower.cyx(); diff --git a/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h b/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h index 3a6925080a227..44fea80269a6a 100644 --- a/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h +++ b/RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h @@ -10,10 +10,9 @@ #include "FWCore/Utilities/interface/mplVector.h" class TkPhase2OTCPERecord - : public edm::eventsetup::DependentRecordImplementation > {}; + : public edm::eventsetup::DependentRecordImplementation< + TkPhase2OTCPERecord, + edm::mpl::Vector > { +}; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 082293459902d..f8ec0ef0aa2f3 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -20,8 +20,8 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { const TrackerGeometry* tkGeomProd, const TrackerTopology* tkTopoProd, const ClusterParameterEstimator* cpeProd) - : VectorHitBuilderAlgorithmBase(conf, tkGeomProd, tkTopoProd, cpeProd), theFitter(new LinearFit()){}; - ~VectorHitBuilderAlgorithm() override { delete theFitter; }; + : VectorHitBuilderAlgorithmBase(conf, tkGeomProd, tkTopoProd, cpeProd){}; + ~VectorHitBuilderAlgorithm() override{}; void run(edm::Handle> clusters, VectorHitCollectionNew& vhAcc, @@ -63,10 +63,6 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { Phase2TrackerCluster1DRef lower, Phase2TrackerCluster1DRef upper) const override; - // Full I/O in DetSet - //void buildDetUnit( const edm::DetSetVector & input, - // output_t& output); - void fit2Dzx(const Local3DPoint lpCI, const Local3DPoint lpCO, const LocalError leCI, @@ -84,19 +80,15 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { AlgebraicSymMatrix22& covMatrix, double& chi2) const; - void fit(const std::vector& x, - const std::vector& y, - const std::vector& sigy, + void fit(float x[2], + float y[2], + float sigy[2], Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, double& chi2) const; - // void build( const edm::DetSet & input, - // output_t::FastFiller& output); - private: - LinearFit* theFitter; }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index 9850c3a043095..129163541880d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -28,9 +28,6 @@ class VectorHitBuilderAlgorithmBase { const TrackerTopology*, const ClusterParameterEstimator*); virtual ~VectorHitBuilderAlgorithmBase() {} - void initTkGeom(const TrackerGeometry* tkGeomProd); - void initTkTopo(const TrackerTopology* tkTopoProd); - void initCpe(const ClusterParameterEstimator* cpeProd); //FIXME::ERICA::this should be template, return different collection for different algo used!! virtual void run(edm::Handle> clusters, @@ -58,20 +55,18 @@ class VectorHitBuilderAlgorithmBase { void printClusters(const edmNew::DetSetVector& clusters) const; void printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* cluster) const; - void loadDetSetVector(std::map>& theMap, + void loadDetSetVector(std::unordered_map>& theMap, edmNew::DetSetVector& theCollection) const; const TrackerGeometry* theTkGeom; const TrackerTopology* theTkTopo; - const ClusterParameterEstimator* cpe; + const ClusterParameterEstimator* theCpe; unsigned int nMaxVHforeachStack; std::vector barrelCut; std::vector endcapCut; private: edm::ESInputTag cpeTag_; - - // typedef SiStripRecHit2DCollection::FastFiller Collector; }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc index d313d4bc920c9..4df79a4761e60 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -35,7 +35,7 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { }; //VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; } -VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { } +VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() {} VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) : offlinestubsTag_(conf.getParameter("offlinestubs")), @@ -74,12 +74,10 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu run(clustersHandle, *outputClustersAccepted, *outputClustersRejected, *outputVHAccepted, *outputVHRejected); unsigned int numberOfVectorHits = 0; - edmNew::DetSetVector::const_iterator DSViter; - for (DSViter = (*outputVHAccepted).begin(); DSViter != (*outputVHAccepted).end(); DSViter++) { - edmNew::DetSet::const_iterator vh; - for (vh = DSViter->begin(); vh != DSViter->end(); ++vh) { + for (const auto& DSViter : *outputVHAccepted) { + for (const auto& vh : DSViter) { numberOfVectorHits++; - LogDebug("VectorHitBuilderEDProducer") << "\t vectorhit in output " << *vh << std::endl; + LogDebug("VectorHitBuilderEDProducer") << "\t vectorhit in output " << vh << std::endl; } } // write output to file diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index c20a651520f9d..1c8c2c8de6205 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -19,8 +19,8 @@ void VectorHitBuilderAlgorithm::run(edm::Handle* ClustersPhase2Collection = clusters.product(); - std::map> tempVHAcc, tempVHRej; - std::map>::iterator it_temporary; + std::unordered_map> tempVHAcc, tempVHRej; + std::unordered_map>::iterator it_temporary; //loop over the DetSetVector LogDebug("VectorHitBuilderAlgorithm") << "with #clusters : " << ClustersPhase2Collection->size() << std::endl; @@ -50,10 +50,8 @@ void VectorHitBuilderAlgorithm::run(edm::Handle::const_iterator it_detLower = - ClustersPhase2Collection->find(lowerDetId); - edmNew::DetSetVector::const_iterator it_detUpper = - ClustersPhase2Collection->find(upperDetId); + const auto& it_detLower = ClustersPhase2Collection->find(lowerDetId); + const auto& it_detUpper = ClustersPhase2Collection->find(upperDetId); if (it_detLower != ClustersPhase2Collection->end() && it_detUpper != ClustersPhase2Collection->end()) { gd = theTkGeom->idToDet(detIdStack); @@ -77,7 +75,7 @@ void VectorHitBuilderAlgorithm::run(edm::Handle> VectorHitBuilderAlgorithm::buildVectorHi upperClusters.push_back(clusterUpper); } - std::sort_heap(lowerClusters.begin(), lowerClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->lowerDet())); - std::sort_heap(upperClusters.begin(), upperClusters.end(), LocalPositionSort(&*theTkGeom, &*cpe, &*stack->upperDet())); + std::sort_heap( + lowerClusters.begin(), lowerClusters.end(), LocalPositionSort(&*theTkGeom, &*theCpe, &*stack->lowerDet())); + std::sort_heap( + upperClusters.begin(), upperClusters.end(), LocalPositionSort(&*theTkGeom, &*theCpe, &*stack->upperDet())); for (const auto& cluL : lowerClusters) { LogDebug("VectorHitBuilderAlgorithm") << " lower clusters " << std::endl; printCluster(stack->lowerDet(), &*cluL); const PixelGeomDetUnit* gduLow = dynamic_cast(stack->lowerDet()); - auto&& lparamsLow = cpe->localParameters(*cluL, *gduLow); + auto&& lparamsLow = theCpe->localParameters(*cluL, *gduLow); for (const auto& cluU : upperClusters) { LogDebug("VectorHitBuilderAlgorithm") << "\t upper clusters " << std::endl; printCluster(stack->upperDet(), &*cluU); const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); - auto&& lparamsUpp = cpe->localParameters(*cluU, *gduUpp); + auto&& lparamsUpp = theCpe->localParameters(*cluU, *gduUpp); //applying the parallax correction double pC = computeParallaxCorrection(gduLow, lparamsLow.first, gduUpp, lparamsUpp.first); @@ -174,29 +175,26 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi if (lparamsUpp.first.x() > lparamsLow.first.x()) { if (lparamsUpp.first.x() > 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() - fabs(pC); - } - if (lparamsUpp.first.x() < 0) { - lpos_low_corr = lparamsLow.first.x() + fabs(pC); + lpos_upp_corr = lparamsUpp.first.x() - std::abs(pC); + } else if (lparamsUpp.first.x() < 0) { + lpos_low_corr = lparamsLow.first.x() + std::abs(pC); lpos_upp_corr = lparamsUpp.first.x(); } } else if (lparamsUpp.first.x() < lparamsLow.first.x()) { if (lparamsUpp.first.x() > 0) { - lpos_low_corr = lparamsLow.first.x() - fabs(pC); + lpos_low_corr = lparamsLow.first.x() - std::abs(pC); lpos_upp_corr = lparamsUpp.first.x(); - } - if (lparamsUpp.first.x() < 0) { + } else if (lparamsUpp.first.x() < 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() + fabs(pC); + lpos_upp_corr = lparamsUpp.first.x() + std::abs(pC); } } else { if (lparamsUpp.first.x() > 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() - fabs(pC); - } - if (lparamsUpp.first.x() < 0) { + lpos_upp_corr = lparamsUpp.first.x() - std::abs(pC); + } else if (lparamsUpp.first.x() < 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() + fabs(pC); + lpos_upp_corr = lparamsUpp.first.x() + std::abs(pC); } } @@ -228,19 +226,19 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi //if( (lpos_upp_corr < lpos_low_corr + delta) && // (lpos_upp_corr > lpos_low_corr - delta) ){ //new cut: dependent on layers - if (fabs(width) < cut) { + if (std::abs(width) < cut) { LogDebug("VectorHitBuilderAlgorithm") << " accepting VH! " << std::endl; VectorHit vh = buildVectorHit(stack, cluL, cluU); //protection: the VH can also be empty!! if (vh.isValid()) { - result.push_back(std::make_pair(vh, true)); + result.emplace_back(std::make_pair(vh, true)); } } else { LogDebug("VectorHitBuilderAlgorithm") << " rejecting VH: " << std::endl; //storing vh rejected for combinatiorial studies VectorHit vh = buildVectorHit(stack, cluL, cluU); - result.push_back(std::make_pair(vh, false)); + result.emplace_back(std::make_pair(vh, false)); } } } @@ -252,17 +250,16 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, Phase2TrackerCluster1DRef upper) const { LogTrace("VectorHitBuilderAlgorithm") << "Build VH with: "; - //printCluster(stack->lowerDet(),&*lower); //printCluster(stack->upperDet(),&*upper); const PixelGeomDetUnit* geomDetLower = static_cast(stack->lowerDet()); const PixelGeomDetUnit* geomDetUpper = static_cast(stack->upperDet()); - auto&& lparamsLower = cpe->localParameters(*lower, *geomDetLower); // x, y, z, e2_xx, e2_xy, e2_yy + auto&& lparamsLower = theCpe->localParameters(*lower, *geomDetLower); // x, y, z, e2_xx, e2_xy, e2_yy Global3DPoint gparamsLower = geomDetLower->surface().toGlobal(lparamsLower.first); LogTrace("VectorHitBuilderAlgorithm") << "\t lower global pos: " << gparamsLower; - auto&& lparamsUpper = cpe->localParameters(*upper, *geomDetUpper); + auto&& lparamsUpper = theCpe->localParameters(*upper, *geomDetUpper); Global3DPoint gparamsUpper = geomDetUpper->surface().toGlobal(lparamsUpper.first); LogTrace("VectorHitBuilderAlgorithm") << "\t upper global pos: " << gparamsUpper; @@ -332,11 +329,11 @@ void VectorHitBuilderAlgorithm::fit2Dzx(const Local3DPoint lpCI, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, double& chi2) const { - std::vector x = {lpCI.z(), lpCO.z()}; - std::vector y = {lpCI.x(), lpCO.x()}; + float x[2] = {lpCI.z(), lpCO.z()}; + float y[2] = {lpCI.x(), lpCO.x()}; float sqCI = sqrt(leCI.xx()); float sqCO = sqrt(leCO.xx()); - std::vector sigy = {sqCI, sqCO}; + float sigy[2] = {sqCI, sqCO}; fit(x, y, sigy, pos, dir, covMatrix, chi2); @@ -351,28 +348,28 @@ void VectorHitBuilderAlgorithm::fit2Dzy(const Local3DPoint lpCI, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, double& chi2) const { - std::vector x = {lpCI.z(), lpCO.z()}; - std::vector y = {lpCI.y(), lpCO.y()}; + float x[2] = {lpCI.z(), lpCO.z()}; + float y[2] = {lpCI.y(), lpCO.y()}; float sqCI = sqrt(leCI.yy()); float sqCO = sqrt(leCO.yy()); - std::vector sigy = {sqCI, sqCO}; + float sigy[2] = {sqCI, sqCO}; fit(x, y, sigy, pos, dir, covMatrix, chi2); return; } -void VectorHitBuilderAlgorithm::fit(const std::vector& x, - const std::vector& y, - const std::vector& sigy, +void VectorHitBuilderAlgorithm::fit(float x[2], + float y[2], + float sigy[2], Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, double& chi2) const { - if (x.size() != y.size() || x.size() != sigy.size()) { - edm::LogError("VectorHitBuilderAlgorithm") << "Different size for x,z !! No fit possible."; - return; - } + // if (x.size() != y.size() || x.size() != sigy.size()) { + // edm::LogError("VectorHitBuilderAlgorithm") << "Different size for x,z !! No fit possible."; + // return; + // } float slope = 0.; float intercept = 0.; @@ -380,24 +377,25 @@ void VectorHitBuilderAlgorithm::fit(const std::vector& x, float covii = 0.; float covsi = 0.; - theFitter->fit(x, y, x.size(), sigy, slope, intercept, covss, covii, covsi); + //theFitter->linearFit(x, y, 2, sigy, slope, intercept, covss, covii, covsi); + linearFit(x, y, 2, sigy, slope, intercept, covss, covii, covsi); covMatrix[0][0] = covss; // this is var(dy/dz) covMatrix[1][1] = covii; // this is var(y) covMatrix[1][0] = covsi; // this is cov(dy/dz,y) - for (unsigned int j = 0; j < x.size(); j++) { + for (unsigned int j = 0; j < 2; j++) { const double ypred = intercept + slope * x[j]; const double dy = (y[j] - ypred) / sigy[j]; chi2 += dy * dy; } pos = Local3DPoint(intercept, 0., 0.); - if (x.size() == 2) { - //difference in z is the difference of the lowermost and the uppermost cluster z pos - float slopeZ = x.at(1) - x.at(0); - dir = LocalVector(slope, 0., slopeZ); - } else { - dir = LocalVector(slope, 0., -1.); - } + // if (x.size() == 2) { + //difference in z is the difference of the lowermost and the uppermost cluster z pos + float slopeZ = x[1] - x[0]; + dir = LocalVector(slope, 0., slopeZ); + // } else { + // dir = LocalVector(slope, 0., -1.); + // } } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index 9575020313679..48d2864c7038c 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -14,11 +14,11 @@ VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase( const ClusterParameterEstimator* cpeProd) : theTkGeom(tkGeomProd), theTkTopo(tkTopoProd), - cpe(cpeProd), + theCpe(cpeProd), nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), barrelCut(conf.getParameter >("BarrelCut")), endcapCut(conf.getParameter >("EndcapCut")), - cpeTag_(conf.getParameter("CPE")){ } + cpeTag_(conf.getParameter("CPE")) {} double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomDetUnit*& geomDetUnit_low, const Point3DBase& lPosClu_low, @@ -45,10 +45,10 @@ double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomD void VectorHitBuilderAlgorithmBase::printClusters(const edmNew::DetSetVector& clusters) const { int nCluster = 0; int numberOfDSV = 0; - for (const auto& DSViter : clusters){ + for (const auto& DSViter : clusters) { ++numberOfDSV; // Loop over the clusters in the detector unit - for (const auto& clustIt :DSViter) { + for (const auto& clustIt : DSViter) { nCluster++; // get the detector unit's id const GeomDetUnit* geomDetUnit(theTkGeom->idToDetUnit(DSViter.detId())); @@ -84,7 +84,7 @@ void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, LogTrace("VectorHitBuilder") << " and width:" << pixelGeomDetUnit->surface().bounds().width() << " , lenght:" << pixelGeomDetUnit->surface().bounds().length() << std::endl; - auto&& lparams = cpe->localParameters(*clustIt, *pixelGeomDetUnit); + auto&& lparams = theCpe->localParameters(*clustIt, *pixelGeomDetUnit); Global3DPoint gparams = pixelGeomDetUnit->surface().toGlobal(lparams.first); LogTrace("VectorHitBuilder") << "\t global pos " << gparams << std::endl; @@ -94,10 +94,11 @@ void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, return; } -void VectorHitBuilderAlgorithmBase::loadDetSetVector(std::map >& theMap, +void VectorHitBuilderAlgorithmBase::loadDetSetVector(std::unordered_map >& theMap, edmNew::DetSetVector& theCollection) const { for (const auto& it : theMap) { edmNew::DetSetVector::FastFiller vh_col(theCollection, it.first); - for (const auto& vh_it: it.second) vh_col.push_back(vh_it); + for (const auto& vh_it : it.second) + vh_col.push_back(vh_it); } } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc index e55abd65260f7..bb12a15caee68 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/ClustersValidationTGraph.cc @@ -125,14 +125,11 @@ void Phase2TrackerClusterizerValidationTGraph::beginJob() { trackerLayout_[1]->SetName("RVsZ_Pixel"); trackerLayout_[2] = td.make(); trackerLayout_[2]->SetName("RVsZ_Strip"); - trackerLayoutXY_[0] = - td.make(); + trackerLayoutXY_[0] = td.make(); trackerLayoutXY_[0]->SetName("YVsX_Mixed"); - trackerLayoutXY_[1] = - td.make(); + trackerLayoutXY_[1] = td.make(); trackerLayoutXY_[1]->SetName("YVsX_Pixel"); - trackerLayoutXY_[2] = - td.make(); + trackerLayoutXY_[2] = td.make(); trackerLayoutXY_[2]->SetName("YVsX_Strip"); trackerLayoutXYBar_ = td.make(); trackerLayoutXYBar_->SetName("YVsXBar"); @@ -202,7 +199,7 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, // Rearrange the simHits for ease of use SimHitsMap simHitsDetUnit; SimHitsMap simHitsTrackId; - for (const auto& simHitIt: *simHitsRaw) { + for (const auto& simHitIt : *simHitsRaw) { SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt.detUnitId())); if (simHitsDetUnitIt == simHitsDetUnit.end()) { std::pair newIt(simHitsDetUnit.insert( @@ -308,12 +305,12 @@ void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, for (unsigned int i(0); i < clustIt.size(); ++i) { unsigned int channel(PixelDigi::pixelToChannel( clustIt.firstRow() + i, - clustIt.column())); // Here we have to use the old pixelToChannel function (not Phase2TrackerDigi but PixelDigi), change this when using new Digis + clustIt + .column())); // Here we have to use the old pixelToChannel function (not Phase2TrackerDigi but PixelDigi), change this when using new Digis unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detId, channel)); clusterSimTrackIds.push_back(simTrackId); } - - } + } if (nClustersPixel) histogramLayer->second.numberClusterPixel->Fill(nClustersPixel); @@ -400,38 +397,32 @@ std::map::iterator Phase2TrackerClusterizerValidati histoName.str(""); histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; - local_histos.localPosXY[0] = - td.make(); + local_histos.localPosXY[0] = td.make(); local_histos.localPosXY[0]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Local_Position_XY_Pixel" << tag.c_str() << id; - local_histos.localPosXY[1] = - td.make(); + local_histos.localPosXY[1] = td.make(); local_histos.localPosXY[1]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Local_Position_XY_Strip" << tag.c_str() << id; - local_histos.localPosXY[2] = - td.make(); + local_histos.localPosXY[2] = td.make(); local_histos.localPosXY[2]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; - local_histos.globalPosXY[0] = - td.make(); + local_histos.globalPosXY[0] = td.make(); local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_Pixel" << tag.c_str() << id; - local_histos.globalPosXY[1] = - td.make(); + local_histos.globalPosXY[1] = td.make(); local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_Strip" << tag.c_str() << id; - local_histos.globalPosXY[2] = - td.make(); + local_histos.globalPosXY[2] = td.make(); local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); /* diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py index 2b8480df625d5..714dbb67c9ddc 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py @@ -91,19 +91,19 @@ # debug -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring("debugVH_tilted"), - debugModules = cms.untracked.vstring("*"), - categories = cms.untracked.vstring("VectorHitBuilderEDProducer","VectorHitBuilderAlgorithm","VectorHitsBuilderValidation","CkfPattern"), - debugVH_tilted = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), - DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), - default = cms.untracked.PSet(limit = cms.untracked.int32(0)), - VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), - VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), - CkfPattern = cms.untracked.PSet(limit = cms.untracked.int32(-1)), - VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) - ) - ) +#process.MessageLogger = cms.Service("MessageLogger", +# destinations = cms.untracked.vstring("debugVH_tilted"), +# debugModules = cms.untracked.vstring("*"), +# categories = cms.untracked.vstring("VectorHitBuilderEDProducer","VectorHitBuilderAlgorithm","VectorHitsBuilderValidation","CkfPattern"), +# debugVH_tilted = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), +# DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), +# default = cms.untracked.PSet(limit = cms.untracked.int32(0)), +# VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), +# VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), +# CkfPattern = cms.untracked.PSet(limit = cms.untracked.int32(-1)), +# VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) +# ) +# ) # Path and EndPath definitions diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 548bac202e449..7a1d6fe06748e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -84,7 +84,6 @@ void VectorHitsBuilderValidation::beginJob() { VHaccTrue_signal_Layer_->SetName("VHaccepted_true_signal"); VHrejTrue_signal_Layer_ = tdWid.make("VHrejTrueSignalLayer", "VHrejTrueSignalLayer", 250, 0., 250.); VHrejTrue_signal_Layer_->SetName("VHrejected_true_signal"); - } void VectorHitsBuilderValidation::endJob() {} @@ -288,7 +287,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } } for (const auto& DSViter : *vhsRej) { - for (const auto& vhIt :DSViter) { + for (const auto& vhIt : DSViter) { LogTrace("VectorHitsBuilderValidation") << "rejected VH: " << vhIt; } } @@ -519,9 +518,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev unsigned int otherSimHits(0); for (const auto hitIt : *simHitsRaw) { - if (hitIt.detUnitId() == - geomDetLower->geographicalId()) { - + if (hitIt.detUnitId() == geomDetLower->geographicalId()) { //check clusters track id compatibility if (std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt.trackId()) != clusterSimTrackIds.end()) { @@ -738,7 +735,6 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } } - for (const auto& DSViter : *vhsRej) { unsigned int rawid(DSViter.detId()); DetId detId(rawid); @@ -774,7 +770,6 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } } - int VHtot = VHacc + VHrej; LogTrace("VectorHitsBuilderValidation") << "VH total: " << VHtot << " with " << VHacc << " VHs accepted and " << VHrej << " VHs rejected."; @@ -886,38 +881,32 @@ std::map::iterator VectorHitsBuilderValidation::createLa histoName.str(""); histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; - local_histos.localPosXY[0] = - td.make(); + local_histos.localPosXY[0] = td.make(); local_histos.localPosXY[0]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Local_Position_XY_PS" << tag.c_str() << id; - local_histos.localPosXY[1] = - td.make(); + local_histos.localPosXY[1] = td.make(); local_histos.localPosXY[1]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Local_Position_XY_2S" << tag.c_str() << id; - local_histos.localPosXY[2] = - td.make(); + local_histos.localPosXY[2] = td.make(); local_histos.localPosXY[2]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; - local_histos.globalPosXY[0] = - td.make(); + local_histos.globalPosXY[0] = td.make(); local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_PS" << tag.c_str() << id; - local_histos.globalPosXY[1] = - td.make(); + local_histos.globalPosXY[1] = td.make(); local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); histoName.str(""); histoName << "Global_Position_XY_2S" << tag.c_str() << id; - local_histos.globalPosXY[2] = - td.make(); + local_histos.globalPosXY[2] = td.make(); local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); /* @@ -1023,12 +1012,12 @@ void VectorHitsBuilderValidation::CreateVHsXYGraph(const std::vector { static void fillDescriptions(edm::ConfigurationDescriptions&); - TrajectorySeedCollection run(edm::Handle); + std::unique_ptr run(edm::Handle); unsigned int checkLayer(unsigned int iidd); std::vector collectVHsOnLayer(const edmNew::DetSetVector&, unsigned int); void printVHsOnLayer(const edmNew::DetSetVector&, unsigned int); @@ -89,6 +89,7 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { edm::ESGetToken updatorToken_; edm::ESGetToken measurementTrackerToken_; edm::ESGetToken estToken_; + edm::EDPutTokenT putToken_; }; SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) @@ -97,13 +98,13 @@ SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) topoToken_(esConsumes()), propagatorToken_(esConsumes(edm::ESInputTag("", "PropagatorWithMaterial"))), magFieldToken_(esConsumes()), - updatorToken_(esConsumes(edm::ESInputTag("","KFUpdator"))), + updatorToken_(esConsumes(edm::ESInputTag("", "KFUpdator"))), measurementTrackerToken_(esConsumes()), estToken_(esConsumes(edm::ESInputTag("", "Chi2"))) { vhProducerToken_ = consumes(edm::InputTag(conf.getParameter("src"))); beamSpotToken_ = consumes(conf.getParameter("beamSpotLabel")); updatorName_ = conf.getParameter("updator"); - produces(); + putToken_ = produces(); } SeedingOTEDProducer::~SeedingOTEDProducer() {} @@ -118,7 +119,7 @@ void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descr } void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { - auto seedsWithVHs = std::make_unique(); + //auto seedsWithVHs = std::make_unique(); tkTopo_ = &es.getData(topoToken_); @@ -148,18 +149,20 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) edm::Handle vhs; event.getByToken(vhProducerToken_, vhs); - TrajectorySeedCollection const& tempSeeds = run(vhs); + /* TrajectorySeedCollection const& tempSeeds = run(vhs); for (auto& qIt : tempSeeds) { seedsWithVHs->push_back(qIt); } seedsWithVHs->shrink_to_fit(); - event.put(std::move(seedsWithVHs)); + event.put(std::move(seedsWithVHs));*/ + //auto seedsWithVHs = std::make_unique<> + event.put(putToken_, run(vhs)); } -TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { - TrajectorySeedCollection result; - +std::unique_ptr SeedingOTEDProducer::run(edm::Handle VHs) { + //TrajectorySeedCollection result; + auto result = std::make_unique(); //check if all the first three layers have VHs std::vector vhSeedsL1 = collectVHsOnLayer(*(VHs.product()), 1); std::vector vhSeedsL2 = collectVHsOnLayer(*(VHs.product()), 2); @@ -245,21 +248,21 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle updatedTSOSL2_final = propagateAndUpdate(updatedTSOSL1_final, *buildingPropagator, *hitL2); - if (!updatedTSOSL2_final.first) + if (!updatedTSOSL2_final.first) continue; - std::pair updatedTSOSL3_final = + std::pair updatedTSOSL3_final = propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, hitL3); if (!updatedTSOSL3_final.first) continue; TrajectorySeed ts = createSeed(updatedTSOSL3_final.second, container, hitL3.geographicalId(), *buildingPropagator); - result.push_back(ts); + result->push_back(ts); } } } } } - + result->shrink_to_fit(); return result; } @@ -293,7 +296,7 @@ void SeedingOTEDProducer::printVHsOnLayer(const edmNew::DetSetVector& for (const auto& DSViter : input) { for (const auto& vh : DSViter) { if (checkLayer(DSViter.id()) == layerNumber) - LogTrace("SeedingOTEDProducer") << " VH in layer " << layerNumber << " >> " << vh; + LogTrace("SeedingOTEDProducer") << " VH in layer " << layerNumber << " >> " << vh; } } } else { @@ -336,7 +339,7 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto return tsos; } -AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) const{ +AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) const { if (mat44.num_row() != 4 || mat44.num_col() != 4) assert("Wrong dimension! This should be a 4x4 matrix!"); @@ -353,7 +356,7 @@ std::pair SeedingOTEDProducer::propagateAndUpdat const TrajectoryStateOnSurface initialTSOS, const Propagator& prop, const TrackingRecHit& hit) const { TrajectoryStateOnSurface propTSOS = prop.propagate(initialTSOS, hit.det()->surface()); if UNLIKELY (!propTSOS.isValid()) - return std::make_pair(false, propTSOS); + return std::make_pair(false, propTSOS); TrajectoryStateOnSurface updatedTSOS = updator_->update(propTSOS, hit); if UNLIKELY (!updatedTSOS.isValid()) return std::make_pair(false, updatedTSOS); diff --git a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc index 09087a243275a..f93d4eedc55e7 100644 --- a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc +++ b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc @@ -129,9 +129,7 @@ void HitExtractorSTRP::cleanedOfClusters(const TkTransientTrackingRecHitBuilder& assert(hits[iH]->isValid()); auto id = hits[iH]->geographicalId(); if (matched) { - bool replace; - ProjectedSiStripRecHit2D* replaceMe; - std::tie(replace, replaceMe) = skipThis(ttrhBuilder, *hits[iH], stripClusterMask); + auto [replace, replaceMe] = skipThis(ttrhBuilder, *hits[iH], stripClusterMask); if (replace) { if (!replaceMe) { LogTrace("HitExtractorSTRP") << "skipping a matched hit on :" << hits[iH]->geographicalId().rawId(); From 9109e2ebc4c2b72966cf85cbc2bf8b1f4e5c4ccd Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 9 Sep 2020 08:00:43 -0500 Subject: [PATCH 057/115] fix clang compile error --- .../SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 7a1d6fe06748e..ce79785e8962b 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -517,7 +517,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev unsigned int primarySimHits(0); unsigned int otherSimHits(0); - for (const auto hitIt : *simHitsRaw) { + for (const auto& hitIt : *simHitsRaw) { if (hitIt.detUnitId() == geomDetLower->geographicalId()) { //check clusters track id compatibility if (std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt.trackId()) != From 0aba3e5ad6cb082e8057b968ac2c9be8f1b67fd2 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 9 Sep 2020 09:59:52 -0500 Subject: [PATCH 058/115] move curvatureOrPhi function from VectorHit to VectorHitBuilderAlgorithm and move momentum and transverseMomentum function back to VectorHit --- .../TrackerRecHit2D/interface/VectorHit.h | 25 ++- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 195 ++---------------- .../TrackerRecHit2D/src/classes_def.xml | 4 +- .../interface/VectorHitBuilderAlgorithm.h | 4 + .../interface/VectorHitMomentumHelper.h | 26 --- .../src/VectorHitBuilderAlgorithm.cc | 193 ++++++++++++++++- .../test/VectorHitsValidation.cc | 10 +- .../test/VectorHitsValidation.h | 1 - .../plugins/SeedingOTEDProducer.cc | 8 +- 9 files changed, 238 insertions(+), 228 deletions(-) delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 7f726e4149533..454464035454b 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -39,13 +39,19 @@ class VectorHit final : public BaseTrackerRecHit { const AlgebraicSymMatrix& covMatrix, const float chi2, OmniClusterRef const& lower, - OmniClusterRef const& upper); + OmniClusterRef const& upper, + const float curvature, + const float curvatureError, + const float phi); VectorHit(const GeomDet& idet, const VectorHit2D& vh2Dzx, const VectorHit2D& vh2Dzy, OmniClusterRef const& lower, - OmniClusterRef const& upper); + OmniClusterRef const& upper, + const float curvature, + const float curvatureError, + const float phi); ~VectorHit() override; @@ -77,10 +83,12 @@ class VectorHit final : public BaseTrackerRecHit { virtual float chi2() const { return theChi2; } int dimension() const override { return theDimension; } + float curvature() const { return theCurvature; } + float curvatureError() const { return theCurvatureError; } + float phi() const { return thePhi; } - enum curvatureOrPhi { curvatureMode, phiMode }; - - std::pair curvatureORphi(curvatureOrPhi curvatureMode) const; + float transverseMomentum(float magField) const; + float momentum(float magField) const; /// "lower" is logical, not geometrically lower; in pixel-strip modules the "lower" is always a pixel ClusterRef lowerCluster() const { return theLowerCluster.cluster_phase2OT(); } @@ -91,10 +99,10 @@ class VectorHit final : public BaseTrackerRecHit { //FIXME::to update with a proper CPE maybe... Global3DPoint lowerGlobalPos() const; Global3DPoint upperGlobalPos() const; - Global3DPoint phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster) const; + static Global3DPoint phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster); GlobalError lowerGlobalPosErr() const; GlobalError upperGlobalPosErr() const; - GlobalError phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet) const; + static GlobalError phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet); bool isPhase2() const override { return true; } @@ -142,6 +150,9 @@ class VectorHit final : public BaseTrackerRecHit { int theDimension; OmniClusterRef theLowerCluster; OmniClusterRef theUpperCluster; + float theCurvature; + float theCurvatureError; + float thePhi; }; inline bool operator<(const VectorHit& one, const VectorHit& other) { return (one.chi2() < other.chi2()); } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index b8e5d895e7c12..3710a0d10718d 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -9,7 +9,10 @@ VectorHit::VectorHit(const VectorHit& vh) theChi2(vh.chi2()), theDimension(vh.dimension()), theLowerCluster(vh.lowerClusterRef()), - theUpperCluster(vh.upperClusterRef()) {} + theUpperCluster(vh.upperClusterRef()), + theCurvature(vh.curvature()), + theCurvatureError(vh.curvatureError()), + thePhi(vh.phi()) {} VectorHit::VectorHit(const GeomDet& idet, const LocalPoint& posLower, @@ -17,7 +20,10 @@ VectorHit::VectorHit(const GeomDet& idet, const AlgebraicSymMatrix& covMatrix, const float chi2, OmniClusterRef const& lower, - OmniClusterRef const& upper) + OmniClusterRef const& upper, + const float curvature, + const float curvatureError, + const float phi) : BaseTrackerRecHit(idet, trackerHitRTTI::vector), thePosition(posLower), theDirection(dir), @@ -25,14 +31,20 @@ VectorHit::VectorHit(const GeomDet& idet, theChi2(chi2), theDimension(4), theLowerCluster(lower), - theUpperCluster(upper) {} + theUpperCluster(upper), + theCurvature(curvature), + theCurvatureError(curvatureError), + thePhi(phi) {} VectorHit::VectorHit(const GeomDet& idet, const VectorHit2D& vh2Dzx, const VectorHit2D& vh2Dzy, OmniClusterRef const& lower, - OmniClusterRef const& upper) - : BaseTrackerRecHit(idet, trackerHitRTTI::vector), theDimension(4), theLowerCluster(lower), theUpperCluster(upper) { + OmniClusterRef const& upper, + const float curvature, + const float curvatureError, + const float phi) + : BaseTrackerRecHit(idet, trackerHitRTTI::vector), theDimension(4), theLowerCluster(lower), theUpperCluster(upper), theCurvature(curvature), theCurvatureError(curvatureError), thePhi(phi) { thePosition = LocalPoint(vh2Dzx.localPosition()->x(), vh2Dzy.localPosition()->x(), 0.); theDirection = LocalVector(vh2Dzx.localDirection()->x(), vh2Dzy.localDirection()->x(), 1.); @@ -129,7 +141,7 @@ Global3DPoint VectorHit::upperGlobalPos() const { return phase2clusterGlobalPos(geomDetUpper, upperCluster()); } -Global3DPoint VectorHit::phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster) const { +Global3DPoint VectorHit::phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster) { const PixelTopology* topo = &geomDet->specificTopology(); float ix = cluster->center(); float iy = cluster->column() + 0.5; // halfway the column @@ -150,7 +162,7 @@ GlobalError VectorHit::upperGlobalPosErr() const { return phase2clusterGlobalPosErr(geomDetUpper); } -GlobalError VectorHit::phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet) const { +GlobalError VectorHit::phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet) { const PixelTopology* topo = &geomDet->specificTopology(); float pitchX = topo->pitch().first; float pitchY = topo->pitch().second; @@ -169,174 +181,11 @@ Global3DVector VectorHit::globalDelta() const { Global3DVector VectorHit::globalDirection() const { return (det()->surface().toGlobal(localDirection())); } -std::pair VectorHit::curvatureORphi(curvatureOrPhi curvORphi) const { - float curvature = -999.; - float errorCurvature = -999.; - float phi = -999.; - - //global pos and errors - Global3DPoint gPositionLower = lowerGlobalPos(); - Global3DPoint gPositionUpper = upperGlobalPos(); - - GlobalError gErrorLower = lowerGlobalPosErr(); - GlobalError gErrorUpper = upperGlobalPosErr(); - - //insert lower and upper in the global sor - if (gPositionLower.perp() > gPositionUpper.perp()) { - gPositionLower = upperGlobalPos(); - gPositionUpper = lowerGlobalPos(); - gErrorLower = upperGlobalPosErr(); - gErrorUpper = lowerGlobalPosErr(); - } - - float h1 = gPositionLower.x() * gPositionUpper.y() - gPositionUpper.x() * gPositionLower.y(); - - //determine sign of curvature - AlgebraicVector2 n1; - n1[0] = -gPositionLower.y(); - n1[1] = gPositionLower.x(); - AlgebraicVector2 n2; - n2[0] = gPositionUpper.x() - gPositionLower.x(); - n2[1] = gPositionUpper.y() - gPositionLower.y(); - - double n3 = n1[0] * n2[0] + n1[1] * n2[1]; - double signCurv = -copysign(1.0, n3); - double phi1 = atan2(gPositionUpper.y() - gPositionLower.y(), gPositionUpper.x() - gPositionLower.x()); - - if (h1 != 0) { - double h2 = 2 * h1; - double h2Inf = 1. / (2 * h1); - double r12 = pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2); - double r22 = pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2); - double h3 = - (pow(gPositionLower.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.x(), 2) + - pow(gPositionLower.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y() + pow(gPositionUpper.y(), 2)); - double h4 = -pow(gPositionLower.x(), 2) * gPositionUpper.x() + gPositionLower.x() * pow(gPositionUpper.x(), 2) + - gPositionLower.x() * pow(gPositionUpper.y(), 2) - gPositionUpper.x() * pow(gPositionLower.y(), 2); - double h5 = pow(gPositionLower.x(), 2) * gPositionUpper.y() - pow(gPositionUpper.x(), 2) * gPositionLower.y() + - pow(gPositionLower.y(), 2) * gPositionUpper.y() - gPositionLower.y() * pow(gPositionUpper.y(), 2); - - //radius of circle - double invRho2 = (4. * h1 * h1) / (r12 * r22 * h3); - curvature = sqrt(invRho2); - - //center of circle - double xcentre = h5 / h2; - double ycentre = h4 / h2; - - //to compute phi at the cluster points - double xtg = gPositionLower.y() - ycentre; - double ytg = -(gPositionLower.x() - xcentre); - - //to compute phi at the origin - phi = atan2(ytg, xtg); - - AlgebraicROOTObject<4, 4>::Matrix jacobian; - - double denom1 = 1. / sqrt(r12 * r22 * h3); - double denom2 = 1. / (pow(r12 * r22 * h3, 1.5)); - jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 - jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 - jacobian[2][0] = - -2. * ((h1 * (gPositionLower.x() * r22 * h3 + (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2 - - (gPositionUpper.y()) * denom1); // dkappa/dx1 - jacobian[2][1] = - -2. * ((gPositionUpper.x()) * denom1 + - (h1 * (gPositionLower.y() * r22 * h3 + r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * - denom2); // dkappa/dy1 - jacobian[2][2] = - -2. * ((gPositionLower.y()) * denom1 + - (h1 * (gPositionUpper.x() * r12 * h3 - (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * - denom2); // dkappa/dx2 - jacobian[2][3] = - -2. * ((h1 * (gPositionUpper.y() * r12 * h3 - r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * denom2 - - (gPositionLower.x()) * denom1); // dkappa/dy2 - - AlgebraicVector2 M; - //to compute phi at the cluster points - M[0] = (gPositionLower.y() - ycentre) * invRho2; // dphi/dxcentre - M[1] = -(gPositionLower.x() - xcentre) * invRho2; // dphi/dycentre - //to compute phi at the origin - - AlgebraicROOTObject<2, 4>::Matrix K; - K[0][0] = - 2. * ((gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionUpper.y() * h5) / pow(h2, 2)); // dxm/dx1 - K[0][1] = (2. * gPositionUpper.x() * h5) / pow(h2, 2) - - (pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y()) * - h2Inf; // dxm/dy1 - K[0][2] = - 2. * ((gPositionLower.y() * h5) / pow(h2, 2) - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dxm/dx2 - K[0][3] = (pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2) - 2. * gPositionUpper.y() * gPositionLower.y()) * - h2Inf - - (2. * gPositionLower.x() * h5) / pow(h2, 2); // dxm/dy2 - K[1][0] = (pow(gPositionUpper.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.y(), 2)) * - h2Inf - - (2. * gPositionUpper.y() * h4) / pow(h2, 2); // dym/dx1 - K[1][1] = - 2. * ((gPositionUpper.x() * h4) / pow(h2, 2) - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dym/dy1 - K[1][2] = (2. * gPositionLower.y() * h4) / pow(h2, 2) - - (pow(gPositionLower.x(), 2) - 2. * gPositionUpper.x() * gPositionLower.x() + pow(gPositionLower.y(), 2)) * - h2Inf; // dym/dx2 - K[1][3] = - 2. * (gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionLower.x() * h4) / pow(h2, 2); // dym/dy2 - - AlgebraicVector4 N = M * K; - jacobian[3][0] = N[0]; // dphi/(dx1,dy1,dx2,dy2) - jacobian[3][1] = N[1]; // dphi/(dx1,dy1,dx2,dy2) - jacobian[3][2] = N[2]; // dphi/(dx1,dy1,dx2,dy2) - jacobian[3][3] = N[3]; // dphi/(dx1,dy1,dx2,dy2) - - //assign correct sign to the curvature errors - if ((signCurv < 0 && curvature > 0) || (signCurv > 0 && curvature < 0)) { - curvature = -curvature; - for (int i = 0; i < 4; i++) { - jacobian[2][i] = -jacobian[2][i]; - } - } - - // bring phi in the same quadrant as phi1 - if (deltaPhi(phi, phi1) > M_PI / 2.) { - phi = phi + M_PI; - if (phi > M_PI) - phi = phi - 2. * M_PI; - } - - //computing the curvature error - AlgebraicVector4 curvatureJacobian; - for (int i = 0; i < 4; i++) { - curvatureJacobian[i] = jacobian[2][i]; - } - - AlgebraicROOTObject<4, 4>::Matrix gErrors; - - gErrors[0][0] = gErrorLower.cxx(); - gErrors[0][1] = gErrorLower.cyx(); - gErrors[1][0] = gErrorLower.cyx(); - gErrors[1][1] = gErrorLower.cyy(); - gErrors[2][2] = gErrorUpper.cxx(); - gErrors[2][3] = gErrorUpper.cyx(); - gErrors[3][2] = gErrorUpper.cyx(); - gErrors[3][3] = gErrorUpper.cyy(); - - AlgebraicVector4 temp = curvatureJacobian; - temp = temp * gErrors; - errorCurvature = temp[0] * curvatureJacobian[0] + temp[1] * curvatureJacobian[1] + temp[2] * curvatureJacobian[2] + - temp[3] * curvatureJacobian[3]; - - } else { - return std::make_pair(0.0, 0.0); - } - switch (curvORphi) { - case curvatureMode: - return std::make_pair(curvature, errorCurvature); - case phiMode: - return std::make_pair(phi, 0.0); - } - return std::make_pair(0.0, 0.0); -} - float VectorHit::theta() const { return globalDirection().theta(); } +float VectorHit::transverseMomentum(float magField) const { return magField * 2.99792458e-3F / theCurvature;} // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, thus using 2.99792458e-3F (precise value from speed of light) +float VectorHit::momentum(float magField) const { return transverseMomentum(magField) / (1. * sin(theta()));} + AlgebraicMatrix VectorHit::projectionMatrix() const { // obsolete (for what tracker is concerned...) interface static const AlgebraicMatrix the4DProjectionMatrix(4, 5, 0); diff --git a/DataFormats/TrackerRecHit2D/src/classes_def.xml b/DataFormats/TrackerRecHit2D/src/classes_def.xml index 569ec40801614..2175ee0e8f371 100644 --- a/DataFormats/TrackerRecHit2D/src/classes_def.xml +++ b/DataFormats/TrackerRecHit2D/src/classes_def.xml @@ -189,8 +189,8 @@ - - + + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index f8ec0ef0aa2f3..f6c1e89ab4153 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -38,6 +38,10 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { LocalError& errinner, LocalError& errouter) const; + enum curvatureOrPhi { curvatureMode, phiMode }; + + std::pair curvatureORphi(curvatureOrPhi curvatureMode, Global3DPoint gPositionLower, Global3DPoint gPositionUpper, GlobalError gErrorLower, GlobalError gErrorUpper ) const; + class LocalPositionSort { public: LocalPositionSort(const TrackerGeometry* geometry, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h deleted file mode 100644 index dbe8b1096fc2c..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef VectorHitMomentumHelper_H -#define VectorHitMomentumHelper_H - -#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" -#include "MagneticField/Engine/interface/MagneticField.h" - -class VectorHitMomentumHelper { -public: - VectorHitMomentumHelper(const MagneticField* magField) { - GlobalPoint center(0.0, 0.0, 0.0); - intermediate = magField->inTesla(center).mag() * 0.003; - //0.003 is because the curvature (rho) is in cm and not in m - } - ~VectorHitMomentumHelper() {} - - float transverseMomentum(const VectorHit& vh) const { - float rho = 1. / vh.curvatureORphi(VectorHit::curvatureMode).first; - return (intermediate * rho); - } - float momentum(const VectorHit& vh) const { return transverseMomentum(vh) / (1. * sin(vh.theta())); } - -private: - float intermediate; -}; - -#endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 1c8c2c8de6205..fa4de8f46494e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -314,7 +314,24 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, OmniClusterRef lowerOmni(lower); OmniClusterRef upperOmni(upper); - VectorHit vh = VectorHit(*stack, vh2Dzx, vh2Dzy, lowerOmni, upperOmni); + + Global3DPoint gPositionLower = VectorHit::phase2clusterGlobalPos(geomDetLower, lower); + Global3DPoint gPositionUpper = VectorHit::phase2clusterGlobalPos(geomDetUpper, upper); + GlobalError gErrorLower = VectorHit::phase2clusterGlobalPosErr(geomDetLower); + GlobalError gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetUpper); + + + if (gPositionLower.perp() > gPositionUpper.perp()) { + gPositionLower = VectorHit::phase2clusterGlobalPos(geomDetUpper, upper); + gPositionUpper = VectorHit::phase2clusterGlobalPos(geomDetLower, lower); + gErrorLower = VectorHit::phase2clusterGlobalPosErr(geomDetUpper); + gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetLower); + } + const float curvature = curvatureORphi(curvatureMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).first; + const float curvatureError = curvatureORphi(curvatureMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).second; + const float phi = curvatureORphi(phiMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).first; + + VectorHit vh = VectorHit(*stack, vh2Dzx, vh2Dzy, lowerOmni, upperOmni, curvature, curvatureError, phi); return vh; } @@ -366,10 +383,6 @@ void VectorHitBuilderAlgorithm::fit(float x[2], Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, double& chi2) const { - // if (x.size() != y.size() || x.size() != sigy.size()) { - // edm::LogError("VectorHitBuilderAlgorithm") << "Different size for x,z !! No fit possible."; - // return; - // } float slope = 0.; float intercept = 0.; @@ -391,11 +404,173 @@ void VectorHitBuilderAlgorithm::fit(float x[2], } pos = Local3DPoint(intercept, 0., 0.); - // if (x.size() == 2) { //difference in z is the difference of the lowermost and the uppermost cluster z pos float slopeZ = x[1] - x[0]; dir = LocalVector(slope, 0., slopeZ); - // } else { - // dir = LocalVector(slope, 0., -1.); - // } } + +std::pair VectorHitBuilderAlgorithm::curvatureORphi(curvatureOrPhi curvORphi, Global3DPoint gPositionLower, Global3DPoint gPositionUpper, GlobalError gErrorLower, GlobalError gErrorUpper) const { + float curvature = -999.; + float errorCurvature = -999.; + float phi = -999.; + + //global pos and errors +// Global3DPoint gPositionLower = lowerGlobalPos(); +// Global3DPoint gPositionUpper = upperGlobalPos(); + +// GlobalError gErrorLower = lowerGlobalPosErr(); +// GlobalError gErrorUpper = upperGlobalPosErr(); + + //insert lower and upper in the global sor +// if (gPositionLower.perp() > gPositionUpper.perp()) { +// gPositionLower = upperGlobalPos(); +// gPositionUpper = lowerGlobalPos(); +// gErrorLower = upperGlobalPosErr(); +// gErrorUpper = lowerGlobalPosErr(); +// } + + float h1 = gPositionLower.x() * gPositionUpper.y() - gPositionUpper.x() * gPositionLower.y(); + + //determine sign of curvature + AlgebraicVector2 n1; + n1[0] = -gPositionLower.y(); + n1[1] = gPositionLower.x(); + AlgebraicVector2 n2; + n2[0] = gPositionUpper.x() - gPositionLower.x(); + n2[1] = gPositionUpper.y() - gPositionLower.y(); + + double n3 = n1[0] * n2[0] + n1[1] * n2[1]; + double signCurv = -copysign(1.0, n3); + double phi1 = atan2(gPositionUpper.y() - gPositionLower.y(), gPositionUpper.x() - gPositionLower.x()); + + if (h1 != 0) { + double h2 = 2 * h1; + double h2Inf = 1. / (2 * h1); + double r12 = pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2); + double r22 = pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2); + double h3 = + (pow(gPositionLower.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.x(), 2) + + pow(gPositionLower.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y() + pow(gPositionUpper.y(), 2)); + double h4 = -pow(gPositionLower.x(), 2) * gPositionUpper.x() + gPositionLower.x() * pow(gPositionUpper.x(), 2) + + gPositionLower.x() * pow(gPositionUpper.y(), 2) - gPositionUpper.x() * pow(gPositionLower.y(), 2); + double h5 = pow(gPositionLower.x(), 2) * gPositionUpper.y() - pow(gPositionUpper.x(), 2) * gPositionLower.y() + + pow(gPositionLower.y(), 2) * gPositionUpper.y() - gPositionLower.y() * pow(gPositionUpper.y(), 2); + + //radius of circle + double invRho2 = (4. * h1 * h1) / (r12 * r22 * h3); + curvature = sqrt(invRho2); + + //center of circle + double xcentre = h5 / h2; + double ycentre = h4 / h2; + + //to compute phi at the cluster points + double xtg = gPositionLower.y() - ycentre; + double ytg = -(gPositionLower.x() - xcentre); + + //to compute phi at the origin + phi = atan2(ytg, xtg); + + AlgebraicROOTObject<4, 4>::Matrix jacobian; + + double denom1 = 1. / sqrt(r12 * r22 * h3); + double denom2 = 1. / (pow(r12 * r22 * h3, 1.5)); + jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 + jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 + jacobian[2][0] = + -2. * ((h1 * (gPositionLower.x() * r22 * h3 + (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2 - + (gPositionUpper.y()) * denom1); // dkappa/dx1 + jacobian[2][1] = + -2. * ((gPositionUpper.x()) * denom1 + + (h1 * (gPositionLower.y() * r22 * h3 + r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * + denom2); // dkappa/dy1 + jacobian[2][2] = + -2. * ((gPositionLower.y()) * denom1 + + (h1 * (gPositionUpper.x() * r12 * h3 - (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * + denom2); // dkappa/dx2 + jacobian[2][3] = + -2. * ((h1 * (gPositionUpper.y() * r12 * h3 - r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * denom2 - + (gPositionLower.x()) * denom1); // dkappa/dy2 + AlgebraicVector2 M; + //to compute phi at the cluster points + M[0] = (gPositionLower.y() - ycentre) * invRho2; // dphi/dxcentre + M[1] = -(gPositionLower.x() - xcentre) * invRho2; // dphi/dycentre + //to compute phi at the origin + + AlgebraicROOTObject<2, 4>::Matrix K; + K[0][0] = + 2. * ((gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionUpper.y() * h5) / pow(h2, 2)); // dxm/dx1 + K[0][1] = (2. * gPositionUpper.x() * h5) / pow(h2, 2) - + (pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y()) * + h2Inf; // dxm/dy1 + K[0][2] = + 2. * ((gPositionLower.y() * h5) / pow(h2, 2) - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dxm/dx2 + K[0][3] = (pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2) - 2. * gPositionUpper.y() * gPositionLower.y()) * + h2Inf - + (2. * gPositionLower.x() * h5) / pow(h2, 2); // dxm/dy2 + K[1][0] = (pow(gPositionUpper.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.y(), 2)) * + h2Inf - + (2. * gPositionUpper.y() * h4) / pow(h2, 2); // dym/dx1 + K[1][1] = + 2. * ((gPositionUpper.x() * h4) / pow(h2, 2) - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dym/dy1 + K[1][2] = (2. * gPositionLower.y() * h4) / pow(h2, 2) - + (pow(gPositionLower.x(), 2) - 2. * gPositionUpper.x() * gPositionLower.x() + pow(gPositionLower.y(), 2)) * + h2Inf; // dym/dx2 + K[1][3] = + 2. * (gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionLower.x() * h4) / pow(h2, 2); // dym/dy2 + + AlgebraicVector4 N = M * K; + jacobian[3][0] = N[0]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][1] = N[1]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][2] = N[2]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][3] = N[3]; // dphi/(dx1,dy1,dx2,dy2) + + //assign correct sign to the curvature errors + if ((signCurv < 0 && curvature > 0) || (signCurv > 0 && curvature < 0)) { + curvature = -curvature; + for (int i = 0; i < 4; i++) { + jacobian[2][i] = -jacobian[2][i]; + } + } + + // bring phi in the same quadrant as phi1 + if (deltaPhi(phi, phi1) > M_PI / 2.) { + phi = phi + M_PI; + if (phi > M_PI) + phi = phi - 2. * M_PI; + } + + //computing the curvature error + AlgebraicVector4 curvatureJacobian; + for (int i = 0; i < 4; i++) { + curvatureJacobian[i] = jacobian[2][i]; + } + + AlgebraicROOTObject<4, 4>::Matrix gErrors; + + gErrors[0][0] = gErrorLower.cxx(); + gErrors[0][1] = gErrorLower.cyx(); + gErrors[1][0] = gErrorLower.cyx(); + gErrors[1][1] = gErrorLower.cyy(); + gErrors[2][2] = gErrorUpper.cxx(); + gErrors[2][3] = gErrorUpper.cyx(); + gErrors[3][2] = gErrorUpper.cyx(); + gErrors[3][3] = gErrorUpper.cyy(); + + AlgebraicVector4 temp = curvatureJacobian; + temp = temp * gErrors; + errorCurvature = temp[0] * curvatureJacobian[0] + temp[1] * curvatureJacobian[1] + temp[2] * curvatureJacobian[2] + + temp[3] * curvatureJacobian[3]; + + } else { + return std::make_pair(0.0, 0.0); + } + switch (curvORphi) { + case curvatureMode: + return std::make_pair(curvature, errorCurvature); + case phiMode: + return std::make_pair(phi, 0.0); + } + return std::make_pair(0.0, 0.0); +} + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index ce79785e8962b..4195a2a85e149 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -601,12 +601,12 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev continue; } - VectorHitMomentumHelper vhMomHelper(magField_); //curvature - curvature = vh.curvatureORphi(VectorHit::curvatureMode).first; - phi = vh.curvatureORphi(VectorHit::phiMode).first; - QOverPT = vhMomHelper.transverseMomentum(vh); - QOverP = vhMomHelper.momentum(vh); + GlobalPoint center(0.0, 0.0, 0.0); + curvature = vh.curvature(); + phi = vh.phi(); + QOverPT = vh.transverseMomentum(magField_->inTesla(center).z()); + QOverP = vh.momentum(magField_->inTesla(center).z()); histogramLayer->second.curvature->Fill(curvature); //stub width diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index 074433bf3a96c..0bfcb55fb4602 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -30,7 +30,6 @@ #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" #include "DataFormats/SiPixelDigi/interface/PixelDigi.h" #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" #include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h" #include "SimDataFormats/Track/interface/SimTrackContainer.h" diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index fd8adebc9ccea..8afbdb9763eff 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -9,7 +9,6 @@ #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" #include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitMomentumHelper.h" #include "RecoTracker/Record/interface/CkfComponentsRecord.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" @@ -311,12 +310,11 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto // gv transform to local (lv) const Local3DVector lv(vHit.det()->surface().toLocal(gv)); - //Helper class to access momentum of VH - VectorHitMomentumHelper vhMomHelper(magField_); //FIXME::charge is fine 1 every two times!! + GlobalPoint center(0.0, 0.0, 0.0); int charge = 1; - float p = vhMomHelper.momentum(vHit); + float p = vHit.momentum(magField_->inTesla(center).z()); float x = vHit.localPosition().x(); float y = vHit.localPosition().y(); float dx = vHit.localDirection().x(); @@ -330,7 +328,7 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p mat[0][0] = - pow(computeInverseMomentumError(vHit, theta, beamSpot_->sigmaZ(), vhMomHelper.transverseMomentum(vHit)), 2); + pow(computeInverseMomentumError(vHit, theta, beamSpot_->sigmaZ(), vHit.transverseMomentum(magField_->inTesla(center).z())), 2); //building tsos LocalTrajectoryError lterr(asSMatrix<5>(mat)); From 90cf48a7f0b1b27ad57b771d5b33a80a1828c791 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 9 Sep 2020 15:17:43 -0500 Subject: [PATCH 059/115] code checks, mostly --- .../TrackerRecHit2D/interface/VectorHit.h | 4 +- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 14 +++++-- .../interface/VectorHitBuilderAlgorithm.h | 6 ++- .../src/VectorHitBuilderAlgorithm.cc | 40 +++++++------------ .../test/VHs_productionAndTesting.py | 26 ++++++------ .../TrackerRecoGeometryESProducer_cfi.py | 4 +- .../plugins/SeedingOTEDProducer.cc | 29 +++++++------- .../TkSeedingLayers/src/HitExtractorSTRP.cc | 2 +- 8 files changed, 62 insertions(+), 63 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 454464035454b..5a75a770df641 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -40,7 +40,7 @@ class VectorHit final : public BaseTrackerRecHit { const float chi2, OmniClusterRef const& lower, OmniClusterRef const& upper, - const float curvature, + const float curvature, const float curvatureError, const float phi); @@ -49,7 +49,7 @@ class VectorHit final : public BaseTrackerRecHit { const VectorHit2D& vh2Dzy, OmniClusterRef const& lower, OmniClusterRef const& upper, - const float curvature, + const float curvature, const float curvatureError, const float phi); diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 3710a0d10718d..5e5aa727b750b 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -44,7 +44,13 @@ VectorHit::VectorHit(const GeomDet& idet, const float curvature, const float curvatureError, const float phi) - : BaseTrackerRecHit(idet, trackerHitRTTI::vector), theDimension(4), theLowerCluster(lower), theUpperCluster(upper), theCurvature(curvature), theCurvatureError(curvatureError), thePhi(phi) { + : BaseTrackerRecHit(idet, trackerHitRTTI::vector), + theDimension(4), + theLowerCluster(lower), + theUpperCluster(upper), + theCurvature(curvature), + theCurvatureError(curvatureError), + thePhi(phi) { thePosition = LocalPoint(vh2Dzx.localPosition()->x(), vh2Dzy.localPosition()->x(), 0.); theDirection = LocalVector(vh2Dzx.localDirection()->x(), vh2Dzy.localDirection()->x(), 1.); @@ -183,8 +189,10 @@ Global3DVector VectorHit::globalDirection() const { return (det()->surface().toG float VectorHit::theta() const { return globalDirection().theta(); } -float VectorHit::transverseMomentum(float magField) const { return magField * 2.99792458e-3F / theCurvature;} // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, thus using 2.99792458e-3F (precise value from speed of light) -float VectorHit::momentum(float magField) const { return transverseMomentum(magField) / (1. * sin(theta()));} +float VectorHit::transverseMomentum(float magField) const { + return magField * 2.99792458e-3F / theCurvature; +} // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, thus using 2.99792458e-3F (precise value from speed of light) +float VectorHit::momentum(float magField) const { return transverseMomentum(magField) / (1. * sin(theta())); } AlgebraicMatrix VectorHit::projectionMatrix() const { // obsolete (for what tracker is concerned...) interface diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index f6c1e89ab4153..93d1a7c28eac5 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -40,7 +40,11 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { enum curvatureOrPhi { curvatureMode, phiMode }; - std::pair curvatureORphi(curvatureOrPhi curvatureMode, Global3DPoint gPositionLower, Global3DPoint gPositionUpper, GlobalError gErrorLower, GlobalError gErrorUpper ) const; + std::pair curvatureORphi(curvatureOrPhi curvatureMode, + Global3DPoint gPositionLower, + Global3DPoint gPositionUpper, + GlobalError gErrorLower, + GlobalError gErrorUpper) const; class LocalPositionSort { public: diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index fa4de8f46494e..4b1a0a6e31a11 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -320,15 +320,16 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, GlobalError gErrorLower = VectorHit::phase2clusterGlobalPosErr(geomDetLower); GlobalError gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetUpper); - if (gPositionLower.perp() > gPositionUpper.perp()) { - gPositionLower = VectorHit::phase2clusterGlobalPos(geomDetUpper, upper); - gPositionUpper = VectorHit::phase2clusterGlobalPos(geomDetLower, lower); - gErrorLower = VectorHit::phase2clusterGlobalPosErr(geomDetUpper); - gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetLower); + gPositionLower = VectorHit::phase2clusterGlobalPos(geomDetUpper, upper); + gPositionUpper = VectorHit::phase2clusterGlobalPos(geomDetLower, lower); + gErrorLower = VectorHit::phase2clusterGlobalPosErr(geomDetUpper); + gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetLower); } - const float curvature = curvatureORphi(curvatureMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).first; - const float curvatureError = curvatureORphi(curvatureMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).second; + const float curvature = + curvatureORphi(curvatureMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).first; + const float curvatureError = + curvatureORphi(curvatureMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).second; const float phi = curvatureORphi(phiMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).first; VectorHit vh = VectorHit(*stack, vh2Dzx, vh2Dzy, lowerOmni, upperOmni, curvature, curvatureError, phi); @@ -383,7 +384,6 @@ void VectorHitBuilderAlgorithm::fit(float x[2], Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, double& chi2) const { - float slope = 0.; float intercept = 0.; float covss = 0.; @@ -409,26 +409,15 @@ void VectorHitBuilderAlgorithm::fit(float x[2], dir = LocalVector(slope, 0., slopeZ); } -std::pair VectorHitBuilderAlgorithm::curvatureORphi(curvatureOrPhi curvORphi, Global3DPoint gPositionLower, Global3DPoint gPositionUpper, GlobalError gErrorLower, GlobalError gErrorUpper) const { +std::pair VectorHitBuilderAlgorithm::curvatureORphi(curvatureOrPhi curvORphi, + Global3DPoint gPositionLower, + Global3DPoint gPositionUpper, + GlobalError gErrorLower, + GlobalError gErrorUpper) const { float curvature = -999.; float errorCurvature = -999.; float phi = -999.; - //global pos and errors -// Global3DPoint gPositionLower = lowerGlobalPos(); -// Global3DPoint gPositionUpper = upperGlobalPos(); - -// GlobalError gErrorLower = lowerGlobalPosErr(); -// GlobalError gErrorUpper = upperGlobalPosErr(); - - //insert lower and upper in the global sor -// if (gPositionLower.perp() > gPositionUpper.perp()) { -// gPositionLower = upperGlobalPos(); -// gPositionUpper = lowerGlobalPos(); -// gErrorLower = upperGlobalPosErr(); -// gErrorUpper = lowerGlobalPosErr(); -// } - float h1 = gPositionLower.x() * gPositionUpper.y() - gPositionUpper.x() * gPositionLower.y(); //determine sign of curvature @@ -443,7 +432,7 @@ std::pair VectorHitBuilderAlgorithm::curvatureORphi(curvatureOrPhi double signCurv = -copysign(1.0, n3); double phi1 = atan2(gPositionUpper.y() - gPositionLower.y(), gPositionUpper.x() - gPositionLower.x()); - if (h1 != 0) { + if (h1 != 0) { double h2 = 2 * h1; double h2Inf = 1. / (2 * h1); double r12 = pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2); @@ -573,4 +562,3 @@ std::pair VectorHitBuilderAlgorithm::curvatureORphi(curvatureOrPhi } return std::make_pair(0.0, 0.0); } - diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py index 0618b7982446a..10d7b0fdc9191 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py @@ -70,19 +70,19 @@ ) # debug -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring("debugVH_tilted"), - debugModules = cms.untracked.vstring("*"), - categories = cms.untracked.vstring("VectorHitBuilderEDProducer","VectorHitBuilderAlgorithm","VectorHitsBuilderValidation","VectorHitBuilder"), - debugVH_tilted = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), - DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), - default = cms.untracked.PSet(limit = cms.untracked.int32(0)), - VectorHitBuilder = cms.untracked.PSet(limit = cms.untracked.int32(-1)), - VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), - VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), - VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) - ) - ) +#process.MessageLogger = cms.Service("MessageLogger", +# destinations = cms.untracked.vstring("debugVH_tilted"), +# debugModules = cms.untracked.vstring("*"), +# categories = cms.untracked.vstring("VectorHitBuilderEDProducer","VectorHitBuilderAlgorithm","VectorHitsBuilderValidation","VectorHitBuilder"), +# debugVH_tilted = cms.untracked.PSet(threshold = cms.untracked.string("DEBUG"), +# DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), +# default = cms.untracked.PSet(limit = cms.untracked.int32(0)), +# VectorHitBuilder = cms.untracked.PSet(limit = cms.untracked.int32(-1)), +# VectorHitBuilderEDProducer = cms.untracked.PSet(limit = cms.untracked.int32(-1)), +# VectorHitBuilderAlgorithm = cms.untracked.PSet(limit = cms.untracked.int32(-1)), +# VectorHitsBuilderValidation = cms.untracked.PSet(limit = cms.untracked.int32(-1)) +# ) +# ) # Analyzer process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 22d95e29034d3..9a87a93207ed2 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", - usePhase2Stacks = cms.bool(False) + usePhase2Stacks = cms.bool(True) ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 8afbdb9763eff..58d8729ae33c3 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -9,6 +9,7 @@ #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" #include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" +#include "MagneticField/Engine/interface/MagneticField.h" #include "RecoTracker/Record/interface/CkfComponentsRecord.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" @@ -41,7 +42,7 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { static void fillDescriptions(edm::ConfigurationDescriptions&); - std::unique_ptr run(edm::Handle); + TrajectorySeedCollection run(edm::Handle); unsigned int checkLayer(unsigned int iidd); std::vector collectVHsOnLayer(const edmNew::DetSetVector&, unsigned int); void printVHsOnLayer(const edmNew::DetSetVector&, unsigned int); @@ -118,7 +119,6 @@ void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descr } void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { - //auto seedsWithVHs = std::make_unique(); tkTopo_ = &es.getData(topoToken_); @@ -156,16 +156,15 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) seedsWithVHs->shrink_to_fit(); event.put(std::move(seedsWithVHs));*/ //auto seedsWithVHs = std::make_unique<> - event.put(putToken_, run(vhs)); + event.emplace(putToken_, run(vhs)); } -std::unique_ptr SeedingOTEDProducer::run(edm::Handle VHs) { - //TrajectorySeedCollection result; - auto result = std::make_unique(); +TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { + TrajectorySeedCollection result; //check if all the first three layers have VHs - std::vector vhSeedsL1 = collectVHsOnLayer(*(VHs.product()), 1); - std::vector vhSeedsL2 = collectVHsOnLayer(*(VHs.product()), 2); - std::vector vhSeedsL3 = collectVHsOnLayer(*(VHs.product()), 3); + std::vector vhSeedsL1 = collectVHsOnLayer(*VHs.product(), 1); + std::vector vhSeedsL2 = collectVHsOnLayer(*VHs.product(), 2); + std::vector vhSeedsL3 = collectVHsOnLayer(*VHs.product(), 3); if (vhSeedsL1.empty() || vhSeedsL2.empty() || vhSeedsL3.empty()) { return result; } @@ -255,13 +254,13 @@ std::unique_ptr SeedingOTEDProducer::run(edm::Handlepush_back(ts); + result.push_back(ts); } } } } } - result->shrink_to_fit(); + result.shrink_to_fit(); return result; } @@ -274,7 +273,7 @@ unsigned int SeedingOTEDProducer::checkLayer(unsigned int iidd) { return 0; } -std::vector SeedingOTEDProducer::collectVHsOnLayer(const edmNew::DetSetVector& input, +std::vector SeedingOTEDProducer::collectVHsOnLayer(const edmNew::DetSetVector &input, unsigned int layerNumber) { std::vector VHsOnLayer; if (!input.empty()) { @@ -310,7 +309,6 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto // gv transform to local (lv) const Local3DVector lv(vHit.det()->surface().toLocal(gv)); - //FIXME::charge is fine 1 every two times!! GlobalPoint center(0.0, 0.0, 0.0); int charge = 1; @@ -327,8 +325,9 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); // set the error on 1/p - mat[0][0] = - pow(computeInverseMomentumError(vHit, theta, beamSpot_->sigmaZ(), vHit.transverseMomentum(magField_->inTesla(center).z())), 2); + mat[0][0] = pow(computeInverseMomentumError( + vHit, theta, beamSpot_->sigmaZ(), vHit.transverseMomentum(magField_->inTesla(center).z())), + 2); //building tsos LocalTrajectoryError lterr(asSMatrix<5>(mat)); diff --git a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc index f93d4eedc55e7..561a240bb230b 100644 --- a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc +++ b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc @@ -478,7 +478,7 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder if (!ringRange(ring)) continue; for (VectorHitCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); + result.emplace_back(*hit); } } if (skipClusters) From 6b9b4f22fa3643430ef61efe37580771e09055c0 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Thu, 10 Sep 2020 00:34:53 -0500 Subject: [PATCH 060/115] minor updates --- .../SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc | 2 +- .../python/TrackerRecoGeometryESProducer_cfi.py | 4 ++-- RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc | 3 +-- RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 4b1a0a6e31a11..e693d19a5844c 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -58,7 +58,7 @@ void VectorHitBuilderAlgorithm::run(edm::Handle(gd); std::vector vhsInStack_Acc; std::vector vhsInStack_Rej; - const auto vhsInStack_AccRej = buildVectorHits(stackDet, clusters, *it_detLower, *it_detUpper); + const auto& vhsInStack_AccRej = buildVectorHits(stackDet, clusters, *it_detLower, *it_detUpper); //storing accepted and rejected VHs for (const auto& vh : vhsInStack_AccRej) { diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 9a87a93207ed2..22d95e29034d3 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", - usePhase2Stacks = cms.bool(True) + usePhase2Stacks = cms.bool(False) ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 58d8729ae33c3..32c6b78b8b678 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -119,7 +119,6 @@ void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descr } void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { - tkTopo_ = &es.getData(topoToken_); edm::ESHandle measurementTrackerHandle = es.getHandle(measurementTrackerToken_); @@ -273,7 +272,7 @@ unsigned int SeedingOTEDProducer::checkLayer(unsigned int iidd) { return 0; } -std::vector SeedingOTEDProducer::collectVHsOnLayer(const edmNew::DetSetVector &input, +std::vector SeedingOTEDProducer::collectVHsOnLayer(const edmNew::DetSetVector& input, unsigned int layerNumber) { std::vector VHsOnLayer; if (!input.empty()) { diff --git a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc index 561a240bb230b..f93d4eedc55e7 100644 --- a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc +++ b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc @@ -478,7 +478,7 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder if (!ringRange(ring)) continue; for (VectorHitCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) { - result.emplace_back(*hit); + result.emplace_back(*hit); } } if (skipClusters) From 61599bc59a8b0f03b3843ea56a72a145a802838a Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Thu, 10 Sep 2020 10:35:27 -0500 Subject: [PATCH 061/115] cache position in LocalPositionSort --- .../src/VectorHitBuilderAlgorithm.cc | 10 ++++++++++ .../python/TrackerRecoGeometryESProducer_cfi.py | 4 ++-- .../TkDetLayers/src/Phase2OTBarrelRodBuilder.cc | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index e693d19a5844c..994282ca29035 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -5,10 +5,20 @@ bool VectorHitBuilderAlgorithm::LocalPositionSort::operator()(Phase2TrackerCluster1DRef clus1, Phase2TrackerCluster1DRef clus2) const { + static std::map, bool> cache; + + if (cache.find(std::make_pair(clus1, clus2)) != cache.end()) + return cache[std::pair(clus1, clus2)]; + else if (cache.find(std::make_pair(clus2, clus1)) != cache.end()) + return !cache[std::pair(clus1, clus2)]; + const PixelGeomDetUnit* gdu1 = dynamic_cast(geomDet_); auto&& lparams1 = cpe_->localParameters(*clus1, *gdu1); // x, y, z, e2_xx, e2_xy, e2_yy auto&& lparams2 = cpe_->localParameters(*clus2, *gdu1); // x, y, z, e2_xx, e2_xy, e2_yy + + cache[std::make_pair(clus1, clus2)] = lparams1.first.x() < lparams2.first.x(); return lparams1.first.x() < lparams2.first.x(); + ; } void VectorHitBuilderAlgorithm::run(edm::Handle> clusters, diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 22d95e29034d3..9a87a93207ed2 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", - usePhase2Stacks = cms.bool(False) + usePhase2Stacks = cms.bool(True) ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc index 6ac4e8c0248fb..e73c2f45c93fe 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc @@ -8,7 +8,6 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 const TrackerGeometry* theGeomDetGeometry, const bool useBrothers) { vector allGeometricDets = thePhase2OTBarrelRod->components(); - // vector compGeometricDets; LogDebug("TkDetLayers") << "Phase2OTBarrelRodBuilder with #Modules: " << allGeometricDets.size() << std::endl; LogDebug("TkDetLayers") << " useBrothers: " << useBrothers << std::endl; From 18a03b3e66378d74ed53ce4b97ab84a4b703cb93 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Thu, 10 Sep 2020 10:38:08 -0500 Subject: [PATCH 062/115] turn VHs off again --- .../python/TrackerRecoGeometryESProducer_cfi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 9a87a93207ed2..22d95e29034d3 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", - usePhase2Stacks = cms.bool(True) + usePhase2Stacks = cms.bool(False) ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) From 8bf7d15201f2de6b668c72eef3d61a5a5af69c3c Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Mon, 14 Sep 2020 09:55:52 -0500 Subject: [PATCH 063/115] clarify 'sor' and rebase to latest IB --- .../src/VectorHitBuilderAlgorithmBase.cc | 4 ++-- .../SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index 48d2864c7038c..0758bab8e6451 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -31,9 +31,9 @@ double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomD LogTrace("VectorHitsBuilderValidation") << " global vector passing to the origin:" << gV; LocalVector lV = geomDetUnit_low->surface().toLocal(gV); - LogTrace("VectorHitsBuilderValidation") << " local vector passing to the origin (in low sor):" << lV; + LogTrace("VectorHitsBuilderValidation") << " local vector passing to the origin (in the lower detector system of reference):" << lV; LocalVector lV_norm = lV / lV.z(); - LogTrace("VectorHitsBuilderValidation") << " normalized local vector passing to the origin (in low sor):" << lV_norm; + LogTrace("VectorHitsBuilderValidation") << " normalized local vector passing to the origin (in low the lower detector system of reference):" << lV_norm; Global3DPoint gPosClu_upp = geomDetUnit_upp->surface().toGlobal(lPosClu_upp); Local3DPoint lPosClu_uppInLow = geomDetUnit_low->surface().toLocal(gPosClu_upp); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 4195a2a85e149..3515d731c60ef 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -612,13 +612,13 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev //stub width auto&& lparamsUpp = cpe_->localParameters(*vhIt.upperClusterRef().cluster_phase2OT(), *geomDetUnit_upp); - LogTrace("VectorHitsBuilderValidation") << " upper local pos (in its sor):" << lparamsUpp.first; + LogTrace("VectorHitsBuilderValidation") << " upper local pos (in its system of reference):" << lparamsUpp.first; Global3DPoint gparamsUpp = geomDetUnit_upp->surface().toGlobal(lparamsUpp.first); LogTrace("VectorHitsBuilderValidation") << " upper global pos :" << gparamsUpp; Local3DPoint lparamsUppInLow = geomDetUnit_low->surface().toLocal(gparamsUpp); - LogTrace("VectorHitsBuilderValidation") << " upper local pos (in low sor):" << lparamsUppInLow; + LogTrace("VectorHitsBuilderValidation") << " upper local pos (in low system of reference):" << lparamsUppInLow; auto&& lparamsLow = cpe_->localParameters(*vhIt.lowerClusterRef().cluster_phase2OT(), *geomDetUnit_low); - LogTrace("VectorHitsBuilderValidation") << " lower local pos (in its sor):" << lparamsLow.first; + LogTrace("VectorHitsBuilderValidation") << " lower local pos (in its system of reference):" << lparamsLow.first; Global3DPoint gparamsLow = geomDetUnit_low->surface().toGlobal(lparamsLow.first); LogTrace("VectorHitsBuilderValidation") << " lower global pos :" << gparamsLow; From 45ec1f2047d3a71136b74b9dced5cf054841ea67 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Mon, 14 Sep 2020 10:05:31 -0500 Subject: [PATCH 064/115] code format --- .../src/VectorHitBuilderAlgorithmBase.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index 0758bab8e6451..5b78682bcde01 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -31,9 +31,11 @@ double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomD LogTrace("VectorHitsBuilderValidation") << " global vector passing to the origin:" << gV; LocalVector lV = geomDetUnit_low->surface().toLocal(gV); - LogTrace("VectorHitsBuilderValidation") << " local vector passing to the origin (in the lower detector system of reference):" << lV; + LogTrace("VectorHitsBuilderValidation") + << " local vector passing to the origin (in the lower detector system of reference):" << lV; LocalVector lV_norm = lV / lV.z(); - LogTrace("VectorHitsBuilderValidation") << " normalized local vector passing to the origin (in low the lower detector system of reference):" << lV_norm; + LogTrace("VectorHitsBuilderValidation") + << " normalized local vector passing to the origin (in low the lower detector system of reference):" << lV_norm; Global3DPoint gPosClu_upp = geomDetUnit_upp->surface().toGlobal(lPosClu_upp); Local3DPoint lPosClu_uppInLow = geomDetUnit_low->surface().toLocal(gPosClu_upp); From 17a2e02182da8be78be8fac57f12d0119bc00414 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Mon, 14 Sep 2020 10:42:19 -0500 Subject: [PATCH 065/115] fix theDimension usage and add constepr nComponents --- .../TrackerRecHit2D/interface/VectorHit.h | 2 ++ .../TrackerRecHit2D/interface/VectorHit2D.h | 2 +- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 30 +++++++++---------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 5a75a770df641..35140ba1118ff 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -153,6 +153,8 @@ class VectorHit final : public BaseTrackerRecHit { float theCurvature; float theCurvatureError; float thePhi; + + static constexpr int nComponents = 4; }; inline bool operator<(const VectorHit& one, const VectorHit& other) { return (one.chi2() < other.chi2()); } diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index e7fd9bfb6f953..4e378b0ac58aa 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -28,7 +28,7 @@ class VectorHit2D { } const AlgebraicSymMatrix22* covMatrix() const { return &theCovMatrix; } float chi2() const { return theChi2; } - int dimension() const { return 2; } + int dimension() const { return theDimension; } private: LocalPoint thePosition; diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 5e5aa727b750b..651a6d8317df1 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -45,7 +45,7 @@ VectorHit::VectorHit(const GeomDet& idet, const float curvatureError, const float phi) : BaseTrackerRecHit(idet, trackerHitRTTI::vector), - theDimension(4), + theDimension(vh2Dzx.dimension() + vh2Dzy.dimension()), theLowerCluster(lower), theUpperCluster(upper), theCurvature(curvature), @@ -59,7 +59,7 @@ VectorHit::VectorHit(const GeomDet& idet, const AlgebraicSymMatrix22 covMatZX = *vh2Dzx.covMatrix(); const AlgebraicSymMatrix22 covMatZY = *vh2Dzy.covMatrix(); - theCovMatrix = AlgebraicSymMatrix(4); + theCovMatrix = AlgebraicSymMatrix(nComponents); theCovMatrix[0][0] = covMatZX[0][0]; // var(dx/dz) theCovMatrix[1][1] = covMatZY[0][0]; // var(dy/dz) theCovMatrix[2][2] = covMatZX[1][1]; // var(x) @@ -98,35 +98,35 @@ bool VectorHit::sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedI } void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const { - constexpr int four = 4; - AlgebraicVector4& pars = holder.params(); + + AlgebraicVector4& pars = holder.params(); pars[0] = theDirection.x(); pars[1] = theDirection.y(); pars[2] = thePosition.x(); pars[3] = thePosition.y(); - AlgebraicSymMatrix44& errs = holder.errors(); - for (int i = 0; i < four; i++) { - for (int j = 0; j < four; j++) { + AlgebraicSymMatrix44& errs = holder.errors(); + for (int i = 0; i < nComponents; i++) { + for (int j = 0; j < nComponents; j++) { errs(i, j) = theCovMatrix[i][j]; } } - ProjectMatrix& pf = holder.projFunc(); + ProjectMatrix& pf = holder.projFunc(); pf.index[0] = 1; pf.index[1] = 2; pf.index[2] = 3; pf.index[3] = 4; - holder.measuredParams() = AlgebraicVector4(&holder.tsosLocalParameters().At(1), four); - holder.measuredErrors() = holder.tsosLocalErrors().Sub(1, 1); + holder.measuredParams() = AlgebraicVector4(&holder.tsosLocalParameters().At(1), nComponents); + holder.measuredErrors() = holder.tsosLocalErrors().Sub(1, 1); } VectorHit::~VectorHit() {} AlgebraicVector VectorHit::parameters() const { // (dx/dz,dy/dz,x,y) - AlgebraicVector result(4); + AlgebraicVector result(nComponents); result[0] = theDirection.x(); result[1] = theDirection.y(); @@ -196,7 +196,7 @@ float VectorHit::momentum(float magField) const { return transverseMomentum(magF AlgebraicMatrix VectorHit::projectionMatrix() const { // obsolete (for what tracker is concerned...) interface - static const AlgebraicMatrix the4DProjectionMatrix(4, 5, 0); + static const AlgebraicMatrix the4DProjectionMatrix(nComponents, 5, 0); return the4DProjectionMatrix; } @@ -210,9 +210,9 @@ LocalError VectorHit::localDirectionError() const { AlgebraicSymMatrix VectorHit::parametersError() const { //think about a more efficient method - AlgebraicSymMatrix result(4); - for (int i = 0; i < theDimension; i++) { - for (int j = 0; j < theDimension; j++) { + AlgebraicSymMatrix result(nComponents); + for (int i = 0; i < nComponents; i++) { + for (int j = 0; j < nComponents; j++) { result[i][j] = theCovMatrix[i][j]; } } From f149ea2f4f46b86a255665f22e3fcea8546cbc30 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Mon, 14 Sep 2020 12:33:15 -0500 Subject: [PATCH 066/115] Vincenzo's commnets on VectorHitBuilderAlgorirthm --- .../interface/VectorHitBuilderAlgorithm.h | 14 --- .../src/VectorHitBuilderAlgorithm.cc | 88 +++++++------------ .../TrackerRecoGeometryESProducer_cfi.py | 4 +- 3 files changed, 33 insertions(+), 73 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 93d1a7c28eac5..e5f36655cb2f9 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -46,20 +46,6 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { GlobalError gErrorLower, GlobalError gErrorUpper) const; - class LocalPositionSort { - public: - LocalPositionSort(const TrackerGeometry* geometry, - const ClusterParameterEstimator* cpe, - const GeomDet* geomDet) - : geom_(geometry), cpe_(cpe), geomDet_(geomDet) {} - bool operator()(Phase2TrackerCluster1DRef clus1, Phase2TrackerCluster1DRef clus2) const; - - private: - const TrackerGeometry* geom_; - const ClusterParameterEstimator* cpe_; - const GeomDet* geomDet_; - }; - std::vector> buildVectorHits( const StackGeomDet* stack, edm::Handle> clusters, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 994282ca29035..949db88cdb752 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -1,25 +1,9 @@ #include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" +#include "RecoLocalTracker/ClusterParameterEstimator/interface/ClusterParameterEstimator.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/CommonTopologies/interface/PixelTopology.h" #include "DataFormats/TrackerRecHit2D/interface/VectorHit2D.h" -bool VectorHitBuilderAlgorithm::LocalPositionSort::operator()(Phase2TrackerCluster1DRef clus1, - Phase2TrackerCluster1DRef clus2) const { - static std::map, bool> cache; - - if (cache.find(std::make_pair(clus1, clus2)) != cache.end()) - return cache[std::pair(clus1, clus2)]; - else if (cache.find(std::make_pair(clus2, clus1)) != cache.end()) - return !cache[std::pair(clus1, clus2)]; - - const PixelGeomDetUnit* gdu1 = dynamic_cast(geomDet_); - auto&& lparams1 = cpe_->localParameters(*clus1, *gdu1); // x, y, z, e2_xx, e2_xy, e2_yy - auto&& lparams2 = cpe_->localParameters(*clus2, *gdu1); // x, y, z, e2_xx, e2_xy, e2_yy - - cache[std::make_pair(clus1, clus2)] = lparams1.first.x() < lparams2.first.x(); - return lparams1.first.x() < lparams2.first.x(); - ; -} void VectorHitBuilderAlgorithm::run(edm::Handle> clusters, VectorHitCollectionNew& vhAcc, @@ -30,7 +14,6 @@ void VectorHitBuilderAlgorithm::run(edm::Handle* ClustersPhase2Collection = clusters.product(); std::unordered_map> tempVHAcc, tempVHRej; - std::unordered_map>::iterator it_temporary; //loop over the DetSetVector LogDebug("VectorHitBuilderAlgorithm") << "with #clusters : " << ClustersPhase2Collection->size() << std::endl; @@ -42,8 +25,7 @@ void VectorHitBuilderAlgorithm::run(edm::HandlepartnerDetId(detId1); } else if (theTkTopo->isUpper(detId1)) { - upperDetId = detId1; - lowerDetId = theTkTopo->partnerDetId(detId1); + continue; } DetId detIdStack = theTkTopo->stack(detId1); @@ -52,11 +34,6 @@ void VectorHitBuilderAlgorithm::run(edm::Handle skip it "; - continue; - } const GeomDet* gd; const StackGeomDet* stackDet; @@ -149,62 +126,58 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi } else { LogTrace("VectorHitBuilderAlgorithm") << " not compatible, going to the next cluster"; } + //only cache local parameters for upper cluster as we loop over lower clusters only once anyway + std::vector> localParamsUpper; + std::vector localGDUUpper; - std::vector lowerClusters; - for (const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++cil) { - Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo(clusters, cil); - lowerClusters.push_back(clusterLower); - } std::vector upperClusters; for (const_iterator ciu = theUpperDetSet.begin(); ciu != theUpperDetSet.end(); ++ciu) { Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo(clusters, ciu); - upperClusters.push_back(clusterUpper); + const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); + localGDUUpper.push_back(gduUpp); + localParamsUpper.push_back(theCpe->localParameters(*clusterUpper, *gduUpp)); } - - std::sort_heap( - lowerClusters.begin(), lowerClusters.end(), LocalPositionSort(&*theTkGeom, &*theCpe, &*stack->lowerDet())); - std::sort_heap( - upperClusters.begin(), upperClusters.end(), LocalPositionSort(&*theTkGeom, &*theCpe, &*stack->upperDet())); - - for (const auto& cluL : lowerClusters) { + int upperIterator = 0; + for (const_iterator cil = theUpperDetSet.begin(); cil != theUpperDetSet.end(); ++cil) { LogDebug("VectorHitBuilderAlgorithm") << " lower clusters " << std::endl; + Phase2TrackerCluster1DRef cluL = edmNew::makeRefTo(clusters, cil); printCluster(stack->lowerDet(), &*cluL); const PixelGeomDetUnit* gduLow = dynamic_cast(stack->lowerDet()); auto&& lparamsLow = theCpe->localParameters(*cluL, *gduLow); - for (const auto& cluU : upperClusters) { + upperIterator = 0; + for (const_iterator ciu = theUpperDetSet.begin(); ciu != theUpperDetSet.end(); ++ciu) { LogDebug("VectorHitBuilderAlgorithm") << "\t upper clusters " << std::endl; + Phase2TrackerCluster1DRef cluU = edmNew::makeRefTo(clusters, ciu); printCluster(stack->upperDet(), &*cluU); - const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); - auto&& lparamsUpp = theCpe->localParameters(*cluU, *gduUpp); //applying the parallax correction - double pC = computeParallaxCorrection(gduLow, lparamsLow.first, gduUpp, lparamsUpp.first); + double pC = computeParallaxCorrection(gduLow, lparamsLow.first, localGDUUpper[upperIterator], localParamsUpper[upperIterator].first); LogDebug("VectorHitBuilderAlgorithm") << " \t parallax correction:" << pC << std::endl; double lpos_upp_corr = 0.0; double lpos_low_corr = 0.0; - if (lparamsUpp.first.x() > lparamsLow.first.x()) { - if (lparamsUpp.first.x() > 0) { + if (localParamsUpper[upperIterator].first.x() > lparamsLow.first.x()) { + if (localParamsUpper[upperIterator].first.x() > 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() - std::abs(pC); - } else if (lparamsUpp.first.x() < 0) { + lpos_upp_corr = localParamsUpper[upperIterator].first.x() - std::abs(pC); + } else if (localParamsUpper[upperIterator].first.x() < 0) { lpos_low_corr = lparamsLow.first.x() + std::abs(pC); - lpos_upp_corr = lparamsUpp.first.x(); + lpos_upp_corr = localParamsUpper[upperIterator].first.x(); } - } else if (lparamsUpp.first.x() < lparamsLow.first.x()) { - if (lparamsUpp.first.x() > 0) { + } else if (localParamsUpper[upperIterator].first.x() < lparamsLow.first.x()) { + if (localParamsUpper[upperIterator].first.x() > 0) { lpos_low_corr = lparamsLow.first.x() - std::abs(pC); - lpos_upp_corr = lparamsUpp.first.x(); - } else if (lparamsUpp.first.x() < 0) { + lpos_upp_corr = localParamsUpper[upperIterator].first.x(); + } else if (localParamsUpper[upperIterator].first.x() < 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() + std::abs(pC); + lpos_upp_corr = localParamsUpper[upperIterator].first.x() + std::abs(pC); } } else { - if (lparamsUpp.first.x() > 0) { + if (localParamsUpper[upperIterator].first.x() > 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() - std::abs(pC); - } else if (lparamsUpp.first.x() < 0) { + lpos_upp_corr = localParamsUpper[upperIterator].first.x() - std::abs(pC); + } else if (localParamsUpper[upperIterator].first.x() < 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() + std::abs(pC); + lpos_upp_corr = localParamsUpper[upperIterator].first.x() + std::abs(pC); } } @@ -212,7 +185,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi LogDebug("VectorHitBuilderAlgorithm") << " \t local pos lower corrected (x):" << lpos_low_corr << std::endl; //building my tolerance : 10*sigma - double delta = 10.0 * sqrt(lparamsLow.second.xx() + lparamsUpp.second.xx()); + double delta = 10.0 * sqrt(lparamsLow.second.xx() + localParamsUpper[upperIterator].second.xx()); LogDebug("VectorHitBuilderAlgorithm") << " \t delta: " << delta << std::endl; double width = lpos_low_corr - lpos_upp_corr; @@ -250,6 +223,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi VectorHit vh = buildVectorHit(stack, cluL, cluU); result.emplace_back(std::make_pair(vh, false)); } + upperIterator=+1; } } diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 22d95e29034d3..9a87a93207ed2 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", - usePhase2Stacks = cms.bool(False) + usePhase2Stacks = cms.bool(True) ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) From ccc74b6546f25a66b5be8ce839bf5c846706423b Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Mon, 14 Sep 2020 12:42:15 -0500 Subject: [PATCH 067/115] code checks --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 1 - .../src/VectorHitBuilderAlgorithm.cc | 9 ++++----- .../python/TrackerRecoGeometryESProducer_cfi.py | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 651a6d8317df1..9dc9a214479b0 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -98,7 +98,6 @@ bool VectorHit::sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedI } void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const { - AlgebraicVector4& pars = holder.params(); pars[0] = theDirection.x(); pars[1] = theDirection.y(); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 949db88cdb752..a1ac88723aa2b 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -4,7 +4,6 @@ #include "Geometry/CommonTopologies/interface/PixelTopology.h" #include "DataFormats/TrackerRecHit2D/interface/VectorHit2D.h" - void VectorHitBuilderAlgorithm::run(edm::Handle> clusters, VectorHitCollectionNew& vhAcc, VectorHitCollectionNew& vhRej, @@ -25,7 +24,7 @@ void VectorHitBuilderAlgorithm::run(edm::HandlepartnerDetId(detId1); } else if (theTkTopo->isUpper(detId1)) { - continue; + continue; } DetId detIdStack = theTkTopo->stack(detId1); @@ -34,7 +33,6 @@ void VectorHitBuilderAlgorithm::run(edm::Handlefind(lowerDetId); @@ -151,7 +149,8 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi printCluster(stack->upperDet(), &*cluU); //applying the parallax correction - double pC = computeParallaxCorrection(gduLow, lparamsLow.first, localGDUUpper[upperIterator], localParamsUpper[upperIterator].first); + double pC = computeParallaxCorrection( + gduLow, lparamsLow.first, localGDUUpper[upperIterator], localParamsUpper[upperIterator].first); LogDebug("VectorHitBuilderAlgorithm") << " \t parallax correction:" << pC << std::endl; double lpos_upp_corr = 0.0; double lpos_low_corr = 0.0; @@ -223,7 +222,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi VectorHit vh = buildVectorHit(stack, cluL, cluU); result.emplace_back(std::make_pair(vh, false)); } - upperIterator=+1; + upperIterator = +1; } } diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 9a87a93207ed2..22d95e29034d3 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms TrackerRecoGeometryESProducer = cms.ESProducer("TrackerRecoGeometryESProducer", - usePhase2Stacks = cms.bool(True) + usePhase2Stacks = cms.bool(False) ) from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) +trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) From 999d80bc6e94b3d37ae27a6d7e3c635a5b2e88b8 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Mon, 14 Sep 2020 13:30:14 -0500 Subject: [PATCH 068/115] add process modifier to switch on Vector Hits --- Configuration/ProcessModifiers/python/vectorHits_cff.py | 5 +++++ .../python/TrackerRecoGeometryESProducer_cfi.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 Configuration/ProcessModifiers/python/vectorHits_cff.py diff --git a/Configuration/ProcessModifiers/python/vectorHits_cff.py b/Configuration/ProcessModifiers/python/vectorHits_cff.py new file mode 100644 index 0000000000000..13c607fc1c922 --- /dev/null +++ b/Configuration/ProcessModifiers/python/vectorHits_cff.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +# This modifier is for activating Vector Hits reconstruction in the Phase II OT + +vectorHits = cms.Modifier() diff --git a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py index 22d95e29034d3..048fd49b6da54 100644 --- a/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py +++ b/RecoTracker/GeometryESProducer/python/TrackerRecoGeometryESProducer_cfi.py @@ -4,6 +4,6 @@ usePhase2Stacks = cms.bool(False) ) -from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = False) +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) From 92f2c7e390080b173087e9762c532a396a25b23d Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 15 Sep 2020 15:25:51 -0500 Subject: [PATCH 069/115] remove need to run curvatureORPhi 3 times --- .../interface/VectorHitBuilderAlgorithm.h | 5 +---- .../src/VectorHitBuilderAlgorithm.cc | 19 +++++++------------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index e5f36655cb2f9..a24b21ff2df69 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -38,10 +38,7 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { LocalError& errinner, LocalError& errouter) const; - enum curvatureOrPhi { curvatureMode, phiMode }; - - std::pair curvatureORphi(curvatureOrPhi curvatureMode, - Global3DPoint gPositionLower, + std::pair,float> curvatureANDphi(Global3DPoint gPositionLower, Global3DPoint gPositionUpper, GlobalError gErrorLower, GlobalError gErrorUpper) const; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index a1ac88723aa2b..7ed9079b8eb30 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -309,13 +309,9 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, gErrorLower = VectorHit::phase2clusterGlobalPosErr(geomDetUpper); gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetLower); } - const float curvature = - curvatureORphi(curvatureMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).first; - const float curvatureError = - curvatureORphi(curvatureMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).second; - const float phi = curvatureORphi(phiMode, gPositionLower, gPositionUpper, gErrorLower, gErrorUpper).first; - VectorHit vh = VectorHit(*stack, vh2Dzx, vh2Dzy, lowerOmni, upperOmni, curvature, curvatureError, phi); + const auto& curvatureAndPhi = curvatureANDphi(gPositionLower, gPositionUpper, gErrorLower, gErrorUpper); + VectorHit vh = VectorHit(*stack, vh2Dzx, vh2Dzy, lowerOmni, upperOmni, curvatureAndPhi.first.first, curvatureAndPhi.first.second, curvatureAndPhi.second); return vh; } @@ -392,8 +388,7 @@ void VectorHitBuilderAlgorithm::fit(float x[2], dir = LocalVector(slope, 0., slopeZ); } -std::pair VectorHitBuilderAlgorithm::curvatureORphi(curvatureOrPhi curvORphi, - Global3DPoint gPositionLower, +std::pair,float> VectorHitBuilderAlgorithm::curvatureANDphi(Global3DPoint gPositionLower, Global3DPoint gPositionUpper, GlobalError gErrorLower, GlobalError gErrorUpper) const { @@ -535,13 +530,13 @@ std::pair VectorHitBuilderAlgorithm::curvatureORphi(curvatureOrPhi temp[3] * curvatureJacobian[3]; } else { - return std::make_pair(0.0, 0.0); + return std::make_pair(std::make_pair(0.,0.), 0.0); } - switch (curvORphi) { +/* switch (curvORphi) { case curvatureMode: return std::make_pair(curvature, errorCurvature); case phiMode: return std::make_pair(phi, 0.0); - } - return std::make_pair(0.0, 0.0); + }*/ + return std::make_pair(std::make_pair(curvature, errorCurvature), phi); } From 68ea0ce89bd8e17c3dfac69b4cc9fb72797be145 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 15 Sep 2020 20:25:42 -0500 Subject: [PATCH 070/115] put printClusters behind EDM_ML_DEBUG --- .../src/VectorHitBuilderAlgorithm.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 7ed9079b8eb30..53020ff332e68 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -139,15 +139,18 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi for (const_iterator cil = theUpperDetSet.begin(); cil != theUpperDetSet.end(); ++cil) { LogDebug("VectorHitBuilderAlgorithm") << " lower clusters " << std::endl; Phase2TrackerCluster1DRef cluL = edmNew::makeRefTo(clusters, cil); +#ifdef EDM_ML_DEBUG printCluster(stack->lowerDet(), &*cluL); +#endif const PixelGeomDetUnit* gduLow = dynamic_cast(stack->lowerDet()); auto&& lparamsLow = theCpe->localParameters(*cluL, *gduLow); upperIterator = 0; for (const_iterator ciu = theUpperDetSet.begin(); ciu != theUpperDetSet.end(); ++ciu) { LogDebug("VectorHitBuilderAlgorithm") << "\t upper clusters " << std::endl; Phase2TrackerCluster1DRef cluU = edmNew::makeRefTo(clusters, ciu); +#ifdef EDM_ML_DEBUG printCluster(stack->upperDet(), &*cluU); - +#endif //applying the parallax correction double pC = computeParallaxCorrection( gduLow, lparamsLow.first, localGDUUpper[upperIterator], localParamsUpper[upperIterator].first); @@ -233,8 +236,9 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, Phase2TrackerCluster1DRef upper) const { LogTrace("VectorHitBuilderAlgorithm") << "Build VH with: "; - //printCluster(stack->upperDet(),&*upper); - +#ifdef EDM_ML_DEBUG + printCluster(stack->upperDet(),&*upper); +#endif const PixelGeomDetUnit* geomDetLower = static_cast(stack->lowerDet()); const PixelGeomDetUnit* geomDetUpper = static_cast(stack->upperDet()); From ba5e5d40f594a311e907b6d4059db0ebed28e532 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Tue, 15 Sep 2020 20:57:16 -0500 Subject: [PATCH 071/115] add forgotten push_heap --- .../SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 53020ff332e68..b985ea5360e6b 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -49,6 +49,7 @@ void VectorHitBuilderAlgorithm::run(edm::Handle Date: Tue, 15 Sep 2020 23:29:46 -0500 Subject: [PATCH 072/115] code format --- .../interface/VectorHitBuilderAlgorithm.h | 8 +++--- .../src/VectorHitBuilderAlgorithm.cc | 25 ++++++++++++------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index a24b21ff2df69..376382eb04853 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -38,10 +38,10 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { LocalError& errinner, LocalError& errouter) const; - std::pair,float> curvatureANDphi(Global3DPoint gPositionLower, - Global3DPoint gPositionUpper, - GlobalError gErrorLower, - GlobalError gErrorUpper) const; + std::pair, float> curvatureANDphi(Global3DPoint gPositionLower, + Global3DPoint gPositionUpper, + GlobalError gErrorLower, + GlobalError gErrorUpper) const; std::vector> buildVectorHits( const StackGeomDet* stack, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index b985ea5360e6b..1097537b086de 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -49,7 +49,7 @@ void VectorHitBuilderAlgorithm::run(edm::HandleupperDet(),&*upper); + printCluster(stack->upperDet(), &*upper); #endif const PixelGeomDetUnit* geomDetLower = static_cast(stack->lowerDet()); const PixelGeomDetUnit* geomDetUpper = static_cast(stack->upperDet()); @@ -316,7 +316,14 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, } const auto& curvatureAndPhi = curvatureANDphi(gPositionLower, gPositionUpper, gErrorLower, gErrorUpper); - VectorHit vh = VectorHit(*stack, vh2Dzx, vh2Dzy, lowerOmni, upperOmni, curvatureAndPhi.first.first, curvatureAndPhi.first.second, curvatureAndPhi.second); + VectorHit vh = VectorHit(*stack, + vh2Dzx, + vh2Dzy, + lowerOmni, + upperOmni, + curvatureAndPhi.first.first, + curvatureAndPhi.first.second, + curvatureAndPhi.second); return vh; } @@ -393,10 +400,10 @@ void VectorHitBuilderAlgorithm::fit(float x[2], dir = LocalVector(slope, 0., slopeZ); } -std::pair,float> VectorHitBuilderAlgorithm::curvatureANDphi(Global3DPoint gPositionLower, - Global3DPoint gPositionUpper, - GlobalError gErrorLower, - GlobalError gErrorUpper) const { +std::pair, float> VectorHitBuilderAlgorithm::curvatureANDphi(Global3DPoint gPositionLower, + Global3DPoint gPositionUpper, + GlobalError gErrorLower, + GlobalError gErrorUpper) const { float curvature = -999.; float errorCurvature = -999.; float phi = -999.; @@ -535,9 +542,9 @@ std::pair,float> VectorHitBuilderAlgorithm::curvatureAND temp[3] * curvatureJacobian[3]; } else { - return std::make_pair(std::make_pair(0.,0.), 0.0); + return std::make_pair(std::make_pair(0., 0.), 0.0); } -/* switch (curvORphi) { + /* switch (curvORphi) { case curvatureMode: return std::make_pair(curvature, errorCurvature); case phiMode: From 66e765d064c24cb45d8534daf03f09db7cf0e6fd Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 16 Sep 2020 13:36:48 -0500 Subject: [PATCH 073/115] adapt track selection for vector hits --- .../python/HighPtTripletStep_cff.py | 55 +++++++++++++++++++ .../python/LowPtTripletStep_cff.py | 47 ++++++++++++++++ .../python/PixelPairStep_cff.py | 46 ++++++++++++++++ 3 files changed, 148 insertions(+) diff --git a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py index dad46627f08d7..326a45a8d5b18 100644 --- a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py @@ -318,6 +318,59 @@ ] #end of vpset ) #end of clone +highPtTripletStepSelector_vectorHits = RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.multiTrackSelector.clone( + src = 'highPtTripletStepTracks', + trackSelectors = [ + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.looseMTS.clone( + name = 'highPtTripletStepLoose', + chi2n_par = 2.0, + res_par = ( 0.003, 0.002 ), + minNumberLayers = 3, + maxNumberLostLayers = 3, + minNumber3DLayers = 3, + d0_par1 = ( 0.7, 4.0 ), + dz_par1 = ( 0.8, 4.0 ), + d0_par2 = ( 0.6, 4.0 ), + dz_par2 = ( 0.6, 4.0 ) + ), #end of pset + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.tightMTS.clone( + name = 'highPtTripletStepTight', + preFilterName = 'highPtTripletStepLoose', + chi2n_par = 1.0, + res_par = ( 0.003, 0.002 ), + minNumberLayers = 3, + maxNumberLostLayers = 2, + minNumber3DLayers = 3, + d0_par1 = ( 0.6, 4.0 ), + dz_par1 = ( 0.7, 4.0 ), + d0_par2 = ( 0.5, 4.0 ), + dz_par2 = ( 0.6, 4.0 ) + ), + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.highpurityMTS.clone( + name = 'highPtTripletStep', + preFilterName = 'highPtTripletStepTight', + min_eta = -4.1, + max_eta = 4.1, + chi2n_par = 0.8, + res_par = ( 0.003, 0.001 ), + min_nhits = 4, + minNumberLayers = 3, + maxNumberLostLayers = 2, + minNumber3DLayers = 3, + d0_par1 = ( 0.5, 4.0 ), + dz_par1 = ( 0.6, 4.0 ), + d0_par2 = ( 0.45, 4.0 ), + dz_par2 = ( 0.55, 4.0 ) + ), + ] #end of vpset +) #en + + +#vectorHits.toModify(highPtTripletStepSelector, minNumberLayers = 3) +#vectorHits.toModify(highPtTripletStepSelector, minNumber3DLayers = 3) +#vectorHits.toModify(highPtTripletStepSelector, d0_par1 = ( 0.5, 4.0 )) +#vectorHits.toModify(highPtTripletStepSelector, dz_par1 = ( 0.6, 4.0 )) + # Final sequence HighPtTripletStepTask = cms.Task(highPtTripletStepClusters, highPtTripletStepSeedLayers, @@ -335,6 +388,8 @@ _HighPtTripletStep_Phase2PU140 = cms.Sequence(_HighPtTripletStepTask_Phase2PU140) trackingPhase2PU140.toReplaceWith(HighPtTripletStepTask, _HighPtTripletStepTask_Phase2PU140) +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toReplaceWith(highPtTripletStepSelector, highPtTripletStepSelector_vectorHits) # fast tracking mask producer from FastSimulation.Tracking.FastTrackerRecHitMaskProducer_cfi import maskProducerFromClusterRemover highPtTripletStepMasks = maskProducerFromClusterRemover(highPtTripletStepClusters) diff --git a/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py index fdd1f29f75afe..0f1d9aeb10c12 100644 --- a/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py @@ -362,6 +362,53 @@ ), #end of vpset ) #end of clone +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toModify(lowPtTripletStepSelector, + trackSelectors= cms.VPSet( + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.looseMTS.clone( + name = 'lowPtTripletStepLoose', + chi2n_par = 1.2, + res_par = ( 0.003, 0.002 ), + minNumberLayers = 3, + maxNumberLostLayers = 2, + minNumber3DLayers = 3, + d0_par1 = ( 0.7, 4.0 ), + dz_par1 = ( 0.7, 4.0 ), + d0_par2 = ( 0.6, 4.0 ), + dz_par2 = ( 0.6, 4.0 ) + ), #end of pset + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.tightMTS.clone( + name = 'lowPtTripletStepTight', + preFilterName = 'lowPtTripletStepLoose', + chi2n_par = 0.7, + res_par = ( 0.003, 0.002 ), + minNumberLayers = 3, + maxNumberLostLayers = 2, + minNumber3DLayers = 3, + d0_par1 = ( 0.6, 4.0 ), + dz_par1 = ( 0.6, 4.0 ), + d0_par2 = ( 0.5, 4.0 ), + dz_par2 = ( 0.5, 4.0 ) + ), + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.highpurityMTS.clone( + name = 'lowPtTripletStep', + preFilterName = 'lowPtTripletStepTight', + min_eta = -4.0, + max_eta = 4.0, + chi2n_par = 0.4, + res_par = ( 0.003, 0.001 ), + min_nhits = 3, + minNumberLayers = 3, + maxNumberLostLayers = 2, + minNumber3DLayers = 3, + d0_par1 = ( 0.5, 4.0 ), + dz_par1 = ( 0.5, 4.0 ), + d0_par2 = ( 0.45, 4.0 ), + dz_par2 = ( 0.45, 4.0 ) + ), + ), #end of vpset +) #end of clone + # Final sequence diff --git a/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py b/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py index bdca6fd4af1e7..9570c259b6b6a 100644 --- a/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py @@ -419,6 +419,52 @@ vertices = 'firstStepPrimaryVertices' ) #end of clone +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toModify(pixelPairStepSelector, + trackSelectors = cms.VPSet( + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.looseMTS.clone( + name = 'pixelPairStepLoose', + chi2n_par = 0.7, + res_par = ( 0.003, 0.002 ), + minNumberLayers = 3, + maxNumberLostLayers = 2, + minNumber3DLayers = 3, + d0_par1 = ( 0.4, 4.0 ), + dz_par1 = ( 0.4, 4.0 ), + d0_par2 = ( 0.6, 4.0 ), + dz_par2 = ( 0.45, 4.0 ) + ), #end of pset + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.tightMTS.clone( + name = 'pixelPairStepTight', + preFilterName = 'pixelPairStepLoose', + chi2n_par = 0.6, + res_par = ( 0.003, 0.002 ), + minNumberLayers = 4, + maxNumberLostLayers = 2, + minNumber3DLayers = 3, + d0_par1 = ( 0.35, 4.0 ), + dz_par1 = ( 0.35, 4.0 ), + d0_par2 = ( 0.5, 4.0 ), + dz_par2 = ( 0.4, 4.0 ) + ), + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.highpurityMTS.clone( + name = 'pixelPairStep', + preFilterName = 'pixelPairStepTight', +# min_eta = -4.0, # useless, the eta distribution does not even reach |eta| = 3 (!) +# max_eta = 4.0, + chi2n_par = 0.5, + res_par = ( 0.003, 0.001 ), + minNumberLayers = 4, + maxNumberLostLayers = 2, + minNumber3DLayers = 3, + d0_par1 = ( 0.3, 4.0 ), + dz_par1 = ( 0.3, 4.0 ), + d0_par2 = ( 0.45, 4.0 ), + dz_par2 = ( 0.35, 4.0 ) + ), + ), #end of vpset + vertices = 'firstStepPrimaryVertices' +) #end of clone # Final sequence PixelPairStepTask = cms.Task(pixelPairStepClusters, From c3357eba33dd46809d405564aa73077631874c57 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 16 Sep 2020 16:17:07 -0500 Subject: [PATCH 074/115] add pixelLess iteration for vectorHits process modifier --- .../python/earlyGeneralTracks_cfi.py | 26 ++++ .../python/PixelLessStep_cff.py | 127 +++++++++++++++++- .../python/iterativeTkConfig.py | 2 + 3 files changed, 154 insertions(+), 1 deletion(-) diff --git a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py index 6ab340983ab9c..b0ac555769792 100644 --- a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py +++ b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py @@ -101,3 +101,29 @@ makeReKeyedSeeds = cms.untracked.bool(False) ) ) +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toReplaceWith(earlyGeneralTracks, _trackListMerger.clone( + TrackProducers =['initialStepTracks', + 'highPtTripletStepTracks', + 'lowPtQuadStepTracks', + 'lowPtTripletStepTracks', + 'detachedQuadStepTracks', + 'pixelPairStepTracks', + 'pixelLessStepTracks', + ], + hasSelector = [1,1,1,1,1,1,1], + indivShareFrac = [1.0,0.16,0.095,0.09,0.09,0.09,0.095], + selectedTrackQuals = ['initialStepSelector:initialStep', + 'highPtTripletStepSelector:highPtTripletStep', + 'lowPtQuadStepSelector:lowPtQuadStep', + 'lowPtTripletStepSelector:lowPtTripletStep', + 'detachedQuadStep', + 'pixelPairStepSelector:pixelPairStep', + 'pixelLessStepSelector:pixelLessStep', + ], + setsToMerge = cms.VPSet( cms.PSet( tLists=cms.vint32(0,1,2,3,4,5,6), pQual=cms.bool(True) ) + ), + copyExtras = True, + makeReKeyedSeeds = cms.untracked.bool(False) + ) +) diff --git a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py index 4180e142dd8ff..2272535b4cf28 100644 --- a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py @@ -104,7 +104,34 @@ MTID = None, MTEC = None, ) - +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toModify(pixelLessStepSeedLayers, + layerList = [ + 'TOB1+TOB2', 'TOB2+TOB3', +# 'TOB3+TOB4', 'TOB4+TOB5', + 'TID1_pos+TID2_pos', 'TID1_neg+TID2_neg' + ], + TOB = cms.PSet( + TTRHBuilder = cms.string('WithTrackAngle'), + clusterChargeCut = cms.PSet(refToPSet_ = cms.string('SiStripClusterChargeCutNone')), + vectorRecHits = cms.InputTag("siPhase2VectorHits", 'vectorHitsAccepted'), + skipClusters = cms.InputTag('pixelLessStepClusters') + ), + TIB = None, + TID = cms.PSet( + TTRHBuilder = cms.string('WithTrackAngle'), + clusterChargeCut = cms.PSet(refToPSet_ = cms.string('SiStripClusterChargeCutNone')), + vectorRecHits = cms.InputTag("siPhase2VectorHits", 'vectorHitsAccepted'), + skipClusters = cms.InputTag('pixelLessStepClusters'), + useRingSlector = cms.bool(True), + minRing = cms.int32(1), + maxRing = cms.int32(8) + ), + TEC = None, + MTIB = None, + MTID = None, + MTEC = None, +) # TrackingRegion from RecoTracker.TkTrackingRegions.globalTrackingRegionFromBeamSpotFixedZ_cfi import globalTrackingRegionFromBeamSpotFixedZ as _globalTrackingRegionFromBeamSpotFixedZ pixelLessStepTrackingRegions = _globalTrackingRegionFromBeamSpotFixedZ.clone(RegionPSet = dict( @@ -194,6 +221,28 @@ )) fastSim.toReplaceWith(pixelLessStepSeeds,_fastSim_pixelLessStepSeeds) +vectorHits.toModify(pixelLessStepHitDoublets, produceSeedingHitSets=True, produceIntermediateHitDoublets=False) +vectorHits.toModify(pixelLessStepSeeds, + seedingHitSets = "pixelLessStepHitDoublets", + SeedComparitorPSet = cms.PSet( + ClusterShapeCacheSrc = cms.InputTag("siPixelClusterShapeCache"), + ClusterShapeHitFilterName = cms.string('ClusterShapeHitFilter'), + ComponentName = cms.string('PixelClusterShapeSeedComparitor'), + FilterAtHelixStage = cms.bool(False), + FilterPixelHits = cms.bool(False), + FilterStripHits = cms.bool(False), +# comparitors = cms.VPSet(cms.PSet( +# ClusterShapeCacheSrc = cms.InputTag("siPixelClusterShapeCache"), +# ClusterShapeHitFilterName = cms.string('pixelLessStepClusterShapeHitFilter'), +# ComponentName = cms.string('PixelClusterShapeSeedComparitor'), +# FilterAtHelixStage = cms.bool(False), +# FilterPixelHits = cms.bool(False), +# FilterStripHits = cms.bool(False) +# ), +# ) + ) +) + # QUALITY CUTS DURING TRACK BUILDING import TrackingTools.TrajectoryFiltering.TrajectoryFilter_cff _pixelLessStepTrajectoryFilterBase = TrackingTools.TrajectoryFiltering.TrajectoryFilter_cff.CkfBaseTrajectoryFilter_block.clone( @@ -208,6 +257,9 @@ for e in [pp_on_XeXe_2017, pp_on_AA_2018]: e.toModify(pixelLessStepTrajectoryFilter, minPt=2.0) +vectorHits.toReplaceWith(pixelLessStepTrajectoryFilter, _pixelLessStepTrajectoryFilterBase) +vectorHits.toModify(pixelLessStepTrajectoryFilter, minimumNumberOfHits = 4, maxLostHits = 1) + import RecoTracker.MeasurementDet.Chi2ChargeMeasurementEstimator_cfi pixelLessStepChi2Est = RecoTracker.MeasurementDet.Chi2ChargeMeasurementEstimator_cfi.Chi2ChargeMeasurementEstimator.clone( ComponentName = 'pixelLessStepChi2Est', @@ -219,6 +271,11 @@ clusterChargeCut = dict(refToPSet_ = 'SiStripClusterChargeCutTiny') ) +vectorHits.toModify(pixelLessStepChi2Est, + clusterChargeCut = dict(refToPSet_ = 'SiStripClusterChargeCutNone'), + MaxChi2 = cms.double(30.0) +) + # TRACK BUILDING import RecoTracker.CkfPattern.GroupedCkfTrajectoryBuilder_cfi pixelLessStepTrajectoryBuilder = RecoTracker.CkfPattern.GroupedCkfTrajectoryBuilder_cfi.GroupedCkfTrajectoryBuilder.clone( @@ -252,6 +309,11 @@ ) ) +vectorHits.toModify(pixelLessStepTrackCandidates, + phase2clustersToSkip = cms.InputTag('pixelLessStepClusters'), + clustersToSkip = None +) + from TrackingTools.TrajectoryCleaning.TrajectoryCleanerBySharedHits_cfi import trajectoryCleanerBySharedHits pixelLessStepTrajectoryCleanerBySharedHits = trajectoryCleanerBySharedHits.clone( ComponentName = 'pixelLessStepTrajectoryCleanerBySharedHits', @@ -358,6 +420,55 @@ vertices = 'pixelVertices'#end of vpset ) #end of clone +vectorHits.toModify(pixelLessStepSelector, + GBRForestLabel = None, + useAnyMVA = None, + trackSelectors= cms.VPSet( + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.looseMTS.clone( + name = 'pixelLessStepLoose', + chi2n_par = 1.0, + res_par = ( 0.003, 0.001 ), + minNumberLayers = 0, + maxNumberLostLayers = 1, + minNumber3DLayers = 0, + d0_par1 = ( 0.9, 4.0 ), + dz_par1 = ( 0.9, 4.0 ), + d0_par2 = ( 1.0, 4.0 ), + dz_par2 = ( 1.0, 4.0 ) + ), + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.tightMTS.clone( + name = 'pixelLessStepTight', + preFilterName = 'pixelLessStepLoose', + chi2n_par = 0.35, + res_par = ( 0.003, 0.001 ), + minNumberLayers = 4, + maxNumberLostLayers = 0, + minNumber3DLayers = 3, + d0_par1 = ( 1.1, 4.0 ), + dz_par1 = ( 1.1, 4.0 ), + d0_par2 = ( 1.1, 4.0 ), + dz_par2 = ( 1.1, 4.0 ) + ), + RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.highpurityMTS.clone( + name = 'QualityMasks', + preFilterName = 'pixelLessStepTight', + chi2n_par = 0.2, + res_par = ( 0.003, 0.001 ), + minNumberLayers = 1, + maxNumberLostLayers = 2, + minNumber3DLayers = 0, + d0_par1 = ( 100., 4.0 ), + dz_par1 = ( 100., 4.0 ), + d0_par2 = ( 100., 4.0 ), + dz_par2 = ( 100., 4.0 ) + ), + ), + vertices = 'firstStepPrimaryVertices' +) + +vectorHits.toModify(pixelLessStepSelector.trackSelectors[2], name = 'pixelLessStep') + + PixelLessStepTask = cms.Task(pixelLessStepClusters, pixelLessStepSeedLayers, pixelLessStepTrackingRegions, @@ -386,3 +497,17 @@ ,pixelLessStep ) ) +from RecoLocalTracker.SiPhase2VectorHitBuilder.siPhase2VectorHits_cfi import * +_PixelLessStepTask_vectorHits = cms.Task(siPhase2VectorHits, + pixelLessStepClusters, + pixelLessStepSeedLayers, + pixelLessStepTrackingRegions, + pixelLessStepHitDoublets, + pixelLessStepHitTriplets, + pixelLessStepSeeds, + pixelLessStepTrackCandidates, + pixelLessStepTracks, + pixelLessStepSelector) +_PixelLessStep_vectorHits = cms.Sequence(_PixelLessStepTask_vectorHits) +vectorHits.toReplaceWith(PixelLessStepTask, _PixelLessStepTask_vectorHits) +vectorHits.toReplaceWith(PixelLessStep, _PixelLessStep_vectorHits) diff --git a/RecoTracker/IterativeTracking/python/iterativeTkConfig.py b/RecoTracker/IterativeTracking/python/iterativeTkConfig.py index a34b00031488e..0f187dcf4184b 100644 --- a/RecoTracker/IterativeTracking/python/iterativeTkConfig.py +++ b/RecoTracker/IterativeTracking/python/iterativeTkConfig.py @@ -56,6 +56,8 @@ "DetachedQuadStep", "PixelPairStep", ] +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toModify(_iterations_trackingPhase2PU140, func=lambda x: x.append('PixelLessStep')) _iterations_muonSeeded = [ "MuonSeededStepInOut", "MuonSeededStepOutIn", From e9b6828514fc32e3a64a87660ed5f923e40c0b50 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 16 Sep 2020 18:54:55 -0500 Subject: [PATCH 075/115] add special workflows to test vector hits --- .../python/upgradeWorkflowComponents.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 348256ce9258b..6ca34a2531afd 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -298,6 +298,24 @@ def condition_(self, fragment, stepList, key, hasHarvest): '--procModifiers': 'trackingMkFit' } +# Vector Hits workflows +class UpgradeWorkflow_vectorHits(UpgradeWorkflow): + def setup_(self, step, stepName, stepDict, k, properties): + stepDict[stepName][k] = merge([{'--procModifiers': 'vectorHits'}, stepDict[step][k]]) + def condition(self, fragment, stepList, key, hasHarvest): + return fragment=="TTbar_14TeV" and '2026' in key +upgradeWFs['vectorHits'] = UpgradeWorkflow_vectorHits( + steps = [ + 'Reco', + ], + PU = [ + 'Reco', + ], + suffix = '_vectorHits', + offset = 0.9, +) + + # Patatrack workflows class UpgradeWorkflowPatatrack(UpgradeWorkflow): def condition(self, fragment, stepList, key, hasHarvest): From 580200d7dc6b27117649c3d11034e58780ff526f Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 16 Sep 2020 19:05:57 -0500 Subject: [PATCH 076/115] some cleanup --- .../IterativeTracking/python/HighPtTripletStep_cff.py | 6 ------ .../IterativeTracking/python/PixelLessStep_cff.py | 9 --------- 2 files changed, 15 deletions(-) diff --git a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py index 326a45a8d5b18..867a57fde8806 100644 --- a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py @@ -366,11 +366,6 @@ ) #en -#vectorHits.toModify(highPtTripletStepSelector, minNumberLayers = 3) -#vectorHits.toModify(highPtTripletStepSelector, minNumber3DLayers = 3) -#vectorHits.toModify(highPtTripletStepSelector, d0_par1 = ( 0.5, 4.0 )) -#vectorHits.toModify(highPtTripletStepSelector, dz_par1 = ( 0.6, 4.0 )) - # Final sequence HighPtTripletStepTask = cms.Task(highPtTripletStepClusters, highPtTripletStepSeedLayers, @@ -380,7 +375,6 @@ highPtTripletStepSeeds, highPtTripletStepTrackCandidates, highPtTripletStepTracks, -# highPtTripletStepClassifier1,highPtTripletStepClassifier2,highPtTripletStepClassifier3* highPtTripletStep) HighPtTripletStep = cms.Sequence(HighPtTripletStepTask) _HighPtTripletStepTask_Phase2PU140 = HighPtTripletStepTask.copy() diff --git a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py index 2272535b4cf28..37c1276b64c44 100644 --- a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py @@ -231,15 +231,6 @@ FilterAtHelixStage = cms.bool(False), FilterPixelHits = cms.bool(False), FilterStripHits = cms.bool(False), -# comparitors = cms.VPSet(cms.PSet( -# ClusterShapeCacheSrc = cms.InputTag("siPixelClusterShapeCache"), -# ClusterShapeHitFilterName = cms.string('pixelLessStepClusterShapeHitFilter'), -# ComponentName = cms.string('PixelClusterShapeSeedComparitor'), -# FilterAtHelixStage = cms.bool(False), -# FilterPixelHits = cms.bool(False), -# FilterStripHits = cms.bool(False) -# ), -# ) ) ) From 16e51bb1ca8db60423c50a74b85f159dc8ed2e95 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Wed, 16 Sep 2020 20:59:59 -0500 Subject: [PATCH 077/115] add wf 23234.9 to those available for PR validation --- Configuration/PyReleaseValidation/python/relval_2026.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Configuration/PyReleaseValidation/python/relval_2026.py b/Configuration/PyReleaseValidation/python/relval_2026.py index e023aaf2653d8..3d753c1ea6c79 100644 --- a/Configuration/PyReleaseValidation/python/relval_2026.py +++ b/Configuration/PyReleaseValidation/python/relval_2026.py @@ -19,6 +19,7 @@ numWFIB.extend([23434.99,23434.999]) #2026D49 premixing combined stage1+stage2 (ttbar+PU200, ttbar+PU50 for PR test) numWFIB.extend([23234.21,23434.21]) #2026D49 prodlike, prodlike PU numWFIB.extend([23234.103]) #2026D49 aging +numWFIB.extend([23234.9]) #2026D49 vector hits numWFIB.extend([28234.0]) #2026D60 numWFIB.extend([29834.0]) #2026D64 numWFIB.extend([30234.0]) #2026D65 From cfd6018cb0213f01ed116e8083ad92d3d321c148 Mon Sep 17 00:00:00 2001 From: JanFSchulte Date: Mon, 21 Sep 2020 13:09:53 -0500 Subject: [PATCH 078/115] add removed newline --- .../GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc index 5242ff422eef2..04f9f7fba6026 100644 --- a/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc +++ b/RecoTracker/GeometryESProducer/plugins/TrackerRecoGeometryESProducer.cc @@ -46,6 +46,7 @@ TrackerRecoGeometryESProducer::TrackerRecoGeometryESProducer(const edm::Paramete tTopToken_ = c.consumes(); geomToken_ = c.consumes(edm::ESInputTag("", p.getUntrackedParameter("trackerGeometryLabel"))); } + std::unique_ptr TrackerRecoGeometryESProducer::produce( const TrackerRecoGeometryRecord &iRecord) { TrackerGeometry const &tG = iRecord.get(geomToken_); From 74cf64c15e09058cf5a9aae55013e19836168ed0 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Tue, 22 Sep 2020 20:29:39 +0200 Subject: [PATCH 079/115] use seedingOT producer in pixelLess step --- .../IterativeTracking/python/PixelLessStep_cff.py | 14 ++++++++++---- .../TkSeedGenerator/plugins/SeedingOTEDProducer.cc | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py index 37c1276b64c44..359931be8c6cd 100644 --- a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py @@ -489,16 +489,22 @@ ) ) from RecoLocalTracker.SiPhase2VectorHitBuilder.siPhase2VectorHits_cfi import * +from RecoTracker.TkSeedGenerator.SeedingOTEDProducer_cfi import SeedingOTEDProducer as _SeedingOTEDProducer +pixelLessStepSeeds_vectorHits = _SeedingOTEDProducer.clone() + +#siPhase2VectorHits.Clusters = cms.string("pixelLessStepClusters") + _PixelLessStepTask_vectorHits = cms.Task(siPhase2VectorHits, pixelLessStepClusters, - pixelLessStepSeedLayers, - pixelLessStepTrackingRegions, - pixelLessStepHitDoublets, - pixelLessStepHitTriplets, + #pixelLessStepSeedLayers, + #pixelLessStepTrackingRegions, + #pixelLessStepHitDoublets, + #pixelLessStepHitTriplets, pixelLessStepSeeds, pixelLessStepTrackCandidates, pixelLessStepTracks, pixelLessStepSelector) _PixelLessStep_vectorHits = cms.Sequence(_PixelLessStepTask_vectorHits) +vectorHits.toReplaceWith(pixelLessStepSeeds,pixelLessStepSeeds_vectorHits) vectorHits.toReplaceWith(PixelLessStepTask, _PixelLessStepTask_vectorHits) vectorHits.toReplaceWith(PixelLessStep, _PixelLessStep_vectorHits) diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 32c6b78b8b678..392039375e749 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -260,6 +260,7 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle Date: Tue, 22 Sep 2020 20:29:57 +0200 Subject: [PATCH 080/115] bug fixes --- .../src/VectorHitBuilderAlgorithm.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 1097537b086de..12369a604c48d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -137,7 +137,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi localParamsUpper.push_back(theCpe->localParameters(*clusterUpper, *gduUpp)); } int upperIterator = 0; - for (const_iterator cil = theUpperDetSet.begin(); cil != theUpperDetSet.end(); ++cil) { + for (const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++cil) { LogDebug("VectorHitBuilderAlgorithm") << " lower clusters " << std::endl; Phase2TrackerCluster1DRef cluL = edmNew::makeRefTo(clusters, cil); #ifdef EDM_ML_DEBUG @@ -342,9 +342,9 @@ void VectorHitBuilderAlgorithm::fit2Dzx(const Local3DPoint lpCI, float y[2] = {lpCI.x(), lpCO.x()}; float sqCI = sqrt(leCI.xx()); float sqCO = sqrt(leCO.xx()); - float sigy[2] = {sqCI, sqCO}; + float sigy2[2] = {sqCI*sqCI, sqCO*sqCO}; - fit(x, y, sigy, pos, dir, covMatrix, chi2); + fit(x, y, sigy2, pos, dir, covMatrix, chi2); return; } @@ -361,16 +361,16 @@ void VectorHitBuilderAlgorithm::fit2Dzy(const Local3DPoint lpCI, float y[2] = {lpCI.y(), lpCO.y()}; float sqCI = sqrt(leCI.yy()); float sqCO = sqrt(leCO.yy()); - float sigy[2] = {sqCI, sqCO}; + float sigy2[2] = {sqCI*sqCI, sqCO*sqCO}; - fit(x, y, sigy, pos, dir, covMatrix, chi2); + fit(x, y, sigy2, pos, dir, covMatrix, chi2); return; } void VectorHitBuilderAlgorithm::fit(float x[2], float y[2], - float sigy[2], + float sigy2[2], Local3DPoint& pos, Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, @@ -382,7 +382,7 @@ void VectorHitBuilderAlgorithm::fit(float x[2], float covsi = 0.; //theFitter->linearFit(x, y, 2, sigy, slope, intercept, covss, covii, covsi); - linearFit(x, y, 2, sigy, slope, intercept, covss, covii, covsi); + linearFit(x, y, 2, sigy2, slope, intercept, covss, covii, covsi); covMatrix[0][0] = covss; // this is var(dy/dz) covMatrix[1][1] = covii; // this is var(y) @@ -390,7 +390,7 @@ void VectorHitBuilderAlgorithm::fit(float x[2], for (unsigned int j = 0; j < 2; j++) { const double ypred = intercept + slope * x[j]; - const double dy = (y[j] - ypred) / sigy[j]; + const double dy = (y[j] - ypred) / sqrt(sigy2[j]); chi2 += dy * dy; } From ec1a12e1ca10b2a5fd39df2b14673b80e9e4425b Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Tue, 22 Sep 2020 20:40:12 +0200 Subject: [PATCH 081/115] code checks --- .../SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 12369a604c48d..8864c7e03613d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -342,7 +342,7 @@ void VectorHitBuilderAlgorithm::fit2Dzx(const Local3DPoint lpCI, float y[2] = {lpCI.x(), lpCO.x()}; float sqCI = sqrt(leCI.xx()); float sqCO = sqrt(leCO.xx()); - float sigy2[2] = {sqCI*sqCI, sqCO*sqCO}; + float sigy2[2] = {sqCI * sqCI, sqCO * sqCO}; fit(x, y, sigy2, pos, dir, covMatrix, chi2); @@ -361,7 +361,7 @@ void VectorHitBuilderAlgorithm::fit2Dzy(const Local3DPoint lpCI, float y[2] = {lpCI.y(), lpCO.y()}; float sqCI = sqrt(leCI.yy()); float sqCO = sqrt(leCO.yy()); - float sigy2[2] = {sqCI*sqCI, sqCO*sqCO}; + float sigy2[2] = {sqCI * sqCI, sqCO * sqCO}; fit(x, y, sigy2, pos, dir, covMatrix, chi2); From 2c876398ee155984bb225fec2ed1ec6d515f35ad Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Tue, 22 Sep 2020 20:44:23 +0200 Subject: [PATCH 082/115] cleanup --- RecoTracker/IterativeTracking/python/PixelLessStep_cff.py | 6 ------ RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc | 1 - 2 files changed, 7 deletions(-) diff --git a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py index 359931be8c6cd..de2e3fb74a343 100644 --- a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py @@ -492,14 +492,8 @@ from RecoTracker.TkSeedGenerator.SeedingOTEDProducer_cfi import SeedingOTEDProducer as _SeedingOTEDProducer pixelLessStepSeeds_vectorHits = _SeedingOTEDProducer.clone() -#siPhase2VectorHits.Clusters = cms.string("pixelLessStepClusters") - _PixelLessStepTask_vectorHits = cms.Task(siPhase2VectorHits, pixelLessStepClusters, - #pixelLessStepSeedLayers, - #pixelLessStepTrackingRegions, - #pixelLessStepHitDoublets, - #pixelLessStepHitTriplets, pixelLessStepSeeds, pixelLessStepTrackCandidates, pixelLessStepTracks, diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 392039375e749..32c6b78b8b678 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -260,7 +260,6 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle Date: Wed, 23 Sep 2020 16:32:51 +0200 Subject: [PATCH 083/115] fix bug in incrementing loop counter --- .../SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 8864c7e03613d..8c37b6ae1e90d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -226,7 +226,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi VectorHit vh = buildVectorHit(stack, cluL, cluU); result.emplace_back(std::make_pair(vh, false)); } - upperIterator = +1; + upperIterator += 1; } } From 9ac1ebe7dfc2f84e861db43e117cd5e39c5deaa0 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Fri, 25 Sep 2020 00:51:06 +0200 Subject: [PATCH 084/115] use pre-created VectorHits in track building --- .../interface/MeasurementTracker.h | 1 + .../interface/MeasurementTrackerEvent.h | 5 ++++ .../MeasurementTrackerEventProducer.cc | 27 ++++++++++++++++++- .../plugins/MeasurementTrackerEventProducer.h | 2 ++ .../plugins/MeasurementTrackerImpl.cc | 20 +++++++------- .../plugins/MeasurementTrackerImpl.h | 4 +-- .../plugins/TkStackMeasurementDet.cc | 24 ++++++++++++++--- .../plugins/TkStackMeasurementDet.h | 4 ++- .../MeasurementTrackerEventProducer_cfi.py | 5 +++- .../src/MeasurementTrackerEvent.cc | 6 +++++ 10 files changed, 79 insertions(+), 19 deletions(-) diff --git a/RecoTracker/MeasurementDet/interface/MeasurementTracker.h b/RecoTracker/MeasurementDet/interface/MeasurementTracker.h index 8da9362f58258..f1cf8e59780bb 100644 --- a/RecoTracker/MeasurementDet/interface/MeasurementTracker.h +++ b/RecoTracker/MeasurementDet/interface/MeasurementTracker.h @@ -4,6 +4,7 @@ #include "TrackingTools/MeasurementDet/interface/MeasurementDetSystem.h" #include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h" #include "FWCore/Framework/interface/Event.h" diff --git a/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h b/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h index c65203dba5624..ab5214206e9a2 100644 --- a/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h +++ b/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h @@ -8,6 +8,7 @@ class Phase2OTMeasurementDetSet; #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h" #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "DataFormats/Common/interface/ContainerMask.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" @@ -25,6 +26,7 @@ class MeasurementTrackerEvent { const StMeasurementDetSet *strips, const PxMeasurementDetSet *pixels, const Phase2OTMeasurementDetSet *phase2OT, + const VectorHitCollectionNew *phase2OTVectorHits, const std::vector &stripClustersToSkip, const std::vector &pixelClustersToSkip, const std::vector &phase2OTClustersToSkip) @@ -32,6 +34,7 @@ class MeasurementTrackerEvent { theStripData(strips), thePixelData(pixels), thePhase2OTData(phase2OT), + thePhase2OTVectorHits(phase2OTVectorHits), theOwner(true), theStripClustersToSkip(stripClustersToSkip), thePixelClustersToSkip(pixelClustersToSkip), @@ -57,6 +60,7 @@ class MeasurementTrackerEvent { const StMeasurementDetSet &stripData() const { return *theStripData; } const PxMeasurementDetSet &pixelData() const { return *thePixelData; } const Phase2OTMeasurementDetSet &phase2OTData() const { return *thePhase2OTData; } + const VectorHitCollectionNew &phase2OTVectorHits() const { return *thePhase2OTVectorHits; } const std::vector &stripClustersToSkip() const { return theStripClustersToSkip; } const std::vector &pixelClustersToSkip() const { return thePixelClustersToSkip; } const std::vector &phase2OTClustersToSkip() const { return thePhase2OTClustersToSkip; } @@ -73,6 +77,7 @@ class MeasurementTrackerEvent { const StMeasurementDetSet *theStripData = nullptr; const PxMeasurementDetSet *thePixelData = nullptr; const Phase2OTMeasurementDetSet *thePhase2OTData = nullptr; + const VectorHitCollectionNew *thePhase2OTVectorHits = nullptr; bool theOwner = false; // do I own the tree above? // these could be const pointers as well, but ContainerMask doesn't expose the vector std::vector theStripClustersToSkip; diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc index 364f91ee33896..f2d98ea16aedf 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc @@ -60,6 +60,11 @@ MeasurementTrackerEventProducer::MeasurementTrackerEventProducer(const edm::Para edm::InputTag(iConfig.getParameter("Phase2TrackerCluster1DProducer"))); isPhase2 = true; } + if (!(iConfig.getParameter("vectorHits") == edm::InputTag(""))) { + thePh2OTVectorHitsLabel = consumes(iConfig.getParameter("vectorHits")); + isPhase2 = true; + useVectorHits = true; + } produces(); } @@ -72,6 +77,7 @@ void MeasurementTrackerEventProducer::fillDescriptions(edm::ConfigurationDescrip desc.add("pixelClusterProducer", "siPixelClusters"); desc.add("stripClusterProducer", "siStripClusters"); desc.add("Phase2TrackerCluster1DProducer", ""); + desc.add("vectorHits",edm::InputTag("")); desc.add>("inactivePixelDetectorLabels", std::vector{{edm::InputTag("siPixelDigis")}}) @@ -97,6 +103,7 @@ void MeasurementTrackerEventProducer::produce(edm::Event& iEvent, const edm::Eve auto stripData = std::make_unique(measurementTracker->stripDetConditions()); auto pixelData = std::make_unique(measurementTracker->pixelDetConditions()); auto phase2OTData = std::make_unique(measurementTracker->phase2DetConditions()); + std::vector stripClustersToSkip; std::vector pixelClustersToSkip; std::vector phase2ClustersToSkip; @@ -112,13 +119,31 @@ void MeasurementTrackerEventProducer::produce(edm::Event& iEvent, const edm::Eve // put into MTE // put into event - iEvent.put(std::make_unique(*measurementTracker, + + edm::Handle vectorHitsHandle; + if (useVectorHits) { + const VectorHitCollectionNew* phase2OTVectorHits = vectorHitsHandle.product(); + + iEvent.put(std::make_unique(*measurementTracker, stripData.release(), pixelData.release(), phase2OTData.release(), + phase2OTVectorHits, stripClustersToSkip, pixelClustersToSkip, phase2ClustersToSkip)); + } + else{ + + iEvent.put(std::make_unique(*measurementTracker, + stripData.release(), + pixelData.release(), + phase2OTData.release(), + nullptr, + stripClustersToSkip, + pixelClustersToSkip, + phase2ClustersToSkip)); + } } void MeasurementTrackerEventProducer::updatePixels(const edm::Event& event, diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h index c502477a8e3d8..ef16e4659a06c 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h @@ -40,6 +40,7 @@ class dso_hidden MeasurementTrackerEventProducer final : public edm::stream::EDP edm::EDGetTokenT> thePixelClusterLabel; edm::EDGetTokenT> theStripClusterLabel; edm::EDGetTokenT> thePh2OTClusterLabel; + edm::EDGetTokenT thePh2OTVectorHitsLabel; edm::EDGetTokenT>> thePixelClusterMask; edm::EDGetTokenT>> theStripClusterMask; @@ -51,6 +52,7 @@ class dso_hidden MeasurementTrackerEventProducer final : public edm::stream::EDP bool selfUpdateSkipClusters_; bool switchOffPixelsIfEmpty_; bool isPhase2; + bool useVectorHits; }; #endif diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index 337082baf5e7d..2ee029d9e17b1 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -111,13 +111,13 @@ void MeasurementTrackerImpl::initialize(const TrackerTopology* trackerTopology) if (!theTrackerGeom->detsPXB().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsPXB().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsPXB(), subIsPixel, subIsOT); + addDets(theTrackerGeom->detsPXB(), subIsPixel, subIsOT, trackerTopology); } if (!theTrackerGeom->detsPXF().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsPXF().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsPXF(), subIsPixel, subIsOT); + addDets(theTrackerGeom->detsPXF(), subIsPixel, subIsOT, trackerTopology); } subIsOT = true; @@ -125,25 +125,25 @@ void MeasurementTrackerImpl::initialize(const TrackerTopology* trackerTopology) if (!theTrackerGeom->detsTIB().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTIB().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsTIB(), subIsPixel, subIsOT); + addDets(theTrackerGeom->detsTIB(), subIsPixel, subIsOT, trackerTopology); } if (!theTrackerGeom->detsTID().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTID().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsTID(), subIsPixel, subIsOT); + addDets(theTrackerGeom->detsTID(), subIsPixel, subIsOT, trackerTopology); } if (!theTrackerGeom->detsTOB().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTOB().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsTOB(), subIsPixel, subIsOT); + addDets(theTrackerGeom->detsTOB(), subIsPixel, subIsOT, trackerTopology); } if (!theTrackerGeom->detsTEC().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTEC().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsTEC(), subIsPixel, subIsOT); + addDets(theTrackerGeom->detsTEC(), subIsPixel, subIsOT, trackerTopology); } // fist all stripdets @@ -217,7 +217,7 @@ void MeasurementTrackerImpl::initPhase2OTMeasurementConditionSet(std::vector(*gd); @@ -244,7 +244,7 @@ void MeasurementTrackerImpl::addDets(const TrackingGeometry::DetContainer& dets, if (gluedDet != nullptr) addGluedDet(gluedDet); else - addStackDet(stackDet); + addStackDet(stackDet,trackerTopology); } } } @@ -283,10 +283,10 @@ void MeasurementTrackerImpl::addGluedDet(const GluedGeomDet* gd) { theGluedDets.push_back(TkGluedMeasurementDet(gd, theStDetConditions.matcher(), theStDetConditions.stripCPE())); } -void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd) { +void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd, const TrackerTopology* trackerTopology) { //since the Stack will be composed by PS or 2S, //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. - theStackDets.push_back(TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE())); + theStackDets.push_back(TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE(),trackerTopology)); } void MeasurementTrackerImpl::initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology) { diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h index 69c6a0e97d5ba..da44026df0c75 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h @@ -132,12 +132,12 @@ class dso_hidden MeasurementTrackerImpl final : public MeasurementTracker { void addPhase2Det(const GeomDet* gd); void addGluedDet(const GluedGeomDet* gd); - void addStackDet(const StackGeomDet* gd); + void addStackDet(const StackGeomDet* gd, const TrackerTopology* trackerTopology); void initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology); void initStackDet(TkStackMeasurementDet& det); - void addDets(const TrackingGeometry::DetContainer& dets, bool subIsPixel, bool subIsOT); + void addDets(const TrackingGeometry::DetContainer& dets, bool subIsPixel, bool subIsOT, const TrackerTopology* trackerTopology); bool checkDets(); diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index 176211395063c..6186dacf5a9b7 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -7,8 +7,9 @@ using namespace std; TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet, const VectorHitBuilderAlgorithm* matcher, - const PixelClusterParameterEstimator* cpe) - : MeasurementDet(gdet), theMatcher(matcher), thePixelCPE(cpe), theLowerDet(nullptr), theUpperDet(nullptr) {} + const PixelClusterParameterEstimator* cpe, + const TrackerTopology* tkTopo) + : MeasurementDet(gdet), theMatcher(matcher), thePixelCPE(cpe), theTkTopo(tkTopo), theLowerDet(nullptr), theUpperDet(nullptr) {} void TkStackMeasurementDet::init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet) { theLowerDet = dynamic_cast(lowerDet); @@ -27,13 +28,13 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj HitCollectorForRecHits collector( &fastGeomDet(), theMatcher, theCPE, result ); collectRecHits(ts, collector); */ - if (isEmpty(data.phase2OTData())) + if (data.phase2OTVectorHits().size() == 0) return result; LogTrace("MeasurementTracker") << " is not empty"; if (!isActive(data)) return result; LogTrace("MeasurementTracker") << " and is active"; - +/* const Phase2TrackerCluster1D* begin = nullptr; if (!data.phase2OTData().handle()->data().empty()) { begin = &(data.phase2OTData().handle()->data().front()); @@ -77,7 +78,22 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj } } } + + +*/ + //unsigned int rawDetId1(lowerDet()->index()); + //DetId detId1(rawDetId1); + //DetId detIdStack = theTkTopo->stack(detId1); + //DetId detIdStack = theTkTopo->stack(specificGeomDet().geographicalId()); + DetId detIdStack = specificGeomDet().geographicalId(); + + //std::cout << "ID of current stack " << detIdStack << std::endl; + auto iterator = data.phase2OTVectorHits().find(detIdStack); + if (iterator == data.phase2OTVectorHits().end()) return result; + for (auto& vecHit : data.phase2OTVectorHits()[detIdStack]) + result.push_back(std::make_shared(vecHit)); + //std::cout << result.size() << std::endl; return result; } diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index a5bbfde36414f..f675ff3a7f9ff 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -16,7 +16,8 @@ class TkStackMeasurementDet final : public MeasurementDet { public: TkStackMeasurementDet(const StackGeomDet* gdet, const VectorHitBuilderAlgorithm* matcher, - const PixelClusterParameterEstimator* cpe); + const PixelClusterParameterEstimator* cpe, + const TrackerTopology* tkTopo); void init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet); RecHitContainer recHits(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent& data) const override; @@ -51,6 +52,7 @@ class TkStackMeasurementDet final : public MeasurementDet { private: const VectorHitBuilderAlgorithm* theMatcher; const PixelClusterParameterEstimator* thePixelCPE; + const TrackerTopology* theTkTopo; const TkPhase2OTMeasurementDet* theLowerDet; const TkPhase2OTMeasurementDet* theUpperDet; }; diff --git a/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py b/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py index 6442eb1de605a..d4431bbfa3662 100644 --- a/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py +++ b/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py @@ -23,7 +23,10 @@ inactiveStripDetectorLabels = cms.VInputTag(), switchOffPixelsIfEmpty = False ) - +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toModify(MeasurementTrackerEvent, + vectorHits = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), +) MeasurementTrackerEventPreSplitting = MeasurementTrackerEvent.clone( pixelClusterProducer = 'siPixelClustersPreSplitting' diff --git a/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc b/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc index 274a2f62cfbde..a3431fcee0dc7 100644 --- a/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc +++ b/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc @@ -10,6 +10,8 @@ MeasurementTrackerEvent::~MeasurementTrackerEvent() { thePixelData = nullptr; // to double-delete the same object (!!!) delete thePhase2OTData; thePhase2OTData = nullptr; // to double-delete the same object (!!!) +// delete thePhase2OTVectorHits; +// thePhase2OTVectorHits = nullptr; // to double-delete the same object (!!!) } } @@ -18,6 +20,7 @@ MeasurementTrackerEvent::MeasurementTrackerEvent(MeasurementTrackerEvent &&other theStripData = other.theStripData; thePixelData = other.thePixelData; thePhase2OTData = other.thePhase2OTData; + thePhase2OTVectorHits = other.thePhase2OTVectorHits; theOwner = other.theOwner; other.theOwner = false; // make sure to fully transfer the ownership theStripClustersToSkip = std::move(other.theStripClustersToSkip); @@ -28,6 +31,7 @@ MeasurementTrackerEvent &MeasurementTrackerEvent::operator=(MeasurementTrackerEv theStripData = other.theStripData; thePixelData = other.thePixelData; thePhase2OTData = other.thePhase2OTData; + thePhase2OTVectorHits = other.thePhase2OTVectorHits; theOwner = other.theOwner; other.theOwner = false; // make sure to fully transfer the ownership theStripClustersToSkip = std::move(other.theStripClustersToSkip); @@ -43,6 +47,7 @@ MeasurementTrackerEvent::MeasurementTrackerEvent( theStripData(trackerEvent.theStripData), thePixelData(trackerEvent.thePixelData), thePhase2OTData(nullptr), + thePhase2OTVectorHits(nullptr), theOwner(false) { //std::cout << "Creatign non-owned MT @ " << this << " from @ " << & trackerEvent << " (strip data @ " << trackerEvent.theStripData << ")" << std::endl; if (stripClustersToSkip.refProd().id() != theStripData->handle().id()) { @@ -77,6 +82,7 @@ MeasurementTrackerEvent::MeasurementTrackerEvent( theStripData(nullptr), thePixelData(trackerEvent.thePixelData), thePhase2OTData(trackerEvent.thePhase2OTData), + thePhase2OTVectorHits(trackerEvent.thePhase2OTVectorHits), theOwner(false) { if (pixelClustersToSkip.refProd().id() != thePixelData->handle().id()) { edm::LogError("ProductIdMismatch") << "The pixel masking does not point to the proper collection of clusters: " From 03f94959dba8a7fed7160efbef43ec39d3465a1d Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Fri, 25 Sep 2020 01:40:20 +0200 Subject: [PATCH 085/115] code checks and format --- .../MeasurementTrackerEventProducer.cc | 40 +++++++++---------- .../plugins/MeasurementTrackerImpl.cc | 10 +++-- .../plugins/MeasurementTrackerImpl.h | 5 ++- .../plugins/TkStackMeasurementDet.cc | 31 ++++++++------ .../plugins/TkStackMeasurementDet.h | 2 +- .../src/MeasurementTrackerEvent.cc | 4 +- 6 files changed, 51 insertions(+), 41 deletions(-) diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc index f2d98ea16aedf..ed9dcfb9553d4 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc @@ -77,7 +77,7 @@ void MeasurementTrackerEventProducer::fillDescriptions(edm::ConfigurationDescrip desc.add("pixelClusterProducer", "siPixelClusters"); desc.add("stripClusterProducer", "siStripClusters"); desc.add("Phase2TrackerCluster1DProducer", ""); - desc.add("vectorHits",edm::InputTag("")); + desc.add("vectorHits", edm::InputTag("")); desc.add>("inactivePixelDetectorLabels", std::vector{{edm::InputTag("siPixelDigis")}}) @@ -122,27 +122,25 @@ void MeasurementTrackerEventProducer::produce(edm::Event& iEvent, const edm::Eve edm::Handle vectorHitsHandle; if (useVectorHits) { - const VectorHitCollectionNew* phase2OTVectorHits = vectorHitsHandle.product(); - - iEvent.put(std::make_unique(*measurementTracker, - stripData.release(), - pixelData.release(), - phase2OTData.release(), - phase2OTVectorHits, - stripClustersToSkip, - pixelClustersToSkip, - phase2ClustersToSkip)); - } - else{ - + iEvent.getByToken(thePh2OTVectorHitsLabel, vectorHitsHandle); + const VectorHitCollectionNew* phase2OTVectorHits = vectorHitsHandle.product(); + iEvent.put(std::make_unique(*measurementTracker, + stripData.release(), + pixelData.release(), + phase2OTData.release(), + phase2OTVectorHits, + stripClustersToSkip, + pixelClustersToSkip, + phase2ClustersToSkip)); + } else { iEvent.put(std::make_unique(*measurementTracker, - stripData.release(), - pixelData.release(), - phase2OTData.release(), - nullptr, - stripClustersToSkip, - pixelClustersToSkip, - phase2ClustersToSkip)); + stripData.release(), + pixelData.release(), + phase2OTData.release(), + nullptr, + stripClustersToSkip, + pixelClustersToSkip, + phase2ClustersToSkip)); } } diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index 2ee029d9e17b1..8030097d49a11 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -217,7 +217,10 @@ void MeasurementTrackerImpl::initPhase2OTMeasurementConditionSet(std::vector(*gd); @@ -244,7 +247,7 @@ void MeasurementTrackerImpl::addDets(const TrackingGeometry::DetContainer& dets, if (gluedDet != nullptr) addGluedDet(gluedDet); else - addStackDet(stackDet,trackerTopology); + addStackDet(stackDet, trackerTopology); } } } @@ -286,7 +289,8 @@ void MeasurementTrackerImpl::addGluedDet(const GluedGeomDet* gd) { void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd, const TrackerTopology* trackerTopology) { //since the Stack will be composed by PS or 2S, //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. - theStackDets.push_back(TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE(),trackerTopology)); + theStackDets.push_back( + TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE(), trackerTopology)); } void MeasurementTrackerImpl::initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology) { diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h index da44026df0c75..0cd595a08a3fc 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h @@ -137,7 +137,10 @@ class dso_hidden MeasurementTrackerImpl final : public MeasurementTracker { void initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology); void initStackDet(TkStackMeasurementDet& det); - void addDets(const TrackingGeometry::DetContainer& dets, bool subIsPixel, bool subIsOT, const TrackerTopology* trackerTopology); + void addDets(const TrackingGeometry::DetContainer& dets, + bool subIsPixel, + bool subIsOT, + const TrackerTopology* trackerTopology); bool checkDets(); diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index 6186dacf5a9b7..01e633a5c576f 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -8,8 +8,13 @@ using namespace std; TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet, const VectorHitBuilderAlgorithm* matcher, const PixelClusterParameterEstimator* cpe, - const TrackerTopology* tkTopo) - : MeasurementDet(gdet), theMatcher(matcher), thePixelCPE(cpe), theTkTopo(tkTopo), theLowerDet(nullptr), theUpperDet(nullptr) {} + const TrackerTopology* tkTopo) + : MeasurementDet(gdet), + theMatcher(matcher), + thePixelCPE(cpe), + theTkTopo(tkTopo), + theLowerDet(nullptr), + theUpperDet(nullptr) {} void TkStackMeasurementDet::init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet) { theLowerDet = dynamic_cast(lowerDet); @@ -28,13 +33,13 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj HitCollectorForRecHits collector( &fastGeomDet(), theMatcher, theCPE, result ); collectRecHits(ts, collector); */ - if (data.phase2OTVectorHits().size() == 0) + if (data.phase2OTVectorHits().empty()) return result; LogTrace("MeasurementTracker") << " is not empty"; if (!isActive(data)) return result; LogTrace("MeasurementTracker") << " and is active"; -/* + /* const Phase2TrackerCluster1D* begin = nullptr; if (!data.phase2OTData().handle()->data().empty()) { begin = &(data.phase2OTData().handle()->data().front()); @@ -82,18 +87,18 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj */ - //unsigned int rawDetId1(lowerDet()->index()); - //DetId detId1(rawDetId1); - //DetId detIdStack = theTkTopo->stack(detId1); - //DetId detIdStack = theTkTopo->stack(specificGeomDet().geographicalId()); - DetId detIdStack = specificGeomDet().geographicalId(); + //unsigned int rawDetId1(lowerDet()->index()); + //DetId detId1(rawDetId1); + //DetId detIdStack = theTkTopo->stack(detId1); + //DetId detIdStack = theTkTopo->stack(specificGeomDet().geographicalId()); + DetId detIdStack = specificGeomDet().geographicalId(); //std::cout << "ID of current stack " << detIdStack << std::endl; - auto iterator = data.phase2OTVectorHits().find(detIdStack); - if (iterator == data.phase2OTVectorHits().end()) return result; + auto iterator = data.phase2OTVectorHits().find(detIdStack); + if (iterator == data.phase2OTVectorHits().end()) + return result; for (auto& vecHit : data.phase2OTVectorHits()[detIdStack]) - result.push_back(std::make_shared(vecHit)); - //std::cout << result.size() << std::endl; + result.push_back(std::make_shared(vecHit)); return result; } diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index f675ff3a7f9ff..a04f613751bf6 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -17,7 +17,7 @@ class TkStackMeasurementDet final : public MeasurementDet { TkStackMeasurementDet(const StackGeomDet* gdet, const VectorHitBuilderAlgorithm* matcher, const PixelClusterParameterEstimator* cpe, - const TrackerTopology* tkTopo); + const TrackerTopology* tkTopo); void init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet); RecHitContainer recHits(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent& data) const override; diff --git a/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc b/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc index a3431fcee0dc7..d4b438630a58a 100644 --- a/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc +++ b/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc @@ -10,8 +10,8 @@ MeasurementTrackerEvent::~MeasurementTrackerEvent() { thePixelData = nullptr; // to double-delete the same object (!!!) delete thePhase2OTData; thePhase2OTData = nullptr; // to double-delete the same object (!!!) -// delete thePhase2OTVectorHits; -// thePhase2OTVectorHits = nullptr; // to double-delete the same object (!!!) + // delete thePhase2OTVectorHits; + // thePhase2OTVectorHits = nullptr; // to double-delete the same object (!!!) } } From 5c42b055d65519e73bea57f41abe0ea56b82605c Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Fri, 25 Sep 2020 16:08:41 +0200 Subject: [PATCH 086/115] some cleanup --- .../interface/MeasurementTracker.h | 1 - .../plugins/MeasurementTrackerImpl.cc | 23 ++++++++----------- .../plugins/MeasurementTrackerImpl.h | 7 ++---- .../plugins/TkStackMeasurementDet.cc | 22 ++++-------------- .../plugins/TkStackMeasurementDet.h | 4 +--- .../src/MeasurementTrackerEvent.cc | 2 -- .../plugins/SeedingOTEDProducer.cc | 8 ------- 7 files changed, 18 insertions(+), 49 deletions(-) diff --git a/RecoTracker/MeasurementDet/interface/MeasurementTracker.h b/RecoTracker/MeasurementDet/interface/MeasurementTracker.h index f1cf8e59780bb..8da9362f58258 100644 --- a/RecoTracker/MeasurementDet/interface/MeasurementTracker.h +++ b/RecoTracker/MeasurementDet/interface/MeasurementTracker.h @@ -4,7 +4,6 @@ #include "TrackingTools/MeasurementDet/interface/MeasurementDetSystem.h" #include "DataFormats/DetId/interface/DetId.h" -#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h" #include "FWCore/Framework/interface/Event.h" diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index 8030097d49a11..a530bbe78d21f 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -111,13 +111,13 @@ void MeasurementTrackerImpl::initialize(const TrackerTopology* trackerTopology) if (!theTrackerGeom->detsPXB().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsPXB().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsPXB(), subIsPixel, subIsOT, trackerTopology); + addDets(theTrackerGeom->detsPXB(), subIsPixel, subIsOT); } if (!theTrackerGeom->detsPXF().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsPXF().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsPXF(), subIsPixel, subIsOT, trackerTopology); + addDets(theTrackerGeom->detsPXF(), subIsPixel, subIsOT); } subIsOT = true; @@ -125,25 +125,25 @@ void MeasurementTrackerImpl::initialize(const TrackerTopology* trackerTopology) if (!theTrackerGeom->detsTIB().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTIB().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsTIB(), subIsPixel, subIsOT, trackerTopology); + addDets(theTrackerGeom->detsTIB(), subIsPixel, subIsOT); } if (!theTrackerGeom->detsTID().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTID().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsTID(), subIsPixel, subIsOT, trackerTopology); + addDets(theTrackerGeom->detsTID(), subIsPixel, subIsOT); } if (!theTrackerGeom->detsTOB().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTOB().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsTOB(), subIsPixel, subIsOT, trackerTopology); + addDets(theTrackerGeom->detsTOB(), subIsPixel, subIsOT); } if (!theTrackerGeom->detsTEC().empty()) { subIsPixel = GeomDetEnumerators::isTrackerPixel( theTrackerGeom->geomDetSubDetector(theTrackerGeom->detsTEC().front()->geographicalId().subdetId())); - addDets(theTrackerGeom->detsTEC(), subIsPixel, subIsOT, trackerTopology); + addDets(theTrackerGeom->detsTEC(), subIsPixel, subIsOT); } // fist all stripdets @@ -217,10 +217,7 @@ void MeasurementTrackerImpl::initPhase2OTMeasurementConditionSet(std::vector(*gd); @@ -247,7 +244,7 @@ void MeasurementTrackerImpl::addDets(const TrackingGeometry::DetContainer& dets, if (gluedDet != nullptr) addGluedDet(gluedDet); else - addStackDet(stackDet, trackerTopology); + addStackDet(stackDet); } } } @@ -286,11 +283,11 @@ void MeasurementTrackerImpl::addGluedDet(const GluedGeomDet* gd) { theGluedDets.push_back(TkGluedMeasurementDet(gd, theStDetConditions.matcher(), theStDetConditions.stripCPE())); } -void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd, const TrackerTopology* trackerTopology) { +void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd) { //since the Stack will be composed by PS or 2S, //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. theStackDets.push_back( - TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE(), trackerTopology)); + TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE())); } void MeasurementTrackerImpl::initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology) { diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h index 0cd595a08a3fc..69c6a0e97d5ba 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h @@ -132,15 +132,12 @@ class dso_hidden MeasurementTrackerImpl final : public MeasurementTracker { void addPhase2Det(const GeomDet* gd); void addGluedDet(const GluedGeomDet* gd); - void addStackDet(const StackGeomDet* gd, const TrackerTopology* trackerTopology); + void addStackDet(const StackGeomDet* gd); void initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology); void initStackDet(TkStackMeasurementDet& det); - void addDets(const TrackingGeometry::DetContainer& dets, - bool subIsPixel, - bool subIsOT, - const TrackerTopology* trackerTopology); + void addDets(const TrackingGeometry::DetContainer& dets, bool subIsPixel, bool subIsOT); bool checkDets(); diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index 01e633a5c576f..09857880467b2 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -7,14 +7,8 @@ using namespace std; TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet, const VectorHitBuilderAlgorithm* matcher, - const PixelClusterParameterEstimator* cpe, - const TrackerTopology* tkTopo) - : MeasurementDet(gdet), - theMatcher(matcher), - thePixelCPE(cpe), - theTkTopo(tkTopo), - theLowerDet(nullptr), - theUpperDet(nullptr) {} + const PixelClusterParameterEstimator* cpe) + : MeasurementDet(gdet), theMatcher(matcher), thePixelCPE(cpe), theLowerDet(nullptr), theUpperDet(nullptr) {} void TkStackMeasurementDet::init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet) { theLowerDet = dynamic_cast(lowerDet); @@ -29,16 +23,15 @@ void TkStackMeasurementDet::init(const MeasurementDet* lowerDet, const Measureme TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const TrajectoryStateOnSurface& ts, const MeasurementTrackerEvent& data) const { RecHitContainer result; - /* - HitCollectorForRecHits collector( &fastGeomDet(), theMatcher, theCPE, result ); - collectRecHits(ts, collector); -*/ + if (data.phase2OTVectorHits().empty()) return result; LogTrace("MeasurementTracker") << " is not empty"; if (!isActive(data)) return result; LogTrace("MeasurementTracker") << " and is active"; + + // Old solution creating the VHs on the fly. Keep for now /* const Phase2TrackerCluster1D* begin = nullptr; if (!data.phase2OTData().handle()->data().empty()) { @@ -87,13 +80,8 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj */ - //unsigned int rawDetId1(lowerDet()->index()); - //DetId detId1(rawDetId1); - //DetId detIdStack = theTkTopo->stack(detId1); - //DetId detIdStack = theTkTopo->stack(specificGeomDet().geographicalId()); DetId detIdStack = specificGeomDet().geographicalId(); - //std::cout << "ID of current stack " << detIdStack << std::endl; auto iterator = data.phase2OTVectorHits().find(detIdStack); if (iterator == data.phase2OTVectorHits().end()) return result; diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index a04f613751bf6..a5bbfde36414f 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -16,8 +16,7 @@ class TkStackMeasurementDet final : public MeasurementDet { public: TkStackMeasurementDet(const StackGeomDet* gdet, const VectorHitBuilderAlgorithm* matcher, - const PixelClusterParameterEstimator* cpe, - const TrackerTopology* tkTopo); + const PixelClusterParameterEstimator* cpe); void init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet); RecHitContainer recHits(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent& data) const override; @@ -52,7 +51,6 @@ class TkStackMeasurementDet final : public MeasurementDet { private: const VectorHitBuilderAlgorithm* theMatcher; const PixelClusterParameterEstimator* thePixelCPE; - const TrackerTopology* theTkTopo; const TkPhase2OTMeasurementDet* theLowerDet; const TkPhase2OTMeasurementDet* theUpperDet; }; diff --git a/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc b/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc index d4b438630a58a..fe2a1d361c85c 100644 --- a/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc +++ b/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc @@ -10,8 +10,6 @@ MeasurementTrackerEvent::~MeasurementTrackerEvent() { thePixelData = nullptr; // to double-delete the same object (!!!) delete thePhase2OTData; thePhase2OTData = nullptr; // to double-delete the same object (!!!) - // delete thePhase2OTVectorHits; - // thePhase2OTVectorHits = nullptr; // to double-delete the same object (!!!) } } diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 32c6b78b8b678..e4846baf28ba2 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -147,14 +147,6 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) edm::Handle vhs; event.getByToken(vhProducerToken_, vhs); - /* TrajectorySeedCollection const& tempSeeds = run(vhs); - for (auto& qIt : tempSeeds) { - seedsWithVHs->push_back(qIt); - } - - seedsWithVHs->shrink_to_fit(); - event.put(std::move(seedsWithVHs));*/ - //auto seedsWithVHs = std::make_unique<> event.emplace(putToken_, run(vhs)); } From 867caf24a96de12e5a8ac2b1bba9f94dd7d02e61 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Fri, 25 Sep 2020 19:54:09 +0200 Subject: [PATCH 087/115] code comments from Kevin + Matti and implementation of cluster masking --- .../MeasurementTrackerEventProducer.cc | 28 +++-------- .../plugins/MeasurementTrackerEventProducer.h | 4 +- .../plugins/TkStackMeasurementDet.cc | 50 +++++++++++++++++-- 3 files changed, 57 insertions(+), 25 deletions(-) diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc index ed9dcfb9553d4..54bdf53581abf 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc @@ -39,7 +39,7 @@ MeasurementTrackerEventProducer::MeasurementTrackerEventProducer(const edm::Para edm::InputTag skip = iConfig.getParameter("skipClusters"); selfUpdateSkipClusters_ = !(skip == edm::InputTag("")); LogDebug("MeasurementTracker") << "skipping clusters: " << selfUpdateSkipClusters_; - isPhase2 = false; + isPhase2_ = false; if (!iConfig.getParameter("stripClusterProducer").empty()) { theStripClusterLabel = consumes>( @@ -58,12 +58,12 @@ MeasurementTrackerEventProducer::MeasurementTrackerEventProducer(const edm::Para if (!iConfig.getParameter("Phase2TrackerCluster1DProducer").empty()) { thePh2OTClusterLabel = consumes>( edm::InputTag(iConfig.getParameter("Phase2TrackerCluster1DProducer"))); - isPhase2 = true; + isPhase2_ = true; } if (!(iConfig.getParameter("vectorHits") == edm::InputTag(""))) { thePh2OTVectorHitsLabel = consumes(iConfig.getParameter("vectorHits")); - isPhase2 = true; - useVectorHits = true; + isPhase2_ = true; + useVectorHits_ = true; } produces(); @@ -119,12 +119,10 @@ void MeasurementTrackerEventProducer::produce(edm::Event& iEvent, const edm::Eve // put into MTE // put into event + // - edm::Handle vectorHitsHandle; - if (useVectorHits) { - iEvent.getByToken(thePh2OTVectorHitsLabel, vectorHitsHandle); - const VectorHitCollectionNew* phase2OTVectorHits = vectorHitsHandle.product(); - iEvent.put(std::make_unique(*measurementTracker, + const VectorHitCollectionNew* phase2OTVectorHits = useVectorHits_ ? &iEvent.get(thePh2OTVectorHitsLabel) : nullptr; + iEvent.put(std::make_unique(*measurementTracker, stripData.release(), pixelData.release(), phase2OTData.release(), @@ -132,16 +130,6 @@ void MeasurementTrackerEventProducer::produce(edm::Event& iEvent, const edm::Eve stripClustersToSkip, pixelClustersToSkip, phase2ClustersToSkip)); - } else { - iEvent.put(std::make_unique(*measurementTracker, - stripData.release(), - pixelData.release(), - phase2OTData.release(), - nullptr, - stripClustersToSkip, - pixelClustersToSkip, - phase2ClustersToSkip)); - } } void MeasurementTrackerEventProducer::updatePixels(const edm::Event& event, @@ -376,7 +364,7 @@ void MeasurementTrackerEventProducer::updatePhase2OT(const edm::Event& event, thePh2OTDets.setEmpty(); // Phase2OT Clusters - if (isPhase2) { + if (isPhase2_) { if (thePh2OTClusterLabel.isUninitialized()) { //clusters have not been produced thePh2OTDets.setActiveThisEvent(false); } else { diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h index ef16e4659a06c..e6e123b360450 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h @@ -51,8 +51,8 @@ class dso_hidden MeasurementTrackerEventProducer final : public edm::stream::EDP bool selfUpdateSkipClusters_; bool switchOffPixelsIfEmpty_; - bool isPhase2; - bool useVectorHits; + bool isPhase2_; + bool useVectorHits_; }; #endif diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index 09857880467b2..b59f47c7ab903 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -80,13 +80,56 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj */ + + //find clusters to skip + std::vector skipClustersLower; + std::vector skipClustersUpper; + const Phase2TrackerCluster1D* begin = nullptr; + if (!data.phase2OTData().handle()->data().empty()) { + begin = &(data.phase2OTData().handle()->data().front()); + } + if (!data.phase2OTClustersToSkip().empty()){ + const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); + const detset& upperDetSet = data.phase2OTData().detSet(upperDet()->index()); + + if (lowerDetSet.size() > 0){ + for (const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++cil) { + if (cil < begin) { + edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; + return result; + } + unsigned int indexl = cil - begin; + if (data.phase2OTClustersToSkip()[indexl]){ + Phase2TrackerCluster1DRef clusterRef = edmNew::makeRefTo(data.phase2OTData().handle(), cil); + skipClustersLower.push_back(clusterRef); + } + + } + } + if (upperDetSet.size() > 0){ + for (const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ciu) { + if (ciu < begin) { + edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; + return result; + } + unsigned int indexu = ciu - begin; + if (data.phase2OTClustersToSkip()[indexu]){ + Phase2TrackerCluster1DRef clusterRef = edmNew::makeRefTo(data.phase2OTData().handle(), ciu); + skipClustersUpper.push_back(clusterRef); + } + } + } + } DetId detIdStack = specificGeomDet().geographicalId(); auto iterator = data.phase2OTVectorHits().find(detIdStack); if (iterator == data.phase2OTVectorHits().end()) return result; - for (auto& vecHit : data.phase2OTVectorHits()[detIdStack]) + for (const auto& vecHit : data.phase2OTVectorHits()[detIdStack]){ + if (std::find(skipClustersLower.begin(), skipClustersLower.end(), vecHit.lowerCluster()) != skipClustersLower.end()) continue; + if (std::find(skipClustersUpper.begin(), skipClustersUpper.end(), vecHit.upperCluster()) != skipClustersUpper.end()) continue; result.push_back(std::make_shared(vecHit)); + } return result; } @@ -108,9 +151,10 @@ bool TkStackMeasurementDet::measurements(const TrajectoryStateOnSurface& stateOn for (auto&& hit : allHits) { std::pair diffEst = est.estimate(stateOnThisDet, *hit); - LogDebug("MeasurementTracker") << "New vh added with chi2: " << diffEst.second; - if (diffEst.first) + if (diffEst.first){ + LogDebug("MeasurementTracker") << "New vh added with chi2: " << diffEst.second; result.add(std::move(hit), diffEst.second); + } } if (result.size() > oldSize) From 1edd84dbc46a929e3dca2050da26a3b528ecfec1 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 26 Sep 2020 01:09:56 +0200 Subject: [PATCH 088/115] add second VH collection to TkStackMeasurementDet to recover low pT tracks --- .../interface/MeasurementTrackerEvent.h | 4 + .../MeasurementTrackerEventProducer.cc | 22 +++-- .../plugins/MeasurementTrackerEventProducer.h | 1 + .../plugins/MeasurementTrackerImpl.cc | 3 +- .../plugins/TkStackMeasurementDet.cc | 85 +++++++++++-------- .../MeasurementTrackerEventProducer_cfi.py | 1 + .../src/MeasurementTrackerEvent.cc | 4 + 7 files changed, 74 insertions(+), 46 deletions(-) diff --git a/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h b/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h index ab5214206e9a2..29f669f731b05 100644 --- a/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h +++ b/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h @@ -27,6 +27,7 @@ class MeasurementTrackerEvent { const PxMeasurementDetSet *pixels, const Phase2OTMeasurementDetSet *phase2OT, const VectorHitCollectionNew *phase2OTVectorHits, + const VectorHitCollectionNew *phase2OTVectorHitsRej, const std::vector &stripClustersToSkip, const std::vector &pixelClustersToSkip, const std::vector &phase2OTClustersToSkip) @@ -35,6 +36,7 @@ class MeasurementTrackerEvent { thePixelData(pixels), thePhase2OTData(phase2OT), thePhase2OTVectorHits(phase2OTVectorHits), + thePhase2OTVectorHitsRej(phase2OTVectorHitsRej), theOwner(true), theStripClustersToSkip(stripClustersToSkip), thePixelClustersToSkip(pixelClustersToSkip), @@ -61,6 +63,7 @@ class MeasurementTrackerEvent { const PxMeasurementDetSet &pixelData() const { return *thePixelData; } const Phase2OTMeasurementDetSet &phase2OTData() const { return *thePhase2OTData; } const VectorHitCollectionNew &phase2OTVectorHits() const { return *thePhase2OTVectorHits; } + const VectorHitCollectionNew &phase2OTVectorHitsRej() const { return *thePhase2OTVectorHitsRej; } const std::vector &stripClustersToSkip() const { return theStripClustersToSkip; } const std::vector &pixelClustersToSkip() const { return thePixelClustersToSkip; } const std::vector &phase2OTClustersToSkip() const { return thePhase2OTClustersToSkip; } @@ -78,6 +81,7 @@ class MeasurementTrackerEvent { const PxMeasurementDetSet *thePixelData = nullptr; const Phase2OTMeasurementDetSet *thePhase2OTData = nullptr; const VectorHitCollectionNew *thePhase2OTVectorHits = nullptr; + const VectorHitCollectionNew *thePhase2OTVectorHitsRej = nullptr; bool theOwner = false; // do I own the tree above? // these could be const pointers as well, but ContainerMask doesn't expose the vector std::vector theStripClustersToSkip; diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc index 54bdf53581abf..91b938d0a7fad 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc @@ -60,8 +60,10 @@ MeasurementTrackerEventProducer::MeasurementTrackerEventProducer(const edm::Para edm::InputTag(iConfig.getParameter("Phase2TrackerCluster1DProducer"))); isPhase2_ = true; } - if (!(iConfig.getParameter("vectorHits") == edm::InputTag(""))) { + if (!(iConfig.getParameter("vectorHits") == edm::InputTag("") || + iConfig.getParameter("vectorHitsRej") == edm::InputTag(""))) { thePh2OTVectorHitsLabel = consumes(iConfig.getParameter("vectorHits")); + thePh2OTVectorHitsRejLabel = consumes(iConfig.getParameter("vectorHitsRej")); isPhase2_ = true; useVectorHits_ = true; } @@ -78,6 +80,7 @@ void MeasurementTrackerEventProducer::fillDescriptions(edm::ConfigurationDescrip desc.add("stripClusterProducer", "siStripClusters"); desc.add("Phase2TrackerCluster1DProducer", ""); desc.add("vectorHits", edm::InputTag("")); + desc.add("vectorHitsRej", edm::InputTag("")); desc.add>("inactivePixelDetectorLabels", std::vector{{edm::InputTag("siPixelDigis")}}) @@ -122,14 +125,17 @@ void MeasurementTrackerEventProducer::produce(edm::Event& iEvent, const edm::Eve // const VectorHitCollectionNew* phase2OTVectorHits = useVectorHits_ ? &iEvent.get(thePh2OTVectorHitsLabel) : nullptr; + const VectorHitCollectionNew* phase2OTVectorHitsRej = + useVectorHits_ ? &iEvent.get(thePh2OTVectorHitsRejLabel) : nullptr; iEvent.put(std::make_unique(*measurementTracker, - stripData.release(), - pixelData.release(), - phase2OTData.release(), - phase2OTVectorHits, - stripClustersToSkip, - pixelClustersToSkip, - phase2ClustersToSkip)); + stripData.release(), + pixelData.release(), + phase2OTData.release(), + phase2OTVectorHits, + phase2OTVectorHitsRej, + stripClustersToSkip, + pixelClustersToSkip, + phase2ClustersToSkip)); } void MeasurementTrackerEventProducer::updatePixels(const edm::Event& event, diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h index e6e123b360450..13e7b125926bb 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h @@ -41,6 +41,7 @@ class dso_hidden MeasurementTrackerEventProducer final : public edm::stream::EDP edm::EDGetTokenT> theStripClusterLabel; edm::EDGetTokenT> thePh2OTClusterLabel; edm::EDGetTokenT thePh2OTVectorHitsLabel; + edm::EDGetTokenT thePh2OTVectorHitsRejLabel; edm::EDGetTokenT>> thePixelClusterMask; edm::EDGetTokenT>> theStripClusterMask; diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index a530bbe78d21f..337082baf5e7d 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -286,8 +286,7 @@ void MeasurementTrackerImpl::addGluedDet(const GluedGeomDet* gd) { void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd) { //since the Stack will be composed by PS or 2S, //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. - theStackDets.push_back( - TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE())); + theStackDets.push_back(TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE())); } void MeasurementTrackerImpl::initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology) { diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index b59f47c7ab903..cdd1d400f9a7c 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -80,7 +80,6 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj */ - //find clusters to skip std::vector skipClustersLower; std::vector skipClustersUpper; @@ -88,48 +87,62 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj if (!data.phase2OTData().handle()->data().empty()) { begin = &(data.phase2OTData().handle()->data().front()); } - if (!data.phase2OTClustersToSkip().empty()){ - const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); - const detset& upperDetSet = data.phase2OTData().detSet(upperDet()->index()); - - if (lowerDetSet.size() > 0){ - for (const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++cil) { - if (cil < begin) { - edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; - return result; - } - unsigned int indexl = cil - begin; - if (data.phase2OTClustersToSkip()[indexl]){ - Phase2TrackerCluster1DRef clusterRef = edmNew::makeRefTo(data.phase2OTData().handle(), cil); - skipClustersLower.push_back(clusterRef); - } - - } - } - if (upperDetSet.size() > 0){ - for (const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ciu) { - if (ciu < begin) { - edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; - return result; - } - unsigned int indexu = ciu - begin; - if (data.phase2OTClustersToSkip()[indexu]){ - Phase2TrackerCluster1DRef clusterRef = edmNew::makeRefTo(data.phase2OTData().handle(), ciu); - skipClustersUpper.push_back(clusterRef); - } - } - } + if (!data.phase2OTClustersToSkip().empty()) { + const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); + const detset& upperDetSet = data.phase2OTData().detSet(upperDet()->index()); + + if (!lowerDetSet.empty()) { + for (const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++cil) { + if (cil < begin) { + edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; + return result; + } + unsigned int indexl = cil - begin; + if (data.phase2OTClustersToSkip()[indexl]) { + Phase2TrackerCluster1DRef clusterRef = edmNew::makeRefTo(data.phase2OTData().handle(), cil); + skipClustersLower.push_back(clusterRef); + } + } + } + if (!upperDetSet.empty()) { + for (const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ciu) { + if (ciu < begin) { + edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; + return result; + } + unsigned int indexu = ciu - begin; + if (data.phase2OTClustersToSkip()[indexu]) { + Phase2TrackerCluster1DRef clusterRef = edmNew::makeRefTo(data.phase2OTData().handle(), ciu); + skipClustersUpper.push_back(clusterRef); + } + } + } } + DetId detIdStack = specificGeomDet().geographicalId(); auto iterator = data.phase2OTVectorHits().find(detIdStack); if (iterator == data.phase2OTVectorHits().end()) return result; - for (const auto& vecHit : data.phase2OTVectorHits()[detIdStack]){ - if (std::find(skipClustersLower.begin(), skipClustersLower.end(), vecHit.lowerCluster()) != skipClustersLower.end()) continue; - if (std::find(skipClustersUpper.begin(), skipClustersUpper.end(), vecHit.upperCluster()) != skipClustersUpper.end()) continue; + for (const auto& vecHit : data.phase2OTVectorHits()[detIdStack]) { + if (std::find(skipClustersLower.begin(), skipClustersLower.end(), vecHit.lowerCluster()) != skipClustersLower.end()) + continue; + if (std::find(skipClustersUpper.begin(), skipClustersUpper.end(), vecHit.upperCluster()) != skipClustersUpper.end()) + continue; result.push_back(std::make_shared(vecHit)); } + + iterator = data.phase2OTVectorHitsRej().find(detIdStack); + if (iterator == data.phase2OTVectorHitsRej().end()) + return result; + for (const auto& vecHit : data.phase2OTVectorHitsRej()[detIdStack]) { + if (std::find(skipClustersLower.begin(), skipClustersLower.end(), vecHit.lowerCluster()) != skipClustersLower.end()) + continue; + if (std::find(skipClustersUpper.begin(), skipClustersUpper.end(), vecHit.upperCluster()) != skipClustersUpper.end()) + continue; + result.push_back(std::make_shared(vecHit)); + } + return result; } @@ -151,7 +164,7 @@ bool TkStackMeasurementDet::measurements(const TrajectoryStateOnSurface& stateOn for (auto&& hit : allHits) { std::pair diffEst = est.estimate(stateOnThisDet, *hit); - if (diffEst.first){ + if (diffEst.first) { LogDebug("MeasurementTracker") << "New vh added with chi2: " << diffEst.second; result.add(std::move(hit), diffEst.second); } diff --git a/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py b/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py index d4431bbfa3662..1cc806bac523f 100644 --- a/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py +++ b/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py @@ -26,6 +26,7 @@ from Configuration.ProcessModifiers.vectorHits_cff import vectorHits vectorHits.toModify(MeasurementTrackerEvent, vectorHits = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), + vectorHitsRej = cms.InputTag("siPhase2VectorHits", "vectorHitsRejected"), ) MeasurementTrackerEventPreSplitting = MeasurementTrackerEvent.clone( diff --git a/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc b/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc index fe2a1d361c85c..e764ff3607fc7 100644 --- a/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc +++ b/RecoTracker/MeasurementDet/src/MeasurementTrackerEvent.cc @@ -19,6 +19,7 @@ MeasurementTrackerEvent::MeasurementTrackerEvent(MeasurementTrackerEvent &&other thePixelData = other.thePixelData; thePhase2OTData = other.thePhase2OTData; thePhase2OTVectorHits = other.thePhase2OTVectorHits; + thePhase2OTVectorHitsRej = other.thePhase2OTVectorHitsRej; theOwner = other.theOwner; other.theOwner = false; // make sure to fully transfer the ownership theStripClustersToSkip = std::move(other.theStripClustersToSkip); @@ -30,6 +31,7 @@ MeasurementTrackerEvent &MeasurementTrackerEvent::operator=(MeasurementTrackerEv thePixelData = other.thePixelData; thePhase2OTData = other.thePhase2OTData; thePhase2OTVectorHits = other.thePhase2OTVectorHits; + thePhase2OTVectorHitsRej = other.thePhase2OTVectorHitsRej; theOwner = other.theOwner; other.theOwner = false; // make sure to fully transfer the ownership theStripClustersToSkip = std::move(other.theStripClustersToSkip); @@ -46,6 +48,7 @@ MeasurementTrackerEvent::MeasurementTrackerEvent( thePixelData(trackerEvent.thePixelData), thePhase2OTData(nullptr), thePhase2OTVectorHits(nullptr), + thePhase2OTVectorHitsRej(nullptr), theOwner(false) { //std::cout << "Creatign non-owned MT @ " << this << " from @ " << & trackerEvent << " (strip data @ " << trackerEvent.theStripData << ")" << std::endl; if (stripClustersToSkip.refProd().id() != theStripData->handle().id()) { @@ -81,6 +84,7 @@ MeasurementTrackerEvent::MeasurementTrackerEvent( thePixelData(trackerEvent.thePixelData), thePhase2OTData(trackerEvent.thePhase2OTData), thePhase2OTVectorHits(trackerEvent.thePhase2OTVectorHits), + thePhase2OTVectorHitsRej(trackerEvent.thePhase2OTVectorHitsRej), theOwner(false) { if (pixelClustersToSkip.refProd().id() != thePixelData->handle().id()) { edm::LogError("ProductIdMismatch") << "The pixel masking does not point to the proper collection of clusters: " From d8b3b31a4f099fcb33f9bcb5ef1eedff70a85946 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 26 Sep 2020 14:33:35 +0200 Subject: [PATCH 089/115] initialize useVectorHits_ in MeasurementTrackerEventProducer --- .../MeasurementDet/plugins/MeasurementTrackerEventProducer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc index 91b938d0a7fad..8d9f0343ee003 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc @@ -40,6 +40,7 @@ MeasurementTrackerEventProducer::MeasurementTrackerEventProducer(const edm::Para selfUpdateSkipClusters_ = !(skip == edm::InputTag("")); LogDebug("MeasurementTracker") << "skipping clusters: " << selfUpdateSkipClusters_; isPhase2_ = false; + useVectorHits_ = false; if (!iConfig.getParameter("stripClusterProducer").empty()) { theStripClusterLabel = consumes>( From 35d4bf778048f9060ad6ab9b6a8f3c5f4ff437d0 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 30 Sep 2020 00:32:51 +0200 Subject: [PATCH 090/115] cleanup --- .../TrackerRecHit2D/interface/VectorHit2D.h | 1 - DataFormats/TrackerRecHit2D/src/VectorHit.cc | 21 +++++-------------- .../plugins/VectorHitBuilderEDProducer.cc | 1 - .../src/VectorHitBuilderAlgorithm.cc | 9 +------- .../test/VectorHitsValidation.cc | 3 --- .../test/VectorHitsValidation.h | 1 - RecoTracker/CkfPattern/src/PrintoutHelper.cc | 15 ------------- .../plugins/SeedingOTEDProducer.cc | 1 - 8 files changed, 6 insertions(+), 46 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index 4e378b0ac58aa..62943d3fd1b51 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -23,7 +23,6 @@ class VectorHit2D { const LocalPoint* localPosition() const { return &thePosition; } const LocalVector* localDirection() const { return &theDirection; } const LocalError* localDirectionError() const { - //return &LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); return &theLocalError; } const AlgebraicSymMatrix22* covMatrix() const { return &theCovMatrix; } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 9dc9a214479b0..5ca72f5655cdb 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -1,5 +1,6 @@ #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "Geometry/CommonDetUnit/interface/StackGeomDet.h" +#include "CLHEP/Units/PhysicalConstants.h" VectorHit::VectorHit(const VectorHit& vh) : BaseTrackerRecHit(*vh.det(), trackerHitRTTI::vector), @@ -189,8 +190,8 @@ Global3DVector VectorHit::globalDirection() const { return (det()->surface().toG float VectorHit::theta() const { return globalDirection().theta(); } float VectorHit::transverseMomentum(float magField) const { - return magField * 2.99792458e-3F / theCurvature; -} // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, thus using 2.99792458e-3F (precise value from speed of light) + return magField * (CLHEP::c_light * 1e-11) / theCurvature; +} // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, using precise value from speed of light float VectorHit::momentum(float magField) const { return transverseMomentum(magField) / (1. * sin(theta())); } AlgebraicMatrix VectorHit::projectionMatrix() const { @@ -208,14 +209,7 @@ LocalError VectorHit::localDirectionError() const { } AlgebraicSymMatrix VectorHit::parametersError() const { - //think about a more efficient method - AlgebraicSymMatrix result(nComponents); - for (int i = 0; i < nComponents; i++) { - for (int j = 0; j < nComponents; j++) { - result[i][j] = theCovMatrix[i][j]; - } - } - return result; + return theCovMatrix; } std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { @@ -223,12 +217,7 @@ std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { << " Vectorhit local position : " << vh.localPosition() << "\n" << " Vectorhit local direction : " << vh.localDirection() << "\n" << " Vectorhit global direction : " << vh.globalDirection() << "\n" - << - //" Vectorhit theta : " << vh.theta() << "\n" << - //" Cov: " << vh.parametersError() << "\n" << - //" Dim: " << vh.dimension() << "\n" << - //" chi2: " << vh.chi2() << "\n" << - " Lower cluster global position : " << vh.lowerGlobalPos() << "\n" + << " Lower cluster global position : " << vh.lowerGlobalPos() << "\n" << " Upper cluster global position : " << vh.upperGlobalPos(); return os; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc index 4df79a4761e60..97f89f85e14e8 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -34,7 +34,6 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT> clusterProducer_; }; -//VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; } VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() {} VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 8c37b6ae1e90d..a8432ba24399e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -381,7 +381,6 @@ void VectorHitBuilderAlgorithm::fit(float x[2], float covii = 0.; float covsi = 0.; - //theFitter->linearFit(x, y, 2, sigy, slope, intercept, covss, covii, covsi); linearFit(x, y, 2, sigy2, slope, intercept, covss, covii, covsi); covMatrix[0][0] = covss; // this is var(dy/dz) @@ -544,11 +543,5 @@ std::pair, float> VectorHitBuilderAlgorithm::curvatureAN } else { return std::make_pair(std::make_pair(0., 0.), 0.0); } - /* switch (curvORphi) { - case curvatureMode: - return std::make_pair(curvature, errorCurvature); - case phiMode: - return std::make_pair(phi, 0.0); - }*/ - return std::make_pair(std::make_pair(curvature, errorCurvature), phi); + return std::make_pair(std::make_pair(curvature, errorCurvature), phi); } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 3515d731c60ef..47d53e0f82dda 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -587,7 +587,6 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev } // loop simhits nVHsTot++; - //tree_->Fill(); //****************************** //combinatorial studies : not filling if more than 1 VH has been produced @@ -1071,7 +1070,6 @@ std::vector > VectorHitsBuilderValidation::g if (isearch != simLinks->end()) { // Loop over DigiSimLink in this det unit edm::DetSet link_detset = (*isearch); - //for (typename edm::DetSet::const_iterator it = link_detset.data.begin(); it != link_detset.data.end(); ++it) { for (const auto& it : link_detset.data) { if (channel == it.channel()) simTrkId.push_back(std::make_pair(it.SimTrackId(), it.eventId())); @@ -1087,7 +1085,6 @@ unsigned int VectorHitsBuilderValidation::getSimTrackId( edm::DetSetVector::const_iterator DSViter(pixelSimLinks->find(detId)); if (DSViter == pixelSimLinks->end()) return 0; - //for (edm::DetSet::const_iterator it = DSViter->data.begin(); it != DSViter->data.end(); ++it) { for (const auto& it : DSViter->data) { if (channel == it.channel()) return it.SimTrackId(); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index 0bfcb55fb4602..3ce33868d1bdd 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -120,7 +120,6 @@ class VectorHitsBuilderValidation : public edm::one::EDAnalyzer simTracksToken_; edm::EDGetTokenT simVerticesToken_; edm::EDGetTokenT trackingParticleToken_; - //SiPixelVectorHitBuilderAlgorithmBase *algo; const TrackerGeometry* tkGeom_; const TrackerTopology* tkTopo_; diff --git a/RecoTracker/CkfPattern/src/PrintoutHelper.cc b/RecoTracker/CkfPattern/src/PrintoutHelper.cc index 82885a3dc03bc..65f26d972ab42 100644 --- a/RecoTracker/CkfPattern/src/PrintoutHelper.cc +++ b/RecoTracker/CkfPattern/src/PrintoutHelper.cc @@ -57,7 +57,6 @@ std::string PrintoutHelper::dumpMeasurement(const TrajectoryMeasurement& tm) { else buffer << "no valid state\n"; buffer - // <<"geomdet pointer from rechit: "<det()<<"\n" << "detId: " << tm.recHit()->geographicalId().rawId(); if (tm.recHit()->isValid()) { buffer << "\n hit global x: " << tm.recHit()->globalPosition() @@ -75,19 +74,6 @@ std::string PrintoutHelper::dumpMeasurement(const TrajectoryMeasurement& tm) { std::string PrintoutHelper::regressionTest(const TrackerGeometry& tracker, std::vector& unsmoothedResult) { std::stringstream buffer; - /* - for(iseed=theSeedColl.begin();iseed!=theSeedColl.end();iseed++){ - DetId tmpId = DetId( iseed->startingState().detId()); - const GeomDet* tmpDet = tracker->idToDet( tmpId ); - GlobalVector gv = tmpDet->surface().toGlobal( iseed->startingState().parameters().momentum() ); - - LogTrace("TrackingRegressionTest") << "seed perp,phi,eta : " - << gv.perp() << " , " - << gv.phi() << " , " - << gv.eta() ; - } - */ - buffer << "number of finalTrajectories: " << unsmoothedResult.size() << std::endl; for (std::vector::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) { if (it->lastMeasurement().updatedState().isValid()) { @@ -103,7 +89,6 @@ std::string PrintoutHelper::regressionTest(const TrackerGeometry& tracker, std:: } buffer << "================================================="; buffer << "=========== Traj in details =====================\n"; - //for (std::vector::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) { for (const auto& it : unsmoothedResult) { for (const auto& hit : it.measurements()) { buffer << "measurement : " << hit.recHit()->geographicalId().rawId() << std::endl; diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index e4846baf28ba2..f63181ca281af 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -93,7 +93,6 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { }; SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) - //: updator_(nullptr), : tkMeasEventToken_(consumes(conf.getParameter("trackerEvent"))), topoToken_(esConsumes()), propagatorToken_(esConsumes(edm::ESInputTag("", "PropagatorWithMaterial"))), From b4fe5a6f21bcfb18b6396a658c61ae4a6e4321d6 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 30 Sep 2020 01:12:01 +0200 Subject: [PATCH 091/115] remove phase2 matcher from MeasurementTrackerEvent as it is no longer needed --- .../plugins/MeasurementTrackerESProducer.cc | 7 --- .../plugins/MeasurementTrackerEventProducer.h | 1 + .../plugins/MeasurementTrackerImpl.cc | 7 +-- .../plugins/MeasurementTrackerImpl.h | 2 - .../plugins/TkStackMeasurementDet.cc | 56 +------------------ .../plugins/TkStackMeasurementDet.h | 6 +- .../MeasurementTrackerESProducer_cfi.py | 5 +- .../MeasurementDet/src/TkMeasurementDetSet.h | 8 +-- 8 files changed, 9 insertions(+), 83 deletions(-) diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc index 36cca63a0fdce..8b689550b5fb8 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc @@ -56,7 +56,6 @@ class dso_hidden MeasurementTrackerESProducer : public edm::ESProducer { edm::ESGetToken trackerGeomToken_; edm::ESGetToken geometricSearchTrackerToken_; edm::ESGetToken, TkPhase2OTCPERecord> phase2TrackerCPEToken_; - edm::ESGetToken phase2matcherToken_; MeasurementTrackerImpl::BadStripCutsDet badStripCuts_; @@ -158,11 +157,9 @@ MeasurementTrackerESProducer::MeasurementTrackerESProducer(const edm::ParameterS //FIXME:: just temporary solution for phase2! auto phase2 = p.getParameter("Phase2StripCPE"); - auto phase2Matcher = p.getParameter("Phase2HitMatcher"); if (not phase2.empty()) { usePhase2_ = true; phase2TrackerCPEToken_ = c.consumes(edm::ESInputTag("", phase2)); - phase2matcherToken_ = c.consumes(edm::ESInputTag("", phase2Matcher)); } } @@ -185,16 +182,13 @@ std::unique_ptr MeasurementTrackerESProducer::produce(const } const ClusterParameterEstimator *ptr_phase2TrackerCPE = nullptr; - const VectorHitBuilderAlgorithm *ptr_phase2Matcher = nullptr; if (usePhase2_) { ptr_phase2TrackerCPE = &iRecord.get(phase2TrackerCPEToken_); - ptr_phase2Matcher = &iRecord.get(phase2matcherToken_); } return std::make_unique(badStripCuts_, &iRecord.get(pixelCPEToken_), &iRecord.get(stripCPEToken_), &iRecord.get(hitMatcherToken_), - ptr_phase2Matcher, &iRecord.get(trackerTopologyToken_), &iRecord.get(trackerGeomToken_), &iRecord.get(geometricSearchTrackerToken_), @@ -218,7 +212,6 @@ void MeasurementTrackerESProducer::fillDescriptions(edm::ConfigurationDescriptio desc.add("HitMatcher", "StandardMatcher"); desc.add("Phase2StripCPE", "")->setComment("empty string used to turn off Phase 2"); - desc.add("Phase2HitMatcher", ""); desc.add("SiStripQualityLabel", ""); desc.add("UseStripModuleQualityDB", true); diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h index 13e7b125926bb..02fd476d71092 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h @@ -12,6 +12,7 @@ #include "DataFormats/DetId/interface/DetIdCollection.h" #include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" class dso_hidden MeasurementTrackerEventProducer final : public edm::stream::EDProducer<> { public: diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index 337082baf5e7d..918f4473d65a1 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -78,7 +78,6 @@ MeasurementTrackerImpl::MeasurementTrackerImpl(const BadStripCutsDet& badStripCu const PixelClusterParameterEstimator* pixelCPE, const StripClusterParameterEstimator* stripCPE, const SiStripRecHitMatcher* hitMatcher, - const VectorHitBuilderAlgorithm* ph2hitMatcher, const TrackerTopology* trackerTopology, const TrackerGeometry* trackerGeom, const GeometricSearchTracker* geometricSearchTracker, @@ -93,7 +92,7 @@ MeasurementTrackerImpl::MeasurementTrackerImpl(const BadStripCutsDet& badStripCu : MeasurementTracker(trackerGeom, geometricSearchTracker), theStDetConditions(hitMatcher, stripCPE), thePxDetConditions(pixelCPE), - thePhase2DetConditions(ph2hitMatcher, phase2OTCPE) { + thePhase2DetConditions(phase2OTCPE) { this->initialize(trackerTopology); this->initializeStripStatus(badStripCuts, stripQuality, stripQualityFlags, stripQualityDebugFlags); this->initializePixelStatus(pixelQuality, pixelCabling, pixelQualityFlags, pixelQualityDebugFlags); @@ -284,9 +283,7 @@ void MeasurementTrackerImpl::addGluedDet(const GluedGeomDet* gd) { } void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd) { - //since the Stack will be composed by PS or 2S, - //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. - theStackDets.push_back(TkStackMeasurementDet(gd, thePhase2DetConditions.matcher(), thePxDetConditions.pixelCPE())); + theStackDets.push_back(TkStackMeasurementDet(gd)); } void MeasurementTrackerImpl::initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology) { diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h index 69c6a0e97d5ba..7794f31e5fe94 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.h @@ -9,7 +9,6 @@ #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -57,7 +56,6 @@ class dso_hidden MeasurementTrackerImpl final : public MeasurementTracker { const PixelClusterParameterEstimator* pixelCPE, const StripClusterParameterEstimator* stripCPE, const SiStripRecHitMatcher* hitMatcher, - const VectorHitBuilderAlgorithm* ph2hitMatcher, const TrackerTopology* trackerTopology, const TrackerGeometry* trackerGeom, const GeometricSearchTracker* geometricSearchTracker, diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index cdd1d400f9a7c..276197c5c00ca 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -5,10 +5,8 @@ using namespace std; -TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet, - const VectorHitBuilderAlgorithm* matcher, - const PixelClusterParameterEstimator* cpe) - : MeasurementDet(gdet), theMatcher(matcher), thePixelCPE(cpe), theLowerDet(nullptr), theUpperDet(nullptr) {} +TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet) + : MeasurementDet(gdet), theLowerDet(nullptr), theUpperDet(nullptr) {} void TkStackMeasurementDet::init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet) { theLowerDet = dynamic_cast(lowerDet); @@ -31,54 +29,6 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj return result; LogTrace("MeasurementTracker") << " and is active"; - // Old solution creating the VHs on the fly. Keep for now - /* - const Phase2TrackerCluster1D* begin = nullptr; - if (!data.phase2OTData().handle()->data().empty()) { - begin = &(data.phase2OTData().handle()->data().front()); - } - - LogTrace("MeasurementTracker") << "TkStackMeasurementDet::recHits algo has been set" << std::endl; - - const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); - const detset& upperDetSet = data.phase2OTData().detSet(upperDet()->index()); - - LogTrace("MeasurementTracker") << " DetSets set with sizes:" << lowerDetSet.size() << " and " << upperDetSet.size() - << "!"; - result.reserve(lowerDetSet.size() > upperDetSet.size() ? lowerDetSet.size() : upperDetSet.size()); - - for (const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++cil) { - if (cil < begin) { - edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; - return result; - } - unsigned int indexl = cil - begin; - LogTrace("MeasurementTracker") << " index cluster lower" << indexl << " on detId " - << fastGeomDet().geographicalId().rawId(); - - for (const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ciu) { - unsigned int indexu = ciu - begin; - if (ciu < begin) { - edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch."; - return result; - } - LogTrace("VectorHitBuilderAlgorithm") << " index cluster upper " << indexu; - - if (data.phase2OTClustersToSkip().empty() or - ((not data.phase2OTClustersToSkip()[indexl]) and (not data.phase2OTClustersToSkip()[indexu]))) { - Phase2TrackerCluster1DRef clusterLower = edmNew::makeRefTo(data.phase2OTData().handle(), cil); - Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo(data.phase2OTData().handle(), ciu); - //ERICA:I would have prefer to keep buildVectorHits ... - VectorHit vh = theMatcher->buildVectorHit(&specificGeomDet(), clusterLower, clusterUpper); - LogTrace("MeasurementTracker") << "TkStackMeasurementDet::rechits adding VectorHits!" << std::endl; - LogTrace("MeasurementTracker") << vh << std::endl; - result.push_back(std::make_shared(vh)); - } - } - } - - -*/ //find clusters to skip std::vector skipClustersLower; @@ -103,7 +53,7 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj skipClustersLower.push_back(clusterRef); } } - } + } if (!upperDetSet.empty()) { for (const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ciu) { if (ciu < begin) { diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index a5bbfde36414f..100d6572b66d4 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -14,9 +14,7 @@ class TkStackMeasurementDet final : public MeasurementDet { public: - TkStackMeasurementDet(const StackGeomDet* gdet, - const VectorHitBuilderAlgorithm* matcher, - const PixelClusterParameterEstimator* cpe); + TkStackMeasurementDet(const StackGeomDet* gdet); void init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet); RecHitContainer recHits(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent& data) const override; @@ -49,8 +47,6 @@ class TkStackMeasurementDet final : public MeasurementDet { } private: - const VectorHitBuilderAlgorithm* theMatcher; - const PixelClusterParameterEstimator* thePixelCPE; const TkPhase2OTMeasurementDet* theLowerDet; const TkPhase2OTMeasurementDet* theUpperDet; }; diff --git a/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py b/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py index a09c7c51b6597..d5b0dcefdc434 100644 --- a/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py +++ b/RecoTracker/MeasurementDet/python/MeasurementTrackerESProducer_cfi.py @@ -5,7 +5,4 @@ MeasurementTracker = _MeasurementTrackerESProducer_default.clone() from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140 -trackingPhase2PU140.toModify(MeasurementTracker, - Phase2StripCPE = 'Phase2StripCPE', - Phase2HitMatcher = 'SiPhase2VectorHitMatcher' -) +trackingPhase2PU140.toModify(MeasurementTracker, Phase2StripCPE = 'Phase2StripCPE') diff --git a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h index cfbfefbe3e471..6c5f3f89c317a 100644 --- a/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h +++ b/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.h @@ -20,8 +20,6 @@ class Phase2StripCPE; #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h" #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" - #include // #define VISTAT @@ -406,9 +404,7 @@ class PxMeasurementDetSet { //FIXME:just temporary solution for phase2 OT that works! class Phase2OTMeasurementConditionSet { public: - Phase2OTMeasurementConditionSet(const VectorHitBuilderAlgorithm* ph2matcher, - const ClusterParameterEstimator* cpe) - : thePhase2Matcher(ph2matcher), theCPE(cpe) {} + Phase2OTMeasurementConditionSet(const ClusterParameterEstimator* cpe) : theCPE(cpe) {} void init(int size); @@ -417,7 +413,6 @@ class Phase2OTMeasurementConditionSet { int find(unsigned int jd, int i = 0) const { return std::lower_bound(id_.begin() + i, id_.end(), jd) - id_.begin(); } const ClusterParameterEstimator* cpe() const { return theCPE; } - const VectorHitBuilderAlgorithm* matcher() const { return thePhase2Matcher; } bool isActiveThisPeriod(int i) const { return activeThisPeriod_[i]; } /** \brief Turn on/off the module for reconstruction, for the full run or lumi (using info from DB, usually). @@ -428,7 +423,6 @@ class Phase2OTMeasurementConditionSet { friend class MeasurementTrackerImpl; // Globals (not-per-event) - const VectorHitBuilderAlgorithm* thePhase2Matcher; const ClusterParameterEstimator* theCPE; // Locals, per-event From 38225d683e15c41a77fa78bf401a6af38f49b1f6 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 30 Sep 2020 01:31:24 +0200 Subject: [PATCH 092/115] code format --- DataFormats/TrackerRecHit2D/interface/VectorHit2D.h | 4 +--- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 4 +--- .../src/VectorHitBuilderAlgorithm.cc | 2 +- RecoTracker/CkfPattern/src/PrintoutHelper.cc | 3 +-- .../MeasurementDet/plugins/MeasurementTrackerImpl.cc | 5 +++-- .../MeasurementDet/plugins/TkStackMeasurementDet.cc | 7 +++---- RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h | 3 ++- 7 files changed, 12 insertions(+), 16 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index 62943d3fd1b51..ec0ad38f22f6a 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -22,9 +22,7 @@ class VectorHit2D { const LocalPoint* localPosition() const { return &thePosition; } const LocalVector* localDirection() const { return &theDirection; } - const LocalError* localDirectionError() const { - return &theLocalError; - } + const LocalError* localDirectionError() const { return &theLocalError; } const AlgebraicSymMatrix22* covMatrix() const { return &theCovMatrix; } float chi2() const { return theChi2; } int dimension() const { return theDimension; } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 5ca72f5655cdb..75e0b6ee5c23c 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -208,9 +208,7 @@ LocalError VectorHit::localDirectionError() const { return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); } -AlgebraicSymMatrix VectorHit::parametersError() const { - return theCovMatrix; -} +AlgebraicSymMatrix VectorHit::parametersError() const { return theCovMatrix; } std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { os << " VectorHit create in the DetId#: " << vh.geographicalId() << "\n" diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index a8432ba24399e..b0b2842d7ba28 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -543,5 +543,5 @@ std::pair, float> VectorHitBuilderAlgorithm::curvatureAN } else { return std::make_pair(std::make_pair(0., 0.), 0.0); } - return std::make_pair(std::make_pair(curvature, errorCurvature), phi); + return std::make_pair(std::make_pair(curvature, errorCurvature), phi); } diff --git a/RecoTracker/CkfPattern/src/PrintoutHelper.cc b/RecoTracker/CkfPattern/src/PrintoutHelper.cc index 65f26d972ab42..bae0056c13a86 100644 --- a/RecoTracker/CkfPattern/src/PrintoutHelper.cc +++ b/RecoTracker/CkfPattern/src/PrintoutHelper.cc @@ -56,8 +56,7 @@ std::string PrintoutHelper::dumpMeasurement(const TrajectoryMeasurement& tm) { << "p: " << tm.predictedState().globalMomentum() << "\n"; else buffer << "no valid state\n"; - buffer - << "detId: " << tm.recHit()->geographicalId().rawId(); + buffer << "detId: " << tm.recHit()->geographicalId().rawId(); if (tm.recHit()->isValid()) { buffer << "\n hit global x: " << tm.recHit()->globalPosition() << "\n hit global error: " << tm.recHit()->globalPositionError().matrix() diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index 918f4473d65a1..dd263250a736e 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -25,7 +25,6 @@ #include "RecoLocalTracker/Records/interface/TrackerCPERecord.h" #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h" #include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPE.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h" #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h" #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" @@ -283,7 +282,9 @@ void MeasurementTrackerImpl::addGluedDet(const GluedGeomDet* gd) { } void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd) { - theStackDets.push_back(TkStackMeasurementDet(gd)); + //since the Stack will be composed by PS or 2S, + // //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. + theStackDets.push_back(TkStackMeasurementDet(gd, thePxDetConditions.pixelCPE())); } void MeasurementTrackerImpl::initGluedDet(TkGluedMeasurementDet& det, const TrackerTopology* trackerTopology) { diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index 276197c5c00ca..597dc27d64f74 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -5,8 +5,8 @@ using namespace std; -TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet) - : MeasurementDet(gdet), theLowerDet(nullptr), theUpperDet(nullptr) {} +TkStackMeasurementDet::TkStackMeasurementDet(const StackGeomDet* gdet, const PixelClusterParameterEstimator* cpe) + : MeasurementDet(gdet), thePixelCPE(cpe), theLowerDet(nullptr), theUpperDet(nullptr) {} void TkStackMeasurementDet::init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet) { theLowerDet = dynamic_cast(lowerDet); @@ -29,7 +29,6 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj return result; LogTrace("MeasurementTracker") << " and is active"; - //find clusters to skip std::vector skipClustersLower; std::vector skipClustersUpper; @@ -53,7 +52,7 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj skipClustersLower.push_back(clusterRef); } } - } + } if (!upperDetSet.empty()) { for (const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ciu) { if (ciu < begin) { diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h index 100d6572b66d4..7dc973344b529 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.h @@ -14,7 +14,7 @@ class TkStackMeasurementDet final : public MeasurementDet { public: - TkStackMeasurementDet(const StackGeomDet* gdet); + TkStackMeasurementDet(const StackGeomDet* gdet, const PixelClusterParameterEstimator* cpe); void init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet); RecHitContainer recHits(const TrajectoryStateOnSurface&, const MeasurementTrackerEvent& data) const override; @@ -47,6 +47,7 @@ class TkStackMeasurementDet final : public MeasurementDet { } private: + const PixelClusterParameterEstimator* thePixelCPE; const TkPhase2OTMeasurementDet* theLowerDet; const TkPhase2OTMeasurementDet* theUpperDet; }; From 47747108aaf3e6d7a7e6c71dbe124b179608bf31 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Wed, 30 Sep 2020 01:35:37 +0200 Subject: [PATCH 093/115] slightly reduce diff --- RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc index dd263250a736e..bd7c54e22fa4f 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerImpl.cc @@ -283,7 +283,7 @@ void MeasurementTrackerImpl::addGluedDet(const GluedGeomDet* gd) { void MeasurementTrackerImpl::addStackDet(const StackGeomDet* gd) { //since the Stack will be composed by PS or 2S, - // //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. + //both cluster parameter estimators are needed? - right now just the thePixelCPE is used. theStackDets.push_back(TkStackMeasurementDet(gd, thePxDetConditions.pixelCPE())); } From b6b9e9e1341e9694e8d6a5fdab07430eead966b2 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Thu, 1 Oct 2020 01:26:50 +0200 Subject: [PATCH 094/115] get rid of AlgebraicSymMatrix as member of VectorHit clas --- .../TrackerRecHit2D/interface/VectorHit.h | 7 ++--- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 26 +++++++++++++++---- .../TrackerRecHit2D/src/classes_def.xml | 4 +-- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 35140ba1118ff..f630031c21c7b 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -36,7 +36,7 @@ class VectorHit final : public BaseTrackerRecHit { VectorHit(const GeomDet& idet, const LocalPoint& posInner, const LocalVector& dir, - const AlgebraicSymMatrix& covMatrix, + const std::array, 4> covMatrix, const float chi2, OmniClusterRef const& lower, OmniClusterRef const& upper, @@ -76,6 +76,7 @@ class VectorHit final : public BaseTrackerRecHit { // returning methods LocalPoint localPosition() const override { return thePosition; } virtual LocalVector localDirection() const { return theDirection; } + const std::array, 4> parametersErrorPlain() const; AlgebraicSymMatrix parametersError() const override; LocalError localPositionError() const override; virtual LocalError localDirectionError() const; @@ -124,7 +125,7 @@ class VectorHit final : public BaseTrackerRecHit { // setting methods void setPosition(LocalPoint pos) { thePosition = pos; } void setDirection(LocalVector dir) { theDirection = dir; } - void setCovMatrix(AlgebraicSymMatrix mat) { theCovMatrix = mat; } + void setCovMatrix(std::array, 4> mat) { theCovMatrix = mat; } private: // double dispatch @@ -145,7 +146,7 @@ class VectorHit final : public BaseTrackerRecHit { // mat[3][3]=var(y) // mat[0][2]=cov(dx/dz,x) // mat[1][3]=cov(dy/dz,y) - AlgebraicSymMatrix theCovMatrix; + std::array, 4> theCovMatrix; float theChi2; int theDimension; OmniClusterRef theLowerCluster; diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 75e0b6ee5c23c..de77a333393b1 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -6,7 +6,7 @@ VectorHit::VectorHit(const VectorHit& vh) : BaseTrackerRecHit(*vh.det(), trackerHitRTTI::vector), thePosition(vh.localPosition()), theDirection(vh.localDirection()), - theCovMatrix(vh.parametersError()), + theCovMatrix(vh.parametersErrorPlain()), theChi2(vh.chi2()), theDimension(vh.dimension()), theLowerCluster(vh.lowerClusterRef()), @@ -18,7 +18,7 @@ VectorHit::VectorHit(const VectorHit& vh) VectorHit::VectorHit(const GeomDet& idet, const LocalPoint& posLower, const LocalVector& dir, - const AlgebraicSymMatrix& covMatrix, + const std::array, 4> covMatrix, const float chi2, OmniClusterRef const& lower, OmniClusterRef const& upper, @@ -60,7 +60,13 @@ VectorHit::VectorHit(const GeomDet& idet, const AlgebraicSymMatrix22 covMatZX = *vh2Dzx.covMatrix(); const AlgebraicSymMatrix22 covMatZY = *vh2Dzy.covMatrix(); - theCovMatrix = AlgebraicSymMatrix(nComponents); + for (int i = 0; i < nComponents; i++) { + for (int j = 0; j < nComponents; j++) { + theCovMatrix[i][j] = 0.; + } + } + + //theCovMatrix = AlgebraicSymMatrix(nComponents); theCovMatrix[0][0] = covMatZX[0][0]; // var(dx/dz) theCovMatrix[1][1] = covMatZY[0][0]; // var(dy/dz) theCovMatrix[2][2] = covMatZX[1][1]; // var(x) @@ -190,7 +196,7 @@ Global3DVector VectorHit::globalDirection() const { return (det()->surface().toG float VectorHit::theta() const { return globalDirection().theta(); } float VectorHit::transverseMomentum(float magField) const { - return magField * (CLHEP::c_light * 1e-11) / theCurvature; + return magField * (CLHEP::c_light * 1e-5F) / theCurvature; } // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, using precise value from speed of light float VectorHit::momentum(float magField) const { return transverseMomentum(magField) / (1. * sin(theta())); } @@ -208,7 +214,17 @@ LocalError VectorHit::localDirectionError() const { return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); } -AlgebraicSymMatrix VectorHit::parametersError() const { return theCovMatrix; } +const std::array, 4> VectorHit::parametersErrorPlain() const { return theCovMatrix; } + +AlgebraicSymMatrix VectorHit::parametersError() const { + AlgebraicSymMatrix result(nComponents); + for (int i = 0; i < nComponents; i++) { + for (int j = 0; j < nComponents; j++) { + result[i][j] = theCovMatrix[i][j]; + } + } + return result; +} std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { os << " VectorHit create in the DetId#: " << vh.geographicalId() << "\n" diff --git a/DataFormats/TrackerRecHit2D/src/classes_def.xml b/DataFormats/TrackerRecHit2D/src/classes_def.xml index 2175ee0e8f371..bce22d6237c56 100644 --- a/DataFormats/TrackerRecHit2D/src/classes_def.xml +++ b/DataFormats/TrackerRecHit2D/src/classes_def.xml @@ -189,8 +189,8 @@ - - + + From 1e9919f9d68c5cf9d00a9befdb8c5f771d23abfe Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Thu, 8 Oct 2020 16:06:46 +0200 Subject: [PATCH 095/115] restore change overwritten in rebase --- .../src/Phase2OTBarrelRodBuilder.cc | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc index e73c2f45c93fe..eb0647209b786 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc @@ -26,36 +26,25 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 } meanR = meanR / allGeometricDets.size(); LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl; -<<<<<<< HEAD - - for(vector::const_iterator compGeometricDets=allGeometricDets.begin(); compGeometricDets!=allGeometricDets.end(); compGeometricDets++){ - const GeomDet* theGeomDet = theGeomDetGeometry->idToDet( (*compGeometricDets)->geographicalId() ); - - if( (*compGeometricDets)->positionBounds().perp() < meanR) -======= for (vector::const_iterator compGeometricDets = allGeometricDets.begin(); compGeometricDets != allGeometricDets.end(); compGeometricDets++) { - const GeomDet* theGeomDet = theGeomDetGeometry->idToDet((*compGeometricDets)->geographicalID()); + const GeomDet* theGeomDet = theGeomDetGeometry->idToDet((*compGeometricDets)->geographicalId()); if ((*compGeometricDets)->positionBounds().perp() < meanR) ->>>>>>> apply code checks innerGeomDets.push_back(theGeomDet); if ((*compGeometricDets)->positionBounds().perp() > meanR) outerGeomDets.push_back(theGeomDet); } -<<<<<<< HEAD -======= LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size(); LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size(); return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers); } else { ->>>>>>> apply code checks vector compGeometricDets; vector innerGeomDetBrothers; @@ -78,8 +67,8 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 for (auto& it : allGeometricDets) { compGeometricDets = it->components(); - const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets[0]->geographicalID()); - LogTrace("TkDetLayers") << " inserting " << compGeometricDets[0]->geographicalID().rawId() << std::endl; + const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets[0]->geographicalId()); + LogTrace("TkDetLayers") << " inserting " << compGeometricDets[0]->geographicalId().rawId() << std::endl; if (compGeometricDets[0]->positionBounds().perp() < meanR) innerGeomDets.push_back(theGeomDet); @@ -87,8 +76,8 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 if (compGeometricDets[0]->positionBounds().perp() > meanR) outerGeomDets.push_back(theGeomDet); - const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet(compGeometricDets[1]->geographicalID()); - LogTrace("TkDetLayers") << " inserting " << compGeometricDets[1]->geographicalID().rawId() << std::endl; + const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet(compGeometricDets[1]->geographicalId()); + LogTrace("TkDetLayers") << " inserting " << compGeometricDets[1]->geographicalId().rawId() << std::endl; if (compGeometricDets[1]->positionBounds().perp() < meanRBrothers) innerGeomDetBrothers.push_back(theGeomDetBrother); From 1fea02b95d21ad434657187542739d749d017054 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Fri, 9 Oct 2020 22:06:41 +0200 Subject: [PATCH 096/115] Slava's comments on DataFormats --- .../TrackerRecHit2D/interface/VectorHit.h | 43 +++---- .../TrackerRecHit2D/interface/VectorHit2D.h | 18 ++- .../TrackerRecHit2D/src/BaseTrackerRecHit.cc | 4 +- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 115 +++++------------- .../TrackerRecHit2D/src/classes_def.xml | 9 +- .../SiPhase2VectorHitBuilder/BuildFile.xml | 1 - .../interface/VectorHitBuilderAlgorithm.h | 17 ++- .../interface/VectorHitBuilderAlgorithmBase.h | 4 +- .../plugins/VectorHitBuilderEDProducer.cc | 16 +-- .../src/VectorHitBuilderAlgorithm.cc | 26 ++-- .../test/VectorHitsValidation.cc | 10 +- .../test/VectorHitsValidation.h | 4 +- .../interface/MeasurementTrackerEvent.h | 12 +- .../MeasurementTrackerEventProducer.cc | 8 +- .../plugins/MeasurementTrackerEventProducer.h | 4 +- .../plugins/SeedingOTEDProducer.cc | 24 ++-- .../TkSeedingLayers/src/HitExtractorSTRP.cc | 8 +- .../TkSeedingLayers/src/HitExtractorSTRP.h | 4 +- 18 files changed, 131 insertions(+), 196 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index f630031c21c7b..2ceebd2e5568a 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -29,14 +29,14 @@ class VectorHit final : public BaseTrackerRecHit { public: typedef OmniClusterRef::Phase2Cluster1DRef ClusterRef; - VectorHit() : thePosition(), theDirection(), theCovMatrix(), theDimension(0) { setType(bad); } + VectorHit() : thePosition(), theDirection(), theCovMatrix() { setType(bad); } - VectorHit(const VectorHit& vh); + //VectorHit(const VectorHit& vh); VectorHit(const GeomDet& idet, const LocalPoint& posInner, const LocalVector& dir, - const std::array, 4> covMatrix, + const AlgebraicSymMatrix44 covMatrix, const float chi2, OmniClusterRef const& lower, OmniClusterRef const& upper, @@ -53,36 +53,34 @@ class VectorHit final : public BaseTrackerRecHit { const float curvatureError, const float phi); - ~VectorHit() override; + ~VectorHit() override = default; VectorHit* clone() const override { return new VectorHit(*this); } RecHitPointer cloneSH() const override { return std::make_shared(*this); } bool sharesInput(const TrackingRecHit* other, SharedInputType what) const override; - bool sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedInputType what) const; + bool sharesClusters(VectorHit const& other, SharedInputType what) const; // Parameters of the segment, for the track fit // For a 4D segment: (dx/dz,dy/dz,x,y) bool hasPositionAndError() const override { - //if det is present pose&err are available as well. - //if det() is not present (null) the hit ihas been read from file and not updated + //if det is present pos&err are available as well. + //if det() is not present (null) the hit has been read from file and not updated return det(); }; - AlgebraicVector parameters() const override; void getKfComponents(KfComponentsHolder& holder) const override { getKfComponents4D(holder); } void getKfComponents4D(KfComponentsHolder& holder) const; // returning methods LocalPoint localPosition() const override { return thePosition; } virtual LocalVector localDirection() const { return theDirection; } - const std::array, 4> parametersErrorPlain() const; - AlgebraicSymMatrix parametersError() const override; + AlgebraicSymMatrix44 covMatrix() const; LocalError localPositionError() const override; - virtual LocalError localDirectionError() const; - Global3DVector globalDirection() const; + LocalError localDirectionError() const; + Global3DVector globalDirectionVH() const; - virtual float chi2() const { return theChi2; } + float chi2() const { return theChi2; } int dimension() const override { return theDimension; } float curvature() const { return theCurvature; } float curvatureError() const { return theCurvatureError; } @@ -111,22 +109,14 @@ class VectorHit final : public BaseTrackerRecHit { OmniClusterRef const& firstClusterRef() const override { return theLowerCluster; } ClusterRef cluster() const { return theLowerCluster.cluster_phase2OT(); } - //This method returns the delta in global coordinates - Global3DVector globalDelta() const; + //This method returns the direction of the segment/stub in global coordinates + Global3DVector globalDirection() const; float theta() const; - /// The projection matrix relates the trajectory state parameters to the segment parameters(). - AlgebraicMatrix projectionMatrix() const override; - // Access to component RecHits (if any) std::vector recHits() const override; std::vector recHits() override; - // setting methods - void setPosition(LocalPoint pos) { thePosition = pos; } - void setDirection(LocalVector dir) { theDirection = dir; } - void setCovMatrix(std::array, 4> mat) { theCovMatrix = mat; } - private: // double dispatch VectorHit* clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override { @@ -146,16 +136,15 @@ class VectorHit final : public BaseTrackerRecHit { // mat[3][3]=var(y) // mat[0][2]=cov(dx/dz,x) // mat[1][3]=cov(dy/dz,y) - std::array, 4> theCovMatrix; + AlgebraicSymMatrix44 theCovMatrix; float theChi2; - int theDimension; + static constexpr int theDimension = 4; OmniClusterRef theLowerCluster; OmniClusterRef theUpperCluster; float theCurvature; float theCurvatureError; float thePhi; - static constexpr int nComponents = 4; }; inline bool operator<(const VectorHit& one, const VectorHit& other) { return (one.chi2() < other.chi2()); } @@ -163,6 +152,6 @@ inline bool operator<(const VectorHit& one, const VectorHit& other) { return (on std::ostream& operator<<(std::ostream& os, const VectorHit& vh); typedef edmNew::DetSetVector VectorHitCollection; -typedef VectorHitCollection VectorHitCollectionNew; +//typedef VectorHitCollection VectorHitCollectionNew; #endif diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index ec0ad38f22f6a..fac5297b52c15 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -10,20 +10,18 @@ class VectorHit2D { public: - VectorHit2D() : thePosition(), theDirection(), theCovMatrix(), theChi2(), theDimension(2) {} - VectorHit2D(const LocalPoint& pos, const LocalVector& dir, const AlgebraicSymMatrix22& covMatrix, const double& Chi2) + VectorHit2D() : thePosition(), theDirection(), theCovMatrix(), theChi2() {} + VectorHit2D(const LocalPoint& pos, const LocalVector& dir, const AlgebraicSymMatrix22& covMatrix, const double& chi2) : thePosition(pos), theDirection(dir), theCovMatrix(covMatrix), theLocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]), - theChi2(Chi2), - theDimension(2){}; - virtual ~VectorHit2D(){}; + theChi2(chi2){}; - const LocalPoint* localPosition() const { return &thePosition; } - const LocalVector* localDirection() const { return &theDirection; } - const LocalError* localDirectionError() const { return &theLocalError; } - const AlgebraicSymMatrix22* covMatrix() const { return &theCovMatrix; } + const LocalPoint localPosition() const { return thePosition; } + const LocalVector localDirection() const { return theDirection; } + const LocalError localDirectionError() const { return theLocalError; } + const AlgebraicSymMatrix22 covMatrix() const { return theCovMatrix; } float chi2() const { return theChi2; } int dimension() const { return theDimension; } @@ -33,6 +31,6 @@ class VectorHit2D { AlgebraicSymMatrix22 theCovMatrix; LocalError theLocalError; float theChi2; - int theDimension; + static constexpr int theDimension = 2; }; #endif diff --git a/DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc b/DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc index 672b3aeb55e6d..35aca8a3339c8 100644 --- a/DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc +++ b/DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc @@ -27,8 +27,8 @@ void BaseTrackerRecHit::check() const { #endif bool BaseTrackerRecHit::hasPositionAndError() const { - //if det is present pose&err are available as well. - // //if det() is not present (null) the hit ihas been read from file and not updated + //if det is present pos&err are available as well. + // //if det() is not present (null) the hit has been read from file and not updated return det(); } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index de77a333393b1..cab98d2f00909 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -2,23 +2,10 @@ #include "Geometry/CommonDetUnit/interface/StackGeomDet.h" #include "CLHEP/Units/PhysicalConstants.h" -VectorHit::VectorHit(const VectorHit& vh) - : BaseTrackerRecHit(*vh.det(), trackerHitRTTI::vector), - thePosition(vh.localPosition()), - theDirection(vh.localDirection()), - theCovMatrix(vh.parametersErrorPlain()), - theChi2(vh.chi2()), - theDimension(vh.dimension()), - theLowerCluster(vh.lowerClusterRef()), - theUpperCluster(vh.upperClusterRef()), - theCurvature(vh.curvature()), - theCurvatureError(vh.curvatureError()), - thePhi(vh.phi()) {} - VectorHit::VectorHit(const GeomDet& idet, const LocalPoint& posLower, const LocalVector& dir, - const std::array, 4> covMatrix, + const AlgebraicSymMatrix44 covMatrix, const float chi2, OmniClusterRef const& lower, OmniClusterRef const& upper, @@ -30,7 +17,6 @@ VectorHit::VectorHit(const GeomDet& idet, theDirection(dir), theCovMatrix(covMatrix), theChi2(chi2), - theDimension(4), theLowerCluster(lower), theUpperCluster(upper), theCurvature(curvature), @@ -46,27 +32,23 @@ VectorHit::VectorHit(const GeomDet& idet, const float curvatureError, const float phi) : BaseTrackerRecHit(idet, trackerHitRTTI::vector), - theDimension(vh2Dzx.dimension() + vh2Dzy.dimension()), + thePosition(LocalPoint(vh2Dzx.localPosition().x(), vh2Dzy.localPosition().x(), 0.)), + theDirection(LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), 1.)), theLowerCluster(lower), theUpperCluster(upper), theCurvature(curvature), theCurvatureError(curvatureError), thePhi(phi) { - thePosition = LocalPoint(vh2Dzx.localPosition()->x(), vh2Dzy.localPosition()->x(), 0.); +// thePosition = LocalPoint(vh2Dzx.localPosition().x(), vh2Dzy.localPosition().x(), 0.); - theDirection = LocalVector(vh2Dzx.localDirection()->x(), vh2Dzy.localDirection()->x(), 1.); +// theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), 1.); //building the cov matrix 4x4 starting from the 2x2 - const AlgebraicSymMatrix22 covMatZX = *vh2Dzx.covMatrix(); - const AlgebraicSymMatrix22 covMatZY = *vh2Dzy.covMatrix(); + const AlgebraicSymMatrix22 covMatZX = vh2Dzx.covMatrix(); + const AlgebraicSymMatrix22 covMatZY = vh2Dzy.covMatrix(); - for (int i = 0; i < nComponents; i++) { - for (int j = 0; j < nComponents; j++) { - theCovMatrix[i][j] = 0.; - } - } + theCovMatrix = AlgebraicSymMatrix44(); - //theCovMatrix = AlgebraicSymMatrix(nComponents); theCovMatrix[0][0] = covMatZX[0][0]; // var(dx/dz) theCovMatrix[1][1] = covMatZY[0][0]; // var(dy/dz) theCovMatrix[2][2] = covMatZX[1][1]; // var(x) @@ -86,7 +68,7 @@ bool VectorHit::sharesInput(const TrackingRecHit* other, SharedInputType what) c if (trackerHitRTTI::isVector(*other)) { const VectorHit* otherVh = static_cast(other); - return sharesClusters(*this, *otherVh, what); + return sharesClusters(*otherVh, what); } if (what == all) @@ -97,59 +79,41 @@ bool VectorHit::sharesInput(const TrackingRecHit* other, SharedInputType what) c return (otherClus == lowerClusterRef()) || (otherClus == upperClusterRef()); } -bool VectorHit::sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedInputType what) const { - bool lower = h1.lowerClusterRef() == h2.lowerClusterRef(); - bool upper = h1.upperClusterRef() == h2.upperClusterRef(); +bool VectorHit::sharesClusters(VectorHit const& other, SharedInputType what) const { + bool lower = this->lowerClusterRef() == other.lowerClusterRef(); + bool upper = this->upperClusterRef() == other.upperClusterRef(); return (what == TrackingRecHit::all) ? (lower && upper) : (upper || lower); } void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const { - AlgebraicVector4& pars = holder.params(); + AlgebraicVector4& pars = holder.params(); pars[0] = theDirection.x(); pars[1] = theDirection.y(); pars[2] = thePosition.x(); pars[3] = thePosition.y(); - AlgebraicSymMatrix44& errs = holder.errors(); - for (int i = 0; i < nComponents; i++) { - for (int j = 0; j < nComponents; j++) { - errs(i, j) = theCovMatrix[i][j]; - } - } + holder.errors() = theCovMatrix; - ProjectMatrix& pf = holder.projFunc(); + ProjectMatrix& pf = holder.projFunc(); pf.index[0] = 1; pf.index[1] = 2; pf.index[2] = 3; - pf.index[3] = 4; - - holder.measuredParams() = AlgebraicVector4(&holder.tsosLocalParameters().At(1), nComponents); - holder.measuredErrors() = holder.tsosLocalErrors().Sub(1, 1); -} - -VectorHit::~VectorHit() {} - -AlgebraicVector VectorHit::parameters() const { - // (dx/dz,dy/dz,x,y) - AlgebraicVector result(nComponents); + pf.index[3] = 4; - result[0] = theDirection.x(); - result[1] = theDirection.y(); - result[2] = thePosition.x(); - result[3] = thePosition.y(); - return result; + holder.measuredParams() = AlgebraicVector4(&holder.tsosLocalParameters().At(1), theDimension); + holder.measuredErrors() = holder.tsosLocalErrors().Sub(1, 1); } Global3DPoint VectorHit::lowerGlobalPos() const { - const StackGeomDet* stackDet = dynamic_cast(det()); - const PixelGeomDetUnit* geomDetLower = dynamic_cast(stackDet->lowerDet()); + const StackGeomDet* stackDet = static_cast(det()); + const PixelGeomDetUnit* geomDetLower = static_cast(stackDet->lowerDet()); return phase2clusterGlobalPos(geomDetLower, lowerCluster()); } Global3DPoint VectorHit::upperGlobalPos() const { - const StackGeomDet* stackDet = dynamic_cast(det()); - const PixelGeomDetUnit* geomDetUpper = dynamic_cast(stackDet->upperDet()); + const StackGeomDet* stackDet = static_cast(det()); + const PixelGeomDetUnit* geomDetUpper = static_cast(stackDet->upperDet()); return phase2clusterGlobalPos(geomDetUpper, upperCluster()); } @@ -163,14 +127,14 @@ Global3DPoint VectorHit::phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, } GlobalError VectorHit::lowerGlobalPosErr() const { - const StackGeomDet* stackDet = dynamic_cast(det()); - const PixelGeomDetUnit* geomDetLower = dynamic_cast(stackDet->lowerDet()); + const StackGeomDet* stackDet = static_cast(det()); + const PixelGeomDetUnit* geomDetLower = static_cast(stackDet->lowerDet()); return phase2clusterGlobalPosErr(geomDetLower); } GlobalError VectorHit::upperGlobalPosErr() const { - const StackGeomDet* stackDet = dynamic_cast(det()); - const PixelGeomDetUnit* geomDetUpper = dynamic_cast(stackDet->upperDet()); + const StackGeomDet* stackDet = static_cast(det()); + const PixelGeomDetUnit* geomDetUpper = static_cast(stackDet->upperDet()); return phase2clusterGlobalPosErr(geomDetUpper); } @@ -184,7 +148,7 @@ GlobalError VectorHit::phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet return ge; } -Global3DVector VectorHit::globalDelta() const { +Global3DVector VectorHit::globalDirectionVH() const { Local3DVector theLocalDelta = LocalVector(theDirection.x() * theDirection.z(), theDirection.y() * theDirection.z(), theDirection.z()); Global3DVector g = det()->surface().toGlobal(theLocalDelta); @@ -200,12 +164,6 @@ float VectorHit::transverseMomentum(float magField) const { } // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, using precise value from speed of light float VectorHit::momentum(float magField) const { return transverseMomentum(magField) / (1. * sin(theta())); } -AlgebraicMatrix VectorHit::projectionMatrix() const { - // obsolete (for what tracker is concerned...) interface - static const AlgebraicMatrix the4DProjectionMatrix(nComponents, 5, 0); - return the4DProjectionMatrix; -} - LocalError VectorHit::localPositionError() const { return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]); } @@ -214,17 +172,7 @@ LocalError VectorHit::localDirectionError() const { return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); } -const std::array, 4> VectorHit::parametersErrorPlain() const { return theCovMatrix; } - -AlgebraicSymMatrix VectorHit::parametersError() const { - AlgebraicSymMatrix result(nComponents); - for (int i = 0; i < nComponents; i++) { - for (int j = 0; j < nComponents; j++) { - result[i][j] = theCovMatrix[i][j]; - } - } - return result; -} +AlgebraicSymMatrix44 VectorHit::covMatrix() const { return theCovMatrix; } std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { os << " VectorHit create in the DetId#: " << vh.geographicalId() << "\n" @@ -239,12 +187,11 @@ std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { /// Access to component RecHits (if any) std::vector VectorHit::recHits() const { - std::vector pointersOfRecHits; - return pointersOfRecHits; + return {}; } /// Non-const access to component RecHits (if any) std::vector VectorHit::recHits() { - std::vector pointersOfRecHits; - return pointersOfRecHits; + return {}; } + diff --git a/DataFormats/TrackerRecHit2D/src/classes_def.xml b/DataFormats/TrackerRecHit2D/src/classes_def.xml index bce22d6237c56..5de054ebdfa8f 100644 --- a/DataFormats/TrackerRecHit2D/src/classes_def.xml +++ b/DataFormats/TrackerRecHit2D/src/classes_def.xml @@ -189,18 +189,17 @@ - - + + - - + + - diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml b/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml index c5630c284bb8a..67dc8d580bb3d 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/BuildFile.xml @@ -4,7 +4,6 @@ - diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 376382eb04853..3333c29804915 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -21,11 +21,11 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { const TrackerTopology* tkTopoProd, const ClusterParameterEstimator* cpeProd) : VectorHitBuilderAlgorithmBase(conf, tkGeomProd, tkTopoProd, cpeProd){}; - ~VectorHitBuilderAlgorithm() override{}; + ~VectorHitBuilderAlgorithm() override = default; void run(edm::Handle> clusters, - VectorHitCollectionNew& vhAcc, - VectorHitCollectionNew& vhRej, + VectorHitCollection& vhAcc, + VectorHitCollection& vhRej, edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej) const override; @@ -37,11 +37,11 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { Local3DPoint& posouter, LocalError& errinner, LocalError& errouter) const; - - std::pair, float> curvatureANDphi(Global3DPoint gPositionLower, - Global3DPoint gPositionUpper, - GlobalError gErrorLower, - GlobalError gErrorUpper) const; + struct CurvatureAndPhi { float curvature; float curvatureError; float phi; }; + CurvatureAndPhi curvatureANDphi(Global3DPoint gPositionLower, + Global3DPoint gPositionUpper, + GlobalError gErrorLower, + GlobalError gErrorUpper) const; std::vector> buildVectorHits( const StackGeomDet* stack, @@ -79,7 +79,6 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { AlgebraicSymMatrix22& covMatrix, double& chi2) const; -private: }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index 129163541880d..bd0e331e191ab 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -31,8 +31,8 @@ class VectorHitBuilderAlgorithmBase { //FIXME::ERICA::this should be template, return different collection for different algo used!! virtual void run(edm::Handle> clusters, - VectorHitCollectionNew& vhAcc, - VectorHitCollectionNew& vhRej, + VectorHitCollection& vhAcc, + VectorHitCollection& vhRej, edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej) const = 0; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc index 97f89f85e14e8..35ecdb8ba418e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -21,8 +21,8 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { void run(edm::Handle> clusters, edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, - VectorHitCollectionNew& outputAcc, - VectorHitCollectionNew& outputRej); + VectorHitCollection& outputAcc, + VectorHitCollection& outputRej); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); const VectorHitBuilderAlgorithm* algo() const { return stubsBuilder_; }; @@ -45,8 +45,8 @@ VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& produces>("ClustersAccepted"); produces>("ClustersRejected"); - produces(offlinestubsTag_ + "Accepted"); - produces(offlinestubsTag_ + "Rejected"); + produces(offlinestubsTag_ + "Accepted"); + produces(offlinestubsTag_ + "Rejected"); } void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { @@ -61,8 +61,8 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu new edmNew::DetSetVector); std::unique_ptr> outputClustersRejected( new edmNew::DetSetVector); - std::unique_ptr outputVHAccepted(new VectorHitCollectionNew()); - std::unique_ptr outputVHRejected(new VectorHitCollectionNew()); + std::unique_ptr outputVHAccepted(new VectorHitCollection()); + std::unique_ptr outputVHRejected(new VectorHitCollection()); stubsBuilder_ = &es.getData(stubsBuilderToken_); // check on the input clusters @@ -91,8 +91,8 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu void VectorHitBuilderEDProducer::run(edm::Handle> clusters, edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej, - VectorHitCollectionNew& outputAcc, - VectorHitCollectionNew& outputRej) { + VectorHitCollection& outputAcc, + VectorHitCollection& outputRej) { stubsBuilder_->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej); } void VectorHitBuilderEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index b0b2842d7ba28..86757833c3b5c 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -5,8 +5,8 @@ #include "DataFormats/TrackerRecHit2D/interface/VectorHit2D.h" void VectorHitBuilderAlgorithm::run(edm::Handle> clusters, - VectorHitCollectionNew& vhAcc, - VectorHitCollectionNew& vhRej, + VectorHitCollection& vhAcc, + VectorHitCollection& vhRej, edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej) const { LogDebug("VectorHitBuilderAlgorithm") << "Run VectorHitBuilderAlgorithm ... \n"; @@ -315,15 +315,15 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetLower); } - const auto& curvatureAndPhi = curvatureANDphi(gPositionLower, gPositionUpper, gErrorLower, gErrorUpper); + const CurvatureAndPhi curvatureAndPhi = curvatureANDphi(gPositionLower, gPositionUpper, gErrorLower, gErrorUpper); VectorHit vh = VectorHit(*stack, vh2Dzx, vh2Dzy, lowerOmni, upperOmni, - curvatureAndPhi.first.first, - curvatureAndPhi.first.second, - curvatureAndPhi.second); + curvatureAndPhi.curvature, + curvatureAndPhi.curvatureError, + curvatureAndPhi.phi); return vh; } @@ -399,10 +399,12 @@ void VectorHitBuilderAlgorithm::fit(float x[2], dir = LocalVector(slope, 0., slopeZ); } -std::pair, float> VectorHitBuilderAlgorithm::curvatureANDphi(Global3DPoint gPositionLower, +VectorHitBuilderAlgorithm::CurvatureAndPhi VectorHitBuilderAlgorithm::curvatureANDphi(Global3DPoint gPositionLower, Global3DPoint gPositionUpper, GlobalError gErrorLower, GlobalError gErrorUpper) const { + VectorHitBuilderAlgorithm::CurvatureAndPhi result; + float curvature = -999.; float errorCurvature = -999.; float phi = -999.; @@ -540,8 +542,10 @@ std::pair, float> VectorHitBuilderAlgorithm::curvatureAN errorCurvature = temp[0] * curvatureJacobian[0] + temp[1] * curvatureJacobian[1] + temp[2] * curvatureJacobian[2] + temp[3] * curvatureJacobian[3]; - } else { - return std::make_pair(std::make_pair(0., 0.), 0.0); - } - return std::make_pair(std::make_pair(curvature, errorCurvature), phi); + } + + result.curvature = curvature; + result.curvatureError = errorCurvature; + result.phi = phi; + return result; } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc index 47d53e0f82dda..18d0f87e7ece4 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc @@ -12,8 +12,8 @@ VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet : cpeTag_(conf.getParameter("CPE")) { srcClu_ = consumes >(edm::InputTag(conf.getParameter("src"))); - VHacc_ = consumes(edm::InputTag(conf.getParameter("VH_acc"))); - VHrej_ = consumes(edm::InputTag(conf.getParameter("VH_rej"))); + VHacc_ = consumes(edm::InputTag(conf.getParameter("VH_acc"))); + VHrej_ = consumes(edm::InputTag(conf.getParameter("VH_rej"))); siphase2OTSimLinksToken_ = consumes >(conf.getParameter("links")); simHitsToken_ = consumes(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof")); simTracksToken_ = consumes(edm::InputTag("g4SimHits")); @@ -96,10 +96,10 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev event.getByToken(srcClu_, clusters); // Get the vector hits - edm::Handle vhsAcc; + edm::Handle vhsAcc; event.getByToken(VHacc_, vhsAcc); - edm::Handle vhsRej; + edm::Handle vhsRej; event.getByToken(VHrej_, vhsRej); // load the cpe via the eventsetup @@ -354,7 +354,7 @@ void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::Ev LogTrace("VectorHitsBuilderValidation") << "local VH direction " << localDirVH << std::endl; VectorHit vh = vhIt; - Global3DVector globalDirVH = vh.globalDelta(); + Global3DVector globalDirVH = vh.globalDirectionVH(); dirVHs.push_back(globalDirVH); LogTrace("VectorHitsBuilderValidation") << "global VH direction " << globalDirVH << std::endl; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h index 3ce33868d1bdd..66ca71f0d46a7 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h @@ -110,8 +110,8 @@ class VectorHitsBuilderValidation : public edm::one::EDAnalyzer > srcClu_; - edm::EDGetTokenT VHacc_; - edm::EDGetTokenT VHrej_; + edm::EDGetTokenT VHacc_; + edm::EDGetTokenT VHrej_; edm::ESInputTag cpeTag_; const ClusterParameterEstimator* cpe_; diff --git a/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h b/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h index 29f669f731b05..a7cf35cbab0cb 100644 --- a/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h +++ b/RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h @@ -26,8 +26,8 @@ class MeasurementTrackerEvent { const StMeasurementDetSet *strips, const PxMeasurementDetSet *pixels, const Phase2OTMeasurementDetSet *phase2OT, - const VectorHitCollectionNew *phase2OTVectorHits, - const VectorHitCollectionNew *phase2OTVectorHitsRej, + const VectorHitCollection *phase2OTVectorHits, + const VectorHitCollection *phase2OTVectorHitsRej, const std::vector &stripClustersToSkip, const std::vector &pixelClustersToSkip, const std::vector &phase2OTClustersToSkip) @@ -62,8 +62,8 @@ class MeasurementTrackerEvent { const StMeasurementDetSet &stripData() const { return *theStripData; } const PxMeasurementDetSet &pixelData() const { return *thePixelData; } const Phase2OTMeasurementDetSet &phase2OTData() const { return *thePhase2OTData; } - const VectorHitCollectionNew &phase2OTVectorHits() const { return *thePhase2OTVectorHits; } - const VectorHitCollectionNew &phase2OTVectorHitsRej() const { return *thePhase2OTVectorHitsRej; } + const VectorHitCollection &phase2OTVectorHits() const { return *thePhase2OTVectorHits; } + const VectorHitCollection &phase2OTVectorHitsRej() const { return *thePhase2OTVectorHitsRej; } const std::vector &stripClustersToSkip() const { return theStripClustersToSkip; } const std::vector &pixelClustersToSkip() const { return thePixelClustersToSkip; } const std::vector &phase2OTClustersToSkip() const { return thePhase2OTClustersToSkip; } @@ -80,8 +80,8 @@ class MeasurementTrackerEvent { const StMeasurementDetSet *theStripData = nullptr; const PxMeasurementDetSet *thePixelData = nullptr; const Phase2OTMeasurementDetSet *thePhase2OTData = nullptr; - const VectorHitCollectionNew *thePhase2OTVectorHits = nullptr; - const VectorHitCollectionNew *thePhase2OTVectorHitsRej = nullptr; + const VectorHitCollection *thePhase2OTVectorHits = nullptr; + const VectorHitCollection *thePhase2OTVectorHitsRej = nullptr; bool theOwner = false; // do I own the tree above? // these could be const pointers as well, but ContainerMask doesn't expose the vector std::vector theStripClustersToSkip; diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc index 8d9f0343ee003..0b744c7733b3a 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc @@ -63,8 +63,8 @@ MeasurementTrackerEventProducer::MeasurementTrackerEventProducer(const edm::Para } if (!(iConfig.getParameter("vectorHits") == edm::InputTag("") || iConfig.getParameter("vectorHitsRej") == edm::InputTag(""))) { - thePh2OTVectorHitsLabel = consumes(iConfig.getParameter("vectorHits")); - thePh2OTVectorHitsRejLabel = consumes(iConfig.getParameter("vectorHitsRej")); + thePh2OTVectorHitsLabel = consumes(iConfig.getParameter("vectorHits")); + thePh2OTVectorHitsRejLabel = consumes(iConfig.getParameter("vectorHitsRej")); isPhase2_ = true; useVectorHits_ = true; } @@ -125,8 +125,8 @@ void MeasurementTrackerEventProducer::produce(edm::Event& iEvent, const edm::Eve // put into event // - const VectorHitCollectionNew* phase2OTVectorHits = useVectorHits_ ? &iEvent.get(thePh2OTVectorHitsLabel) : nullptr; - const VectorHitCollectionNew* phase2OTVectorHitsRej = + const VectorHitCollection* phase2OTVectorHits = useVectorHits_ ? &iEvent.get(thePh2OTVectorHitsLabel) : nullptr; + const VectorHitCollection* phase2OTVectorHitsRej = useVectorHits_ ? &iEvent.get(thePh2OTVectorHitsRejLabel) : nullptr; iEvent.put(std::make_unique(*measurementTracker, stripData.release(), diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h index 02fd476d71092..53ee67905c456 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.h @@ -41,8 +41,8 @@ class dso_hidden MeasurementTrackerEventProducer final : public edm::stream::EDP edm::EDGetTokenT> thePixelClusterLabel; edm::EDGetTokenT> theStripClusterLabel; edm::EDGetTokenT> thePh2OTClusterLabel; - edm::EDGetTokenT thePh2OTVectorHitsLabel; - edm::EDGetTokenT thePh2OTVectorHitsRejLabel; + edm::EDGetTokenT thePh2OTVectorHitsLabel; + edm::EDGetTokenT thePh2OTVectorHitsRejLabel; edm::EDGetTokenT>> thePixelClusterMask; edm::EDGetTokenT>> theStripClusterMask; diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index f63181ca281af..d9045290f30bb 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -42,12 +42,12 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { static void fillDescriptions(edm::ConfigurationDescriptions&); - TrajectorySeedCollection run(edm::Handle); + TrajectorySeedCollection run(edm::Handle); unsigned int checkLayer(unsigned int iidd); std::vector collectVHsOnLayer(const edmNew::DetSetVector&, unsigned int); void printVHsOnLayer(const edmNew::DetSetVector&, unsigned int); const TrajectoryStateOnSurface buildInitialTSOS(const VectorHit&) const; - AlgebraicSymMatrix assign44To55(AlgebraicSymMatrix) const; + AlgebraicSymMatrix55 assign44To55(AlgebraicSymMatrix44) const; std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, const Propagator&, const TrackingRecHit& hit) const; @@ -70,7 +70,7 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { }; private: - edm::EDGetTokenT vhProducerToken_; + edm::EDGetTokenT vhProducerToken_; const TrackerTopology* tkTopo_; const MeasurementTracker* measurementTracker_; std::unique_ptr layerMeasurements_; @@ -100,7 +100,7 @@ SeedingOTEDProducer::SeedingOTEDProducer(edm::ParameterSet const& conf) updatorToken_(esConsumes(edm::ESInputTag("", "KFUpdator"))), measurementTrackerToken_(esConsumes()), estToken_(esConsumes(edm::ESInputTag("", "Chi2"))) { - vhProducerToken_ = consumes(edm::InputTag(conf.getParameter("src"))); + vhProducerToken_ = consumes(edm::InputTag(conf.getParameter("src"))); beamSpotToken_ = consumes(conf.getParameter("beamSpotLabel")); updatorName_ = conf.getParameter("updator"); putToken_ = produces(); @@ -143,13 +143,13 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) } // Get the vector hits - edm::Handle vhs; + edm::Handle vhs; event.getByToken(vhProducerToken_, vhs); event.emplace(putToken_, run(vhs)); } -TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { +TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { TrajectorySeedCollection result; //check if all the first three layers have VHs std::vector vhSeedsL1 = collectVHsOnLayer(*VHs.product(), 1); @@ -313,24 +313,24 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto float signPz = copysign(1.0, vHit.globalPosition().z()); LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); - AlgebraicSymMatrix mat = assign44To55(vHit.parametersError()); + AlgebraicSymMatrix55 mat = assign44To55(vHit.covMatrix()); // set the error on 1/p mat[0][0] = pow(computeInverseMomentumError( vHit, theta, beamSpot_->sigmaZ(), vHit.transverseMomentum(magField_->inTesla(center).z())), 2); //building tsos - LocalTrajectoryError lterr(asSMatrix<5>(mat)); + LocalTrajectoryError lterr(mat); const TrajectoryStateOnSurface tsos(ltpar2, lterr, vHit.det()->surface(), magField_); return tsos; } -AlgebraicSymMatrix SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix mat44) const { - if (mat44.num_row() != 4 || mat44.num_col() != 4) - assert("Wrong dimension! This should be a 4x4 matrix!"); +AlgebraicSymMatrix55 SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix44 mat44) const { +// if (mat44.num_row() != 4 || mat44.num_col() != 4) +// assert("Wrong dimension! This should be a 4x4 matrix!"); - AlgebraicSymMatrix result(5, 0); + AlgebraicSymMatrix55 result; for (int i = 1; i < 5; i++) { for (int j = 1; j < 5; j++) { result[i][j] = mat44[i - 1][j - 1]; diff --git a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc index f93d4eedc55e7..65aac0eaa406e 100644 --- a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc +++ b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc @@ -239,7 +239,7 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder if (hasVectorHits) { LogError("HitExtractorSTRP") << "TIB is not supposed to be in Phase2 TRK detector configuration. What follows " "have never been checked before! "; - edm::Handle vectorHits; + edm::Handle vectorHits; ev.getByToken(theVectorHits, vectorHits); if (skipClusters) cleanFrom = result.size(); @@ -314,7 +314,7 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder } if (hasVectorHits) { LogTrace("HitExtractorSTRP") << "Getting vector hits for IdLayer " << theIdLayer; - edm::Handle vectorHits; + edm::Handle vectorHits; ev.getByToken(theVectorHits, vectorHits); //FIXME: check the skipClusters with VHits if (skipClusters) @@ -390,7 +390,7 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder } if (hasVectorHits) { LogTrace("HitExtractorSTRP") << "Getting vector hits for IdLayer " << theIdLayer; - edm::Handle vectorHits; + edm::Handle vectorHits; ev.getByToken(theVectorHits, vectorHits); //FIXME: check the skipClusters with VHits if (skipClusters) @@ -467,7 +467,7 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder if (hasVectorHits) { LogError("HitExtractorSTRP") << "TEC is not supposed to be in Phase2 TRK detector configuration. What follows " "have never been checked before! "; - edm::Handle vectorHits; + edm::Handle vectorHits; ev.getByToken(theVectorHits, vectorHits); if (skipClusters) cleanFrom = result.size(); diff --git a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.h b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.h index 7d6852c30c53d..e92b2e3646fac 100644 --- a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.h +++ b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.h @@ -48,7 +48,7 @@ namespace ctfseeding { void useVectorHits(const edm::InputTag& m, edm::ConsumesCollector& iC) { hasVectorHits = true; - theVectorHits = iC.consumes(m); + theVectorHits = iC.consumes(m); } void useRingSelector(int minRing, int maxRing); void useSimpleRphiHitsCleaner(bool use) { hasSimpleRphiHitsCleaner = use; } @@ -92,7 +92,7 @@ namespace ctfseeding { edm::EDGetTokenT theMatchedHits; edm::EDGetTokenT theRPhiHits; edm::EDGetTokenT theStereoHits; - edm::EDGetTokenT theVectorHits; + edm::EDGetTokenT theVectorHits; bool hasMatchedHits; bool hasRPhiHits; bool hasStereoHits; From 946eb905f7d036217cc6437eb23a534ab2d18240 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Fri, 9 Oct 2020 22:58:51 +0200 Subject: [PATCH 097/115] intermediate commit of Slava's comments --- .../interface/VectorHitBuilderAlgorithmBase.h | 13 ++--- .../plugins/VectorHitBuilderEDProducer.cc | 47 +++++++++---------- .../src/VectorHitBuilderAlgorithm.cc | 45 +++++++++--------- .../src/VectorHitBuilderAlgorithmBase.cc | 22 ++++----- .../test/VHs_combinatorialStudies_PU200.py | 4 +- .../test/VHs_productionAndTesting.py | 4 +- .../python/PixelLessStep_cff.py | 4 +- .../MeasurementTrackerEventProducer_cfi.py | 4 +- .../plugins/SeedingOTEDProducer.cc | 2 +- 9 files changed, 72 insertions(+), 73 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index bd0e331e191ab..8876fd85d95bc 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -58,12 +58,13 @@ class VectorHitBuilderAlgorithmBase { void loadDetSetVector(std::unordered_map>& theMap, edmNew::DetSetVector& theCollection) const; - const TrackerGeometry* theTkGeom; - const TrackerTopology* theTkTopo; - const ClusterParameterEstimator* theCpe; - unsigned int nMaxVHforeachStack; - std::vector barrelCut; - std::vector endcapCut; + const TrackerGeometry* tkGeom_; + const TrackerTopology* tkTopo_; + const ClusterParameterEstimator* cpe_; + unsigned int nMaxVHforeachStack_; + std::vector barrelCut_; + std::vector endcapCut_; + private: edm::ESInputTag cpeTag_; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc index 35ecdb8ba418e..59a065f834c8e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -10,13 +10,13 @@ #include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" #include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" -#include -#include +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { public: explicit VectorHitBuilderEDProducer(const edm::ParameterSet&); - ~VectorHitBuilderEDProducer() override; + ~VectorHitBuilderEDProducer() override = default; void produce(edm::Event&, const edm::EventSetup&) override; void run(edm::Handle> clusters, edmNew::DetSetVector& clustersAcc, @@ -24,7 +24,7 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { VectorHitCollection& outputAcc, VectorHitCollection& outputRej); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - const VectorHitBuilderAlgorithm* algo() const { return stubsBuilder_; }; + const VectorHitBuilderAlgorithm* algo() const { return stubsBuilder_; } private: const VectorHitBuilderAlgorithm* stubsBuilder_; @@ -34,8 +34,6 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT> clusterProducer_; }; -VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() {} - VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf) : offlinestubsTag_(conf.getParameter("offlinestubs")), maxOfflinestubs_(conf.getParameter("maxVectorHits")), @@ -43,24 +41,20 @@ VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& clusterProducer_ = consumes>(edm::InputTag(conf.getParameter("Clusters"))); - produces>("ClustersAccepted"); - produces>("ClustersRejected"); - produces(offlinestubsTag_ + "Accepted"); - produces(offlinestubsTag_ + "Rejected"); + produces>("accepted"); + produces>("rejected"); + produces("accepted"); + produces("rejected"); } void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) { LogDebug("VectorHitBuilderEDProducer") << "VectorHitBuilderEDProducer::produce() begin"; // get input clusters data - edm::Handle> clustersHandle; - event.getByToken(clusterProducer_, clustersHandle); - + auto clustersHandle = event.getHandle(clusterProducer_); // create the final output collection - std::unique_ptr> outputClustersAccepted( - new edmNew::DetSetVector); - std::unique_ptr> outputClustersRejected( - new edmNew::DetSetVector); + auto outputClustersAccepted = std::make_unique >(); + auto outputClustersRejected = std::make_unique >(); std::unique_ptr outputVHAccepted(new VectorHitCollection()); std::unique_ptr outputVHRejected(new VectorHitCollection()); @@ -71,21 +65,22 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu // running the stub building algorithm //ERICA::output should be moved in the different algo classes? run(clustersHandle, *outputClustersAccepted, *outputClustersRejected, *outputVHAccepted, *outputVHRejected); - +#ifdef EDM_ML_DEBUG unsigned int numberOfVectorHits = 0; - for (const auto& DSViter : *outputVHAccepted) { - for (const auto& vh : DSViter) { + for (const auto& dSViter : *outputVHAccepted) { + for (const auto& vh : dSViter) { numberOfVectorHits++; - LogDebug("VectorHitBuilderEDProducer") << "\t vectorhit in output " << vh << std::endl; + LogDebug("VectorHitBuilderEDProducer") << "\t vectorhit in output " << vh; } } + LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n"; +#endif //EDM_ML_DEBUG // write output to file - event.put(std::move(outputClustersAccepted), "ClustersAccepted"); - event.put(std::move(outputClustersRejected), "ClustersRejected"); - event.put(std::move(outputVHAccepted), offlinestubsTag_ + "Accepted"); - event.put(std::move(outputVHRejected), offlinestubsTag_ + "Rejected"); + event.put(std::move(outputClustersAccepted), "accepted"); + event.put(std::move(outputClustersRejected), "rejected"); + event.put(std::move(outputVHAccepted), "accepted"); + event.put(std::move(outputVHRejected), "rejected"); - LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n"; } void VectorHitBuilderEDProducer::run(edm::Handle> clusters, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 86757833c3b5c..f34773a4e9fa2 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -10,23 +10,23 @@ void VectorHitBuilderAlgorithm::run(edm::Handle& clustersAcc, edmNew::DetSetVector& clustersRej) const { LogDebug("VectorHitBuilderAlgorithm") << "Run VectorHitBuilderAlgorithm ... \n"; - const edmNew::DetSetVector* ClustersPhase2Collection = clusters.product(); + const auto* clustersPhase2Collection = clusters.product(); std::unordered_map> tempVHAcc, tempVHRej; //loop over the DetSetVector - LogDebug("VectorHitBuilderAlgorithm") << "with #clusters : " << ClustersPhase2Collection->size() << std::endl; - for (auto DSViter : *ClustersPhase2Collection) { - unsigned int rawDetId1(DSViter.detId()); + LogDebug("VectorHitBuilderAlgorithm") << "with #clusters : " << clustersPhase2Collection->size() << std::endl; + for (auto dSViter : *clustersPhase2Collection) { + unsigned int rawDetId1(dSViter.detId()); DetId detId1(rawDetId1); DetId lowerDetId, upperDetId; - if (theTkTopo->isLower(detId1)) { + if (tkTopo_->isLower(detId1)) { lowerDetId = detId1; - upperDetId = theTkTopo->partnerDetId(detId1); - } else if (theTkTopo->isUpper(detId1)) { + upperDetId = tkTopo_->partnerDetId(detId1); + } else continue; - } - DetId detIdStack = theTkTopo->stack(detId1); + + DetId detIdStack = tkTopo_->stack(detId1); //debug LogDebug("VectorHitBuilderAlgorithm") << " DetId stack : " << detIdStack.rawId() << std::endl; @@ -35,15 +35,18 @@ void VectorHitBuilderAlgorithm::run(edm::Handlefind(lowerDetId); - const auto& it_detUpper = ClustersPhase2Collection->find(upperDetId); + //const auto& it_detLower = clustersPhase2Collection->find(lowerDetId); + const auto& it_detLower = dSViter; + const auto& it_detUpper = clustersPhase2Collection->find(upperDetId); - if (it_detLower != ClustersPhase2Collection->end() && it_detUpper != ClustersPhase2Collection->end()) { - gd = theTkGeom->idToDet(detIdStack); + //if (it_detLower != clustersPhase2Collection->end() && it_detUpper != clustersPhase2Collection->end()) { + if (it_detUpper != clustersPhase2Collection->end()) { + gd = tkGeom_->idToDet(detIdStack); stackDet = dynamic_cast(gd); std::vector vhsInStack_Acc; std::vector vhsInStack_Rej; - const auto& vhsInStack_AccRej = buildVectorHits(stackDet, clusters, *it_detLower, *it_detUpper); + //const auto& vhsInStack_AccRej = buildVectorHits(stackDet, clusters, *it_detLower, *it_detUpper); + const auto& vhsInStack_AccRej = buildVectorHits(stackDet, clusters, it_detLower, *it_detUpper); //storing accepted and rejected VHs for (const auto& vh : vhsInStack_AccRej) { @@ -134,7 +137,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo(clusters, ciu); const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); localGDUUpper.push_back(gduUpp); - localParamsUpper.push_back(theCpe->localParameters(*clusterUpper, *gduUpp)); + localParamsUpper.push_back(cpe_->localParameters(*clusterUpper, *gduUpp)); } int upperIterator = 0; for (const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++cil) { @@ -144,7 +147,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi printCluster(stack->lowerDet(), &*cluL); #endif const PixelGeomDetUnit* gduLow = dynamic_cast(stack->lowerDet()); - auto&& lparamsLow = theCpe->localParameters(*cluL, *gduLow); + auto&& lparamsLow = cpe_->localParameters(*cluL, *gduLow); upperIterator = 0; for (const_iterator ciu = theUpperDetSet.begin(); ciu != theUpperDetSet.end(); ++ciu) { LogDebug("VectorHitBuilderAlgorithm") << "\t upper clusters " << std::endl; @@ -194,7 +197,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi double width = lpos_low_corr - lpos_upp_corr; LogDebug("VectorHitBuilderAlgorithm") << " \t width: " << width << std::endl; - unsigned int layerStack = theTkTopo->layer(stack->geographicalId()); + unsigned int layerStack = tkTopo_->layer(stack->geographicalId()); if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) LogDebug("VectorHitBuilderAlgorithm") << " \t is barrel. " << std::endl; if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) @@ -203,9 +206,9 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi float cut = 0.0; if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) - cut = barrelCut.at(layerStack); + cut = barrelCut_.at(layerStack); if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) - cut = endcapCut.at(layerStack); + cut = endcapCut_.at(layerStack); LogDebug("VectorHitBuilderAlgorithm") << " \t the cut is:" << cut << std::endl; //old cut: indipendent from layer @@ -243,11 +246,11 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, const PixelGeomDetUnit* geomDetLower = static_cast(stack->lowerDet()); const PixelGeomDetUnit* geomDetUpper = static_cast(stack->upperDet()); - auto&& lparamsLower = theCpe->localParameters(*lower, *geomDetLower); // x, y, z, e2_xx, e2_xy, e2_yy + auto&& lparamsLower = cpe_->localParameters(*lower, *geomDetLower); // x, y, z, e2_xx, e2_xy, e2_yy Global3DPoint gparamsLower = geomDetLower->surface().toGlobal(lparamsLower.first); LogTrace("VectorHitBuilderAlgorithm") << "\t lower global pos: " << gparamsLower; - auto&& lparamsUpper = theCpe->localParameters(*upper, *geomDetUpper); + auto&& lparamsUpper = cpe_->localParameters(*upper, *geomDetUpper); Global3DPoint gparamsUpper = geomDetUpper->surface().toGlobal(lparamsUpper.first); LogTrace("VectorHitBuilderAlgorithm") << "\t upper global pos: " << gparamsUpper; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index 5b78682bcde01..f91cdede22a6e 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -12,12 +12,12 @@ VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase( const TrackerGeometry* tkGeomProd, const TrackerTopology* tkTopoProd, const ClusterParameterEstimator* cpeProd) - : theTkGeom(tkGeomProd), - theTkTopo(tkTopoProd), - theCpe(cpeProd), - nMaxVHforeachStack(conf.getParameter("maxVectorHitsInAStack")), - barrelCut(conf.getParameter >("BarrelCut")), - endcapCut(conf.getParameter >("EndcapCut")), + : tkGeom_(tkGeomProd), + tkTopo_(tkTopoProd), + cpe_(cpeProd), + nMaxVHforeachStack_(conf.getParameter("maxVectorHitsInAStack")), + barrelCut_(conf.getParameter >("BarrelCut")), + endcapCut_(conf.getParameter >("EndcapCut")), cpeTag_(conf.getParameter("CPE")) {} double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomDetUnit*& geomDetUnit_low, @@ -53,7 +53,7 @@ void VectorHitBuilderAlgorithmBase::printClusters(const edmNew::DetSetVectoridToDetUnit(DSViter.detId())); + const GeomDetUnit* geomDetUnit(tkGeom_->idToDetUnit(DSViter.detId())); if (!geomDetUnit) return; printCluster(geomDetUnit, &clustIt); @@ -71,11 +71,11 @@ void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, if (!pixelGeomDetUnit) return; - unsigned int layer = theTkTopo->layer(geomDetUnit->geographicalId()); - unsigned int module = theTkTopo->module(geomDetUnit->geographicalId()); + unsigned int layer = tkTopo_->layer(geomDetUnit->geographicalId()); + unsigned int module = tkTopo_->module(geomDetUnit->geographicalId()); LogTrace("VectorHitBuilder") << "Layer:" << layer << " and DetId: " << geomDetUnit->geographicalId().rawId() << std::endl; - TrackerGeometry::ModuleType mType = theTkGeom->getDetectorType(geomDetUnit->geographicalId()); + TrackerGeometry::ModuleType mType = tkGeom_->getDetectorType(geomDetUnit->geographicalId()); if (mType == TrackerGeometry::ModuleType::Ph2PSP) LogTrace("VectorHitBuilder") << "Pixel cluster (module:" << module << ") " << std::endl; else if (mType == TrackerGeometry::ModuleType::Ph2SS || mType == TrackerGeometry::ModuleType::Ph2PSS) @@ -86,7 +86,7 @@ void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, LogTrace("VectorHitBuilder") << " and width:" << pixelGeomDetUnit->surface().bounds().width() << " , lenght:" << pixelGeomDetUnit->surface().bounds().length() << std::endl; - auto&& lparams = theCpe->localParameters(*clustIt, *pixelGeomDetUnit); + auto&& lparams = cpe_->localParameters(*clustIt, *pixelGeomDetUnit); Global3DPoint gparams = pixelGeomDetUnit->surface().toGlobal(lparams.first); LogTrace("VectorHitBuilder") << "\t global pos " << gparams << std::endl; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py index 88e0af4c221fa..4a6c601fa2ecd 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_combinatorialStudies_PU200.py @@ -88,8 +88,8 @@ # Analyzer process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', src = cms.string("siPhase2Clusters"), - VH_acc = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), - VH_rej = cms.InputTag("siPhase2VectorHits", "vectorHitsRejected"), + VH_acc = cms.InputTag("siPhase2VectorHits", "accepted"), + VH_rej = cms.InputTag("siPhase2VectorHits", "rejected"), CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE"), links = cms.InputTag("simSiPixelDigis", "Tracker"), trackingParticleSrc = cms.InputTag('mix', 'MergedTrackTruth'), diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py index 10d7b0fdc9191..cbb75e27d744a 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_productionAndTesting.py @@ -87,8 +87,8 @@ # Analyzer process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', src = cms.string("siPhase2Clusters"), - VH_acc = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), - VH_rej = cms.InputTag("siPhase2VectorHits", "vectorHitsRejected"), + VH_acc = cms.InputTag("siPhase2VectorHits", "accepted"), + VH_rej = cms.InputTag("siPhase2VectorHits", "rejected"), CPE = cms.ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE"), links = cms.InputTag("simSiPixelDigis", "Tracker"), trackingParticleSrc = cms.InputTag('mix', 'MergedTrackTruth'), diff --git a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py index de2e3fb74a343..c9d5cd19de4d8 100644 --- a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py @@ -114,14 +114,14 @@ TOB = cms.PSet( TTRHBuilder = cms.string('WithTrackAngle'), clusterChargeCut = cms.PSet(refToPSet_ = cms.string('SiStripClusterChargeCutNone')), - vectorRecHits = cms.InputTag("siPhase2VectorHits", 'vectorHitsAccepted'), + vectorRecHits = cms.InputTag("siPhase2VectorHits", 'accepted'), skipClusters = cms.InputTag('pixelLessStepClusters') ), TIB = None, TID = cms.PSet( TTRHBuilder = cms.string('WithTrackAngle'), clusterChargeCut = cms.PSet(refToPSet_ = cms.string('SiStripClusterChargeCutNone')), - vectorRecHits = cms.InputTag("siPhase2VectorHits", 'vectorHitsAccepted'), + vectorRecHits = cms.InputTag("siPhase2VectorHits", 'accepted'), skipClusters = cms.InputTag('pixelLessStepClusters'), useRingSlector = cms.bool(True), minRing = cms.int32(1), diff --git a/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py b/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py index 1cc806bac523f..9f7c08126f3b6 100644 --- a/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py +++ b/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py @@ -25,8 +25,8 @@ ) from Configuration.ProcessModifiers.vectorHits_cff import vectorHits vectorHits.toModify(MeasurementTrackerEvent, - vectorHits = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), - vectorHitsRej = cms.InputTag("siPhase2VectorHits", "vectorHitsRejected"), + vectorHits = cms.InputTag("siPhase2VectorHits", "accepted"), + vectorHitsRej = cms.InputTag("siPhase2VectorHits", "rejected"), ) MeasurementTrackerEventPreSplitting = MeasurementTrackerEvent.clone( diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index d9045290f30bb..cf55cd98cf4c4 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -110,7 +110,7 @@ SeedingOTEDProducer::~SeedingOTEDProducer() {} void SeedingOTEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("src", edm::InputTag("siPhase2VectorHits", "vectorHitsAccepted")); + desc.add("src", edm::InputTag("siPhase2VectorHits", "accepted")); desc.add("trackerEvent", edm::InputTag("MeasurementTrackerEvent")); desc.add("beamSpotLabel", edm::InputTag("offlineBeamSpot")); desc.add("updator", std::string("KFUpdator")); From 359a1bc658ee31989cf3b7b460f3ecc213982f1b Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 01:12:29 +0200 Subject: [PATCH 098/115] more comments from Slava --- .../src/VectorHitBuilderAlgorithm.cc | 4 - .../src/VectorHitBuilderAlgorithmBase.cc | 1 + .../test/BuildFile.xml | 2 +- .../VHs_SeedingOT_productionAndTesting.py | 9 +- .../test/VectorHitsValidation.cc | 1137 ----------------- .../test/VectorHitsValidation.h | 148 --- .../src/SeedClusterRemoverPhase2.cc | 4 - .../plugins/DuplicateTrackMerger.cc | 10 - .../python/earlyGeneralTracks_cfi.py | 32 +- .../python/HighPtTripletStep_cff.py | 51 +- .../python/LowPtTripletStep_cff.py | 48 +- .../python/PixelLessStep_cff.py | 17 +- .../python/PixelPairStep_cff.py | 46 +- 13 files changed, 22 insertions(+), 1487 deletions(-) delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc delete mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index f34773a4e9fa2..b8ff6c4d5cacf 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -35,17 +35,14 @@ void VectorHitBuilderAlgorithm::run(edm::Handlefind(lowerDetId); const auto& it_detLower = dSViter; const auto& it_detUpper = clustersPhase2Collection->find(upperDetId); - //if (it_detLower != clustersPhase2Collection->end() && it_detUpper != clustersPhase2Collection->end()) { if (it_detUpper != clustersPhase2Collection->end()) { gd = tkGeom_->idToDet(detIdStack); stackDet = dynamic_cast(gd); std::vector vhsInStack_Acc; std::vector vhsInStack_Rej; - //const auto& vhsInStack_AccRej = buildVectorHits(stackDet, clusters, *it_detLower, *it_detUpper); const auto& vhsInStack_AccRej = buildVectorHits(stackDet, clusters, it_detLower, *it_detUpper); //storing accepted and rejected VHs @@ -83,7 +80,6 @@ void VectorHitBuilderAlgorithm::run(edm::Handle& theCollection) const { for (const auto& it : theMap) { edmNew::DetSetVector::FastFiller vh_col(theCollection, it.first); + //vh_col.reserve(it.second.size()); for (const auto& vh_it : it.second) vh_col.push_back(vh_it); } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml index 104d876b608e1..847e241c1ee43 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/BuildFile.xml @@ -22,7 +22,7 @@ - + diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py index 714dbb67c9ddc..ac5fdd513eb95 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VHs_SeedingOT_productionAndTesting.py @@ -70,11 +70,8 @@ ) # Analyzer -process.analysis = cms.EDAnalyzer('VectorHitsBuilderValidation', - src = cms.string("siPhase2Clusters"), - VH_acc = cms.InputTag("siPhase2VectorHits", "vectorHitsAccepted"), - links = cms.InputTag("simSiPixelDigis", "Tracker") -) +process.load('RecoLocalTracker.SiPhase2VectorHitBuilder.vectorHitsBuilderValidation_cfi') + process.TFileService = cms.Service('TFileService', fileName = cms.string('file:vh_validation_tilted.root') ) @@ -111,7 +108,7 @@ process.L1Reco_step = cms.Path(process.L1Reco) process.trackerlocalreco_step = cms.Path(process.trackerlocalreco+process.siPixelClusters+process.siPhase2VectorHits) process.seedingOT_step = cms.Path(process.MeasurementTrackerEvent+process.offlineBeamSpot+process.phase2SeedingOTEDProducer) -process.analysis_step = cms.Path(process.analysis) +process.analysis_step = cms.Path(process.vectorHitsBuilderValidation) process.RECOSIMoutput_step = cms.EndPath(process.RECOSIMoutput) # Schedule definition diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc deleted file mode 100644 index 18d0f87e7ece4..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.cc +++ /dev/null @@ -1,1137 +0,0 @@ -#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" -#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h" -#include "SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h" -#include "RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h" -#include "Geometry/CommonDetUnit/interface/StackGeomDet.h" -#include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" -#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" -#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" -#include "DataFormats/SiStripDetId/interface/StripSubdetector.h" - -VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet& conf) - : cpeTag_(conf.getParameter("CPE")) { - srcClu_ = - consumes >(edm::InputTag(conf.getParameter("src"))); - VHacc_ = consumes(edm::InputTag(conf.getParameter("VH_acc"))); - VHrej_ = consumes(edm::InputTag(conf.getParameter("VH_rej"))); - siphase2OTSimLinksToken_ = consumes >(conf.getParameter("links")); - simHitsToken_ = consumes(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof")); - simTracksToken_ = consumes(edm::InputTag("g4SimHits")); - simVerticesToken_ = consumes(edm::InputTag("g4SimHits")); - trackingParticleToken_ = - consumes(conf.getParameter("trackingParticleSrc")); -} - -VectorHitsBuilderValidation::~VectorHitsBuilderValidation() {} - -void VectorHitsBuilderValidation::beginJob() { - edm::Service fs; - fs->file().cd("/"); - TFileDirectory td = fs->mkdir("Common"); - - //Create common ntuple - tree_ = td.make("VectorHits", "VectorHits"); - - // Create common graphs - TFileDirectory tdGloPos = td.mkdir("GlobalPositions"); - trackerLayoutRZ_[0] = tdGloPos.make(); - trackerLayoutRZ_[0]->SetName("RVsZ_Mixed"); - trackerLayoutRZ_[1] = tdGloPos.make(); - trackerLayoutRZ_[1]->SetName("RVsZ_Pixel"); - trackerLayoutRZ_[2] = tdGloPos.make(); - trackerLayoutRZ_[2]->SetName("RVsZ_Strip"); - trackerLayoutXY_[0] = tdGloPos.make(); - trackerLayoutXY_[0]->SetName("YVsX_Mixed"); - trackerLayoutXY_[1] = tdGloPos.make(); - trackerLayoutXY_[1]->SetName("YVsX_Pixel"); - trackerLayoutXY_[2] = tdGloPos.make(); - trackerLayoutXY_[2]->SetName("YVsX_Strip"); - trackerLayoutXYBar_ = tdGloPos.make(); - trackerLayoutXYBar_->SetName("YVsXBar"); - trackerLayoutXYEC_ = tdGloPos.make(); - trackerLayoutXYEC_->SetName("YVsXEC"); - - TFileDirectory tdLocPos = td.mkdir("LocalPositions"); - localPosXvsDeltaX_[0] = tdLocPos.make(); - localPosXvsDeltaX_[0]->SetName("localPosXvsDeltaX_Mixed"); - localPosXvsDeltaX_[1] = tdLocPos.make(); - localPosXvsDeltaX_[1]->SetName("localPosXvsDeltaX_Pixel"); - localPosXvsDeltaX_[2] = tdLocPos.make(); - localPosXvsDeltaX_[2]->SetName("localPosXvsDeltaX_Strip"); - localPosYvsDeltaY_[0] = tdLocPos.make(); - localPosYvsDeltaY_[0]->SetName("localPosYvsDeltaY_Mixed"); - localPosYvsDeltaY_[1] = tdLocPos.make(); - localPosYvsDeltaY_[1]->SetName("localPosYvsDeltaY_Pixel"); - localPosYvsDeltaY_[2] = tdLocPos.make(); - localPosYvsDeltaY_[2]->SetName("localPosYvsDeltaY_Strip"); - - //drawing VHs arrows - TFileDirectory tdArr = td.mkdir("Directions"); - - TFileDirectory tdWid = td.mkdir("CombinatorialStudies"); - ParallaxCorrectionRZ_ = - tdWid.make("ParallaxCorrectionRZ", "ParallaxCorrectionRZ", 100, 0., 300., 100., 0., 120.); - ParallaxCorrectionRZ_->SetName("ParallaxCorrectionFactor"); - VHaccLayer_ = tdWid.make("VHacceptedLayer", "VHacceptedLayer", 250, 0., 250.); - VHaccLayer_->SetName("VHaccepted"); - VHrejLayer_ = tdWid.make("VHrejectedLayer", "VHrejectedLayer", 250, 0., 250.); - VHrejLayer_->SetName("VHrejected"); - VHaccTrueLayer_ = tdWid.make("VHaccTrueLayer", "VHaccTrueLayer", 250, 0., 250.); - VHaccTrueLayer_->SetName("VHaccepted_true"); - VHrejTrueLayer_ = tdWid.make("VHrejTrueLayer", "VHrejTrueLayer", 250, 0., 250.); - VHrejTrueLayer_->SetName("VHrejected_true"); - VHaccTrue_signal_Layer_ = tdWid.make("VHaccTrueSignalLayer", "VHaccTrueSignalLayer", 250, 0., 250.); - VHaccTrue_signal_Layer_->SetName("VHaccepted_true_signal"); - VHrejTrue_signal_Layer_ = tdWid.make("VHrejTrueSignalLayer", "VHrejTrueSignalLayer", 250, 0., 250.); - VHrejTrue_signal_Layer_->SetName("VHrejected_true_signal"); -} - -void VectorHitsBuilderValidation::endJob() {} - -void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) { - // Get the needed objects - - // Get the clusters - edm::Handle clusters; - event.getByToken(srcClu_, clusters); - - // Get the vector hits - edm::Handle vhsAcc; - event.getByToken(VHacc_, vhsAcc); - - edm::Handle vhsRej; - event.getByToken(VHrej_, vhsRej); - - // load the cpe via the eventsetup - edm::ESHandle > cpeHandle; - eventSetup.get().get(cpeTag_, cpeHandle); - cpe_ = cpeHandle.product(); - - // Get the Phase2 DigiSimLink - edm::Handle > siphase2SimLinks; - event.getByToken(siphase2OTSimLinksToken_, siphase2SimLinks); - - // Get the SimHits - edm::Handle simHitsRaw; - event.getByToken(simHitsToken_, simHitsRaw); - - // Get the SimTracks - edm::Handle simTracksRaw; - event.getByToken(simTracksToken_, simTracksRaw); - - // Get the SimVertex - edm::Handle simVertices; - event.getByToken(simVerticesToken_, simVertices); - - // Get the geometry - edm::ESHandle geomHandle; - eventSetup.get().get(geomHandle); - tkGeom_ = &(*geomHandle); - - // Get the Topology - edm::ESHandle tTopoHandle; - eventSetup.get().get(tTopoHandle); - tkTopo_ = tTopoHandle.product(); - - edm::ESHandle magFieldHandle; - eventSetup.get().get(magFieldHandle); - magField_ = magFieldHandle.product(); - - //Tracking Particle collection - edm::Handle TPCollectionH; - event.getByToken(trackingParticleToken_, TPCollectionH); - - auto clusterTPList = std::make_unique(TPCollectionH); - std::map, TrackingParticleRef> mapping; - - for (TrackingParticleCollection::size_type itp = 0; itp < TPCollectionH.product()->size(); ++itp) { - TrackingParticleRef trackingParticle(TPCollectionH, itp); - EncodedEventId eid(trackingParticle->eventId()); - for (std::vector::const_iterator itrk = trackingParticle->g4Track_begin(); - itrk != trackingParticle->g4Track_end(); - ++itrk) { - std::pair trkid(itrk->trackId(), eid); - LogTrace("VectorHitsBuilderValidation") - << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key(); - mapping.insert(std::make_pair(trkid, trackingParticle)); - } - } - - //set up for tree - int eventNum; - int layer; - int module_id; - int module_number; - int module_type; //1: pixel, 2: strip - int VHacc = 0.0; - int VHrej = 0.0; - int vh_isTrue; - - float x_global, y_global, z_global; - float vh_x_local, vh_y_local; - float vh_x_le, vh_y_le; - float curvature, phi; - float QOverPT, QOverP; - float chi2; - - int low_tp_id, upp_tp_id; - float vh_sim_trackPt; - float sim_x_local, sim_y_local; - float sim_x_global, sim_y_global, sim_z_global; - float low_x_global, low_y_global, low_z_global; - float upp_x_global, upp_y_global, upp_z_global; - float low_xx_global_err, low_yy_global_err, low_zz_global_err; - float low_xy_global_err, low_zx_global_err, low_zy_global_err; - float upp_xx_global_err, upp_yy_global_err, upp_zz_global_err; - float upp_xy_global_err, upp_zx_global_err, upp_zy_global_err; - float deltaXVHSimHits, deltaYVHSimHits; - int multiplicity; - float width, deltaXlocal; - unsigned int processType(99); - - tree_->Branch("event", &eventNum, "eventNum/I"); - tree_->Branch("accepted", &VHacc, "VHacc/I"); - tree_->Branch("rejected", &VHrej, "VHrej/I"); - tree_->Branch("layer", &layer, "layer/I"); - tree_->Branch("module_id", &module_id, "module_id/I"); - tree_->Branch("module_type", &module_type, "module_type/I"); - tree_->Branch("module_number", &module_number, "module_number/I"); - tree_->Branch("vh_isTrue", &vh_isTrue, "vh_isTrue/I"); - tree_->Branch("x_global", &x_global, "x_global/F"); - tree_->Branch("y_global", &y_global, "y_global/F"); - tree_->Branch("z_global", &z_global, "z_global/F"); - tree_->Branch("vh_x_local", &vh_x_local, "vh_x_local/F"); - tree_->Branch("vh_y_local", &vh_y_local, "vh_y_local/F"); - tree_->Branch("vh_x_lError", &vh_x_le, "vh_x_le/F"); - tree_->Branch("vh_y_lError", &vh_y_le, "vh_y_le/F"); - tree_->Branch("curvature", &curvature, "curvature/F"); - tree_->Branch("chi2", &chi2, "chi2/F"); - tree_->Branch("phi", &phi, "phi/F"); - tree_->Branch("QOverP", &QOverP, "QOverP/F"); - tree_->Branch("QOverPT", &QOverPT, "QOverPT/F"); - tree_->Branch("low_tp_id", &low_tp_id, "low_tp_id/I"); - tree_->Branch("upp_tp_id", &upp_tp_id, "upp_tp_id/I"); - tree_->Branch("vh_sim_trackPt", &vh_sim_trackPt, "vh_sim_trackPt/F"); - tree_->Branch("sim_x_local", &sim_x_local, "sim_x_local/F"); - tree_->Branch("sim_y_local", &sim_y_local, "sim_y_local/F"); - tree_->Branch("sim_x_global", &sim_x_global, "sim_x_global/F"); - tree_->Branch("sim_y_global", &sim_y_global, "sim_y_global/F"); - tree_->Branch("sim_z_global", &sim_z_global, "sim_z_global/F"); - tree_->Branch("low_x_global", &low_x_global, "low_x_global/F"); - tree_->Branch("low_y_global", &low_y_global, "low_y_global/F"); - tree_->Branch("low_z_global", &low_z_global, "low_z_global/F"); - tree_->Branch("low_xx_global_err", &low_xx_global_err, "low_xx_global_err/F"); - tree_->Branch("low_yy_global_err", &low_yy_global_err, "low_yy_global_err/F"); - tree_->Branch("low_zz_global_err", &low_zz_global_err, "low_zz_global_err/F"); - tree_->Branch("low_xy_global_err", &low_xy_global_err, "low_xy_global_err/F"); - tree_->Branch("low_zx_global_err", &low_zx_global_err, "low_zx_global_err/F"); - tree_->Branch("low_zy_global_err", &low_zy_global_err, "low_zy_global_err/F"); - tree_->Branch("upp_x_global", &upp_x_global, "upp_x_global/F"); - tree_->Branch("upp_y_global", &upp_y_global, "upp_y_global/F"); - tree_->Branch("upp_z_global", &upp_z_global, "upp_z_global/F"); - tree_->Branch("upp_xx_global_err", &upp_xx_global_err, "upp_xx_global_err/F"); - tree_->Branch("upp_yy_global_err", &upp_yy_global_err, "upp_yy_global_err/F"); - tree_->Branch("upp_zz_global_err", &upp_zz_global_err, "upp_zz_global_err/F"); - tree_->Branch("upp_xy_global_err", &upp_xy_global_err, "upp_xy_global_err/F"); - tree_->Branch("upp_zx_global_err", &upp_zx_global_err, "upp_zx_global_err/F"); - tree_->Branch("upp_zy_global_err", &upp_zy_global_err, "upp_zy_global_err/F"); - tree_->Branch("deltaXVHSimHits", &deltaXVHSimHits, "deltaXVHSimHits/F"); - tree_->Branch("deltaYVHSimHits", &deltaYVHSimHits, "deltaYVHSimHits/F"); - tree_->Branch("multiplicity", &multiplicity, "multiplicity/I"); - tree_->Branch("width", &width, "width/F"); - tree_->Branch("deltaXlocal", &deltaXlocal, "deltaXlocal/F"); - tree_->Branch("processType", &processType, "processType/i"); - - // Rearrange the simTracks for ease of use - SimTracksMap simTracks; - for (const auto& simTrackIt : *simTracksRaw.product()) - simTracks.emplace(std::pair(simTrackIt.trackId(), simTrackIt)); - - // Rearrange the simHits by detUnit for ease of use - SimHitsMap simHitsDetUnit; - SimHitsMap simHitsTrackId; - for (const auto& simHitIt : *simHitsRaw.product()) { - SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt.detUnitId())); - if (simHitsDetUnitIt == simHitsDetUnit.end()) { - std::pair newIt(simHitsDetUnit.insert( - std::pair >(simHitIt.detUnitId(), std::vector()))); - simHitsDetUnitIt = newIt.first; - } - simHitsDetUnitIt->second.push_back(simHitIt); - - SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt.trackId())); - if (simHitsTrackIdIt == simHitsTrackId.end()) { - std::pair newIt(simHitsTrackId.insert( - std::pair >(simHitIt.trackId(), std::vector()))); - simHitsTrackIdIt = newIt.first; - } - simHitsTrackIdIt->second.push_back(simHitIt); - } - - //Printout outer tracker clusters in the event - for (const auto& DSViter : *clusters) { - unsigned int rawid(DSViter.detId()); - DetId detId(rawid); - const GeomDetUnit* geomDetUnit(tkGeom_->idToDetUnit(detId)); - const PixelGeomDetUnit* theGeomDet = dynamic_cast(geomDetUnit); - for (const auto& clustIt : DSViter) { - auto&& lparams = cpe_->localParameters(clustIt, *theGeomDet); - Global3DPoint gparams = theGeomDet->surface().toGlobal(lparams.first); - LogTrace("VectorHitsBuilderValidation") << "phase2 OT clusters: " << gparams << " DetId: " << rawid; - } - } - - for (const auto& DSViter : *vhsAcc) { - for (const auto& vhIt : DSViter) { - LogTrace("VectorHitsBuilderValidation") << "accepted VH: " << vhIt; - } - } - for (const auto& DSViter : *vhsRej) { - for (const auto& vhIt : DSViter) { - LogTrace("VectorHitsBuilderValidation") << "rejected VH: " << vhIt; - } - } - // Validation - eventNum = event.id().event(); - - unsigned int nVHsTot(0), nVHsPSTot(0), nVHs2STot(0); - std::vector glVHs; - std::vector dirVHs; - std::vector detIds; - - // Loop over modules - for (const auto DSViter : *vhsAcc) { - // Get the detector unit's id - unsigned int rawid(DSViter.detId()); - module_id = rawid; - DetId detId(rawid); - - module_number = getModuleNumber(detId); - layer = getLayerNumber(detId); - - LogDebug("VectorHitsBuilderValidation") << "Layer: " << layer << " det id" << rawid << std::endl; - - // Get the geometry of the tracker - const GeomDet* geomDet(tkGeom_->idToDet(detId)); - if (!geomDet) - break; - - // Create histograms for the layer if they do not yet exist - std::map::iterator histogramLayer(histograms_.find(layer)); - if (histogramLayer == histograms_.end()) - histogramLayer = createLayerHistograms(layer); - // Number of clusters - unsigned int nVHsPS(0), nVHs2S(0); - - LogDebug("VectorHitsBuilderValidation") << "DSViter size: " << DSViter.size(); - - // Loop over the vhs in the detector unit - for (const auto& vhIt : DSViter) { - // vh variables - if (vhIt.isValid()) { - LogDebug("VectorHitsBuilderValidation") << " vh analyzing ..."; - chi2 = vhIt.chi2(); - LogTrace("VectorHitsBuilderValidation") << "VH chi2 " << chi2 << std::endl; - - Local3DPoint localPosVH = vhIt.localPosition(); - vh_x_local = localPosVH.x(); - vh_y_local = localPosVH.y(); - LogTrace("VectorHitsBuilderValidation") << "local VH position " << localPosVH << std::endl; - - LocalError localErrVH = vhIt.localPositionError(); - vh_x_le = localErrVH.xx(); - vh_y_le = localErrVH.yy(); - LogTrace("VectorHitsBuilderValidation") << "local VH error " << localErrVH << std::endl; - - Global3DPoint globalPosVH = geomDet->surface().toGlobal(localPosVH); - x_global = globalPosVH.x(); - y_global = globalPosVH.y(); - z_global = globalPosVH.z(); - glVHs.push_back(globalPosVH); - LogTrace("VectorHitsBuilderValidation") << " global VH position " << globalPosVH << std::endl; - - Local3DVector localDirVH = vhIt.localDirection(); - LogTrace("VectorHitsBuilderValidation") << "local VH direction " << localDirVH << std::endl; - - VectorHit vh = vhIt; - Global3DVector globalDirVH = vh.globalDirectionVH(); - dirVHs.push_back(globalDirVH); - LogTrace("VectorHitsBuilderValidation") << "global VH direction " << globalDirVH << std::endl; - - // Fill the position histograms - trackerLayoutRZ_[0]->SetPoint(nVHsTot, globalPosVH.z(), globalPosVH.perp()); - trackerLayoutXY_[0]->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); - - if (layer < 100) - trackerLayoutXYBar_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); - else - trackerLayoutXYEC_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); - - histogramLayer->second.localPosXY[0]->SetPoint(nVHsTot, vh_x_local, vh_y_local); - histogramLayer->second.globalPosXY[0]->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); - - localPosXvsDeltaX_[0]->SetPoint(nVHsTot, vh_x_local, localDirVH.x()); - localPosYvsDeltaY_[0]->SetPoint(nVHsTot, vh_y_local, localDirVH.y()); - - // Pixel module - const StackGeomDet* stackDet = dynamic_cast(geomDet); - const PixelGeomDetUnit* geomDetLower = dynamic_cast(stackDet->lowerDet()); - DetId lowerDetId = stackDet->lowerDet()->geographicalId(); - DetId upperDetId = stackDet->upperDet()->geographicalId(); - - TrackerGeometry::ModuleType mType = tkGeom_->getDetectorType(lowerDetId); - module_type = 0; - if (mType == TrackerGeometry::ModuleType::Ph2PSP) { - module_type = 1; - trackerLayoutRZ_[1]->SetPoint(nVHsPSTot, globalPosVH.z(), globalPosVH.perp()); - trackerLayoutXY_[1]->SetPoint(nVHsPSTot, globalPosVH.x(), globalPosVH.y()); - - histogramLayer->second.localPosXY[1]->SetPoint(nVHsPSTot, vh_x_local, vh_y_local); - histogramLayer->second.globalPosXY[1]->SetPoint(nVHsPSTot, globalPosVH.x(), globalPosVH.y()); - - localPosXvsDeltaX_[1]->SetPoint(nVHsPSTot, vh_x_local, localDirVH.x()); - localPosYvsDeltaY_[1]->SetPoint(nVHsPSTot, vh_y_local, localDirVH.y()); - - ++nVHsPS; - ++nVHsPSTot; - } - - // Strip module - else if (mType == TrackerGeometry::ModuleType::Ph2SS) { - module_type = 2; - trackerLayoutRZ_[2]->SetPoint(nVHs2STot, globalPosVH.z(), globalPosVH.perp()); - trackerLayoutXY_[2]->SetPoint(nVHs2STot, globalPosVH.x(), globalPosVH.y()); - - histogramLayer->second.localPosXY[2]->SetPoint(nVHs2STot, vh_x_local, vh_y_local); - histogramLayer->second.globalPosXY[2]->SetPoint(nVHs2STot, globalPosVH.x(), globalPosVH.y()); - - localPosXvsDeltaX_[2]->SetPoint(nVHs2STot, vh_x_local, localDirVH.x()); - localPosYvsDeltaY_[2]->SetPoint(nVHs2STot, vh_y_local, localDirVH.y()); - - ++nVHs2S; - ++nVHs2STot; - } else if (mType == TrackerGeometry::ModuleType::Ph2PSS) { - edm::LogError("VectorHitsBuilderValidation") << "module type " << module_type << " should never happen!"; - } - LogTrace("VectorHitsBuilderValidation") << "module type " << module_type << std::endl; - - // get the geomDetUnit of the clusters - low_x_global = vhIt.lowerGlobalPos().x(); - low_y_global = vhIt.lowerGlobalPos().y(); - low_z_global = vhIt.lowerGlobalPos().z(); - upp_x_global = vhIt.upperGlobalPos().x(); - upp_y_global = vhIt.upperGlobalPos().y(); - upp_z_global = vhIt.upperGlobalPos().z(); - - low_xx_global_err = vhIt.lowerGlobalPosErr().cxx(); - low_yy_global_err = vhIt.lowerGlobalPosErr().cyy(); - low_zz_global_err = vhIt.lowerGlobalPosErr().czz(); - low_xy_global_err = vhIt.lowerGlobalPosErr().cyx(); - low_zx_global_err = vhIt.lowerGlobalPosErr().czx(); - low_zy_global_err = vhIt.lowerGlobalPosErr().czy(); - - upp_xx_global_err = vhIt.upperGlobalPosErr().cxx(); - upp_yy_global_err = vhIt.upperGlobalPosErr().cyy(); - upp_zz_global_err = vhIt.upperGlobalPosErr().czz(); - upp_xy_global_err = vhIt.upperGlobalPosErr().cyx(); - upp_zx_global_err = vhIt.upperGlobalPosErr().czx(); - upp_zy_global_err = vhIt.upperGlobalPosErr().czy(); - - LogDebug("VectorHitsBuilderValidation") << "print Clusters into the VH:" << std::endl; - printCluster(geomDetLower, vhIt.lowerClusterRef()); - LogTrace("VectorHitsBuilderValidation") << "\t global pos lower " << vhIt.lowerGlobalPos() << std::endl; - LogTrace("VectorHitsBuilderValidation") - << "\t global posErr lower " << vhIt.lowerGlobalPosErr().cxx() << std::endl; - const GeomDetUnit* geomDetUpper = stackDet->upperDet(); - printCluster(geomDetUpper, vhIt.upperClusterRef()); - LogTrace("VectorHitsBuilderValidation") << "\t global pos upper " << vhIt.upperGlobalPos() << std::endl; - - //comparison with SIM hits - LogDebug("VectorHitsBuilderValidation") << "comparison Clusters with sim hits ... " << std::endl; - std::vector clusterSimTrackIds; - std::vector clusterSimTrackIdsUpp; - std::set > simTkIds; - const GeomDetUnit* geomDetUnit_low(tkGeom_->idToDetUnit(lowerDetId)); - LogTrace("VectorHitsBuilderValidation") << " lowerDetID : " << lowerDetId.rawId(); - const GeomDetUnit* geomDetUnit_upp(tkGeom_->idToDetUnit(upperDetId)); - LogTrace("VectorHitsBuilderValidation") << " upperDetID : " << upperDetId.rawId(); - - for (unsigned int istr(0); istr < (*(vhIt.lowerClusterRef().cluster_phase2OT())).size(); ++istr) { - uint32_t channel = - Phase2TrackerDigi::pixelToChannel((*(vhIt.lowerClusterRef().cluster_phase2OT())).firstRow() + istr, - (*(vhIt.lowerClusterRef().cluster_phase2OT())).column()); - unsigned int LowerSimTrackId(getSimTrackId(siphase2SimLinks, lowerDetId, channel)); - std::vector > trkid( - getSimTrackIds(siphase2SimLinks, lowerDetId, channel)); - if (trkid.size() == 0) - continue; - clusterSimTrackIds.push_back(LowerSimTrackId); - simTkIds.insert(trkid.begin(), trkid.end()); - LogTrace("VectorHitsBuilderValidation") << "LowerSimTrackId " << LowerSimTrackId << std::endl; - } - // In the case of PU, we need the TPs to find the proper SimTrackID - for (const auto& iset : simTkIds) { - auto ipos = mapping.find(iset); - if (ipos != mapping.end()) { - LogTrace("VectorHitsBuilderValidation") << "lower cluster in detid: " << lowerDetId.rawId() - << " from tp: " << ipos->second.key() << " " << iset.first; - LogTrace("VectorHitsBuilderValidation") << "with pt(): " << (*ipos->second).pt(); - low_tp_id = ipos->second.key(); - vh_sim_trackPt = (*ipos->second).pt(); - } - } - - simTkIds.clear(); - for (unsigned int istr(0); istr < (*(vhIt.upperClusterRef().cluster_phase2OT())).size(); ++istr) { - uint32_t channel = - Phase2TrackerDigi::pixelToChannel((*(vhIt.upperClusterRef().cluster_phase2OT())).firstRow() + istr, - (*(vhIt.upperClusterRef().cluster_phase2OT())).column()); - unsigned int UpperSimTrackId(getSimTrackId(siphase2SimLinks, upperDetId, channel)); - std::vector > trkid( - getSimTrackIds(siphase2SimLinks, upperDetId, channel)); - if (trkid.size() == 0) - continue; - clusterSimTrackIdsUpp.push_back(UpperSimTrackId); - simTkIds.insert(trkid.begin(), trkid.end()); - LogTrace("VectorHitsBuilderValidation") << "UpperSimTrackId " << UpperSimTrackId << std::endl; - } - // In the case of PU, we need the TPs to find the proper SimTrackID - for (const auto& iset : simTkIds) { - auto ipos = mapping.find(iset); - if (ipos != mapping.end()) { - LogTrace("VectorHitsBuilderValidation") - << "upper cluster in detid: " << upperDetId.rawId() << " from tp: " << ipos->second.key() << " " - << iset.first << std::endl; - upp_tp_id = ipos->second.key(); - } - } - //compute if the vhits is 'true' or 'false' and save sim pT - std::pair istrue = isTrue(vhIt, siphase2SimLinks, detId); - vh_isTrue = 0; - if (istrue.first) { - vh_isTrue = 1; - } - - // loop over all simHits - unsigned int totalSimHits(0); - unsigned int primarySimHits(0); - unsigned int otherSimHits(0); - - for (const auto& hitIt : *simHitsRaw) { - if (hitIt.detUnitId() == geomDetLower->geographicalId()) { - //check clusters track id compatibility - if (std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt.trackId()) != - clusterSimTrackIds.end()) { - Local3DPoint localPosHit(hitIt.localPosition()); - sim_x_local = localPosHit.x(); - sim_y_local = localPosHit.y(); - - deltaXVHSimHits = vh_x_local - sim_x_local; - deltaYVHSimHits = vh_y_local - sim_y_local; - - Global3DPoint globalPosHit = geomDetLower->surface().toGlobal(localPosHit); - sim_x_global = globalPosHit.x(); - sim_y_global = globalPosHit.y(); - sim_z_global = globalPosHit.z(); - - histogramLayer->second.deltaXVHSimHits[0]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits[0]->Fill(vh_y_local - sim_y_local); - - // Pixel module - if (layer == 1 || layer == 2 || layer == 3) { - histogramLayer->second.deltaXVHSimHits[1]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits[1]->Fill(vh_y_local - sim_y_local); - } - // Strip module - else if (layer == 4 || layer == 5 || layer == 6) { - histogramLayer->second.deltaXVHSimHits[2]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits[2]->Fill(vh_y_local - sim_y_local); - } - - ++totalSimHits; - - std::map::const_iterator simTrackIt(simTracks.find(hitIt.trackId())); - if (simTrackIt == simTracks.end()) - continue; - - // Primary particles only - processType = hitIt.processType(); - - if (simTrackIt->second.vertIndex() == 0 and - (processType == 2 || processType == 7 || processType == 9 || processType == 11 || processType == 13 || - processType == 15)) { - histogramLayer->second.deltaXVHSimHits_P[0]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits_P[0]->Fill(vh_y_local - sim_y_local); - - // Pixel module - if (layer == 1 || layer == 2 || layer == 3) { - histogramLayer->second.deltaXVHSimHits_P[1]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits_P[1]->Fill(vh_y_local - sim_y_local); - } - // Strip module - else if (layer == 4 || layer == 5 || layer == 6) { - histogramLayer->second.deltaXVHSimHits_P[2]->Fill(vh_x_local - sim_x_local); - histogramLayer->second.deltaYVHSimHits_P[2]->Fill(vh_y_local - sim_y_local); - } - - ++primarySimHits; - } - - otherSimHits = totalSimHits - primarySimHits; - - histogramLayer->second.totalSimHits->Fill(totalSimHits); - histogramLayer->second.primarySimHits->Fill(primarySimHits); - histogramLayer->second.otherSimHits->Fill(otherSimHits); - } - } - } // loop simhits - - nVHsTot++; - - //****************************** - //combinatorial studies : not filling if more than 1 VH has been produced - //****************************** - multiplicity = DSViter.size(); - if (DSViter.size() > 1) { - LogTrace("VectorHitsBuilderValidation") << " not filling if more than 1 VH has been produced"; - width = -100; - deltaXlocal = -100; - tree_->Fill(); - continue; - } - - //curvature - GlobalPoint center(0.0, 0.0, 0.0); - curvature = vh.curvature(); - phi = vh.phi(); - QOverPT = vh.transverseMomentum(magField_->inTesla(center).z()); - QOverP = vh.momentum(magField_->inTesla(center).z()); - histogramLayer->second.curvature->Fill(curvature); - - //stub width - - auto&& lparamsUpp = cpe_->localParameters(*vhIt.upperClusterRef().cluster_phase2OT(), *geomDetUnit_upp); - LogTrace("VectorHitsBuilderValidation") << " upper local pos (in its system of reference):" << lparamsUpp.first; - Global3DPoint gparamsUpp = geomDetUnit_upp->surface().toGlobal(lparamsUpp.first); - LogTrace("VectorHitsBuilderValidation") << " upper global pos :" << gparamsUpp; - Local3DPoint lparamsUppInLow = geomDetUnit_low->surface().toLocal(gparamsUpp); - LogTrace("VectorHitsBuilderValidation") << " upper local pos (in low system of reference):" << lparamsUppInLow; - auto&& lparamsLow = cpe_->localParameters(*vhIt.lowerClusterRef().cluster_phase2OT(), *geomDetUnit_low); - LogTrace("VectorHitsBuilderValidation") << " lower local pos (in its system of reference):" << lparamsLow.first; - Global3DPoint gparamsLow = geomDetUnit_low->surface().toGlobal(lparamsLow.first); - LogTrace("VectorHitsBuilderValidation") << " lower global pos :" << gparamsLow; - - deltaXlocal = lparamsUppInLow.x() - lparamsLow.first.x(); - histogramLayer->second.deltaXlocal->Fill(deltaXlocal); - LogTrace("VectorHitsBuilderValidation") << " deltaXlocal : " << deltaXlocal; - - double parallCorr = 0.0; - - Global3DPoint origin(0, 0, 0); - GlobalVector gV = gparamsLow - origin; - LocalVector lV = geomDetUnit_low->surface().toLocal(gV); - LocalVector lV_norm = lV / lV.z(); - parallCorr = lV_norm.x() * lparamsUppInLow.z(); - LogTrace("VectorHitsBuilderValidation") << " parallalex correction:" << parallCorr; - - double lpos_upp_corr = 0.0; - double lpos_low_corr = 0.0; - if (lparamsUpp.first.x() > lparamsLow.first.x()) { - if (lparamsUpp.first.x() > 0) { - lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() - fabs(parallCorr); - } - if (lparamsUpp.first.x() < 0) { - lpos_low_corr = lparamsLow.first.x() + fabs(parallCorr); - lpos_upp_corr = lparamsUpp.first.x(); - } - } else if (lparamsUpp.first.x() < lparamsLow.first.x()) { - if (lparamsUpp.first.x() > 0) { - lpos_low_corr = lparamsLow.first.x() - fabs(parallCorr); - lpos_upp_corr = lparamsUpp.first.x(); - } - if (lparamsUpp.first.x() < 0) { - lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = lparamsUpp.first.x() + fabs(parallCorr); - } - } else { - if (lparamsUpp.first.x() > 0) { - lpos_upp_corr = lparamsUpp.first.x() - fabs(parallCorr); - lpos_low_corr = lparamsLow.first.x(); - } - if (lparamsUpp.first.x() < 0) { - lpos_upp_corr = lparamsUpp.first.x() + fabs(parallCorr); - lpos_low_corr = lparamsLow.first.x(); - } - } - - LogDebug("VectorHitsBuilderValidation") << " \t local pos upper corrected (x):" << lpos_upp_corr << std::endl; - LogDebug("VectorHitsBuilderValidation") << " \t local pos lower corrected (x):" << lpos_low_corr << std::endl; - - width = lpos_low_corr - lpos_upp_corr; - histogramLayer->second.width->Fill(width); - LogTrace("VectorHitsBuilderValidation") << " width:" << width; - - tree_->Fill(); - - } // vh valid - - } // loop vhs - - if (nVHsPS) - histogramLayer->second.numberVHsPS->Fill(nVHsPS); - if (nVHs2S) - histogramLayer->second.numberVHs2S->Fill(nVHs2S); - LogTrace("VectorHitsBuilderValidation") - << "nVHsPS for this layer : " << nVHsPS << ", nVHs2S for this layer : " << nVHs2S << std::endl; - } - - CreateVHsXYGraph(glVHs, dirVHs); - CreateVHsRZGraph(glVHs, dirVHs); - - int VHaccTrue = 0.0; - int VHaccFalse = 0.0; - int VHrejTrue = 0.0; - int VHrejFalse = 0.0; - int VHaccTrue_signal = 0.0; - int VHrejTrue_signal = 0.0; - - // Loop over modules - for (const auto& DSViter : *vhsAcc) { - unsigned int rawid(DSViter.detId()); - DetId detId(rawid); - int layerAcc = getLayerNumber(detId); - LogTrace("VectorHitsBuilderValidation") << "acc Layer: " << layerAcc << " det id" << rawid << std::endl; - for (const auto& vhIt : DSViter) { - if (vhIt.isValid()) { - VHaccLayer_->Fill(layerAcc); - VHacc++; - - //compute if the vhits is 'true' or 'false' - std::pair istrue = isTrue(vhIt, siphase2SimLinks, detId); - if (istrue.first) { - LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; - VHaccTrueLayer_->Fill(layerAcc); - VHaccTrue++; - - //saving info of 'signal' track - std::map::const_iterator simTrackIt(simTracks.find(istrue.second)); - if (simTrackIt == simTracks.end()) - continue; - LogTrace("VectorHitsBuilderValidation") << "this vectorhit is associated with SimTrackId: " << istrue.second; - LogTrace("VectorHitsBuilderValidation") << "the SimTrack has pt: " << simTrackIt->second.momentum().pt(); - if (simTrackIt->second.momentum().pt() > 1) { - VHaccTrue_signal_Layer_->Fill(layerAcc); - LogTrace("VectorHitsBuilderValidation") << "the vectorhit belongs to signal"; - VHaccTrue_signal++; - } - - } else { - LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'false' vhit."; - VHaccFalse++; - } - } - } - } - - for (const auto& DSViter : *vhsRej) { - unsigned int rawid(DSViter.detId()); - DetId detId(rawid); - int layerRej = getLayerNumber(detId); - LogTrace("VectorHitsBuilderValidation") << "rej Layer: " << layerRej << " det id" << rawid << std::endl; - for (const auto& vhIt : DSViter) { - VHrejLayer_->Fill(layerRej); - VHrej++; - - //compute if the vhits is 'true' or 'false' - std::pair istrue = isTrue(vhIt, siphase2SimLinks, detId); - if (istrue.first) { - LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; - VHrejTrueLayer_->Fill(layerRej); - VHrejTrue++; - - //saving info of 'signal' track - std::map::const_iterator simTrackIt(simTracks.find(istrue.second)); - if (simTrackIt == simTracks.end()) - continue; - LogTrace("VectorHitsBuilderValidation") << "this vectorhit is associated with SimTrackId: " << istrue.second; - LogTrace("VectorHitsBuilderValidation") << "the SimTrack has pt: " << simTrackIt->second.momentum().pt(); - if (simTrackIt->second.momentum().pt() > 1) { - VHrejTrue_signal_Layer_->Fill(layerRej); - LogTrace("VectorHitsBuilderValidation") << "the vectorhit belongs to signal"; - VHrejTrue_signal++; - } - - } else { - LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'false' vhit."; - VHrejFalse++; - } - } - } - - int VHtot = VHacc + VHrej; - LogTrace("VectorHitsBuilderValidation") - << "VH total: " << VHtot << " with " << VHacc << " VHs accepted and " << VHrej << " VHs rejected."; - LogTrace("VectorHitsBuilderValidation") - << "of the VH accepted, there are " << VHaccTrue << " true and " << VHaccFalse << " false."; - LogTrace("VectorHitsBuilderValidation") - << "of the VH rejected, there are " << VHrejTrue << " true and " << VHrejFalse << " false."; - LogTrace("VectorHitsBuilderValidation") - << "of the true VH , there are " << VHaccTrue_signal << " accepted belonging to signal and " - << VHrejTrue_signal << " rejected belonging to signal."; - - // CreateWindowCorrGraph(); -} - -// Check if the vector hit is true (both clusters are formed from the same SimTrack -std::pair VectorHitsBuilderValidation::isTrue( - const VectorHit vh, const edm::Handle >& siphase2SimLinks, DetId& detId) const { - const GeomDet* geomDet(tkGeom_->idToDet(detId)); - const StackGeomDet* stackDet = dynamic_cast(geomDet); - const GeomDetUnit* geomDetLower = stackDet->lowerDet(); - const GeomDetUnit* geomDetUpper = stackDet->upperDet(); - - std::vector lowClusterSimTrackIds; - - for (unsigned int istr(0); istr < (*(vh.lowerClusterRef().cluster_phase2OT())).size(); ++istr) { - uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.lowerClusterRef().cluster_phase2OT())).firstRow() + istr, - (*(vh.lowerClusterRef().cluster_phase2OT())).column()); - DetId detIdCluster = geomDetLower->geographicalId(); - unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detIdCluster, channel)); - LogTrace("VectorHitsBuilderValidation") << "LowerSimTrackId " << simTrackId << std::endl; - std::vector > trkid(getSimTrackIds(siphase2SimLinks, detIdCluster, channel)); - if (trkid.size() == 0) - continue; - lowClusterSimTrackIds.push_back(simTrackId); - } - - std::vector::iterator it_simTrackUpper; - - for (unsigned int istr(0); istr < (*(vh.upperClusterRef().cluster_phase2OT())).size(); ++istr) { - uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.upperClusterRef().cluster_phase2OT())).firstRow() + istr, - (*(vh.upperClusterRef().cluster_phase2OT())).column()); - DetId detIdCluster = geomDetUpper->geographicalId(); - unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detIdCluster, channel)); - LogTrace("VectorHitsBuilderValidation") << "UpperSimTrackId " << simTrackId << std::endl; - std::vector > trkid(getSimTrackIds(siphase2SimLinks, detIdCluster, channel)); - if (trkid.size() == 0) - continue; - it_simTrackUpper = std::find(lowClusterSimTrackIds.begin(), lowClusterSimTrackIds.end(), simTrackId); - if (it_simTrackUpper != lowClusterSimTrackIds.end()) { - LogTrace("VectorHitsBuilderValidation") << " UpperSimTrackId found in lowClusterSimTrackIds "; - return std::make_pair(true, simTrackId); - } - } - return std::make_pair(false, 0); -} - -// Create the histograms -std::map::iterator VectorHitsBuilderValidation::createLayerHistograms(unsigned int ival) { - std::ostringstream fname1, fname2; - - edm::Service fs; - fs->file().cd("/"); - - std::string tag; - unsigned int id; - if (ival < 100) { - id = ival; - fname1 << "Barrel"; - fname2 << "Layer_" << id; - tag = "_layer_"; - } else { - int side = ival / 100; - id = ival - side * 100; - fname1 << "EndCap_Side_" << side; - fname2 << "Disc_" << id; - tag = "_disc_"; - } - - TFileDirectory td1 = fs->mkdir(fname1.str().c_str()); - TFileDirectory td = td1.mkdir(fname2.str().c_str()); - - VHHistos local_histos; - - std::ostringstream histoName; - - /* - * Number of clusters - */ - - histoName.str(""); - histoName << "Number_VHs_PS" << tag.c_str() << id; - local_histos.numberVHsPS = td.make(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); - local_histos.numberVHsPS->SetFillColor(kAzure + 7); - - histoName.str(""); - histoName << "Number_VHs_2S" << tag.c_str() << id; - local_histos.numberVHs2S = td.make(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); - local_histos.numberVHs2S->SetFillColor(kOrange - 3); - - histoName.str(""); - histoName << "Number_VHs_Mixed" << tag.c_str() << id; - local_histos.numberVHsMixed = td.make(histoName.str().c_str(), histoName.str().c_str()); - local_histos.numberVHsMixed->Add(local_histos.numberVHsPS); - local_histos.numberVHsMixed->Add(local_histos.numberVHs2S); - - /* - * Local and Global positions - */ - - histoName.str(""); - histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; - local_histos.localPosXY[0] = td.make(); - local_histos.localPosXY[0]->SetName(histoName.str().c_str()); - - histoName.str(""); - histoName << "Local_Position_XY_PS" << tag.c_str() << id; - local_histos.localPosXY[1] = td.make(); - local_histos.localPosXY[1]->SetName(histoName.str().c_str()); - - histoName.str(""); - histoName << "Local_Position_XY_2S" << tag.c_str() << id; - local_histos.localPosXY[2] = td.make(); - local_histos.localPosXY[2]->SetName(histoName.str().c_str()); - - histoName.str(""); - histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; - local_histos.globalPosXY[0] = td.make(); - local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); - - histoName.str(""); - histoName << "Global_Position_XY_PS" << tag.c_str() << id; - local_histos.globalPosXY[1] = td.make(); - local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); - - histoName.str(""); - histoName << "Global_Position_XY_2S" << tag.c_str() << id; - local_histos.globalPosXY[2] = td.make(); - local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); - - /* - * Delta positions with SimHits - */ - - histoName.str(""); - histoName << "Delta_X_VH_SimHits_Mixed" << tag.c_str() << id; - local_histos.deltaXVHSimHits[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_X_VH_SimHits_PS" << tag.c_str() << id; - local_histos.deltaXVHSimHits[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_X_VH_SimHits_2S" << tag.c_str() << id; - local_histos.deltaXVHSimHits[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_Y_VH_SimHits_Mixed" << tag.c_str() << id; - local_histos.deltaYVHSimHits[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_Y_VH_SimHits_PS" << tag.c_str() << id; - local_histos.deltaYVHSimHits[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_Y_VH_SimHits_2S" << tag.c_str() << id; - local_histos.deltaYVHSimHits[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - /* - * Delta position with simHits for primary tracks only - */ - - histoName.str(""); - histoName << "Delta_X_VH_SimHits_Mixed_P" << tag.c_str() << id; - local_histos.deltaXVHSimHits_P[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_X_VH_SimHits_PS_P" << tag.c_str() << id; - local_histos.deltaXVHSimHits_P[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_X_VH_SimHits_2S_P" << tag.c_str() << id; - local_histos.deltaXVHSimHits_P[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_Y_VH_SimHits_Mixed_P" << tag.c_str() << id; - local_histos.deltaYVHSimHits_P[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_Y_VH_SimHits_PS_P" << tag.c_str() << id; - local_histos.deltaYVHSimHits_P[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - histoName.str(""); - histoName << "Delta_Y_VH_SimHits_2S_P" << tag.c_str() << id; - local_histos.deltaYVHSimHits_P[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); - - /* - * Information on the Digis per cluster - */ - - histoName.str(""); - histoName << "Total_Digis" << tag.c_str() << id; - local_histos.totalSimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - - histoName.str(""); - histoName << "Primary_Digis" << tag.c_str() << id; - local_histos.primarySimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - - histoName.str(""); - histoName << "Other_Digis" << tag.c_str() << id; - local_histos.otherSimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); - - /* - * Study on the clusters combinatorial problem - */ - - histoName.str(""); - histoName << "DeltaXlocal_clusters" << tag.c_str() << id; - local_histos.deltaXlocal = td.make(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); - histoName.str(""); - histoName << "Width" << tag.c_str() << id; - local_histos.width = td.make(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); - histoName.str(""); - histoName << "Curvature" << tag.c_str() << id; - local_histos.curvature = td.make(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); - - std::pair::iterator, bool> insertedIt( - histograms_.insert(std::make_pair(ival, local_histos))); - fs->file().cd("/"); - - return insertedIt.first; -} - -void VectorHitsBuilderValidation::CreateVHsXYGraph(const std::vector glVHs, - const std::vector dirVHs) { - if (glVHs.size() != dirVHs.size()) { - std::cout << "Cannot fullfil the graphs for this event. Return." << std::endl; - return; - } - - // opening canvas and drawing XY TGraph - - for (unsigned int nVH = 0; nVH < glVHs.size(); nVH++) { - //same r - if ((fabs(dirVHs.at(nVH).x()) < 10e-5) && (fabs(dirVHs.at(nVH).y()) < 10e-5)) { - continue; - - } else { - } - } - - return; -} - -void VectorHitsBuilderValidation::CreateVHsRZGraph(const std::vector glVHs, - const std::vector dirVHs) { - if (glVHs.size() != dirVHs.size()) { - std::cout << "Cannot fullfil the graphs for this event. Return." << std::endl; - return; - } - - return; -} - -void VectorHitsBuilderValidation::CreateWindowCorrGraph() { - //FIXME: This function is not working properly, yet. - - //return if we are not using Phase2 OT - if (!tkGeom_->isThere(GeomDetEnumerators::P2OTB) && !tkGeom_->isThere(GeomDetEnumerators::P2OTEC)) - return; - - for (auto det : tkGeom_->detsTOB()) { - ParallaxCorrectionRZ_->Fill(det->position().z(), det->position().perp(), 5.); - } - for (auto det : tkGeom_->detsTID()) { - ParallaxCorrectionRZ_->Fill(det->position().z(), det->position().perp(), 10.); - } - ParallaxCorrectionRZ_->Fill(0., 0., 5.); - return; -} - -unsigned int VectorHitsBuilderValidation::getLayerNumber(const DetId& detid) { - if (detid.det() == DetId::Tracker) { - if (detid.subdetId() == StripSubdetector::TOB) - return (tkTopo_->layer(detid)); - else if (detid.subdetId() == StripSubdetector::TID) - return (100 * tkTopo_->side(detid) + tkTopo_->layer(detid)); - else - return 999; - } - return 999; -} - -unsigned int VectorHitsBuilderValidation::getModuleNumber(const DetId& detid) { return (tkTopo_->module(detid)); } - -std::vector > VectorHitsBuilderValidation::getSimTrackIds( - const edm::Handle >& simLinks, const DetId& detId, uint32_t channel) const { - std::vector > simTrkId; - auto isearch = simLinks->find(detId); - if (isearch != simLinks->end()) { - // Loop over DigiSimLink in this det unit - edm::DetSet link_detset = (*isearch); - for (const auto& it : link_detset.data) { - if (channel == it.channel()) - simTrkId.push_back(std::make_pair(it.SimTrackId(), it.eventId())); - } - } - return simTrkId; -} - -unsigned int VectorHitsBuilderValidation::getSimTrackId( - const edm::Handle >& pixelSimLinks, - const DetId& detId, - unsigned int channel) const { - edm::DetSetVector::const_iterator DSViter(pixelSimLinks->find(detId)); - if (DSViter == pixelSimLinks->end()) - return 0; - for (const auto& it : DSViter->data) { - if (channel == it.channel()) - return it.SimTrackId(); - } - return 0; -} - -void VectorHitsBuilderValidation::printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster) { - if (!geomDetUnit) - return; - - const PixelGeomDetUnit* theGeomDet = dynamic_cast(geomDetUnit); - const PixelTopology& topol = theGeomDet->specificTopology(); - - unsigned int layer = getLayerNumber(geomDetUnit->geographicalId()); - unsigned int module = getModuleNumber(geomDetUnit->geographicalId()); - LogTrace("VectorHitsBuilderValidation") << "Layer:" << layer << std::endl; - if (topol.ncolumns() == 32) - LogTrace("VectorHitsBuilderValidation") << "Pixel cluster with detId:" << geomDetUnit->geographicalId().rawId() - << "(module:" << module << ") " << std::endl; - else if (topol.ncolumns() == 2) - LogTrace("VectorHitsBuilderValidation") << "Strip cluster with detId:" << geomDetUnit->geographicalId().rawId() - << "(module:" << module << ") " << std::endl; - else - std::cout << "no module?!" << std::endl; - LogTrace("VectorHitsBuilderValidation") - << "with pitch:" << topol.pitch().first << " , " << topol.pitch().second << std::endl; - LogTrace("VectorHitsBuilderValidation") << " and width:" << theGeomDet->surface().bounds().width() - << " , lenght:" << theGeomDet->surface().bounds().length() << std::endl; - - auto&& lparams = cpe_->localParameters(*cluster.cluster_phase2OT(), *theGeomDet); - - LogTrace("VectorHitsBuilderValidation") - << "\t local pos " << lparams.first << "with err " << lparams.second << std::endl; - - return; -} - -void VectorHitsBuilderValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add("src", "siPhase2Clusters"); - desc.add("links", edm::InputTag("simSiPixelDigis", "Tracker")); - desc.add("VH_acc", edm::InputTag("siPhase2VectorHits", "vectorHitsAccepted")); - desc.add("VH_rej", edm::InputTag("siPhase2VectorHits", "vectorHitsRejected")); - desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); - desc.add("trackingParticleSrc", edm::InputTag("mix", "MergedTrackTruth")); - descriptions.add("vectorHitsBuilderValidation", desc); -} - -DEFINE_FWK_MODULE(VectorHitsBuilderValidation); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h deleted file mode 100644 index 66ca71f0d46a7..0000000000000 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsValidation.h +++ /dev/null @@ -1,148 +0,0 @@ -#include -#include -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/ServiceRegistry/interface/Service.h" - -#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" -#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" - -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" -#include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" - -#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" -#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" -#include "DataFormats/Common/interface/DetSetVectorNew.h" -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/DetId/interface/DetId.h" -#include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" -#include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" -#include "DataFormats/SiPixelDigi/interface/PixelDigi.h" -#include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" - -#include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h" -#include "SimDataFormats/Track/interface/SimTrackContainer.h" -#include "SimDataFormats/Vertex/interface/SimVertexContainer.h" -#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" - -#include "CommonTools/UtilAlgos/interface/TFileService.h" -#include "CommonTools/Utils/interface/TFileDirectory.h" - -#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" -#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h" - -#include -#include -#include -#include -#include -#include -#include - -struct VHHistos { - THStack* numberVHsMixed; - TH1F* numberVHsPS; - TH1F* numberVHs2S; - - TGraph* globalPosXY[3]; - TGraph* localPosXY[3]; - - TH1F* deltaXVHSimHits[3]; - TH1F* deltaYVHSimHits[3]; - - TH1F* deltaXVHSimHits_P[3]; - TH1F* deltaYVHSimHits_P[3]; - - TH1F* digiEfficiency[3]; - - TH1F* totalSimHits; - TH1F* primarySimHits; - TH1F* otherSimHits; - - TH1F* curvature; - TH1F* width; - TH1F* deltaXlocal; -}; - -class VectorHitsBuilderValidation : public edm::one::EDAnalyzer { -public: - typedef edm::Ref, Phase2TrackerCluster1D> Phase2TrackerCluster1DRef; - - typedef std::map > SimHitsMap; - typedef std::map SimTracksMap; - - explicit VectorHitsBuilderValidation(const edm::ParameterSet&); - ~VectorHitsBuilderValidation(); - void beginJob(); - void endJob(); - void analyze(const edm::Event&, const edm::EventSetup&); - - static void fillDescriptions(edm::ConfigurationDescriptions&); - -private: - std::map::iterator createLayerHistograms(unsigned int); - void CreateVHsXYGraph(const std::vector, const std::vector); - void CreateVHsRZGraph(const std::vector, const std::vector); - void CreateWindowCorrGraph(); - - unsigned int getLayerNumber(const DetId&); - unsigned int getModuleNumber(const DetId& detid); - void printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster); - - std::pair isTrue(const VectorHit vh, - const edm::Handle >& siphase2SimLinks, - DetId& detId) const; - std::vector > getSimTrackIds( - const edm::Handle >&, const DetId&, uint32_t) const; - unsigned int getSimTrackId(const edm::Handle >& pixelSimLinks, - const DetId& detId, - unsigned int channel) const; - - edm::EDGetTokenT > srcClu_; - edm::EDGetTokenT VHacc_; - edm::EDGetTokenT VHrej_; - edm::ESInputTag cpeTag_; - const ClusterParameterEstimator* cpe_; - - edm::EDGetTokenT > siphase2OTSimLinksToken_; - edm::EDGetTokenT simHitsToken_; - edm::EDGetTokenT simTracksToken_; - edm::EDGetTokenT simVerticesToken_; - edm::EDGetTokenT trackingParticleToken_; - - const TrackerGeometry* tkGeom_; - const TrackerTopology* tkTopo_; - const MagneticField* magField_; - - TTree* tree_; - TGraph* trackerLayoutRZ_[3]; - TGraph* trackerLayoutXY_[3]; - TGraph* trackerLayoutXYBar_; - TGraph* trackerLayoutXYEC_; - TGraph* localPosXvsDeltaX_[3]; - TGraph* localPosYvsDeltaY_[3]; - TCanvas* VHXY_; - TCanvas* VHRZ_; - std::vector arrowVHs_; - - TH2D* ParallaxCorrectionRZ_; - TH1F* VHaccLayer_; - TH1F* VHrejLayer_; - TH1F* VHaccTrueLayer_; - TH1F* VHrejTrueLayer_; - TH1F* VHaccTrue_signal_Layer_; - TH1F* VHrejTrue_signal_Layer_; - - std::map histograms_; -}; diff --git a/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc b/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc index c3946d8f19c8f..24df700d80ed4 100644 --- a/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc +++ b/RecoLocalTracker/SubCollectionProducers/src/SeedClusterRemoverPhase2.cc @@ -140,8 +140,6 @@ void SeedClusterRemoverPhase2::process(const TrackingRecHit *hit, float chi2, co << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id() << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n."; - assert(cluster.id() == outerTrackerSourceProdID); - OTs[cluster.key()] = false; assert(collectedOuterTrackers_.size() > cluster.key()); collectedOuterTrackers_[cluster.key()] = true; @@ -153,8 +151,6 @@ void SeedClusterRemoverPhase2::process(const TrackingRecHit *hit, float chi2, co << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id() << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n."; - assert(cluster.id() == outerTrackerSourceProdID); - OTs[cluster.key()] = false; assert(collectedOuterTrackers_.size() > cluster.key()); collectedOuterTrackers_[cluster.key()] = true; diff --git a/RecoTracker/FinalTrackSelectors/plugins/DuplicateTrackMerger.cc b/RecoTracker/FinalTrackSelectors/plugins/DuplicateTrackMerger.cc index 3a20b4671a9ad..0bd101844174c 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/DuplicateTrackMerger.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/DuplicateTrackMerger.cc @@ -488,16 +488,6 @@ namespace { gbrVals_[7] = tmva_outer_nMissingInner_; gbrVals_[8] = tmva_inner_nMissingOuter_; - IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_ddsz_ : gbrVals_[0] " << gbrVals_[0]; - IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_ddxy_ : gbrVals_[1] " << gbrVals_[1]; - IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_dphi_ : gbrVals_[2] " << gbrVals_[2]; - IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_dlambda_ : gbrVals_[3] " << gbrVals_[3]; - IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_dqoverp_ : gbrVals_[4] " << gbrVals_[4]; - IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_d3dr_ : gbrVals_[5] " << gbrVals_[5]; - IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_d3dz_ : gbrVals_[6] " << gbrVals_[6]; - IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_outer_nMissingInner_ : gbrVals_[7] " << gbrVals_[7]; - IfLogTrace(debug_, "DuplicateTrackMerger") << " tmva_inner_nMissingOuter_ : gbrVals_[8] " << gbrVals_[8]; - auto mvaBDTG = forest_->GetClassifier(gbrVals_); IfLogTrace(debug_, "DuplicateTrackMerger") << " mvaBDTG " << mvaBDTG; if (mvaBDTG < minBDTG_) diff --git a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py index b0ac555769792..9bc904b3ebd5e 100644 --- a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py +++ b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py @@ -102,28 +102,10 @@ ) ) from Configuration.ProcessModifiers.vectorHits_cff import vectorHits -vectorHits.toReplaceWith(earlyGeneralTracks, _trackListMerger.clone( - TrackProducers =['initialStepTracks', - 'highPtTripletStepTracks', - 'lowPtQuadStepTracks', - 'lowPtTripletStepTracks', - 'detachedQuadStepTracks', - 'pixelPairStepTracks', - 'pixelLessStepTracks', - ], - hasSelector = [1,1,1,1,1,1,1], - indivShareFrac = [1.0,0.16,0.095,0.09,0.09,0.09,0.095], - selectedTrackQuals = ['initialStepSelector:initialStep', - 'highPtTripletStepSelector:highPtTripletStep', - 'lowPtQuadStepSelector:lowPtQuadStep', - 'lowPtTripletStepSelector:lowPtTripletStep', - 'detachedQuadStep', - 'pixelPairStepSelector:pixelPairStep', - 'pixelLessStepSelector:pixelLessStep', - ], - setsToMerge = cms.VPSet( cms.PSet( tLists=cms.vint32(0,1,2,3,4,5,6), pQual=cms.bool(True) ) - ), - copyExtras = True, - makeReKeyedSeeds = cms.untracked.bool(False) - ) -) + +(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, TrackProducers = earlyGeneralTracks.TrackProducers + ['pixelLessStepTracks']) +(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, hasSelector = earlyGeneralTracks.hasSelector + [1]) +(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, indivShareFrac = earlyGeneralTracks.indivShareFrac + [0.095]) +(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, selectedTrackQuals = earlyGeneralTracks.selectedTrackQuals + ['pixelLessStepSelector:pixelLessStep']) +(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, setsToMerge = cms.VPSet( cms.PSet( tLists=cms.vint32(0,1,2,3,4,5,6), pQual=cms.bool(True)))) + diff --git a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py index 867a57fde8806..ad72a25b1959c 100644 --- a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py @@ -318,53 +318,8 @@ ] #end of vpset ) #end of clone -highPtTripletStepSelector_vectorHits = RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.multiTrackSelector.clone( - src = 'highPtTripletStepTracks', - trackSelectors = [ - RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.looseMTS.clone( - name = 'highPtTripletStepLoose', - chi2n_par = 2.0, - res_par = ( 0.003, 0.002 ), - minNumberLayers = 3, - maxNumberLostLayers = 3, - minNumber3DLayers = 3, - d0_par1 = ( 0.7, 4.0 ), - dz_par1 = ( 0.8, 4.0 ), - d0_par2 = ( 0.6, 4.0 ), - dz_par2 = ( 0.6, 4.0 ) - ), #end of pset - RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.tightMTS.clone( - name = 'highPtTripletStepTight', - preFilterName = 'highPtTripletStepLoose', - chi2n_par = 1.0, - res_par = ( 0.003, 0.002 ), - minNumberLayers = 3, - maxNumberLostLayers = 2, - minNumber3DLayers = 3, - d0_par1 = ( 0.6, 4.0 ), - dz_par1 = ( 0.7, 4.0 ), - d0_par2 = ( 0.5, 4.0 ), - dz_par2 = ( 0.6, 4.0 ) - ), - RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.highpurityMTS.clone( - name = 'highPtTripletStep', - preFilterName = 'highPtTripletStepTight', - min_eta = -4.1, - max_eta = 4.1, - chi2n_par = 0.8, - res_par = ( 0.003, 0.001 ), - min_nhits = 4, - minNumberLayers = 3, - maxNumberLostLayers = 2, - minNumber3DLayers = 3, - d0_par1 = ( 0.5, 4.0 ), - dz_par1 = ( 0.6, 4.0 ), - d0_par2 = ( 0.45, 4.0 ), - dz_par2 = ( 0.55, 4.0 ) - ), - ] #end of vpset -) #en - +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toModify(highPtTripletStepSelector.trackSelectors[2], minNumberLayers = 3, minNumber3DLayers = 3, d0_par1 = ( 0.5, 4.0 ), dz_par1 = ( 0.6, 4.0 )) # Final sequence HighPtTripletStepTask = cms.Task(highPtTripletStepClusters, @@ -382,8 +337,6 @@ _HighPtTripletStep_Phase2PU140 = cms.Sequence(_HighPtTripletStepTask_Phase2PU140) trackingPhase2PU140.toReplaceWith(HighPtTripletStepTask, _HighPtTripletStepTask_Phase2PU140) -from Configuration.ProcessModifiers.vectorHits_cff import vectorHits -vectorHits.toReplaceWith(highPtTripletStepSelector, highPtTripletStepSelector_vectorHits) # fast tracking mask producer from FastSimulation.Tracking.FastTrackerRecHitMaskProducer_cfi import maskProducerFromClusterRemover highPtTripletStepMasks = maskProducerFromClusterRemover(highPtTripletStepClusters) diff --git a/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py index 0f1d9aeb10c12..266a80b156123 100644 --- a/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py @@ -362,53 +362,9 @@ ), #end of vpset ) #end of clone -from Configuration.ProcessModifiers.vectorHits_cff import vectorHits -vectorHits.toModify(lowPtTripletStepSelector, - trackSelectors= cms.VPSet( - RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.looseMTS.clone( - name = 'lowPtTripletStepLoose', - chi2n_par = 1.2, - res_par = ( 0.003, 0.002 ), - minNumberLayers = 3, - maxNumberLostLayers = 2, - minNumber3DLayers = 3, - d0_par1 = ( 0.7, 4.0 ), - dz_par1 = ( 0.7, 4.0 ), - d0_par2 = ( 0.6, 4.0 ), - dz_par2 = ( 0.6, 4.0 ) - ), #end of pset - RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.tightMTS.clone( - name = 'lowPtTripletStepTight', - preFilterName = 'lowPtTripletStepLoose', - chi2n_par = 0.7, - res_par = ( 0.003, 0.002 ), - minNumberLayers = 3, - maxNumberLostLayers = 2, - minNumber3DLayers = 3, - d0_par1 = ( 0.6, 4.0 ), - dz_par1 = ( 0.6, 4.0 ), - d0_par2 = ( 0.5, 4.0 ), - dz_par2 = ( 0.5, 4.0 ) - ), - RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.highpurityMTS.clone( - name = 'lowPtTripletStep', - preFilterName = 'lowPtTripletStepTight', - min_eta = -4.0, - max_eta = 4.0, - chi2n_par = 0.4, - res_par = ( 0.003, 0.001 ), - min_nhits = 3, - minNumberLayers = 3, - maxNumberLostLayers = 2, - minNumber3DLayers = 3, - d0_par1 = ( 0.5, 4.0 ), - dz_par1 = ( 0.5, 4.0 ), - d0_par2 = ( 0.45, 4.0 ), - dz_par2 = ( 0.45, 4.0 ) - ), - ), #end of vpset -) #end of clone +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toModify(lowPtTripletStepSelector.trackSelectors[2], minNumberLayers = 3, minNumber3DLayers = 3) # Final sequence diff --git a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py index c9d5cd19de4d8..904b1d81aedf0 100644 --- a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py @@ -114,17 +114,13 @@ TOB = cms.PSet( TTRHBuilder = cms.string('WithTrackAngle'), clusterChargeCut = cms.PSet(refToPSet_ = cms.string('SiStripClusterChargeCutNone')), - vectorRecHits = cms.InputTag("siPhase2VectorHits", 'accepted'), + vectorRecHits = cms.InputTag("siPhase2VectorHits", 'vectorHitsAccepted'), skipClusters = cms.InputTag('pixelLessStepClusters') ), TIB = None, - TID = cms.PSet( - TTRHBuilder = cms.string('WithTrackAngle'), - clusterChargeCut = cms.PSet(refToPSet_ = cms.string('SiStripClusterChargeCutNone')), + TID = dict( + clusterChargeCut = dict(refToPSet_ = cms.string('SiStripClusterChargeCutNone')), vectorRecHits = cms.InputTag("siPhase2VectorHits", 'accepted'), - skipClusters = cms.InputTag('pixelLessStepClusters'), - useRingSlector = cms.bool(True), - minRing = cms.int32(1), maxRing = cms.int32(8) ), TEC = None, @@ -224,12 +220,9 @@ vectorHits.toModify(pixelLessStepHitDoublets, produceSeedingHitSets=True, produceIntermediateHitDoublets=False) vectorHits.toModify(pixelLessStepSeeds, seedingHitSets = "pixelLessStepHitDoublets", - SeedComparitorPSet = cms.PSet( - ClusterShapeCacheSrc = cms.InputTag("siPixelClusterShapeCache"), + SeedComparitorPSet = dict( ClusterShapeHitFilterName = cms.string('ClusterShapeHitFilter'), - ComponentName = cms.string('PixelClusterShapeSeedComparitor'), FilterAtHelixStage = cms.bool(False), - FilterPixelHits = cms.bool(False), FilterStripHits = cms.bool(False), ) ) @@ -264,7 +257,7 @@ vectorHits.toModify(pixelLessStepChi2Est, clusterChargeCut = dict(refToPSet_ = 'SiStripClusterChargeCutNone'), - MaxChi2 = cms.double(30.0) + MaxChi2 = 30.0 ) # TRACK BUILDING diff --git a/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py b/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py index 9570c259b6b6a..81eb716d6a39b 100644 --- a/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py @@ -420,51 +420,7 @@ ) #end of clone from Configuration.ProcessModifiers.vectorHits_cff import vectorHits -vectorHits.toModify(pixelPairStepSelector, - trackSelectors = cms.VPSet( - RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.looseMTS.clone( - name = 'pixelPairStepLoose', - chi2n_par = 0.7, - res_par = ( 0.003, 0.002 ), - minNumberLayers = 3, - maxNumberLostLayers = 2, - minNumber3DLayers = 3, - d0_par1 = ( 0.4, 4.0 ), - dz_par1 = ( 0.4, 4.0 ), - d0_par2 = ( 0.6, 4.0 ), - dz_par2 = ( 0.45, 4.0 ) - ), #end of pset - RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.tightMTS.clone( - name = 'pixelPairStepTight', - preFilterName = 'pixelPairStepLoose', - chi2n_par = 0.6, - res_par = ( 0.003, 0.002 ), - minNumberLayers = 4, - maxNumberLostLayers = 2, - minNumber3DLayers = 3, - d0_par1 = ( 0.35, 4.0 ), - dz_par1 = ( 0.35, 4.0 ), - d0_par2 = ( 0.5, 4.0 ), - dz_par2 = ( 0.4, 4.0 ) - ), - RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.highpurityMTS.clone( - name = 'pixelPairStep', - preFilterName = 'pixelPairStepTight', -# min_eta = -4.0, # useless, the eta distribution does not even reach |eta| = 3 (!) -# max_eta = 4.0, - chi2n_par = 0.5, - res_par = ( 0.003, 0.001 ), - minNumberLayers = 4, - maxNumberLostLayers = 2, - minNumber3DLayers = 3, - d0_par1 = ( 0.3, 4.0 ), - dz_par1 = ( 0.3, 4.0 ), - d0_par2 = ( 0.45, 4.0 ), - dz_par2 = ( 0.35, 4.0 ) - ), - ), #end of vpset - vertices = 'firstStepPrimaryVertices' -) #end of clone +vectorHits.toModify(pixelPairStepSelector.trackSelectors[2], minNumberLayers = 3, minNumber3DLayers = 3) # Final sequence PixelPairStepTask = cms.Task(pixelPairStepClusters, From 41ed2adb2ab1a0f7cf00a9ce996f2b6ec9b973aa Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 01:12:53 +0200 Subject: [PATCH 099/115] add renamed files --- .../test/VectorHitsBuilderValidation.cc | 1137 +++++++++++++++++ .../test/VectorHitsBuilderValidation.h | 152 +++ 2 files changed, 1289 insertions(+) create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsBuilderValidation.cc create mode 100644 RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsBuilderValidation.h diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsBuilderValidation.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsBuilderValidation.cc new file mode 100644 index 0000000000000..aac23a7052c51 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsBuilderValidation.cc @@ -0,0 +1,1137 @@ +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h" +#include "SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h" +#include "RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsBuilderValidation.h" +#include "Geometry/CommonDetUnit/interface/StackGeomDet.h" +#include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" +#include "DataFormats/SiStripDetId/interface/StripSubdetector.h" + +VectorHitsBuilderValidation::VectorHitsBuilderValidation(const edm::ParameterSet& conf) + : cpeTag_(conf.getParameter("CPE")) { + srcClu_ = + consumes >(edm::InputTag(conf.getParameter("src"))); + VHacc_ = consumes(edm::InputTag(conf.getParameter("VH_acc"))); + VHrej_ = consumes(edm::InputTag(conf.getParameter("VH_rej"))); + siphase2OTSimLinksToken_ = consumes >(conf.getParameter("links")); + simHitsToken_ = consumes(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof")); + simTracksToken_ = consumes(edm::InputTag("g4SimHits")); + simVerticesToken_ = consumes(edm::InputTag("g4SimHits")); + trackingParticleToken_ = + consumes(conf.getParameter("trackingParticleSrc")); +} + +VectorHitsBuilderValidation::~VectorHitsBuilderValidation() {} + +void VectorHitsBuilderValidation::beginJob() { + edm::Service fs; + fs->file().cd("/"); + TFileDirectory td = fs->mkdir("Common"); + + //Create common ntuple + tree_ = td.make("VectorHits", "VectorHits"); + + // Create common graphs + TFileDirectory tdGloPos = td.mkdir("GlobalPositions"); + trackerLayoutRZ_[0] = tdGloPos.make(); + trackerLayoutRZ_[0]->SetName("RVsZ_Mixed"); + trackerLayoutRZ_[1] = tdGloPos.make(); + trackerLayoutRZ_[1]->SetName("RVsZ_Pixel"); + trackerLayoutRZ_[2] = tdGloPos.make(); + trackerLayoutRZ_[2]->SetName("RVsZ_Strip"); + trackerLayoutXY_[0] = tdGloPos.make(); + trackerLayoutXY_[0]->SetName("YVsX_Mixed"); + trackerLayoutXY_[1] = tdGloPos.make(); + trackerLayoutXY_[1]->SetName("YVsX_Pixel"); + trackerLayoutXY_[2] = tdGloPos.make(); + trackerLayoutXY_[2]->SetName("YVsX_Strip"); + trackerLayoutXYBar_ = tdGloPos.make(); + trackerLayoutXYBar_->SetName("YVsXBar"); + trackerLayoutXYEC_ = tdGloPos.make(); + trackerLayoutXYEC_->SetName("YVsXEC"); + + TFileDirectory tdLocPos = td.mkdir("LocalPositions"); + localPosXvsDeltaX_[0] = tdLocPos.make(); + localPosXvsDeltaX_[0]->SetName("localPosXvsDeltaX_Mixed"); + localPosXvsDeltaX_[1] = tdLocPos.make(); + localPosXvsDeltaX_[1]->SetName("localPosXvsDeltaX_Pixel"); + localPosXvsDeltaX_[2] = tdLocPos.make(); + localPosXvsDeltaX_[2]->SetName("localPosXvsDeltaX_Strip"); + localPosYvsDeltaY_[0] = tdLocPos.make(); + localPosYvsDeltaY_[0]->SetName("localPosYvsDeltaY_Mixed"); + localPosYvsDeltaY_[1] = tdLocPos.make(); + localPosYvsDeltaY_[1]->SetName("localPosYvsDeltaY_Pixel"); + localPosYvsDeltaY_[2] = tdLocPos.make(); + localPosYvsDeltaY_[2]->SetName("localPosYvsDeltaY_Strip"); + + //drawing VHs arrows + TFileDirectory tdArr = td.mkdir("Directions"); + + TFileDirectory tdWid = td.mkdir("CombinatorialStudies"); + ParallaxCorrectionRZ_ = + tdWid.make("ParallaxCorrectionRZ", "ParallaxCorrectionRZ", 100, 0., 300., 100., 0., 120.); + ParallaxCorrectionRZ_->SetName("ParallaxCorrectionFactor"); + VHaccLayer_ = tdWid.make("VHacceptedLayer", "VHacceptedLayer", 250, 0., 250.); + VHaccLayer_->SetName("VHaccepted"); + VHrejLayer_ = tdWid.make("VHrejectedLayer", "VHrejectedLayer", 250, 0., 250.); + VHrejLayer_->SetName("VHrejected"); + VHaccTrueLayer_ = tdWid.make("VHaccTrueLayer", "VHaccTrueLayer", 250, 0., 250.); + VHaccTrueLayer_->SetName("VHaccepted_true"); + VHrejTrueLayer_ = tdWid.make("VHrejTrueLayer", "VHrejTrueLayer", 250, 0., 250.); + VHrejTrueLayer_->SetName("VHrejected_true"); + VHaccTrue_signal_Layer_ = tdWid.make("VHaccTrueSignalLayer", "VHaccTrueSignalLayer", 250, 0., 250.); + VHaccTrue_signal_Layer_->SetName("VHaccepted_true_signal"); + VHrejTrue_signal_Layer_ = tdWid.make("VHrejTrueSignalLayer", "VHrejTrueSignalLayer", 250, 0., 250.); + VHrejTrue_signal_Layer_->SetName("VHrejected_true_signal"); +} + +void VectorHitsBuilderValidation::endJob() {} + +void VectorHitsBuilderValidation::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) { + // Get the needed objects + + // Get the clusters + edm::Handle clusters; + event.getByToken(srcClu_, clusters); + + // Get the vector hits + edm::Handle vhsAcc; + event.getByToken(VHacc_, vhsAcc); + + edm::Handle vhsRej; + event.getByToken(VHrej_, vhsRej); + + // load the cpe via the eventsetup + edm::ESHandle > cpeHandle; + eventSetup.get().get(cpeTag_, cpeHandle); + cpe_ = cpeHandle.product(); + + // Get the Phase2 DigiSimLink + edm::Handle > siphase2SimLinks; + event.getByToken(siphase2OTSimLinksToken_, siphase2SimLinks); + + // Get the SimHits + edm::Handle simHitsRaw; + event.getByToken(simHitsToken_, simHitsRaw); + + // Get the SimTracks + edm::Handle simTracksRaw; + event.getByToken(simTracksToken_, simTracksRaw); + + // Get the SimVertex + edm::Handle simVertices; + event.getByToken(simVerticesToken_, simVertices); + + // Get the geometry + edm::ESHandle geomHandle; + eventSetup.get().get(geomHandle); + tkGeom_ = &(*geomHandle); + + // Get the Topology + edm::ESHandle tTopoHandle; + eventSetup.get().get(tTopoHandle); + tkTopo_ = tTopoHandle.product(); + + edm::ESHandle magFieldHandle; + eventSetup.get().get(magFieldHandle); + magField_ = magFieldHandle.product(); + + //Tracking Particle collection + edm::Handle TPCollectionH; + event.getByToken(trackingParticleToken_, TPCollectionH); + + auto clusterTPList = std::make_unique(TPCollectionH); + std::map, TrackingParticleRef> mapping; + + for (TrackingParticleCollection::size_type itp = 0; itp < TPCollectionH.product()->size(); ++itp) { + TrackingParticleRef trackingParticle(TPCollectionH, itp); + EncodedEventId eid(trackingParticle->eventId()); + for (std::vector::const_iterator itrk = trackingParticle->g4Track_begin(); + itrk != trackingParticle->g4Track_end(); + ++itrk) { + std::pair trkid(itrk->trackId(), eid); + LogTrace("VectorHitsBuilderValidation") + << "creating map for id: " << trkid.first << " with tp: " << trackingParticle.key(); + mapping.insert(std::make_pair(trkid, trackingParticle)); + } + } + + //set up for tree + int eventNum; + int layer; + int module_id; + int module_number; + int module_type; //1: pixel, 2: strip + int VHacc = 0.0; + int VHrej = 0.0; + int vh_isTrue; + + float x_global, y_global, z_global; + float vh_x_local, vh_y_local; + float vh_x_le, vh_y_le; + float curvature, phi; + float QOverPT, QOverP; + float chi2; + + int low_tp_id, upp_tp_id; + float vh_sim_trackPt; + float sim_x_local, sim_y_local; + float sim_x_global, sim_y_global, sim_z_global; + float low_x_global, low_y_global, low_z_global; + float upp_x_global, upp_y_global, upp_z_global; + float low_xx_global_err, low_yy_global_err, low_zz_global_err; + float low_xy_global_err, low_zx_global_err, low_zy_global_err; + float upp_xx_global_err, upp_yy_global_err, upp_zz_global_err; + float upp_xy_global_err, upp_zx_global_err, upp_zy_global_err; + float deltaXVHSimHits, deltaYVHSimHits; + int multiplicity; + float width, deltaXlocal; + unsigned int processType(99); + + tree_->Branch("event", &eventNum, "eventNum/I"); + tree_->Branch("accepted", &VHacc, "VHacc/I"); + tree_->Branch("rejected", &VHrej, "VHrej/I"); + tree_->Branch("layer", &layer, "layer/I"); + tree_->Branch("module_id", &module_id, "module_id/I"); + tree_->Branch("module_type", &module_type, "module_type/I"); + tree_->Branch("module_number", &module_number, "module_number/I"); + tree_->Branch("vh_isTrue", &vh_isTrue, "vh_isTrue/I"); + tree_->Branch("x_global", &x_global, "x_global/F"); + tree_->Branch("y_global", &y_global, "y_global/F"); + tree_->Branch("z_global", &z_global, "z_global/F"); + tree_->Branch("vh_x_local", &vh_x_local, "vh_x_local/F"); + tree_->Branch("vh_y_local", &vh_y_local, "vh_y_local/F"); + tree_->Branch("vh_x_lError", &vh_x_le, "vh_x_le/F"); + tree_->Branch("vh_y_lError", &vh_y_le, "vh_y_le/F"); + tree_->Branch("curvature", &curvature, "curvature/F"); + tree_->Branch("chi2", &chi2, "chi2/F"); + tree_->Branch("phi", &phi, "phi/F"); + tree_->Branch("QOverP", &QOverP, "QOverP/F"); + tree_->Branch("QOverPT", &QOverPT, "QOverPT/F"); + tree_->Branch("low_tp_id", &low_tp_id, "low_tp_id/I"); + tree_->Branch("upp_tp_id", &upp_tp_id, "upp_tp_id/I"); + tree_->Branch("vh_sim_trackPt", &vh_sim_trackPt, "vh_sim_trackPt/F"); + tree_->Branch("sim_x_local", &sim_x_local, "sim_x_local/F"); + tree_->Branch("sim_y_local", &sim_y_local, "sim_y_local/F"); + tree_->Branch("sim_x_global", &sim_x_global, "sim_x_global/F"); + tree_->Branch("sim_y_global", &sim_y_global, "sim_y_global/F"); + tree_->Branch("sim_z_global", &sim_z_global, "sim_z_global/F"); + tree_->Branch("low_x_global", &low_x_global, "low_x_global/F"); + tree_->Branch("low_y_global", &low_y_global, "low_y_global/F"); + tree_->Branch("low_z_global", &low_z_global, "low_z_global/F"); + tree_->Branch("low_xx_global_err", &low_xx_global_err, "low_xx_global_err/F"); + tree_->Branch("low_yy_global_err", &low_yy_global_err, "low_yy_global_err/F"); + tree_->Branch("low_zz_global_err", &low_zz_global_err, "low_zz_global_err/F"); + tree_->Branch("low_xy_global_err", &low_xy_global_err, "low_xy_global_err/F"); + tree_->Branch("low_zx_global_err", &low_zx_global_err, "low_zx_global_err/F"); + tree_->Branch("low_zy_global_err", &low_zy_global_err, "low_zy_global_err/F"); + tree_->Branch("upp_x_global", &upp_x_global, "upp_x_global/F"); + tree_->Branch("upp_y_global", &upp_y_global, "upp_y_global/F"); + tree_->Branch("upp_z_global", &upp_z_global, "upp_z_global/F"); + tree_->Branch("upp_xx_global_err", &upp_xx_global_err, "upp_xx_global_err/F"); + tree_->Branch("upp_yy_global_err", &upp_yy_global_err, "upp_yy_global_err/F"); + tree_->Branch("upp_zz_global_err", &upp_zz_global_err, "upp_zz_global_err/F"); + tree_->Branch("upp_xy_global_err", &upp_xy_global_err, "upp_xy_global_err/F"); + tree_->Branch("upp_zx_global_err", &upp_zx_global_err, "upp_zx_global_err/F"); + tree_->Branch("upp_zy_global_err", &upp_zy_global_err, "upp_zy_global_err/F"); + tree_->Branch("deltaXVHSimHits", &deltaXVHSimHits, "deltaXVHSimHits/F"); + tree_->Branch("deltaYVHSimHits", &deltaYVHSimHits, "deltaYVHSimHits/F"); + tree_->Branch("multiplicity", &multiplicity, "multiplicity/I"); + tree_->Branch("width", &width, "width/F"); + tree_->Branch("deltaXlocal", &deltaXlocal, "deltaXlocal/F"); + tree_->Branch("processType", &processType, "processType/i"); + + // Rearrange the simTracks for ease of use + SimTracksMap simTracks; + for (const auto& simTrackIt : *simTracksRaw.product()) + simTracks.emplace(std::pair(simTrackIt.trackId(), simTrackIt)); + + // Rearrange the simHits by detUnit for ease of use + SimHitsMap simHitsDetUnit; + SimHitsMap simHitsTrackId; + for (const auto& simHitIt : *simHitsRaw.product()) { + SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt.detUnitId())); + if (simHitsDetUnitIt == simHitsDetUnit.end()) { + std::pair newIt(simHitsDetUnit.insert( + std::pair >(simHitIt.detUnitId(), std::vector()))); + simHitsDetUnitIt = newIt.first; + } + simHitsDetUnitIt->second.push_back(simHitIt); + + SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt.trackId())); + if (simHitsTrackIdIt == simHitsTrackId.end()) { + std::pair newIt(simHitsTrackId.insert( + std::pair >(simHitIt.trackId(), std::vector()))); + simHitsTrackIdIt = newIt.first; + } + simHitsTrackIdIt->second.push_back(simHitIt); + } + + //Printout outer tracker clusters in the event + for (const auto& DSViter : *clusters) { + unsigned int rawid(DSViter.detId()); + DetId detId(rawid); + const GeomDetUnit* geomDetUnit(tkGeom_->idToDetUnit(detId)); + const PixelGeomDetUnit* theGeomDet = dynamic_cast(geomDetUnit); + for (const auto& clustIt : DSViter) { + auto&& lparams = cpe_->localParameters(clustIt, *theGeomDet); + Global3DPoint gparams = theGeomDet->surface().toGlobal(lparams.first); + LogTrace("VectorHitsBuilderValidation") << "phase2 OT clusters: " << gparams << " DetId: " << rawid; + } + } + + for (const auto& DSViter : *vhsAcc) { + for (const auto& vhIt : DSViter) { + LogTrace("VectorHitsBuilderValidation") << "accepted VH: " << vhIt; + } + } + for (const auto& DSViter : *vhsRej) { + for (const auto& vhIt : DSViter) { + LogTrace("VectorHitsBuilderValidation") << "rejected VH: " << vhIt; + } + } + // Validation + eventNum = event.id().event(); + + unsigned int nVHsTot(0), nVHsPSTot(0), nVHs2STot(0); + std::vector glVHs; + std::vector dirVHs; + std::vector detIds; + + // Loop over modules + for (const auto DSViter : *vhsAcc) { + // Get the detector unit's id + unsigned int rawid(DSViter.detId()); + module_id = rawid; + DetId detId(rawid); + + module_number = getModuleNumber(detId); + layer = getLayerNumber(detId); + + LogDebug("VectorHitsBuilderValidation") << "Layer: " << layer << " det id" << rawid << std::endl; + + // Get the geometry of the tracker + const GeomDet* geomDet(tkGeom_->idToDet(detId)); + if (!geomDet) + break; + + // Create histograms for the layer if they do not yet exist + std::map::iterator histogramLayer(histograms_.find(layer)); + if (histogramLayer == histograms_.end()) + histogramLayer = createLayerHistograms(layer); + // Number of clusters + unsigned int nVHsPS(0), nVHs2S(0); + + LogDebug("VectorHitsBuilderValidation") << "DSViter size: " << DSViter.size(); + + // Loop over the vhs in the detector unit + for (const auto& vhIt : DSViter) { + // vh variables + if (vhIt.isValid()) { + LogDebug("VectorHitsBuilderValidation") << " vh analyzing ..."; + chi2 = vhIt.chi2(); + LogTrace("VectorHitsBuilderValidation") << "VH chi2 " << chi2 << std::endl; + + Local3DPoint localPosVH = vhIt.localPosition(); + vh_x_local = localPosVH.x(); + vh_y_local = localPosVH.y(); + LogTrace("VectorHitsBuilderValidation") << "local VH position " << localPosVH << std::endl; + + LocalError localErrVH = vhIt.localPositionError(); + vh_x_le = localErrVH.xx(); + vh_y_le = localErrVH.yy(); + LogTrace("VectorHitsBuilderValidation") << "local VH error " << localErrVH << std::endl; + + Global3DPoint globalPosVH = geomDet->surface().toGlobal(localPosVH); + x_global = globalPosVH.x(); + y_global = globalPosVH.y(); + z_global = globalPosVH.z(); + glVHs.push_back(globalPosVH); + LogTrace("VectorHitsBuilderValidation") << " global VH position " << globalPosVH << std::endl; + + Local3DVector localDirVH = vhIt.localDirection(); + LogTrace("VectorHitsBuilderValidation") << "local VH direction " << localDirVH << std::endl; + + VectorHit vh = vhIt; + Global3DVector globalDirVH = vh.globalDirectionVH(); + dirVHs.push_back(globalDirVH); + LogTrace("VectorHitsBuilderValidation") << "global VH direction " << globalDirVH << std::endl; + + // Fill the position histograms + trackerLayoutRZ_[0]->SetPoint(nVHsTot, globalPosVH.z(), globalPosVH.perp()); + trackerLayoutXY_[0]->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + + if (layer < 100) + trackerLayoutXYBar_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + else + trackerLayoutXYEC_->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + + histogramLayer->second.localPosXY[0]->SetPoint(nVHsTot, vh_x_local, vh_y_local); + histogramLayer->second.globalPosXY[0]->SetPoint(nVHsTot, globalPosVH.x(), globalPosVH.y()); + + localPosXvsDeltaX_[0]->SetPoint(nVHsTot, vh_x_local, localDirVH.x()); + localPosYvsDeltaY_[0]->SetPoint(nVHsTot, vh_y_local, localDirVH.y()); + + // Pixel module + const StackGeomDet* stackDet = dynamic_cast(geomDet); + const PixelGeomDetUnit* geomDetLower = dynamic_cast(stackDet->lowerDet()); + DetId lowerDetId = stackDet->lowerDet()->geographicalId(); + DetId upperDetId = stackDet->upperDet()->geographicalId(); + + TrackerGeometry::ModuleType mType = tkGeom_->getDetectorType(lowerDetId); + module_type = 0; + if (mType == TrackerGeometry::ModuleType::Ph2PSP) { + module_type = 1; + trackerLayoutRZ_[1]->SetPoint(nVHsPSTot, globalPosVH.z(), globalPosVH.perp()); + trackerLayoutXY_[1]->SetPoint(nVHsPSTot, globalPosVH.x(), globalPosVH.y()); + + histogramLayer->second.localPosXY[1]->SetPoint(nVHsPSTot, vh_x_local, vh_y_local); + histogramLayer->second.globalPosXY[1]->SetPoint(nVHsPSTot, globalPosVH.x(), globalPosVH.y()); + + localPosXvsDeltaX_[1]->SetPoint(nVHsPSTot, vh_x_local, localDirVH.x()); + localPosYvsDeltaY_[1]->SetPoint(nVHsPSTot, vh_y_local, localDirVH.y()); + + ++nVHsPS; + ++nVHsPSTot; + } + + // Strip module + else if (mType == TrackerGeometry::ModuleType::Ph2SS) { + module_type = 2; + trackerLayoutRZ_[2]->SetPoint(nVHs2STot, globalPosVH.z(), globalPosVH.perp()); + trackerLayoutXY_[2]->SetPoint(nVHs2STot, globalPosVH.x(), globalPosVH.y()); + + histogramLayer->second.localPosXY[2]->SetPoint(nVHs2STot, vh_x_local, vh_y_local); + histogramLayer->second.globalPosXY[2]->SetPoint(nVHs2STot, globalPosVH.x(), globalPosVH.y()); + + localPosXvsDeltaX_[2]->SetPoint(nVHs2STot, vh_x_local, localDirVH.x()); + localPosYvsDeltaY_[2]->SetPoint(nVHs2STot, vh_y_local, localDirVH.y()); + + ++nVHs2S; + ++nVHs2STot; + } else if (mType == TrackerGeometry::ModuleType::Ph2PSS) { + edm::LogError("VectorHitsBuilderValidation") << "module type " << module_type << " should never happen!"; + } + LogTrace("VectorHitsBuilderValidation") << "module type " << module_type << std::endl; + + // get the geomDetUnit of the clusters + low_x_global = vhIt.lowerGlobalPos().x(); + low_y_global = vhIt.lowerGlobalPos().y(); + low_z_global = vhIt.lowerGlobalPos().z(); + upp_x_global = vhIt.upperGlobalPos().x(); + upp_y_global = vhIt.upperGlobalPos().y(); + upp_z_global = vhIt.upperGlobalPos().z(); + + low_xx_global_err = vhIt.lowerGlobalPosErr().cxx(); + low_yy_global_err = vhIt.lowerGlobalPosErr().cyy(); + low_zz_global_err = vhIt.lowerGlobalPosErr().czz(); + low_xy_global_err = vhIt.lowerGlobalPosErr().cyx(); + low_zx_global_err = vhIt.lowerGlobalPosErr().czx(); + low_zy_global_err = vhIt.lowerGlobalPosErr().czy(); + + upp_xx_global_err = vhIt.upperGlobalPosErr().cxx(); + upp_yy_global_err = vhIt.upperGlobalPosErr().cyy(); + upp_zz_global_err = vhIt.upperGlobalPosErr().czz(); + upp_xy_global_err = vhIt.upperGlobalPosErr().cyx(); + upp_zx_global_err = vhIt.upperGlobalPosErr().czx(); + upp_zy_global_err = vhIt.upperGlobalPosErr().czy(); + + LogDebug("VectorHitsBuilderValidation") << "print Clusters into the VH:" << std::endl; + printCluster(geomDetLower, vhIt.lowerClusterRef()); + LogTrace("VectorHitsBuilderValidation") << "\t global pos lower " << vhIt.lowerGlobalPos() << std::endl; + LogTrace("VectorHitsBuilderValidation") + << "\t global posErr lower " << vhIt.lowerGlobalPosErr().cxx() << std::endl; + const GeomDetUnit* geomDetUpper = stackDet->upperDet(); + printCluster(geomDetUpper, vhIt.upperClusterRef()); + LogTrace("VectorHitsBuilderValidation") << "\t global pos upper " << vhIt.upperGlobalPos() << std::endl; + + //comparison with SIM hits + LogDebug("VectorHitsBuilderValidation") << "comparison Clusters with sim hits ... " << std::endl; + std::vector clusterSimTrackIds; + std::vector clusterSimTrackIdsUpp; + std::set > simTkIds; + const GeomDetUnit* geomDetUnit_low(tkGeom_->idToDetUnit(lowerDetId)); + LogTrace("VectorHitsBuilderValidation") << " lowerDetID : " << lowerDetId.rawId(); + const GeomDetUnit* geomDetUnit_upp(tkGeom_->idToDetUnit(upperDetId)); + LogTrace("VectorHitsBuilderValidation") << " upperDetID : " << upperDetId.rawId(); + + for (unsigned int istr(0); istr < (*(vhIt.lowerClusterRef().cluster_phase2OT())).size(); ++istr) { + uint32_t channel = + Phase2TrackerDigi::pixelToChannel((*(vhIt.lowerClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vhIt.lowerClusterRef().cluster_phase2OT())).column()); + unsigned int LowerSimTrackId(getSimTrackId(siphase2SimLinks, lowerDetId, channel)); + std::vector > trkid( + getSimTrackIds(siphase2SimLinks, lowerDetId, channel)); + if (trkid.size() == 0) + continue; + clusterSimTrackIds.push_back(LowerSimTrackId); + simTkIds.insert(trkid.begin(), trkid.end()); + LogTrace("VectorHitsBuilderValidation") << "LowerSimTrackId " << LowerSimTrackId << std::endl; + } + // In the case of PU, we need the TPs to find the proper SimTrackID + for (const auto& iset : simTkIds) { + auto ipos = mapping.find(iset); + if (ipos != mapping.end()) { + LogTrace("VectorHitsBuilderValidation") << "lower cluster in detid: " << lowerDetId.rawId() + << " from tp: " << ipos->second.key() << " " << iset.first; + LogTrace("VectorHitsBuilderValidation") << "with pt(): " << (*ipos->second).pt(); + low_tp_id = ipos->second.key(); + vh_sim_trackPt = (*ipos->second).pt(); + } + } + + simTkIds.clear(); + for (unsigned int istr(0); istr < (*(vhIt.upperClusterRef().cluster_phase2OT())).size(); ++istr) { + uint32_t channel = + Phase2TrackerDigi::pixelToChannel((*(vhIt.upperClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vhIt.upperClusterRef().cluster_phase2OT())).column()); + unsigned int UpperSimTrackId(getSimTrackId(siphase2SimLinks, upperDetId, channel)); + std::vector > trkid( + getSimTrackIds(siphase2SimLinks, upperDetId, channel)); + if (trkid.size() == 0) + continue; + clusterSimTrackIdsUpp.push_back(UpperSimTrackId); + simTkIds.insert(trkid.begin(), trkid.end()); + LogTrace("VectorHitsBuilderValidation") << "UpperSimTrackId " << UpperSimTrackId << std::endl; + } + // In the case of PU, we need the TPs to find the proper SimTrackID + for (const auto& iset : simTkIds) { + auto ipos = mapping.find(iset); + if (ipos != mapping.end()) { + LogTrace("VectorHitsBuilderValidation") + << "upper cluster in detid: " << upperDetId.rawId() << " from tp: " << ipos->second.key() << " " + << iset.first << std::endl; + upp_tp_id = ipos->second.key(); + } + } + //compute if the vhits is 'true' or 'false' and save sim pT + std::pair istrue = isTrue(vhIt, siphase2SimLinks, detId); + vh_isTrue = 0; + if (istrue.first) { + vh_isTrue = 1; + } + + // loop over all simHits + unsigned int totalSimHits(0); + unsigned int primarySimHits(0); + unsigned int otherSimHits(0); + + for (const auto& hitIt : *simHitsRaw) { + if (hitIt.detUnitId() == geomDetLower->geographicalId()) { + //check clusters track id compatibility + if (std::find(clusterSimTrackIds.begin(), clusterSimTrackIds.end(), hitIt.trackId()) != + clusterSimTrackIds.end()) { + Local3DPoint localPosHit(hitIt.localPosition()); + sim_x_local = localPosHit.x(); + sim_y_local = localPosHit.y(); + + deltaXVHSimHits = vh_x_local - sim_x_local; + deltaYVHSimHits = vh_y_local - sim_y_local; + + Global3DPoint globalPosHit = geomDetLower->surface().toGlobal(localPosHit); + sim_x_global = globalPosHit.x(); + sim_y_global = globalPosHit.y(); + sim_z_global = globalPosHit.z(); + + histogramLayer->second.deltaXVHSimHits[0]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits[0]->Fill(vh_y_local - sim_y_local); + + // Pixel module + if (layer == 1 || layer == 2 || layer == 3) { + histogramLayer->second.deltaXVHSimHits[1]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits[1]->Fill(vh_y_local - sim_y_local); + } + // Strip module + else if (layer == 4 || layer == 5 || layer == 6) { + histogramLayer->second.deltaXVHSimHits[2]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits[2]->Fill(vh_y_local - sim_y_local); + } + + ++totalSimHits; + + std::map::const_iterator simTrackIt(simTracks.find(hitIt.trackId())); + if (simTrackIt == simTracks.end()) + continue; + + // Primary particles only + processType = hitIt.processType(); + + if (simTrackIt->second.vertIndex() == 0 and + (processType == 2 || processType == 7 || processType == 9 || processType == 11 || processType == 13 || + processType == 15)) { + histogramLayer->second.deltaXVHSimHits_P[0]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits_P[0]->Fill(vh_y_local - sim_y_local); + + // Pixel module + if (layer == 1 || layer == 2 || layer == 3) { + histogramLayer->second.deltaXVHSimHits_P[1]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits_P[1]->Fill(vh_y_local - sim_y_local); + } + // Strip module + else if (layer == 4 || layer == 5 || layer == 6) { + histogramLayer->second.deltaXVHSimHits_P[2]->Fill(vh_x_local - sim_x_local); + histogramLayer->second.deltaYVHSimHits_P[2]->Fill(vh_y_local - sim_y_local); + } + + ++primarySimHits; + } + + otherSimHits = totalSimHits - primarySimHits; + + histogramLayer->second.totalSimHits->Fill(totalSimHits); + histogramLayer->second.primarySimHits->Fill(primarySimHits); + histogramLayer->second.otherSimHits->Fill(otherSimHits); + } + } + } // loop simhits + + nVHsTot++; + + //****************************** + //combinatorial studies : not filling if more than 1 VH has been produced + //****************************** + multiplicity = DSViter.size(); + if (DSViter.size() > 1) { + LogTrace("VectorHitsBuilderValidation") << " not filling if more than 1 VH has been produced"; + width = -100; + deltaXlocal = -100; + tree_->Fill(); + continue; + } + + //curvature + GlobalPoint center(0.0, 0.0, 0.0); + curvature = vh.curvature(); + phi = vh.phi(); + QOverPT = vh.transverseMomentum(magField_->inTesla(center).z()); + QOverP = vh.momentum(magField_->inTesla(center).z()); + histogramLayer->second.curvature->Fill(curvature); + + //stub width + + auto&& lparamsUpp = cpe_->localParameters(*vhIt.upperClusterRef().cluster_phase2OT(), *geomDetUnit_upp); + LogTrace("VectorHitsBuilderValidation") << " upper local pos (in its system of reference):" << lparamsUpp.first; + Global3DPoint gparamsUpp = geomDetUnit_upp->surface().toGlobal(lparamsUpp.first); + LogTrace("VectorHitsBuilderValidation") << " upper global pos :" << gparamsUpp; + Local3DPoint lparamsUppInLow = geomDetUnit_low->surface().toLocal(gparamsUpp); + LogTrace("VectorHitsBuilderValidation") << " upper local pos (in low system of reference):" << lparamsUppInLow; + auto&& lparamsLow = cpe_->localParameters(*vhIt.lowerClusterRef().cluster_phase2OT(), *geomDetUnit_low); + LogTrace("VectorHitsBuilderValidation") << " lower local pos (in its system of reference):" << lparamsLow.first; + Global3DPoint gparamsLow = geomDetUnit_low->surface().toGlobal(lparamsLow.first); + LogTrace("VectorHitsBuilderValidation") << " lower global pos :" << gparamsLow; + + deltaXlocal = lparamsUppInLow.x() - lparamsLow.first.x(); + histogramLayer->second.deltaXlocal->Fill(deltaXlocal); + LogTrace("VectorHitsBuilderValidation") << " deltaXlocal : " << deltaXlocal; + + double parallCorr = 0.0; + + Global3DPoint origin(0, 0, 0); + GlobalVector gV = gparamsLow - origin; + LocalVector lV = geomDetUnit_low->surface().toLocal(gV); + LocalVector lV_norm = lV / lV.z(); + parallCorr = lV_norm.x() * lparamsUppInLow.z(); + LogTrace("VectorHitsBuilderValidation") << " parallalex correction:" << parallCorr; + + double lpos_upp_corr = 0.0; + double lpos_low_corr = 0.0; + if (lparamsUpp.first.x() > lparamsLow.first.x()) { + if (lparamsUpp.first.x() > 0) { + lpos_low_corr = lparamsLow.first.x(); + lpos_upp_corr = lparamsUpp.first.x() - fabs(parallCorr); + } + if (lparamsUpp.first.x() < 0) { + lpos_low_corr = lparamsLow.first.x() + fabs(parallCorr); + lpos_upp_corr = lparamsUpp.first.x(); + } + } else if (lparamsUpp.first.x() < lparamsLow.first.x()) { + if (lparamsUpp.first.x() > 0) { + lpos_low_corr = lparamsLow.first.x() - fabs(parallCorr); + lpos_upp_corr = lparamsUpp.first.x(); + } + if (lparamsUpp.first.x() < 0) { + lpos_low_corr = lparamsLow.first.x(); + lpos_upp_corr = lparamsUpp.first.x() + fabs(parallCorr); + } + } else { + if (lparamsUpp.first.x() > 0) { + lpos_upp_corr = lparamsUpp.first.x() - fabs(parallCorr); + lpos_low_corr = lparamsLow.first.x(); + } + if (lparamsUpp.first.x() < 0) { + lpos_upp_corr = lparamsUpp.first.x() + fabs(parallCorr); + lpos_low_corr = lparamsLow.first.x(); + } + } + + LogDebug("VectorHitsBuilderValidation") << " \t local pos upper corrected (x):" << lpos_upp_corr << std::endl; + LogDebug("VectorHitsBuilderValidation") << " \t local pos lower corrected (x):" << lpos_low_corr << std::endl; + + width = lpos_low_corr - lpos_upp_corr; + histogramLayer->second.width->Fill(width); + LogTrace("VectorHitsBuilderValidation") << " width:" << width; + + tree_->Fill(); + + } // vh valid + + } // loop vhs + + if (nVHsPS) + histogramLayer->second.numberVHsPS->Fill(nVHsPS); + if (nVHs2S) + histogramLayer->second.numberVHs2S->Fill(nVHs2S); + LogTrace("VectorHitsBuilderValidation") + << "nVHsPS for this layer : " << nVHsPS << ", nVHs2S for this layer : " << nVHs2S << std::endl; + } + + CreateVHsXYGraph(glVHs, dirVHs); + CreateVHsRZGraph(glVHs, dirVHs); + + int VHaccTrue = 0.0; + int VHaccFalse = 0.0; + int VHrejTrue = 0.0; + int VHrejFalse = 0.0; + int VHaccTrue_signal = 0.0; + int VHrejTrue_signal = 0.0; + + // Loop over modules + for (const auto& DSViter : *vhsAcc) { + unsigned int rawid(DSViter.detId()); + DetId detId(rawid); + int layerAcc = getLayerNumber(detId); + LogTrace("VectorHitsBuilderValidation") << "acc Layer: " << layerAcc << " det id" << rawid << std::endl; + for (const auto& vhIt : DSViter) { + if (vhIt.isValid()) { + VHaccLayer_->Fill(layerAcc); + VHacc++; + + //compute if the vhits is 'true' or 'false' + std::pair istrue = isTrue(vhIt, siphase2SimLinks, detId); + if (istrue.first) { + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; + VHaccTrueLayer_->Fill(layerAcc); + VHaccTrue++; + + //saving info of 'signal' track + std::map::const_iterator simTrackIt(simTracks.find(istrue.second)); + if (simTrackIt == simTracks.end()) + continue; + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is associated with SimTrackId: " << istrue.second; + LogTrace("VectorHitsBuilderValidation") << "the SimTrack has pt: " << simTrackIt->second.momentum().pt(); + if (simTrackIt->second.momentum().pt() > 1) { + VHaccTrue_signal_Layer_->Fill(layerAcc); + LogTrace("VectorHitsBuilderValidation") << "the vectorhit belongs to signal"; + VHaccTrue_signal++; + } + + } else { + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'false' vhit."; + VHaccFalse++; + } + } + } + } + + for (const auto& DSViter : *vhsRej) { + unsigned int rawid(DSViter.detId()); + DetId detId(rawid); + int layerRej = getLayerNumber(detId); + LogTrace("VectorHitsBuilderValidation") << "rej Layer: " << layerRej << " det id" << rawid << std::endl; + for (const auto& vhIt : DSViter) { + VHrejLayer_->Fill(layerRej); + VHrej++; + + //compute if the vhits is 'true' or 'false' + std::pair istrue = isTrue(vhIt, siphase2SimLinks, detId); + if (istrue.first) { + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'true' vhit."; + VHrejTrueLayer_->Fill(layerRej); + VHrejTrue++; + + //saving info of 'signal' track + std::map::const_iterator simTrackIt(simTracks.find(istrue.second)); + if (simTrackIt == simTracks.end()) + continue; + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is associated with SimTrackId: " << istrue.second; + LogTrace("VectorHitsBuilderValidation") << "the SimTrack has pt: " << simTrackIt->second.momentum().pt(); + if (simTrackIt->second.momentum().pt() > 1) { + VHrejTrue_signal_Layer_->Fill(layerRej); + LogTrace("VectorHitsBuilderValidation") << "the vectorhit belongs to signal"; + VHrejTrue_signal++; + } + + } else { + LogTrace("VectorHitsBuilderValidation") << "this vectorhit is a 'false' vhit."; + VHrejFalse++; + } + } + } + + int VHtot = VHacc + VHrej; + LogTrace("VectorHitsBuilderValidation") + << "VH total: " << VHtot << " with " << VHacc << " VHs accepted and " << VHrej << " VHs rejected."; + LogTrace("VectorHitsBuilderValidation") + << "of the VH accepted, there are " << VHaccTrue << " true and " << VHaccFalse << " false."; + LogTrace("VectorHitsBuilderValidation") + << "of the VH rejected, there are " << VHrejTrue << " true and " << VHrejFalse << " false."; + LogTrace("VectorHitsBuilderValidation") + << "of the true VH , there are " << VHaccTrue_signal << " accepted belonging to signal and " + << VHrejTrue_signal << " rejected belonging to signal."; + + // CreateWindowCorrGraph(); +} + +// Check if the vector hit is true (both clusters are formed from the same SimTrack +std::pair VectorHitsBuilderValidation::isTrue( + const VectorHit vh, const edm::Handle >& siphase2SimLinks, DetId& detId) const { + const GeomDet* geomDet(tkGeom_->idToDet(detId)); + const StackGeomDet* stackDet = dynamic_cast(geomDet); + const GeomDetUnit* geomDetLower = stackDet->lowerDet(); + const GeomDetUnit* geomDetUpper = stackDet->upperDet(); + + std::vector lowClusterSimTrackIds; + + for (unsigned int istr(0); istr < (*(vh.lowerClusterRef().cluster_phase2OT())).size(); ++istr) { + uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.lowerClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vh.lowerClusterRef().cluster_phase2OT())).column()); + DetId detIdCluster = geomDetLower->geographicalId(); + unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detIdCluster, channel)); + LogTrace("VectorHitsBuilderValidation") << "LowerSimTrackId " << simTrackId << std::endl; + std::vector > trkid(getSimTrackIds(siphase2SimLinks, detIdCluster, channel)); + if (trkid.size() == 0) + continue; + lowClusterSimTrackIds.push_back(simTrackId); + } + + std::vector::iterator it_simTrackUpper; + + for (unsigned int istr(0); istr < (*(vh.upperClusterRef().cluster_phase2OT())).size(); ++istr) { + uint32_t channel = Phase2TrackerDigi::pixelToChannel((*(vh.upperClusterRef().cluster_phase2OT())).firstRow() + istr, + (*(vh.upperClusterRef().cluster_phase2OT())).column()); + DetId detIdCluster = geomDetUpper->geographicalId(); + unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detIdCluster, channel)); + LogTrace("VectorHitsBuilderValidation") << "UpperSimTrackId " << simTrackId << std::endl; + std::vector > trkid(getSimTrackIds(siphase2SimLinks, detIdCluster, channel)); + if (trkid.size() == 0) + continue; + it_simTrackUpper = std::find(lowClusterSimTrackIds.begin(), lowClusterSimTrackIds.end(), simTrackId); + if (it_simTrackUpper != lowClusterSimTrackIds.end()) { + LogTrace("VectorHitsBuilderValidation") << " UpperSimTrackId found in lowClusterSimTrackIds "; + return std::make_pair(true, simTrackId); + } + } + return std::make_pair(false, 0); +} + +// Create the histograms +std::map::iterator VectorHitsBuilderValidation::createLayerHistograms(unsigned int ival) { + std::ostringstream fname1, fname2; + + edm::Service fs; + fs->file().cd("/"); + + std::string tag; + unsigned int id; + if (ival < 100) { + id = ival; + fname1 << "Barrel"; + fname2 << "Layer_" << id; + tag = "_layer_"; + } else { + int side = ival / 100; + id = ival - side * 100; + fname1 << "EndCap_Side_" << side; + fname2 << "Disc_" << id; + tag = "_disc_"; + } + + TFileDirectory td1 = fs->mkdir(fname1.str().c_str()); + TFileDirectory td = td1.mkdir(fname2.str().c_str()); + + VHHistos local_histos; + + std::ostringstream histoName; + + /* + * Number of clusters + */ + + histoName.str(""); + histoName << "Number_VHs_PS" << tag.c_str() << id; + local_histos.numberVHsPS = td.make(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberVHsPS->SetFillColor(kAzure + 7); + + histoName.str(""); + histoName << "Number_VHs_2S" << tag.c_str() << id; + local_histos.numberVHs2S = td.make(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.); + local_histos.numberVHs2S->SetFillColor(kOrange - 3); + + histoName.str(""); + histoName << "Number_VHs_Mixed" << tag.c_str() << id; + local_histos.numberVHsMixed = td.make(histoName.str().c_str(), histoName.str().c_str()); + local_histos.numberVHsMixed->Add(local_histos.numberVHsPS); + local_histos.numberVHsMixed->Add(local_histos.numberVHs2S); + + /* + * Local and Global positions + */ + + histoName.str(""); + histoName << "Local_Position_XY_Mixed" << tag.c_str() << id; + local_histos.localPosXY[0] = td.make(); + local_histos.localPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Local_Position_XY_PS" << tag.c_str() << id; + local_histos.localPosXY[1] = td.make(); + local_histos.localPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Local_Position_XY_2S" << tag.c_str() << id; + local_histos.localPosXY[2] = td.make(); + local_histos.localPosXY[2]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Global_Position_XY_Mixed" << tag.c_str() << id; + local_histos.globalPosXY[0] = td.make(); + local_histos.globalPosXY[0]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Global_Position_XY_PS" << tag.c_str() << id; + local_histos.globalPosXY[1] = td.make(); + local_histos.globalPosXY[1]->SetName(histoName.str().c_str()); + + histoName.str(""); + histoName << "Global_Position_XY_2S" << tag.c_str() << id; + local_histos.globalPosXY[2] = td.make(); + local_histos.globalPosXY[2]->SetName(histoName.str().c_str()); + + /* + * Delta positions with SimHits + */ + + histoName.str(""); + histoName << "Delta_X_VH_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaXVHSimHits[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_X_VH_SimHits_PS" << tag.c_str() << id; + local_histos.deltaXVHSimHits[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_X_VH_SimHits_2S" << tag.c_str() << id; + local_histos.deltaXVHSimHits[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_Mixed" << tag.c_str() << id; + local_histos.deltaYVHSimHits[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_PS" << tag.c_str() << id; + local_histos.deltaYVHSimHits[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_2S" << tag.c_str() << id; + local_histos.deltaYVHSimHits[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + /* + * Delta position with simHits for primary tracks only + */ + + histoName.str(""); + histoName << "Delta_X_VH_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaXVHSimHits_P[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_X_VH_SimHits_PS_P" << tag.c_str() << id; + local_histos.deltaXVHSimHits_P[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_X_VH_SimHits_2S_P" << tag.c_str() << id; + local_histos.deltaXVHSimHits_P[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_Mixed_P" << tag.c_str() << id; + local_histos.deltaYVHSimHits_P[0] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_PS_P" << tag.c_str() << id; + local_histos.deltaYVHSimHits_P[1] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + histoName.str(""); + histoName << "Delta_Y_VH_SimHits_2S_P" << tag.c_str() << id; + local_histos.deltaYVHSimHits_P[2] = td.make(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.); + + /* + * Information on the Digis per cluster + */ + + histoName.str(""); + histoName << "Total_Digis" << tag.c_str() << id; + local_histos.totalSimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + + histoName.str(""); + histoName << "Primary_Digis" << tag.c_str() << id; + local_histos.primarySimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + + histoName.str(""); + histoName << "Other_Digis" << tag.c_str() << id; + local_histos.otherSimHits = td.make(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.); + + /* + * Study on the clusters combinatorial problem + */ + + histoName.str(""); + histoName << "DeltaXlocal_clusters" << tag.c_str() << id; + local_histos.deltaXlocal = td.make(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); + histoName.str(""); + histoName << "Width" << tag.c_str() << id; + local_histos.width = td.make(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); + histoName.str(""); + histoName << "Curvature" << tag.c_str() << id; + local_histos.curvature = td.make(histoName.str().c_str(), histoName.str().c_str(), 200, -0.4, 0.4); + + std::pair::iterator, bool> insertedIt( + histograms_.insert(std::make_pair(ival, local_histos))); + fs->file().cd("/"); + + return insertedIt.first; +} + +void VectorHitsBuilderValidation::CreateVHsXYGraph(const std::vector glVHs, + const std::vector dirVHs) { + if (glVHs.size() != dirVHs.size()) { + std::cout << "Cannot fullfil the graphs for this event. Return." << std::endl; + return; + } + + // opening canvas and drawing XY TGraph + + for (unsigned int nVH = 0; nVH < glVHs.size(); nVH++) { + //same r + if ((fabs(dirVHs.at(nVH).x()) < 10e-5) && (fabs(dirVHs.at(nVH).y()) < 10e-5)) { + continue; + + } else { + } + } + + return; +} + +void VectorHitsBuilderValidation::CreateVHsRZGraph(const std::vector glVHs, + const std::vector dirVHs) { + if (glVHs.size() != dirVHs.size()) { + std::cout << "Cannot fullfil the graphs for this event. Return." << std::endl; + return; + } + + return; +} + +void VectorHitsBuilderValidation::CreateWindowCorrGraph() { + //FIXME: This function is not working properly, yet. + + //return if we are not using Phase2 OT + if (!tkGeom_->isThere(GeomDetEnumerators::P2OTB) && !tkGeom_->isThere(GeomDetEnumerators::P2OTEC)) + return; + + for (auto det : tkGeom_->detsTOB()) { + ParallaxCorrectionRZ_->Fill(det->position().z(), det->position().perp(), 5.); + } + for (auto det : tkGeom_->detsTID()) { + ParallaxCorrectionRZ_->Fill(det->position().z(), det->position().perp(), 10.); + } + ParallaxCorrectionRZ_->Fill(0., 0., 5.); + return; +} + +unsigned int VectorHitsBuilderValidation::getLayerNumber(const DetId& detid) { + if (detid.det() == DetId::Tracker) { + if (detid.subdetId() == StripSubdetector::TOB) + return (tkTopo_->layer(detid)); + else if (detid.subdetId() == StripSubdetector::TID) + return (100 * tkTopo_->side(detid) + tkTopo_->layer(detid)); + else + return 999; + } + return 999; +} + +unsigned int VectorHitsBuilderValidation::getModuleNumber(const DetId& detid) { return (tkTopo_->module(detid)); } + +std::vector > VectorHitsBuilderValidation::getSimTrackIds( + const edm::Handle >& simLinks, const DetId& detId, uint32_t channel) const { + std::vector > simTrkId; + auto isearch = simLinks->find(detId); + if (isearch != simLinks->end()) { + // Loop over DigiSimLink in this det unit + edm::DetSet link_detset = (*isearch); + for (const auto& it : link_detset.data) { + if (channel == it.channel()) + simTrkId.push_back(std::make_pair(it.SimTrackId(), it.eventId())); + } + } + return simTrkId; +} + +unsigned int VectorHitsBuilderValidation::getSimTrackId( + const edm::Handle >& pixelSimLinks, + const DetId& detId, + unsigned int channel) const { + edm::DetSetVector::const_iterator DSViter(pixelSimLinks->find(detId)); + if (DSViter == pixelSimLinks->end()) + return 0; + for (const auto& it : DSViter->data) { + if (channel == it.channel()) + return it.SimTrackId(); + } + return 0; +} + +void VectorHitsBuilderValidation::printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster) { + if (!geomDetUnit) + return; + + const PixelGeomDetUnit* theGeomDet = dynamic_cast(geomDetUnit); + const PixelTopology& topol = theGeomDet->specificTopology(); + + unsigned int layer = getLayerNumber(geomDetUnit->geographicalId()); + unsigned int module = getModuleNumber(geomDetUnit->geographicalId()); + LogTrace("VectorHitsBuilderValidation") << "Layer:" << layer << std::endl; + if (topol.ncolumns() == 32) + LogTrace("VectorHitsBuilderValidation") << "Pixel cluster with detId:" << geomDetUnit->geographicalId().rawId() + << "(module:" << module << ") " << std::endl; + else if (topol.ncolumns() == 2) + LogTrace("VectorHitsBuilderValidation") << "Strip cluster with detId:" << geomDetUnit->geographicalId().rawId() + << "(module:" << module << ") " << std::endl; + else + std::cout << "no module?!" << std::endl; + LogTrace("VectorHitsBuilderValidation") + << "with pitch:" << topol.pitch().first << " , " << topol.pitch().second << std::endl; + LogTrace("VectorHitsBuilderValidation") << " and width:" << theGeomDet->surface().bounds().width() + << " , lenght:" << theGeomDet->surface().bounds().length() << std::endl; + + auto&& lparams = cpe_->localParameters(*cluster.cluster_phase2OT(), *theGeomDet); + + LogTrace("VectorHitsBuilderValidation") + << "\t local pos " << lparams.first << "with err " << lparams.second << std::endl; + + return; +} + +void VectorHitsBuilderValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("src", "siPhase2Clusters"); + desc.add("links", edm::InputTag("simSiPixelDigis", "Tracker")); + desc.add("VH_acc", edm::InputTag("siPhase2VectorHits", "accepted")); + desc.add("VH_rej", edm::InputTag("siPhase2VectorHits", "rejected")); + desc.add("CPE", edm::ESInputTag("phase2StripCPEESProducer", "Phase2StripCPE")); + desc.add("trackingParticleSrc", edm::InputTag("mix", "MergedTrackTruth")); + descriptions.add("vectorHitsBuilderValidation", desc); +} + +DEFINE_FWK_MODULE(VectorHitsBuilderValidation); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsBuilderValidation.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsBuilderValidation.h new file mode 100644 index 0000000000000..f0233dafe4a64 --- /dev/null +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/test/VectorHitsBuilderValidation.h @@ -0,0 +1,152 @@ +#ifndef RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitsBuilderValidation_H +#define RecoLocalTracker_SiPhase2VectorHitBuilder_VectorHitsBuilderValidation_H + +#include +#include +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" + +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" + +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h" +#include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h" +#include "DataFormats/SiPixelDigi/interface/PixelDigi.h" +#include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h" + +#include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h" +#include "SimDataFormats/Track/interface/SimTrackContainer.h" +#include "SimDataFormats/Vertex/interface/SimVertexContainer.h" +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" + +#include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "CommonTools/Utils/interface/TFileDirectory.h" + +#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h" +#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h" + +#include +#include +#include +#include +#include +#include +#include + +struct VHHistos { + THStack* numberVHsMixed; + TH1F* numberVHsPS; + TH1F* numberVHs2S; + + TGraph* globalPosXY[3]; + TGraph* localPosXY[3]; + + TH1F* deltaXVHSimHits[3]; + TH1F* deltaYVHSimHits[3]; + + TH1F* deltaXVHSimHits_P[3]; + TH1F* deltaYVHSimHits_P[3]; + + TH1F* digiEfficiency[3]; + + TH1F* totalSimHits; + TH1F* primarySimHits; + TH1F* otherSimHits; + + TH1F* curvature; + TH1F* width; + TH1F* deltaXlocal; +}; + +class VectorHitsBuilderValidation : public edm::one::EDAnalyzer { +public: + typedef edm::Ref, Phase2TrackerCluster1D> Phase2TrackerCluster1DRef; + + typedef std::map > SimHitsMap; + typedef std::map SimTracksMap; + + explicit VectorHitsBuilderValidation(const edm::ParameterSet&); + ~VectorHitsBuilderValidation(); + void beginJob(); + void endJob(); + void analyze(const edm::Event&, const edm::EventSetup&); + + static void fillDescriptions(edm::ConfigurationDescriptions&); + +private: + std::map::iterator createLayerHistograms(unsigned int); + void CreateVHsXYGraph(const std::vector, const std::vector); + void CreateVHsRZGraph(const std::vector, const std::vector); + void CreateWindowCorrGraph(); + + unsigned int getLayerNumber(const DetId&); + unsigned int getModuleNumber(const DetId& detid); + void printCluster(const GeomDetUnit* geomDetUnit, const OmniClusterRef cluster); + + std::pair isTrue(const VectorHit vh, + const edm::Handle >& siphase2SimLinks, + DetId& detId) const; + std::vector > getSimTrackIds( + const edm::Handle >&, const DetId&, uint32_t) const; + unsigned int getSimTrackId(const edm::Handle >& pixelSimLinks, + const DetId& detId, + unsigned int channel) const; + + edm::EDGetTokenT > srcClu_; + edm::EDGetTokenT VHacc_; + edm::EDGetTokenT VHrej_; + edm::ESInputTag cpeTag_; + const ClusterParameterEstimator* cpe_; + + edm::EDGetTokenT > siphase2OTSimLinksToken_; + edm::EDGetTokenT simHitsToken_; + edm::EDGetTokenT simTracksToken_; + edm::EDGetTokenT simVerticesToken_; + edm::EDGetTokenT trackingParticleToken_; + + const TrackerGeometry* tkGeom_; + const TrackerTopology* tkTopo_; + const MagneticField* magField_; + + TTree* tree_; + TGraph* trackerLayoutRZ_[3]; + TGraph* trackerLayoutXY_[3]; + TGraph* trackerLayoutXYBar_; + TGraph* trackerLayoutXYEC_; + TGraph* localPosXvsDeltaX_[3]; + TGraph* localPosYvsDeltaY_[3]; + TCanvas* VHXY_; + TCanvas* VHRZ_; + std::vector arrowVHs_; + + TH2D* ParallaxCorrectionRZ_; + TH1F* VHaccLayer_; + TH1F* VHrejLayer_; + TH1F* VHaccTrueLayer_; + TH1F* VHrejTrueLayer_; + TH1F* VHaccTrue_signal_Layer_; + TH1F* VHrejTrue_signal_Layer_; + + std::map histograms_; +}; +#endif From e58adabf4b509b320bdc2fca75967f1aac8eac51 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 14:42:04 +0200 Subject: [PATCH 100/115] a few more comments --- .../plugins/MeasurementTrackerESProducer.cc | 2 +- .../MeasurementTrackerEventProducer_cfi.py | 4 +-- .../src/Phase2OTBarrelRodBuilder.cc | 26 ++++++------------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc index 8b689550b5fb8..540532c0ad0ba 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc @@ -17,7 +17,7 @@ #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" #include "RecoLocalTracker/Records/interface/TrackerCPERecord.h" -#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" +//#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" diff --git a/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py b/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py index 9f7c08126f3b6..2d4e807b21872 100644 --- a/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py +++ b/RecoTracker/MeasurementDet/python/MeasurementTrackerEventProducer_cfi.py @@ -25,8 +25,8 @@ ) from Configuration.ProcessModifiers.vectorHits_cff import vectorHits vectorHits.toModify(MeasurementTrackerEvent, - vectorHits = cms.InputTag("siPhase2VectorHits", "accepted"), - vectorHitsRej = cms.InputTag("siPhase2VectorHits", "rejected"), + vectorHits = ("siPhase2VectorHits", "accepted"), + vectorHitsRej = ("siPhase2VectorHits", "rejected"), ) MeasurementTrackerEventPreSplitting = MeasurementTrackerEvent.clone( diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc index eb0647209b786..b96c630d7e74e 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc @@ -19,37 +19,28 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 double meanR = 0; if (!useBrothers) { - for (vector::const_iterator compGeometricDets = allGeometricDets.begin(); - compGeometricDets != allGeometricDets.end(); - compGeometricDets++) { - meanR = meanR + (*compGeometricDets)->positionBounds().perp(); + for (auto const& compGeometricDets : allGeometricDets) { + meanR = meanR + compGeometricDets->positionBounds().perp(); } meanR = meanR / allGeometricDets.size(); LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl; + for (auto const& compGeometricDets : allGeometricDets){ + const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets->geographicalId()); - for (vector::const_iterator compGeometricDets = allGeometricDets.begin(); - compGeometricDets != allGeometricDets.end(); - compGeometricDets++) { - const GeomDet* theGeomDet = theGeomDetGeometry->idToDet((*compGeometricDets)->geographicalId()); - - if ((*compGeometricDets)->positionBounds().perp() < meanR) + if (compGeometricDets->positionBounds().perp() < meanR) innerGeomDets.push_back(theGeomDet); - if ((*compGeometricDets)->positionBounds().perp() > meanR) + if (compGeometricDets->positionBounds().perp() > meanR) outerGeomDets.push_back(theGeomDet); } LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size(); LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size(); - return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers); } else { vector compGeometricDets; - vector innerGeomDetBrothers; - vector outerGeomDetBrothers; - double meanRBrothers = 0; for (auto& it : allGeometricDets) { compGeometricDets = it->components(); @@ -73,7 +64,7 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 if (compGeometricDets[0]->positionBounds().perp() < meanR) innerGeomDets.push_back(theGeomDet); - if (compGeometricDets[0]->positionBounds().perp() > meanR) + else outerGeomDets.push_back(theGeomDet); const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet(compGeometricDets[1]->geographicalId()); @@ -81,7 +72,7 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 if (compGeometricDets[1]->positionBounds().perp() < meanRBrothers) innerGeomDetBrothers.push_back(theGeomDetBrother); - if (compGeometricDets[1]->positionBounds().perp() > meanRBrothers) + else outerGeomDetBrothers.push_back(theGeomDetBrother); } @@ -90,7 +81,6 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 LogDebug("TkDetLayers") << "innerGeomDetsBro.size(): " << innerGeomDetBrothers.size(); LogDebug("TkDetLayers") << "outerGeomDetsBro.size(): " << outerGeomDetBrothers.size(); - return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers); } return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers); From 2689ca84b3e4a4fb1c03c7e242c71718b0e20659 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 16:41:35 +0200 Subject: [PATCH 101/115] finish first pass at Slava's comments --- .../src/VectorHitBuilderAlgorithm.cc | 170 ++++++++---------- .../plugins/SeedingOTEDProducer.cc | 93 +++++----- .../TkSeedingLayers/src/HitExtractorSTRP.cc | 10 +- ...ransientTrackingRecHitBuilderESProducer.cc | 2 +- .../plugins/QuickTrackAssociatorByHitsImpl.cc | 1 - 5 files changed, 126 insertions(+), 150 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index b8ff6c4d5cacf..d7c314bb93845 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -124,25 +124,40 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi } else { LogTrace("VectorHitBuilderAlgorithm") << " not compatible, going to the next cluster"; } + + unsigned int layerStack = tkTopo_->layer(stack->geographicalId()); + if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) + LogDebug("VectorHitBuilderAlgorithm") << " \t is barrel. " << std::endl; + if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) + LogDebug("VectorHitBuilderAlgorithm") << " \t is endcap. " << std::endl; + LogDebug("VectorHitBuilderAlgorithm") << " \t layer is : " << layerStack << std::endl; + + float cut = 0.0; + if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) + cut = barrelCut_.at(layerStack); + if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) + cut = endcapCut_.at(layerStack); + LogDebug("VectorHitBuilderAlgorithm") << " \t the cut is:" << cut << std::endl; + + //only cache local parameters for upper cluster as we loop over lower clusters only once anyway std::vector> localParamsUpper; std::vector localGDUUpper; std::vector upperClusters; - for (const_iterator ciu = theUpperDetSet.begin(); ciu != theUpperDetSet.end(); ++ciu) { - Phase2TrackerCluster1DRef clusterUpper = edmNew::makeRefTo(clusters, ciu); - const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); + const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); + for (auto const& clusterUpper : theUpperDetSet) { localGDUUpper.push_back(gduUpp); - localParamsUpper.push_back(cpe_->localParameters(*clusterUpper, *gduUpp)); + localParamsUpper.push_back(cpe_->localParameters(clusterUpper, *gduUpp)); } int upperIterator = 0; + const PixelGeomDetUnit* gduLow = dynamic_cast(stack->lowerDet()); for (const_iterator cil = theLowerDetSet.begin(); cil != theLowerDetSet.end(); ++cil) { LogDebug("VectorHitBuilderAlgorithm") << " lower clusters " << std::endl; Phase2TrackerCluster1DRef cluL = edmNew::makeRefTo(clusters, cil); #ifdef EDM_ML_DEBUG printCluster(stack->lowerDet(), &*cluL); #endif - const PixelGeomDetUnit* gduLow = dynamic_cast(stack->lowerDet()); auto&& lparamsLow = cpe_->localParameters(*cluL, *gduLow); upperIterator = 0; for (const_iterator ciu = theUpperDetSet.begin(); ciu != theUpperDetSet.end(); ++ciu) { @@ -157,57 +172,44 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi LogDebug("VectorHitBuilderAlgorithm") << " \t parallax correction:" << pC << std::endl; double lpos_upp_corr = 0.0; double lpos_low_corr = 0.0; - if (localParamsUpper[upperIterator].first.x() > lparamsLow.first.x()) { - if (localParamsUpper[upperIterator].first.x() > 0) { + auto const localUpperX = localParamsUpper[upperIterator].first.x(); + if (localUpperX > lparamsLow.first.x()) { + if (localUpperX > 0) { lpos_low_corr = lparamsLow.first.x(); lpos_upp_corr = localParamsUpper[upperIterator].first.x() - std::abs(pC); - } else if (localParamsUpper[upperIterator].first.x() < 0) { + } else if (localUpperX < 0) { lpos_low_corr = lparamsLow.first.x() + std::abs(pC); - lpos_upp_corr = localParamsUpper[upperIterator].first.x(); + lpos_upp_corr = localUpperX; } - } else if (localParamsUpper[upperIterator].first.x() < lparamsLow.first.x()) { - if (localParamsUpper[upperIterator].first.x() > 0) { + } else if (localUpperX < lparamsLow.first.x()) { + if (localUpperX > 0) { lpos_low_corr = lparamsLow.first.x() - std::abs(pC); - lpos_upp_corr = localParamsUpper[upperIterator].first.x(); - } else if (localParamsUpper[upperIterator].first.x() < 0) { + lpos_upp_corr = localUpperX; + } else if (localUpperX < 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = localParamsUpper[upperIterator].first.x() + std::abs(pC); + lpos_upp_corr = localUpperX + std::abs(pC); } } else { - if (localParamsUpper[upperIterator].first.x() > 0) { + if (localUpperX > 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = localParamsUpper[upperIterator].first.x() - std::abs(pC); - } else if (localParamsUpper[upperIterator].first.x() < 0) { + lpos_upp_corr = localUpperX - std::abs(pC); + } else if (localUpperX < 0) { lpos_low_corr = lparamsLow.first.x(); - lpos_upp_corr = localParamsUpper[upperIterator].first.x() + std::abs(pC); + lpos_upp_corr = localUpperX + std::abs(pC); } } LogDebug("VectorHitBuilderAlgorithm") << " \t local pos upper corrected (x):" << lpos_upp_corr << std::endl; LogDebug("VectorHitBuilderAlgorithm") << " \t local pos lower corrected (x):" << lpos_low_corr << std::endl; - //building my tolerance : 10*sigma - double delta = 10.0 * sqrt(lparamsLow.second.xx() + localParamsUpper[upperIterator].second.xx()); - LogDebug("VectorHitBuilderAlgorithm") << " \t delta: " << delta << std::endl; - double width = lpos_low_corr - lpos_upp_corr; LogDebug("VectorHitBuilderAlgorithm") << " \t width: " << width << std::endl; - unsigned int layerStack = tkTopo_->layer(stack->geographicalId()); - if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) - LogDebug("VectorHitBuilderAlgorithm") << " \t is barrel. " << std::endl; - if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) - LogDebug("VectorHitBuilderAlgorithm") << " \t is endcap. " << std::endl; - LogDebug("VectorHitBuilderAlgorithm") << " \t layer is : " << layerStack << std::endl; - - float cut = 0.0; - if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) - cut = barrelCut_.at(layerStack); - if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) - cut = endcapCut_.at(layerStack); - LogDebug("VectorHitBuilderAlgorithm") << " \t the cut is:" << cut << std::endl; //old cut: indipendent from layer + //building my tolerance : 10*sigma + //double delta = 10.0 * sqrt(lparamsLow.second.xx() + localParamsUpper[upperIterator].second.xx()); + //LogDebug("VectorHitBuilderAlgorithm") << " \t delta: " << delta << std::endl; //if( (lpos_upp_corr < lpos_low_corr + delta) && // (lpos_upp_corr > lpos_low_corr - delta) ){ //new cut: dependent on layers @@ -223,7 +225,9 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi LogDebug("VectorHitBuilderAlgorithm") << " rejecting VH: " << std::endl; //storing vh rejected for combinatiorial studies VectorHit vh = buildVectorHit(stack, cluL, cluU); - result.emplace_back(std::make_pair(vh, false)); + if (vh.isValid()){ + result.emplace_back(std::make_pair(vh, false)); + } } upperIterator += 1; } @@ -308,10 +312,8 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, GlobalError gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetUpper); if (gPositionLower.perp() > gPositionUpper.perp()) { - gPositionLower = VectorHit::phase2clusterGlobalPos(geomDetUpper, upper); - gPositionUpper = VectorHit::phase2clusterGlobalPos(geomDetLower, lower); - gErrorLower = VectorHit::phase2clusterGlobalPosErr(geomDetUpper); - gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetLower); + std::swap(gPositionLower,gPositionUpper); + std::swap(gErrorLower,gErrorUpper); } const CurvatureAndPhi curvatureAndPhi = curvatureANDphi(gPositionLower, gPositionUpper, gErrorLower, gErrorUpper); @@ -422,18 +424,20 @@ VectorHitBuilderAlgorithm::CurvatureAndPhi VectorHitBuilderAlgorithm::curvatureA double signCurv = -copysign(1.0, n3); double phi1 = atan2(gPositionUpper.y() - gPositionLower.y(), gPositionUpper.x() - gPositionLower.x()); + + double x2Low = pow(gPositionLower.x(), 2); + double y2Low = pow(gPositionLower.y(), 2); + double x2Up = pow(gPositionUpper.x(), 2); + double y2Up = pow(gPositionUpper.y(), 2); + if (h1 != 0) { double h2 = 2 * h1; double h2Inf = 1. / (2 * h1); - double r12 = pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2); - double r22 = pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2); - double h3 = - (pow(gPositionLower.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.x(), 2) + - pow(gPositionLower.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y() + pow(gPositionUpper.y(), 2)); - double h4 = -pow(gPositionLower.x(), 2) * gPositionUpper.x() + gPositionLower.x() * pow(gPositionUpper.x(), 2) + - gPositionLower.x() * pow(gPositionUpper.y(), 2) - gPositionUpper.x() * pow(gPositionLower.y(), 2); - double h5 = pow(gPositionLower.x(), 2) * gPositionUpper.y() - pow(gPositionUpper.x(), 2) * gPositionLower.y() + - pow(gPositionLower.y(), 2) * gPositionUpper.y() - gPositionLower.y() * pow(gPositionUpper.y(), 2); + double r12 = gPositionLower.perp2(); + double r22 = gPositionUpper.perp2(); + double h3 = pow(n2[0],2) + pow(n2[1],2); + double h4 = -x2Low * gPositionUpper.x() + gPositionLower.x() * x2Up + gPositionLower.x() *y2Up - gPositionUpper.x() * y2Low; + double h5 = x2Low * gPositionUpper.y() - x2Up * gPositionLower.y() + y2Low * gPositionUpper.y() - gPositionLower.y() * y2Up; //radius of circle double invRho2 = (4. * h1 * h1) / (r12 * r22 * h3); @@ -456,53 +460,33 @@ VectorHitBuilderAlgorithm::CurvatureAndPhi VectorHitBuilderAlgorithm::curvatureA double denom2 = 1. / (pow(r12 * r22 * h3, 1.5)); jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 - jacobian[2][0] = - -2. * ((h1 * (gPositionLower.x() * r22 * h3 + (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2 - - (gPositionUpper.y()) * denom1); // dkappa/dx1 - jacobian[2][1] = - -2. * ((gPositionUpper.x()) * denom1 + - (h1 * (gPositionLower.y() * r22 * h3 + r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * - denom2); // dkappa/dy1 - jacobian[2][2] = - -2. * ((gPositionLower.y()) * denom1 + - (h1 * (gPositionUpper.x() * r12 * h3 - (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * - denom2); // dkappa/dx2 - jacobian[2][3] = - -2. * ((h1 * (gPositionUpper.y() * r12 * h3 - r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * denom2 - - (gPositionLower.x()) * denom1); // dkappa/dy2 - AlgebraicVector2 M; + jacobian[2][0] = -2. * ((h1 * (gPositionLower.x() * r22 * h3 + (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2 - (gPositionUpper.y()) * denom1); // dkappa/dx1 + jacobian[2][1] = -2. * ((gPositionUpper.x()) * denom1 + (h1 * (gPositionLower.y() * r22 * h3 + r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * denom2); // dkappa/dy1 + jacobian[2][2] = -2. * ((gPositionLower.y()) * denom1 + (h1 * (gPositionUpper.x() * r12 * h3 - (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2); // dkappa/dx2 + jacobian[2][3] = -2. * ((h1 * (gPositionUpper.y() * r12 * h3 - r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * denom2 - (gPositionLower.x()) * denom1); // dkappa/dy2 + AlgebraicVector2 mVector; //to compute phi at the cluster points - M[0] = (gPositionLower.y() - ycentre) * invRho2; // dphi/dxcentre - M[1] = -(gPositionLower.x() - xcentre) * invRho2; // dphi/dycentre + mVector[0] = (gPositionLower.y() - ycentre) * invRho2; // dphi/dxcentre + mVector[1] = -(gPositionLower.x() - xcentre) * invRho2; // dphi/dycentre //to compute phi at the origin - AlgebraicROOTObject<2, 4>::Matrix K; - K[0][0] = - 2. * ((gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionUpper.y() * h5) / pow(h2, 2)); // dxm/dx1 - K[0][1] = (2. * gPositionUpper.x() * h5) / pow(h2, 2) - - (pow(gPositionUpper.x(), 2) + pow(gPositionUpper.y(), 2) - 2. * gPositionLower.y() * gPositionUpper.y()) * - h2Inf; // dxm/dy1 - K[0][2] = - 2. * ((gPositionLower.y() * h5) / pow(h2, 2) - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dxm/dx2 - K[0][3] = (pow(gPositionLower.x(), 2) + pow(gPositionLower.y(), 2) - 2. * gPositionUpper.y() * gPositionLower.y()) * - h2Inf - - (2. * gPositionLower.x() * h5) / pow(h2, 2); // dxm/dy2 - K[1][0] = (pow(gPositionUpper.x(), 2) - 2. * gPositionLower.x() * gPositionUpper.x() + pow(gPositionUpper.y(), 2)) * - h2Inf - - (2. * gPositionUpper.y() * h4) / pow(h2, 2); // dym/dx1 - K[1][1] = - 2. * ((gPositionUpper.x() * h4) / pow(h2, 2) - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dym/dy1 - K[1][2] = (2. * gPositionLower.y() * h4) / pow(h2, 2) - - (pow(gPositionLower.x(), 2) - 2. * gPositionUpper.x() * gPositionLower.x() + pow(gPositionLower.y(), 2)) * - h2Inf; // dym/dx2 - K[1][3] = - 2. * (gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionLower.x() * h4) / pow(h2, 2); // dym/dy2 - - AlgebraicVector4 N = M * K; - jacobian[3][0] = N[0]; // dphi/(dx1,dy1,dx2,dy2) - jacobian[3][1] = N[1]; // dphi/(dx1,dy1,dx2,dy2) - jacobian[3][2] = N[2]; // dphi/(dx1,dy1,dx2,dy2) - jacobian[3][3] = N[3]; // dphi/(dx1,dy1,dx2,dy2) + double h22Inv = 1./pow(h2, 2); + + AlgebraicROOTObject<2, 4>::Matrix kMatrix; + kMatrix[0][0] = 2. * ((gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionUpper.y() * h5) * h22Inv); // dxm/dx1 + kMatrix[0][1] = (2. * gPositionUpper.x() * h5) * h22Inv - (x2Up + y2Up - 2. * gPositionLower.y() * gPositionUpper.y()) * h2Inf; // dxm/dy1 + kMatrix[0][2] = 2. * ((gPositionLower.y() * h5) * h22Inv - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dxm/dx2 + kMatrix[0][3] = (x2Low + y2Low - 2. * gPositionUpper.y() * gPositionLower.y()) * h2Inf - (2. * gPositionLower.x() * h5) * h22Inv; // dxm/dy2 + kMatrix[1][0] = (x2Up - 2. * gPositionLower.x() * gPositionUpper.x() + y2Up) * h2Inf - (2. * gPositionUpper.y() * h4) * h22Inv; // dym/dx1 + kMatrix[1][1] = 2. * ((gPositionUpper.x() * h4) * h22Inv - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dym/dy1 + kMatrix[1][2] = (2. * gPositionLower.y() * h4) * h22Inv - (x2Low - 2. * gPositionUpper.x() * gPositionLower.x() + y2Low) * h2Inf; // dym/dx2 + kMatrix[1][3] = 2. * (gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionLower.x() * h4) * h22Inv; // dym/dy2 + + AlgebraicVector4 nMatrix = mVector * kMatrix; + jacobian[3][0] = nMatrix[0]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][1] = nMatrix[1]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][2] = nMatrix[2]; // dphi/(dx1,dy1,dx2,dy2) + jacobian[3][3] = nMatrix[3]; // dphi/(dx1,dy1,dx2,dy2) //assign correct sign to the curvature errors if ((signCurv < 0 && curvature > 0) || (signCurv > 0 && curvature < 0)) { diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index cf55cd98cf4c4..ab8f80679dbdb 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -44,15 +44,15 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { TrajectorySeedCollection run(edm::Handle); unsigned int checkLayer(unsigned int iidd); - std::vector collectVHsOnLayer(const edmNew::DetSetVector&, unsigned int); + std::vector collectVHsOnLayer(const edmNew::DetSetVector&, unsigned int); void printVHsOnLayer(const edmNew::DetSetVector&, unsigned int); - const TrajectoryStateOnSurface buildInitialTSOS(const VectorHit&) const; + const TrajectoryStateOnSurface buildInitialTSOS(const VectorHit*) const; AlgebraicSymMatrix55 assign44To55(AlgebraicSymMatrix44) const; std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, const Propagator&, const TrackingRecHit& hit) const; - float computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot) const; - float computeInverseMomentumError(const VectorHit& vh, + float computeGlobalThetaError(const VectorHit* vh, const double sigmaZ_beamSpot) const; + float computeInverseMomentumError(const VectorHit* vh, const float globalTheta, const double sigmaZ_beamSpot, const double transverseMomentum) const; @@ -64,7 +64,7 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { struct isInvalid { bool operator()(const TrajectoryMeasurement& measurement) { - return (((measurement).recHit() == nullptr) || !((measurement).recHit()->isValid()) || + return ((measurement.recHit() == nullptr) || !(measurement.recHit()->isValid()) || !((measurement).updatedState().isValid())); } }; @@ -123,10 +123,9 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) edm::ESHandle measurementTrackerHandle = es.getHandle(measurementTrackerToken_); measurementTracker_ = measurementTrackerHandle.product(); - edm::Handle measurementTrackerEvent; - event.getByToken(tkMeasEventToken_, measurementTrackerEvent); + auto const& measurementTrackerEvent = event.get(tkMeasEventToken_); - layerMeasurements_ = std::make_unique(*measurementTrackerHandle, *measurementTrackerEvent); + layerMeasurements_ = std::make_unique(*measurementTrackerHandle, measurementTrackerEvent); estimator_ = &es.getData(estToken_); @@ -136,25 +135,20 @@ void SeedingOTEDProducer::produce(edm::Event& event, const edm::EventSetup& es) updator_ = &es.getData(updatorToken_); - edm::Handle beamSpotH; - event.getByToken(beamSpotToken_, beamSpotH); - if (beamSpotH.isValid()) { - beamSpot_ = beamSpotH.product(); - } + beamSpot_ = &event.get(beamSpotToken_); // Get the vector hits - edm::Handle vhs; - event.getByToken(vhProducerToken_, vhs); + auto vhs = event.getHandle(vhProducerToken_); event.emplace(putToken_, run(vhs)); } -TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle VHs) { +TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle vHs) { TrajectorySeedCollection result; //check if all the first three layers have VHs - std::vector vhSeedsL1 = collectVHsOnLayer(*VHs.product(), 1); - std::vector vhSeedsL2 = collectVHsOnLayer(*VHs.product(), 2); - std::vector vhSeedsL3 = collectVHsOnLayer(*VHs.product(), 3); + std::vector vhSeedsL1 = collectVHsOnLayer(*vHs.product(), 1); + std::vector vhSeedsL2 = collectVHsOnLayer(*vHs.product(), 2); + std::vector vhSeedsL3 = collectVHsOnLayer(*vHs.product(), 3); if (vhSeedsL1.empty() || vhSeedsL2.empty() || vhSeedsL3.empty()) { return result; } @@ -176,7 +170,7 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle 0.0) searchingPropagator->setPropagationDirection(oppositeToMomentum); - if (signZ * signPz < 0.0) + else searchingPropagator->setPropagationDirection(alongMomentum); //find vHits in layer 2 @@ -217,15 +211,10 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle container; - container.push_back(hitL1->clone()); - container.push_back(hitL2->clone()); - container.push_back(hitL3.clone()); - //building trajectory inside-out if (searchingPropagator->propagationDirection() == alongMomentum) { buildingPropagator->setPropagationDirection(oppositeToMomentum); - } else if (searchingPropagator->propagationDirection() == oppositeToMomentum) { + } else { buildingPropagator->setPropagationDirection(alongMomentum); } @@ -239,11 +228,17 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle updatedTSOSL3_final = - propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, hitL3); + propagateAndUpdate(updatedTSOSL2_final.second, *buildingPropagator, *hitL3); if (!updatedTSOSL3_final.first) continue; - TrajectorySeed ts = - createSeed(updatedTSOSL3_final.second, container, hitL3.geographicalId(), *buildingPropagator); + + edm::OwnVector container; + container.push_back(hitL1->clone()); + container.push_back(hitL2->clone()); + container.push_back(hitL3->clone()); + + TrajectorySeed ts = + createSeed(updatedTSOSL3_final.second, container, hitL3->geographicalId(), *buildingPropagator); result.push_back(ts); } } @@ -263,20 +258,20 @@ unsigned int SeedingOTEDProducer::checkLayer(unsigned int iidd) { return 0; } -std::vector SeedingOTEDProducer::collectVHsOnLayer(const edmNew::DetSetVector& input, +std::vector SeedingOTEDProducer::collectVHsOnLayer(const edmNew::DetSetVector& input, unsigned int layerNumber) { - std::vector VHsOnLayer; + std::vector vHsOnLayer; if (!input.empty()) { for (const auto& DSViter : input) { if (checkLayer(DSViter.id()) == layerNumber) { for (const auto& vh : DSViter) { - VHsOnLayer.push_back(vh); + vHsOnLayer.push_back(&vh); } } } } - return VHsOnLayer; + return vHsOnLayer; } void SeedingOTEDProducer::printVHsOnLayer(const edmNew::DetSetVector& input, unsigned int layerNumber) { @@ -292,36 +287,36 @@ void SeedingOTEDProducer::printVHsOnLayer(const edmNew::DetSetVector& } } -const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const VectorHit& vHit) const { +const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const VectorHit* vHit) const { // having fun with theta - Global3DVector gv(vHit.globalPosition().x(), vHit.globalPosition().y(), vHit.globalPosition().z()); + Global3DVector gv(vHit->globalPosition().x(), vHit->globalPosition().y(), vHit->globalPosition().z()); float theta = gv.theta(); // gv transform to local (lv) - const Local3DVector lv(vHit.det()->surface().toLocal(gv)); + const Local3DVector lv(vHit->det()->surface().toLocal(gv)); //FIXME::charge is fine 1 every two times!! GlobalPoint center(0.0, 0.0, 0.0); int charge = 1; - float p = vHit.momentum(magField_->inTesla(center).z()); - float x = vHit.localPosition().x(); - float y = vHit.localPosition().y(); - float dx = vHit.localDirection().x(); + float mom = vHit->momentum(magField_->inTesla(center).z()); + float xPos = vHit->localPosition().x(); + float yPos = vHit->localPosition().y(); + float dx = vHit->localDirection().x(); // for dy use second component of the lv renormalized to the z component float dy = lv.y() / lv.z(); // Pz and Dz should have the same sign - float signPz = copysign(1.0, vHit.globalPosition().z()); + float signPz = copysign(1.0, vHit->globalPosition().z()); - LocalTrajectoryParameters ltpar2(charge / p, dx, dy, x, y, signPz); - AlgebraicSymMatrix55 mat = assign44To55(vHit.covMatrix()); + LocalTrajectoryParameters ltpar2(charge / mom, dx, dy, xPos, yPos, signPz); + AlgebraicSymMatrix55 mat = assign44To55(vHit->covMatrix()); // set the error on 1/p mat[0][0] = pow(computeInverseMomentumError( - vHit, theta, beamSpot_->sigmaZ(), vHit.transverseMomentum(magField_->inTesla(center).z())), + vHit, theta, beamSpot_->sigmaZ(), vHit->transverseMomentum(magField_->inTesla(center).z())), 2); //building tsos LocalTrajectoryError lterr(mat); - const TrajectoryStateOnSurface tsos(ltpar2, lterr, vHit.det()->surface(), magField_); + const TrajectoryStateOnSurface tsos(ltpar2, lterr, vHit->det()->surface(), magField_); return tsos; } @@ -350,14 +345,14 @@ std::pair SeedingOTEDProducer::propagateAndUpdat return std::make_pair(true, updatedTSOS); } -float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit& vh, const double sigmaZ_beamSpot) const { +float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit* vh, const double sigmaZ_beamSpot) const { double derivative = - vh.globalPosition().perp() / (pow(vh.globalPosition().z(), 2) + pow(vh.globalPosition().perp(), 2)); + vh->globalPosition().perp() / vh->globalPosition().mag2(); double derivative2 = pow(derivative, 2); - return pow(derivative2 * vh.lowerGlobalPosErr().czz() + derivative2 * pow(sigmaZ_beamSpot, 2), 0.5); + return pow(derivative2 * vh->lowerGlobalPosErr().czz() + derivative2 * pow(sigmaZ_beamSpot, 2), 0.5); } -float SeedingOTEDProducer::computeInverseMomentumError(const VectorHit& vh, +float SeedingOTEDProducer::computeInverseMomentumError(const VectorHit* vh, const float globalTheta, const double sigmaZ_beamSpot, const double transverseMomentum) const { diff --git a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc index 65aac0eaa406e..471c131a5f4c0 100644 --- a/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc +++ b/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc @@ -239,11 +239,10 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder if (hasVectorHits) { LogError("HitExtractorSTRP") << "TIB is not supposed to be in Phase2 TRK detector configuration. What follows " "have never been checked before! "; - edm::Handle vectorHits; - ev.getByToken(theVectorHits, vectorHits); + auto const& vectorHits = ev.get(theVectorHits); if (skipClusters) cleanFrom = result.size(); - range2SeedingHits(*vectorHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); + range2SeedingHits(vectorHits, result, tTopo->tibDetIdLayerComparator(theIdLayer)); if (skipClusters) cleanedOfClusters(ttrhBuilder, ev, result, false, cleanFrom); } @@ -314,13 +313,12 @@ HitExtractor::Hits HitExtractorSTRP::hits(const TkTransientTrackingRecHitBuilder } if (hasVectorHits) { LogTrace("HitExtractorSTRP") << "Getting vector hits for IdLayer " << theIdLayer; - edm::Handle vectorHits; - ev.getByToken(theVectorHits, vectorHits); + auto const& vectorHits = ev.get(theVectorHits); //FIXME: check the skipClusters with VHits if (skipClusters) cleanFrom = result.size(); auto getter = tTopo->tidDetIdWheelComparator(static_cast(theSide), theIdLayer); - VectorHitCollection::Range range = vectorHits->equal_range(getter.first, getter.second); + VectorHitCollection::Range range = vectorHits.equal_range(getter.first, getter.second); for (VectorHitCollection::const_iterator it = range.first; it != range.second; ++it) { int ring = tTopo->tidRing(it->detId()); if (!ringRange(ring)) diff --git a/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc b/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc index 9c19f5c63f05a..e23f3a66df3e7 100644 --- a/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc +++ b/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc @@ -5,7 +5,7 @@ #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" #include "RecoLocalTracker/Records/interface/TrackerCPERecord.h" -#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" +//#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h" diff --git a/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc b/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc index 3b49cff70bd7b..2b1f01b89c6f4 100644 --- a/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc +++ b/SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsImpl.cc @@ -800,7 +800,6 @@ double QuickTrackAssociatorByHitsImpl::weightedNumberOfTrackClusters(iter begin, weightedClusters += weight; } } - LogTrace("QuickTrackAssociatorByHitsImpl") << " total weighted clusters: " << weightedClusters; return weightedClusters; } From 671803fa5ebf5fff030018876262fc1dd28c1e24 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 17:34:59 +0200 Subject: [PATCH 102/115] add reserve statement in loadDetSetVector --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 8 +------- .../interface/VectorHitBuilderAlgorithmBase.h | 3 ++- .../src/VectorHitBuilderAlgorithm.cc | 8 ++++++-- .../src/VectorHitBuilderAlgorithmBase.cc | 8 +++++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index cab98d2f00909..0946507d17094 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -39,9 +39,6 @@ VectorHit::VectorHit(const GeomDet& idet, theCurvature(curvature), theCurvatureError(curvatureError), thePhi(phi) { -// thePosition = LocalPoint(vh2Dzx.localPosition().x(), vh2Dzy.localPosition().x(), 0.); - -// theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), 1.); //building the cov matrix 4x4 starting from the 2x2 const AlgebraicSymMatrix22 covMatZX = vh2Dzx.covMatrix(); @@ -96,10 +93,7 @@ void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const { holder.errors() = theCovMatrix; ProjectMatrix& pf = holder.projFunc(); - pf.index[0] = 1; - pf.index[1] = 2; - pf.index[2] = 3; - pf.index[3] = 4; + for (int i = 0; i<4; ++i) pf.index[i] = i+1; holder.measuredParams() = AlgebraicVector4(&holder.tsosLocalParameters().At(1), theDimension); holder.measuredErrors() = holder.tsosLocalErrors().Sub(1, 1); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index 8876fd85d95bc..bbfdfd608fef7 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -56,7 +56,8 @@ class VectorHitBuilderAlgorithmBase { void printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* cluster) const; void loadDetSetVector(std::unordered_map>& theMap, - edmNew::DetSetVector& theCollection) const; + edmNew::DetSetVector& theCollection, + const int totalSize) const; const TrackerGeometry* tkGeom_; const TrackerTopology* tkTopo_; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index d7c314bb93845..e095f8798b941 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -13,6 +13,8 @@ void VectorHitBuilderAlgorithm::run(edm::Handle> tempVHAcc, tempVHRej; + int totalAccepted = 0; + int totalRejected = 0; //loop over the DetSetVector LogDebug("VectorHitBuilderAlgorithm") << "with #clusters : " << clustersPhase2Collection->size() << std::endl; @@ -50,8 +52,10 @@ void VectorHitBuilderAlgorithm::run(edm::Handle >& theMap, - edmNew::DetSetVector& theCollection) const { - for (const auto& it : theMap) { + edmNew::DetSetVector& theCollection, + const int totalSize) const { + +theCollection.reserve(theMap.size(), totalSize); +for (const auto& it : theMap) { edmNew::DetSetVector::FastFiller vh_col(theCollection, it.first); - //vh_col.reserve(it.second.size()); for (const auto& vh_it : it.second) vh_col.push_back(vh_it); } From 93a827a83c15041eca266633f2a4aad0c5ebfeab Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 19:30:19 +0200 Subject: [PATCH 103/115] speed up cluster masking --- .../src/VectorHitBuilderAlgorithm.cc | 1 - .../plugins/TkStackMeasurementDet.cc | 39 +++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index e095f8798b941..054ca671c6801 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -79,7 +79,6 @@ void VectorHitBuilderAlgorithm::run(edm::Handle skipClustersLower; - std::vector skipClustersUpper; + const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); + const detset& upperDetSet = data.phase2OTData().detSet(upperDet()->index()); + std::vector skipClustersUpper(data.phase2OTClustersToSkip().empty()? 0 : upperDetSet.size(), false); + std::vector skipClustersLower(data.phase2OTClustersToSkip().empty()? 0 : lowerDetSet.size(), false); + + const Phase2TrackerCluster1D* begin = nullptr; if (!data.phase2OTData().handle()->data().empty()) { begin = &(data.phase2OTData().handle()->data().front()); } if (!data.phase2OTClustersToSkip().empty()) { - const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); - const detset& upperDetSet = data.phase2OTData().detSet(upperDet()->index()); if (!lowerDetSet.empty()) { for (const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++cil) { @@ -48,8 +50,8 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj } unsigned int indexl = cil - begin; if (data.phase2OTClustersToSkip()[indexl]) { - Phase2TrackerCluster1DRef clusterRef = edmNew::makeRefTo(data.phase2OTData().handle(), cil); - skipClustersLower.push_back(clusterRef); + int iLocalL = std::distance(lowerDetSet.begin(),cil); + skipClustersLower[iLocalL] = true; } } } @@ -61,23 +63,24 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj } unsigned int indexu = ciu - begin; if (data.phase2OTClustersToSkip()[indexu]) { - Phase2TrackerCluster1DRef clusterRef = edmNew::makeRefTo(data.phase2OTData().handle(), ciu); - skipClustersUpper.push_back(clusterRef); + int iLocalU = std::distance(upperDetSet.begin(),ciu); + skipClustersUpper[iLocalU] = true; } } } } - DetId detIdStack = specificGeomDet().geographicalId(); auto iterator = data.phase2OTVectorHits().find(detIdStack); if (iterator == data.phase2OTVectorHits().end()) return result; for (const auto& vecHit : data.phase2OTVectorHits()[detIdStack]) { - if (std::find(skipClustersLower.begin(), skipClustersLower.end(), vecHit.lowerCluster()) != skipClustersLower.end()) - continue; - if (std::find(skipClustersUpper.begin(), skipClustersUpper.end(), vecHit.upperCluster()) != skipClustersUpper.end()) - continue; + if (!data.phase2OTClustersToSkip().empty()){ + if (skipClustersLower[vecHit.lowerCluster().key()-lowerDetSet.offset()]) + continue; + if (skipClustersUpper[vecHit.upperCluster().key()-upperDetSet.offset()]) + continue; + } result.push_back(std::make_shared(vecHit)); } @@ -85,10 +88,12 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj if (iterator == data.phase2OTVectorHitsRej().end()) return result; for (const auto& vecHit : data.phase2OTVectorHitsRej()[detIdStack]) { - if (std::find(skipClustersLower.begin(), skipClustersLower.end(), vecHit.lowerCluster()) != skipClustersLower.end()) - continue; - if (std::find(skipClustersUpper.begin(), skipClustersUpper.end(), vecHit.upperCluster()) != skipClustersUpper.end()) - continue; + if (!data.phase2OTClustersToSkip().empty()){ + if (skipClustersLower[vecHit.lowerCluster().key()-lowerDetSet.offset()]) + continue; + if (skipClustersUpper[vecHit.upperCluster().key()-upperDetSet.offset()]) + continue; + } result.push_back(std::make_shared(vecHit)); } From 3b4b4d248e76c100895cb2c5345f3597c162c5e7 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 19:40:07 +0200 Subject: [PATCH 104/115] code format --- .../TrackerRecHit2D/interface/VectorHit.h | 1 - DataFormats/TrackerRecHit2D/src/VectorHit.cc | 13 +-- .../interface/VectorHitBuilderAlgorithm.h | 13 +-- .../interface/VectorHitBuilderAlgorithmBase.h | 3 +- .../plugins/VectorHitBuilderEDProducer.cc | 7 +- .../src/VectorHitBuilderAlgorithm.cc | 80 +++++++++++-------- .../src/VectorHitBuilderAlgorithmBase.cc | 9 +-- .../MeasurementTrackerEventProducer.cc | 3 +- .../plugins/TkStackMeasurementDet.cc | 22 +++-- .../src/Phase2OTBarrelRodBuilder.cc | 4 +- .../plugins/SeedingOTEDProducer.cc | 13 ++- 11 files changed, 86 insertions(+), 82 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 2ceebd2e5568a..78e2862603ec3 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -144,7 +144,6 @@ class VectorHit final : public BaseTrackerRecHit { float theCurvature; float theCurvatureError; float thePhi; - }; inline bool operator<(const VectorHit& one, const VectorHit& other) { return (one.chi2() < other.chi2()); } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 0946507d17094..0b0d9fb33cbca 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -39,7 +39,6 @@ VectorHit::VectorHit(const GeomDet& idet, theCurvature(curvature), theCurvatureError(curvatureError), thePhi(phi) { - //building the cov matrix 4x4 starting from the 2x2 const AlgebraicSymMatrix22 covMatZX = vh2Dzx.covMatrix(); const AlgebraicSymMatrix22 covMatZY = vh2Dzy.covMatrix(); @@ -93,7 +92,8 @@ void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const { holder.errors() = theCovMatrix; ProjectMatrix& pf = holder.projFunc(); - for (int i = 0; i<4; ++i) pf.index[i] = i+1; + for (int i = 0; i < 4; ++i) + pf.index[i] = i + 1; holder.measuredParams() = AlgebraicVector4(&holder.tsosLocalParameters().At(1), theDimension); holder.measuredErrors() = holder.tsosLocalErrors().Sub(1, 1); @@ -180,12 +180,7 @@ std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { } /// Access to component RecHits (if any) -std::vector VectorHit::recHits() const { - return {}; -} +std::vector VectorHit::recHits() const { return {}; } /// Non-const access to component RecHits (if any) -std::vector VectorHit::recHits() { - return {}; -} - +std::vector VectorHit::recHits() { return {}; } diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 3333c29804915..d70d8437b3bfc 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -37,11 +37,15 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { Local3DPoint& posouter, LocalError& errinner, LocalError& errouter) const; - struct CurvatureAndPhi { float curvature; float curvatureError; float phi; }; + struct CurvatureAndPhi { + float curvature; + float curvatureError; + float phi; + }; CurvatureAndPhi curvatureANDphi(Global3DPoint gPositionLower, - Global3DPoint gPositionUpper, - GlobalError gErrorLower, - GlobalError gErrorUpper) const; + Global3DPoint gPositionUpper, + GlobalError gErrorLower, + GlobalError gErrorUpper) const; std::vector> buildVectorHits( const StackGeomDet* stack, @@ -78,7 +82,6 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { Local3DVector& dir, AlgebraicSymMatrix22& covMatrix, double& chi2) const; - }; #endif diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index bbfdfd608fef7..88649f4aab00a 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -57,7 +57,7 @@ class VectorHitBuilderAlgorithmBase { void loadDetSetVector(std::unordered_map>& theMap, edmNew::DetSetVector& theCollection, - const int totalSize) const; + const int totalSize) const; const TrackerGeometry* tkGeom_; const TrackerTopology* tkTopo_; @@ -66,7 +66,6 @@ class VectorHitBuilderAlgorithmBase { std::vector barrelCut_; std::vector endcapCut_; - private: edm::ESInputTag cpeTag_; }; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc index 59a065f834c8e..0cd4e95110aaa 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -53,8 +53,8 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu // get input clusters data auto clustersHandle = event.getHandle(clusterProducer_); // create the final output collection - auto outputClustersAccepted = std::make_unique >(); - auto outputClustersRejected = std::make_unique >(); + auto outputClustersAccepted = std::make_unique>(); + auto outputClustersRejected = std::make_unique>(); std::unique_ptr outputVHAccepted(new VectorHitCollection()); std::unique_ptr outputVHRejected(new VectorHitCollection()); @@ -74,13 +74,12 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu } } LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n"; -#endif //EDM_ML_DEBUG +#endif //EDM_ML_DEBUG // write output to file event.put(std::move(outputClustersAccepted), "accepted"); event.put(std::move(outputClustersRejected), "rejected"); event.put(std::move(outputVHAccepted), "accepted"); event.put(std::move(outputVHRejected), "rejected"); - } void VectorHitBuilderEDProducer::run(edm::Handle> clusters, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 054ca671c6801..205e32ec016c5 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -27,7 +27,7 @@ void VectorHitBuilderAlgorithm::run(edm::HandlepartnerDetId(detId1); } else continue; - + DetId detIdStack = tkTopo_->stack(detId1); //debug @@ -52,7 +52,7 @@ void VectorHitBuilderAlgorithm::run(edm::Handle> VectorHitBuilderAlgorithm::buildVectorHi cut = barrelCut_.at(layerStack); if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTEC) cut = endcapCut_.at(layerStack); - LogDebug("VectorHitBuilderAlgorithm") << " \t the cut is:" << cut << std::endl; - + LogDebug("VectorHitBuilderAlgorithm") << " \t the cut is:" << cut << std::endl; //only cache local parameters for upper cluster as we loop over lower clusters only once anyway std::vector> localParamsUpper; @@ -149,7 +148,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi std::vector upperClusters; const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); - for (auto const& clusterUpper : theUpperDetSet) { + for (auto const& clusterUpper : theUpperDetSet) { localGDUUpper.push_back(gduUpp); localParamsUpper.push_back(cpe_->localParameters(clusterUpper, *gduUpp)); } @@ -208,7 +207,6 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi double width = lpos_low_corr - lpos_upp_corr; LogDebug("VectorHitBuilderAlgorithm") << " \t width: " << width << std::endl; - //old cut: indipendent from layer //building my tolerance : 10*sigma //double delta = 10.0 * sqrt(lparamsLow.second.xx() + localParamsUpper[upperIterator].second.xx()); @@ -228,8 +226,8 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi LogDebug("VectorHitBuilderAlgorithm") << " rejecting VH: " << std::endl; //storing vh rejected for combinatiorial studies VectorHit vh = buildVectorHit(stack, cluL, cluU); - if (vh.isValid()){ - result.emplace_back(std::make_pair(vh, false)); + if (vh.isValid()) { + result.emplace_back(std::make_pair(vh, false)); } } upperIterator += 1; @@ -315,8 +313,8 @@ VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, GlobalError gErrorUpper = VectorHit::phase2clusterGlobalPosErr(geomDetUpper); if (gPositionLower.perp() > gPositionUpper.perp()) { - std::swap(gPositionLower,gPositionUpper); - std::swap(gErrorLower,gErrorUpper); + std::swap(gPositionLower, gPositionUpper); + std::swap(gErrorLower, gErrorUpper); } const CurvatureAndPhi curvatureAndPhi = curvatureANDphi(gPositionLower, gPositionUpper, gErrorLower, gErrorUpper); @@ -404,9 +402,9 @@ void VectorHitBuilderAlgorithm::fit(float x[2], } VectorHitBuilderAlgorithm::CurvatureAndPhi VectorHitBuilderAlgorithm::curvatureANDphi(Global3DPoint gPositionLower, - Global3DPoint gPositionUpper, - GlobalError gErrorLower, - GlobalError gErrorUpper) const { + Global3DPoint gPositionUpper, + GlobalError gErrorLower, + GlobalError gErrorUpper) const { VectorHitBuilderAlgorithm::CurvatureAndPhi result; float curvature = -999.; @@ -427,7 +425,6 @@ VectorHitBuilderAlgorithm::CurvatureAndPhi VectorHitBuilderAlgorithm::curvatureA double signCurv = -copysign(1.0, n3); double phi1 = atan2(gPositionUpper.y() - gPositionLower.y(), gPositionUpper.x() - gPositionLower.x()); - double x2Low = pow(gPositionLower.x(), 2); double y2Low = pow(gPositionLower.y(), 2); double x2Up = pow(gPositionUpper.x(), 2); @@ -438,9 +435,11 @@ VectorHitBuilderAlgorithm::CurvatureAndPhi VectorHitBuilderAlgorithm::curvatureA double h2Inf = 1. / (2 * h1); double r12 = gPositionLower.perp2(); double r22 = gPositionUpper.perp2(); - double h3 = pow(n2[0],2) + pow(n2[1],2); - double h4 = -x2Low * gPositionUpper.x() + gPositionLower.x() * x2Up + gPositionLower.x() *y2Up - gPositionUpper.x() * y2Low; - double h5 = x2Low * gPositionUpper.y() - x2Up * gPositionLower.y() + y2Low * gPositionUpper.y() - gPositionLower.y() * y2Up; + double h3 = pow(n2[0], 2) + pow(n2[1], 2); + double h4 = -x2Low * gPositionUpper.x() + gPositionLower.x() * x2Up + gPositionLower.x() * y2Up - + gPositionUpper.x() * y2Low; + double h5 = + x2Low * gPositionUpper.y() - x2Up * gPositionLower.y() + y2Low * gPositionUpper.y() - gPositionLower.y() * y2Up; //radius of circle double invRho2 = (4. * h1 * h1) / (r12 * r22 * h3); @@ -463,27 +462,45 @@ VectorHitBuilderAlgorithm::CurvatureAndPhi VectorHitBuilderAlgorithm::curvatureA double denom2 = 1. / (pow(r12 * r22 * h3, 1.5)); jacobian[0][0] = 1.0; // dx1/dx1 dx1/dy1 dx2/dx1 dy2/dx1 jacobian[1][1] = 1.0; //dy1/dx1 dy1/dy1 dy2/dx1 dy2/dx1 - jacobian[2][0] = -2. * ((h1 * (gPositionLower.x() * r22 * h3 + (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2 - (gPositionUpper.y()) * denom1); // dkappa/dx1 - jacobian[2][1] = -2. * ((gPositionUpper.x()) * denom1 + (h1 * (gPositionLower.y() * r22 * h3 + r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * denom2); // dkappa/dy1 - jacobian[2][2] = -2. * ((gPositionLower.y()) * denom1 + (h1 * (gPositionUpper.x() * r12 * h3 - (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2); // dkappa/dx2 - jacobian[2][3] = -2. * ((h1 * (gPositionUpper.y() * r12 * h3 - r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * denom2 - (gPositionLower.x()) * denom1); // dkappa/dy2 + jacobian[2][0] = + -2. * ((h1 * (gPositionLower.x() * r22 * h3 + (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * denom2 - + (gPositionUpper.y()) * denom1); // dkappa/dx1 + jacobian[2][1] = + -2. * ((gPositionUpper.x()) * denom1 + + (h1 * (gPositionLower.y() * r22 * h3 + r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * + denom2); // dkappa/dy1 + jacobian[2][2] = + -2. * ((gPositionLower.y()) * denom1 + + (h1 * (gPositionUpper.x() * r12 * h3 - (gPositionLower.x() - gPositionUpper.x()) * r12 * r22)) * + denom2); // dkappa/dx2 + jacobian[2][3] = + -2. * ((h1 * (gPositionUpper.y() * r12 * h3 - r12 * r22 * (gPositionLower.y() - gPositionUpper.y()))) * denom2 - + (gPositionLower.x()) * denom1); // dkappa/dy2 AlgebraicVector2 mVector; //to compute phi at the cluster points mVector[0] = (gPositionLower.y() - ycentre) * invRho2; // dphi/dxcentre mVector[1] = -(gPositionLower.x() - xcentre) * invRho2; // dphi/dycentre //to compute phi at the origin - double h22Inv = 1./pow(h2, 2); + double h22Inv = 1. / pow(h2, 2); AlgebraicROOTObject<2, 4>::Matrix kMatrix; - kMatrix[0][0] = 2. * ((gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionUpper.y() * h5) * h22Inv); // dxm/dx1 - kMatrix[0][1] = (2. * gPositionUpper.x() * h5) * h22Inv - (x2Up + y2Up - 2. * gPositionLower.y() * gPositionUpper.y()) * h2Inf; // dxm/dy1 - kMatrix[0][2] = 2. * ((gPositionLower.y() * h5) * h22Inv - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dxm/dx2 - kMatrix[0][3] = (x2Low + y2Low - 2. * gPositionUpper.y() * gPositionLower.y()) * h2Inf - (2. * gPositionLower.x() * h5) * h22Inv; // dxm/dy2 - kMatrix[1][0] = (x2Up - 2. * gPositionLower.x() * gPositionUpper.x() + y2Up) * h2Inf - (2. * gPositionUpper.y() * h4) * h22Inv; // dym/dx1 - kMatrix[1][1] = 2. * ((gPositionUpper.x() * h4) * h22Inv - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dym/dy1 - kMatrix[1][2] = (2. * gPositionLower.y() * h4) * h22Inv - (x2Low - 2. * gPositionUpper.x() * gPositionLower.x() + y2Low) * h2Inf; // dym/dx2 - kMatrix[1][3] = 2. * (gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionLower.x() * h4) * h22Inv; // dym/dy2 + kMatrix[0][0] = + 2. * ((gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionUpper.y() * h5) * h22Inv); // dxm/dx1 + kMatrix[0][1] = (2. * gPositionUpper.x() * h5) * h22Inv - + (x2Up + y2Up - 2. * gPositionLower.y() * gPositionUpper.y()) * h2Inf; // dxm/dy1 + kMatrix[0][2] = + 2. * ((gPositionLower.y() * h5) * h22Inv - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dxm/dx2 + kMatrix[0][3] = (x2Low + y2Low - 2. * gPositionUpper.y() * gPositionLower.y()) * h2Inf - + (2. * gPositionLower.x() * h5) * h22Inv; // dxm/dy2 + kMatrix[1][0] = (x2Up - 2. * gPositionLower.x() * gPositionUpper.x() + y2Up) * h2Inf - + (2. * gPositionUpper.y() * h4) * h22Inv; // dym/dx1 + kMatrix[1][1] = + 2. * ((gPositionUpper.x() * h4) * h22Inv - (gPositionUpper.x() * gPositionLower.y()) * h2Inf); // dym/dy1 + kMatrix[1][2] = (2. * gPositionLower.y() * h4) * h22Inv - + (x2Low - 2. * gPositionUpper.x() * gPositionLower.x() + y2Low) * h2Inf; // dym/dx2 + kMatrix[1][3] = + 2. * (gPositionLower.x() * gPositionUpper.y()) * h2Inf - (gPositionLower.x() * h4) * h22Inv; // dym/dy2 AlgebraicVector4 nMatrix = mVector * kMatrix; jacobian[3][0] = nMatrix[0]; // dphi/(dx1,dy1,dx2,dy2) @@ -527,8 +544,7 @@ VectorHitBuilderAlgorithm::CurvatureAndPhi VectorHitBuilderAlgorithm::curvatureA temp = temp * gErrors; errorCurvature = temp[0] * curvatureJacobian[0] + temp[1] * curvatureJacobian[1] + temp[2] * curvatureJacobian[2] + temp[3] * curvatureJacobian[3]; - - } + } result.curvature = curvature; result.curvatureError = errorCurvature; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index e7db9a0edf44d..b9035a168e4fa 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -97,11 +97,10 @@ void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, } void VectorHitBuilderAlgorithmBase::loadDetSetVector(std::unordered_map >& theMap, - edmNew::DetSetVector& theCollection, - const int totalSize) const { - -theCollection.reserve(theMap.size(), totalSize); -for (const auto& it : theMap) { + edmNew::DetSetVector& theCollection, + const int totalSize) const { + theCollection.reserve(theMap.size(), totalSize); + for (const auto& it : theMap) { edmNew::DetSetVector::FastFiller vh_col(theCollection, it.first); for (const auto& vh_it : it.second) vh_col.push_back(vh_it); diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc index 0b744c7733b3a..29b49c425832d 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerEventProducer.cc @@ -126,8 +126,7 @@ void MeasurementTrackerEventProducer::produce(edm::Event& iEvent, const edm::Eve // const VectorHitCollection* phase2OTVectorHits = useVectorHits_ ? &iEvent.get(thePh2OTVectorHitsLabel) : nullptr; - const VectorHitCollection* phase2OTVectorHitsRej = - useVectorHits_ ? &iEvent.get(thePh2OTVectorHitsRejLabel) : nullptr; + const VectorHitCollection* phase2OTVectorHitsRej = useVectorHits_ ? &iEvent.get(thePh2OTVectorHitsRejLabel) : nullptr; iEvent.put(std::make_unique(*measurementTracker, stripData.release(), pixelData.release(), diff --git a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc index e7ddb45169c28..f284d0c56d30f 100644 --- a/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc +++ b/RecoTracker/MeasurementDet/plugins/TkStackMeasurementDet.cc @@ -32,16 +32,14 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj //find clusters to skip const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index()); const detset& upperDetSet = data.phase2OTData().detSet(upperDet()->index()); - std::vector skipClustersUpper(data.phase2OTClustersToSkip().empty()? 0 : upperDetSet.size(), false); - std::vector skipClustersLower(data.phase2OTClustersToSkip().empty()? 0 : lowerDetSet.size(), false); - + std::vector skipClustersUpper(data.phase2OTClustersToSkip().empty() ? 0 : upperDetSet.size(), false); + std::vector skipClustersLower(data.phase2OTClustersToSkip().empty() ? 0 : lowerDetSet.size(), false); const Phase2TrackerCluster1D* begin = nullptr; if (!data.phase2OTData().handle()->data().empty()) { begin = &(data.phase2OTData().handle()->data().front()); } if (!data.phase2OTClustersToSkip().empty()) { - if (!lowerDetSet.empty()) { for (const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++cil) { if (cil < begin) { @@ -50,7 +48,7 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj } unsigned int indexl = cil - begin; if (data.phase2OTClustersToSkip()[indexl]) { - int iLocalL = std::distance(lowerDetSet.begin(),cil); + int iLocalL = std::distance(lowerDetSet.begin(), cil); skipClustersLower[iLocalL] = true; } } @@ -63,7 +61,7 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj } unsigned int indexu = ciu - begin; if (data.phase2OTClustersToSkip()[indexu]) { - int iLocalU = std::distance(upperDetSet.begin(),ciu); + int iLocalU = std::distance(upperDetSet.begin(), ciu); skipClustersUpper[iLocalU] = true; } } @@ -75,10 +73,10 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj if (iterator == data.phase2OTVectorHits().end()) return result; for (const auto& vecHit : data.phase2OTVectorHits()[detIdStack]) { - if (!data.phase2OTClustersToSkip().empty()){ - if (skipClustersLower[vecHit.lowerCluster().key()-lowerDetSet.offset()]) + if (!data.phase2OTClustersToSkip().empty()) { + if (skipClustersLower[vecHit.lowerCluster().key() - lowerDetSet.offset()]) continue; - if (skipClustersUpper[vecHit.upperCluster().key()-upperDetSet.offset()]) + if (skipClustersUpper[vecHit.upperCluster().key() - upperDetSet.offset()]) continue; } result.push_back(std::make_shared(vecHit)); @@ -88,10 +86,10 @@ TkStackMeasurementDet::RecHitContainer TkStackMeasurementDet::recHits(const Traj if (iterator == data.phase2OTVectorHitsRej().end()) return result; for (const auto& vecHit : data.phase2OTVectorHitsRej()[detIdStack]) { - if (!data.phase2OTClustersToSkip().empty()){ - if (skipClustersLower[vecHit.lowerCluster().key()-lowerDetSet.offset()]) + if (!data.phase2OTClustersToSkip().empty()) { + if (skipClustersLower[vecHit.lowerCluster().key() - lowerDetSet.offset()]) continue; - if (skipClustersUpper[vecHit.upperCluster().key()-upperDetSet.offset()]) + if (skipClustersUpper[vecHit.upperCluster().key() - upperDetSet.offset()]) continue; } result.push_back(std::make_shared(vecHit)); diff --git a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc index b96c630d7e74e..71d3286bdb129 100644 --- a/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc +++ b/RecoTracker/TkDetLayers/src/Phase2OTBarrelRodBuilder.cc @@ -24,7 +24,7 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 } meanR = meanR / allGeometricDets.size(); LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl; - for (auto const& compGeometricDets : allGeometricDets){ + for (auto const& compGeometricDets : allGeometricDets) { const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets->geographicalId()); if (compGeometricDets->positionBounds().perp() < meanR) @@ -37,7 +37,6 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size(); LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size(); - } else { vector compGeometricDets; @@ -80,7 +79,6 @@ Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2 LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size(); LogDebug("TkDetLayers") << "innerGeomDetsBro.size(): " << innerGeomDetBrothers.size(); LogDebug("TkDetLayers") << "outerGeomDetsBro.size(): " << outerGeomDetBrothers.size(); - } return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers); diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index ab8f80679dbdb..195d4f1bf1a7d 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -231,13 +231,13 @@ TrajectorySeedCollection SeedingOTEDProducer::run(edm::Handle container; container.push_back(hitL1->clone()); container.push_back(hitL2->clone()); container.push_back(hitL3->clone()); - TrajectorySeed ts = + TrajectorySeed ts = createSeed(updatedTSOSL3_final.second, container, hitL3->geographicalId(), *buildingPropagator); result.push_back(ts); } @@ -259,7 +259,7 @@ unsigned int SeedingOTEDProducer::checkLayer(unsigned int iidd) { } std::vector SeedingOTEDProducer::collectVHsOnLayer(const edmNew::DetSetVector& input, - unsigned int layerNumber) { + unsigned int layerNumber) { std::vector vHsOnLayer; if (!input.empty()) { for (const auto& DSViter : input) { @@ -322,8 +322,8 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto } AlgebraicSymMatrix55 SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix44 mat44) const { -// if (mat44.num_row() != 4 || mat44.num_col() != 4) -// assert("Wrong dimension! This should be a 4x4 matrix!"); + // if (mat44.num_row() != 4 || mat44.num_col() != 4) + // assert("Wrong dimension! This should be a 4x4 matrix!"); AlgebraicSymMatrix55 result; for (int i = 1; i < 5; i++) { @@ -346,8 +346,7 @@ std::pair SeedingOTEDProducer::propagateAndUpdat } float SeedingOTEDProducer::computeGlobalThetaError(const VectorHit* vh, const double sigmaZ_beamSpot) const { - double derivative = - vh->globalPosition().perp() / vh->globalPosition().mag2(); + double derivative = vh->globalPosition().perp() / vh->globalPosition().mag2(); double derivative2 = pow(derivative, 2); return pow(derivative2 * vh->lowerGlobalPosErr().czz() + derivative2 * pow(sigmaZ_beamSpot, 2), 0.5); } From 224b3a9edfb591cca6f9df75549ac60d45714669 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 20:47:24 +0200 Subject: [PATCH 105/115] put printClusters behind debug statements --- .../plugins/VectorHitBuilderEDProducer.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc index 0cd4e95110aaa..c0f9816a0c2f5 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -59,8 +59,10 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu std::unique_ptr outputVHRejected(new VectorHitCollection()); stubsBuilder_ = &es.getData(stubsBuilderToken_); + #ifdef EDM_ML_DEBUG // check on the input clusters stubsBuilder_->printClusters(*clustersHandle); + #endif //EDM_ML_DEBUG // running the stub building algorithm //ERICA::output should be moved in the different algo classes? From 41ff72e81bfba5e203c0d6cbb033f1137640fe22 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 20:55:13 +0200 Subject: [PATCH 106/115] re-add mysteriously vanished float --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 0b0d9fb33cbca..b832f64f12ed0 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -114,7 +114,7 @@ Global3DPoint VectorHit::upperGlobalPos() const { Global3DPoint VectorHit::phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster) { const PixelTopology* topo = &geomDet->specificTopology(); float ix = cluster->center(); - float iy = cluster->column() + 0.5; // halfway the column + float iy = cluster->column() + 0.5f; // halfway the column LocalPoint lp(topo->localX(ix), topo->localY(iy), 0); // x, y, z Global3DPoint gp = geomDet->surface().toGlobal(lp); return gp; From d952d3ae75d4f5a8fa6863d510a21897719bd91a Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sat, 10 Oct 2020 21:42:50 +0200 Subject: [PATCH 107/115] code format --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 2 +- .../plugins/VectorHitBuilderEDProducer.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index b832f64f12ed0..790b171a815ca 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -114,7 +114,7 @@ Global3DPoint VectorHit::upperGlobalPos() const { Global3DPoint VectorHit::phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster) { const PixelTopology* topo = &geomDet->specificTopology(); float ix = cluster->center(); - float iy = cluster->column() + 0.5f; // halfway the column + float iy = cluster->column() + 0.5f; // halfway the column LocalPoint lp(topo->localX(ix), topo->localY(iy), 0); // x, y, z Global3DPoint gp = geomDet->surface().toGlobal(lp); return gp; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc index c0f9816a0c2f5..404ce82f97004 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/VectorHitBuilderEDProducer.cc @@ -59,10 +59,10 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu std::unique_ptr outputVHRejected(new VectorHitCollection()); stubsBuilder_ = &es.getData(stubsBuilderToken_); - #ifdef EDM_ML_DEBUG +#ifdef EDM_ML_DEBUG // check on the input clusters stubsBuilder_->printClusters(*clustersHandle); - #endif //EDM_ML_DEBUG +#endif //EDM_ML_DEBUG // running the stub building algorithm //ERICA::output should be moved in the different algo classes? From 7d164dbe0db851519f85855bac83195ccac63d99 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Sun, 11 Oct 2020 16:00:34 +0200 Subject: [PATCH 108/115] fix earlyGeneralTracks config --- .../python/earlyGeneralTracks_cfi.py | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py index 9bc904b3ebd5e..bb76495d7438a 100644 --- a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py +++ b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py @@ -103,9 +103,22 @@ ) from Configuration.ProcessModifiers.vectorHits_cff import vectorHits -(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, TrackProducers = earlyGeneralTracks.TrackProducers + ['pixelLessStepTracks']) -(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, hasSelector = earlyGeneralTracks.hasSelector + [1]) -(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, indivShareFrac = earlyGeneralTracks.indivShareFrac + [0.095]) -(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, selectedTrackQuals = earlyGeneralTracks.selectedTrackQuals + ['pixelLessStepSelector:pixelLessStep']) -(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, setsToMerge = cms.VPSet( cms.PSet( tLists=cms.vint32(0,1,2,3,4,5,6), pQual=cms.bool(True)))) +(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, TrackProducers = ['initialStepTracks', + 'highPtTripletStepTracks', + 'lowPtQuadStepTracks', + 'lowPtTripletStepTracks', + 'detachedQuadStepTracks', + 'pixelPairStepTracks', + 'pixelLessStepTracks'], + hasSelector = [1,1,1,1,1,1,1], + indivShareFrac = [1.0,0.16,0.095,0.09,0.09,0.09,0.095], + selectedTrackQuals = ['initialStepSelector:initialStep', + 'highPtTripletStepSelector:highPtTripletStep', + 'lowPtQuadStepSelector:lowPtQuadStep', + 'lowPtTripletStepSelector:lowPtTripletStep', + 'detachedQuadStep', + 'pixelPairStepSelector:pixelPairStep', + 'pixelLessStepSelector:pixelLessStep'], + setsToMerge = cms.VPSet( cms.PSet( tLists=cms.vint32(0,1,2,3,4,5,6), pQual=cms.bool(True))) +) From 72ba9dbfe6ed8a0e84c9e21e0051955e7a1916e1 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 12 Oct 2020 06:17:18 +0200 Subject: [PATCH 109/115] get rid of the sorting of the VH --- .../interface/VectorHitBuilderAlgorithm.h | 5 +- .../interface/VectorHitBuilderAlgorithmBase.h | 5 +- .../src/VectorHitBuilderAlgorithm.cc | 60 ++++--------------- 3 files changed, 20 insertions(+), 50 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index d70d8437b3bfc..05d9ff16e9226 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -47,7 +47,10 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { GlobalError gErrorLower, GlobalError gErrorUpper) const; - std::vector> buildVectorHits( + void buildVectorHits( + VectorHitCollection& vhAcc, + VectorHitCollection& vhRej, + DetId detIdStack, const StackGeomDet* stack, edm::Handle> clusters, const detset& DSVinner, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index 88649f4aab00a..41bde36a9e863 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -36,7 +36,10 @@ class VectorHitBuilderAlgorithmBase { edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej) const = 0; - virtual std::vector> buildVectorHits( + virtual void buildVectorHits( + VectorHitCollection& vhAcc, + VectorHitCollection& vhRej, + DetId detIdStack, const StackGeomDet* stack, edm::Handle> clusters, const detset& DSVinner, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 205e32ec016c5..fb33fc9fb20c8 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -12,10 +12,6 @@ void VectorHitBuilderAlgorithm::run(edm::Handle> tempVHAcc, tempVHRej; - int totalAccepted = 0; - int totalRejected = 0; - //loop over the DetSetVector LogDebug("VectorHitBuilderAlgorithm") << "with #clusters : " << clustersPhase2Collection->size() << std::endl; for (auto dSViter : *clustersPhase2Collection) { @@ -43,45 +39,9 @@ void VectorHitBuilderAlgorithm::run(edm::Handleend()) { gd = tkGeom_->idToDet(detIdStack); stackDet = dynamic_cast(gd); - std::vector vhsInStack_Acc; - std::vector vhsInStack_Rej; - const auto& vhsInStack_AccRej = buildVectorHits(stackDet, clusters, it_detLower, *it_detUpper); - - //storing accepted and rejected VHs - for (const auto& vh : vhsInStack_AccRej) { - if (vh.second == true) { - vhsInStack_Acc.push_back(vh.first); - std::push_heap(vhsInStack_Acc.begin(), vhsInStack_Acc.end()); - totalAccepted += 1; - } else if (vh.second == false) { - vhsInStack_Rej.push_back(vh.first); - totalRejected += 1; - } - } - - //ERICA:: to be checked with map! - //sorting vhs for best chi2 - std::sort_heap(vhsInStack_Acc.begin(), vhsInStack_Acc.end()); - - tempVHAcc[detIdStack] = vhsInStack_Acc; - tempVHRej[detIdStack] = vhsInStack_Rej; -#ifdef EDM_ML_DEBUG - LogTrace("VectorHitBuilderAlgorithm") - << "For detId #" << detIdStack.rawId() << " the following VHits have been accepted:"; - for (const auto& vhIt : vhsInStack_Acc) { - LogTrace("VectorHitBuilderAlgorithm") << "accepted VH: " << vhIt; - } - LogTrace("VectorHitBuilderAlgorithm") - << "For detId #" << detIdStack.rawId() << " the following VHits have been rejected:"; - for (const auto& vhIt : vhsInStack_Rej) { - LogTrace("VectorHitBuilderAlgorithm") << "rejected VH: " << vhIt; - } -#endif + buildVectorHits(vhAcc, vhRej, detIdStack, stackDet, clusters, it_detLower, *it_detUpper); } } - loadDetSetVector(tempVHAcc, vhAcc, totalAccepted); - loadDetSetVector(tempVHRej, vhRej, totalRejected); - LogDebug("VectorHitBuilderAlgorithm") << "End run VectorHitBuilderAlgorithm ... \n"; } @@ -115,19 +75,26 @@ bool VectorHitBuilderAlgorithm::checkClustersCompatibility(Local3DPoint& poslowe //---------------------------------------------------------------------------- //ERICA::in the DT code the global position is used to compute the alpha angle and put a cut on that. -std::vector> VectorHitBuilderAlgorithm::buildVectorHits( +void VectorHitBuilderAlgorithm::buildVectorHits( + VectorHitCollection& vhAcc, + VectorHitCollection& vhRej, + DetId detIdStack, const StackGeomDet* stack, edm::Handle> clusters, const detset& theLowerDetSet, const detset& theUpperDetSet, const std::vector& phase2OTClustersToSkip) const { - std::vector> result; if (checkClustersCompatibilityBeforeBuilding(clusters, theLowerDetSet, theUpperDetSet)) { LogDebug("VectorHitBuilderAlgorithm") << " compatible -> continue ... " << std::endl; } else { LogTrace("VectorHitBuilderAlgorithm") << " not compatible, going to the next cluster"; } + + edmNew::DetSetVector::FastFiller vh_colAcc(vhAcc, detIdStack); + edmNew::DetSetVector::FastFiller vh_colRej(vhRej, detIdStack); + + unsigned int layerStack = tkTopo_->layer(stack->geographicalId()); if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) LogDebug("VectorHitBuilderAlgorithm") << " \t is barrel. " << std::endl; @@ -146,7 +113,6 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi std::vector> localParamsUpper; std::vector localGDUUpper; - std::vector upperClusters; const PixelGeomDetUnit* gduUpp = dynamic_cast(stack->upperDet()); for (auto const& clusterUpper : theUpperDetSet) { localGDUUpper.push_back(gduUpp); @@ -219,7 +185,7 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi VectorHit vh = buildVectorHit(stack, cluL, cluU); //protection: the VH can also be empty!! if (vh.isValid()) { - result.emplace_back(std::make_pair(vh, true)); + vh_colAcc.push_back(vh); } } else { @@ -227,14 +193,12 @@ std::vector> VectorHitBuilderAlgorithm::buildVectorHi //storing vh rejected for combinatiorial studies VectorHit vh = buildVectorHit(stack, cluL, cluU); if (vh.isValid()) { - result.emplace_back(std::make_pair(vh, false)); + vh_colRej.push_back(vh); } } upperIterator += 1; } } - - return result; } VectorHit VectorHitBuilderAlgorithm::buildVectorHit(const StackGeomDet* stack, From 6dcc8c4c0decd466ad4e8cf31de13cb6f6712109 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 12 Oct 2020 06:27:30 +0200 Subject: [PATCH 110/115] code format --- .../interface/VectorHitBuilderAlgorithm.h | 17 ++++++++--------- .../interface/VectorHitBuilderAlgorithmBase.h | 17 ++++++++--------- .../src/VectorHitBuilderAlgorithm.cc | 19 ++++++++----------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 05d9ff16e9226..1cd6515c88378 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -47,15 +47,14 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { GlobalError gErrorLower, GlobalError gErrorUpper) const; - void buildVectorHits( - VectorHitCollection& vhAcc, - VectorHitCollection& vhRej, - DetId detIdStack, - const StackGeomDet* stack, - edm::Handle> clusters, - const detset& DSVinner, - const detset& DSVouter, - const std::vector& phase2OTClustersToSkip = std::vector()) const override; + void buildVectorHits(VectorHitCollection& vhAcc, + VectorHitCollection& vhRej, + DetId detIdStack, + const StackGeomDet* stack, + edm::Handle> clusters, + const detset& DSVinner, + const detset& DSVouter, + const std::vector& phase2OTClustersToSkip = std::vector()) const override; VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index 41bde36a9e863..4ddb2dcb7ec6b 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -36,15 +36,14 @@ class VectorHitBuilderAlgorithmBase { edmNew::DetSetVector& clustersAcc, edmNew::DetSetVector& clustersRej) const = 0; - virtual void buildVectorHits( - VectorHitCollection& vhAcc, - VectorHitCollection& vhRej, - DetId detIdStack, - const StackGeomDet* stack, - edm::Handle> clusters, - const detset& DSVinner, - const detset& DSVouter, - const std::vector& phase2OTClustersToSkip = std::vector()) const = 0; + virtual void buildVectorHits(VectorHitCollection& vhAcc, + VectorHitCollection& vhRej, + DetId detIdStack, + const StackGeomDet* stack, + edm::Handle> clusters, + const detset& DSVinner, + const detset& DSVouter, + const std::vector& phase2OTClustersToSkip = std::vector()) const = 0; virtual VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index fb33fc9fb20c8..1144086b29f58 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -75,26 +75,23 @@ bool VectorHitBuilderAlgorithm::checkClustersCompatibility(Local3DPoint& poslowe //---------------------------------------------------------------------------- //ERICA::in the DT code the global position is used to compute the alpha angle and put a cut on that. -void VectorHitBuilderAlgorithm::buildVectorHits( - VectorHitCollection& vhAcc, - VectorHitCollection& vhRej, - DetId detIdStack, - const StackGeomDet* stack, - edm::Handle> clusters, - const detset& theLowerDetSet, - const detset& theUpperDetSet, - const std::vector& phase2OTClustersToSkip) const { +void VectorHitBuilderAlgorithm::buildVectorHits(VectorHitCollection& vhAcc, + VectorHitCollection& vhRej, + DetId detIdStack, + const StackGeomDet* stack, + edm::Handle> clusters, + const detset& theLowerDetSet, + const detset& theUpperDetSet, + const std::vector& phase2OTClustersToSkip) const { if (checkClustersCompatibilityBeforeBuilding(clusters, theLowerDetSet, theUpperDetSet)) { LogDebug("VectorHitBuilderAlgorithm") << " compatible -> continue ... " << std::endl; } else { LogTrace("VectorHitBuilderAlgorithm") << " not compatible, going to the next cluster"; } - edmNew::DetSetVector::FastFiller vh_colAcc(vhAcc, detIdStack); edmNew::DetSetVector::FastFiller vh_colRej(vhRej, detIdStack); - unsigned int layerStack = tkTopo_->layer(stack->geographicalId()); if (stack->subDetector() == GeomDetEnumerators::SubDetector::P2OTB) LogDebug("VectorHitBuilderAlgorithm") << " \t is barrel. " << std::endl; From a82f98434fc67bca1c87aa3d68b4012b850102fc Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Tue, 13 Oct 2020 01:57:17 +0200 Subject: [PATCH 111/115] add comments --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 4 +++- RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index 790b171a815ca..dcc077e0a6702 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -155,7 +155,9 @@ float VectorHit::theta() const { return globalDirection().theta(); } float VectorHit::transverseMomentum(float magField) const { return magField * (CLHEP::c_light * 1e-5F) / theCurvature; -} // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, using precise value from speed of light + // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, using precise value from speed of light + // because curvature is a signed quantity this transverse momentum is also signed +} float VectorHit::momentum(float magField) const { return transverseMomentum(magField) / (1. * sin(theta())); } LocalError VectorHit::localPositionError() const { diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 195d4f1bf1a7d..334d2f384d69a 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -297,6 +297,7 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto //FIXME::charge is fine 1 every two times!! GlobalPoint center(0.0, 0.0, 0.0); int charge = 1; + // momentum is a signed quantity in this case float mom = vHit->momentum(magField_->inTesla(center).z()); float xPos = vHit->localPosition().x(); float yPos = vHit->localPosition().y(); From 60195712e2b4d2d66c40346df7d72958dff4107f Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Tue, 13 Oct 2020 03:00:40 +0200 Subject: [PATCH 112/115] code format --- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index dcc077e0a6702..b964ac88c3aaf 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -157,7 +157,7 @@ float VectorHit::transverseMomentum(float magField) const { return magField * (CLHEP::c_light * 1e-5F) / theCurvature; // pT [GeV] ~ 0.3 * B[T] * R [m], curvature is in cms, using precise value from speed of light // because curvature is a signed quantity this transverse momentum is also signed -} +} float VectorHit::momentum(float magField) const { return transverseMomentum(magField) / (1. * sin(theta())); } LocalError VectorHit::localPositionError() const { From 3300a89fbe9c670738d762b46d32431fc30368d5 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Thu, 15 Oct 2020 03:54:21 +0200 Subject: [PATCH 113/115] comments from Slava --- .../TrackerRecHit2D/interface/VectorHit.h | 7 ++--- .../TrackerRecHit2D/interface/VectorHit2D.h | 10 +++---- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 4 +-- .../interface/VectorHitBuilderAlgorithm.h | 8 +++--- .../interface/VectorHitBuilderAlgorithmBase.h | 16 +++++------- .../src/VectorHitBuilderAlgorithm.cc | 8 +++--- .../src/VectorHitBuilderAlgorithmBase.cc | 14 ++-------- .../python/earlyGeneralTracks_cfi.py | 26 +++++-------------- .../plugins/MeasurementTrackerESProducer.cc | 1 - .../plugins/SeedingOTEDProducer.cc | 6 ++--- ...ransientTrackingRecHitBuilderESProducer.cc | 1 - 11 files changed, 34 insertions(+), 67 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit.h b/DataFormats/TrackerRecHit2D/interface/VectorHit.h index 78e2862603ec3..df0a771f686d8 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit.h @@ -31,12 +31,10 @@ class VectorHit final : public BaseTrackerRecHit { VectorHit() : thePosition(), theDirection(), theCovMatrix() { setType(bad); } - //VectorHit(const VectorHit& vh); - VectorHit(const GeomDet& idet, const LocalPoint& posInner, const LocalVector& dir, - const AlgebraicSymMatrix44 covMatrix, + const AlgebraicSymMatrix44& covMatrix, const float chi2, OmniClusterRef const& lower, OmniClusterRef const& upper, @@ -75,7 +73,7 @@ class VectorHit final : public BaseTrackerRecHit { // returning methods LocalPoint localPosition() const override { return thePosition; } virtual LocalVector localDirection() const { return theDirection; } - AlgebraicSymMatrix44 covMatrix() const; + const AlgebraicSymMatrix44& covMatrix() const; LocalError localPositionError() const override; LocalError localDirectionError() const; Global3DVector globalDirectionVH() const; @@ -151,6 +149,5 @@ inline bool operator<(const VectorHit& one, const VectorHit& other) { return (on std::ostream& operator<<(std::ostream& os, const VectorHit& vh); typedef edmNew::DetSetVector VectorHitCollection; -//typedef VectorHitCollection VectorHitCollectionNew; #endif diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index fac5297b52c15..3143cd72c72c8 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -16,12 +16,12 @@ class VectorHit2D { theDirection(dir), theCovMatrix(covMatrix), theLocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]), - theChi2(chi2){}; + theChi2(chi2){} - const LocalPoint localPosition() const { return thePosition; } - const LocalVector localDirection() const { return theDirection; } - const LocalError localDirectionError() const { return theLocalError; } - const AlgebraicSymMatrix22 covMatrix() const { return theCovMatrix; } + const LocalPoint& localPosition() const { return thePosition; } + const LocalVector& localDirection() const { return theDirection; } + const LocalError& localDirectionError() const { return theLocalError; } + const AlgebraicSymMatrix22& covMatrix() const { return theCovMatrix; } float chi2() const { return theChi2; } int dimension() const { return theDimension; } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index b964ac88c3aaf..d942c95062104 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -5,7 +5,7 @@ VectorHit::VectorHit(const GeomDet& idet, const LocalPoint& posLower, const LocalVector& dir, - const AlgebraicSymMatrix44 covMatrix, + const AlgebraicSymMatrix44& covMatrix, const float chi2, OmniClusterRef const& lower, OmniClusterRef const& upper, @@ -168,7 +168,7 @@ LocalError VectorHit::localDirectionError() const { return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); } -AlgebraicSymMatrix44 VectorHit::covMatrix() const { return theCovMatrix; } +const AlgebraicSymMatrix44& VectorHit::covMatrix() const { return theCovMatrix; } std::ostream& operator<<(std::ostream& os, const VectorHit& vh) { os << " VectorHit create in the DetId#: " << vh.geographicalId() << "\n" diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h index 1cd6515c88378..8d31827293481 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithm.h @@ -31,8 +31,8 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { //not implemented yet bool checkClustersCompatibilityBeforeBuilding(edm::Handle> clusters, - const detset& theLowerDetSet, - const detset& theUpperDetSet) const; + const Detset& theLowerDetSet, + const Detset& theUpperDetSet) const; bool checkClustersCompatibility(Local3DPoint& posinner, Local3DPoint& posouter, LocalError& errinner, @@ -52,8 +52,8 @@ class VectorHitBuilderAlgorithm : public VectorHitBuilderAlgorithmBase { DetId detIdStack, const StackGeomDet* stack, edm::Handle> clusters, - const detset& DSVinner, - const detset& DSVouter, + const Detset& DSVinner, + const Detset& DSVouter, const std::vector& phase2OTClustersToSkip = std::vector()) const override; VectorHit buildVectorHit(const StackGeomDet* stack, diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h index 4ddb2dcb7ec6b..61d80a95cff87 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderAlgorithmBase.h @@ -18,8 +18,8 @@ class VectorHitBuilderAlgorithmBase { public: typedef edm::Ref, Phase2TrackerCluster1D> Phase2TrackerCluster1DRef; - typedef edmNew::DetSet detset; - typedef detset::const_iterator const_iterator; + typedef edmNew::DetSet Detset; + typedef Detset::const_iterator const_iterator; typedef edmNew::DetSetVector output_t; typedef std::pair> StackClusters; @@ -41,26 +41,22 @@ class VectorHitBuilderAlgorithmBase { DetId detIdStack, const StackGeomDet* stack, edm::Handle> clusters, - const detset& DSVinner, - const detset& DSVouter, + const Detset& DSVinner, + const Detset& DSVouter, const std::vector& phase2OTClustersToSkip = std::vector()) const = 0; virtual VectorHit buildVectorHit(const StackGeomDet* stack, Phase2TrackerCluster1DRef lower, Phase2TrackerCluster1DRef upper) const = 0; - double computeParallaxCorrection(const PixelGeomDetUnit*&, + double computeParallaxCorrection(const PixelGeomDetUnit*, const Point3DBase&, - const PixelGeomDetUnit*&, + const PixelGeomDetUnit*, const Point3DBase&) const; void printClusters(const edmNew::DetSetVector& clusters) const; void printCluster(const GeomDet* geomDetUnit, const Phase2TrackerCluster1D* cluster) const; - void loadDetSetVector(std::unordered_map>& theMap, - edmNew::DetSetVector& theCollection, - const int totalSize) const; - const TrackerGeometry* tkGeom_; const TrackerTopology* tkTopo_; const ClusterParameterEstimator* cpe_; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc index 1144086b29f58..be41bfc3aa412 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithm.cc @@ -47,8 +47,8 @@ void VectorHitBuilderAlgorithm::run(edm::Handle> clusters, - const detset& theLowerDetSet, - const detset& theUpperDetSet) const { + const Detset& theLowerDetSet, + const Detset& theUpperDetSet) const { if (theLowerDetSet.size() == 1 && theUpperDetSet.size() == 1) return true; @@ -80,8 +80,8 @@ void VectorHitBuilderAlgorithm::buildVectorHits(VectorHitCollection& vhAcc, DetId detIdStack, const StackGeomDet* stack, edm::Handle> clusters, - const detset& theLowerDetSet, - const detset& theUpperDetSet, + const Detset& theLowerDetSet, + const Detset& theUpperDetSet, const std::vector& phase2OTClustersToSkip) const { if (checkClustersCompatibilityBeforeBuilding(clusters, theLowerDetSet, theUpperDetSet)) { LogDebug("VectorHitBuilderAlgorithm") << " compatible -> continue ... " << std::endl; diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index b9035a168e4fa..7d557b6beec5f 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -20,9 +20,9 @@ VectorHitBuilderAlgorithmBase::VectorHitBuilderAlgorithmBase( endcapCut_(conf.getParameter >("EndcapCut")), cpeTag_(conf.getParameter("CPE")) {} -double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomDetUnit*& geomDetUnit_low, +double VectorHitBuilderAlgorithmBase::computeParallaxCorrection(const PixelGeomDetUnit* geomDetUnit_low, const Point3DBase& lPosClu_low, - const PixelGeomDetUnit*& geomDetUnit_upp, + const PixelGeomDetUnit* geomDetUnit_upp, const Point3DBase& lPosClu_upp) const { double parallCorr = 0.0; Global3DPoint origin(0, 0, 0); @@ -96,13 +96,3 @@ void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, return; } -void VectorHitBuilderAlgorithmBase::loadDetSetVector(std::unordered_map >& theMap, - edmNew::DetSetVector& theCollection, - const int totalSize) const { - theCollection.reserve(theMap.size(), totalSize); - for (const auto& it : theMap) { - edmNew::DetSetVector::FastFiller vh_col(theCollection, it.first); - for (const auto& vh_it : it.second) - vh_col.push_back(vh_it); - } -} diff --git a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py index bb76495d7438a..bece85beee642 100644 --- a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py +++ b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py @@ -102,23 +102,11 @@ ) ) from Configuration.ProcessModifiers.vectorHits_cff import vectorHits - -(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, TrackProducers = ['initialStepTracks', - 'highPtTripletStepTracks', - 'lowPtQuadStepTracks', - 'lowPtTripletStepTracks', - 'detachedQuadStepTracks', - 'pixelPairStepTracks', - 'pixelLessStepTracks'], - hasSelector = [1,1,1,1,1,1,1], - indivShareFrac = [1.0,0.16,0.095,0.09,0.09,0.09,0.095], - selectedTrackQuals = ['initialStepSelector:initialStep', - 'highPtTripletStepSelector:highPtTripletStep', - 'lowPtQuadStepSelector:lowPtQuadStep', - 'lowPtTripletStepSelector:lowPtTripletStep', - 'detachedQuadStep', - 'pixelPairStepSelector:pixelPairStep', - 'pixelLessStepSelector:pixelLessStep'], - setsToMerge = cms.VPSet( cms.PSet( tLists=cms.vint32(0,1,2,3,4,5,6), pQual=cms.bool(True))) -) +def _extend_pixelLess(x): + x.TrackProducers += ['pixelLessStepTracks'] + x.hasSelector += [1] + x.indivShareFrac += [0.095] + x.selectedTrackQuals += ['pixelLessStepSelector:pixelLessStep'] + x.setsToMerge = cms.VPSet( cms.PSet( tLists=cms.vint32(0,1,2,3,4,5,6), pQual=cms.bool(True))) +(trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, _extend_pixelLess) diff --git a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc index 540532c0ad0ba..54b75367b7df5 100644 --- a/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc +++ b/RecoTracker/MeasurementDet/plugins/MeasurementTrackerESProducer.cc @@ -17,7 +17,6 @@ #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" #include "RecoLocalTracker/Records/interface/TrackerCPERecord.h" -//#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 334d2f384d69a..9db09eea11ba7 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -47,7 +47,7 @@ class SeedingOTEDProducer : public edm::stream::EDProducer<> { std::vector collectVHsOnLayer(const edmNew::DetSetVector&, unsigned int); void printVHsOnLayer(const edmNew::DetSetVector&, unsigned int); const TrajectoryStateOnSurface buildInitialTSOS(const VectorHit*) const; - AlgebraicSymMatrix55 assign44To55(AlgebraicSymMatrix44) const; + AlgebraicSymMatrix55 assign44To55(const AlgebraicSymMatrix44&) const; std::pair propagateAndUpdate(const TrajectoryStateOnSurface initialTSOS, const Propagator&, const TrackingRecHit& hit) const; @@ -322,9 +322,7 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto return tsos; } -AlgebraicSymMatrix55 SeedingOTEDProducer::assign44To55(AlgebraicSymMatrix44 mat44) const { - // if (mat44.num_row() != 4 || mat44.num_col() != 4) - // assert("Wrong dimension! This should be a 4x4 matrix!"); +AlgebraicSymMatrix55 SeedingOTEDProducer::assign44To55(const AlgebraicSymMatrix44& mat44) const { AlgebraicSymMatrix55 result; for (int i = 1; i < 5; i++) { diff --git a/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc b/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc index e23f3a66df3e7..84908be991070 100644 --- a/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc +++ b/RecoTracker/TransientTrackingRecHit/plugins/TkTransientTrackingRecHitBuilderESProducer.cc @@ -5,7 +5,6 @@ #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" #include "RecoLocalTracker/Records/interface/TrackerCPERecord.h" -//#include "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h" From 988c5a36f501de72f62ad4c82b47bccfa3baf316 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Thu, 15 Oct 2020 04:11:49 +0200 Subject: [PATCH 114/115] code format and checks --- DataFormats/TrackerRecHit2D/interface/VectorHit2D.h | 2 +- DataFormats/TrackerRecHit2D/src/VectorHit.cc | 4 ++-- .../src/VectorHitBuilderAlgorithmBase.cc | 1 - .../FinalTrackSelectors/python/earlyGeneralTracks_cfi.py | 2 +- RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc | 1 - 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h index 3143cd72c72c8..d55130f6df8f3 100644 --- a/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h +++ b/DataFormats/TrackerRecHit2D/interface/VectorHit2D.h @@ -16,7 +16,7 @@ class VectorHit2D { theDirection(dir), theCovMatrix(covMatrix), theLocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]), - theChi2(chi2){} + theChi2(chi2) {} const LocalPoint& localPosition() const { return thePosition; } const LocalVector& localDirection() const { return theDirection; } diff --git a/DataFormats/TrackerRecHit2D/src/VectorHit.cc b/DataFormats/TrackerRecHit2D/src/VectorHit.cc index d942c95062104..d57358cc8f5d0 100644 --- a/DataFormats/TrackerRecHit2D/src/VectorHit.cc +++ b/DataFormats/TrackerRecHit2D/src/VectorHit.cc @@ -40,8 +40,8 @@ VectorHit::VectorHit(const GeomDet& idet, theCurvatureError(curvatureError), thePhi(phi) { //building the cov matrix 4x4 starting from the 2x2 - const AlgebraicSymMatrix22 covMatZX = vh2Dzx.covMatrix(); - const AlgebraicSymMatrix22 covMatZY = vh2Dzy.covMatrix(); + const AlgebraicSymMatrix22& covMatZX = vh2Dzx.covMatrix(); + const AlgebraicSymMatrix22& covMatZY = vh2Dzy.covMatrix(); theCovMatrix = AlgebraicSymMatrix44(); diff --git a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc index 7d557b6beec5f..b875042c9fee1 100644 --- a/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc +++ b/RecoLocalTracker/SiPhase2VectorHitBuilder/src/VectorHitBuilderAlgorithmBase.cc @@ -95,4 +95,3 @@ void VectorHitBuilderAlgorithmBase::printCluster(const GeomDet* geomDetUnit, return; } - diff --git a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py index bece85beee642..294008807c0df 100644 --- a/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py +++ b/RecoTracker/FinalTrackSelectors/python/earlyGeneralTracks_cfi.py @@ -107,6 +107,6 @@ def _extend_pixelLess(x): x.hasSelector += [1] x.indivShareFrac += [0.095] x.selectedTrackQuals += ['pixelLessStepSelector:pixelLessStep'] - x.setsToMerge = cms.VPSet( cms.PSet( tLists=cms.vint32(0,1,2,3,4,5,6), pQual=cms.bool(True))) + x.setsToMerge[0].tLists += [6] (trackingPhase2PU140 & vectorHits).toModify(earlyGeneralTracks, _extend_pixelLess) diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc index 9db09eea11ba7..ba28198988b29 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedingOTEDProducer.cc @@ -323,7 +323,6 @@ const TrajectoryStateOnSurface SeedingOTEDProducer::buildInitialTSOS(const Vecto } AlgebraicSymMatrix55 SeedingOTEDProducer::assign44To55(const AlgebraicSymMatrix44& mat44) const { - AlgebraicSymMatrix55 result; for (int i = 1; i < 5; i++) { for (int j = 1; j < 5; j++) { From 53aad7ea80671ecabf2561adcf945493510bc54f Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Thu, 15 Oct 2020 04:39:51 +0200 Subject: [PATCH 115/115] fix vectorHits workflows --- .../PyReleaseValidation/python/upgradeWorkflowComponents.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 6ca34a2531afd..89ede13d1b47f 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -306,16 +306,15 @@ def condition(self, fragment, stepList, key, hasHarvest): return fragment=="TTbar_14TeV" and '2026' in key upgradeWFs['vectorHits'] = UpgradeWorkflow_vectorHits( steps = [ - 'Reco', + 'RecoGlobal', ], PU = [ - 'Reco', + 'RecoGlobal', ], suffix = '_vectorHits', offset = 0.9, ) - # Patatrack workflows class UpgradeWorkflowPatatrack(UpgradeWorkflow): def condition(self, fragment, stepList, key, hasHarvest):