75 detinfo::DetectorClocksData
const& clockData,
76 const simb::MCParticle* trueParticle,
77 art::Event
const& Event,
79 const art::Ptr<recob::PFParticle>& pfparticle)
const
82 std::cout <<
"Making Debug Event Display" << std::endl;
87 int run = Event.run();
88 int subRun = Event.subRun();
89 int event = Event.event();
90 int PFPID = pfparticle->Self();
93 TString canvasName = Form(
"canvas_%i_%i_%i_%i", run, subRun, event, PFPID);
94 TCanvas* canvas = tfs->make<TCanvas>(canvasName, canvasName);
101 std::vector<art::Ptr<recob::SpacePoint>> showerSpacePoints;
102 std::vector<art::Ptr<recob::SpacePoint>> otherSpacePoints;
104 auto const hitHandle = Event.getValidHandle<std::vector<recob::Hit>>(fHitModuleLabel);
105 std::vector<art::Ptr<recob::Hit>> hits;
106 art::fill_ptr_vector(hits, hitHandle);
109 const art::FindManyP<recob::SpacePoint> fmsph(hitHandle, Event, fPFParticleLabel);
110 if (!fmsph.isValid()) {
111 throw cet::exception(
"LArPandoraShowerCheatingAlg")
112 <<
"Spacepoint and hit association not valid. Stopping.";
115 std::map<art::Ptr<recob::SpacePoint>, art::Ptr<recob::Hit>> spacePointHitMap;
117 for (
auto hit : hits) {
118 int trueParticleID = std::abs(TrueParticleID(clockData, hit));
119 std::vector<art::Ptr<recob::SpacePoint>> sps = fmsph.at(hit.key());
120 if (sps.size() == 1) {
121 art::Ptr<recob::SpacePoint> sp = sps.front();
122 if (trueParticleID == trueParticle->TrackId()) { showerSpacePoints.push_back(sp); }
124 otherSpacePoints.push_back(sp);
129 if (!ShowerEleHolder.
CheckElement(fShowerStartPositionInputLabel)) {
130 mf::LogError(
"LArPandoraShowerCheatingAlg")
131 <<
"Start position not set, returning " << std::endl;
134 if (!ShowerEleHolder.
CheckElement(fShowerDirectionInputLabel)) {
135 mf::LogError(
"LArPandoraShowerCheatingAlg") <<
"Direction not set, returning " << std::endl;
138 if (!ShowerEleHolder.
CheckElement(fInitialTrackSpacePointsInputLabel)) {
139 mf::LogError(
"LArPandoraShowerCheatingAlg")
140 <<
"TrackSpacePoints not set, returning " << std::endl;
145 geo::Point_t showerStartPosition = {-999, -999, -999};
146 geo::Vector_t showerDirection = {-999, -999, -999};
147 std::vector<art::Ptr<recob::SpacePoint>> trackSpacePoints;
149 ShowerEleHolder.
GetElement(fShowerStartPositionInputLabel, showerStartPosition);
150 ShowerEleHolder.
GetElement(fShowerDirectionInputLabel, showerDirection);
151 ShowerEleHolder.
GetElement(fInitialTrackSpacePointsInputLabel, trackSpacePoints);
154 double startXYZ[3] = {0, 0, 0};
155 auto startPoly = std::make_unique<TPolyMarker3D>(1, startXYZ);
159 double minProj = std::numeric_limits<double>::max();
160 double maxProj = -std::numeric_limits<double>::max();
162 double x_min = std::numeric_limits<double>::max(), x_max = -std::numeric_limits<double>::max();
163 double y_min = std::numeric_limits<double>::max(), y_max = -std::numeric_limits<double>::max();
164 double z_min = std::numeric_limits<double>::max(), z_max = -std::numeric_limits<double>::max();
170 auto showerPoly = std::make_unique<TPolyMarker3D>(showerSpacePoints.size());
171 for (
auto const& spacePoint : showerSpacePoints) {
172 auto const pos = spacePoint->position() - showerStartPosition;
176 x_min = std::min(x, x_min);
177 x_max = std::max(x, x_max);
178 y_min = std::min(y, y_min);
179 y_max = std::max(y, y_max);
180 z_min = std::min(z, z_min);
181 z_max = std::max(z, z_max);
183 showerPoly->SetPoint(point, x, y, z);
188 fLArPandoraShowerAlg.SpacePointProjection(spacePoint, showerStartPosition, showerDirection);
190 maxProj = std::max(proj, maxProj);
191 minProj = std::min(proj, minProj);
195 double xDirPoints[2] = {minProj * showerDirection.X(), maxProj * showerDirection.X()};
196 double yDirPoints[2] = {minProj * showerDirection.Y(), maxProj * showerDirection.Y()};
197 double zDirPoints[2] = {minProj * showerDirection.Z(), maxProj * showerDirection.Z()};
199 auto dirPoly = std::make_unique<TPolyLine3D>(2, xDirPoints, yDirPoints, zDirPoints);
202 auto trackPoly = std::make_unique<TPolyMarker3D>(trackSpacePoints.size());
203 for (
auto const& spacePoint : trackSpacePoints) {
204 auto const pos = spacePoint->position() - showerStartPosition;
208 trackPoly->SetPoint(point, x, y, z);
215 auto otherPoly = std::make_unique<TPolyMarker3D>(otherSpacePoints.size());
220 for (
auto const& sp : otherSpacePoints) {
221 auto const pos = sp->position() - showerStartPosition;
225 x_min = std::min(x, x_min);
226 x_max = std::max(x, x_max);
227 y_min = std::min(y, y_min);
228 y_max = std::max(y, y_max);
229 z_min = std::min(z, z_min);
230 z_max = std::max(z, z_max);
231 otherPoly->SetPoint(point, x, y, z);
235 gStyle->SetOptStat(0);
236 TH3F axes(
"axes",
"", 1, x_min, x_max, 1, y_min, y_max, 1, z_min, z_max);
237 axes.SetDirectory(0);
238 axes.GetXaxis()->SetTitle(
"X");
239 axes.GetYaxis()->SetTitle(
"Y");
240 axes.GetZaxis()->SetTitle(
"Z");
243 otherPoly->SetMarkerStyle(20);
244 otherPoly->SetMarkerColor(4);
248 showerPoly->SetMarkerStyle(20);
250 trackPoly->SetMarkerStyle(20);
251 trackPoly->SetMarkerColor(2);
253 startPoly->SetMarkerStyle(21);
254 startPoly->SetMarkerSize(2);
255 startPoly->SetMarkerColor(3);
257 dirPoly->SetLineWidth(1);
258 dirPoly->SetLineColor(6);
285 detinfo::DetectorClocksData
const& clockData,
286 std::map<
int, std::vector<int>>
const& ShowersMothers,
287 std::vector<art::Ptr<recob::Hit>>
const& hits,
291 art::ServiceHandle<cheat::BackTrackerService> bt_serv;
292 art::ServiceHandle<cheat::ParticleInventoryService> particleInventory;
295 std::map<int, double> trackIDToEDepMap;
296 std::map<int, double> trackIDTo3EDepMap;
297 for (std::vector<art::Ptr<recob::Hit>>::const_iterator hitIt = hits.begin(); hitIt != hits.end();
299 art::Ptr<recob::Hit> hit = *hitIt;
302 geo::WireID wireid = (*hitIt)->WireID();
303 int PlaneID = wireid.Plane;
304 std::vector<sim::TrackIDE> trackIDs = bt_serv->HitToTrackIDEs(clockData, hit);
305 for (
unsigned int idIt = 0; idIt < trackIDs.size(); ++idIt) {
306 trackIDTo3EDepMap[std::abs(trackIDs[idIt].trackID)] += trackIDs[idIt].energy;
307 if (PlaneID == planeid) {
308 trackIDToEDepMap[std::abs(trackIDs[idIt].trackID)] += trackIDs[idIt].energy;
314 std::map<int, double> MotherIDtoEMap;
315 std::map<int, double> MotherIDto3EMap;
316 for (std::map<
int, std::vector<int>>::const_iterator showermother = ShowersMothers.begin();
317 showermother != ShowersMothers.end();
319 for (std::vector<int>::const_iterator daughter = (showermother->second).begin();
320 daughter != (showermother->second).end();
322 MotherIDtoEMap[showermother->first] += trackIDToEDepMap[*daughter];
323 MotherIDto3EMap[showermother->first] += trackIDTo3EDepMap[*daughter];
328 double maxenergy = -1;
329 int objectTrack = -99999;
330 for (std::map<int, double>::iterator mapIt = MotherIDto3EMap.begin();
331 mapIt != MotherIDto3EMap.end();
333 double energy_three = mapIt->second;
334 double trackid = mapIt->first;
335 if (energy_three > maxenergy) {
336 maxenergy = energy_three;
337 objectTrack = trackid;
342 if (maxenergy == 0) {
return std::make_pair(-99999, -99999); }
344 return std::make_pair(objectTrack, MotherIDtoEMap[objectTrack]);