68 auto const clockData =
74 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.
key());
79 std::vector<art::Ptr<recob::Hit>> showerHits;
80 for (
auto const&
cluster : clusters) {
83 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
84 showerHits.insert(showerHits.end(), hits.begin(), hits.end());
93 std::map<int, const simb::MCParticle*> trueParticles =
95 std::map<int, std::vector<int>> showersMothers =
99 std::pair<int, double> ShowerTrackInfo =
101 clockData, showersMothers, showerHits, 2);
103 if (ShowerTrackInfo.first == -99999) {
104 mf::LogError(
"ShowerStartPosition") <<
"True Shower Not Found";
107 trueParticle = trueParticles[ShowerTrackInfo.first];
112 mf::LogError(
"ShowerDirectionCheater") <<
"True shower not found, returning";
126 TVector3 ShowerStartPosition = {-999, -999, -999};
129 TVector3 ShowerDirection = {-999, -999, -999};
135 art::FindManyP<recob::SpacePoint> fmsph(hitHandle, Event,
fPFParticleLabel);
136 if (!fmsph.isValid()) {
138 <<
"Spacepoint and hit association not valid. Stopping.";
141 std::vector<int> trueParticleIdVec;
145 if (trueParticle->
PdgCode() != 22) { trueParticleIdVec.push_back(trueParticle->
TrackId()); }
149 if (nDaughters == 0) {
151 trueParticleIdVec.push_back(-trueParticle->
TrackId());
155 for (
int i = 0; i < nDaughters; i++) {
156 trueParticleIdVec.push_back(trueParticle->
Daughter(i));
161 std::vector<art::Ptr<recob::Hit>> trackHits;
162 std::vector<art::Ptr<recob::SpacePoint>> trackSpacePoints;
165 for (
auto hit : showerHits) {
167 if (std::find(trueParticleIdVec.cbegin(), trueParticleIdVec.cend(), trueHitId) !=
168 trueParticleIdVec.cend()) {
169 trackHits.push_back(
hit);
170 std::vector<art::Ptr<recob::SpacePoint>> sps = fmsph.at(
hit.key());
171 if (sps.size() == 1) { trackSpacePoints.push_back(sps.front()); }
175 if (trackHits.empty() || trackSpacePoints.empty())
177 <<
"Creating intial track with " << trackHits.size() <<
" hits and " 178 << trackSpacePoints.size() <<
" spacepoints" <<
std::endl;
185 clockData, trueParticle, Event, ShowerEleHolder, pfparticle);
std::map< int, const simb::MCParticle * > GetTrueParticleMap() const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
int NumberDaughters() const
int Daughter(const int i) const
key_type key() const noexcept
std::map< int, std::vector< int > > GetTrueChain(std::map< int, const simb::MCParticle * > &trueParticles) const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool CheckElement(const std::string &Name) const
void CheatDebugEVD(detinfo::DetectorClocksData const &clockData, const simb::MCParticle *trueParticle, art::Event const &Event, reco::shower::ShowerElementHolder &ShowerEleHolder, const art::Ptr< recob::PFParticle > &pfparticle) const
int GetElement(const std::string &Name, T &Element) const
int TrueParticleID(detinfo::DetectorClocksData const &clockData, const art::Ptr< recob::Hit > &hit) const
Detector simulation of raw signals on wires.
std::pair< int, double > TrueParticleIDFromTrueChain(detinfo::DetectorClocksData const &clockData, std::map< int, std::vector< int >> const &ShowersMothers, std::vector< art::Ptr< recob::Hit >> const &hits, int planeid) const
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)