Skip to content

Commit

Permalink
Merge pull request #31314 from JanFSchulte/VHIntegrationV2
Browse files Browse the repository at this point in the history
Integrating VectorHits reconstruction for the Phase2 OT - reprise
  • Loading branch information
cmsbuild authored Oct 21, 2020
2 parents 11c67e5 + 53aad7e commit 1d50057
Show file tree
Hide file tree
Showing 70 changed files with 4,804 additions and 146 deletions.
6 changes: 5 additions & 1 deletion CommonTools/RecoAlgos/src/ClusterStorer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -44,9 +45,12 @@ 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<Phase2TrackerRecHit1D &>(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<VectorHit &>(newHit), hits, index));
} else {
if (hit_type == typeid(FastTrackerRecHit) || hit_type == typeid(FastProjectedTrackerRecHit) ||
hit_type == typeid(FastMatchedTrackerRecHit)) {
Expand Down
5 changes: 5 additions & 0 deletions Configuration/ProcessModifiers/python/vectorHits_cff.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions Configuration/PyReleaseValidation/python/relval_2026.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,23 @@ 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 = [
'RecoGlobal',
],
PU = [
'RecoGlobal',
],
suffix = '_vectorHits',
offset = 0.9,
)

# Patatrack workflows
class UpgradeWorkflowPatatrack(UpgradeWorkflow):
def condition(self, fragment, stepList, key, hasHarvest):
Expand Down
9 changes: 5 additions & 4 deletions DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +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 LocalPoint& p, const LocalError& e, GeomDet const& idet, trackerHitRTTI::RTTI rt)
: TrackingRecHit(idet, (unsigned int)(rt)), pos_(p), err_(e), qualWord_(0) {
Expand All @@ -49,18 +51,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_;
Expand Down
4 changes: 4 additions & 0 deletions DataFormats/TrackerRecHit2D/interface/TkCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SiStripRecHit1D;
class SiStripMatchedRecHit2D;
class ProjectedSiStripRecHit2D;
class Phase2TrackerRecHit1D;
class VectorHit;

class TkCloner {
public:
Expand Down Expand Up @@ -39,6 +40,7 @@ class TkCloner {
TrajectoryStateOnSurface const& tsos) const = 0;
virtual std::unique_ptr<Phase2TrackerRecHit1D> operator()(Phase2TrackerRecHit1D const& hit,
TrajectoryStateOnSurface const& tsos) const = 0;
virtual std::unique_ptr<VectorHit> operator()(VectorHit const& hit, TrajectoryStateOnSurface const& tsos) const = 0;

#ifndef __GCCXML__
virtual TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const& hit,
Expand All @@ -53,6 +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;
#endif
};
#endif
153 changes: 153 additions & 0 deletions DataFormats/TrackerRecHit2D/interface/VectorHit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#ifndef DataFormats_TrackerRecHit2D_VectorHit_h
#define DataFormats_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/CommonDetUnit/interface/PixelGeomDetUnit.h"

#include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h"

#include "DataFormats/TrackerRecHit2D/interface/TkCloner.h"

class VectorHit final : public BaseTrackerRecHit {
public:
typedef OmniClusterRef::Phase2Cluster1DRef ClusterRef;

VectorHit() : thePosition(), theDirection(), theCovMatrix() { setType(bad); }

VectorHit(const GeomDet& idet,
const LocalPoint& posInner,
const LocalVector& dir,
const AlgebraicSymMatrix44& covMatrix,
const float chi2,
OmniClusterRef const& lower,
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,
const float curvature,
const float curvatureError,
const float phi);

~VectorHit() override = default;

VectorHit* clone() const override { return new VectorHit(*this); }
RecHitPointer cloneSH() const override { return std::make_shared<VectorHit>(*this); }

bool sharesInput(const TrackingRecHit* other, SharedInputType what) const override;
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 pos&err are available as well.
//if det() is not present (null) the hit has been read from file and not updated
return det();
};

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 AlgebraicSymMatrix44& covMatrix() const;
LocalError localPositionError() const override;
LocalError localDirectionError() const;
Global3DVector globalDirectionVH() const;

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; }

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(); }
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;
static Global3DPoint phase2clusterGlobalPos(const PixelGeomDetUnit* geomDet, ClusterRef cluster);
GlobalError lowerGlobalPosErr() const;
GlobalError upperGlobalPosErr() const;
static GlobalError phase2clusterGlobalPosErr(const PixelGeomDetUnit* geomDet);

bool isPhase2() const override { return true; }

//FIXME: I have always two clusters in a VH
OmniClusterRef const& firstClusterRef() const override { return theLowerCluster; }
ClusterRef cluster() const { return theLowerCluster.cluster_phase2OT(); }

//This method returns the direction of the segment/stub in global coordinates
Global3DVector globalDirection() const;
float theta() const;

// Access to component RecHits (if any)
std::vector<const TrackingRecHit*> recHits() const override;
std::vector<TrackingRecHit*> recHits() override;

private:
// double dispatch
VectorHit* clone_(TkCloner const& cloner, TrajectoryStateOnSurface const& tsos) const override {
return cloner(*this, tsos).release();
}
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)
AlgebraicSymMatrix44 theCovMatrix;
float theChi2;
static constexpr int theDimension = 4;
OmniClusterRef theLowerCluster;
OmniClusterRef theUpperCluster;
float theCurvature;
float theCurvatureError;
float thePhi;
};

inline bool operator<(const VectorHit& one, const VectorHit& other) { return (one.chi2() < other.chi2()); }

std::ostream& operator<<(std::ostream& os, const VectorHit& vh);

typedef edmNew::DetSetVector<VectorHit> VectorHitCollection;

#endif
36 changes: 36 additions & 0 deletions DataFormats/TrackerRecHit2D/interface/VectorHit2D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#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() {}
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) {}

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; }

private:
LocalPoint thePosition;
LocalVector theDirection;
AlgebraicSymMatrix22 theCovMatrix;
LocalError theLocalError;
float theChi2;
static constexpr int theDimension = 2;
};
#endif
10 changes: 7 additions & 3 deletions DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -32,10 +33,13 @@ 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; }
} // namespace trackerHitRTTI

Expand Down
5 changes: 2 additions & 3 deletions DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ void BaseTrackerRecHit::check() const {
#endif

bool BaseTrackerRecHit::hasPositionAndError() const {
//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();

// 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 {
Expand Down
Loading

0 comments on commit 1d50057

Please sign in to comment.