LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 35 of file AnalysisBaseDrawer.h.

Constructor & Destructor Documentation

evd::AnalysisBaseDrawer::AnalysisBaseDrawer ( )

Definition at line 53 of file AnalysisBaseDrawer.cxx.

54  {
55 
56  }
evd::AnalysisBaseDrawer::~AnalysisBaseDrawer ( )

Definition at line 59 of file AnalysisBaseDrawer.cxx.

60  {
61 
62  }

Member Function Documentation

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

Definition at line 343 of file AnalysisBaseDrawer.cxx.

References evdb::View2D::AddLatex(), evdb::View2D::AddLine(), evdb::View2D::AddPolyMarker(), evd::Style::ColorFromPDG(), anab::Calorimetry::dEdx(), evd::RecoDrawingOptions::fCaloPSet, trkf::BezierTrack::GetCalorimetryObject(), hits(), trkf::HitPtrVec::Hits, geo::kCollection, and anab::Calorimetry::ResidualRange().

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

348  {
349 
350  // slightly dirty workaround to get the hits passed on
351  std::vector<art::Ptr<recob::Hit> > hits = HitHider.Hits;
352 
356 
357 
358 
359  calo::CalorimetryAlg calalg(recoOpt->fCaloPSet);
360 
361 
362 
363  anab::Calorimetry cal = BTrack.GetCalorimetryObject(hits, geo::kCollection, calalg);
364 
365  TPolyMarker& pm = view->AddPolyMarker(cal.dEdx().size(),kOrange,8,0.8);
366  for(size_t h = 0; h!=cal.dEdx().size();++h){
367  pm.SetPoint(h,cal.ResidualRange().at(h), cal.dEdx().at(h));
368 
369 
370 
371  }
372 
373  char proton[80];
374  char kaon[80];
375  char pion[80];
376  char muon[80];
377  char mip[80];
378  char mip2[80];
379 
380  sprintf(proton,"Proton");
381  sprintf(kaon,"Kaon");
382  sprintf(pion,"Pion");
383  sprintf(muon,"Muon");
384 
385  sprintf(mip,"1 MIP");
386  sprintf(mip2,"2 MIP");
387  double offset = 0;
388  TLatex& proton_tex = view->AddLatex(40.0, (23.0-1.0) - offset,proton);
389  TLatex& kaon_tex = view->AddLatex(40.0, (23.0-2.0) - offset,kaon);
390  TLatex& pion_tex = view->AddLatex(40.0, (23.0-3.0) - offset,pion);
391  TLatex& muon_tex = view->AddLatex(40.0, (23.0-4.0) - offset,muon);
392  TLatex& mip_tex = view->AddLatex(40.0, (23.0-20.0) - offset,mip);
393  TLatex& mip2_tex = view->AddLatex(40.0, (23.0-18.0) - offset,mip2);
394  proton_tex.SetTextColor(Style::ColorFromPDG(2212));
395  kaon_tex.SetTextColor(Style::ColorFromPDG(321));
396  pion_tex.SetTextColor(Style::ColorFromPDG(211));
397  muon_tex.SetTextColor(Style::ColorFromPDG(13));
398 
399 
400  proton_tex.SetTextSize(0.03);
401  kaon_tex.SetTextSize(0.03);
402  pion_tex.SetTextSize(0.03);
403  muon_tex.SetTextSize(0.03);
404 
405  mip_tex.SetTextColor(kGray+3);
406  mip2_tex.SetTextColor(kGray+2);
407  mip_tex.SetTextSize(0.02);
408  mip2_tex.SetTextSize(0.02);
409 
410  double MIP = 1.5 * 1.4;
411  TLine & Line1Mip = view->AddLine(0, MIP, 100, MIP);
412  TLine & Line2Mip = view->AddLine(0, 2*MIP, 100, 2*MIP);
413 
414  Line1Mip.SetLineStyle(kDashed);
415  Line1Mip.SetLineColor(kGray+3);
416  Line2Mip.SetLineStyle(kDashed);
417  Line2Mip.SetLineColor(kGray+2);
418 
419 
420  }
TLine & AddLine(double x1, double y1, double x2, double y2)
Definition: View2D.cxx:187
const std::vector< float > & ResidualRange() const
Definition: Calorimetry.h:106
void hits()
Definition: readHits.C:15
TPolyMarker & AddPolyMarker(int n, int c, int st, double sz)
Definition: View2D.cxx:157
static int ColorFromPDG(int pdgcode)
Definition: Style.cxx:65
TLatex & AddLatex(double x, double y, const char *text)
Definition: View2D.cxx:308
const std::vector< float > & dEdx() const
Definition: Calorimetry.h:104
anab::Calorimetry GetCalorimetryObject(std::vector< art::Ptr< recob::Hit > > const &Hits, geo::SigType_t sigtype, calo::CalorimetryAlg const &)
fhicl::ParameterSet fCaloPSet
Signal from collection planes.
Definition: geo_types.h:93
void evd::AnalysisBaseDrawer::CalorShower ( const art::Event evt,
evdb::View2D view 
)

