38 std::unique_ptr<PFMuonAlgo>
pfmu_;
44 : useMTDTiming_(conf.getParameter<
bool>(
"useMTDTiming")),
45 useTimingAverage_(conf.getParameter<
bool>(
"useTimingAverage")),
46 timingQualityThreshold_(conf.getParameter<double>(
"timingQualityThreshold")),
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"))),
54 produces<reco::PFCandidateCollection>();
63 desc.add<
double>(
"timingQualityThreshold", 0.5);
64 desc.add<
bool>(
"useMTDTiming",
true);
65 desc.add<
bool>(
"useTimingAverage",
false);
72 descriptions.
add(
"pfTICLProducer",
desc);
79 const auto ticl_candidates = *ticl_cand_h;
85 const auto muons = *muonH;
87 auto candidates = std::make_unique<reco::PFCandidateCollection>();
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.;
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;
99 double hcal_energy = ticl_cand.rawEnergy() - ecal_energy;
101 hcal_energy = hcal_energy < 0 ? 0 : hcal_energy;
104 switch (abs_pdg_id) {
128 candidate.setEcalEnergy(ecal_energy, ecal_energy);
129 candidate.setHcalEnergy(hcal_energy, hcal_energy);
130 if (candidate.charge()) {
134 candidate.setTrackRef(trackref);
141 pfmu_->reconstructMuon(candidate, muonref, allowLoose);
146 auto time = ticl_cand.time();
147 auto timeE = ticl_cand.timeError();
156 const auto timeHGC =
time;
157 const auto timeEHGC = timeE;
158 const auto timeMTD = (*trackTimeH)[candidate.trackRef()];
159 const auto timeEMTD = (*trackTimeErrH)[candidate.trackRef()];
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;
168 }
else if (timeEMTD > 0) {
174 candidate.setTime(
time, timeE);
static int muAssocToTrack(const reco::TrackRef &trackref, const reco::MuonCollection &muons)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParticleType
particle types
~PFTICLProducer() override
const bool useTimingAverage_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
#define DEFINE_FWK_MODULE(type)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
PFTICLProducer(const edm::ParameterSet &)
std::vector< Muon > MuonCollection
collection of Muon objects
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
EDProductGetter const & productGetter() const
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
const edm::EDGetTokenT< edm::View< TICLCandidate > > ticl_candidates_
std::unique_ptr< PFMuonAlgo > pfmu_
Abs< T >::type abs(const T &t)
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const float timingQualityThreshold_
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
ParameterSet const & getParameterSet(ParameterSetID const &id)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Power< A, B >::type pow(const A &a, const B &b)
const edm::EDGetTokenT< reco::MuonCollection > muons_