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 bool isTICLv5_
 
const edm::EDGetTokenT< reco::MuonCollectionmuons_
 
std::unique_ptr< PFMuonAlgopfmu_
 
edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
 
edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
 
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 44 of file PFTICLProducer.cc.

References edm::ParameterSet::getParameter(), isTICLv5_, srcTrackTime_, srcTrackTimeError_, and srcTrackTimeQuality_.

45  : useMTDTiming_(conf.getParameter<bool>("useMTDTiming")),
46  useTimingAverage_(conf.getParameter<bool>("useTimingAverage")),
47  timingQualityThreshold_(conf.getParameter<double>("timingQualityThreshold")),
48  energy_from_regression_(conf.getParameter<bool>("energyFromRegression")),
49  isTICLv5_(conf.getParameter<bool>("isTICLv5")),
50  ticl_candidates_(consumes<edm::View<TICLCandidate>>(conf.getParameter<edm::InputTag>("ticlCandidateSrc"))),
51  muons_(consumes<reco::MuonCollection>(conf.getParameter<edm::InputTag>("muonSrc"))),
52  pfmu_(std::make_unique<PFMuonAlgo>(conf.getParameterSet("pfMuonAlgoParameters"),
53  false)) { // postMuonCleaning = false
54  if (not isTICLv5_) {
55  srcTrackTime_ = consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeValueMap"));
56  srcTrackTimeError_ = consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeErrorMap"));
57  srcTrackTimeQuality_ = consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeQualityMap"));
58  }
59  produces<reco::PFCandidateCollection>();
60 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const bool energy_from_regression_
edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
const bool useTimingAverage_
ParameterSet const & getParameterSet(std::string const &) const
const bool isTICLv5_
edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
const edm::EDGetTokenT< edm::View< TICLCandidate > > ticl_candidates_
std::unique_ptr< PFMuonAlgo > pfmu_
const bool useMTDTiming_
edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
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 62 of file PFTICLProducer.cc.

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

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

References funct::abs(), HLT_2024v14_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, PFMuonAlgo::isMuon(), edm::Ref< C, T, F >::isNonnull(), isTICLv5_, WZElectronSkims53X_cff::max, eostools::move(), reco::PFCandidate::mu, PFMuonAlgo::muAssocToTrack(), DiMuonV_cfg::muons, muons_, or, pfmu_, funct::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.

82  {
83  //get TICLCandidates
85  evt.getByToken(ticl_candidates_, ticl_cand_h);
86  const auto ticl_candidates = *ticl_cand_h;
87  edm::Handle<edm::ValueMap<float>> trackTimeH, trackTimeErrH, trackTimeQualH;
88  if (not isTICLv5_) {
89  evt.getByToken(srcTrackTime_, trackTimeH);
90  evt.getByToken(srcTrackTimeError_, trackTimeErrH);
91  evt.getByToken(srcTrackTimeQuality_, trackTimeQualH);
92  }
93  const auto muonH = evt.getHandle(muons_);
94  const auto& muons = *muonH;
95 
96  auto candidates = std::make_unique<reco::PFCandidateCollection>();
97 
98  for (const auto& ticl_cand : ticl_candidates) {
99  const auto abs_pdg_id = std::abs(ticl_cand.pdgId());
100  const auto charge = ticl_cand.charge();
101  const auto& four_mom = ticl_cand.p4();
102  float total_raw_energy = 0.f;
103  float total_em_raw_energy = 0.f;
104  for (const auto& t : ticl_cand.tracksters()) {
105  total_raw_energy += t->raw_energy();
106  total_em_raw_energy += t->raw_em_energy();
107  }
108  float ecal_energy_fraction = total_em_raw_energy / total_raw_energy;
109  float ecal_energy = energy_from_regression_ ? ticl_cand.p4().energy() * ecal_energy_fraction
110  : ticl_cand.rawEnergy() * ecal_energy_fraction;
111  float hcal_energy =
112  energy_from_regression_ ? ticl_cand.p4().energy() - ecal_energy : ticl_cand.rawEnergy() - ecal_energy;
113  // fix for floating point rounding could go slightly below 0
114  hcal_energy = std::max(0.f, hcal_energy);
116  switch (abs_pdg_id) {
117  case 11:
118  part_type = reco::PFCandidate::e;
119  break;
120  case 13:
121  part_type = reco::PFCandidate::mu;
122  break;
123  case 22:
124  part_type = reco::PFCandidate::gamma;
125  break;
126  case 130:
127  part_type = reco::PFCandidate::h0;
128  break;
129  case 211:
130  part_type = reco::PFCandidate::h;
131  break;
132  // default also handles neutral pions (111) for the time being (not yet foreseen in PFCandidate)
133  default:
134  part_type = reco::PFCandidate::X;
135  }
136 
137  candidates->emplace_back(charge, four_mom, part_type);
138 
139  auto& candidate = candidates->back();
140  candidate.setEcalEnergy(ecal_energy, ecal_energy);
141  candidate.setHcalEnergy(hcal_energy, hcal_energy);
142  if (candidate.charge()) { // otherwise PFCandidate throws
143  // Construct edm::Ref from edm::Ptr. As of now, assumes type to be reco::Track. To be extended (either via
144  // dynamic type checking or configuration) if additional track types are needed.
145  reco::TrackRef trackref(ticl_cand.trackPtr().id(), int(ticl_cand.trackPtr().key()), &evt.productGetter());
146  candidate.setTrackRef(trackref);
147  // Utilize PFMuonAlgo
148  const int muId = PFMuonAlgo::muAssocToTrack(trackref, muons);
149  if (isTICLv5_) {
150  if (muId != -1) {
151  const reco::MuonRef muonref = reco::MuonRef(muonH, muId);
152  if ((PFMuonAlgo::isMuon(muonref) and not(*muonH)[muId].isTrackerMuon()) or
153  (ticl_cand.tracksters().empty() and muonref.isNonnull() and muonref->isGlobalMuon())) {
154  const bool allowLoose = (part_type == reco::PFCandidate::mu);
155  // Redefine pfmuon candidate kinematics and add muonref
156  pfmu_->reconstructMuon(candidate, muonref, allowLoose);
157  }
158  }
159  } else {
160  if (muId != -1) {
161  const reco::MuonRef muonref = reco::MuonRef(muonH, muId);
162  const bool allowLoose = (part_type == reco::PFCandidate::mu);
163  // Redefine pfmuon candidate kinematics and add muonref
164  pfmu_->reconstructMuon(candidate, muonref, allowLoose);
165  }
166  }
167  }
168 
169  if (isTICLv5_) {
170  candidate.setTime(ticl_cand.time(), ticl_cand.timeError());
171  } else {
172  // HGCAL timing as default values
173  auto time = ticl_cand.time();
174  auto timeE = ticl_cand.timeError();
175 
176  if (useMTDTiming_ and candidate.charge()) {
177  // Ignore HGCAL timing until it will be TOF corrected
178  time = -99.;
179  timeE = -1.;
180  // Check MTD timing availability
181  const bool assocQuality = (*trackTimeQualH)[candidate.trackRef()] > timingQualityThreshold_;
182  if (assocQuality) {
183  const auto timeHGC = time;
184  const auto timeEHGC = timeE;
185  const auto timeMTD = (*trackTimeH)[candidate.trackRef()];
186  const auto timeEMTD = (*trackTimeErrH)[candidate.trackRef()];
187 
188  if (useTimingAverage_ && (timeEMTD > 0 && timeEHGC > 0)) {
189  // Compute weighted average between HGCAL and MTD timing
190  const auto invTimeESqHGC = pow(timeEHGC, -2);
191  const auto invTimeESqMTD = pow(timeEMTD, -2);
192  timeE = 1.f / (invTimeESqHGC + invTimeESqMTD);
193  time = (timeHGC * invTimeESqHGC + timeMTD * invTimeESqMTD) * timeE;
194  timeE = sqrt(timeE);
195  } else if (timeEMTD > 0) { // Ignore HGCal timing until it will be TOF corrected
196  time = timeMTD;
197  timeE = timeEMTD;
198  }
199  }
200  }
201  candidate.setTime(time, timeE);
202  }
203  }
204 
205  evt.put(std::move(candidates));
206 }
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
edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
const bool useTimingAverage_
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:48
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:232
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:526
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
EDProductGetter const & productGetter() const
Definition: Event.cc:106
const bool isTICLv5_
edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
const edm::EDGetTokenT< edm::View< TICLCandidate > > ticl_candidates_
T sqrt(T t)
Definition: SSEVec.h:23
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
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
edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
const float timingQualityThreshold_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:550
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

◆ energy_from_regression_

const bool PFTICLProducer::energy_from_regression_
private

Definition at line 32 of file PFTICLProducer.cc.

Referenced by produce().

◆ isTICLv5_

const bool PFTICLProducer::isTICLv5_
private

Definition at line 33 of file PFTICLProducer.cc.

Referenced by PFTICLProducer(), and produce().

◆ muons_

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

Definition at line 37 of file PFTICLProducer.cc.

Referenced by produce().

◆ pfmu_

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

Definition at line 39 of file PFTICLProducer.cc.

Referenced by produce().

◆ srcTrackTime_

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

Definition at line 36 of file PFTICLProducer.cc.

Referenced by PFTICLProducer(), and produce().

◆ srcTrackTimeError_

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

Definition at line 36 of file PFTICLProducer.cc.

Referenced by PFTICLProducer(), and produce().

◆ srcTrackTimeQuality_

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

Definition at line 36 of file PFTICLProducer.cc.

Referenced by PFTICLProducer(), and produce().

◆ ticl_candidates_

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

Definition at line 35 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().