60 :
IShowerTool(pset.get<fhicl::ParameterSet>(
"BaseTools"))
61 , fLArPandoraShowerCheatingAlg(pset.get<fhicl::ParameterSet>(
"LArPandoraShowerCheatingAlg"))
62 , fPFParticleLabel(pset.get<
art::InputTag>(
"PFParticleLabel"))
63 , fNSegments(pset.get<unsigned int>(
"NSegments"))
64 , fRMSFlip(pset.get<bool>(
"RMSFlip"))
65 , fVertexFlip(pset.get<bool>(
"VertexFlip"))
66 , fShowerStartPositionInputLabel(pset.get<std::string>(
"ShowerStartPositionInputLabel"))
67 , fTrueParticleInputLabel(pset.get<std::string>(
"TrueParticleInputLabel"))
68 , fShowerDirectionOutputLabel(pset.get<std::string>(
"ShowerDirectionOutputLabel"))
71 Tree =
tfs->make<TTree>(
"DebugTreeDirCheater",
"DebugTree from shower direction cheater");
82 const simb::MCParticle* trueParticle;
85 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
87 auto const clockData =
88 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
90 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
98 std::map<int, const simb::MCParticle*> trueParticles =
100 std::map<int, std::vector<int>> showersMothers =
104 auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(
fPFParticleLabel);
106 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
111 std::vector<art::Ptr<recob::Hit>> showerHits;
112 for (
auto const&
cluster : clusters) {
114 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
115 showerHits.insert(showerHits.end(), hits.begin(), hits.end());
119 std::pair<int, double> ShowerTrackInfo =
121 clockData, showersMothers, showerHits, 2);
123 if (ShowerTrackInfo.first == -99999) {
124 mf::LogError(
"ShowerDirectionCheater") <<
"True shower not found, returning";
127 trueParticle = trueParticles[ShowerTrackInfo.first];
132 mf::LogError(
"ShowerDirectionCheater") <<
"True shower not found, returning";
136 auto trueDir = geo::Vector_t{trueParticle->Px(), trueParticle->Py(), trueParticle->Pz()}.Unit();
138 geo::Vector_t trueDirErr = {-999, -999, -999};
144 rmsGradient = std::numeric_limits<float>::lowest();
148 art::FindManyP<recob::SpacePoint> fmspp(pfpHandle, Event,
fPFParticleLabel);
150 if (!fmspp.isValid()) {
151 throw cet::exception(
"ShowerDirectionCheater")
152 <<
"Trying to get the spacepoint and failed. Something is not configured correctly. "
156 auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(
fPFParticleLabel);
158 if (!fmh.isValid()) {
159 throw cet::exception(
"ShowerDirectionCheater")
160 <<
"Spacepoint and hit association not valid. Stopping.";
162 std::vector<art::Ptr<recob::SpacePoint>> spacePoints = fmspp.at(pfparticle.key());
164 if (spacePoints.size() < 3) {
165 mf::LogWarning(
"ShowerDirectionCheater")
166 << spacePoints.size() <<
" spacepoints in shower, not calculating direction" << std::endl;
174 clockData, detProp, spacePoints, fmh, TotalCharge);
180 geo::Point_t StartPositionVec = {-999, -999, -999};
183 auto const GeneralDir = (ShowerCentre - StartPositionVec).Unit();
192 spacePoints, ShowerCentre, trueDir,
fNSegments);