Definition at line 281 of file AnalysisBaseDrawer.cxx.

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

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

283  {
286 
287  for(size_t imod = 0; imod < recoOpt->fShowerLabels.size(); ++imod) {
288 
289  //Get Track collection
290  art::InputTag which = recoOpt->fShowerLabels[imod];
292  evt.getByLabel(which,caloListHandle);
293  std::vector<art::Ptr<anab::Calorimetry> > calolist;
294  art::fill_ptr_vector(calolist, caloListHandle);
295 
296 
297  //Loop over PID collections
298  for(size_t pmod = 0; pmod < anaOpt->fParticleIDLabels.size(); ++pmod) {
299  std::string const pidlabel = anaOpt->fParticleIDLabels[pmod];
300  //Association between Tracks and PID
301 
302  //Loop over Tracks
303  for(size_t shwIter = 0; shwIter<calolist.size(); ++shwIter){
304  int color = kRed;
305 
306  TPolyMarker& pm = view->AddPolyMarker((*calolist.at(shwIter)).dEdx().size(),color,8,0.8);
307  for(size_t h = 0; h<(*calolist.at(shwIter)).dEdx().size();++h){
308  pm.SetPoint(h,(*calolist.at(shwIter)).ResidualRange().at(h),(*calolist.at(shwIter)).dEdx().at(h));
309  }
310 
311 
312 
313  }
314  }
315  }
316 
317  char mip[80];
318  char mip2[80];
319 
320  sprintf(mip,"1 MIP");
321  sprintf(mip2,"2 MIP");
322  double offset = 0;
323 
324  double MIP = 2.12; // This is one mip in LAr, taken from uboone docdb #414
325  TLine & Line1Mip = view->AddLine(0, MIP, 100, MIP);
326  TLine & Line2Mip = view->AddLine(0, 2*MIP, 100, 2*MIP);
327 
328  TLatex& mip_tex = view->AddLatex(40.0, (23.0-20.0) - offset,mip);
329  TLatex& mip2_tex = view->AddLatex(40.0, (23.0-18.0) - offset,mip2);
330 
331  mip_tex.SetTextColor(kGray+3);
332  mip2_tex.SetTextColor(kGray+2);
333  mip_tex.SetTextSize(0.02);
334  mip2_tex.SetTextSize(0.02);
335 
336  Line1Mip.SetLineStyle(kDashed);
337  Line1Mip.SetLineColor(kGray+3);
338  Line2Mip.SetLineStyle(kDashed);
339  Line2Mip.SetLineColor(kGray+2);
340  }
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
std::size_t color(std::string const &procname)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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:464
void evd::AnalysisBaseDrawer::DrawDeDx ( const art::Event evt,
evdb::View2D view 
)

Definition at line 65 of file AnalysisBaseDrawer.cxx.

