84 std::cout <<
"Making Debug Event Display" << std::endl;
89 int run = Event.run();
90 int subRun = Event.subRun();
91 int event = Event.event();
92 int PFPID = pfparticle->Self();
95 TString canvasName = Form(
"canvas_%i_%i_%i_%i", run, subRun, event, PFPID);
96 TCanvas* canvas =
tfs->make<TCanvas>(canvasName, canvasName);
103 std::vector<art::Ptr<recob::SpacePoint>> showerSpacePoints;
104 std::vector<art::Ptr<recob::SpacePoint>> otherSpacePoints;
106 auto const hitHandle = Event.getValidHandle<std::vector<recob::Hit>>(
fHitModuleLabel);
107 std::vector<art::Ptr<recob::Hit>> hits;
108 art::fill_ptr_vector(hits, hitHandle);
111 const art::FindManyP<recob::SpacePoint> fmsph(hitHandle, Event,
fPFParticleLabel);
112 if (!fmsph.isValid()) {
113 throw cet::exception(
"LArPandoraShowerCheatingAlg")
114 <<
"Spacepoint and hit association not valid. Stopping.";
117 std::map<art::Ptr<recob::SpacePoint>, art::Ptr<recob::Hit>> spacePointHitMap;
119 for (
auto hit : hits) {
121 std::vector<art::Ptr<recob::SpacePoint>> sps = fmsph.at(
hit.key());
122 if (sps.size() == 1) {
123 art::Ptr<recob::SpacePoint> sp = sps.front();
124 if (trueParticleID == trueParticle->TrackId()) { showerSpacePoints.push_back(sp); }
126 otherSpacePoints.push_back(sp);
132 mf::LogError(
"LArPandoraShowerCheatingAlg")
133 <<
"Start position not set, returning " << std::endl;
137 mf::LogError(
"LArPandoraShowerCheatingAlg") <<
"Direction not set, returning " << std::endl;
141 mf::LogError(
"LArPandoraShowerCheatingAlg")
142 <<
"TrackSpacePoints not set, returning " << std::endl;
147 TVector3 showerStartPosition = {-999, -999, -999};
148 TVector3 showerDirection = {-999, -999, -999};
149 std::vector<art::Ptr<recob::SpacePoint>> trackSpacePoints;
156 double startXYZ[3] = {0, 0, 0};
157 auto startPoly = std::make_unique<TPolyMarker3D>(1, startXYZ);
161 double minProj = std::numeric_limits<double>::max();
162 double maxProj = -std::numeric_limits<double>::max();
164 double x_min = std::numeric_limits<double>::max(), x_max = -std::numeric_limits<double>::max();
165 double y_min = std::numeric_limits<double>::max(), y_max = -std::numeric_limits<double>::max();
166 double z_min = std::numeric_limits<double>::max(), z_max = -std::numeric_limits<double>::max();
172 auto showerPoly = std::make_unique<TPolyMarker3D>(showerSpacePoints.size());
173 for (
auto spacePoint : showerSpacePoints) {
179 x_min = std::min(x, x_min);
180 x_max = std::max(x, x_max);
181 y_min = std::min(y, y_min);
182 y_max = std::max(y, y_max);
183 z_min = std::min(z, z_min);
184 z_max = std::max(z, z_max);
186 showerPoly->SetPoint(point, x, y, z);
193 maxProj = std::max(proj, maxProj);
194 minProj = std::min(proj, minProj);
198 double xDirPoints[2] = {minProj * showerDirection.X(), maxProj * showerDirection.X()};
199 double yDirPoints[2] = {minProj * showerDirection.Y(), maxProj * showerDirection.Y()};
200 double zDirPoints[2] = {minProj * showerDirection.Z(), maxProj * showerDirection.Z()};
202 auto dirPoly = std::make_unique<TPolyLine3D>(2, xDirPoints, yDirPoints, zDirPoints);
205 auto trackPoly = std::make_unique<TPolyMarker3D>(trackSpacePoints.size());
206 for (
auto spacePoint : trackSpacePoints) {
211 trackPoly->SetPoint(point, x, y, z);
218 auto otherPoly = std::make_unique<TPolyMarker3D>(otherSpacePoints.size());
223 for (
auto const& sp : otherSpacePoints) {
228 x_min = std::min(x, x_min);
229 x_max = std::max(x, x_max);
230 y_min = std::min(y, y_min);
231 y_max = std::max(y, y_max);
232 z_min = std::min(z, z_min);
233 z_max = std::max(z, z_max);
234 otherPoly->SetPoint(point, x, y, z);
238 gStyle->SetOptStat(0);
239 TH3F axes(
"axes",
"", 1, x_min, x_max, 1, y_min, y_max, 1, z_min, z_max);
240 axes.SetDirectory(0);
241 axes.GetXaxis()->SetTitle(
"X");
242 axes.GetYaxis()->SetTitle(
"Y");
243 axes.GetZaxis()->SetTitle(
"Z");
246 otherPoly->SetMarkerStyle(20);
247 otherPoly->SetMarkerColor(4);
251 showerPoly->SetMarkerStyle(20);
253 trackPoly->SetMarkerStyle(20);
254 trackPoly->SetMarkerColor(2);
256 startPoly->SetMarkerStyle(21);
257 startPoly->SetMarkerSize(2);
258 startPoly->SetMarkerColor(3);
260 dirPoly->SetLineWidth(1);
261 dirPoly->SetLineColor(6);
process_name opflash particleana ie ie ie z
shower::LArPandoraShowerAlg fLArPandoraShowerAlg
process_name opflash particleana ie x
process_name opflash particleana ie ie y
std::string fShowerDirectionInputLabel
bool CheckElement(const std::string &Name) const
art::InputTag fHitModuleLabel
double SpacePointProjection(art::Ptr< recob::SpacePoint > const &sp, TVector3 const &vertex, TVector3 const &direction) const
int GetElement(const std::string &Name, T &Element) const
int TrueParticleID(detinfo::DetectorClocksData const &clockData, const art::Ptr< recob::Hit > &hit) const
std::string fShowerStartPositionInputLabel
std::string fInitialTrackSpacePointsInputLabel
art::ServiceHandle< art::TFileService > tfs
art::InputTag fPFParticleLabel
BEGIN_PROLOG could also be cout
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const