Public Member Functions | List of all members
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 23 of file AnalysisBaseDrawer.h.

Constructor & Destructor Documentation

evd::AnalysisBaseDrawer::AnalysisBaseDrawer ( )

Definition at line 43 of file AnalysisBaseDrawer.cxx.

44  {
45 
46  }
evd::AnalysisBaseDrawer::~AnalysisBaseDrawer ( )

Definition at line 49 of file AnalysisBaseDrawer.cxx.

50  {
51 
52  }

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 280 of file AnalysisBaseDrawer.cxx.

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

Definition at line 55 of file AnalysisBaseDrawer.cxx.

57  {
61 
62  for(size_t imod = 0; imod < recoOpt->fTrackLabels.size(); ++imod) {
63 
64 
65  //Get Track collection
66  art::InputTag which = recoOpt->fTrackLabels[imod];
67  art::Handle<std::vector<recob::Track> > trackListHandle;
68  evt.getByLabel(which,trackListHandle);
69  std::vector<art::Ptr<recob::Track> > tracklist;
70  art::fill_ptr_vector(tracklist, trackListHandle);
71 
72  //Loop over Calorimetry collections
73  for(size_t cmod = 0; cmod < anaOpt->fCalorimetryLabels.size(); ++cmod) {
74  std::string const callabel = anaOpt->fCalorimetryLabels[cmod];
75  //Association between Tracks and Calorimetry
76  art::FindMany<anab::Calorimetry> fmcal(trackListHandle, evt, callabel);
77  if (!fmcal.isValid()) continue;
78  //Loop over PID collections
79  for(size_t pmod = 0; pmod < anaOpt->fParticleIDLabels.size(); ++pmod) {
80  std::string const pidlabel = anaOpt->fParticleIDLabels[pmod];
81  //Association between Tracks and PID
82  art::FindMany<anab::ParticleID> fmpid(trackListHandle, evt, pidlabel);
83  if (!fmpid.isValid()) continue;
84 
85  //Loop over Tracks
86  int ntracks = 0;
87  for(size_t trkIter = 0; trkIter<tracklist.size(); ++trkIter){
88  if (anaOpt->fTrackID >=0 and tracklist[trkIter]->ID() != anaOpt->fTrackID) continue;
89  ++ntracks;
90  int color = tracklist[trkIter].key()%evd::kNCOLS;
91  std::vector<const anab::Calorimetry*> calos = fmcal.at(trkIter);
92  std::vector<const anab::ParticleID*> pids = fmpid.at(trkIter);
93  if (!calos.size()) continue;
94  if (calos.size()!=pids.size()) continue;
95  size_t bestplane = 0;
96  size_t calopl = 0;
97  //size_t pidpl = 0;
98  size_t nmaxhits = 0;
99  for (size_t icalo = 0; icalo < calos.size(); ++icalo){
100  if (calos[icalo]->dEdx().size() > nmaxhits){
101  nmaxhits = calos[icalo]->dEdx().size();
102  bestplane = calos[icalo]->PlaneID().Plane;
103  }
104  }
105  if (anaOpt->fCaloPlane>=0 and anaOpt->fCaloPlane<int(geom->Nplanes())){
106  for (size_t icalo = 0; icalo < calos.size(); ++icalo){
107  if (int(calos[icalo]->PlaneID().Plane)==anaOpt->fCaloPlane&&
108  calos[icalo]->dEdx().size())
109  bestplane = calos[icalo]->PlaneID().Plane;
110  }
111  }
112 
113  for (size_t icalo = 0; icalo < calos.size(); ++icalo){
114  if (calos[icalo]->PlaneID().Plane==bestplane){
115  calopl = icalo;
116  }
117  }
118  /*
119  for (size_t ipid = 0; ipid < pids.size(); ++ipid){
120  if (pids[ipid]->PlaneID().Plane==bestplane){
121  pidpl = ipid;
122  }
123  }
124  */
125 
126  TPolyMarker& pm = view->AddPolyMarker(calos[calopl]->dEdx().size(),evd::kColor[color],8,0.8);
127  for(size_t h = 0; h<calos[calopl]->dEdx().size();++h){
128  double xvalue = calos[calopl]->ResidualRange().at(h);
129  double yvalue = calos[calopl]->dEdx().at(h);
130  pm.SetPoint(h,xvalue,yvalue);
131 
132  double error = yvalue*(0.04231 + 0.0001783*(yvalue*yvalue));
133  TLine& l = view->AddLine(xvalue,yvalue-error,xvalue,yvalue+error);
134  l.SetLineColor(evd::kColor[color]);
135  }
136 
137  char trackinfo[80];
138  char pida[80];
139  char proton[80];
140  //char kaon[80];
141  char pion[80];
142  //char muon[80];
143  sprintf(trackinfo,"Track #%d: K.E. = %.1f MeV , Range = %.1f cm",
144  int(tracklist[trkIter].key()),
145  calos[calopl]->KineticEnergy(),
146  calos[calopl]->Range());
147  /*
148  sprintf(proton,"Proton Chi2 = %.1f, Kaon Chi2 = %.1f",
149  pids[pidpl]->Chi2Proton(),
150  pids[pidpl]->Chi2Kaon());
151 // sprintf(kaon,"Kaon Chi2 = %.1f",
152 // pids[pidpl]->Chi2Kaon());
153  sprintf(pion,"Pion Chi2 = %.1f, Muon Chi2 = %.1f",
154  pids[pidpl]->Chi2Pion(),
155  pids[pidpl]->Chi2Muon());
156 // sprintf(muon,"Muon Chi2 = %.1f",
157 // pids[pidpl]->Chi2Muon());
158  sprintf(pida,"Plane %d, PIDA = %.1f, NHits = %d",
159  calos[calopl]->PlaneID().Plane,
160  pids[pidpl]->PIDA(),
161  int(calos[calopl]->dEdx().size()));
162 
163  */
164  double offset = (ntracks - 1)*10.0;
165  TLatex& track_tex = view->AddLatex(13.0, (46.0) - offset,trackinfo);
166  TLatex& pida_tex = view->AddLatex(13.0, (46.0-2.5) - offset,pida);
167  TLatex& proton_tex = view->AddLatex(13.0, (46.0-5.0) - offset,proton);
168  //TLatex& kaon_tex = view->AddLatex(13.0, (46.0-4.0) - offset,kaon);
169  TLatex& pion_tex = view->AddLatex(13.0, (46.0-7.5) - offset,pion);
170  //TLatex& muon_tex = view->AddLatex(13.0, (46.0-8.0) - offset,muon);
171  track_tex.SetTextColor(evd::kColor[color]);
172  proton_tex.SetTextColor(evd::kColor[color]);
173  //kaon_tex.SetTextColor(evd::kColor[color]);
174  pion_tex.SetTextColor(evd::kColor[color]);
175  //muon_tex.SetTextColor(evd::kColor[color]);
176  pida_tex.SetTextColor(evd::kColor[color]);
177  track_tex.SetTextSize(0.05);
178  proton_tex.SetTextSize(0.05);
179  //kaon_tex.SetTextSize(0.05);
180  pion_tex.SetTextSize(0.05);
181  //muon_tex.SetTextSize(0.05);
182  pida_tex.SetTextSize(0.05);
183  }
184  }
185  }
186  }
187  }
int ntracks
Definition: tracks.py:246
std::vector< art::InputTag > fTrackLabels
module labels that produced tracks
std::vector< std::string > fParticleIDLabels
module labels that produced particleid
std::string string
Definition: nybbler.cc:12
error
Definition: include.cc:26
static const int kNCOLS
Definition: eventdisplay.h:10
static QStrList * l
Definition: config.cpp:1044
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
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
def key(type, name=None)
Definition: graph.py:13
static const int kColor[kNCOLS]
Definition: eventdisplay.h:11
std::size_t color(std::string const &procname)
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
recob::tracking::Plane Plane
Definition: TrackState.h:17
void evd::AnalysisBaseDrawer::DrawKineticEnergy ( const art::Event evt,
evdb::View2D *  view 
)

Definition at line 190 of file AnalysisBaseDrawer.cxx.

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

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