All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
reco3d::PlotSpacePoints Class Reference
Inheritance diagram for reco3d::PlotSpacePoints:

Public Member Functions

 PlotSpacePoints (const fhicl::ParameterSet &pset)
 

Private Member Functions

void analyze (const art::Event &evt) override
 
void Plot (const std::vector< recob::SpacePoint > &pts, const std::string &suffix) const
 
void Plot3D (const std::vector< recob::SpacePoint > &pts, const std::string &suffix) const
 
std::vector< recob::SpacePointTrueSpacePoints (detinfo::DetectorClocksData const &clockData, art::Handle< std::vector< recob::Hit >> hits) const
 

Private Attributes

art::InputTag fSpacePointTag
 
std::string fHitLabel
 
std::string fSuffix
 
bool fPlots
 
bool fPlots3D
 
bool fPlotsTrue
 

Detailed Description

Definition at line 24 of file PlotSpacePoints_module.cc.

Constructor & Destructor Documentation

reco3d::PlotSpacePoints::PlotSpacePoints ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 52 of file PlotSpacePoints_module.cc.

53  : EDAnalyzer(pset)
54  , fSpacePointTag(art::InputTag(pset.get<std::string>("SpacePointLabel"),
55  pset.get<std::string>("SpacePointInstanceLabel")))
56  , fHitLabel(pset.get<std::string>("HitLabel"))
57  , fSuffix(pset.get<std::string>("Suffix"))
58  , fPlots(pset.get<bool>("Plots"))
59  , fPlots3D(pset.get<bool>("Plots3D"))
60  , fPlotsTrue(pset.get<bool>("PlotsTrue"))
61  {
62  if (!fSuffix.empty()) fSuffix = "_" + fSuffix;
63  }

Member Function Documentation

void reco3d::PlotSpacePoints::analyze ( const art::Event &  evt)
overrideprivate

Definition at line 173 of file PlotSpacePoints_module.cc.

174  {
175  if (fPlots) {
176  art::Handle<std::vector<recob::SpacePoint>> pts;
177  evt.getByLabel(fSpacePointTag, pts);
178 
179  const std::string suffix = TString::Format("%s_%d", fSuffix.c_str(), evt.event()).Data();
180 
181  if (!pts->empty()) {
182  Plot(*pts, suffix);
183 
184  if (fPlots3D) Plot3D(*pts, suffix);
185  }
186  }
187 
188  if (fPlotsTrue) {
189  art::Handle<std::vector<recob::Hit>> hits;
190  evt.getByLabel(fHitLabel, hits);
191  auto const clockData =
192  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
193  const std::vector<recob::SpacePoint> pts = TrueSpacePoints(clockData, hits);
194 
195  const std::string suffix = TString::Format("%s_true_%d", fSuffix.c_str(), evt.event()).Data();
196 
197  Plot(pts, suffix);
198 
199  if (fPlots3D) Plot3D(pts, suffix);
200  }
201  }
std::vector< recob::SpacePoint > TrueSpacePoints(detinfo::DetectorClocksData const &clockData, art::Handle< std::vector< recob::Hit >> hits) const
unsigned int event
Definition: DataStructs.h:634
void Plot3D(const std::vector< recob::SpacePoint > &pts, const std::string &suffix) const
TCEvent evt
Definition: DataStructs.cxx:8
void Plot(const std::vector< recob::SpacePoint > &pts, const std::string &suffix) const
void reco3d::PlotSpacePoints::Plot ( const std::vector< recob::SpacePoint > &  pts,
const std::string &  suffix 
) const
private

Definition at line 67 of file PlotSpacePoints_module.cc.

68  {
69  TGraph gZX;
70  TGraph gYX;
71  TGraph gZY;
72 
73  gZX.SetTitle(";z;x");
74  gYX.SetTitle(";y;x");
75  gZY.SetTitle(";z;y");
76 
77  for (const recob::SpacePoint& pt : pts) {
78  const double* xyz = pt.XYZ();
79  const double x = xyz[0];
80  const double y = xyz[1];
81  const double z = xyz[2];
82  gZX.SetPoint(gZX.GetN(), z, x);
83  gYX.SetPoint(gYX.GetN(), y, x);
84  gZY.SetPoint(gZY.GetN(), z, y);
85  }
86 
87  if (gZX.GetN() == 0) gZX.SetPoint(0, 0, 0);
88  if (gYX.GetN() == 0) gYX.SetPoint(0, 0, 0);
89  if (gZY.GetN() == 0) gZY.SetPoint(0, 0, 0);
90 
91  gZX.Draw("ap");
92  gPad->Print(("plots/evd" + suffix + ".png").c_str());
93 
94  gYX.Draw("ap");
95  gPad->Print(("plots/evd_ortho" + suffix + ".png").c_str());
96  gZY.Draw("ap");
97  gPad->Print(("plots/evd_zy" + suffix + ".png").c_str());
98  }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
process_name opflash particleana ie ie y
void reco3d::PlotSpacePoints::Plot3D ( const std::vector< recob::SpacePoint > &  pts,
const std::string &  suffix 
) const
private

