Skip to content

Commit

Permalink
Migrate code to use MultipleScatteringParametrisationMaker
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Sep 22, 2021
1 parent 292d13b commit 7cf94fc
Show file tree
Hide file tree
Showing 19 changed files with 165 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@
tag = cms.string("")
)
)

# Multiple scattering parametrisation
from RecoTracker.TkMSParametrization.multipleScatteringParametrisationMakerESProducer_cfi import *
6 changes: 6 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,18 @@ def customiseFor35315(process):

return process

# MultipleScatteringParametrisationMakerESProducer
def customiseFor35269(process):
process.load("RecoTracker.TkMSParametrization.multipleScatteringParametrisationMakerESProducer_cfi")
return process

# CMSSW version specific customizations
def customizeHLTforCMSSW(process, menuType="GRun"):

# add call to action function in proper order: newest last!
# process = customiseFor12718(process)

process = customiseFor35315(process)
process = customiseFor35269(process)

return process
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@

#include "RecoPixelVertexing/PixelLowPtUtilities/interface/TripletFilter.h"

class IdealMagneticFieldRecord;
class MultipleScatteringParametrisationMaker;
class TrackerMultipleScatteringRecord;
class SiPixelClusterShapeCache;
class TrackerGeometry;
class TransientTrackingRecHitBuilder;
class TransientRecHitRecord;
class TripletFilter;
class SiPixelClusterShapeCache;

#include <vector>

