LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
evd::AnalysisBaseDrawer Class Reference

Aid in the rendering of AnalysisBase objects. More...

#include "AnalysisBaseDrawer.h"

Public Member Functions

 AnalysisBaseDrawer ()
 
 ~AnalysisBaseDrawer ()
 
void DrawDeDx (const art::Event &evt, evdb::View2D *view)
 
void DrawKineticEnergy (const art::Event &evt, evdb::View2D *view)
 
void CalorShower (const art::Event &evt, evdb::View2D *view)
 
void CalorInteractive (const art::Event &evt, evdb::View2D *view, trkf::BezierTrack BTrack, trkf::HitPtrVec Hits)
 

Detailed Description

Aid in the rendering of AnalysisBase objects.

Definition at line 20 of file AnalysisBaseDrawer.h.

Constructor & Destructor Documentation

evd::AnalysisBaseDrawer::AnalysisBaseDrawer ( )
default
evd::AnalysisBaseDrawer::~AnalysisBaseDrawer ( )
default

Member Function Documentation

void evd::AnalysisBaseDrawer::CalorInteractive ( const art::Event evt,
evdb::View2D view,
trkf::BezierTrack  BTrack,
trkf::HitPtrVec  Hits 
)
void evd::AnalysisBaseDrawer::CalorShower ( const art::Event evt,
evdb::View2D view 
)

Definition at line 221 of file AnalysisBaseDrawer.cxx.

References evdb::View2D::AddLatex(), evdb::View2D::AddLine(), evdb::View2D::AddPolyMarker(), color(), tca::dEdx(), art::fill_ptr_vector(), evd::AnalysisDrawingOptions::fParticleIDLabels, evd::RecoDrawingOptions::fShowerLabels, and art::ProductRetriever::getByLabel().

Referenced by evd::CalorPad::Draw().

222  {
225 
226  for (size_t imod = 0; imod < recoOpt->fShowerLabels.size(); ++imod) {
227 
228  //Get Track collection
229  art::InputTag which = recoOpt->fShowerLabels[imod];
231  evt.getByLabel(which, caloListHandle);
232  std::vector<art::Ptr<anab::Calorimetry>> calolist;
233  art::fill_ptr_vector(calolist, caloListHandle);
234 
235  //Loop over PID collections
236  for (size_t pmod = 0; pmod < anaOpt->fParticleIDLabels.size(); ++pmod) {
237  std::string const pidlabel = anaOpt->fParticleIDLabels[pmod];
238  //Association between Tracks and PID
239 
240  //Loop over Tracks
241  for (size_t shwIter = 0; shwIter < calolist.size(); ++shwIter) {
242  int color = kRed;
243 
244  TPolyMarker& pm =
245  view->AddPolyMarker((*calolist.at(shwIter)).dEdx().size(), color, 8, 0.8);
246  for (size_t h = 0; h < (*calolist.at(shwIter)).dEdx().size(); ++h) {
247  pm.SetPoint(h,
248  (*calolist.at(shwIter)).ResidualRange().at(h),
249  (*calolist.at(shwIter)).dEdx().at(h));
250  }
251  }
252  }
253  }
254 
255  char mip[80];
256  char mip2[80];
257 
258  sprintf(mip, "1 MIP");
259  sprintf(mip2, "2 MIP");
260  double offset = 0;
261 
262  double MIP = 2.12; // This is one mip in LAr, taken from uboone docdb #414
263  TLine& Line1Mip = view->AddLine(0, MIP, 100, MIP);
264  TLine& Line2Mip = view->AddLine(0, 2 * MIP, 100, 2 * MIP);
265 
266  TLatex& mip_tex = view->AddLatex(40.0, (23.0 - 20.0) - offset, mip);
267  TLatex& mip2_tex = view->AddLatex(40.0, (23.0 - 18.0) - offset, mip2);
268 
269  mip_tex.SetTextColor(kGray + 3);
270  mip2_tex.SetTextColor(kGray + 2);
271  mip_tex.SetTextSize(0.02);
272  mip2_tex.SetTextSize(0.02);
273 
274  Line1Mip.SetLineStyle(kDashed);
275  Line1Mip.SetLineColor(kGray + 3);
276  Line2Mip.SetLineStyle(kDashed);
277  Line2Mip.SetLineColor(kGray + 2);
278  }
std::vector< std::string > fParticleIDLabels
module labels that produced particleid
TLine & AddLine(double x1, double y1, double x2, double y2)
Definition: View2D.cxx:187
TPolyMarker & AddPolyMarker(int n, int c, int st, double sz)
Definition: View2D.cxx:157
TLatex & AddLatex(double x, double y, const char *text)
Definition: View2D.cxx:308
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2671
std::size_t color(std::string const &procname)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::vector< art::InputTag > fShowerLabels
module labels that produced showers
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
void evd::AnalysisBaseDrawer::DrawDeDx ( const art::Event evt,
evdb::View2D view 
)

