CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
PFTICLProducer Class Reference
Inheritance diagram for PFTICLProducer:
edm::stream::EDProducer<>

Public Member Functions

 PFTICLProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~PFTICLProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

const bool energy_from_regression_
 
const edm::EDGetTokenT< reco::MuonCollectionmuons_
 
std::unique_ptr< PFMuonAlgopfmu_
 
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
 
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
 
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
 
const edm::EDGetTokenT< edm::View< TICLCandidate > > ticl_candidates_
 
const float timingQualityThreshold_
 
const bool useMTDTiming_
 
const bool useTimingAverage_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 18 of file PFTICLProducer.cc.

Constructor & Destructor Documentation

◆ PFTICLProducer()

PFTICLProducer::PFTICLProducer ( const edm::ParameterSet conf)

Definition at line 43 of file PFTICLProducer.cc.

44  : useMTDTiming_(conf.getParameter<bool>("useMTDTiming")),
45  useTimingAverage_(conf.getParameter<bool>("useTimingAverage")),
46  timingQualityThreshold_(conf.getParameter<double>("timingQualityThreshold")),
47  energy_from_regression_(conf.getParameter<bool>("energyFromRegression")),
48  ticl_candidates_(consumes<edm::View<TICLCandidate>>(conf.getParameter<edm::InputTag>("ticlCandidateSrc"))),
49  srcTrackTime_(consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeValueMap"))),
50  srcTrackTimeError_(consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeErrorMap"))),
51  srcTrackTimeQuality_(consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeQualityMap"))),
52  muons_(consumes<reco::MuonCollection>(conf.getParameter<edm::InputTag>("muonSrc"))),
53  pfmu_(std::make_unique<PFMuonAlgo>(conf.getParameterSet("pfMuonAlgoParameters"),
54  false)) { // postMuonCleaning = false
55  produces<reco::PFCandidateCollection>();
56 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const bool energy_from_regression_
const bool useTimingAverage_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
ParameterSet const & getParameterSet(std::string const &) const
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
const edm::EDGetTokenT< edm::View< TICLCandidate > > ticl_candidates_
std::unique_ptr< PFMuonAlgo > pfmu_
const bool useMTDTiming_
const float timingQualityThreshold_
const edm::EDGetTokenT< reco::MuonCollection > muons_

◆ ~PFTICLProducer()

PFTICLProducer::~PFTICLProducer ( )
inlineoverride

Definition at line 21 of file PFTICLProducer.cc.

21 {}

Member Function Documentation

◆ fillDescriptions()

void PFTICLProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 58 of file PFTICLProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, PFMuonAlgo::fillPSetDescription(), and ProducerED_cfi::InputTag.

58  {
60  desc.add<edm::InputTag>("ticlCandidateSrc", edm::InputTag("ticlTrackstersMerge"));
61  desc.add<edm::InputTag>("trackTimeValueMap", edm::InputTag("tofPID:t0"));
62  desc.add<edm::InputTag>("trackTimeErrorMap", edm::InputTag("tofPID:sigmat0"));
63  desc.add<edm::InputTag>("trackTimeQualityMap", edm::InputTag("mtdTrackQualityMVA:mtdQualMVA"));
64  desc.add<bool>("energyFromRegression", true);
65  desc.add<double>("timingQualityThreshold", 0.5);
66  desc.add<bool>("useMTDTiming", true);
67  desc.add<bool>("useTimingAverage", false);
68  // For PFMuonAlgo
69  desc.add<edm::InputTag>("muonSrc", edm::InputTag("muons1stStep"));
70  edm::ParameterSetDescription psd_PFMuonAlgo;
71  PFMuonAlgo::fillPSetDescription(psd_PFMuonAlgo);
72  desc.add<edm::ParameterSetDescription>("pfMuonAlgoParameters", psd_PFMuonAlgo);
73  //
74  descriptions.add("pfTICLProducer", desc);
75 }
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
Definition: PFMuonAlgo.cc:1043
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void PFTICLProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 77 of file PFTICLProducer.cc.

References funct::abs(), HLT_2023v12_cff::candidates, ALCARECOTkAlJpsiMuMu_cff::charge, reco::PFCandidate::e, energy_from_regression_, f, reco::PFCandidate::gamma, edm::Event::getByToken(), edm::Event::getHandle(), reco::PFCandidate::h, reco::PFCandidate::h0, createfilelist::int, SiStripPI::max, eostools::move(), reco::PFCandidate::mu, PFMuonAlgo::muAssocToTrack(), PDWG_BPHSkim_cff::muons, muons_, pfmu_, conifer::pow(), edm::Event::productGetter(), edm::Event::put(), mathSSE::sqrt(), srcTrackTime_, srcTrackTimeError_, srcTrackTimeQuality_, submitPVValidationJobs::t, ticl_candidates_, hcalRecHitTable_cff::time, timingQualityThreshold_, useMTDTiming_, useTimingAverage_, and reco::PFCandidate::X.

77  {
78  //get TICLCandidates
80  evt.getByToken(ticl_candidates_, ticl_cand_h);
81  const auto ticl_candidates = *ticl_cand_h;
82  edm::Handle<edm::ValueMap<float>> trackTimeH, trackTimeErrH, trackTimeQualH;
83  evt.getByToken(srcTrackTime_, trackTimeH);
84  evt.getByToken(srcTrackTimeError_, trackTimeErrH);
85  evt.getByToken(srcTrackTimeQuality_, trackTimeQualH);
86  const auto muonH = evt.getHandle(muons_);
87  const auto& muons = *muonH;
88 
89  auto candidates = std::make_unique<reco::PFCandidateCollection>();
90 
91  for (const auto& ticl_cand : ticl_candidates) {
92  const auto abs_pdg_id = std::abs(ticl_cand.pdgId());
93  const auto charge = ticl_cand.charge();
94  const auto& four_mom = ticl_cand.p4();
95  float total_raw_energy = 0.f;
96  float total_em_raw_energy = 0.f;
97  for (const auto& t : ticl_cand.tracksters()) {
98  total_raw_energy += t->raw_energy();
99  total_em_raw_energy += t->raw_em_energy();
100  }
101  float ecal_energy_fraction = total_em_raw_energy / total_raw_energy;
102  float ecal_energy = energy_from_regression_ ? ticl_cand.p4().energy() * ecal_energy_fraction
103  : ticl_cand.rawEnergy() * ecal_energy_fraction;
104  float hcal_energy =
105  energy_from_regression_ ? ticl_cand.p4().energy() - ecal_energy : ticl_cand.rawEnergy() - ecal_energy;
106  // fix for floating point rounding could go slightly below 0
107  hcal_energy = std::max(0.f, hcal_energy);
109  switch (abs_pdg_id) {
110  case 11:
111  part_type = reco::PFCandidate::e;
112  break;
113  case 13:
114  part_type = reco::PFCandidate::mu;
115  break;
116  case 22:
117  part_type = reco::PFCandidate::gamma;
118  break;
119  case 130:
120  part_type = reco::PFCandidate::h0;
121  break;
122  case 211:
123  part_type = reco::PFCandidate::h;
124  break;
125  // default also handles neutral pions (111) for the time being (not yet foreseen in PFCandidate)
126  default:
127  part_type = reco::PFCandidate::X;
128  }
129 
130  candidates->emplace_back(charge, four_mom, part_type);
131 
132  auto& candidate = candidates->back();
133  candidate.setEcalEnergy(ecal_energy, ecal_energy);
134  candidate.setHcalEnergy(hcal_energy, hcal_energy);
135  if (candidate.charge()) { // otherwise PFCandidate throws
136  // Construct edm::Ref from edm::Ptr. As of now, assumes type to be reco::Track. To be extended (either via
137  // dynamic type checking or configuration) if additional track types are needed.
138  reco::TrackRef trackref(ticl_cand.trackPtr().id(), int(ticl_cand.trackPtr().key()), &evt.productGetter());
139  candidate.setTrackRef(trackref);
140  // Utilize PFMuonAlgo
141  const int muId = PFMuonAlgo::muAssocToTrack(trackref, muons);
142  if (muId != -1) {
143  const reco::MuonRef muonref = reco::MuonRef(muonH, muId);
144  const bool allowLoose = (part_type == reco::PFCandidate::mu);
145  // Redefine pfmuon candidate kinematics and add muonref
146  pfmu_->reconstructMuon(candidate, muonref, allowLoose);
147  }
148  }
149 
150  // HGCAL timing as default values
151  auto time = ticl_cand.time();
152  auto timeE = ticl_cand.timeError();
153 
154  if (useMTDTiming_ and candidate.charge()) {
155  // Ignore HGCAL timing until it will be TOF corrected
156  time = -99.;
157  timeE = -1.;
158  // Check MTD timing availability
159  const bool assocQuality = (*trackTimeQualH)[candidate.trackRef()] > timingQualityThreshold_;
160  if (assocQuality) {
161  const auto timeHGC = time;
162  const auto timeEHGC = timeE;
163  const auto timeMTD = (*trackTimeH)[candidate.trackRef()];
164  const auto timeEMTD = (*trackTimeErrH)[candidate.trackRef()];
165 
166  if (useTimingAverage_ && (timeEMTD > 0 && timeEHGC > 0)) {
167  // Compute weighted average between HGCAL and MTD timing
168  const auto invTimeESqHGC = pow(timeEHGC, -2);
169  const auto invTimeESqMTD = pow(timeEMTD, -2);
170  timeE = (invTimeESqHGC * invTimeESqMTD) / (invTimeESqHGC + invTimeESqMTD);
171  time = (timeHGC * invTimeESqHGC + timeMTD * invTimeESqMTD) * timeE;
172  timeE = sqrt(timeE);
173  } else if (timeEMTD > 0) { // Ignore HGCal timing until it will be TOF corrected
174  time = timeMTD;
175  timeE = timeEMTD;
176  }
177  }
178  }
179  candidate.setTime(time, timeE);
180  }
181 
182  evt.put(std::move(candidates));
183 }
static int muAssocToTrack(const reco::TrackRef &trackref, const reco::MuonCollection &muons)
Definition: PFMuonAlgo.cc:479
const bool energy_from_regression_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
ParticleType
particle types
Definition: PFCandidate.h:44
const bool useTimingAverage_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
constexpr int pow(int x)
Definition: conifer.h:24
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:536
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
EDProductGetter const & productGetter() const
Definition: Event.cc:106
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
const edm::EDGetTokenT< edm::View< TICLCandidate > > ticl_candidates_
T sqrt(T t)
Definition: SSEVec.h:19
std::unique_ptr< PFMuonAlgo > pfmu_
const bool useMTDTiming_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
Definition: MuonFwd.h:13
const float timingQualityThreshold_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:560
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< reco::MuonCollection > muons_

Member Data Documentation

◆ energy_from_regression_

const bool PFTICLProducer::energy_from_regression_
private

Definition at line 32 of file PFTICLProducer.cc.

Referenced by produce().

◆ muons_

const edm::EDGetTokenT<reco::MuonCollection> PFTICLProducer::muons_
private

Definition at line 36 of file PFTICLProducer.cc.

Referenced by produce().

◆ pfmu_

std::unique_ptr<PFMuonAlgo> PFTICLProducer::pfmu_
private

Definition at line 38 of file PFTICLProducer.cc.

Referenced by produce().

◆ srcTrackTime_

const edm::EDGetTokenT<edm::ValueMap<float> > PFTICLProducer::srcTrackTime_
private

Definition at line 35 of file PFTICLProducer.cc.

Referenced by produce().

◆ srcTrackTimeError_

const edm::EDGetTokenT<edm::ValueMap<float> > PFTICLProducer::srcTrackTimeError_
private

Definition at line 35 of file PFTICLProducer.cc.

Referenced by produce().

◆ srcTrackTimeQuality_

const edm::EDGetTokenT<edm::ValueMap<float> > PFTICLProducer::srcTrackTimeQuality_
private

Definition at line 35 of file PFTICLProducer.cc.

Referenced by produce().

◆ ticl_candidates_

const edm::EDGetTokenT<edm::View<TICLCandidate> > PFTICLProducer::ticl_candidates_
private

Definition at line 34 of file PFTICLProducer.cc.

Referenced by produce().

◆ timingQualityThreshold_

const float PFTICLProducer::timingQualityThreshold_
private

Definition at line 31 of file PFTICLProducer.cc.

Referenced by produce().

◆ useMTDTiming_

const bool PFTICLProducer::useMTDTiming_
private

Definition at line 29 of file PFTICLProducer.cc.

Referenced by produce().

◆ useTimingAverage_

const bool PFTICLProducer::useTimingAverage_
private

Definition at line 30 of file PFTICLProducer.cc.

Referenced by produce().