Expand All @@ -48,6 +53,9 @@ class PixelTripletLowPtGenerator : public HitTripletGeneratorFromPairAndLayers {
private:
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> m_geomToken;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_topoToken;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> m_magfieldToken;
edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> m_ttrhBuilderToken;
edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> m_msmakerToken;

void getTracker(const edm::EventSetup& es);
GlobalPoint getGlobalPosition(const TrackingRecHit* recHit);
Expand All @@ -60,7 +68,6 @@ class PixelTripletLowPtGenerator : public HitTripletGeneratorFromPairAndLayers {
double rzTolerance;
double maxAngleRatio;

std::string builderName;
bool checkMultipleScattering;
bool checkClusterShape;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class DetLayer;
class OrderedHitPair;
class TrackingRecHit;

class MagneticField;
class TransientTrackingRecHitBuilder;
class MultipleScatteringParametrisationMaker;

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
Expand All @@ -38,10 +40,10 @@ class ThirdHitPrediction {
ThirdHitPrediction(const TrackingRegion& region,
GlobalPoint inner,
GlobalPoint outer,
const edm::EventSetup& es,
const MagneticField& magfield,
const TransientTrackingRecHitBuilder& ttrhBuilder,
double nSigMultipleScattering,
double maxAngleRatio,
std::string builderName);
double maxAngleRatio);
~ThirdHitPrediction();

void getRanges(const DetLayer* layer, float phi[], float rz[]);
Expand All @@ -50,7 +52,7 @@ class ThirdHitPrediction {
bool isCompatibleWithMultipleScattering(GlobalPoint g3,
const std::vector<const TrackingRecHit*>& h,
std::vector<GlobalVector>& localDirs,
const edm::EventSetup& es);
const MultipleScatteringParametrisationMaker& msmaker);

private:
void initLayer(const DetLayer* layer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
#include "RecoTracker/TkMSParametrization/interface/PixelRecoPointRZ.h"
#include "RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/SiPixelCluster/interface/SiPixelClusterShapeCache.h"

#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"
#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h"

#undef Debug

using namespace std;
Expand All @@ -21,6 +25,9 @@ PixelTripletLowPtGenerator::PixelTripletLowPtGenerator(const edm::ParameterSet&
: HitTripletGeneratorFromPairAndLayers(), // no theMaxElement used in this class
m_geomToken(iC.esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
m_topoToken(iC.esConsumes<TrackerTopology, TrackerTopologyRcd>()),
m_magfieldToken(iC.esConsumes()),
m_ttrhBuilderToken(iC.esConsumes(edm::ESInputTag("", cfg.getParameter<string>("TTRHBuilder")))),
m_msmakerToken(iC.esConsumes()),
theTracker(nullptr),
theClusterShapeCacheToken(
iC.consumes<SiPixelClusterShapeCache>(cfg.getParameter<edm::InputTag>("clusterShapeCacheSrc"))) {
Expand All @@ -29,7 +36,6 @@ PixelTripletLowPtGenerator::PixelTripletLowPtGenerator(const edm::ParameterSet&
checkClusterShape = cfg.getParameter<bool>("checkClusterShape");
rzTolerance = cfg.getParameter<double>("rzTolerance");
maxAngleRatio = cfg.getParameter<double>("maxAngleRatio");
builderName = cfg.getParameter<string>("TTRHBuilder");
}

/*****************************************************************************/
Expand Down Expand Up @@ -65,6 +71,9 @@ void PixelTripletLowPtGenerator::hitTriplets(const TrackingRegion& region,
const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers) {
//Retrieve tracker topology from geometry
const TrackerTopology* tTopo = &es.getData(m_topoToken);
const auto& magfield = es.getData(m_magfieldToken);
const auto& ttrhBuilder = es.getData(m_ttrhBuilderToken);
const auto& msmaker = es.getData(m_msmakerToken);

edm::Handle<SiPixelClusterShapeCache> clusterShapeCache;
ev.getByToken(theClusterShapeCacheToken, clusterShapeCache);
Expand Down Expand Up @@ -105,7 +114,7 @@ void PixelTripletLowPtGenerator::hitTriplets(const TrackingRegion& region,

// Initialize helix prediction
ThirdHitPrediction thePrediction(
region, points[0], points[1], es, nSigMultipleScattering, maxAngleRatio, builderName);
region, points[0], points[1], magfield, ttrhBuilder, nSigMultipleScattering, maxAngleRatio);

// Look at all layers
for (int il = 0; il < size; il++) {
Expand Down Expand Up @@ -138,7 +147,7 @@ void PixelTripletLowPtGenerator::hitTriplets(const TrackingRegion& region,

// Check if third hit is compatible with multiple scattering
vector<GlobalVector> globalDirs;
if (thePrediction.isCompatibleWithMultipleScattering(points[2], recHits, globalDirs, es) == false) {
if (thePrediction.isCompatibleWithMultipleScattering(points[2], recHits, globalDirs, msmaker) == false) {
#ifdef Debug
cerr << " not compatible: multiple scattering" << endl;
#endif
Expand Down
21 changes: 8 additions & 13 deletions RecoPixelVertexing/PixelLowPtUtilities/src/ThirdHitPrediction.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "RecoPixelVertexing/PixelLowPtUtilities/interface/ThirdHitPrediction.h"
#include "RecoPixelVertexing/PixelTrackFitting/interface/CircleFromThreePoints.h"
#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"
#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisation.h"
#include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
#include "TrackingTools/DetLayers/interface/DetLayer.h"
Expand All @@ -18,19 +18,14 @@ using namespace std;
ThirdHitPrediction::ThirdHitPrediction(const TrackingRegion& region,
GlobalPoint inner,
GlobalPoint outer,
const edm::EventSetup& es,
const MagneticField& magfield,
const TransientTrackingRecHitBuilder& ttrhBuilder,
double nSigMultipleScattering,
double maxAngleRatio,
string builderName) {
double maxAngleRatio) {
using namespace edm;
ESHandle<MagneticField> magfield;
es.get<IdealMagneticFieldRecord>().get(magfield);
theTTRecHitBuilder = &ttrhBuilder;

edm::ESHandle<TransientTrackingRecHitBuilder> ttrhbESH;
es.get<TransientRecHitRecord>().get(builderName, ttrhbESH);
theTTRecHitBuilder = ttrhbESH.product();

Bz = fabs(magfield->inInverseGeV(GlobalPoint(0, 0, 0)).z());
Bz = fabs(magfield.inInverseGeV(GlobalPoint(0, 0, 0)).z());

c0 = Global2DVector(region.origin().x(), region.origin().y());

Expand Down Expand Up @@ -345,7 +340,7 @@ void ThirdHitPrediction::getRanges(float rz3, float phi[], float rz[]) { calcula
bool ThirdHitPrediction::isCompatibleWithMultipleScattering(GlobalPoint g3,
const vector<const TrackingRecHit*>& h,
vector<GlobalVector>& globalDirs,
const edm::EventSetup& es) {
const MultipleScatteringParametrisationMaker& msmaker) {
Global2DVector p1(g1.x(), g1.y());
Global2DVector p2(g2.x(), g2.y());
Global2DVector p3(g3.x(), g3.y());
Expand Down Expand Up @@ -383,7 +378,7 @@ bool ThirdHitPrediction::isCompatibleWithMultipleScattering(GlobalPoint g3,
float m_pi = 0.13957018;
float beta = p / sqrt(sqr(p) + sqr(m_pi));

MultipleScatteringParametrisation msp(theLayer, es);
MultipleScatteringParametrisation msp = msmaker.parametrisation(theLayer);
PixelRecoPointRZ rz2(g2.perp(), g2.z());

float sigma_z = msp(pt, cotTheta, rz2) / beta;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#include "RecoPixelVertexing/PixelTriplets/plugins/PixelTripletHLTGenerator.h"
#include "RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include "ThirdHitPredictionFromInvParabola.h"
#include "RecoPixelVertexing/PixelTriplets/interface/ThirdHitRZPrediction.h"
#include "RecoTracker/TkMSParametrization/interface/PixelRecoUtilities.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "ThirdHitCorrection.h"
#include "RecoTracker/TkHitPairs/interface/RecHitsSortedInPhi.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
Expand All @@ -23,8 +21,6 @@

#include "DataFormats/Math/interface/normalizedPhi.h"

#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"

#include <cstdio>
#include <iostream>

Expand All @@ -35,6 +31,7 @@ using namespace std;

PixelTripletHLTGenerator::PixelTripletHLTGenerator(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC)
: HitTripletGeneratorFromPairAndLayers(cfg),
fieldToken_(iC.esConsumes()),
useFixedPreFiltering(cfg.getParameter<bool>("useFixedPreFiltering")),
extraHitRZtolerance(cfg.getParameter<double>("extraHitRZtolerance")),
extraHitRPhitolerance(cfg.getParameter<double>("extraHitRPhitolerance")),
Expand All @@ -46,6 +43,9 @@ PixelTripletHLTGenerator::PixelTripletHLTGenerator(const edm::ParameterSet& cfg,
if (comparitorName != "none") {
theComparitor = SeedComparitorFactory::get()->create(comparitorName, comparitorPSet, iC);
}
if (useMScat) {
msmakerToken_ = iC.esConsumes();
}
}

PixelTripletHLTGenerator::~PixelTripletHLTGenerator() {}
Expand Down Expand Up @@ -139,9 +139,11 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region,
const float maxphi = M_PI + maxDelphi, minphi = -maxphi; // increase to cater for any range
const float safePhi = M_PI - maxDelphi; // sideband

edm::ESHandle<MagneticField> hfield;
es.get<IdealMagneticFieldRecord>().get(hfield);
const auto& field = *hfield;
const auto& field = es.getData(fieldToken_);
const MultipleScatteringParametrisationMaker* msmaker = nullptr;
if (useMScat) {
msmaker = &es.getData(msmakerToken_);
}

// fill the prediction vector
for (int il = 0; il < nThirdLayers; ++il) {
Expand All @@ -150,13 +152,14 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region,
pred.initLayer(thirdLayerDetLayer[il]);
pred.initTolerance(extraHitRZtolerance);

corrections[il].init(es,
region.ptMin(),
corrections[il].init(region.ptMin(),
*doublets.detLayer(HitDoublets::inner),
*doublets.detLayer(HitDoublets::outer),
*thirdLayerDetLayer[il],
useMScat,
useBend);
msmaker,
useBend,
&field);

layerTree.clear();
float minv = 999999.0f, maxv = -minv; // Initialise to extreme values in case no hits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
#include "CombinedHitTripletGenerator.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "RecoPixelVertexing/PixelTriplets/interface/HitTripletGeneratorFromPairAndLayers.h"
#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h"
#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"

#include <utility>
#include <vector>
Expand Down Expand Up @@ -64,6 +67,8 @@ class PixelTripletHLTGenerator : public HitTripletGeneratorFromPairAndLayers {
std::vector<int>* tripletLastLayerIndex);

private:
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> fieldToken_;
edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> msmakerToken_;
const bool useFixedPreFiltering;
const float extraHitRZtolerance;
const float extraHitRPhitolerance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "RecoPixelVertexing/PixelTriplets/plugins/PixelTripletLargeTipGenerator.h"
#include "RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "RecoPixelVertexing/PixelTriplets/interface/ThirdHitPredictionFromCircle.h"
#include "RecoPixelVertexing/PixelTriplets/interface/ThirdHitRZPrediction.h"
Expand All @@ -15,8 +16,6 @@
#include "MatchedHitRZCorrectionFromBending.h"
#include "CommonTools/RecoAlgos/interface/KDTreeLinkerAlgo.h"

#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"

#include <algorithm>
#include <iostream>
#include <vector>
Expand Down Expand Up @@ -53,7 +52,12 @@ PixelTripletLargeTipGenerator::PixelTripletLargeTipGenerator(const edm::Paramete
useMScat(cfg.getParameter<bool>("useMultScattering")),
useBend(cfg.getParameter<bool>("useBending")),
dphi(useFixedPreFiltering ? cfg.getParameter<double>("phiPreFiltering") : 0),
trackerTopologyESToken_(iC.esConsumes()) {}
trackerTopologyESToken_(iC.esConsumes()),
fieldESToken_(iC.esConsumes()) {
if (useMScat) {
msmakerESToken_ = iC.esConsumes();
}
}

PixelTripletLargeTipGenerator::~PixelTripletLargeTipGenerator() {}

Expand Down Expand Up @@ -133,10 +137,11 @@ void PixelTripletLargeTipGenerator::hitTriplets(const TrackingRegion& region,
const int nThirdLayers,
std::vector<int>* tripletLastLayerIndex) {
const TrackerTopology* tTopo = &es.getData(trackerTopologyESToken_);

edm::ESHandle<MagneticField> hfield;
es.get<IdealMagneticFieldRecord>().get(hfield);
const auto& field = *hfield;
const auto& field = es.getData(fieldESToken_);
const MultipleScatteringParametrisationMaker* msmaker = nullptr;
if (useMScat) {
msmaker = &es.getData(msmakerESToken_);
}

auto outSeq = doublets.detLayer(HitDoublets::outer)->seqNum();

Expand Down Expand Up @@ -166,13 +171,14 @@ void PixelTripletLargeTipGenerator::hitTriplets(const TrackingRegion& region,
predRZ.helix1.initTolerance(extraHitRZtolerance);
predRZ.helix2.initTolerance(extraHitRZtolerance);
predRZ.rzPositionFixup = MatchedHitRZCorrectionFromBending(layer, tTopo);
predRZ.correction.init(es,
region.ptMin(),
predRZ.correction.init(region.ptMin(),
*doublets.detLayer(HitDoublets::inner),
*doublets.detLayer(HitDoublets::outer),
*thirdLayerDetLayer[il],
useMScat,
false);
msmaker,
false,
nullptr);

layerTree.clear();
float minv = 999999.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "RecoPixelVertexing/PixelTriplets/interface/HitTripletGeneratorFromPairAndLayers.h"
#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h"
#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"

#include <utility>
#include <vector>
Expand Down Expand Up @@ -72,5 +75,7 @@ class PixelTripletLargeTipGenerator : public HitTripletGeneratorFromPairAndLayer
const float dphi;

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyESToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> fieldESToken_;
edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> msmakerESToken_;
};
#endif
Loading

0 comments on commit 7cf94fc

Please sign in to comment.