Skip to content

Commit

Permalink
Merge pull request #18728 from VinInn/Phase2CAplusD11
Browse files Browse the repository at this point in the history
CA for Phase2 tracking + few more smaller-impact optimizations
  • Loading branch information
cmsbuild committed May 23, 2017
2 parents 0fca914 + 8e1ceb4 commit 6ce8de5
Show file tree
Hide file tree
Showing 16 changed files with 309 additions and 115 deletions.
Expand Up @@ -24,7 +24,7 @@ class Phase2TrackerCluster1D {
unsigned int column() const { return firstDigi_.column(); }
uint16_t size() const { return (data_ & 0x7fff); }
uint16_t threshold() const { return ((data_ >> 15) & 0x1); }
float center() const { return firstStrip() + (data_ & 0x7fff) / 2.; }
float center() const { return float(firstStrip()) + 0.5f*size(); }
std::pair< float, float > barycenter() const { return std::make_pair(column(), center()); }

private:
Expand Down
32 changes: 23 additions & 9 deletions RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h
Expand Up @@ -3,33 +3,47 @@

#include "RecoLocalTracker/ClusterParameterEstimator/interface/ClusterParameterEstimator.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"


class Phase2StripCPE : public ClusterParameterEstimator<Phase2TrackerCluster1D> {

public:
class Phase2StripCPE final : public ClusterParameterEstimator<Phase2TrackerCluster1D> {
public:

// currently (?) use Pixel classes for GeomDetUnit and Topology
using Phase2TrackerGeomDetUnit = PixelGeomDetUnit;
using Phase2TrackerTopology = PixelTopology ;

public:
struct Param {
Param() : topology(nullptr) {}
Phase2TrackerTopology const * topology;
LocalError localErr;
float coveredStrips;

};


public:

Phase2StripCPE() {};
Phase2StripCPE(edm::ParameterSet & conf, const MagneticField &);
Phase2StripCPE(edm::ParameterSet & conf, const MagneticField &,const TrackerGeometry&);
LocalValues localParameters(const Phase2TrackerCluster1D & cluster, const GeomDetUnit & det) const;
LocalVector driftDirection(const Phase2TrackerGeomDetUnit & det) const;

protected:
private:

void fillParam();
std::vector<Param> m_Params;

const MagneticField & magfield_;
const TrackerGeometry& geom_;
float tanLorentzAnglePerTesla_;
unsigned int m_off;

const MagneticField * magfield_;
bool use_LorentzAngle_DB_;
double tanLorentzAnglePerTesla_;

};

Expand Down
Expand Up @@ -54,11 +54,13 @@ Phase2StripCPEESProducer::Phase2StripCPEESProducer(const edm::ParameterSet & p)
std::shared_ptr<ClusterParameterEstimator<Phase2TrackerCluster1D> > Phase2StripCPEESProducer::produce(const TkStripCPERecord & iRecord) {

edm::ESHandle<MagneticField> magfield;
edm::ESHandle<TrackerGeometry> pDD;

switch(cpeNum_) {
case DEFAULT:
iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield );
cpe_ = std::make_shared<Phase2StripCPE>(pset_, *magfield);
iRecord.getRecord<TrackerDigiGeometryRecord>().get( pDD );
cpe_ = std::make_shared<Phase2StripCPE>(pset_, *magfield,*pDD);
break;
case GEOMETRIC:
cpe_ = std::make_shared<Phase2StripCPEGeometric>(pset_);
Expand Down
78 changes: 53 additions & 25 deletions RecoLocalTracker/Phase2TrackerRecHits/src/Phase2StripCPE.cc
@@ -1,57 +1,85 @@

#include "RecoLocalTracker/Phase2TrackerRecHits/interface/Phase2StripCPE.h"
#include "Geometry/CommonTopologies/interface/PixelTopology.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"


Phase2StripCPE::Phase2StripCPE(edm::ParameterSet & conf, const MagneticField & magf)
Phase2StripCPE::Phase2StripCPE(edm::ParameterSet & conf, const MagneticField & magf,const TrackerGeometry& geom) :
magfield_(magf),
geom_(geom),
tanLorentzAnglePerTesla_(conf.getParameter<double>("TanLorentzAnglePerTesla"))
{
magfield_ = &magf;
use_LorentzAngle_DB_ = conf.getParameter<bool>("LorentzAngle_DB");
if (use_LorentzAngle_DB_) {
throw cms::Exception("Lorentz Angle from DB not implemented yet");
tanLorentzAnglePerTesla_ = 0;
// old code: LorentzAngleMap_.getLorentzAngle(det->geographicalId().rawId());
} else {
tanLorentzAnglePerTesla_ = conf.getParameter<double>("TanLorentzAnglePerTesla");
}
fillParam();
}


Phase2StripCPE::LocalValues Phase2StripCPE::localParameters(
const Phase2TrackerCluster1D & cluster,
const GeomDetUnit & detunit) const
{
const Phase2TrackerGeomDetUnit & det = (const Phase2TrackerGeomDetUnit &) detunit;
const Phase2TrackerTopology * topo = &det.specificTopology();

float pitch_x = topo->pitch().first;
float pitch_y = topo->pitch().second;

// see https://github.com/cms-sw/cmssw/blob/CMSSW_8_1_X/RecoLocalTracker/SiStripRecHitConverter/src/StripCPE.cc
auto const & p = m_Params[detunit.index()-m_off];
auto const & topo = *p.topology;
float ix = cluster.center() - 0.5f * p.coveredStrips;
float iy = float(cluster.column())+0.5f; // halfway the column

float thickness = det.specificSurface().bounds().thickness();
LocalVector drift = driftDirection(det) * thickness;
LocalVector lvec = drift + LocalVector(0,0,-thickness);
float coveredStrips = lvec.x() / pitch_x; // simplifies wrt Phase0 tracker because only rectangular modules
LocalPoint lp( topo.localX(ix), topo.localY(iy), 0 ); // x, y, z

float ix = cluster.center() - 0.5 * coveredStrips;
float iy = cluster.column()+0.5; // halfway the column

LocalPoint lp( topo->localX(ix), topo->localY(iy), 0 ); // x, y, z
LocalError le( pow(pitch_x, 2) / 12, 0, pow(pitch_y, 2) / 12); // e2_xx, e2_xy, e2_yy

return std::make_pair( lp, le );
return std::make_pair( lp, p.localErr );
}


LocalVector Phase2StripCPE::driftDirection(
const Phase2TrackerGeomDetUnit & det) const
{
LocalVector lbfield = (det.surface()).toLocal(magfield_->inTesla(det.surface().position()));
LocalVector lbfield = (det.surface()).toLocal(magfield_.inTesla(det.surface().position()));

float dir_x = -tanLorentzAnglePerTesla_ * lbfield.y();
float dir_y = tanLorentzAnglePerTesla_ * lbfield.x();
float dir_z = 1.f; // E field always in z direction

return LocalVector(dir_x,dir_y,dir_z);
}


void Phase2StripCPE::fillParam() {

// in phase 2 they are all pixel topologies...
auto const & dus = geom_.detUnits();
m_off = dus.size();
// skip Barrel and Foward pixels...
for(unsigned int i=3;i<7;++i) {
LogDebug("LookingForFirstPhase2OT") << " Subdetector " << i
<< " GeomDetEnumerator " << GeomDetEnumerators::tkDetEnum[i]
<< " offset " << geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) << std::endl;
if(geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) != dus.size()) {
if(geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) < m_off) m_off = geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]);
}
}
LogDebug("LookingForFirstPhase2OT") << " Chosen offset: " << m_off;

