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 all 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
9 changes: 7 additions & 2 deletions DataFormats/ParticleFlowReco/interface/PFTrajectoryPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ namespace reco {
HOLayer = 8,
/// VFcal(HF) front face
VFcalEntrance = 9,

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

static const std::array<std::string, NLayers> layerTypeNames;
static LayerType layerTypeByName(const std::string& name);

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

Expand Down
23 changes: 23 additions & 0 deletions DataFormats/ParticleFlowReco/src/PFTrajectoryPoint.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
#include "DataFormats/ParticleFlowReco/interface/PFTrajectoryPoint.h"
#include <ostream>
#include <algorithm>

using namespace reco;

// To be kept in synch with the enumerator definitions in PFTrajectoryPoint.h file
// Don't consider "Unknown" and "NLayers"
std::array<std::string, PFTrajectoryPoint::NLayers> const PFTrajectoryPoint::layerTypeNames{{"ClosestApproach",
"BeamPipeOrEndVertex",
"PS1",
"PS2",
"ECALEntrance",
"ECALShowerMax",
"HCALEntrance",
"HCALExit",
"HOLayer",
"VFcalEntrance"}};

PFTrajectoryPoint::PFTrajectoryPoint() : isTrackerLayer_(false), detId_(-1), layer_(-1) {}

PFTrajectoryPoint::PFTrajectoryPoint(int detId,
Expand All @@ -25,6 +39,15 @@ PFTrajectoryPoint::PFTrajectoryPoint(const PFTrajectoryPoint& other)

PFTrajectoryPoint::~PFTrajectoryPoint() {}

PFTrajectoryPoint::LayerType PFTrajectoryPoint::layerTypeByName(const std::string& name) {
auto it = std::find(layerTypeNames.begin(), layerTypeNames.end(), name);
if (it == layerTypeNames.end()) {
return Unknown; // better this or throw()?
}
int index = std::distance(layerTypeNames.begin(), it);
return LayerType(index);
}

bool PFTrajectoryPoint::operator==(const reco::PFTrajectoryPoint& other) const {
if (posxyz_ == other.posxyz_ && momentum_ == other.momentum_)
return true;
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: 6 additions & 1 deletion RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef KDTreeLinkerBase_h
#define KDTreeLinkerBase_h

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecHitFraction.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
Expand All @@ -17,6 +18,7 @@ using BlockElt2BlockEltMap = std::map<reco::PFBlockElement *, BlockEltSet>;

class KDTreeLinkerBase {
public:
KDTreeLinkerBase(const edm::ParameterSet &conf) {}
virtual ~KDTreeLinkerBase() {}

void setTargetType(const reco::PFBlockElement::Type &tgt) { _targetType = tgt; }
Expand Down Expand Up @@ -81,11 +83,14 @@ 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;
};

#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory<KDTreeLinkerBase *()> KDTreeLinkerFactory;
typedef edmplugin::PluginFactory<KDTreeLinkerBase *(const edm::ParameterSet &)> KDTreeLinkerFactory;

#endif /* !KDTreeLinkerBase_h */
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 @@ -9,7 +9,7 @@
// It is used in PFBlockAlgo.cc in the function links().
class KDTreeLinkerPSEcal : public KDTreeLinkerBase {
public:
KDTreeLinkerPSEcal();
KDTreeLinkerPSEcal(const edm::ParameterSet &conf);
~KDTreeLinkerPSEcal() override;

// With this method, we create the list of psCluster that we want to link.
Expand Down Expand Up @@ -70,8 +70,8 @@ class KDTreeLinkerPSEcal : public KDTreeLinkerBase {
// construct it when calling the factory
DEFINE_EDM_PLUGIN(KDTreeLinkerFactory, KDTreeLinkerPSEcal, "KDTreePreshowerAndECALLinker");

KDTreeLinkerPSEcal::KDTreeLinkerPSEcal()
: KDTreeLinkerBase(), resPSpitch_(0.19), resPSlength_(6.1), ps1ToEcal_(1.072), ps2ToEcal_(1.057) {}
KDTreeLinkerPSEcal::KDTreeLinkerPSEcal(const edm::ParameterSet &conf)
: KDTreeLinkerBase(conf), resPSpitch_(0.19), resPSlength_(6.1), ps1ToEcal_(1.072), ps2ToEcal_(1.057) {}

KDTreeLinkerPSEcal::~KDTreeLinkerPSEcal() { clear(); }

Expand Down 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 @@ -9,7 +9,7 @@
// It is used in PFBlockAlgo.cc in the function links().
class KDTreeLinkerTrackEcal : public KDTreeLinkerBase {
public:
KDTreeLinkerTrackEcal();
KDTreeLinkerTrackEcal(const edm::ParameterSet &conf);
~KDTreeLinkerTrackEcal() override;

// With this method, we create the list of psCluster that we want to link.
Expand Down Expand Up @@ -58,7 +58,7 @@ class KDTreeLinkerTrackEcal : public KDTreeLinkerBase {
// construct it when calling the factory
DEFINE_EDM_PLUGIN(KDTreeLinkerFactory, KDTreeLinkerTrackEcal, "KDTreeTrackAndECALLinker");

KDTreeLinkerTrackEcal::KDTreeLinkerTrackEcal() : KDTreeLinkerBase() {}
KDTreeLinkerTrackEcal::KDTreeLinkerTrackEcal(const edm::ParameterSet &conf) : KDTreeLinkerBase(conf) {}

KDTreeLinkerTrackEcal::~KDTreeLinkerTrackEcal() { clear(); }

Expand All @@ -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
Loading