References evdb::View2D::AddLatex(), evdb::View2D::AddLine(), evdb::View2D::AddPolyMarker(), color(), evd::AnalysisDrawingOptions::fCaloPlane, evd::AnalysisDrawingOptions::fCalorimetryLabels, art::fill_ptr_vector(), evd::AnalysisDrawingOptions::fParticleIDLabels, evd::RecoDrawingOptions::fTrackLabels, art::DataViewImpl::getByLabel(), evd::kColor, evd::kNCOLS, and geo::GeometryCore::Nplanes().

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

67  {
71 
72  for(size_t imod = 0; imod < recoOpt->fTrackLabels.size(); ++imod) {
73 
74  //Get Track collection
75  art::InputTag which = recoOpt->fTrackLabels[imod];
76  art::Handle<std::vector<recob::Track> > trackListHandle;
77  evt.getByLabel(which,trackListHandle);
78  std::vector<art::Ptr<recob::Track> > tracklist;
79  art::fill_ptr_vector(tracklist, trackListHandle);
80 
81  //Loop over Calorimetry collections
82  for(size_t cmod = 0; cmod < anaOpt->fCalorimetryLabels.size(); ++cmod) {
83  std::string const callabel = anaOpt->fCalorimetryLabels[cmod];
84  //Association between Tracks and Calorimetry
85  art::FindMany<anab::Calorimetry> fmcal(trackListHandle, evt, callabel);
86  if (!fmcal.isValid()) continue;
87  //Loop over PID collections
88  for(size_t pmod = 0; pmod < anaOpt->fParticleIDLabels.size(); ++pmod) {
89  std::string const pidlabel = anaOpt->fParticleIDLabels[pmod];
90  //Association between Tracks and PID
91  art::FindMany<anab::ParticleID> fmpid(trackListHandle, evt, pidlabel);
92  if (!fmpid.isValid()) continue;
93 
94  //Loop over Tracks
95  for(size_t trkIter = 0; trkIter<tracklist.size(); ++trkIter){
96  int color = tracklist[trkIter].key()%evd::kNCOLS;
97  std::vector<const anab::Calorimetry*> calos = fmcal.at(trkIter);
98  std::vector<const anab::ParticleID*> pids = fmpid.at(trkIter);
99  if (!calos.size()) continue;
100  if (calos.size()!=pids.size()) continue;
101  size_t bestplane = 0;
102  size_t calopl = 0;
103  size_t pidpl = 0;
104  size_t nmaxhits = 0;
105  for (size_t icalo = 0; icalo < calos.size(); ++icalo){
106  if (calos[icalo]->dEdx().size() > nmaxhits){
107  nmaxhits = calos[icalo]->dEdx().size();
108  bestplane = calos[icalo]->PlaneID().Plane;
109  }
110  }
111  if (anaOpt->fCaloPlane>=0 and anaOpt->fCaloPlane<int(geom->Nplanes())){
112  for (size_t icalo = 0; icalo < calos.size(); ++icalo){
113  if (int(calos[icalo]->PlaneID().Plane)==anaOpt->fCaloPlane&&
114  calos[icalo]->dEdx().size())
115  bestplane = calos[icalo]->PlaneID().Plane;
116  }
117  }
118 
119  for (size_t icalo = 0; icalo < calos.size(); ++icalo){
120  if (calos[icalo]->PlaneID().Plane==bestplane){
121  calopl = icalo;
122  }
123  }
124  for (size_t ipid = 0; ipid < pids.size(); ++ipid){
125  if (pids[ipid]->PlaneID().Plane==bestplane){
126  pidpl = ipid;
127  }
128  }
129 
130  TPolyMarker& pm = view->AddPolyMarker(calos[calopl]->dEdx().size(),evd::kColor[color],8,0.8);
131  for(size_t h = 0; h<calos[calopl]->dEdx().size();++h){
132  double xvalue = calos[calopl]->ResidualRange().at(h);
133  double yvalue = calos[calopl]->dEdx().at(h);
134  pm.SetPoint(h,xvalue,yvalue);
135 
136  double error = yvalue*(0.04231 + 0.0001783*(yvalue*yvalue));
137  TLine& l = view->AddLine(xvalue,yvalue-error,xvalue,yvalue+error);
138  l.SetLineColor(evd::kColor[color]);
139  }
140 
141  char trackinfo[80];
142  char pida[80];
143  char proton[80];
144  //char kaon[80];
145  char pion[80];
146  //char muon[80];
147  sprintf(trackinfo,"Track #%d: K.E. = %.1f MeV , Range = %.1f cm",
148  int(tracklist[trkIter].key()),
149  calos[calopl]->KineticEnergy(),
150  calos[calopl]->Range());
151  sprintf(proton,"Proton Chi2 = %.1f, Kaon Chi2 = %.1f",
152  pids[pidpl]->Chi2Proton(),
153  pids[pidpl]->Chi2Kaon());
154 // sprintf(kaon,"Kaon Chi2 = %.1f",
155 // pids[pidpl]->Chi2Kaon());
156  sprintf(pion,"Pion Chi2 = %.1f, Muon Chi2 = %.1f",
157  pids[pidpl]->Chi2Pion(),
158  pids[pidpl]->Chi2Muon());
159 // sprintf(muon,"Muon Chi2 = %.1f",
160 // pids[pidpl]->Chi2Muon());
161  sprintf(pida,"Plane %d, PIDA = %.1f, NHits = %d",
162  calos[calopl]->PlaneID().Plane,
163  pids[pidpl]->PIDA(),
164  int(calos[calopl]->dEdx().size()));
165 
166  double offset = ((double)trkIter)*10.0;
167  TLatex& track_tex = view->AddLatex(13.0, (46.0) - offset,trackinfo);
168  TLatex& pida_tex = view->AddLatex(13.0, (46.0-2.5) - offset,pida);
169  TLatex& proton_tex = view->AddLatex(13.0, (46.0-5.0) - offset,proton);
170  //TLatex& kaon_tex = view->AddLatex(13.0, (46.0-4.0) - offset,kaon);
171  TLatex& pion_tex = view->AddLatex(13.0, (46.0-7.5) - offset,pion);
172  //TLatex& muon_tex = view->AddLatex(13.0, (46.0-8.0) - offset,muon);
173  track_tex.SetTextColor(evd::kColor[color]);
174  proton_tex.SetTextColor(evd::kColor[color]);
175  //kaon_tex.SetTextColor(evd::kColor[color]);
176  pion_tex.SetTextColor(evd::kColor[color]);
177  //muon_tex.SetTextColor(evd::kColor[color]);
178  pida_tex.SetTextColor(evd::kColor[color]);
179  track_tex.SetTextSize(0.05);
180  proton_tex.SetTextSize(0.05);
181  //kaon_tex.SetTextSize(0.05);
182  pion_tex.SetTextSize(0.05);
183  //muon_tex.SetTextSize(0.05);
184  pida_tex.SetTextSize(0.05);
185  }
186  }
187  }
188  }
189  }
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
static const int kNCOLS
Definition: eventdisplay.h:10
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
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
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 &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
recob::tracking::Plane Plane
Definition: TrackState.h:17
void evd::AnalysisBaseDrawer::DrawKineticEnergy ( const art::Event evt,
evdb::View2D view 
)

