-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Changes from 28 commits
2237467
2557e10
593175c
d50cff3
8cc3b6a
c9d4a47
3efc28d
8e81828
95fb6d4
6e4003d
eacdbc7
479009b
2555a42
366c152
18a1727
8c89b49
fc37708
ed14398
fb4822e
16c8782
2485ea4
13a2c4b
639aba3
67c0510
c0b4cd0
028495a
b9f559c
a53683c
d1e6a74
1981ab1
020db58
b4d88a8
b07fda1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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(); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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},
}; There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 cmssw/DataFormats/TrackReco/src/TrackBase.cc Lines 137 to 142 in 431e2fd
for an example) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If only used in job startup the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||||||||||||||
|
||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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': | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this search for type trajectoryLayerEntrance = cms.string("HCALEntrance"), # added
trajectoryLayerExit = cms.string("HCALExit") # added ? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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){}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. See more in comments for PFBlockAlgo.cc |
||
|
||
const reco::PFBlockElement::Type &targetType() const { return _targetType; } | ||
|
||
const reco::PFBlockElement::Type &fieldType() const { return _fieldType; } | ||
|
@@ -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; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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_; | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use a trailing underscore http://cms-sw.github.io/cms_coding_rules.html#2--naming-rules-1 |
||
}; | ||
|
||
// the text name is different so that we can easily | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just |
||
} | ||
|
||
void KDTreeLinkerTrackHcal::insertFieldClusterElt(reco::PFBlockElement* hcalCluster) { | ||
const reco::PFClusterRef& clusterref = hcalCluster->clusterRef(); | ||
|
||
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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(); | ||
|
||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.