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::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PFTICLProducer (const edm::ParameterSet &)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~PFTICLProducer () override
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

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::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 16 of file PFTICLProducer.cc.

Constructor & Destructor Documentation

◆ PFTICLProducer()

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

Definition at line 37 of file PFTICLProducer.cc.

38  : useTimingAverage_(conf.getParameter<bool>("useTimingAverage")),
39  timingQualityThreshold_(conf.getParameter<double>("timingQualityThreshold")),
44  produces<reco::PFCandidateCollection>();
45 }

◆ ~PFTICLProducer()

PFTICLProducer::~PFTICLProducer ( )
inlineoverride

Definition at line 19 of file PFTICLProducer.cc.

19 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 47 of file PFTICLProducer.cc.

47  {
49  desc.add<edm::InputTag>("ticlCandidateSrc", edm::InputTag("ticlTrackstersMerge"));
50  desc.add<edm::InputTag>("trackTimeValueMap", edm::InputTag("tofPID:t0"));
51  desc.add<edm::InputTag>("trackTimeErrorMap", edm::InputTag("tofPID:sigmat0"));
52  desc.add<edm::InputTag>("trackTimeQualityMap", edm::InputTag("mtdTrackQualityMVA:mtdQualMVA"));
53  desc.add<double>("timingQualityThreshold", 0.5);
54  desc.add<bool>("useTimingAverage", false);
55  descriptions.add("pfTICLProducer", desc);
56 }

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

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 58 of file PFTICLProducer.cc.

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

References funct::abs(), HLT_FULL_cff::candidates, ALCARECOTkAlJpsiMuMu_cff::charge, reco::PFCandidate::e, reco::PFCandidate::gamma, edm::Event::getByToken(), reco::PFCandidate::h, reco::PFCandidate::h0, createfilelist::int, eostools::move(), reco::PFCandidate::mu, funct::pow(), edm::Event::productGetter(), edm::Event::put(), mathSSE::sqrt(), srcTrackTime_, srcTrackTimeError_, srcTrackTimeQuality_, submitPVValidationJobs::t, ticl_candidates_, ntuplemaker::time, timingQualityThreshold_, useTimingAverage_, and reco::PFCandidate::X.

Member Data Documentation

◆ srcTrackTime_

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

Definition at line 32 of file PFTICLProducer.cc.

Referenced by produce().

◆ srcTrackTimeError_

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

Definition at line 32 of file PFTICLProducer.cc.

Referenced by produce().

◆ srcTrackTimeQuality_

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

Definition at line 32 of file PFTICLProducer.cc.

Referenced by produce().

◆ ticl_candidates_

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

Definition at line 31 of file PFTICLProducer.cc.

Referenced by produce().

◆ timingQualityThreshold_

const float PFTICLProducer::timingQualityThreshold_
private

Definition at line 28 of file PFTICLProducer.cc.

Referenced by produce().

◆ useTimingAverage_

const bool PFTICLProducer::useTimingAverage_
private

Definition at line 27 of file PFTICLProducer.cc.

Referenced by produce().

PFTICLProducer::srcTrackTime_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
Definition: PFTICLProducer.cc:32
PFTICLProducer::useTimingAverage_
const bool useTimingAverage_
Definition: PFTICLProducer.cc:27
reco::PFCandidate::e
Definition: PFCandidate.h:47
edm::Event::productGetter
EDProductGetter const & productGetter() const
Definition: Event.cc:105
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco::PFCandidate::h
Definition: PFCandidate.h:46
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:31
PFTICLProducer::srcTrackTimeQuality_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
Definition: PFTICLProducer.cc:32
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
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
PFTICLProducer::srcTrackTimeError_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
Definition: PFTICLProducer.cc:32
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::View
Definition: CaloClusterFwd.h:14
createfilelist.int
int
Definition: createfilelist.py:10
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
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:54985
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:28
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
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
reco::PFCandidate::ParticleType
ParticleType
particle types
Definition: PFCandidate.h:44
ntuplemaker.time
time
Definition: ntuplemaker.py:310
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::InputTag
Definition: InputTag.h:15