Definition at line 34 of file AnalysisBaseDrawer.cxx.

References evdb::View2D::AddLatex(), evdb::View2D::AddLine(), evdb::View2D::AddPolyMarker(), color(), tca::dEdx(), evd::AnalysisDrawingOptions::fCaloPlane, evd::AnalysisDrawingOptions::fCalorimetryLabels, art::fill_ptr_vector(), evd::AnalysisDrawingOptions::fParticleIDLabels, evd::AnalysisDrawingOptions::fTrackID, evd::RecoDrawingOptions::fTrackLabels, Get, art::ProductRetriever::getByLabel(), evd::kColor, evd::kNCOLS, and util::size().

Referenced by evd::CalorPad::Draw().

35  {
38  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
39 
40  for (size_t imod = 0; imod < recoOpt->fTrackLabels.size(); ++imod) {
41 
42  //Get Track collection
43  art::InputTag which = recoOpt->fTrackLabels[imod];
45  evt.getByLabel(which, trackListHandle);
46  std::vector<art::Ptr<recob::Track>> tracklist;
47  art::fill_ptr_vector(tracklist, trackListHandle);
48 
49  //Loop over Calorimetry collections
50  for (size_t cmod = 0; cmod < anaOpt->fCalorimetryLabels.size(); ++cmod) {
51  std::string const callabel = anaOpt->fCalorimetryLabels[cmod];
52  //Association between Tracks and Calorimetry
53  art::FindMany<anab::Calorimetry> fmcal(trackListHandle, evt, callabel);
54  if (!fmcal.isValid()) continue;
55  //Loop over PID collections
56  for (size_t pmod = 0; pmod < anaOpt->fParticleIDLabels.size(); ++pmod) {
57  std::string const pidlabel = anaOpt->fParticleIDLabels[pmod];
58  //Association between Tracks and PID
59  art::FindMany<anab::ParticleID> fmpid(trackListHandle, evt, pidlabel);
60  if (!fmpid.isValid()) continue;
61 
62  //Loop over Tracks
63  int ntracks = 0;
64  for (size_t trkIter = 0; trkIter < tracklist.size(); ++trkIter) {
65  if (anaOpt->fTrackID >= 0 and tracklist[trkIter]->ID() != anaOpt->fTrackID) continue;
66  ++ntracks;
67  int color = tracklist[trkIter].key() % evd::kNCOLS;
68  std::vector<const anab::Calorimetry*> calos = fmcal.at(trkIter);
69  std::vector<const anab::ParticleID*> pids = fmpid.at(trkIter);
70  if (!calos.size()) continue;
71  if (calos.size() != pids.size()) continue;
72  size_t bestplane = 0;
73  size_t calopl = 0;
74  size_t nmaxhits = 0;
75  for (size_t icalo = 0; icalo < calos.size(); ++icalo) {
76  if (calos[icalo]->dEdx().size() > nmaxhits) {
77  nmaxhits = calos[icalo]->dEdx().size();
78  bestplane = calos[icalo]->PlaneID().Plane;
79  }
80  }
81  if (anaOpt->fCaloPlane >= 0 and anaOpt->fCaloPlane < int(wireReadoutGeom.Nplanes())) {
82  for (size_t icalo = 0; icalo < calos.size(); ++icalo) {
83  if (int(calos[icalo]->PlaneID().Plane) == anaOpt->fCaloPlane &&
84  calos[icalo]->dEdx().size())
85  bestplane = calos[icalo]->PlaneID().Plane;
86  }
87  }
88 
89  for (size_t icalo = 0; icalo < calos.size(); ++icalo) {
90  if (calos[icalo]->PlaneID().Plane == bestplane) { calopl = icalo; }
91  }
92 
93  TPolyMarker& pm =
94  view->AddPolyMarker(calos[calopl]->dEdx().size(), evd::kColor[color], 8, 0.8);
95  for (size_t h = 0; h < calos[calopl]->dEdx().size(); ++h) {
96  double xvalue = calos[calopl]->ResidualRange().at(h);
97  double yvalue = calos[calopl]->dEdx().at(h);
98  pm.SetPoint(h, xvalue, yvalue);
99 
100  double error = yvalue * (0.04231 + 0.0001783 * (yvalue * yvalue));
101  TLine& l = view->AddLine(xvalue, yvalue - error, xvalue, yvalue + error);
102  l.SetLineColor(evd::kColor[color]);
103  }
104 
105  char trackinfo[80];
106  char pida[80];
107  char proton[80];
108  char pion[80];
109  sprintf(trackinfo,
110  "Track #%d: K.E. = %.1f MeV , Range = %.1f cm",
111  int(tracklist[trkIter].key()),
112  calos[calopl]->KineticEnergy(),
113  calos[calopl]->Range());
114 
115  double offset = (ntracks - 1) * 10.0;
116  TLatex& track_tex = view->AddLatex(13.0, (46.0) - offset, trackinfo);
117  TLatex& pida_tex = view->AddLatex(13.0, (46.0 - 2.5) - offset, pida);
118  TLatex& proton_tex = view->AddLatex(13.0, (46.0 - 5.0) - offset, proton);
119  TLatex& pion_tex = view->AddLatex(13.0, (46.0 - 7.5) - offset, pion);
120  track_tex.SetTextColor(evd::kColor[color]);
121  proton_tex.SetTextColor(evd::kColor[color]);
122  pion_tex.SetTextColor(evd::kColor[color]);
123  pida_tex.SetTextColor(evd::kColor[color]);
124  track_tex.SetTextSize(0.05);
125  proton_tex.SetTextSize(0.05);
126  pion_tex.SetTextSize(0.05);
127  pida_tex.SetTextSize(0.05);
128  }
129  }
130  }
131  }
132  }
std::vector< art::InputTag > fTrackLabels
module labels that produced tracks
std::vector< std::string > fParticleIDLabels
module labels that produced particleid
TLine & AddLine(double x1, double y1, double x2, double y2)
Definition: View2D.cxx:187
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
static const int kNCOLS
Definition: eventdisplay.h:10
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
std::vector< std::string > fCalorimetryLabels
module labels that produced calorimetry
TPolyMarker & AddPolyMarker(int n, int c, int st, double sz)
Definition: View2D.cxx:157
TLatex & AddLatex(double x, double y, const char *text)
Definition: View2D.cxx:308
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2671
static const int kColor[kNCOLS]
Definition: eventdisplay.h:11
std::size_t color(std::string const &procname)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
recob::tracking::Plane Plane
Definition: TrackState.h:17
void evd::AnalysisBaseDrawer::DrawKineticEnergy ( const art::Event evt,
evdb::View2D view 
)