m_Params.resize(dus.size()-m_off);
// very very minimal, for sure it will need to expand...
for (auto i=m_off; i!=dus.size();++i) {
auto & p= m_Params[i-m_off];

const Phase2TrackerGeomDetUnit & det = (const Phase2TrackerGeomDetUnit &)(*dus[i]);
assert(det.index()==int(i));
p.topology = &det.specificTopology();

auto pitch_x = p.topology->pitch().first;
auto pitch_y = p.topology->pitch().second;

// see https://github.com/cms-sw/cmssw/blob/CMSSW_8_1_X/RecoLocalTracker/SiStripRecHitConverter/src/StripCPE.cc
auto thickness = det.specificSurface().bounds().thickness();
auto drift = driftDirection(det) * thickness;
auto lvec = drift + LocalVector(0,0,-thickness);
p.coveredStrips = lvec.x() / pitch_x; // simplifies wrt Phase0 tracker because only rectangular modules

constexpr float o12 = 1./12;
p.localErr = LocalError( o12*pitch_x*pitch_x, 0, o12*pitch_y*pitch_y); // e2_xx, e2_xy, e2_yy
}
}
Expand Up @@ -88,6 +88,19 @@ class Phase2TrackerClusterizer : public edm::stream::EDProducer<> {
algo.clusterizeDetUnit(DSViter, clusters);
if (clusters.empty()) clusters.abort();

#ifdef VERIFY_PH2_TK_CLUS
if (!clusters.empty()) {
auto cp = clusters[0].column();
auto sp = clusters[0].firstStrip();
for (auto const & cl : clusters) {
if (cl.column()<cp) std::cout << "column not in order! " << std::endl;
if (cl.column()==cp && cl.firstStrip()<sp) std::cout << "strip not in order! " << std::endl;
cp = cl.column();
sp = cl.firstStrip();
}
}
#endif

#ifdef VERIFY_PH2_TK_CLUS
// Geometry
const GeomDetUnit* geomDetUnit(tkGeom->idToDetUnit(detId));
Expand Down
@@ -1,5 +1,7 @@
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140

# moving to the block. Will delete the PSet once transition is done
PixelTripletHLTGenerator = cms.PSet(
maxElement = cms.uint32(100000),
Expand All @@ -15,6 +17,12 @@
)
)

