21#include "TRestTrackEvent.h"
24#include "TRestTools.h"
30TRestTrackEvent::TRestTrackEvent() {
45 fPrintHitsWarning =
true;
48TRestTrackEvent::~TRestTrackEvent() {
61 if (c->isXZ()) fNtracksX++;
62 if (c->isYZ()) fNtracksY++;
65 fTrack.emplace_back(*c);
70void TRestTrackEvent::RemoveTrack(
int n) {
71 if (fTrack[n].isXZ()) fNtracksX--;
72 if (fTrack[n].isYZ()) fNtracksY--;
75 fTrack.erase(fTrack.begin() + n);
80Int_t TRestTrackEvent::GetNumberOfTracks(TString option) {
85 for (
int n = 0; n < GetNumberOfTracks(); n++) {
86 if (!this->isTopLevel(n))
continue;
88 if (option ==
"X" && GetTrack(n)->isXZ())
90 else if (option ==
"Y" && GetTrack(n)->isYZ())
92 else if (option ==
"XYZ" && GetTrack(n)->isXYZ())
102TRestTrack* TRestTrackEvent::GetTrackById(Int_t
id) {
103 for (
int i = 0; i < GetNumberOfTracks(); i++)
104 if (GetTrack(i)->GetTrackID() == id)
return GetTrack(i);
108TRestTrack* TRestTrackEvent::GetMaxEnergyTrackInX() {
110 Double_t maxEnergy = 0;
111 for (
int tck = 0; tck < GetNumberOfTracks(); tck++) {
112 if (!this->isTopLevel(tck))
continue;
116 if (t->GetEnergy() > maxEnergy) {
117 maxEnergy = t->GetEnergy();
123 if (track == -1)
return nullptr;
125 return GetTrack(track);
128TRestTrack* TRestTrackEvent::GetMaxEnergyTrackInY() {
130 Double_t maxEnergy = 0;
131 for (
int tck = 0; tck < GetNumberOfTracks(); tck++) {
132 if (!this->isTopLevel(tck))
continue;
136 if (t->GetEnergy() > maxEnergy) {
137 maxEnergy = t->GetEnergy();
143 if (track == -1)
return nullptr;
145 return GetTrack(track);
148TRestTrack* TRestTrackEvent::GetMaxEnergyTrack(TString option) {
149 if (option ==
"X")
return GetMaxEnergyTrackInX();
150 if (option ==
"Y")
return GetMaxEnergyTrackInY();
153 Double_t maxEnergy = 0;
154 for (
int tck = 0; tck < GetNumberOfTracks(); tck++) {
155 if (!this->isTopLevel(tck))
continue;
159 if (t->GetEnergy() > maxEnergy) {
160 maxEnergy = t->GetEnergy();
166 if (track == -1)
return nullptr;
168 return GetTrack(track);
171TRestTrack* TRestTrackEvent::GetSecondMaxEnergyTrack(TString option) {
172 if (GetMaxEnergyTrack(option) ==
nullptr)
return nullptr;
174 Int_t
id = GetMaxEnergyTrack(option)->GetTrackID();
177 Double_t maxEnergy = 0;
178 for (
int tck = 0; tck < GetNumberOfTracks(); tck++) {
179 if (!this->isTopLevel(tck))
continue;
182 if (t->GetTrackID() ==
id)
continue;
184 Double_t en = t->GetEnergy();
186 if (option ==
"X" && (t->isXZ() || t->isXYZ())) {
187 if (en > maxEnergy) {
188 maxEnergy = t->GetEnergy();
191 }
else if (option ==
"Y" && (t->isYZ() || t->isXYZ())) {
192 if (t->GetEnergy() > maxEnergy) {
193 maxEnergy = t->GetEnergy();
196 }
else if (t->isXYZ()) {
197 if (t->GetEnergy() > maxEnergy) {
198 maxEnergy = t->GetEnergy();
204 if (track == -1)
return nullptr;
206 return GetTrack(track);
209Double_t TRestTrackEvent::GetMaxEnergyTrackVolume(TString option) {
210 if (this->GetMaxEnergyTrack(option))
return this->GetMaxEnergyTrack(option)->GetVolume();
214Double_t TRestTrackEvent::GetMaxEnergyTrackLength(TString option) {
215 if (this->GetMaxEnergyTrack(option))
return this->GetMaxEnergyTrack(option)->GetLength();
219Double_t TRestTrackEvent::GetEnergy(TString option) {
221 for (
int tck = 0; tck < this->GetNumberOfTracks(); tck++) {
222 if (!this->isTopLevel(tck))
continue;
227 en += t->GetEnergy();
229 else if (option ==
"X" && (t->isXZ() || t->isXYZ()))
230 en += t->GetEnergy();
232 else if (option ==
"Y" && (t->isYZ() || t->isXYZ()))
233 en += t->GetEnergy();
235 else if (option ==
"XYZ" && t->isXYZ())
236 en += t->GetEnergy();
242Bool_t TRestTrackEvent::isXYZ() {
243 for (
int tck = 0; tck < GetNumberOfTracks(); tck++)
244 if (!fTrack[tck].isXYZ())
return false;
248Int_t TRestTrackEvent::GetTotalHits() {
250 for (
int tck = 0; tck < GetNumberOfTracks(); tck++) totHits += GetTrack(tck)->GetNumberOfHits();
254Int_t TRestTrackEvent::GetLevel(Int_t tck) {
256 Int_t parentTrackId = GetTrack(tck)->GetParentID();
258 while (parentTrackId > 0) {
260 parentTrackId = GetTrackById(parentTrackId)->GetParentID();
265Bool_t TRestTrackEvent::isTopLevel(Int_t tck) {
266 if (GetLevels() == GetLevel(tck))
return true;
270Int_t TRestTrackEvent::GetOriginTrackID(Int_t tck) {
271 Int_t originTrackID = tck;
272 Int_t pID = GetTrack(tck)->GetParentID();
276 pID = GetTrackById(originTrackID)->GetParentID();
279 return originTrackID;
282TRestTrack* TRestTrackEvent::GetOriginTrack(Int_t tck) {
283 Int_t originTrackID = GetTrack(tck)->GetTrackID();
284 Int_t pID = GetTrackById(originTrackID)->GetParentID();
288 pID = GetTrackById(originTrackID)->GetParentID();
291 return GetTrackById(originTrackID);
294TRestTrack* TRestTrackEvent::GetOriginTrackById(Int_t tckId) {
295 Int_t originTrackID = tckId;
296 Int_t pID = GetTrackById(tckId)->GetParentID();
300 pID = GetTrackById(originTrackID)->GetParentID();
303 return GetTrackById(originTrackID);
306void TRestTrackEvent::SetLevels() {
309 for (
int tck = 0; tck < GetNumberOfTracks(); tck++) {
310 Int_t lvl = GetLevel(tck);
311 if (maxLevel < lvl) maxLevel = lvl;
329 if (tckX ==
nullptr || tckY ==
nullptr) {
330 RESTWarning <<
"Track is empty, skipping" << RESTendl;
337 const int nHits = std::min(hitsX.GetNumberOfHits(), hitsY.GetNumberOfHits());
340 for (
int i = 0; i < nHits; i++) {
341 double enX = hitsX.GetEnergy(i);
342 double enY = hitsY.GetEnergy(i);
343 double posXZ = hitsX.GetZ(i);
344 double posYZ = hitsY.GetZ(i);
345 double avgZ = (enX * posXZ + enY * posYZ) / (enX + enY);
346 best3DHits.AddHit(hitsX.GetX(i), hitsY.GetY(i), avgZ, enX + enY, 0, XYZ, 0, 0, 0);
347 const int j = nHits - i - 1;
348 enY = hitsY.GetEnergy(j);
349 posYZ = hitsY.GetZ(j);
350 avgZ = (enX * posXZ + enY * posYZ) / (enX + enY);
351 hits3D.AddHit(hitsX.GetX(i), hitsY.GetY(j), avgZ, enX + enY, 0, XYZ, 0, 0, 0);
361 for (
unsigned int i = 0; i < best3DHits.GetNumberOfHits(); i++) {
362 totEn += best3DHits.GetEnergy(i);
366 const TVector3 posE = best3DHits.
GetPosition(best3DHits.GetNumberOfHits() - 1);
369 unsigned int pos = 0;
370 for (pos = 0; pos < best3DHits.GetNumberOfHits(); pos++) {
371 integ += best3DHits.GetEnergy(pos);
372 if (integ > totEn / 2.)
break;
376 const double intToFirst = (pos0 - intPos).Mag();
377 const double intToLast = (posE - intPos).Mag();
379 RESTDebug <<
"Integ pos " << pos <<
" Pos to first " << intToFirst <<
" last " << intToLast << RESTendl;
380 if (intToFirst < intToLast) {
388 RESTDebug <<
"Origin " << orig.X() <<
" " << orig.Y() <<
" " << orig.Z() << RESTendl;
389 RESTDebug <<
"End " << end.X() <<
" " << end.Y() <<
" " << end.Z() << RESTendl;
404 if (tckX ==
nullptr || tckY ==
nullptr) {
405 RESTWarning <<
"Track is empty, skipping" << RESTendl;
409 TVector3 origX, endX;
412 TVector3 origY, endY;
416 double originZ = (origX.Z() + origY.Z()) / 2.;
417 double endZ = (endX.Z() + endY.Z()) / 2.;
419 orig = TVector3(origX.X(), origY.Y(), originZ);
420 end = TVector3(endX.X(), endY.Y(), endZ);
431 if (tckX ==
nullptr || tckY ==
nullptr) {
432 RESTWarning <<
"Track is empty, skipping" << RESTendl;
436 std::vector<std::pair<double, double> > zEn;
439 for (
size_t i = 0; i < tckX->GetVolumeHits()->GetNumberOfHits(); i++) {
440 double en = tckX->GetVolumeHits()->GetEnergy(i);
441 double z = tckX->GetVolumeHits()->GetZ(i);
442 zEn.emplace_back(std::make_pair(z, en));
446 for (
size_t i = 0; i < tckY->GetVolumeHits()->GetNumberOfHits(); i++) {
447 double en = tckY->GetVolumeHits()->GetEnergy(i);
448 double z = tckY->GetVolumeHits()->GetZ(i);
449 zEn.emplace_back(std::make_pair(z, en));
453 std::sort(zEn.begin(), zEn.end());
457 for (pos = 0; pos < zEn.size(); pos++) {
458 integ += zEn[pos].second;
459 if (integ >= totEn / 2.)
break;
462 double length = zEn.front().first - zEn.back().first;
463 double diff = zEn.front().first - zEn[pos].first;
468 return diff / length;
471void TRestTrackEvent::PrintOnlyTracks() {
472 cout <<
"TrackEvent " << GetID() << endl;
473 cout <<
"-----------------------" << endl;
474 for (
int i = 0; i < GetNumberOfTracks(); i++) {
475 cout <<
"Track " << i <<
" id : " << GetTrack(i)->GetTrackID()
476 <<
" parent : " << GetTrack(i)->GetParentID() << endl;
478 cout <<
"-----------------------" << endl;
479 cout <<
"Track levels : " << GetLevels() << endl;
485 cout <<
"Number of tracks : "
486 << GetNumberOfTracks(
"XYZ") + GetNumberOfTracks(
"X") + GetNumberOfTracks(
"Y") << endl;
487 cout <<
"Number of tracks XZ " << GetNumberOfTracks(
"X") << endl;
488 cout <<
"Number of tracks YZ " << GetNumberOfTracks(
"Y") << endl;
489 cout <<
"Track levels : " << GetLevels() << endl;
490 cout <<
"+++++++++++++++++++++++++++++++++++" << endl;
491 for (
int i = 0; i < GetNumberOfTracks(); i++) this->GetTrack(i)->PrintTrack(fullInfo);
494TPad* TRestTrackEvent::DrawHits() {
508 std::vector<double> fX, fY, fZ;
510 for (
int t = 0; t < GetNumberOfTracks(); t++) {
512 if (GetLevel(t) != 1)
continue;
514 for (
unsigned int i = 0; i < hits->GetNumberOfHits(); i++) {
515 if (hits->GetType(i) % X == 0) fX.emplace_back(hits->GetX(i));
516 if (hits->GetType(i) % Y == 0) fY.emplace_back(hits->GetY(i));
517 if (hits->GetType(i) % Z == 0) fZ.emplace_back(hits->GetZ(i));
521 double maxX, minX, maxY, minY, maxZ, minZ;
522 int nBinsX, nBinsY, nBinsZ;
527 fXZHits =
new TH2F(
"TXZ",
"TXZ", nBinsX, minX, maxX, nBinsZ, minZ, maxZ);
528 fYZHits =
new TH2F(
"TYZ",
"TYZ", nBinsY, minY, maxY, nBinsZ, minZ, maxZ);
530 for (
int t = 0; t < GetNumberOfTracks(); t++) {
532 if (GetLevel(t) != 1)
continue;
534 for (
unsigned int i = 0; i < hits->GetNumberOfHits(); i++) {
535 if (hits->GetType(i) == XZ) fXZHits->Fill(hits->GetX(i), hits->GetZ(i), hits->GetEnergy(i));
536 if (hits->GetType(i) == YZ) fYZHits->Fill(hits->GetY(i), hits->GetZ(i), hits->GetEnergy(i));
540 fHitsPad =
new TPad(
"TrackHits",
"TrackHits", 0, 0, 1, 1);
541 fHitsPad->Divide(2, 1);
545 fXZHits->GetXaxis()->SetTitle(
"X-axis (mm)");
546 fXZHits->GetYaxis()->SetTitle(
"Z-axis (mm)");
547 fXZHits->Draw(
"COLZ");
550 fYZHits->GetXaxis()->SetTitle(
"Y-axis (mm)");
551 fYZHits->GetYaxis()->SetTitle(
"Z-axis (mm)");
552 fYZHits->Draw(
"COLZ");
572 for (
unsigned int n = 0; n < optList.size(); n++) {
573 if (optList[n] ==
"print") this->
PrintEvent();
574 if (optList[n] ==
"noWarning") fPrintHitsWarning =
false;
577 optList.erase(std::remove(optList.begin(), optList.end(),
"print"), optList.end());
578 optList.erase(std::remove(optList.begin(), optList.end(),
"noWarning"), optList.end());
580 for (
unsigned int n = 0; n < optList.size(); n++) {
588 string opt = optList[n];
590 if (opt.find(
"maxLevel=") != string::npos) maxLevel = stoi(opt.substr(9, opt.length()).c_str());
592 if (opt.find(
"minLevel=") != string::npos) minLevel = stoi(opt.substr(9, opt.length()).c_str());
595 if (fXYHit !=
nullptr) {
599 if (fXZHit !=
nullptr) {
603 if (fYZHit !=
nullptr) {
607 if (fXYZHit !=
nullptr) {
611 if (fXYTrack !=
nullptr) {
615 if (fXZTrack !=
nullptr) {
619 if (fYZTrack !=
nullptr) {
623 if (fXYZTrack !=
nullptr) {
627 if (fPad !=
nullptr) {
632 int nTracks = this->GetNumberOfTracks();
635 cout <<
"Empty event " << endl;
641 double maxX = -1e10, minX = 1e10, maxZ = -1e10, minZ = 1e10, maxY = -1e10, minY = 1e10;
643 Int_t nTotHits = GetTotalHits();
645 if (fPrintHitsWarning && nTotHits > 5000) {
647 cout <<
" REST WARNING. TRestTrackEvent::DrawEvent. Number of hits is too "
650 cout <<
" This drawing method is not properly optimized to draw events "
651 "with a high number of hits."
653 cout <<
" To remove this warning you may use the DrawEvent method option : "
658 fPrintHitsWarning =
false;
661 fXYHit =
new TGraph[nTotHits];
662 fXZHit =
new TGraph[nTotHits];
663 fYZHit =
new TGraph[nTotHits];
664 fXYZHit =
new TGraph2D[nTotHits];
665 fXYTrack =
new TGraph[nTracks];
666 fXZTrack =
new TGraph[nTracks];
667 fYZTrack =
new TGraph[nTracks];
668 fXYZTrack =
new TGraph2D[nTracks];
670 vector<Int_t> drawLinesXY(nTracks, 0);
671 vector<Int_t> drawLinesXZ(nTracks, 0);
672 vector<Int_t> drawLinesYZ(nTracks, 0);
673 vector<Int_t> drawLinesXYZ(nTracks, 0);
675 int countXY = 0, countYZ = 0, countXZ = 0, countXYZ = 0;
676 int nTckXY = 0, nTckXZ = 0, nTckYZ = 0, nTckXYZ = 0;
678 Double_t minRadiusSize = 0.4;
679 Double_t maxRadiusSize = 2.;
681 Int_t maxTrackHits = 0;
685 for (
int tck = 0; tck < nTracks; tck++) {
697 Bool_t isTopLevel = this->isTopLevel(tck);
698 if (isTopLevel) tckColor++;
699 Int_t level = this->GetLevel(tck);
701 if (!isTopLevel && maxLevel > 0 && level > maxLevel)
continue;
703 if (!isTopLevel && minLevel > 0 && level < minLevel)
continue;
705 int tckXY = 0, tckYZ = 0, tckXZ = 0, tckXYZ = 0;
708 for (
unsigned int nhit = 0; nhit < hits->GetNumberOfHits(); nhit++) {
709 if (hits->GetNumberOfHits() > (
unsigned int)maxTrackHits) maxTrackHits = hits->GetNumberOfHits();
711 if (hits->
isNaN(nhit)) {
712 cout <<
"REST Warning. TRestTrackEvent::Draw. Hit is not defined!!" << endl;
717 Double_t x = hits->GetX(nhit);
718 Double_t y = hits->GetY(nhit);
719 Double_t z = hits->GetZ(nhit);
720 Double_t en = hits->GetEnergy(nhit);
721 auto type = hits->GetType(nhit);
726 Double_t m = (maxRadiusSize) / (maxHitEnergy - meanHitEnergy);
727 Double_t n = (maxRadiusSize - minRadiusSize) - m * meanHitEnergy;
731 if (radius < 0.1) radius = 0.1;
732 if (hits->GetNumberOfHits() == 1) radius = 2;
733 if (hits->GetNumberOfHits() > 100) radius = 0.8;
736 radius = 1.5 * minRadiusSize * level;
740 if (this->isXYZ() && nhit > 1) {
741 if (tckXYZ == 0) nTckXYZ++;
742 fXYZTrack[nTckXYZ - 1].SetPoint(tckXYZ, x, y, z);
744 if (isTopLevel) drawLinesXYZ[nTckXYZ - 1] = 1;
747 fXYZHit[countXYZ].SetPoint(0, x, y, z);
749 fXYZHit[countXYZ].SetPoint(1, x + 0.001, y + 0.001, z + 0.001);
751 fXYZHit[countXYZ].SetMarkerColor(level + 11);
753 fXYZHit[countXYZ].SetMarkerSize(radius);
754 fXYZHit[countXYZ].SetMarkerStyle(20);
761 if (tckXY == 0) nTckXY++;
762 fXYTrack[nTckXY - 1].SetPoint(tckXY, x, y);
763 if (isTopLevel) drawLinesXY[nTckXY - 1] = 1;
764 fXYHit[countXY].SetPoint(0, x, y);
767 fXYHit[countXY].SetMarkerColor(level + 11);
769 fXYHit[countXY].SetMarkerColor(tckColor);
771 fXYHit[countXY].SetMarkerSize(radius);
772 fXYHit[countXY].SetMarkerStyle(20);
778 if (tckXZ == 0) nTckXZ++;
779 fXZTrack[nTckXZ - 1].SetPoint(tckXZ, x, z);
780 if (isTopLevel) drawLinesXZ[nTckXZ - 1] = 1;
781 fXZHit[countXZ].SetPoint(0, x, z);
784 fXZHit[countXZ].SetMarkerColor(level + 11);
786 fXZHit[countXZ].SetMarkerColor(tckColor);
788 fXZHit[countXZ].SetMarkerSize(radius);
789 fXZHit[countXZ].SetMarkerStyle(20);
795 if (tckYZ == 0) nTckYZ++;
796 fYZTrack[nTckYZ - 1].SetPoint(tckYZ, y, z);
797 if (isTopLevel) drawLinesYZ[nTckYZ - 1] = 1;
798 fYZHit[countYZ].SetPoint(0, y, z);
801 fYZHit[countYZ].SetMarkerColor(level + 11);
803 fYZHit[countYZ].SetMarkerColor(tckColor);
805 fYZHit[countYZ].SetMarkerSize(radius);
806 fYZHit[countYZ].SetMarkerStyle(20);
812 if (x > maxX) maxX = x;
813 if (x < minX) minX = x;
817 if (y > maxY) maxY = y;
818 if (y < minY) minY = y;
822 if (z > maxZ) maxZ = z;
823 if (z < minZ) minZ = z;
828 fPad =
new TPad(this->GetName(),
" ", 0, 0, 1, 1);
836 sprintf(title,
"Event ID %d", this->GetID());
838 TMultiGraph* mgXY =
new TMultiGraph();
839 TMultiGraph* mgXZ =
new TMultiGraph();
840 TMultiGraph* mgYZ =
new TMultiGraph();
842 fPad->cd(1)->DrawFrame(minX - 10, minZ - 10, maxX + 10, maxZ + 10, title);
843 fPad->cd(2)->DrawFrame(minY - 10, minZ - 10, maxY + 10, maxZ + 10, title);
845 if (this->isXYZ()) fPad->cd(3)->DrawFrame(minX - 10, minY - 10, maxX + 10, maxY + 10, title);
847 for (
int i = 0; i < countXZ; i++) mgXZ->Add(&fXZHit[i]);
850 mgXZ->GetXaxis()->SetTitle(
"X-axis (mm)");
851 mgXZ->GetYaxis()->SetTitle(
"Z-axis (mm)");
852 mgXZ->GetYaxis()->SetTitleOffset(1.75);
853 mgXZ->GetYaxis()->SetTitleSize(1.4 * mgXZ->GetYaxis()->GetTitleSize());
854 mgXZ->GetXaxis()->SetTitleSize(1.4 * mgXZ->GetXaxis()->GetTitleSize());
855 mgXZ->GetYaxis()->SetLabelSize(1.25 * mgXZ->GetYaxis()->GetLabelSize());
856 mgXZ->GetXaxis()->SetLabelSize(1.25 * mgXZ->GetXaxis()->GetLabelSize());
859 for (
int i = 0; i < countYZ; i++) mgYZ->Add(&fYZHit[i]);
862 mgYZ->GetXaxis()->SetTitle(
"Y-axis (mm)");
863 mgYZ->GetYaxis()->SetTitle(
"Z-axis (mm)");
864 mgYZ->GetYaxis()->SetTitleOffset(1.75);
865 mgYZ->GetYaxis()->SetTitleSize(1.4 * mgYZ->GetYaxis()->GetTitleSize());
866 mgYZ->GetXaxis()->SetTitleSize(1.4 * mgYZ->GetXaxis()->GetTitleSize());
867 mgYZ->GetYaxis()->SetLabelSize(1.25 * mgYZ->GetYaxis()->GetLabelSize());
868 mgYZ->GetXaxis()->SetLabelSize(1.25 * mgYZ->GetXaxis()->GetLabelSize());
872 for (
int i = 0; i < countXY; i++) mgXY->Add(&fXYHit[i]);
875 mgXY->GetXaxis()->SetTitle(
"X-axis (mm)");
876 mgXY->GetYaxis()->SetTitle(
"Y-axis (mm)");
877 mgXY->GetYaxis()->SetTitleOffset(1.75);
879 mgXY->GetYaxis()->SetTitleSize(1.4 * mgXY->GetYaxis()->GetTitleSize());
880 mgXY->GetXaxis()->SetTitleSize(1.4 * mgXY->GetXaxis()->GetTitleSize());
881 mgXY->GetYaxis()->SetLabelSize(1.25 * mgXY->GetYaxis()->GetLabelSize());
882 mgXY->GetXaxis()->SetLabelSize(1.25 * mgXY->GetXaxis()->GetLabelSize());
885 for (
int tck = 0; tck < nTckXZ; tck++) {
887 fXZTrack[tck].SetLineWidth(2.);
888 if (fXZTrack[tck].GetN() < 100 && drawLinesXZ[tck] == 1) fXZTrack[tck].Draw(
"L");
891 for (
int tck = 0; tck < nTckYZ; tck++) {
893 fYZTrack[tck].SetLineWidth(2.);
894 if (fYZTrack[tck].GetN() < 100 && drawLinesYZ[tck] == 1) fYZTrack[tck].Draw(
"L");
898 for (
int tck = 0; tck < nTckXY; tck++) {
900 fXYTrack[tck].SetLineWidth(2.);
901 if (fXYTrack[tck].GetN() < 100 && drawLinesXY[tck] == 1) fXYTrack[tck].Draw(
"L");
906 TString option =
"P";
907 for (
int tck = 0; tck < nTckXYZ; tck++) {
908 fXYZTrack[tck].SetLineWidth(2.);
909 if (fXZTrack[tck].GetN() < 100 && drawLinesXYZ[tck] == 1) {
910 fXYZTrack[tck].Draw(
"LINE");
915 for (
int i = 0; i < countXYZ; i++) {
916 if (i > 0) option =
"same P";
917 fXYZHit[i].Draw(option);
929 std::vector<TLegend*>& leg) {
930 if (originGr.size() != 2 || endGr.size() != 2 || leg.size() != 2)
return;
932 for (
auto gr : originGr)
935 for (
auto gr : endGr)
944 for (
int i = 0; i < 2; i++) {
945 originGr[i] =
new TGraph();
946 originGr[i]->SetPoint(0, orig[i], orig[2]);
947 originGr[i]->SetMarkerColor(kRed);
948 originGr[i]->SetMarkerStyle(20);
949 endGr[i] =
new TGraph();
950 endGr[i]->SetPoint(0, end[i], end[2]);
951 endGr[i]->SetMarkerColor(kBlack);
952 endGr[i]->SetMarkerStyle(20);
953 leg[i] =
new TLegend(0.7, 0.7, 0.9, 0.9);
954 leg[i]->AddEntry(originGr[i],
"Origin",
"p");
955 leg[i]->AddEntry(endGr[i],
"End",
"p");
964 std::vector<TLegend*>& leg) {
965 if (originGr.size() != 2 || endGr.size() != 2 || leg.size() != 2)
return;
967 for (
int i = 0; i < 2; i++) {
969 if (originGr[i]) originGr[i]->Draw(
"LP");
970 if (endGr[i]) endGr[i]->Draw(
"LP");
971 if (leg[i]) leg[i]->Draw();
virtual void PrintEvent() const
virtual void Initialize()=0
Double_t GetMaximumHitEnergy() const
It returns the maximum hit energy.
Double_t GetMeanHitEnergy() const
It returns the mean hits energy.
static void GetBoundaries(std::vector< double > &val, double &max, double &min, int &nBins, double offset=10)
TODO This method is not using any TRestHits member. This probably means that it should be placed some...
Bool_t isNaN(Int_t n) const
It will return true only if all the 3-coordinates of hit number n are not a number,...
TVector3 GetPosition(int n) const
It returns the position of hit number n.
void GetOriginEnd(std::vector< TGraph * > &originGr, std::vector< TGraph * > &endGr, std::vector< TLegend * > &leg)
Retreive origin and end of the track and store in a TGraph and legend.
TRestVolumeHits GetMaxTrackBoundaries3D(TVector3 &orig, TVector3 &end)
This function retrieves the origin and the end track positions based after the reconstruction of a 3D...
TPad * DrawEvent(const TString &option="")
Draw the event.
void DrawOriginEnd(TPad *pad, std::vector< TGraph * > &originGr, std::vector< TGraph * > &endGr, std::vector< TLegend * > &leg)
Draw origin and end of the track in a pad passed to the function Note that GetOriginEnd has to be iss...
Double_t GetMaxTrackRelativeZ()
Function to calculate the relative Z of the most energetic track to crosscheck if the track is upward...
void GetMaxTrackBoundaries(TVector3 &orig, TVector3 &end)
This function retreive the origin and the end of the track based on the most energetic hit....
void GetBoundaries(TVector3 &orig, TVector3 &end)
This function retreive the origin and the end of a single track based on the most energetic hit....