38 std::unique_ptr<PFMuonAlgo>
pfmu_;
44 : useMTDTiming_(conf.getParameter<
bool>(
"useMTDTiming")),
45 useTimingAverage_(conf.getParameter<
bool>(
"useTimingAverage")),
46 timingQualityThreshold_(conf.getParameter<double>(
"timingQualityThreshold")),
47 energy_from_regression_(conf.getParameter<
bool>(
"energyFromRegression")),
49 srcTrackTime_(consumes<
edm::ValueMap<
float>>(conf.getParameter<
edm::
InputTag>(
"trackTimeValueMap"))),
50 srcTrackTimeError_(consumes<
edm::ValueMap<
float>>(conf.getParameter<
edm::
InputTag>(
"trackTimeErrorMap"))),
51 srcTrackTimeQuality_(consumes<
edm::ValueMap<
float>>(conf.getParameter<
edm::
InputTag>(
"trackTimeQualityMap"))),
55 produces<reco::PFCandidateCollection>();
64 desc.add<
bool>(
"energyFromRegression",
true);
65 desc.add<
double>(
"timingQualityThreshold", 0.5);
66 desc.add<
bool>(
"useMTDTiming",
true);
67 desc.add<
bool>(
"useTimingAverage",
false);
74 descriptions.
add(
"pfTICLProducer",
desc);
81 const auto ticl_candidates = *ticl_cand_h;
87 const auto&
muons = *muonH;
89 auto candidates = std::make_unique<reco::PFCandidateCollection>();
91 for (
const auto& ticl_cand : ticl_candidates) {
92 const auto abs_pdg_id =
std::abs(ticl_cand.pdgId());
93 const auto charge = ticl_cand.charge();
94 const auto& four_mom = ticl_cand.p4();
95 float total_raw_energy = 0.f;
96 float total_em_raw_energy = 0.f;
97 for (
const auto&
t : ticl_cand.tracksters()) {
98 total_raw_energy +=
t->raw_energy();
99 total_em_raw_energy +=
t->raw_em_energy();
101 float ecal_energy_fraction = total_em_raw_energy / total_raw_energy;
103 : ticl_cand.rawEnergy() * ecal_energy_fraction;
107 hcal_energy =
std::max(0.
f, hcal_energy);
109 switch (abs_pdg_id) {
133 candidate.setEcalEnergy(ecal_energy, ecal_energy);
134 candidate.setHcalEnergy(hcal_energy, hcal_energy);
135 if (candidate.charge()) {
139 candidate.setTrackRef(trackref);
146 pfmu_->reconstructMuon(candidate, muonref, allowLoose);
151 auto time = ticl_cand.time();
152 auto timeE = ticl_cand.timeError();
161 const auto timeHGC =
time;
162 const auto timeEHGC = timeE;
163 const auto timeMTD = (*trackTimeH)[candidate.trackRef()];
164 const auto timeEMTD = (*trackTimeErrH)[candidate.trackRef()];
168 const auto invTimeESqHGC =
pow(timeEHGC, -2);
169 const auto invTimeESqMTD =
pow(timeEMTD, -2);
170 timeE = (invTimeESqHGC * invTimeESqMTD) / (invTimeESqHGC + invTimeESqMTD);
171 time = (timeHGC * invTimeESqHGC + timeMTD * invTimeESqMTD) * timeE;
173 }
else if (timeEMTD > 0) {
179 candidate.setTime(
time, timeE);
static int muAssocToTrack(const reco::TrackRef &trackref, const reco::MuonCollection &muons)
const bool energy_from_regression_
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_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
PFTICLProducer(const edm::ParameterSet &)
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
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
#define DEFINE_FWK_MODULE(type)
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_