# do thy make any difference anywhere?
trackingPhase2PU140.toModify(PixelTripletHLTGenerator,
extraHitRPhitolerance = cms.double(0.016),
extraHitRZtolerance = cms.double(0.020)
)

import RecoPixelVertexing.PixelLowPtUtilities.LowPtClusterShapeSeedComparitor_cfi
PixelTripletHLTGeneratorWithFilter = PixelTripletHLTGenerator.clone()
PixelTripletHLTGeneratorWithFilter.SeedComparitorPSet = RecoPixelVertexing.PixelLowPtUtilities.LowPtClusterShapeSeedComparitor_cfi.LowPtClusterShapeSeedComparitor.clone()
Expand Down
Expand Up @@ -40,15 +40,16 @@
'BPix1+BPix2+BPix3+FPix1_pos','BPix1+BPix2+BPix3+FPix1_neg',
'BPix1+BPix2+FPix1_pos+FPix2_pos', 'BPix1+BPix2+FPix1_neg+FPix2_neg',
'BPix1+FPix1_pos+FPix2_pos+FPix3_pos', 'BPix1+FPix1_neg+FPix2_neg+FPix3_neg',
# removed as redundant in current geometry (here for documentation)
# 'FPix1_pos+FPix2_pos+FPix3_pos+FPix4_pos', 'FPix1_neg+FPix2_neg+FPix3_neg+FPix4_neg',
'FPix1_pos+FPix2_pos+FPix3_pos+FPix4_pos', 'FPix1_neg+FPix2_neg+FPix3_neg+FPix4_neg',
'FPix2_pos+FPix3_pos+FPix4_pos+FPix5_pos', 'FPix2_neg+FPix3_neg+FPix4_neg+FPix5_neg',
'FPix3_pos+FPix4_pos+FPix5_pos+FPix6_pos', 'FPix3_neg+FPix4_neg+FPix5_neg+FPix6_neg',
'FPix4_pos+FPix5_pos+FPix6_pos+FPix7_pos', 'FPix4_neg+FPix5_neg+FPix6_neg+FPix7_neg',
'FPix5_pos+FPix6_pos+FPix7_pos+FPix8_pos', 'FPix5_neg+FPix6_neg+FPix7_neg+FPix8_neg',
# removed as redunant and covering effectively only eta>4 (here for documentation, to be optimized after TDR)
# 'FPix5_pos+FPix6_pos+FPix7_pos+FPix9_pos', 'FPix5_neg+FPix6_neg+FPix7_neg+FPix9_neg',
# 'FPix6_pos+FPix7_pos+FPix8_pos+FPix9_pos', 'FPix6_neg+FPix7_neg+FPix8_neg+FPix9_neg'
# 'FPix6_pos+FPix7_pos+FPix8_pos+FPix9_pos', 'FPix6_neg+FPix7_neg+FPix8_neg+FPix9_neg',
# 'FPix8_pos+FPix9_pos+FPix10_pos+FPix11_pos', 'FPix8_neg+FPix9_neg+FPix10_neg+FPix11_neg',
# 'FPix11_pos'FPix9_pos+FPix10_pos+FPix12_pos', 'FPix9_neg+FPix10_neg+FPix11_neg+FPix12_neg'
]