Definition at line 192 of file AnalysisBaseDrawer.cxx.

References evdb::View2D::AddLatex(), evdb::View2D::AddLine(), evdb::View2D::AddMarker(), color(), evd::AnalysisDrawingOptions::fCaloPlane, evd::AnalysisDrawingOptions::fCalorimetryLabels, art::fill_ptr_vector(), evd::AnalysisDrawingOptions::fParticleIDLabels, evd::RecoDrawingOptions::fTrackLabels, art::DataViewImpl::getByLabel(), evd::kColor, evd::kNCOLS, and geo::GeometryCore::Nplanes().

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

194  {
198  //add some legend-like labels with appropriate grayscale
199  char proton[80];
200  char kaon[80];
201  char pion[80];
202  char muon[80];
203  sprintf(proton,"proton");
204  sprintf(kaon,"kaon");
205  sprintf(pion,"pion");
206  sprintf(muon,"muon");
207  TLatex& proton_tex = view->AddLatex(2.0, 180.0,proton);
208  TLatex& kaon_tex = view->AddLatex(2.0, 165.0,kaon);
209  TLatex& pion_tex = view->AddLatex(2.0, 150.0,pion);
210  TLatex& muon_tex = view->AddLatex(2.0, 135.0,muon);
211  proton_tex.SetTextColor(kBlack);
212  kaon_tex.SetTextColor(kGray+2);
213  pion_tex.SetTextColor(kGray+1);
214  muon_tex.SetTextColor(kGray);
215  proton_tex.SetTextSize(0.075);
216  kaon_tex.SetTextSize(0.075);
217  pion_tex.SetTextSize(0.075);
218  muon_tex.SetTextSize(0.075);
219 
220  //now get the actual data
221  for(size_t imod = 0; imod < recoOpt->fTrackLabels.size(); ++imod) {
222  //Get Track collection
223  art::InputTag which = recoOpt->fTrackLabels[imod];
224  art::Handle<std::vector<recob::Track> > trackListHandle;
225  evt.getByLabel(which,trackListHandle);
226  std::vector<art::Ptr<recob::Track> > tracklist;
227  art::fill_ptr_vector(tracklist, trackListHandle);
228 
229  //Loop over Calorimetry collections
230  for(size_t cmod = 0; cmod < anaOpt->fCalorimetryLabels.size(); ++cmod) {
231  std::string const callabel = anaOpt->fCalorimetryLabels[cmod];
232  //Association between Tracks and Calorimetry
233  art::FindMany<anab::Calorimetry> fmcal(trackListHandle, evt, callabel);
234  if (!fmcal.isValid()) continue;
235 
236  //Loop over PID collections
237  for(size_t pmod = 0; pmod < anaOpt->fParticleIDLabels.size(); ++pmod) {
238  std::string const pidlabel = anaOpt->fParticleIDLabels[pmod];
239  //Association between Tracks and PID
240  art::FindMany<anab::ParticleID> fmpid(trackListHandle, evt, pidlabel);
241  if (!fmpid.isValid()) continue;
242 
243  //Loop over Tracks
244  for(size_t trkIter = 0; trkIter<tracklist.size(); ++trkIter){
245  int color = tracklist[trkIter].key()%evd::kNCOLS;
246 
247  std::vector<const anab::Calorimetry*> calos = fmcal.at(trkIter);
248  if (!calos.size()) continue;
249  size_t bestplane = 0;
250  size_t nmaxhits = 0;
251  for (size_t icalo = 0; icalo < calos.size(); ++icalo){
252  if (calos[icalo]->dEdx().size() > nmaxhits){
253  nmaxhits = calos[icalo]->dEdx().size();
254  bestplane = icalo;
255  }
256  }
257  if (anaOpt->fCaloPlane>=0 and anaOpt->fCaloPlane<int(geom->Nplanes())){
258  for (size_t i = 0; i<geom->Nplanes(); ++i){
259  if (int(calos[i]->PlaneID().Plane)==anaOpt->fCaloPlane)
260  bestplane = i;
261  }
262  }
263 
264  double xvalue = calos[bestplane]->Range();
265  double yvalue = calos[bestplane]->KineticEnergy();
266  view->AddMarker(xvalue,yvalue,evd::kColor[color],8,0.8);
267  if(yvalue>0.0){
268  double error = yvalue*(0.6064/std::sqrt(yvalue));
269  TLine& l = view->AddLine(xvalue,yvalue-error,xvalue,yvalue+error);
270  l.SetLineColor(evd::kColor[color]);
271  }
272 
273  }
274  }
275  }
276  }
277 
278  }
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
static const int kNCOLS
Definition: eventdisplay.h:10
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
std::vector< std::string > fCalorimetryLabels
module labels that produced calorimetry
TLatex & AddLatex(double x, double y, const char *text)
Definition: View2D.cxx:308
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 &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
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: