40#include "TRestDetectorHitsEvent.h"
47#include "TPolyLine3D.h"
48#include "TPolyMarker3D.h"
50#include "TRestStringHelper.h"
51#include "TRestTools.h"
164 if (compareCondition == 0) {
168 return hit1.z() < hit2.z();
171 std::sort(
fHits->begin(),
fHits->end(), compareCondition);
174 std::cout <<
"TRestDetectorHitsEvent::Sort is not implemented on MacOs!!" << std::endl;
175 std::cout <<
"This method implementation should be reviewed for proper operation in Mac" << std::endl;
179void TRestDetectorHitsEvent::Shuffle(
int NLoop) {
180 Int_t nHits =
fHits->GetNumberOfHits();
182 for (
int n = 0; n < NLoop; n++) {
183 Int_t hit1 = (Int_t)(nHits * gRandom->Uniform(0, 1));
184 Int_t hit2 = (Int_t)(nHits * gRandom->Uniform(0, 1));
201 for (
unsigned int i = 0; i < this->GetNumberOfHits(); i++) {
202 if (GetType(i) == XZ) {
204 this->GetTime(i), XZ);
221 for (
unsigned int i = 0; i < this->GetNumberOfHits(); i++) {
222 if (GetType(i) == YZ) {
224 this->GetTime(i), YZ);
241 for (
unsigned int i = 0; i < this->GetNumberOfHits(); i++) {
242 if (GetType(i) == XYZ) {
245 this->GetTime(i), XYZ);
376 Double_t sizeY, Double_t theta) {
391 Double_t sizeY, Double_t theta) {
407 Double_t rad2 = radius * radius;
408 Double_t hitDistance = rad2;
412 TVector3 axis = x1 - x0;
413 Double_t cylLength = axis.Mag();
416 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
418 l = axis.Dot(this->GetPosition(n) - x0) / cylLength;
420 d2 = rad2 - (this->GetPosition(n) - x0).Mag2() + l * l;
422 if (d2 < hitDistance) hitDistance = d2;
428 if (nhits == 0)
return -1;
430 return TMath::Sqrt(hitDistance);
445 TVector3 axis = x1 - x0;
446 Double_t cylLength = axis.Mag();
448 Double_t hitDistance = cylLength;
449 Double_t d = cylLength;
452 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
454 d = cylLength - axis.Dot(this->GetPosition(n) - x0) / cylLength;
456 if (d < hitDistance) hitDistance = d;
462 if (nhits == 0)
return -1;
479 TVector3 axis = x1 - x0;
480 Double_t cylLength = axis.Mag();
482 Double_t hitDistance = cylLength;
483 Double_t d = cylLength;
486 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
488 d = axis.Dot(this->GetPosition(n) - x0) / cylLength;
490 if (d < hitDistance) hitDistance = d;
496 if (nhits == 0)
return -1;
514 Double_t sizeX, Double_t sizeY,
516 Double_t dX = sizeX / 2;
517 Double_t dY = sizeY / 2;
519 Double_t hitDistance = max(dX, dY);
523 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
525 dX = sizeX / 2 - TMath::Abs((this->GetPosition(n) - x0).X());
526 dY = sizeY / 2 - TMath::Abs((this->GetPosition(n) - x0).Y());
530 if (d < hitDistance) hitDistance = d;
536 if (nhits == 0)
return -1;
554 Double_t sizeX, Double_t sizeY,
556 TVector3 axis = x1 - x0;
557 Double_t prismLength = axis.Mag();
559 Double_t hitDistance = prismLength;
563 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
565 d = prismLength - axis.Dot(this->GetPosition(n) - x0) / prismLength;
567 if (d < hitDistance) hitDistance = d;
573 if (nhits == 0)
return -1;
591 const TVector3& x1, Double_t sizeX,
592 Double_t sizeY, Double_t theta) {
593 TVector3 axis = x1 - x0;
594 Double_t prismLength = axis.Mag();
596 Double_t hitDistance = prismLength;
600 for (
unsigned int n = 0; n < GetNumberOfHits(); n++) {
602 d = axis.Dot(this->GetPosition(n) - x0) / prismLength;
604 if (d < hitDistance) hitDistance = d;
610 if (nhits == 0)
return -1;
642 for (
unsigned int n = 0; n < optList.size(); n++) {
643 if (optList[n] ==
"print") this->
PrintEvent();
646 optList.erase(std::remove(optList.begin(), optList.end(),
"print"), optList.end());
650 if (optList.size() == 0) optList.push_back(
"hist(Cont1,col)");
652 if (fPad !=
nullptr) {
657 fPad =
new TPad(this->GetName(),
" ", 0, 0, 1, 1);
658 fPad->Divide(3, 2 * optList.size());
663 for (
int i = 1; i <= 6 * (int)optList.size(); i++) {
665 gPad->SetBottomMargin(0.13);
666 gPad->SetLeftMargin(0.15);
670 for (
unsigned int n = 0; n < optList.size(); n++) {
671 string optionStr = (string)optList[n];
672 TString drawEventOption = optList[n];
675 size_t startPos = optionStr.find(
"(");
676 if (startPos != string::npos) drawEventOption = optList[n](0, startPos);
679 string histOption =
"";
680 size_t endPos = optionStr.find(
")");
681 if (endPos != string::npos) {
682 TString histOptionTmp = optList[n](startPos + 1, endPos - startPos - 1);
684 histOption = (string)histOptionTmp;
686 while ((pos = histOption.find(
",", pos)) != string::npos) {
687 histOption.replace(pos, 1,
":");
693 string pitchOption =
"";
695 startPos = optionStr.find(
"[");
696 endPos = optionStr.find(
"]");
698 if (endPos != string::npos) {
699 TString pitchOption = optList[n](startPos + 1, endPos - startPos - 1);
700 pitch = stod((
string)pitchOption);
703 if (drawEventOption ==
"graph") this->
DrawGraphs(column);
705 if (drawEventOption ==
"hist") this->
DrawHistograms(column, histOption, pitch);
732 vector<vector<Double_t>> xz(2, vector<Double_t>(this->GetNumberOfHits()));
733 vector<vector<Double_t>> yz(2, vector<Double_t>(this->GetNumberOfHits()));
734 vector<vector<Double_t>> xy(2, vector<Double_t>(this->GetNumberOfHits()));
741 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
742 Double_t x =
fHits->GetX(nhit);
743 Double_t y =
fHits->GetY(nhit);
744 Double_t z =
fHits->GetZ(nhit);
745 int type =
fHits->GetType(nhit);
747 if (type % XZ == 0) {
753 if (type % YZ == 0) {
759 if (type % XY == 0) {
766 fXZHitGraph =
new TGraph(nXZ, &xz[0][0], &xz[1][0]);
771 fYZHitGraph =
new TGraph(nYZ, &yz[0][0], &yz[1][0]);
776 fXYHitGraph =
new TGraph(nXY, &xy[0][0], &xy[1][0]);
783 sprintf(title,
"Event ID %d", this->GetID());
786 fPad->cd(1 + 3 * column);
795 fPad->cd(2 + 3 * column);
804 fPad->cd(3 + 3 * column);
830 std::vector<double> fX, fY, fZ;
831 for (
unsigned int i = 0; i < GetNumberOfHits(); i++) {
832 if (GetType(i) % X == 0) fX.emplace_back(
GetX(i));
833 if (GetType(i) % Y == 0) fY.emplace_back(
GetY(i));
834 if (GetType(i) % Z == 0) fZ.emplace_back(
GetZ(i));
837 double maxX, minX, maxY, minY, maxZ, minZ;
838 int nBinsX, nBinsY, nBinsZ;
841 auto getBoundaries = [](std::vector<double>& v,
double& mx,
double& mn,
int& nb) {
850 getBoundaries(fX, maxX, minX, nBinsX);
851 getBoundaries(fY, maxY, minY, nBinsY);
852 getBoundaries(fZ, maxZ, minZ, nBinsZ);
855 nBinsX = std::round((maxX - minX) / pitch);
856 nBinsY = std::round((maxY - minY) / pitch);
857 nBinsZ = std::round((maxZ - minZ) / pitch);
862 nBinsX = std::max(1, nBinsX);
863 nBinsY = std::max(1, nBinsY);
864 nBinsZ = std::max(1, nBinsZ);
880 fXYHisto =
new TH2F(
"XY",
"", nBinsX, minX, maxX, nBinsY, minY, maxY);
882 fXZHisto =
new TH2F(
"XZ",
"", nBinsX, minX, maxX, nBinsZ, minZ, maxZ);
884 fYZHisto =
new TH2F(
"YZ",
"", nBinsY, minY, maxY, nBinsZ, minZ, maxZ);
887 fXHisto =
new TH1F(
"X",
"", nBinsX, minX, maxX);
888 fXHisto->SetDirectory(
nullptr);
889 fYHisto =
new TH1F(
"Y",
"", nBinsY, minY, maxY);
890 fYHisto->SetDirectory(
nullptr);
891 fZHisto =
new TH1F(
"Z",
"", nBinsZ, minZ, maxZ);
892 fZHisto->SetDirectory(
nullptr);
902 Int_t nYZ = 0, nXZ = 0, nXY = 0;
903 Int_t nX = 0, nY = 0, nZ = 0;
905 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
906 Double_t x =
fHits->GetX(nhit);
907 Double_t y =
fHits->GetY(nhit);
908 Double_t z =
fHits->GetZ(nhit);
909 Double_t en =
fHits->GetEnergy(nhit);
910 int type =
fHits->GetType(nhit);
912 if (type % XZ == 0) {
917 if (type % YZ == 0) {
922 if (type % XY == 0) {
947 fPad->cd(1 + 3 * column);
949 fXZHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
950 fXZHisto->GetYaxis()->SetTitle(
"Z-axis (mm)");
951 fXZHisto->GetYaxis()->SetTitleSize(1.4 *
fXZHisto->GetYaxis()->GetTitleSize());
952 fXZHisto->GetXaxis()->SetTitleSize(1.4 *
fXZHisto->GetXaxis()->GetTitleSize());
953 fXZHisto->GetYaxis()->SetLabelSize(1.25 *
fXZHisto->GetYaxis()->GetLabelSize());
954 fXZHisto->GetXaxis()->SetLabelSize(1.25 *
fXZHisto->GetXaxis()->GetLabelSize());
955 fXZHisto->GetYaxis()->SetTitleOffset(1);
959 fPad->cd(2 + 3 * column);
961 fYZHisto->GetXaxis()->SetTitle(
"Y-axis (mm)");
962 fYZHisto->GetYaxis()->SetTitle(
"Z-axis (mm)");
963 fYZHisto->GetYaxis()->SetTitleSize(1.4 *
fYZHisto->GetYaxis()->GetTitleSize());
964 fYZHisto->GetXaxis()->SetTitleSize(1.4 *
fYZHisto->GetXaxis()->GetTitleSize());
965 fYZHisto->GetYaxis()->SetLabelSize(1.25 *
fYZHisto->GetYaxis()->GetLabelSize());
966 fYZHisto->GetXaxis()->SetLabelSize(1.25 *
fYZHisto->GetXaxis()->GetLabelSize());
967 fYZHisto->GetYaxis()->SetTitleOffset(1);
971 fPad->cd(3 + 3 * column);
973 fXYHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
974 fXYHisto->GetYaxis()->SetTitle(
"Y-axis (mm)");
975 fXYHisto->GetYaxis()->SetTitleSize(1.4 *
fXYHisto->GetYaxis()->GetTitleSize());
976 fXYHisto->GetXaxis()->SetTitleSize(1.4 *
fXYHisto->GetXaxis()->GetTitleSize());
977 fXYHisto->GetYaxis()->SetLabelSize(1.25 *
fXYHisto->GetYaxis()->GetLabelSize());
978 fXYHisto->GetXaxis()->SetLabelSize(1.25 *
fXYHisto->GetXaxis()->GetLabelSize());
979 fXYHisto->GetYaxis()->SetTitleOffset(1);
990 fPad->cd(3 + 3 * column);
992 TH3F* frame =
new TH3F(
"XYZframe",
"3D hits;X-axis (mm);Y-axis (mm);Z-axis (mm)", 1, minX, maxX, 1,
993 minY, maxY, 1, minZ, maxZ);
994 frame->SetDirectory(
nullptr);
995 frame->SetStats(
false);
996 frame->SetBit(kCanDelete);
999 Double_t eMin = 1e9, eMax = -1e9;
1000 for (
unsigned int nhit = 0; nhit < GetNumberOfHits(); nhit++) {
1001 Double_t e =
fHits->GetEnergy(nhit);
1002 if (e < eMin) eMin = e;
1003 if (e > eMax) eMax = e;
1005 const Int_t nColors = TColor::GetNumberOfColors();
1006 auto energyColor = [&](Double_t e) {
1007 Int_t ci = (eMax > eMin) ? (Int_t)((e - eMin) / (eMax - eMin) * (nColors - 1)) : 0;
1008 return TColor::GetColorPalette(ci);
1011 std::vector<std::array<Double_t, 3>> xzHits;
1012 std::vector<std::array<Double_t, 3>> yzHits;
1013 for (
unsigned int nhit = 0; nhit < GetNumberOfHits(); nhit++) {
1014 Double_t x =
fHits->GetX(nhit);
1015 Double_t y =
fHits->GetY(nhit);
1016 Double_t z =
fHits->GetZ(nhit);
1017 Double_t en =
fHits->GetEnergy(nhit);
1018 int type =
fHits->GetType(nhit);
1019 bool hasX = (type % X == 0);
1020 bool hasY = (type % Y == 0);
1022 TPolyLine3D* line =
new TPolyLine3D(2);
1024 line->SetPoint(0, minX, y, z);
1025 line->SetPoint(1, maxX, y, z);
1026 yzHits.push_back({y, z, en});
1028 line->SetPoint(0, x, minY, z);
1029 line->SetPoint(1, x, maxY, z);
1030 xzHits.push_back({x, z, en});
1032 line->SetPoint(0, x, y, minZ);
1033 line->SetPoint(1, x, y, maxZ);
1035 line->SetLineColor(energyColor(en));
1036 line->SetBit(kCanDelete);
1041 const Double_t zTol = 0.05 * (maxZ - minZ);
1042 for (
const auto& xz : xzHits) {
1043 for (
const auto& yz : yzHits) {
1044 if (std::abs(xz[1] - yz[1]) > zTol)
continue;
1045 TPolyMarker3D* marker =
new TPolyMarker3D(1);
1046 marker->SetPoint(0, xz[0], yz[0], 0.5 * (xz[1] + yz[1]));
1047 marker->SetMarkerStyle(20);
1048 marker->SetMarkerSize(1.2);
1049 marker->SetMarkerColor(energyColor(0.5 * (xz[2] + yz[2])));
1050 marker->SetBit(kCanDelete);
1059 fPad->cd(1 + 3 * column);
1061 fXHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
1062 fXHisto->GetYaxis()->SetTitle(
"Number of events");
1063 fXHisto->GetYaxis()->SetTitleSize(1.4 *
fXHisto->GetYaxis()->GetTitleSize());
1064 fXHisto->GetXaxis()->SetTitleSize(1.4 *
fXHisto->GetXaxis()->GetTitleSize());
1065 fXHisto->GetYaxis()->SetLabelSize(1.25 *
fXHisto->GetYaxis()->GetLabelSize());
1066 fXHisto->GetXaxis()->SetLabelSize(1.25 *
fXHisto->GetXaxis()->GetLabelSize());
1067 fXHisto->GetYaxis()->SetTitleOffset(1);
1071 fPad->cd(2 + 3 * column);
1073 fYHisto->GetXaxis()->SetTitle(
"Y-axis (mm)");
1074 fYHisto->GetYaxis()->SetTitle(
"Number of events");
1075 fYHisto->GetYaxis()->SetTitleSize(1.4 *
fYHisto->GetYaxis()->GetTitleSize());
1076 fYHisto->GetXaxis()->SetTitleSize(1.4 *
fYHisto->GetXaxis()->GetTitleSize());
1077 fYHisto->GetYaxis()->SetLabelSize(1.25 *
fYHisto->GetYaxis()->GetLabelSize());
1078 fYHisto->GetXaxis()->SetLabelSize(1.25 *
fYHisto->GetXaxis()->GetLabelSize());
1079 fYHisto->GetYaxis()->SetTitleOffset(1);
1083 fPad->cd(3 + 3 * column);
1085 fZHisto->GetXaxis()->SetTitle(
"Z-axis (mm)");
1086 fZHisto->GetYaxis()->SetTitle(
"Number of events");
1087 fZHisto->GetYaxis()->SetTitleSize(1.4 *
fYHisto->GetYaxis()->GetTitleSize());
1088 fZHisto->GetXaxis()->SetTitleSize(1.4 *
fYHisto->GetXaxis()->GetTitleSize());
1089 fZHisto->GetYaxis()->SetLabelSize(1.25 *
fYHisto->GetYaxis()->GetLabelSize());
1090 fZHisto->GetXaxis()->SetLabelSize(1.25 *
fYHisto->GetXaxis()->GetLabelSize());
1091 fZHisto->GetYaxis()->SetTitleOffset(1);
1100 cout <<
"Total energy : " << GetTotalEnergy() << endl;
1101 cout <<
"Mean position : ( " << GetMeanPositionX() <<
" , " << GetMeanPositionY() <<
" , "
1102 << GetMeanPositionZ() <<
" ) " << endl;
1103 cout <<
"Number of hits : " <<
fHits->GetNumberOfHits() << endl;
1105 cout <<
"+++++++++++++++++++++++" << endl;
1106 cout <<
"Printing only the first " << nHits <<
" hits" << endl;
1124 double maxX, minX, maxY, minY;
1127 if (ranges.size() == 6) {
1136 std::vector<double> x, y, en;
1138 for (
unsigned int i = 0; i < GetNumberOfHits(); i++) {
1139 if (GetType(i) % X == 0) x.emplace_back(
GetX(i));
1140 if (GetType(i) % Y == 0) y.emplace_back(
GetY(i));
1143 if (x.empty() && y.empty()) {
1144 std::cout <<
"TRestDetectorHitsEvent::GetXYHistogram. Empty histogram!" << std::endl;
1158 nBinsX = std::round((maxX - minX) / pitch);
1159 nBinsY = std::round((maxY - minY) / pitch);
1165 fXYHisto =
new TH2F(
"XY",
"", nBinsX, minX, maxX, nBinsY, minY, maxY);
1171 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
1172 Double_t x =
fHits->GetX(nhit);
1173 Double_t y =
fHits->GetY(nhit);
1174 Double_t en =
fHits->GetEnergy(nhit);
1175 int type =
fHits->GetType(nhit);
1177 if (type % XY == 0 || type % XYZ == 0) {
1184 style.SetPalette(1);
1189 fXYHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
1190 fXYHisto->GetYaxis()->SetTitle(
"Y-axis (mm)");
1191 fXYHisto->GetYaxis()->SetTitleSize(1.4 *
fXYHisto->GetYaxis()->GetTitleSize());
1192 fXYHisto->GetXaxis()->SetTitleSize(1.4 *
fXYHisto->GetXaxis()->GetTitleSize());
1193 fXYHisto->GetYaxis()->SetLabelSize(1.25 *
fXYHisto->GetYaxis()->GetLabelSize());
1194 fXYHisto->GetXaxis()->SetLabelSize(1.25 *
fXYHisto->GetXaxis()->GetLabelSize());
1195 fXYHisto->GetYaxis()->SetTitleOffset(1);
1213 double maxX, minX, maxZ, minZ;
1216 if (ranges.size() == 6) {
1225 std::vector<double> x, z;
1227 for (
unsigned int i = 0; i < GetNumberOfHits(); i++) {
1228 if (GetType(i) % X == 0) x.emplace_back(
GetX(i));
1229 if (GetType(i) % Z == 0) z.emplace_back(
GetZ(i));
1232 if (x.empty() || z.empty()) {
1233 std::cout <<
"TRestDetectorHitsEvent::GetXZHistogram. Empty histogram!" << std::endl;
1247 nBinsX = std::round((maxX - minX) / pitch);
1248 nBinsZ = std::round((maxZ - minZ) / pitch);
1254 fXZHisto =
new TH2F(
"XZ",
"", nBinsX, minX, maxX, nBinsZ, minZ, maxZ);
1260 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
1261 Double_t x =
fHits->GetX(nhit);
1262 Double_t z =
fHits->GetZ(nhit);
1263 Double_t en =
fHits->GetEnergy(nhit);
1264 int type =
fHits->GetType(nhit);
1266 if (type % XZ == 0 || type % XYZ == 0) {
1273 style.SetPalette(1);
1278 fXZHisto->GetXaxis()->SetTitle(
"X-axis (mm)");
1279 fXZHisto->GetYaxis()->SetTitle(
"Z-axis (mm)");
1280 fXZHisto->GetYaxis()->SetTitleSize(1.4 *
fXZHisto->GetYaxis()->GetTitleSize());
1281 fXZHisto->GetXaxis()->SetTitleSize(1.4 *
fXYHisto->GetXaxis()->GetTitleSize());
1282 fXZHisto->GetYaxis()->SetLabelSize(1.25 *
fXYHisto->GetYaxis()->GetLabelSize());
1283 fXZHisto->GetXaxis()->SetLabelSize(1.25 *
fXYHisto->GetXaxis()->GetLabelSize());
1284 fXZHisto->GetYaxis()->SetTitleOffset(1);
1302 double maxY, minY, maxZ, minZ;
1305 if (ranges.size() == 6) {
1314 std::vector<double> y, z, en;
1316 for (
unsigned int i = 0; i < GetNumberOfHits(); i++) {
1317 if (GetType(i) % Y == 0) y.emplace_back(
GetY(i));
1318 if (GetType(i) % Z == 0) z.emplace_back(
GetZ(i));
1321 if (y.empty() || z.empty()) {
1322 std::cout <<
"TRestDetectorHitsEvent::GetYZHistogram. Empty histogram!" << std::endl;
1336 nBinsY = std::round((maxY - minZ) / pitch);
1337 nBinsZ = std::round((maxZ - minZ) / pitch);
1343 fYZHisto =
new TH2F(
"YZ",
"", nBinsY, minY, maxY, nBinsZ, minZ, maxZ);
1349 for (
unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
1350 Double_t y =
fHits->GetY(nhit);
1351 Double_t z =
fHits->GetZ(nhit);
1352 Double_t en =
fHits->GetEnergy(nhit);
1353 int type =
fHits->GetType(nhit);
1355 if (type % YZ == 0 || type % XYZ == 0) {
1362 style.SetPalette(1);
1367 fYZHisto->GetXaxis()->SetTitle(
"Y-axis (mm)");
1368 fYZHisto->GetYaxis()->SetTitle(
"Z-axis (mm)");
1369 fYZHisto->GetYaxis()->SetTitleSize(1.4 *
fYZHisto->GetYaxis()->GetTitleSize());
1370 fYZHisto->GetXaxis()->SetTitleSize(1.4 *
fYZHisto->GetXaxis()->GetTitleSize());
1371 fYZHisto->GetYaxis()->SetLabelSize(1.25 *
fYZHisto->GetYaxis()->GetLabelSize());
1372 fYZHisto->GetXaxis()->SetLabelSize(1.25 *
fYZHisto->GetXaxis()->GetLabelSize());
1373 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.