# Needed to have pixelTracks to not to look like depending
Expand Down
25 changes: 10 additions & 15 deletions RecoTracker/IterativeTracking/python/DetachedQuadStep_cff.py
Expand Up @@ -30,8 +30,8 @@
from Configuration.Eras.Modifier_trackingPhase2PU140_cff import trackingPhase2PU140
trackingPhase2PU140.toReplaceWith(detachedQuadStepTrackingRegions, _globalTrackingRegionFromBeamSpot.clone(RegionPSet = dict(
ptMin = 0.45,
originRadius = 0.7,
nSigmaZ = 4.0
originRadius = 0.9,
nSigmaZ = 5.0
)))

# seeding
Expand Down Expand Up @@ -75,7 +75,6 @@

from Configuration.Eras.Modifier_trackingPhase1QuadProp_cff import trackingPhase1QuadProp
trackingPhase1QuadProp.toModify(detachedQuadStepHitDoublets, layerPairs = [0])
trackingPhase2PU140.toModify(detachedQuadStepHitDoublets, layerPairs = [0])
detachedQuadStepHitTriplets = _pixelTripletLargeTipEDProducer.clone(
doublets = "detachedQuadStepHitDoublets",
produceIntermediateHitTriplets = True,
Expand All @@ -100,7 +99,6 @@
fitFastCircleChi2Cut = True,
)
trackingPhase1QuadProp.toReplaceWith(detachedQuadStepHitQuadruplets, _detachedQuadStepHitQuadruplets_propagation)
trackingPhase2PU140.toReplaceWith(detachedQuadStepHitQuadruplets, _detachedQuadStepHitQuadruplets_propagation)


# QUALITY CUTS DURING TRACK BUILDING
Expand Down Expand Up @@ -135,7 +133,7 @@
clusterChargeCut = dict(refToPSet_ = 'SiStripClusterChargeCutTight'),
)
trackingPhase2PU140.toModify(detachedQuadStepChi2Est,
MaxChi2 = 16.0,
MaxChi2 = 12.0,
clusterChargeCut = dict(refToPSet_ = "SiStripClusterChargeCutNone")
)

Expand Down Expand Up @@ -163,9 +161,6 @@
fractionShared = cms.double(0.13),
allowSharedFirstHit = cms.bool(True)
)
trackingPhase2PU140.toModify(detachedQuadStepTrajectoryCleanerBySharedHits,
fractionShared = 0.09
)

import RecoTracker.CkfPattern.CkfTrackCandidates_cfi
detachedQuadStepTrackCandidates = RecoTracker.CkfPattern.CkfTrackCandidates_cfi.ckfTrackCandidates.clone(
Expand Down Expand Up @@ -269,15 +264,15 @@
RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.highpurityMTS.clone(
name = 'detachedQuadStepTrk',
preFilterName = 'detachedQuadStepTrkTight',
chi2n_par = 0.45,
chi2n_par = 0.5,
res_par = ( 0.003, 0.001 ),
minNumberLayers = 4,
maxNumberLostLayers = 0,
maxNumberLostLayers = 1,
minNumber3DLayers = 3,
d0_par1 = ( 0.8, 4.0 ),
dz_par1 = ( 0.8, 4.0 ),
d0_par2 = ( 0.8, 4.0 ),
dz_par2 = ( 0.8, 4.0 )
d0_par1 = ( 0.9, 4.0 ),
dz_par1 = ( 0.9, 4.0 ),
d0_par2 = ( 0.9, 4.0 ),
dz_par2 = ( 0.9, 4.0 )
)
] #end of vpset
) #end of clone
Expand Down Expand Up @@ -310,6 +305,6 @@
_DetachedQuadStep_Phase1Prop = DetachedQuadStep.copy()
_DetachedQuadStep_Phase1Prop.replace(detachedQuadStepHitDoublets, detachedQuadStepHitDoublets+detachedQuadStepHitTriplets)
trackingPhase1QuadProp.toReplaceWith(DetachedQuadStep, _DetachedQuadStep_Phase1Prop)
_DetachedQuadStep_Phase2PU140 = _DetachedQuadStep_Phase1Prop.copy()
_DetachedQuadStep_Phase2PU140 = DetachedQuadStep.copy()
_DetachedQuadStep_Phase2PU140.replace(detachedQuadStep, detachedQuadStepSelector+detachedQuadStep)
trackingPhase2PU140.toReplaceWith(DetachedQuadStep, _DetachedQuadStep_Phase2PU140)

0 comments on commit 6ce8de5

Please sign in to comment.