CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 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 42 of file PFTICLProducer.cc.

43  : useTimingAverage_(conf.getParameter<bool>("useTimingAverage")),
44  timingQualityThreshold_(conf.getParameter<double>("timingQualityThreshold")),
45  ticl_candidates_(consumes<edm::View<TICLCandidate>>(conf.getParameter<edm::InputTag>("ticlCandidateSrc"))),
46  srcTrackTime_(consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeValueMap"))),
47  srcTrackTimeError_(consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeErrorMap"))),
48  srcTrackTimeQuality_(consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeQualityMap"))),
49  muons_(consumes<reco::MuonCollection>(conf.getParameter<edm::InputTag>("muonSrc"))),
50  pfmu_(std::make_unique<PFMuonAlgo>(conf.getParameterSet("pfMuonAlgoParameters"),
51  false)) { // postMuonCleaning = false
52  produces<reco::PFCandidateCollection>();
53 }

◆ ~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 55 of file PFTICLProducer.cc.

55  {
57  desc.add<edm::InputTag>("ticlCandidateSrc", edm::InputTag("ticlTrackstersMerge"));
58  desc.add<edm::InputTag>("trackTimeValueMap", edm::InputTag("tofPID:t0"));
59  desc.add<edm::InputTag>("trackTimeErrorMap", edm::InputTag("tofPID:sigmat0"));
60  desc.add<edm::InputTag>("trackTimeQualityMap", edm::InputTag("mtdTrackQualityMVA:mtdQualMVA"));
61  desc.add<double>("timingQualityThreshold", 0.5);
62  desc.add<bool>("useTimingAverage", false);
63  // For PFMuonAlgo
64  desc.add<edm::InputTag>("muonSrc", edm::InputTag("muons1stStep"));
65  edm::ParameterSetDescription psd_PFMuonAlgo;
66  PFMuonAlgo::fillPSetDescription(psd_PFMuonAlgo);
67  desc.add<edm::ParameterSetDescription>("pfMuonAlgoParameters", psd_PFMuonAlgo);
68  //
69  descriptions.add("pfTICLProducer", desc);
70 }

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

◆ produce()

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

Definition at line 72 of file PFTICLProducer.cc.

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

References funct::abs(), HLT_FULL_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_, useTimingAverage_, and reco::PFCandidate::X.

Member Data Documentation

◆ muons_

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

Definition at line 35 of file PFTICLProducer.cc.

Referenced by produce().

◆ pfmu_

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

Definition at line 37 of file PFTICLProducer.cc.

Referenced by produce().

◆ srcTrackTime_

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

Definition at line 34 of file PFTICLProducer.cc.

Referenced by produce().

◆ srcTrackTimeError_

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

Definition at line 34 of file PFTICLProducer.cc.

Referenced by produce().

◆ srcTrackTimeQuality_

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

Definition at line 34 of file PFTICLProducer.cc.

Referenced by produce().

◆ ticl_candidates_

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

Definition at line 33 of file PFTICLProducer.cc.

Referenced by produce().

◆ timingQualityThreshold_

const float PFTICLProducer::timingQualityThreshold_
private

Definition at line 30 of file PFTICLProducer.cc.

Referenced by produce().

◆ useTimingAverage_

const bool PFTICLProducer::useTimingAverage_
private

Definition at line 29 of file PFTICLProducer.cc.

Referenced by produce().

PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
PFTICLProducer::srcTrackTime_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
Definition: PFTICLProducer.cc:34
PFTICLProducer::useTimingAverage_
const bool useTimingAverage_
Definition: PFTICLProducer.cc:29
reco::PFCandidate::e
Definition: PFCandidate.h:47
edm::Event::productGetter
EDProductGetter const & productGetter() const
Definition: Event.cc:106
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco::PFCandidate::h
Definition: PFCandidate.h:46
protons_cff.time
time
Definition: protons_cff.py:35
edm::Handle
Definition: AssociativeIterator.h:50
reco::PFCandidate::X
Definition: PFCandidate.h:45
edm::Ref< TrackCollection >
PFTICLProducer::ticl_candidates_
const edm::EDGetTokenT< edm::View< TICLCandidate > > ticl_candidates_
Definition: PFTICLProducer.cc:33
PFTICLProducer::srcTrackTimeQuality_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
Definition: PFTICLProducer.cc:34
reco::PFCandidate::mu
Definition: PFCandidate.h:48
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::MuonRef
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
Definition: MuonFwd.h:13
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
PFTICLProducer::srcTrackTimeError_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
Definition: PFTICLProducer.cc:34
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::View
Definition: CaloClusterFwd.h:14
createfilelist.int
int
Definition: createfilelist.py:10
PFTICLProducer::pfmu_
std::unique_ptr< PFMuonAlgo > pfmu_
Definition: PFTICLProducer.cc:37
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
reco::PFCandidate::gamma
Definition: PFCandidate.h:49
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
PFMuonAlgo::muAssocToTrack
static int muAssocToTrack(const reco::TrackRef &trackref, const reco::MuonCollection &muons)
Definition: PFMuonAlgo.cc:479
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:55017
edm::ValueMap< float >
reco::PFCandidate::h0
Definition: PFCandidate.h:50
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PFTICLProducer::timingQualityThreshold_
const float timingQualityThreshold_
Definition: PFTICLProducer.cc:30
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PFTICLProducer::muons_
const edm::EDGetTokenT< reco::MuonCollection > muons_
Definition: PFTICLProducer.cc:35
reco::PFCandidate::ParticleType
ParticleType
particle types
Definition: PFCandidate.h:44
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
PFMuonAlgo::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
Definition: PFMuonAlgo.cc:1043
edm::Event::getHandle
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
edm::InputTag
Definition: InputTag.h:15
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128