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
const bool useTimingAverage_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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
const float timingQualityThreshold_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Power< A, B >::type pow(const A &a, const B &b)
const edm::EDGetTokenT< reco::MuonCollection > muons_