12 : m_className(
"ViewDrift"),
14 m_label(
"Drift Lines"),
16 m_hasExternalCanvas(false),
32 m_markerSizeCluster(1.),
33 m_markerSizeCollision(1.) {
35 m_driftLines.reserve(1000);
36 m_driftLinePlots.reserve(1000);
37 m_tracks.reserve(100);
38 m_trackPlots.reserve(100);
39 m_excMarkers.reserve(1000);
40 m_ionMarkers.reserve(1000);
41 m_attMarkers.reserve(1000);
46 if (!m_hasExternalCanvas && m_canvas)
delete m_canvas;
47 if (m_view)
delete m_view;
53 if (c == NULL)
return;
54 if (!m_hasExternalCanvas && m_canvas) {
59 m_hasExternalCanvas =
true;
64 const double& xmax,
const double& ymax,
68 if (xmin == xmax || ymin == ymax || zmin == zmax) {
69 std::cout << m_className <<
"::SetArea:\n";
70 std::cout <<
" Null area range not permitted.\n";
73 m_xMin = std::min(xmin, xmax);
74 m_yMin = std::min(ymin, ymax);
75 m_zMin = std::min(zmin, zmax);
76 m_xMax = std::max(xmin, xmax);
77 m_yMax = std::max(ymin, ymax);
78 m_zMax = std::max(zmin, zmax);
89 m_nExcMarkers = m_nIonMarkers = m_nAttMarkers = 0;
106 const unsigned int nTrackPlots = m_trackPlots.size();
107 for (
unsigned int i = 0; i < nTrackPlots; ++i) {
108 if (m_trackPlots[i])
delete m_trackPlots[i];
110 const unsigned int nTrackLinePlots = m_trackLinePlots.size();
111 for (
unsigned int i = 0; i < nTrackLinePlots; ++i) {
112 if (m_trackLinePlots[i])
delete m_trackLinePlots[i];
114 const unsigned int nDriftLinePlots = m_driftLinePlots.size();
115 for (
unsigned int i = 0; i < nDriftLinePlots; ++i) {
116 if (m_driftLinePlots[i])
delete m_driftLinePlots[i];
123 m_markerSizeCluster = size;
125 std::cerr << m_className <<
"::SetClusterMarkerSize:\n";
126 std::cerr <<
" Size must be positive.\n";
133 m_markerSizeCollision = size;
135 std::cerr << m_className <<
"::SetCollisionMarkerSize:\n";
136 std::cerr <<
" Size must be positive.\n";
141 const double x0,
const double y0,
149 std::vector<marker> p(1);
155 std::vector<marker> p(np);
156 for (
unsigned int i = 0; i < np; ++i) {
164 m_driftLines.push_back(d);
171 const double x0,
const double y0,
182 std::vector<marker> p(1, m0);
185 std::vector<marker> p(np, m0);
189 m_driftLines.push_back(d);
196 const double y0,
const double z0) {
206 std::vector<marker> p(1, m0);
209 std::vector<marker> p(np, m0);
213 m_driftLines.push_back(d);
220 const double z0,
const double x1,
221 const double y1,
const double z1) {
228 p.SetNextPoint(x0, y0, z0);
229 p.SetNextPoint(x1, y1, z1);
234 const double x0,
const double y0,
242 newTrack.vect.resize(1);
244 newTrack.vect.resize(np);
246 newTrack.vect[0].x = x0;
247 newTrack.vect[0].y = y0;
248 newTrack.vect[0].z = z0;
249 m_tracks.push_back(newTrack);
256 const double x,
const double y,
259 if (iL >= m_nDriftLines) {
260 std::cerr << m_className <<
"::SetDriftLinePoint:\n";
261 std::cerr <<
" Drift line index " << iL <<
" is out of range.\n";
264 m_driftLines[iL].vect[iP].x = x;
265 m_driftLines[iL].vect[iP].y = y;
266 m_driftLines[iL].vect[iP].z = z;
270 const double y,
const double z) {
272 if (iL >= m_nDriftLines) {
273 std::cerr << m_className <<
"::AddDriftLinePoint:\n";
274 std::cerr <<
" Drift line index " << iL <<
" is out of range.\n";
281 m_driftLines[iL].vect.push_back(m);
285 const double x,
const double y,
const double z) {
287 if (iL >= m_nTracks) {
288 std::cerr << m_className <<
"::SetTrackPoint:\n";
289 std::cerr <<
" Track index " << iL <<
" is out of range.\n";
292 m_tracks[iL].vect[iP].x = x;
293 m_tracks[iL].vect[iP].y = y;
294 m_tracks[iL].vect[iP].z = z;
298 const double y,
const double z) {
300 if (iL >= m_nTracks) {
301 std::cerr << m_className <<
"::AddTrackPoint:\n";
302 std::cerr <<
" Track index " << iL <<
" is out of range.\n";
309 m_tracks[iL].vect.push_back(newPoint);
319 m_excMarkers.push_back(newMarker);
330 m_ionMarkers.push_back(newMarker);
341 m_attMarkers.push_back(newMarker);
354void ViewDrift::Plot2d(
const bool axis) {
356 std::cout << m_className <<
"::Plot:\n";
357 std::cout <<
" Plotting in 2D.\n";
358 if (m_canvas == NULL) {
359 m_canvas =
new TCanvas();
360 m_canvas->SetTitle(m_label.c_str());
361 if (m_hasExternalCanvas) m_hasExternalCanvas =
false;
366 for (
unsigned int i = 0; i < m_nDriftLines; ++i) {
367 const unsigned int nPoints = m_driftLines[i].vect.size();
369 for (
unsigned int j = 0; j < nPoints; ++j) {
370 t.SetPoint(j, m_driftLines[i].vect[j].x, m_driftLines[i].vect[j].y);
372 t.SetLineColor(m_driftLines[i].n);
375 t.GetXaxis()->SetLimits(m_xMin, m_xMax);
376 t.GetHistogram()->SetMaximum(m_yMax);
377 t.GetHistogram()->SetMinimum(m_yMin);
379 t.DrawClone(
"ALsame");
381 t.DrawClone(
"Lsame");
384 t.DrawClone(
"Lsame");
390 for (
unsigned int i = 0; i < m_nTracks; ++i) {
391 const unsigned int nPoints = m_tracks[i].vect.size();
393 for (
unsigned int j = 0; j < nPoints; ++j) {
394 t.SetPoint(j, m_tracks[i].vect[j].x, m_tracks[i].vect[j].y);
396 t.SetLineColor(trackCol);
399 t.GetXaxis()->SetLimits(m_xMin, m_xMax);
400 t.GetHistogram()->SetMaximum(m_yMax);
401 t.GetHistogram()->SetMinimum(m_yMin);
402 if (axis && m_nDriftLines == 0) {
403 t.DrawClone(
"ALsame");
405 t.DrawClone(
"Lsame");
408 t.DrawClone(
"Lsame");
415void ViewDrift::Plot3d(
const bool axis) {
417 std::cout << m_className <<
"::Plot:\n";
418 std::cout <<
" Plotting in 3D.\n";
419 if (m_canvas == NULL) {
420 m_canvas =
new TCanvas();
421 m_canvas->SetTitle(m_label.c_str());
422 if (m_hasExternalCanvas) m_hasExternalCanvas =
false;
426 if (m_canvas->GetView() == NULL) {
427 if (m_view == NULL) m_view = TView::CreateView(1, 0, 0);
428 m_view->SetRange(m_xMin, m_yMin, m_zMin, m_xMax, m_yMax, m_zMax);
431 m_canvas->SetView(m_view);
435 for (
unsigned int i = 0; i < m_nDriftLines; ++i) {
436 const unsigned int nPoints = m_driftLines[i].vect.size();
437 TPolyLine3D* t =
new TPolyLine3D(nPoints);
438 for (
unsigned int j = 0; j < nPoints; ++j) {
439 t->SetNextPoint(m_driftLines[i].vect[j].x, m_driftLines[i].vect[j].y,
440 m_driftLines[i].vect[j].z);
442 t->SetLineColor(m_driftLines[i].n);
443 m_driftLinePlots.push_back(t);
447 for (
unsigned int i = 0; i < m_nTracks; ++i) {
448 const unsigned int nPoints = m_tracks[i].vect.size();
449 TPolyMarker3D* t =
new TPolyMarker3D(nPoints);
450 TPolyLine3D* l =
new TPolyLine3D(nPoints);
451 for (
unsigned int j = 0; j < nPoints; ++j) {
452 t->SetNextPoint(m_tracks[i].vect[j].x, m_tracks[i].vect[j].y,
453 m_tracks[i].vect[j].z);
454 l->SetNextPoint(m_tracks[i].vect[j].x, m_tracks[i].vect[j].y,
455 m_tracks[i].vect[j].z);
457 t->SetMarkerStyle(20);
458 t->SetMarkerColor(trackCol);
459 t->SetMarkerSize(m_markerSizeCluster);
461 m_trackPlots.push_back(t);
462 l->SetLineColor(trackCol);
465 m_trackLinePlots.push_back(l);
471 if (m_nExcMarkers > 0) {
472 m_excPlot =
new TPolyMarker3D(m_nExcMarkers);
474 m_excPlot->SetMarkerStyle(20);
475 m_excPlot->SetMarkerSize(m_markerSizeCollision);
476 for (
unsigned int i = 0; i < m_nExcMarkers; ++i) {
477 m_excPlot->SetNextPoint(m_excMarkers[i].x, m_excMarkers[i].y,
480 m_excPlot->Draw(
"same");
486 if (m_nIonMarkers > 0) {
487 m_ionPlot =
new TPolyMarker3D(m_nIonMarkers);
489 m_ionPlot->SetMarkerStyle(20);
490 m_ionPlot->SetMarkerSize(m_markerSizeCollision);
491 for (
unsigned int i = 0; i < m_nIonMarkers; ++i) {
492 m_ionPlot->SetNextPoint(m_ionMarkers[i].x, m_ionMarkers[i].y,
495 m_ionPlot->Draw(
"same");
501 if (m_nAttMarkers > 0) {
502 m_attPlot =
new TPolyMarker3D(m_nAttMarkers);
504 m_attPlot->SetMarkerStyle(20);
505 m_attPlot->SetMarkerSize(m_markerSizeCollision);
506 for (
unsigned int i = 0; i < m_nAttMarkers; ++i) {
507 m_attPlot->SetNextPoint(m_attMarkers[i].x, m_attMarkers[i].y,
510 m_attPlot->Draw(
"same");
int GetRootColorChargedParticle()
int GetRootColorElectron()
void NewElectronDriftLine(const unsigned int np, int &id, const double x0, const double y0, const double z0)
void AddExcitationMarker(const double x, const double y, const double z)
void AddIonisationMarker(const double x, const double y, const double z)
void SetArea(const double &xmin, const double &ymin, const double &zmin, const double &xmax, const double &ymax, const double &zmax)
void Plot(const bool twod=false, const bool axis=true)
void SetDriftLinePoint(const unsigned int iL, const unsigned int iP, const double x, const double y, const double z)
void AddAttachmentMarker(const double x, const double y, const double z)
void AddTrackPoint(const unsigned int iL, const double x, const double y, const double z)
void SetCollisionMarkerSize(const double &size)
void SetClusterMarkerSize(const double &size)
void NewChargedParticleTrack(const unsigned int np, int &id, const double x0, const double y0, const double z0)
void AddDriftLinePoint(const unsigned int iL, const double x, const double y, const double z)
void SetTrackPoint(const unsigned int iL, const unsigned int iP, const double x, const double y, const double z)
void SetCanvas(TCanvas *c)
void NewPhotonTrack(const double x0, const double y0, const double z0, const double x1, const double y1, const double z1)
void NewHoleDriftLine(const unsigned int np, int &id, const double x0, const double y0, const double z0)
void NewIonDriftLine(const unsigned int np, int &id, const double x0, const double y0, const double z0)
PlottingEngineRoot plottingEngine