Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PFlow fix/improvement in the HF region for phase2 #28442

Merged
merged 33 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2237467
first attempt to produce PF blocks with tracks and HF clusters, then …
hatakeyamak Jul 4, 2019
2557e10
update
hatakeyamak Jul 8, 2019
593175c
Improve handling of PFBlocks for HF
hatakeyamak Jul 19, 2019
d50cff3
Further improve handling of PFBlocks for HF
hatakeyamak Jul 20, 2019
8cc3b6a
cleanup
hatakeyamak Sep 16, 2019
c9d4a47
Match track-HF. Excess HF gives HFHAD or HFEM candidates
hatakeyamak Nov 16, 2019
3efc28d
remove hack which is no longer necessary after propagator fix from Ia…
hatakeyamak Nov 16, 2019
8e81828
fix the HF surface location to be more precise
hatakeyamak Nov 18, 2019
95fb6d4
fix to propagator for HO which is important for propagation to HF
hatakeyamak Nov 18, 2019
6e4003d
Improve reco for PF candidates in HF. Use HfHad for main loop, look f…
hatakeyamak Nov 18, 2019
eacdbc7
fix issues from rebase
hatakeyamak Nov 19, 2019
479009b
Make some of HF parameters configurable. Run code-format.
hatakeyamak Nov 19, 2019
2555a42
activate track-HF links only for phase2 tracker
hatakeyamak Nov 20, 2019
366c152
Make HFEM candidates from excess first-HFEM-satellite
hatakeyamak Nov 20, 2019
18a1727
improve comments
hatakeyamak Nov 21, 2019
8c89b49
update nSigmaHFEM to 1
hatakeyamak Nov 21, 2019
fc37708
scram build code-checks
hatakeyamak Nov 21, 2019
ed14398
Handle PFBlocks with tracks in the HF region, which have only inactiv…
hatakeyamak Nov 22, 2019
fb4822e
get rid of the dead assignments pointed out by static analyzer
hatakeyamak Dec 2, 2019
16c8782
Cleaning up KDTree and linker following suggestions from Slava and Kevin
hatakeyamak Dec 2, 2019
2485ea4
Cleaning up PFProducer/PFAlgo following suggestions from Slava and Kevin
hatakeyamak Dec 2, 2019
13a2c4b
fix ecal and hcal energy assignments to pfcandidates in the HF region
hatakeyamak Dec 4, 2019
639aba3
Removing KDTreeLinkerTrackHF & TrackAndHFLinker, and use KDTreeLinker…
hatakeyamak Dec 4, 2019
67c0510
removing unnecessary lines
hatakeyamak Dec 4, 2019
c0b4cd0
logic bug fix
hatakeyamak Dec 5, 2019
028495a
Add new config parameters of PFBlockProducer to HLT config via custom…
hatakeyamak Dec 5, 2019
b9f559c
code-format
hatakeyamak Dec 5, 2019
a53683c
add new config params to hltParticleFlowBlockPPOnAA as well via custo…
hatakeyamak Dec 5, 2019
d1e6a74
Improve the string to enum conversion method.
hatakeyamak Dec 11, 2019
1981ab1
use std::array for string to enum conversion
hatakeyamak Dec 17, 2019
020db58
adopt trailing underscores in the data members. pass conf to the corr…
hatakeyamak Dec 17, 2019
b4d88a8
code-format
hatakeyamak Dec 17, 2019
b07fda1
remaining changes to adopt trailing underscores in the data members. …
hatakeyamak Dec 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ bool BaseParticlePropagator::propagate() {
solution = tminus < 0 ? tplus : tminus;
if (solution < 0.)
return false;
zProp = particle_.Z() + particle_.Pz() * solution;
success = 2;
} else {
success = 1;
Expand Down Expand Up @@ -390,7 +389,6 @@ bool BaseParticlePropagator::propagateToClosestApproach(double x0, double y0, bo
if (dist2 > dist1) {
particle_.setVertex(vertex1);
particle_.setMomentum(momentum1.X(), momentum1.Y(), momentum1.Z(), momentum1.E());
dist2 = dist1;
}

// Done
Expand Down Expand Up @@ -506,11 +504,10 @@ bool BaseParticlePropagator::propagateToHcalEntrance(bool first) {

bool BaseParticlePropagator::propagateToVFcalEntrance(bool first) {
//
// Propagation to VFCAL entrance
// TODO: include proper geometry
// Geometry taken from DAQ TDR Chapter 13
// Propagation to VFCAL (HF) entrance
// Geometry taken from xml: Geometry/CMSCommonData/data/cms.xml

setPropagationConditions(400.0, 1110.0, first);
setPropagationConditions(400.0, 1114.95, first);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a future development item, it would be even better to get these directly from the geometry instead of hardcoding the values

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although this is a number that is not supposed to change, I agree with @kpedro88 that this implementation is intrinsicattly weak, although its fix can be deferred to a second moment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. If we make this update, I want to update a few other hardcoded numbers, but some hardcoded numbers may not be directly extractable from geometry. It's not a trivial change, so I prefer to keep this separate, while fixing this known small inconsistency for now.

propDir = 0;
bool done = propagate();
propDir = 1;
Expand Down
29 changes: 27 additions & 2 deletions DataFormats/ParticleFlowReco/interface/PFTrajectoryPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,35 @@ namespace reco {
HOLayer = 8,
/// VFcal(HF) front face
VFcalEntrance = 9,

NLayers = 10
// Number of valid layers
NLayers = 10,
// Unknown
Unknown = -1
};

static std::map<std::string, LayerType> create_map() {
std::map<std::string, LayerType> m;
m["ClosestApproach"] = LayerType::ClosestApproach;
m["BeamPipeOrEndVertex"] = LayerType::BeamPipeOrEndVertex;
m["PS1"] = LayerType::PS1;
m["PS2"] = LayerType::PS2;
m["ECALEntrance"] = LayerType::ECALEntrance;
m["ECALShowerMax"] = LayerType::ECALShowerMax;
m["HCALEntrance"] = LayerType::HCALEntrance;
m["HCALExit"] = LayerType::HCALExit;
m["HOLayer"] = LayerType::HOLayer;
m["VFcalEntrance"] = LayerType::VFcalEntrance;
return m;
}
static LayerType layerTypeFromString(std::string layerTypeString) {
std::map<std::string, LayerType> layerTypeMap = create_map();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be preferable for a few reasons to define the map as a constant within this function:

const std::map<std::string, LayerType> layerTypeMap{
  {"ClosestApproach", LayerType::ClosestApproach},
  {"BeamPipeOrEndVertex", LayerType::BeamPipeOrEndVertex},
  {"PS1", LayerType::PS1},
  {"PS2", LayerType::PS2},
  {"ECALEntrance", LayerType::ECALEntrance},
  {"ECALShowerMax", LayerType::ECALShowerMax},
  {"HCALEntrance", LayerType::HCALEntrance},
  {"HCALExit", LayerType::HCALExit},
  {"HOLayer", LayerType::HOLayer},
  {"VFcalEntrance", LayerType::VFcalEntrance},
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a very expensive way to map a name of an enum to the enum (even with the pre-constructed std::map). Linear search over a static array would require less memory and likely be faster (see e.g.

TrackBase::TrackAlgorithm TrackBase::algoByName(const std::string &name) {
TrackAlgorithm size = algoSize;
int index = std::find(algoNames, algoNames + size, name) - algoNames;
if (index == size) {
return undefAlgorithm; // better this or throw() ?
}

for an example)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. This will be called only at the beginning of each job 1-3 times, and not for each event, so I don't think it's critical to make it less expensive, but let me think..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only used in job startup the std::map could be acceptable (assuming it gets destroyed after last use to not "hoard" memory). This leaves the main argument against to be "bad example for others".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. At the end, I just adopted your string to enum conversion method. I agree that it's nicer.

std::map<std::string, LayerType>::iterator it = layerTypeMap.find(layerTypeString);
if (it != layerTypeMap.end())
return it->second;
else
return LayerType::Unknown;
}

/// default constructor. Set variables at default dummy values
PFTrajectoryPoint();

Expand Down
43 changes: 42 additions & 1 deletion HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def synchronizeHCALHLTofflineRun3on2018data(process):
# this function bring back the Run3 menu to a Run2-2018 like meny, for testing in data 2018

#----------------------------------------------------------------------------------------------------------
# adapt threshold for HB - in 2018 only one depth
# adapt threshold for HB - in 2018 only one depth

for producer in producers_by_type(process, "PFClusterProducer"):
if producer.seedFinder.thresholdsByDetector[0].detector.value() == 'HCAL_BARREL1':
Expand Down Expand Up @@ -164,10 +164,51 @@ def customiseFor2017DtUnpacking(process):

return process

# for PFBlockProducer/Algo change to enable both track-HCAL and track-HF links
hltPFBlockLinkDefPrePhase2 = cms.VPSet(
cms.PSet( linkType = cms.string( "PS1:ECAL" ),
useKDTree = cms.bool( True ),
linkerName = cms.string( "PreshowerAndECALLinker" )
),
cms.PSet( linkType = cms.string( "PS2:ECAL" ),
useKDTree = cms.bool( True ),
linkerName = cms.string( "PreshowerAndECALLinker" )
),
cms.PSet( linkType = cms.string( "TRACK:ECAL" ),
useKDTree = cms.bool( True ),
linkerName = cms.string( "TrackAndECALLinker" )
),
cms.PSet( linkType = cms.string( "TRACK:HCAL" ),
useKDTree = cms.bool( True ),
linkerName = cms.string( "TrackAndHCALLinker" ),
trajectoryLayerEntrance = cms.string("HCALEntrance"), # added
trajectoryLayerExit = cms.string("HCALExit") # added
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, this is full copied replacement of linkDefinitions is too complex and should be reduced to just an insertion of the two lines (the new parameters) above

),
cms.PSet( linkType = cms.string( "ECAL:HCAL" ),
useKDTree = cms.bool( False ),
linkerName = cms.string( "ECALAndHCALLinker" )
),
cms.PSet( linkType = cms.string( "HFEM:HFHAD" ),
useKDTree = cms.bool( False ),
linkerName = cms.string( "HFEMAndHFHADLinker" )
)
)
def customiseFor28442(process):
if hasattr(process,'hltParticleFlowBlock'):
process.hltParticleFlowBlock.linkDefinitions = hltPFBlockLinkDefPrePhase2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this search for type PFBlockProducer and then in the linkDefinitions find the PSet with linkerName = cms.string( "TrackAndHCALLinker" ) and then just insert (conditionally, if not already present)

               trajectoryLayerEntrance = cms.string("HCALEntrance"), # added
               trajectoryLayerExit = cms.string("HCALExit") # added

?

Copy link
Contributor Author

@hatakeyamak hatakeyamak Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean, but syntax to do this wasn't obvious to me, and I think this is sort of temporary until new parameters go to confdb, so I left this as is for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the only actual change is to add two parameters in the PSet with link type TRACK:HCAL?
Everything else is supposed to be unchanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct.

if hasattr(process,'hltParticleFlowBlockForTaus'):
process.hltParticleFlowBlockForTaus.linkDefinitions = hltPFBlockLinkDefPrePhase2
if hasattr(process,'hltParticleFlowBlockReg'):
process.hltParticleFlowBlockReg.linkDefinitions = hltPFBlockLinkDefPrePhase2
if hasattr(process,'hltParticleFlowBlockPPOnAA'):
process.hltParticleFlowBlockPPOnAA.linkDefinitions = hltPFBlockLinkDefPrePhase2
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 = customiseFor28442(process)

return process
7 changes: 7 additions & 0 deletions RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class KDTreeLinkerBase {

void setFieldType(const reco::PFBlockElement::Type &fld) { _fieldType = fld; }

// set trajectory points, necessary for track-HCAL links
virtual void setTrajectoryPoints(const reco::PFTrajectoryPoint::LayerType trajectoryPointEntrance,
const reco::PFTrajectoryPoint::LayerType trajectoryPointExit){};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the use cases, I do not see a good justification to add this method at the base class level.
It seems more practical to me to use a more common pattern of passing configuration to the tool via a PSet.
I suggest to add a KDTreeLinkerBase(const edm::ParameterSet& conf) and add the appropriate logic to KDTreeLinkerTrackHcal(conf) constructor.

See more in comments for PFBlockAlgo.cc


const reco::PFBlockElement::Type &targetType() const { return _targetType; }

const reco::PFBlockElement::Type &fieldType() const { return _fieldType; }
Expand Down Expand Up @@ -81,6 +85,9 @@ class KDTreeLinkerBase {
// substracting (adding) 2Pi. This field define the threshold of this operation.
float phiOffset_ = 0.25;

// rechit with fraction this value will be ignored in KDTreeLinker
const float cutOffFrac = 1E-4;

// Debug boolean. Not used until now.
bool debug_ = false;
};
Expand Down
30 changes: 26 additions & 4 deletions RecoParticleFlow/PFProducer/interface/PFAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class PFAlgo {
/// constructor
PFAlgo(double nSigmaECAL,
double nSigmaHCAL,
double nSigmaHFEM,
double nSigmaHFHAD,
std::vector<double> resolHF_square,
PFEnergyCalibration& calibration,
PFEnergyCalibrationHF& thepfEnergyCalibrationHF,
const edm::ParameterSet& pset);
Expand Down Expand Up @@ -153,10 +156,12 @@ class PFAlgo {
reco::TrackRef& trackRef);

//Looks for a HF-associated element in the block and produces a PFCandidate from it with HF_EM and/or HF_HAD calibrations
void createCandidateHF(const reco::PFBlock& block,
const reco::PFBlockRef& blockref,
const edm::OwnVector<reco::PFBlockElement>& elements,
ElementIndices& inds);
void createCandidatesHF(const reco::PFBlock& block,
reco::PFBlock::LinkData& linkData,
const edm::OwnVector<reco::PFBlockElement>& elements,
std::vector<bool>& active,
const reco::PFBlockRef& blockref,
ElementIndices& inds);

void createCandidatesHCAL(const reco::PFBlock& block,
reco::PFBlock::LinkData& linkData,
Expand Down Expand Up @@ -213,6 +218,11 @@ class PFAlgo {

double nSigmaHCAL(double clusterEnergy, double clusterEta) const;

double hfEnergyResolution(double clusterEnergy) const;

double nSigmaHFEM(double clusterEnergy) const;
double nSigmaHFHAD(double clusterEnergy) const;

std::unique_ptr<reco::PFCandidateCollection> pfCandidates_;
// the post-HF-cleaned candidates
reco::PFCandidateCollection pfCleanedCandidates_;
Expand All @@ -237,6 +247,13 @@ class PFAlgo {
/// number of sigma to judge energy excess in HCAL
const double nSigmaHCAL_;

/// number of sigma to judge energy excess in HF
const double nSigmaHFEM_;
const double nSigmaHFHAD_;

// HF resolution
const std::vector<double> resolHF_square_;

PFEnergyCalibration& calibration_;
PFEnergyCalibrationHF& thepfEnergyCalibrationHF_;

Expand Down Expand Up @@ -312,6 +329,11 @@ class PFAlgo {
bool useVertices_ = false;

edm::Handle<reco::MuonCollection> muonHandle_;

// Named constants
const double nSigmaEConstHCAL = 100.;
const double nSigmaEConstHFEM = 100.;
const double nSigmaEConstHFHAD = 100.;
};

#endif
11 changes: 10 additions & 1 deletion RecoParticleFlow/PFProducer/plugins/PFProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include "TFile.h"

/**\class PFProducer
/**\class PFProducer
\brief Producer for particle flow reconstructed particles (PFCandidates)

This producer makes use of PFAlgo, the particle flow algorithm.
Expand Down Expand Up @@ -120,6 +120,9 @@ PFProducer::PFProducer(const edm::ParameterSet& iConfig)
iConfig.getParameter<std::vector<double>>("calibHF_b_EMHAD")),
pfAlgo_(iConfig.getParameter<double>("pf_nsigma_ECAL"),
iConfig.getParameter<double>("pf_nsigma_HCAL"),
iConfig.getParameter<double>("pf_nsigma_HFEM"),
iConfig.getParameter<double>("pf_nsigma_HFHAD"),
iConfig.getParameter<std::vector<double>>("resolHF_square"),
pfEnergyCalibration_,
pfEnergyCalibrationHF_,
iConfig) {
Expand Down Expand Up @@ -407,6 +410,8 @@ void PFProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions)
// number of sigmas for neutral energy detection
desc.add<double>("pf_nsigma_ECAL", 0.0);
desc.add<double>("pf_nsigma_HCAL", 1.0);
desc.add<double>("pf_nsigma_HFEM", 1.0);
desc.add<double>("pf_nsigma_HFHAD", 1.0);

// ECAL/HCAL PF cluster calibration : take it from global tag ?
desc.add<bool>("useCalibrationsFromDB", true);
Expand Down Expand Up @@ -448,5 +453,9 @@ void PFProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions)
desc.add<std::vector<double>>("calibHF_b_HADonly", {1., 1., 1., 1., 1., 1., 1., 1., 1., 1.});
desc.add<std::vector<double>>("calibHF_b_EMHAD", {1., 1., 1., 1., 1., 1., 1., 1., 1., 1.});

// resolution parameters for HF: EPJC 53(2008)139, doi:10.1140/epjc/s10052-007-0459-4
desc.add<std::vector<double>>("resolHF_square", {2.799 * 2.799, 0.114 * 0.114, 0.0 * 0.0})
->setComment("HF resolution - stochastic, constant, noise term squares");

descriptions.add("particleFlow", desc);
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void KDTreeLinkerPSEcal::insertFieldClusterElt(reco::PFBlockElement *ecalCluster
const reco::PFRecHitRef &rh = fraction[rhit].recHitRef();
double fract = fraction[rhit].fraction();

if ((rh.isNull()) || (fract < 1E-4))
if ((rh.isNull()) || (fract < cutOffFrac))
continue;

const reco::PFRecHit &rechit = *rh;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void KDTreeLinkerTrackEcal::insertFieldClusterElt(reco::PFBlockElement *ecalClus
const reco::PFRecHitRef &rh = fraction[rhit].recHitRef();
double fract = fraction[rhit].fraction();

if ((rh.isNull()) || (fract < 1E-4))
if ((rh.isNull()) || (fract < cutOffFrac))
continue;

const reco::PFRecHit &rechit = *rh;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class KDTreeLinkerTrackHcal : public KDTreeLinkerBase {
// Here we free all allocated structures.
void clear() override;

void setTrajectoryPoints(const reco::PFTrajectoryPoint::LayerType trajectoryLayerEntrance,
const reco::PFTrajectoryPoint::LayerType trajectoryLayerExit) override;

private:
// Data used by the KDTree algorithm : sets of Tracks and HCAL clusters.
BlockEltSet targetSet_;
Expand All @@ -50,6 +53,11 @@ class KDTreeLinkerTrackHcal : public KDTreeLinkerBase {

// KD trees
KDTreeLinkerAlgo<reco::PFRecHit const*> tree_;

// TrajectoryPoints
reco::PFTrajectoryPoint::LayerType _trajectoryLayerEntrance;
reco::PFTrajectoryPoint::LayerType _trajectoryLayerExit;
bool _checkExit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

};

// the text name is different so that we can easily
Expand All @@ -64,11 +72,26 @@ KDTreeLinkerTrackHcal::KDTreeLinkerTrackHcal() : KDTreeLinkerBase() {
KDTreeLinkerTrackHcal::~KDTreeLinkerTrackHcal() { clear(); }

void KDTreeLinkerTrackHcal::insertTargetElt(reco::PFBlockElement* track) {
if (track->trackRefPF()->extrapolatedPoint(reco::PFTrajectoryPoint::HCALEntrance).isValid()) {
if (track->trackRefPF()->extrapolatedPoint(_trajectoryLayerEntrance).isValid()) {
targetSet_.insert(track);
}
}

void KDTreeLinkerTrackHcal::setTrajectoryPoints(const reco::PFTrajectoryPoint::LayerType trajectoryLayerEntrance,
const reco::PFTrajectoryPoint::LayerType trajectoryLayerExit) {
_trajectoryLayerEntrance = trajectoryLayerEntrance;
_trajectoryLayerExit = trajectoryLayerExit;
// make sure the requested setting is supported
assert((_trajectoryLayerEntrance == reco::PFTrajectoryPoint::HCALEntrance &&
_trajectoryLayerExit == reco::PFTrajectoryPoint::HCALExit) ||
(_trajectoryLayerEntrance == reco::PFTrajectoryPoint::HCALEntrance &&
_trajectoryLayerExit == reco::PFTrajectoryPoint::Unknown) ||
(_trajectoryLayerEntrance == reco::PFTrajectoryPoint::VFcalEntrance &&
_trajectoryLayerExit == reco::PFTrajectoryPoint::Unknown));
// flag if exit layer should be checked or not
_checkExit = (_trajectoryLayerExit == reco::PFTrajectoryPoint::Unknown) ? false : true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just
_checkExit = _trajectoryLayerExit != reco::PFTrajectoryPoint::Unknown;

}

void KDTreeLinkerTrackHcal::insertFieldClusterElt(reco::PFBlockElement* hcalCluster) {
const reco::PFClusterRef& clusterref = hcalCluster->clusterRef();

Expand All @@ -85,7 +108,7 @@ void KDTreeLinkerTrackHcal::insertFieldClusterElt(reco::PFBlockElement* hcalClus
const reco::PFRecHitRef& rh = fraction[rhit].recHitRef();
double fract = fraction[rhit].fraction();

if ((rh.isNull()) || (fract < 1E-4))
if ((rh.isNull()) || (fract < cutOffFrac))
continue;

const reco::PFRecHit& rechit = *rh;
Expand Down Expand Up @@ -142,19 +165,24 @@ void KDTreeLinkerTrackHcal::searchLinks() {
for (BlockEltSet::iterator it = targetSet_.begin(); it != targetSet_.end(); it++) {
reco::PFRecTrackRef trackref = (*it)->trackRefPF();

const reco::PFTrajectoryPoint& atHCAL = trackref->extrapolatedPoint(reco::PFTrajectoryPoint::HCALEntrance);
const reco::PFTrajectoryPoint& atHCALExit = trackref->extrapolatedPoint(reco::PFTrajectoryPoint::HCALExit);
const reco::PFTrajectoryPoint& atHCAL = trackref->extrapolatedPoint(_trajectoryLayerEntrance);

// The track didn't reach hcal
if (!atHCAL.isValid())
continue;

double dHeta = atHCALExit.positionREP().eta() - atHCAL.positionREP().eta();
float dHphi = atHCALExit.positionREP().phi() - atHCAL.positionREP().phi();
if (dHphi > M_PI)
dHphi = dHphi - 2. * M_PI;
else if (dHphi < -M_PI)
dHphi = dHphi + 2. * M_PI;
// In case the exit point check is requested, check eta and phi differences between entrance and exit
double dHeta = 0.0;
float dHphi = 0.0;
if (_checkExit) {
const reco::PFTrajectoryPoint& atHCALExit = trackref->extrapolatedPoint(_trajectoryLayerExit);
dHeta = atHCALExit.positionREP().eta() - atHCAL.positionREP().eta();
dHphi = atHCALExit.positionREP().phi() - atHCAL.positionREP().phi();
if (dHphi > M_PI)
dHphi = dHphi - 2. * M_PI;
else if (dHphi < -M_PI)
dHphi = dHphi + 2. * M_PI;
} // _checkExit

float tracketa = atHCAL.positionREP().eta() + 0.1 * dHeta;
float trackphi = atHCAL.positionREP().phi() + 0.1 * dHphi;
Expand Down Expand Up @@ -217,7 +245,7 @@ void KDTreeLinkerTrackHcal::updatePFBlockEltWithLinks() {

for (BlockEltSet::iterator jt = it->second.begin(); jt != it->second.end(); ++jt) {
reco::PFRecTrackRef trackref = (*jt)->trackRefPF();
const reco::PFTrajectoryPoint& atHCAL = trackref->extrapolatedPoint(reco::PFTrajectoryPoint::HCALEntrance);
const reco::PFTrajectoryPoint& atHCAL = trackref->extrapolatedPoint(_trajectoryLayerEntrance);
double tracketa = atHCAL.positionREP().eta();
double trackphi = atHCAL.positionREP().phi();

Expand Down
Loading