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 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  ticl_candidates_(consumes<edm::View<TICLCandidate>>(conf.getParameter<edm::InputTag>("ticlCandidateSrc"))),
48  srcTrackTime_(consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeValueMap"))),
49  srcTrackTimeError_(consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeErrorMap"))),
50  srcTrackTimeQuality_(consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeQualityMap"))),
51  muons_(consumes<reco::MuonCollection>(conf.getParameter<edm::InputTag>("muonSrc"))),
52  pfmu_(std::make_unique<PFMuonAlgo>(conf.getParameterSet("pfMuonAlgoParameters"),
53  false)) { // postMuonCleaning = false
54  produces<reco::PFCandidateCollection>();
55 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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 57 of file PFTICLProducer.cc.

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

57  {
59  desc.add<edm::InputTag>("ticlCandidateSrc", edm::InputTag("ticlTrackstersMerge"));
60  desc.add<edm::InputTag>("trackTimeValueMap", edm::InputTag("tofPID:t0"));
61  desc.add<edm::InputTag>("trackTimeErrorMap", edm::InputTag("tofPID:sigmat0"));
62  desc.add<edm::InputTag>("trackTimeQualityMap", edm::InputTag("mtdTrackQualityMVA:mtdQualMVA"));
63  desc.add<double>("timingQualityThreshold", 0.5);
64  desc.add<bool>("useMTDTiming", true);
65  desc.add<bool>("useTimingAverage", false);
66  // For PFMuonAlgo
67  desc.add<edm::InputTag>("muonSrc", edm::InputTag("muons1stStep"));
68  edm::ParameterSetDescription psd_PFMuonAlgo;
69  PFMuonAlgo::fillPSetDescription(psd_PFMuonAlgo);
70  desc.add<edm::ParameterSetDescription>("pfMuonAlgoParameters", psd_PFMuonAlgo);
71  //
72  descriptions.add("pfTICLProducer", desc);
73 }
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 75 of file PFTICLProducer.cc.

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

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

Member Data Documentation

◆ 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().