Definition at line 135 of file AnalysisBaseDrawer.cxx.

References evdb::View2D::AddLatex(), evdb::View2D::AddLine(), evdb::View2D::AddMarker(), color(), tca::dEdx(), evd::AnalysisDrawingOptions::fCaloPlane, evd::AnalysisDrawingOptions::fCalorimetryLabels, art::fill_ptr_vector(), evd::AnalysisDrawingOptions::fParticleIDLabels, evd::AnalysisDrawingOptions::fTrackID, evd::RecoDrawingOptions::fTrackLabels, Get, art::ProductRetriever::getByLabel(), evd::kColor, and evd::kNCOLS.

Referenced by evd::CalorPad::Draw().

136  {
139  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
140  //add some legend-like labels with appropriate grayscale
141  char proton[80];
142  char kaon[80];
143  char pion[80];
144  char muon[80];
145  sprintf(proton, "proton");
146  sprintf(kaon, "kaon");
147  sprintf(pion, "pion");
148  sprintf(muon, "muon");
149  TLatex& proton_tex = view->AddLatex(2.0, 180.0, proton);
150  TLatex& kaon_tex = view->AddLatex(2.0, 165.0, kaon);
151  TLatex& pion_tex = view->AddLatex(2.0, 150.0, pion);
152  TLatex& muon_tex = view->AddLatex(2.0, 135.0, muon);
153  proton_tex.SetTextColor(kBlack);
154  kaon_tex.SetTextColor(kGray + 2);
155  pion_tex.SetTextColor(kGray + 1);
156  muon_tex.SetTextColor(kGray);
157  proton_tex.SetTextSize(0.075);
158  kaon_tex.SetTextSize(0.075);
159  pion_tex.SetTextSize(0.075);
160  muon_tex.SetTextSize(0.075);
161 
162  //now get the actual data
163  for (size_t imod = 0; imod < recoOpt->fTrackLabels.size(); ++imod) {
164  //Get Track collection
165  art::InputTag which = recoOpt->fTrackLabels[imod];
166  art::Handle<std::vector<recob::Track>> trackListHandle;
167  evt.getByLabel(which, trackListHandle);
168  std::vector<art::Ptr<recob::Track>> tracklist;
169  art::fill_ptr_vector(tracklist, trackListHandle);
170 
171  //Loop over Calorimetry collections
172  for (size_t cmod = 0; cmod < anaOpt->fCalorimetryLabels.size(); ++cmod) {
173  std::string const callabel = anaOpt->fCalorimetryLabels[cmod];
174  //Association between Tracks and Calorimetry
175  art::FindMany<anab::Calorimetry> fmcal(trackListHandle, evt, callabel);
176  if (!fmcal.isValid()) continue;
177 
178  //Loop over PID collections
179  for (size_t pmod = 0; pmod < anaOpt->fParticleIDLabels.size(); ++pmod) {
180  std::string const pidlabel = anaOpt->fParticleIDLabels[pmod];
181  //Association between Tracks and PID
182  art::FindMany<anab::ParticleID> fmpid(trackListHandle, evt, pidlabel);
183  if (!fmpid.isValid()) continue;
184 
185  //Loop over Tracks
186  for (size_t trkIter = 0; trkIter < tracklist.size(); ++trkIter) {
187  if (anaOpt->fTrackID >= 0 and tracklist[trkIter]->ID() != anaOpt->fTrackID) continue;
188  int color = tracklist[trkIter].key() % evd::kNCOLS;
189 
190  std::vector<const anab::Calorimetry*> calos = fmcal.at(trkIter);
191  if (!calos.size()) continue;
192  size_t bestplane = 0;
193  size_t nmaxhits = 0;
194  for (size_t icalo = 0; icalo < calos.size(); ++icalo) {
195  if (calos[icalo]->dEdx().size() > nmaxhits) {
196  nmaxhits = calos[icalo]->dEdx().size();
197  bestplane = icalo;
198  }
199  }
200  if (anaOpt->fCaloPlane >= 0 and anaOpt->fCaloPlane < int(wireReadoutGeom.Nplanes())) {
201  for (size_t i = 0; i < wireReadoutGeom.Nplanes(); ++i) {
202  if (int(calos[i]->PlaneID().Plane) == anaOpt->fCaloPlane) bestplane = i;
203  }
204  }
205 
206  double xvalue = calos[bestplane]->Range();
207  double yvalue = calos[bestplane]->KineticEnergy();
208  view->AddMarker(xvalue, yvalue, evd::kColor[color], 8, 0.8);
209  if (yvalue > 0.0) {
210  double error = yvalue * (0.6064 / std::sqrt(yvalue));
211  TLine& l = view->AddLine(xvalue, yvalue - error, xvalue, yvalue + error);
212  l.SetLineColor(evd::kColor[color]);
213  }
214  }
215  }
216  }
217  }
218  }
std::vector< art::InputTag > fTrackLabels
module labels that produced tracks
std::vector< std::string > fParticleIDLabels
module labels that produced particleid
TLine & AddLine(double x1, double y1, double x2, double y2)
Definition: View2D.cxx:187
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
static const int kNCOLS
Definition: eventdisplay.h:10
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
std::vector< std::string > fCalorimetryLabels
module labels that produced calorimetry
TLatex & AddLatex(double x, double y, const char *text)
Definition: View2D.cxx:308
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2671
static const int kColor[kNCOLS]
Definition: eventdisplay.h:11
std::size_t color(std::string const &procname)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
recob::tracking::Plane Plane
Definition: TrackState.h:17
TMarker & AddMarker(double x, double y, int c, int st, double sz)
Definition: View2D.cxx:124

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