9 #include "art/Utilities/ToolMacros.h"
19 namespace ShowerRecoTools {
45 , fLArPandoraShowerCheatingAlg(pset.
get<fhicl::ParameterSet>(
"LArPandoraShowerCheatingAlg"))
46 , fPFParticleLabel(pset.
get<art::InputTag>(
"PFParticleLabel"))
47 , fHitModuleLabel(pset.
get<art::InputTag>(
"HitModuleLabel"))
48 , fShowerStartPositionOutputLabel(pset.
get<
std::string>(
"ShowerStartPositionOutputLabel"))
49 , fTrueParticleOutputLabel(pset.
get<
std::string>(
"TrueParticleOutputLabel"))
59 std::map<int, const simb::MCParticle*> trueParticles =
61 std::map<int, std::vector<int>> showersMothers =
65 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
68 auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(
fPFParticleLabel);
71 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
76 std::vector<art::Ptr<recob::Hit>> showerHits;
77 for (
auto const&
cluster : clusters) {
80 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
81 showerHits.insert(showerHits.end(), hits.begin(), hits.end());
85 auto const clockData =
86 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
88 std::pair<int, double> ShowerTrackInfo =
90 clockData, showersMothers, showerHits, 2);
92 if (ShowerTrackInfo.first == -99999) {
93 mf::LogError(
"ShowerStartPositionCheater") <<
"True Shower Not Found";
97 const simb::MCParticle* trueParticle = trueParticles[ShowerTrackInfo.first];
99 mf::LogError(
"ShowerDirectionCheater") <<
"True shower not found, returning";
105 TVector3 trueStartPos = {-999, -999, -999};
108 if (
abs(trueParticle->PdgCode()) == 22) {
109 double initialEnergy = trueParticle->E();
110 unsigned int TrajPoints = trueParticle->NumberTrajectoryPoints();
111 for (
unsigned int trajPoint = 0; trajPoint < TrajPoints; trajPoint++) {
112 if (trueParticle->E(trajPoint) < initialEnergy) {
113 trueStartPos = trueParticle->Position(trajPoint).Vect();
119 trueStartPos = trueParticle->Position().Vect();
122 TVector3 trueStartPosErr = {-999, -999, -999};
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
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
Declaration of cluster object.
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