67 const simb::MCParticle* trueParticle;
70 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
71 auto const clockData =
72 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
75 auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(
fPFParticleLabel);
77 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
82 std::vector<art::Ptr<recob::Hit>> showerHits;
83 for (
auto const&
cluster : clusters) {
86 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
87 showerHits.insert(showerHits.end(), hits.begin(), hits.end());
96 std::map<int, const simb::MCParticle*> trueParticles =
98 std::map<int, std::vector<int>> showersMothers =
102 std::pair<int, double> ShowerTrackInfo =
104 clockData, showersMothers, showerHits, 2);
106 if (ShowerTrackInfo.first == -99999) {
107 mf::LogError(
"ShowerStartPosition") <<
"True Shower Not Found";
110 trueParticle = trueParticles[ShowerTrackInfo.first];
115 mf::LogError(
"ShowerDirectionCheater") <<
"True shower not found, returning";
121 mf::LogError(
"ShowerTrackFinderCheater") <<
"Start position not set, returning " << std::endl;
125 mf::LogError(
"ShowerTrackFinderCheater") <<
"Direction not set, returning " << std::endl;
129 TVector3 ShowerStartPosition = {-999, -999, -999};
132 TVector3 ShowerDirection = {-999, -999, -999};
135 auto const hitHandle = Event.getValidHandle<std::vector<recob::Hit>>(
fHitModuleLabel);
138 art::FindManyP<recob::SpacePoint> fmsph(hitHandle, Event,
fPFParticleLabel);
139 if (!fmsph.isValid()) {
140 throw cet::exception(
"ShowerTrackFinderCheater")
141 <<
"Spacepoint and hit association not valid. Stopping.";
144 std::vector<int> trueParticleIdVec;
148 if (trueParticle->PdgCode() != 22) { trueParticleIdVec.push_back(trueParticle->TrackId()); }
151 const int nDaughters = trueParticle->NumberDaughters();
152 if (nDaughters == 0) {
154 trueParticleIdVec.push_back(-trueParticle->TrackId());
158 for (
int i = 0; i < nDaughters; i++) {
159 trueParticleIdVec.push_back(trueParticle->Daughter(i));
164 std::vector<art::Ptr<recob::Hit>> trackHits;
165 std::vector<art::Ptr<recob::SpacePoint>> trackSpacePoints;
168 for (
auto hit : showerHits) {
170 if (std::find(trueParticleIdVec.cbegin(), trueParticleIdVec.cend(), trueHitId) !=
171 trueParticleIdVec.cend()) {
172 trackHits.push_back(
hit);
173 std::vector<art::Ptr<recob::SpacePoint>> sps = fmsph.at(
hit.key());
174 if (sps.size() == 1) { trackSpacePoints.push_back(sps.front()); }
178 if (trackHits.empty() || trackSpacePoints.empty())
179 mf::LogWarning(
"ShowerTrackFinderCheater")
180 <<
"Creating intial track with " << trackHits.size() <<
" hits and "
181 << trackSpacePoints.size() <<
" spacepoints" << std::endl;
188 clockData, trueParticle, Event, ShowerEleHolder, pfparticle);
std::map< int, const simb::MCParticle * > GetTrueParticleMap() const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
std::map< int, std::vector< int > > GetTrueChain(std::map< int, const simb::MCParticle * > &trueParticles) 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
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