12 : m_className(
"ViewDrift"),
15 m_hasExternalCanvas(false),
26 m_markerSizeCluster(1.),
27 m_markerSizeCollision(1.) {
29 m_driftLines.reserve(1000);
30 m_driftLinePlots.reserve(1000);
31 m_tracks.reserve(100);
32 m_trackPlots.reserve(100);
33 m_excMarkers.reserve(1000);
34 m_ionMarkers.reserve(1000);
35 m_attMarkers.reserve(1000);
40 if (!m_hasExternalCanvas && m_canvas)
delete m_canvas;
41 if (m_view)
delete m_view;
48 if (!m_hasExternalCanvas && m_canvas) {
53 m_hasExternalCanvas =
true;
58 const double xmax,
const double ymax,
62 if (xmin == xmax || ymin == ymax || zmin == zmax) {
63 std::cerr << m_className <<
"::SetArea: Null area range not permitted.\n";
66 m_xMin = std::min(xmin, xmax);
67 m_yMin = std::min(ymin, ymax);
68 m_zMin = std::min(zmin, zmax);
69 m_xMax = std::max(xmin, xmax);
70 m_yMax = std::max(ymin, ymax);
71 m_zMax = std::max(zmin, zmax);
95 const unsigned int nTrackPlots = m_trackPlots.size();
96 for (
unsigned int i = 0; i < nTrackPlots; ++i) {
97 if (m_trackPlots[i])
delete m_trackPlots[i];
99 const unsigned int nTrackLinePlots = m_trackLinePlots.size();
100 for (
unsigned int i = 0; i < nTrackLinePlots; ++i) {
101 if (m_trackLinePlots[i])
delete m_trackLinePlots[i];
103 const unsigned int nDriftLinePlots = m_driftLinePlots.size();
104 for (
unsigned int i = 0; i < nDriftLinePlots; ++i) {
105 if (m_driftLinePlots[i])
delete m_driftLinePlots[i];
112 m_markerSizeCluster = size;
114 std::cerr << m_className <<
"::SetClusterMarkerSize: Size must be > 0.\n";
121 m_markerSizeCollision = size;
123 std::cerr << m_className <<
"::SetCollisionMarkerSize: Size must be > 0.\n";
128 const double x0,
const double y0,
136 std::vector<Marker> p(1);
142 std::vector<Marker> p(np);
143 for (
unsigned int i = 0; i < np; ++i) {
151 m_driftLines.push_back(d);
153 id = m_driftLines.size() - 1;
157 const double x0,
const double y0,
168 std::vector<Marker> p(1, m0);
171 std::vector<Marker> p(np, m0);
175 m_driftLines.push_back(d);
177 id = m_driftLines.size() - 1;
181 const double y0,
const double z0) {
191 std::vector<Marker> p(1, m0);
194 std::vector<Marker> p(np, m0);
198 m_driftLines.push_back(d);
200 id = m_driftLines.size() - 1;
204 const double z0,
const double x1,
205 const double y1,
const double z1) {
212 p.SetNextPoint(x0, y0, z0);
213 p.SetNextPoint(x1, y1, z1);
217 const double x0,
const double y0,
221 std::vector<Marker> track(std::max(1U, np));
225 m_tracks.push_back(track);
227 id = m_tracks.size() - 1;
231 const double x,
const double y,
234 if (iL >= m_driftLines.size()) {
235 std::cerr << m_className <<
"::SetDriftLinePoint: Index out of range.\n";
238 m_driftLines[iL].vect[iP].x = x;
239 m_driftLines[iL].vect[iP].y = y;
240 m_driftLines[iL].vect[iP].z = z;
244 const double y,
const double z) {
246 if (iL >= m_driftLines.size()) {
247 std::cerr << m_className <<
"::AddDriftLinePoint: Index out of range.\n";
254 m_driftLines[iL].vect.push_back(m);
258 const double x,
const double y,
const double z) {
260 if (iL >= m_tracks.size()) {
261 std::cerr << m_className <<
"::SetTrackPoint: Index out of range.\n";
264 m_tracks[iL][iP].x = x;
265 m_tracks[iL][iP].y = y;
266 m_tracks[iL][iP].z = z;
270 const double y,
const double z) {
272 if (iL >= m_tracks.size()) {
273 std::cerr << m_className <<
"::AddTrackPoint: Index out of range.\n";
280 m_tracks[iL].push_back(newPoint);
290 m_excMarkers.push_back(newMarker);
300 m_ionMarkers.push_back(newMarker);
310 m_attMarkers.push_back(newMarker);
322void ViewDrift::Plot2d(
const bool axis) {
324 std::cout << m_className <<
"::Plot: Plotting in 2D.\n";
326 m_canvas =
new TCanvas();
327 if (m_hasExternalCanvas) m_hasExternalCanvas =
false;
332 const unsigned int nDriftLines = m_driftLines.size();
333 for (
unsigned int i = 0; i < nDriftLines; ++i) {
334 const unsigned int nPoints = m_driftLines[i].vect.size();
336 for (
unsigned int j = 0; j < nPoints; ++j) {
337 t.SetPoint(j, m_driftLines[i].vect[j].x, m_driftLines[i].vect[j].y);
339 t.SetLineColor(m_driftLines[i].n);
342 t.GetXaxis()->SetLimits(m_xMin, m_xMax);
343 t.GetHistogram()->SetMaximum(m_yMax);
344 t.GetHistogram()->SetMinimum(m_yMin);
346 t.DrawClone(
"ALsame");
348 t.DrawClone(
"Lsame");
351 t.DrawClone(
"Lsame");
357 const unsigned int nTracks = m_tracks.size();
358 for (
unsigned int i = 0; i < nTracks; ++i) {
359 const std::vector<Marker>& track = m_tracks[i];
360 const unsigned int nPoints = track.size();
362 for (
unsigned int j = 0; j < nPoints; ++j) {
363 t.SetPoint(j, track[j].x, track[j].y);
365 t.SetLineColor(trackCol);
368 t.GetXaxis()->SetLimits(m_xMin, m_xMax);
369 t.GetHistogram()->SetMaximum(m_yMax);
370 t.GetHistogram()->SetMinimum(m_yMin);
371 if (axis && m_driftLines.empty()) {
372 t.DrawClone(
"ALsame");
374 t.DrawClone(
"Lsame");
377 t.DrawClone(
"Lsame");
384void ViewDrift::Plot3d(
const bool axis) {
386 std::cout << m_className <<
"::Plot: Plotting in 3D.\n";
388 m_canvas =
new TCanvas();
389 if (m_hasExternalCanvas) m_hasExternalCanvas =
false;
393 if (!m_canvas->GetView()) {
394 if (!m_view) m_view = TView::CreateView(1, 0, 0);
395 m_view->SetRange(m_xMin, m_yMin, m_zMin, m_xMax, m_yMax, m_zMax);
398 m_canvas->SetView(m_view);
402 const unsigned int nDriftLines = m_driftLines.size();
403 for (
unsigned int i = 0; i < nDriftLines; ++i) {
404 const unsigned int nPoints = m_driftLines[i].vect.size();
405 TPolyLine3D* t =
new TPolyLine3D(nPoints);
406 for (
unsigned int j = 0; j < nPoints; ++j) {
407 t->SetNextPoint(m_driftLines[i].vect[j].x, m_driftLines[i].vect[j].y,
408 m_driftLines[i].vect[j].z);
410 t->SetLineColor(m_driftLines[i].n);
411 m_driftLinePlots.push_back(t);
415 const unsigned int nTracks = m_tracks.size();
416 for (
unsigned int i = 0; i < nTracks; ++i) {
417 const std::vector<Marker>& track = m_tracks[i];
418 const unsigned int nPoints = track.size();
419 TPolyMarker3D* t =
new TPolyMarker3D(nPoints);
420 TPolyLine3D* l =
new TPolyLine3D(nPoints);
421 for (
unsigned int j = 0; j < nPoints; ++j) {
422 t->SetNextPoint(track[j].x, track[j].y, track[j].z);
423 l->SetNextPoint(track[j].x, track[j].y, track[j].z);
425 t->SetMarkerStyle(20);
426 t->SetMarkerColor(trackCol);
427 t->SetMarkerSize(m_markerSizeCluster);
429 m_trackPlots.push_back(t);
430 l->SetLineColor(trackCol);
433 m_trackLinePlots.push_back(l);
439 if (!m_excMarkers.empty()) {
440 const unsigned int nExcMarkers = m_excMarkers.size();
441 m_excPlot =
new TPolyMarker3D(nExcMarkers);
443 m_excPlot->SetMarkerStyle(20);
444 m_excPlot->SetMarkerSize(m_markerSizeCollision);
445 for (
unsigned int i = 0; i < nExcMarkers; ++i) {
446 m_excPlot->SetNextPoint(m_excMarkers[i].x, m_excMarkers[i].y,
449 m_excPlot->Draw(
"same");
455 if (!m_ionMarkers.empty()) {
456 const unsigned int nIonMarkers = m_ionMarkers.size();
457 m_ionPlot =
new TPolyMarker3D(nIonMarkers);
459 m_ionPlot->SetMarkerStyle(20);
460 m_ionPlot->SetMarkerSize(m_markerSizeCollision);
461 for (
unsigned int i = 0; i < nIonMarkers; ++i) {
462 m_ionPlot->SetNextPoint(m_ionMarkers[i].x, m_ionMarkers[i].y,
465 m_ionPlot->Draw(
"same");
471 if (!m_attMarkers.empty()) {
472 const unsigned int nAttMarkers = m_attMarkers.size();
473 m_attPlot =
new TPolyMarker3D(nAttMarkers);
475 m_attPlot->SetMarkerStyle(20);
476 m_attPlot->SetMarkerSize(m_markerSizeCollision);
477 for (
unsigned int i = 0; i < nAttMarkers; ++i) {
478 m_attPlot->SetNextPoint(m_attMarkers[i].x, m_attMarkers[i].y,
481 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 Plot(const bool twod=false, const bool axis=true)
Draw the drift lines.
void SetDriftLinePoint(const unsigned int iL, const unsigned int iP, 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)
Set the region to be plotted.
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 SetClusterMarkerSize(const double size)
Set the size of the cluster markers (see TAttMarker).
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 Clear()
Delete existing drift lines, tracks and markers.
void SetCanvas(TCanvas *c)
Set the canvas to be painted on.
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)
void SetCollisionMarkerSize(const double size)
Set the size of the collision markers (see TAttMarker).
PlottingEngineRoot plottingEngine