76 mf::LogInfo(
"DirectHitParticleAssns") <<
"Configured\n";
117 if (!hitListHandle.
isValid()) {
119 <<
"InputTag not associating to valid hit collection, tag: " << inputTag <<
"\n";
124 std::unordered_map<int, int>
127 auto const& hitList(*hitListHandle);
128 auto const& mcpartList(*mcpartHandle);
130 for (
size_t i_h = 0; i_h < hitList.size(); ++i_h) {
133 auto trkide_list = btService->HitToTrackIDEs(clockData, hitPtr);
145 for (
size_t i_t = 0; i_t < trkide_list.size(); ++i_t) {
146 auto const& t(trkide_list[i_t]);
151 maxtrkid = t.trackID;
154 totn += t.numElectrons;
157 maxntrkid = t.trackID;
161 if (trkid_lookup.find(t.trackID) == trkid_lookup.end()) {
163 while (i_p < mcpartList.size()) {
164 if (mcpartList[i_p].TrackId() ==
abs(t.trackID)) {
165 trkid_lookup[t.trackID] = (int)i_p;
170 if (i_p == mcpartList.size()) trkid_lookup[t.trackID] = -1;
177 int mcpart_i = trkid_lookup[t.first];
178 if (mcpart_i == -1)
continue;
181 bthmd.
isMaxIDE = (t.first == maxtrkid);
183 bthmd.
isMaxIDEN = (t.first == maxntrkid);
184 bthmd.
energy = t.second.E;
186 hitPartAssns->
addSingle(mcpartPtr, hitPtr, bthmd);
code to link reconstructed objects back to the MC truth information
std::unordered_map< int, TrackIDEinfo > fTrkIDECollector
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
constexpr auto abs(T v)
Returns the absolute value of the argument.
void CreateHitParticleAssociations(art::Event &, HitParticleAssociations *) override
This rebuilds the internal maps.
DirectHitParticleAssns(fhicl::ParameterSet const &pset)
Constructor.
bool isValid() const noexcept
art::InputTag fMCParticleModuleLabel
T get(std::string const &key) const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::vector< art::InputTag > fHitModuleLabelVec
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
void reconfigure(fhicl::ParameterSet const &pset) override