40#include "TRestDetectorHitsEvent.h"
50#include "TPolyLine3D.h"
51#include "TPolyMarker3D.h"
53#include "TRestStringHelper.h"
54#include "TRestTools.h"
171 const int nHits =
static_cast<int>(
fHits->GetNumberOfHits());
172 if (nHits < 2)
return;
174 std::vector<int> order(nHits);
175 std::iota(order.begin(), order.end(), 0);
177 if (compareCondition == 0) {
179 std::stable_sort(order.begin(), order.end(),
180 [
this](
int a,
int b) { return fHits->GetZ(a) < fHits->GetZ(b); });
182 std::stable_sort(order.begin(), order.end(), [
this, compareCondition](
int a,
int b) {
183 return compareCondition(TRestHits::iterator(fHits, a), TRestHits::iterator(fHits, b));
188 std::vector<int> where(nHits);
189 std::vector<int> at(nHits);
190 std::iota(where.begin(), where.end(), 0);
191 std::iota(at.begin(), at.end(), 0);
192 for (
int i = 0; i < nHits; i++) {
193 const int orig = order[i];
194 const int p = where[orig];
195 if (p == i)
continue;
197 const int displaced = at[i];
201 where[displaced] = p;
205void TRestDetectorHitsEvent::Shuffle(
int NLoop) {
206 Int_t nHits =
fHits->GetNumberOfHits();
208 for (
int n = 0; n < NLoop; n++) {
209 Int_t hit1 = (Int_t)(nHits * gRandom->Uniform(0, 1));
210 Int_t hit2 = (Int_t)(nHits * gRandom->Uniform(0, 1));
227 for (
unsigned int i = 0; i < this->GetNumberOfHits(); i++) {
228 if (GetType(i) == XZ) {
230 this->GetTime(i), XZ);
247 for (
unsigned int i = 0; i < this->GetNumberOfHits(); i++) {
248 if (GetType(i) == YZ) {
250 this->GetTime(i), YZ);
267 for (
unsigned int i = 0; i < this->GetNumberOfHits(); i++) {
268 if (GetType(i) == XYZ) {
271 this->GetTime(i), XYZ);
402 Double_t sizeY, Double_t theta) {
417 Double_t sizeY, Double_t theta) {
433 Double_t rad2 = radius * radius;
434 Double_t hitDistance = rad2;
438 TVector3 axis = x1 - x0;
439 Double_t cylLength = axis.Mag();
442 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
444 l = axis.Dot(this->GetPosition(n) - x0) / cylLength;
446 d2 = rad2 - (this->GetPosition(n) - x0).Mag2() + l * l;
448 if (d2 < hitDistance) hitDistance = d2;
454 if (nhits == 0)
return -1;
456 return TMath::Sqrt(hitDistance);
471 TVector3 axis = x1 - x0;
472 Double_t cylLength = axis.Mag();
474 Double_t hitDistance = cylLength;
475 Double_t d = cylLength;
478 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
480 d = cylLength - axis.Dot(this->GetPosition(n) - x0) / cylLength;
482 if (d < hitDistance) hitDistance = d;
488 if (nhits == 0)
return -1;
505 TVector3 axis = x1 - x0;
506 Double_t cylLength = axis.Mag();
508 Double_t hitDistance = cylLength;
509 Double_t d = cylLength;
512 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
514 d = axis.Dot(this->GetPosition(n) - x0) / cylLength;
516 if (d < hitDistance) hitDistance = d;
522 if (nhits == 0)
return -1;
540 Double_t sizeX, Double_t sizeY,
542 Double_t dX = sizeX / 2;
543 Double_t dY = sizeY / 2;
545 Double_t hitDistance = max(dX, dY);
549 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
551 dX = sizeX / 2 - TMath::Abs((this->GetPosition(n) - x0).X());
552 dY = sizeY / 2 - TMath::Abs((this->GetPosition(n) - x0).Y());
556 if (d < hitDistance) hitDistance = d;
562 if (nhits == 0)
return -1;
580 Double_t sizeX, Double_t sizeY,
582 TVector3 axis = x1 - x0;
583 Double_t prismLength = axis.Mag();
585 Double_t hitDistance = prismLength;
589 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
591 d = prismLength - axis.Dot(this->GetPosition(n) - x0) / prismLength;
593 if (d < hitDistance) hitDistance = d;
599 if (nhits == 0)
return -1;
617 const TVector3& x1, Double_t sizeX,
618 Double_t sizeY, Double_t theta) {
619 TVector3 axis = x1 - x0;
620 Double_t prismLength = axis.Mag();
622 Double_t hitDistance = prismLength;
626 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
628 d = axis.Dot(this->GetPosition(n) - x0) / prismLength;
630 if (d < hitDistance) hitDistance = d;
636 if (nhits == 0)
return -1;
668 for (
unsigned int n = 0; n < optList.size(); n++) {
669 if (optList[n] ==
"print") this->
PrintEvent();
672 optList.erase(std::remove(optList.begin(), optList.end(),
"print"), optList.end());
676 if (optList.size() == 0) optList.push_back(
"hist(Cont1,col)");
678 if (fPad !=
nullptr) {
683 fPad =
new TPad(this->GetName(),
" ", 0, 0, 1, 1);
684 fPad->Divide(3, 2 * optList.size());
689 for (
int i = 1; i <= 6 * (int)optList.size(); i++) {
691 gPad->SetBottomMargin(0.13);
692 gPad->SetLeftMargin(0.15);
696 for (
unsigned int n = 0; n < optList.size(); n++) {
697 string optionStr = (string)optList[n];
698 TString drawEventOption = optList[n];
701 size_t startPos = optionStr.find(
"(");
702 if (startPos != string::npos) drawEventOption = optList[n](0, startPos);
705 string histOption =
"";
706 size_t endPos = optionStr.find(
")");
707 if (endPos != string::npos) {
708 TString histOptionTmp = optList[n](startPos + 1, endPos - startPos - 1);
710 histOption = (string)histOptionTmp;
712 while ((pos = histOption.find(
",", pos)) != string::npos) {
713 histOption.replace(pos, 1,
":");
719 string pitchOption =
"";
721 startPos = optionStr.find(
"[");
722 endPos = optionStr.find(
"]");
724 if (endPos != string::npos) {
725 TString pitchOption = optList[n](startPos + 1, endPos - startPos - 1);
726 pitch = stod((
string)pitchOption);
729 if (drawEventOption ==
"graph") this->
DrawGraphs(column);
731 if (drawEventOption ==
"hist") this->
DrawHistograms(column, histOption, pitch);
758 vector<vector<Double_t>> xz(2, vector<Double_t>(this->GetNumberOfHits()));
759 vector<vector<Double_t>> yz(2, vector<Double_t>(this->GetNumberOfHits()));
760 vector<vector<Double_t>> xy(2, vector<Double_t>(this->GetNumberOfHits()));
767 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
768 Double_t x =
fHits->GetX(nhit);
769 Double_t y =
fHits->GetY(nhit);
770 Double_t z =
fHits->GetZ(nhit);
771 int type =
fHits->GetType(nhit);
773 if (type % XZ == 0) {
779 if (type % YZ == 0) {
785 if (type % XY == 0) {
792 fXZHitGraph =
new TGraph(nXZ, &xz[0][0], &xz[1][0]);
797 fYZHitGraph =
new TGraph(nYZ, &yz[0][0], &yz[1][0]);
802 fXYHitGraph =
new TGraph(nXY, &xy[0][0], &xy[1][0]);
809 sprintf(title,
"Event ID %d", this->GetID());
812 fPad->cd(1 + 3 * column);
821 fPad->cd(2 + 3 * column);
830 fPad->cd(3 + 3 * column);
856 std::vector<double> fX, fY, fZ;
857 for (
unsigned int i = 0; i < GetNumberOfHits(); i++) {
858 if (GetType(i) % X == 0) fX.emplace_back(
GetX(i));
859 if (GetType(i) % Y == 0) fY.emplace_back(
GetY(i));
860 if (GetType(i) % Z == 0) fZ.emplace_back(
GetZ(i));
863 double maxX, minX, maxY, minY, maxZ, minZ;
864 int nBinsX, nBinsY, nBinsZ;
867 auto getBoundaries = [](std::vector<double>& v,
double& mx,
double& mn,
int& nb) {
876 getBoundaries(fX, maxX, minX, nBinsX);
877 getBoundaries(fY, maxY, minY, nBinsY);
878 getBoundaries(fZ, maxZ, minZ, nBinsZ);
881 nBinsX = std::round((maxX - minX) / pitch);
882 nBinsY = std::round((maxY - minY) / pitch);
883 nBinsZ = std::round((maxZ - minZ) / pitch);
888 nBinsX = std::max(1, nBinsX);
889 nBinsY = std::max(1, nBinsY);
890 nBinsZ = std::max(1, nBinsZ);
906 fXYHisto =
new TH2F(
"XY",
"", nBinsX, minX, maxX, nBinsY, minY, maxY);
908 fXZHisto =
new TH2F(
"XZ",
"", nBinsX, minX, maxX, nBinsZ, minZ, maxZ);
910 fYZHisto =
new TH2F(
"YZ",
"", nBinsY, minY, maxY, nBinsZ, minZ, maxZ);
913 fXHisto =
new TH1F(
"X",
"", nBinsX, minX, maxX);
914 fXHisto->SetDirectory(
nullptr);
915 fYHisto =
new TH1F(
"Y",
"", nBinsY, minY, maxY);
916 fYHisto->SetDirectory(
nullptr);
917 fZHisto =
new TH1F(
"Z",
"", nBinsZ, minZ, maxZ);
918 fZHisto->SetDirectory(
nullptr);
928 Int_t nYZ = 0, nXZ = 0, nXY = 0;
929 Int_t nX = 0, nY = 0, nZ = 0;
931 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
932 Double_t x =
fHits->GetX(nhit);
933 Double_t y =
fHits->GetY(nhit);
934 Double_t z =
fHits->GetZ(nhit);
935 Double_t en =
fHits->GetEnergy(nhit);
936 int type =
fHits->GetType(nhit);
938 if (type % XZ == 0) {
943 if (type % YZ == 0) {
948 if (type % XY == 0) {
973 fPad->cd(1 + 3 * column);
975 fXZHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
976 fXZHisto->GetYaxis()->SetTitle(
"Z-axis (mm)");
977 fXZHisto->GetYaxis()->SetTitleSize(1.4 *
fXZHisto->GetYaxis()->GetTitleSize());
978 fXZHisto->GetXaxis()->SetTitleSize(1.4 *
fXZHisto->GetXaxis()->GetTitleSize());
979 fXZHisto->GetYaxis()->SetLabelSize(1.25 *
fXZHisto->GetYaxis()->GetLabelSize());
980 fXZHisto->GetXaxis()->SetLabelSize(1.25 *
fXZHisto->GetXaxis()->GetLabelSize());
981 fXZHisto->GetYaxis()->SetTitleOffset(1);
985 fPad->cd(2 + 3 * column);
987 fYZHisto->GetXaxis()->SetTitle(
"Y-axis (mm)");
988 fYZHisto->GetYaxis()->SetTitle(
"Z-axis (mm)");
989 fYZHisto->GetYaxis()->SetTitleSize(1.4 *
fYZHisto->GetYaxis()->GetTitleSize());
990 fYZHisto->GetXaxis()->SetTitleSize(1.4 *
fYZHisto->GetXaxis()->GetTitleSize());
991 fYZHisto->GetYaxis()->SetLabelSize(1.25 *
fYZHisto->GetYaxis()->GetLabelSize());
992 fYZHisto->GetXaxis()->SetLabelSize(1.25 *
fYZHisto->GetXaxis()->GetLabelSize());
993 fYZHisto->GetYaxis()->SetTitleOffset(1);
997 fPad->cd(3 + 3 * column);
999 fXYHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
1000 fXYHisto->GetYaxis()->SetTitle(
"Y-axis (mm)");
1001 fXYHisto->GetYaxis()->SetTitleSize(1.4 *
fXYHisto->GetYaxis()->GetTitleSize());
1002 fXYHisto->GetXaxis()->SetTitleSize(1.4 *
fXYHisto->GetXaxis()->GetTitleSize());
1003 fXYHisto->GetYaxis()->SetLabelSize(1.25 *
fXYHisto->GetYaxis()->GetLabelSize());
1004 fXYHisto->GetXaxis()->SetLabelSize(1.25 *
fXYHisto->GetXaxis()->GetLabelSize());
1005 fXYHisto->GetYaxis()->SetTitleOffset(1);
1016 fPad->cd(3 + 3 * column);
1018 TH3F* frame =
new TH3F(
"XYZframe",
"3D hits;X-axis (mm);Y-axis (mm);Z-axis (mm)", 1, minX, maxX, 1,
1019 minY, maxY, 1, minZ, maxZ);
1020 frame->SetDirectory(
nullptr);
1021 frame->SetStats(
false);
1022 frame->SetBit(kCanDelete);
1025 Double_t eMin = 1e9, eMax = -1e9;
1026 for (
unsigned int nhit = 0; nhit < GetNumberOfHits(); nhit++) {
1027 Double_t e =
fHits->GetEnergy(nhit);
1028 if (e < eMin) eMin = e;
1029 if (e > eMax) eMax = e;
1031 const Int_t nColors = TColor::GetNumberOfColors();
1032 auto energyColor = [&](Double_t e) {
1033 Int_t ci = (eMax > eMin) ? (Int_t)((e - eMin) / (eMax - eMin) * (nColors - 1)) : 0;
1034 return TColor::GetColorPalette(ci);
1037 std::vector<std::array<Double_t, 3>> xzHits;
1038 std::vector<std::array<Double_t, 3>> yzHits;
1039 for (
unsigned int nhit = 0; nhit < GetNumberOfHits(); nhit++) {
1040 Double_t x =
fHits->GetX(nhit);
1041 Double_t y =
fHits->GetY(nhit);
1042 Double_t z =
fHits->GetZ(nhit);
1043 Double_t en =
fHits->GetEnergy(nhit);
1044 int type =
fHits->GetType(nhit);
1045 bool hasX = (type % X == 0);
1046 bool hasY = (type % Y == 0);
1048 TPolyLine3D* line =
new TPolyLine3D(2);
1050 line->SetPoint(0, minX, y, z);
1051 line->SetPoint(1, maxX, y, z);
1052 yzHits.push_back({y, z, en});
1054 line->SetPoint(0, x, minY, z);
1055 line->SetPoint(1, x, maxY, z);
1056 xzHits.push_back({x, z, en});
1058 line->SetPoint(0, x, y, minZ);
1059 line->SetPoint(1, x, y, maxZ);
1061 line->SetLineColor(energyColor(en));
1062 line->SetBit(kCanDelete);
1067 const Double_t zTol = 0.05 * (maxZ - minZ);
1068 for (
const auto& xz : xzHits) {
1069 for (
const auto& yz : yzHits) {
1070 if (std::abs(xz[1] - yz[1]) > zTol)
continue;
1071 TPolyMarker3D* marker =
new TPolyMarker3D(1);
1072 marker->SetPoint(0, xz[0], yz[0], 0.5 * (xz[1] + yz[1]));
1073 marker->SetMarkerStyle(20);
1074 marker->SetMarkerSize(1.2);
1075 marker->SetMarkerColor(energyColor(0.5 * (xz[2] + yz[2])));
1076 marker->SetBit(kCanDelete);
1085 fPad->cd(1 + 3 * column);
1087 fXHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
1088 fXHisto->GetYaxis()->SetTitle(
"Number of events");
1089 fXHisto->GetYaxis()->SetTitleSize(1.4 *
fXHisto->GetYaxis()->GetTitleSize());
1090 fXHisto->GetXaxis()->SetTitleSize(1.4 *
fXHisto->GetXaxis()->GetTitleSize());
1091 fXHisto->GetYaxis()->SetLabelSize(1.25 *
fXHisto->GetYaxis()->GetLabelSize());
1092 fXHisto->GetXaxis()->SetLabelSize(1.25 *
fXHisto->GetXaxis()->GetLabelSize());
1093 fXHisto->GetYaxis()->SetTitleOffset(1);
1097 fPad->cd(2 + 3 * column);
1099 fYHisto->GetXaxis()->SetTitle(
"Y-axis (mm)");
1100 fYHisto->GetYaxis()->SetTitle(
"Number of events");
1101 fYHisto->GetYaxis()->SetTitleSize(1.4 *
fYHisto->GetYaxis()->GetTitleSize());
1102 fYHisto->GetXaxis()->SetTitleSize(1.4 *
fYHisto->GetXaxis()->GetTitleSize());
1103 fYHisto->GetYaxis()->SetLabelSize(1.25 *
fYHisto->GetYaxis()->GetLabelSize());
1104 fYHisto->GetXaxis()->SetLabelSize(1.25 *
fYHisto->GetXaxis()->GetLabelSize());
1105 fYHisto->GetYaxis()->SetTitleOffset(1);
1109 fPad->cd(3 + 3 * column);
1111 fZHisto->GetXaxis()->SetTitle(
"Z-axis (mm)");
1112 fZHisto->GetYaxis()->SetTitle(
"Number of events");
1113 fZHisto->GetYaxis()->SetTitleSize(1.4 *
fYHisto->GetYaxis()->GetTitleSize());
1114 fZHisto->GetXaxis()->SetTitleSize(1.4 *
fYHisto->GetXaxis()->GetTitleSize());
1115 fZHisto->GetYaxis()->SetLabelSize(1.25 *
fYHisto->GetYaxis()->GetLabelSize());
1116 fZHisto->GetXaxis()->SetLabelSize(1.25 *
fYHisto->GetXaxis()->GetLabelSize());
1117 fZHisto->GetYaxis()->SetTitleOffset(1);
1126 cout <<
"Total energy : " << GetTotalEnergy() << endl;
1127 cout <<
"Mean position : ( " << GetMeanPositionX() <<
" , " << GetMeanPositionY() <<
" , "
1128 << GetMeanPositionZ() <<
" ) " << endl;
1129 cout <<
"Number of hits : " <<
fHits->GetNumberOfHits() << endl;
1131 cout <<
"+++++++++++++++++++++++" << endl;
1132 cout <<
"Printing only the first " << nHits <<
" hits" << endl;
1150 double maxX, minX, maxY, minY;
1153 if (ranges.size() == 6) {
1162 std::vector<double> x, y, en;
1164 for (
unsigned int i = 0; i < GetNumberOfHits(); i++) {
1165 if (GetType(i) % X == 0) x.emplace_back(
GetX(i));
1166 if (GetType(i) % Y == 0) y.emplace_back(
GetY(i));
1169 if (x.empty() && y.empty()) {
1170 std::cout <<
"TRestDetectorHitsEvent::GetXYHistogram. Empty histogram!" << std::endl;
1184 nBinsX = std::round((maxX - minX) / pitch);
1185 nBinsY = std::round((maxY - minY) / pitch);
1191 fXYHisto =
new TH2F(
"XY",
"", nBinsX, minX, maxX, nBinsY, minY, maxY);
1197 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
1198 Double_t x =
fHits->GetX(nhit);
1199 Double_t y =
fHits->GetY(nhit);
1200 Double_t en =
fHits->GetEnergy(nhit);
1201 int type =
fHits->GetType(nhit);
1203 if (type % XY == 0 || type % XYZ == 0) {
1210 style.SetPalette(1);
1215 fXYHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
1216 fXYHisto->GetYaxis()->SetTitle(
"Y-axis (mm)");
1217 fXYHisto->GetYaxis()->SetTitleSize(1.4 *
fXYHisto->GetYaxis()->GetTitleSize());
1218 fXYHisto->GetXaxis()->SetTitleSize(1.4 *
fXYHisto->GetXaxis()->GetTitleSize());
1219 fXYHisto->GetYaxis()->SetLabelSize(1.25 *
fXYHisto->GetYaxis()->GetLabelSize());
1220 fXYHisto->GetXaxis()->SetLabelSize(1.25 *
fXYHisto->GetXaxis()->GetLabelSize());
1221 fXYHisto->GetYaxis()->SetTitleOffset(1);
1239 double maxX, minX, maxZ, minZ;
1242 if (ranges.size() == 6) {
1251 std::vector<double> x, z;
1253 for (
unsigned int i = 0; i < GetNumberOfHits(); i++) {
1254 if (GetType(i) % X == 0) x.emplace_back(
GetX(i));
1255 if (GetType(i) % Z == 0) z.emplace_back(
GetZ(i));
1258 if (x.empty() || z.empty()) {
1259 std::cout <<
"TRestDetectorHitsEvent::GetXZHistogram. Empty histogram!" << std::endl;
1273 nBinsX = std::round((maxX - minX) / pitch);
1274 nBinsZ = std::round((maxZ - minZ) / pitch);
1280 fXZHisto =
new TH2F(
"XZ",
"", nBinsX, minX, maxX, nBinsZ, minZ, maxZ);
1286 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
1287 Double_t x =
fHits->GetX(nhit);
1288 Double_t z =
fHits->GetZ(nhit);
1289 Double_t en =
fHits->GetEnergy(nhit);
1290 int type =
fHits->GetType(nhit);
1292 if (type % XZ == 0 || type % XYZ == 0) {
1299 style.SetPalette(1);
1304 fXZHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
1305 fXZHisto->GetYaxis()->SetTitle(
"Z-axis (mm)");
1306 fXZHisto->GetYaxis()->SetTitleSize(1.4 *
fXZHisto->GetYaxis()->GetTitleSize());
1307 fXZHisto->GetXaxis()->SetTitleSize(1.4 *
fXYHisto->GetXaxis()->GetTitleSize());
1308 fXZHisto->GetYaxis()->SetLabelSize(1.25 *
fXYHisto->GetYaxis()->GetLabelSize());
1309 fXZHisto->GetXaxis()->SetLabelSize(1.25 *
fXYHisto->GetXaxis()->GetLabelSize());
1310 fXZHisto->GetYaxis()->SetTitleOffset(1);
1328 double maxY, minY, maxZ, minZ;
1331 if (ranges.size() == 6) {
1340 std::vector<double> y, z, en;
1342 for (
unsigned int i = 0; i < GetNumberOfHits(); i++) {
1343 if (GetType(i) % Y == 0) y.emplace_back(
GetY(i));
1344 if (GetType(i) % Z == 0) z.emplace_back(
GetZ(i));
1347 if (y.empty() || z.empty()) {
1348 std::cout <<
"TRestDetectorHitsEvent::GetYZHistogram. Empty histogram!" << std::endl;
1362 nBinsY = std::round((maxY - minZ) / pitch);
1363 nBinsZ = std::round((maxZ - minZ) / pitch);
1369 fYZHisto =
new TH2F(
"YZ",
"", nBinsY, minY, maxY, nBinsZ, minZ, maxZ);
1375 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
1376 Double_t y =
fHits->GetY(nhit);
1377 Double_t z =
fHits->GetZ(nhit);
1378 Double_t en =
fHits->GetEnergy(nhit);
1379 int type =
fHits->GetType(nhit);
1381 if (type % YZ == 0 || type % XYZ == 0) {
1388 style.SetPalette(1);
1393 fYZHisto->GetXaxis()->SetTitle(
"Y-axis (mm)");
1394 fYZHisto->GetYaxis()->SetTitle(
"Z-axis (mm)");
1395 fYZHisto->GetYaxis()->SetTitleSize(1.4 *
fYZHisto->GetYaxis()->GetTitleSize());
1396 fYZHisto->GetXaxis()->SetTitleSize(1.4 *
fYZHisto->GetXaxis()->GetTitleSize());
1397 fYZHisto->GetYaxis()->SetLabelSize(1.25 *
fYZHisto->GetYaxis()->GetLabelSize());
1398 fYZHisto->GetXaxis()->SetLabelSize(1.25 *
fYZHisto->GetXaxis()->GetLabelSize());
1399 fYZHisto->GetYaxis()->SetTitleOffset(1);
TH2F * GetXZHistogram(std::vector< float > ranges, Double_t pitch=3, Double_t border=5)
This method draws the hits found on XY as a TH2F and it returns the generated histogram.
TRestHits * GetXYZHits()
This method collects all hits which are compatible with a XYZ hit.
virtual void PrintEvent() const
TVector3 GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the mean position of the hits found inside the cylinder volume given by argument.
TRestHits * GetXZHits()
This method collects all hits which are compatible with a XZ-projected hit.
Double_t GetClosestHitInsideDistanceToCylinderTop(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the distance to the cylinder top face from the closest hit contained inside the c...
void DrawGraphs(Int_t &column)
This method draw the hits events as a graph.
TH1F * fZHisto
An auxiliary TH1F histogram to visualize hits on Z-projection.
TPad * DrawEvent(const TString &option="")
This method draws the hits event structure into a TPad.
Double_t GetX(int n) const
Returns the X-coordinate of hit entry n in mm.
TH2F * fXYHisto
An auxiliary TH2F histogram to visualize hits on XY-projection.
Double_t GetClosestHitInsideDistanceToPrismBottom(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the distance to the prism bottom face from the closest hit contained inside the p...
Int_t GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the total number hits found inside the cylinder volume given by argument.
TH2F * GetXYHistogram(std::vector< float > ranges, Double_t pitch=3, Double_t border=5)
This method draws the hits found on XY as a TH2F and it returns the generated histogram.
Bool_t anyHitInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns true if at least 1 hit is found inside the cylinder volume given by argument.
TH2F * fYZHisto
An auxiliary TH2F histogram to visualize hits on YZ-projection.
Bool_t allHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sX, Double_t sY, Double_t theta)
This method returns true if all hits are found inside the prism volume given by argument.
void DrawHistograms(Int_t &column, const TString &histOption="", double pitch=0)
This method draw the hits events as an histogram.
Double_t GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the total integrated energy of all hits found inside the prism volume given by ar...
Double_t GetClosestHitInsideDistanceToCylinderWall(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the distance to the cylinder wall from the closest hit contained inside the cylin...
TGraph * fYZHitGraph
An auxiliary TGraph pointer to visualize hits on YZ-projection.
Double_t GetY(int n) const
Returns the Y-coordinate of hit entry n in mm.
Double_t GetZ(int n) const
Returns the Z-coordinate of hit entry n in mm.
TRestHits * fHits
The hits structure that is is saved to disk.
TRestHits * fXZHits
An auxiliary TRestHits structure to register hits on XZ projection.
TH2F * fXZHisto
An auxiliary TH2F histogram to visualize hits on XZ-projection.
TRestDetectorHitsEvent()
TRestDetectorHitsEvent default constructor.
Int_t GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the total number of hits found inside the prism volume given by argument.
Double_t GetClosestHitInsideDistanceToCylinderBottom(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the distance to the cylinder bottom face from the closest hit contained inside th...
TH1F * fYHisto
An auxiliary TH1F histogram to visualize hits on Y-projection.
TRestHits * fXYZHits
An auxiliary TRestHits structure to register hits on XYZ projection.
TVector3 GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the mean position of all hits found inside the prism volume given by argument.
Bool_t allHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns true if all hits are contained inside the cylinder volume given by argument.
Double_t GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius)
This method returns the total integrated energy of all hits found inside the cylinder volume given by...
void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t=0, REST_HitType type=XYZ)
Adds a new hit to this event.
TRestHits * GetYZHits()
This method collects all hits which are compatible with a YZ-projected hit.
TGraph * fXZHitGraph
An auxiliary TGraph pointer to visualize hits on XZ-projection.
TH2F * GetYZHistogram(std::vector< float > ranges, Double_t pitch=3, Double_t border=5)
This method draws the hits found on YZ as a TH2F and it returns the generated histogram.
TH1F * fXHisto
An auxiliary TH1F histogram to visualize hits on X-projection.
Double_t GetClosestHitInsideDistanceToPrismTop(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the distance to the prism top face from the closest hit contained inside the pris...
Bool_t anyHitInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns true if at least 1 hit is found inside the prism volume given by argument.
virtual void Initialize()
Removes all hits from this event, and clears all auxiliar variables.
TGraph * fXYHitGraph
An auxiliary TGraph pointer to visualize hits on XY-projection.
Double_t GetClosestHitInsideDistanceToPrismWall(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta)
This method returns the distance to the prism wall from the closest hit contained inside the prism vo...
~TRestDetectorHitsEvent()
TRestDetectorHitsEvent default destructor.
TRestHits * fYZHits
An auxiliary TRestHits structure to register hits on YZ projection.
virtual void PrintEvent() const
virtual void Initialize()=0
It saves a 3-coordinate position and an energy for each punctual deposition.
Int_t GetNumberOfHitsInsidePrism(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines the total number of hits contained inside a prisma delimited between x0 and y0 vertex,...
virtual void RemoveHits()
It removes all hits inside the class.
TVector3 GetMeanPositionInCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the mean position using the hits contained inside a cylinder with a given radius and de...
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...
Double_t GetEnergyInCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the total energy contained inside a cylinder with a given radius and delimited between ...
Bool_t isHitNInsidePrism(Int_t n, const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines if hit n is contained inside a prisma delimited between x0 and y0 vertex,...
Double_t GetEnergyInPrism(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines the total hit energy contained inside a prisma delimited between x0 and y0 vertex,...
void AddHit(const TVector3 &position, Double_t energy, Double_t time=0, REST_HitType type=XYZ)
Adds a new hit to the list of hits using a TVector3.
Int_t GetNumberOfHitsInsideCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the total number of hits contained inside a cylinder with a given radius and delimited ...
Bool_t isHitNInsideCylinder(Int_t n, const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines if hit n is contained inside a cylinder with a given radius and delimited between x0 an...
TVector3 GetMeanPositionInPrism(const TVector3 &x0, const TVector3 &x1, Double_t sizeX, Double_t sizeY, Double_t theta) const
It determines the mean position of hits contained inside a prisma delimited between x0 and x1 vertex,...
virtual void SwapHits(Int_t i, Int_t j)
It exchanges hits n and m affecting to the ordering of the hits inside the list of hits.
virtual void PrintHits(Int_t nHits=-1) const
It prints on screen the first nHits from the list.