Definition at line 126 of file PlotSpacePoints_module.cc.

128  {
129  int frame = 0;
130  for (int phase = 0; phase < 4; ++phase) {
131  const int Nang = 20;
132  for (int iang = 0; iang < Nang; ++iang) {
133  const double ang = M_PI / 2 * iang / double(Nang);
134 
135  TGraph g;
136 
137  for (const recob::SpacePoint& p : pts) {
138  const double* xyz = p.XYZ();
139 
140  double x{}, y{};
141  if (phase == 0) {
142  x = cos(ang) * xyz[1] + sin(ang) * xyz[2];
143  y = xyz[0];
144  }
145  if (phase == 1) {
146  x = xyz[2];
147  y = cos(ang) * xyz[0] + sin(ang) * xyz[1];
148  }
149  if (phase == 2) {
150  x = cos(ang) * xyz[2] - sin(ang) * xyz[0];
151  y = xyz[1];
152  }
153  if (phase == 3) {
154  x = -cos(ang) * xyz[0] + sin(ang) * xyz[1];
155  y = cos(ang) * xyz[1] + sin(ang) * xyz[0];
156  }
157 
158  // const double phi = phase/3.*M_PI/2 + ang/3;
159  const double phi = 0;
160  g.SetPoint(g.GetN(), cos(phi) * x + sin(phi) * y, cos(phi) * y - sin(phi) * x);
161  }
162 
163  std::string fname =
164  TString::Format(("anim/evd3d" + suffix + "_%03d.png").c_str(), frame++).Data();
165  g.SetTitle(fname.c_str());
166  if (g.GetN()) g.Draw("ap");
167  gPad->Print(fname.c_str());
168  }
169  }
170  }
string fname
Definition: demo.py:5
process_name opflash particleana ie x
pdgs p
Definition: selectors.fcl:22
BEGIN_PROLOG g
process_name opflash particleana ie ie y
std::vector< recob::SpacePoint > reco3d::PlotSpacePoints::TrueSpacePoints ( detinfo::DetectorClocksData const &  clockData,
art::Handle< std::vector< recob::Hit >>  hits 
) const
private

Definition at line 102 of file PlotSpacePoints_module.cc.

104  {
105  std::vector<recob::SpacePoint> pts_true;
106 
107  const double err[6] = {
108  0,
109  };
110 
111  art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
112  for (unsigned int i = 0; i < hits->size(); ++i) {
113  try {
114  const std::vector<double> xyz = bt_serv->HitToXYZ(clockData, art::Ptr<recob::Hit>(hits, i));
115  pts_true.emplace_back(&xyz[0], err, 0);
116  }
117  catch (...) {
118  } // some hits have no electrons?
119  }
120 
121  return pts_true;
122  }
EResult err(const char *call)

Member Data Documentation

std::string reco3d::PlotSpacePoints::fHitLabel
private

Definition at line 40 of file PlotSpacePoints_module.cc.

bool reco3d::PlotSpacePoints::fPlots
private

Definition at line 44 of file PlotSpacePoints_module.cc.

bool reco3d::PlotSpacePoints::fPlots3D
private

Definition at line 45 of file PlotSpacePoints_module.cc.

bool reco3d::PlotSpacePoints::fPlotsTrue
private

Definition at line 46 of file PlotSpacePoints_module.cc.

art::InputTag reco3d::PlotSpacePoints::fSpacePointTag
private

Definition at line 38 of file PlotSpacePoints_module.cc.

std::string reco3d::PlotSpacePoints::fSuffix
private

Definition at line 42 of file PlotSpacePoints_module.cc.


The documentation for this class was generated from the following file: