REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorHitsEvent.cxx
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see http://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see http://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
40#include "TRestDetectorHitsEvent.h"
41
42#include <array>
43
44#include "TCanvas.h"
45#include "TColor.h"
46#include "TH3F.h"
47#include "TPolyLine3D.h"
48#include "TPolyMarker3D.h"
49#include "TRandom.h"
50#include "TRestStringHelper.h"
51#include "TRestTools.h"
52#include "TStyle.h"
53
54using namespace std;
55using namespace TMath;
56
58
72 fHits = new TRestHits();
73
74 fPad = nullptr;
75
76 fXYHitGraph = nullptr;
77 fXZHitGraph = nullptr;
78 fYZHitGraph = nullptr;
79
80 fXYHisto = nullptr;
81 fXZHisto = nullptr;
82 fYZHisto = nullptr;
83
84 fXZHits = nullptr;
85 fYZHits = nullptr;
86 fXYZHits = nullptr;
87
88 fXHisto = nullptr;
89 fYHisto = nullptr;
90 fZHisto = nullptr;
91}
92
97 delete fHits;
98 delete fXZHits;
99 delete fYZHits;
100 delete fXYZHits;
101
102 delete fXYHitGraph;
103 delete fXZHitGraph;
104 delete fYZHitGraph;
105
106 delete fXYHisto;
107 delete fXZHisto;
108 delete fYZHisto;
109
110 delete fXHisto;
111 delete fYHisto;
112 delete fZHisto;
113}
114
121void TRestDetectorHitsEvent::AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t,
122 REST_HitType type) {
123 fHits->AddHit({x, y, z}, en, t, type);
124}
125
131void TRestDetectorHitsEvent::AddHit(const TVector3& position, Double_t energy, Double_t time,
132 REST_HitType type) {
133 fHits->AddHit(position, energy, time, type);
134}
135
141 fHits->RemoveHits();
142
143 if (fXZHits) {
144 delete fXZHits;
145 fXZHits = nullptr;
146 }
147 if (fYZHits) {
148 delete fYZHits;
149 fYZHits = nullptr;
150 }
151 if (fXYZHits) {
152 delete fXYZHits;
153 fXYZHits = nullptr;
154 }
155
156 fXZHits = new TRestHits();
157 fYZHits = new TRestHits();
158 fXYZHits = new TRestHits();
159}
160
161void TRestDetectorHitsEvent::Sort(bool(compareCondition)(const TRestHits::iterator& hit1,
162 const TRestHits::iterator& hit2)) {
163#ifndef __APPLE__
164 if (compareCondition == 0) {
165 // default sort logic: z from smaller to greater
166 std::sort(fHits->begin(), fHits->end(),
167 [](const TRestHits::iterator& hit1, const TRestHits::iterator& hit2) -> bool {
168 return hit1.z() < hit2.z();
169 });
170 } else {
171 std::sort(fHits->begin(), fHits->end(), compareCondition);
172 }
173#else
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;
176#endif
177}
178
179void TRestDetectorHitsEvent::Shuffle(int NLoop) {
180 Int_t nHits = fHits->GetNumberOfHits();
181 if (nHits >= 2) {
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));
185
186 fHits->SwapHits(hit1, hit2);
187 }
188 }
189}
190
200
201 for (unsigned int i = 0; i < this->GetNumberOfHits(); i++) {
202 if (GetType(i) == XZ) {
203 fXZHits->AddHit({this->GetX(i), this->GetY(i), this->GetZ(i)}, this->GetEnergy(i),
204 this->GetTime(i), XZ);
205 }
206 }
207
208 return fXZHits;
209}
210
220
221 for (unsigned int i = 0; i < this->GetNumberOfHits(); i++) {
222 if (GetType(i) == YZ) {
223 fYZHits->AddHit({this->GetX(i), this->GetY(i), this->GetZ(i)}, this->GetEnergy(i),
224 this->GetTime(i), YZ);
225 }
226 }
227
228 return fYZHits;
229}
230
240
241 for (unsigned int i = 0; i < this->GetNumberOfHits(); i++) {
242 if (GetType(i) == XYZ) {
243 {
244 fXYZHits->AddHit({this->GetX(i), this->GetY(i), this->GetZ(i)}, this->GetEnergy(i),
245 this->GetTime(i), XYZ);
246 }
247 }
248 }
249
250 return fXYZHits;
251}
252
260Bool_t TRestDetectorHitsEvent::anyHitInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
261 if (fHits->GetNumberOfHitsInsideCylinder(x0, x1, radius) > 0) {
262 return true;
263 }
264
265 return false;
266}
267
275Bool_t TRestDetectorHitsEvent::allHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
276 if ((size_t)fHits->GetNumberOfHitsInsideCylinder(x0, x1, radius) == GetNumberOfHits()) return true;
277
278 return false;
279}
280
289Double_t TRestDetectorHitsEvent::GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
290 return fHits->GetEnergyInCylinder(x0, x1, radius);
291}
292
301Int_t TRestDetectorHitsEvent::GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
302 return fHits->GetNumberOfHitsInsideCylinder(x0, x1, radius);
303}
304
313TVector3 TRestDetectorHitsEvent::GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
314 return fHits->GetMeanPositionInCylinder(x0, x1, radius);
315}
316
326Bool_t TRestDetectorHitsEvent::anyHitInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY,
327 Double_t theta) {
328 if (fHits->GetNumberOfHitsInsidePrism(x0, x1, sizeX, sizeY, theta) > 0) return true;
329
330 return false;
331}
332
342Bool_t TRestDetectorHitsEvent::allHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY,
343 Double_t theta) {
344 if ((size_t)fHits->GetNumberOfHitsInsidePrism(x0, x1, sizeX, sizeY, theta) == GetNumberOfHits())
345 return true;
346
347 return false;
348}
349
360Double_t TRestDetectorHitsEvent::GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY,
361 Double_t theta) {
362 return fHits->GetEnergyInPrism(x0, x1, sizeX, sizeY, theta);
363}
364
375Int_t TRestDetectorHitsEvent::GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX,
376 Double_t sizeY, Double_t theta) {
377 return fHits->GetNumberOfHitsInsidePrism(x0, x1, sizeX, sizeY, theta);
378}
379
390TVector3 TRestDetectorHitsEvent::GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX,
391 Double_t sizeY, Double_t theta) {
392 return fHits->GetMeanPositionInPrism(x0, x1, sizeX, sizeY, theta);
393}
394
406 Double_t radius) {
407 Double_t rad2 = radius * radius;
408 Double_t hitDistance = rad2;
409
410 Double_t d2, l;
411
412 TVector3 axis = x1 - x0;
413 Double_t cylLength = axis.Mag();
414
415 Int_t nhits = 0;
416 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
417 if (fHits->isHitNInsideCylinder(n, x0, x1, radius)) {
418 l = axis.Dot(this->GetPosition(n) - x0) / cylLength;
419
420 d2 = rad2 - (this->GetPosition(n) - x0).Mag2() + l * l;
421
422 if (d2 < hitDistance) hitDistance = d2;
423
424 nhits++;
425 }
426 }
427
428 if (nhits == 0) return -1;
429
430 return TMath::Sqrt(hitDistance);
431}
432
444 Double_t radius) {
445 TVector3 axis = x1 - x0;
446 Double_t cylLength = axis.Mag();
447
448 Double_t hitDistance = cylLength;
449 Double_t d = cylLength;
450
451 Int_t nhits = 0;
452 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
453 if (fHits->isHitNInsideCylinder(n, x0, x1, radius)) {
454 d = cylLength - axis.Dot(this->GetPosition(n) - x0) / cylLength;
455
456 if (d < hitDistance) hitDistance = d;
457
458 nhits++;
459 }
460 }
461
462 if (nhits == 0) return -1;
463
464 return hitDistance;
465}
466
478 Double_t radius) {
479 TVector3 axis = x1 - x0;
480 Double_t cylLength = axis.Mag();
481
482 Double_t hitDistance = cylLength;
483 Double_t d = cylLength;
484
485 Int_t nhits = 0;
486 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
487 if (fHits->isHitNInsideCylinder(n, x0, x1, radius)) {
488 d = axis.Dot(this->GetPosition(n) - x0) / cylLength;
489
490 if (d < hitDistance) hitDistance = d;
491
492 nhits++;
493 }
494 }
495
496 if (nhits == 0) return -1;
497
498 return hitDistance;
499}
500
514 Double_t sizeX, Double_t sizeY,
515 Double_t theta) {
516 Double_t dX = sizeX / 2;
517 Double_t dY = sizeY / 2;
518
519 Double_t hitDistance = max(dX, dY);
520
521 Double_t d;
522 Int_t nhits = 0;
523 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
524 if (fHits->isHitNInsidePrism(n, x0, x1, sizeX, sizeY, theta)) {
525 dX = sizeX / 2 - TMath::Abs((this->GetPosition(n) - x0).X());
526 dY = sizeY / 2 - TMath::Abs((this->GetPosition(n) - x0).Y());
527
528 d = min(dX, dY);
529
530 if (d < hitDistance) hitDistance = d;
531
532 nhits++;
533 }
534 }
535
536 if (nhits == 0) return -1;
537
538 return hitDistance;
539}
540
554 Double_t sizeX, Double_t sizeY,
555 Double_t theta) {
556 TVector3 axis = x1 - x0;
557 Double_t prismLength = axis.Mag();
558
559 Double_t hitDistance = prismLength;
560
561 Double_t d;
562 Int_t nhits = 0;
563 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
564 if (fHits->isHitNInsidePrism(n, x0, x1, sizeX, sizeY, theta)) {
565 d = prismLength - axis.Dot(this->GetPosition(n) - x0) / prismLength;
566
567 if (d < hitDistance) hitDistance = d;
568
569 nhits++;
570 }
571 }
572
573 if (nhits == 0) return -1;
574
575 return hitDistance;
576}
577
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();
595
596 Double_t hitDistance = prismLength;
597
598 Double_t d;
599 Int_t nhits = 0;
600 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
601 if (fHits->isHitNInsidePrism(n, x0, x1, sizeX, sizeY, theta)) {
602 d = axis.Dot(this->GetPosition(n) - x0) / prismLength;
603
604 if (d < hitDistance) hitDistance = d;
605
606 nhits++;
607 }
608 }
609
610 if (nhits == 0) return -1;
611
612 return hitDistance;
613}
614
639TPad* TRestDetectorHitsEvent::DrawEvent(const TString& option) {
640 vector<TString> optList = Vector_cast<string, TString>(TRestTools::GetOptions((string)option));
641
642 for (unsigned int n = 0; n < optList.size(); n++) {
643 if (optList[n] == "print") this->PrintEvent();
644 }
645
646 optList.erase(std::remove(optList.begin(), optList.end(), "print"), optList.end());
647
649 // which means that it should be extracted from the hit array
650 if (optList.size() == 0) optList.push_back("hist(Cont1,col)");
651
652 if (fPad != nullptr) {
653 delete fPad;
654 fPad = nullptr;
655 }
656
657 fPad = new TPad(this->GetName(), " ", 0, 0, 1, 1);
658 fPad->Divide(3, 2 * optList.size());
659 fPad->Draw();
660
661 // Give each sub-pad enough margin so the axis titles (in particular the bottom-row
662 // x-axis titles and the wider 2-digit y-axis labels) are not clipped at the edges.
663 for (int i = 1; i <= 6 * (int)optList.size(); i++) {
664 fPad->cd(i);
665 gPad->SetBottomMargin(0.13);
666 gPad->SetLeftMargin(0.15);
667 }
668
669 Int_t column = 0;
670 for (unsigned int n = 0; n < optList.size(); n++) {
671 string optionStr = (string)optList[n];
672 TString drawEventOption = optList[n];
673
674 // Generating drawOption argument
675 size_t startPos = optionStr.find("(");
676 if (startPos != string::npos) drawEventOption = optList[n](0, startPos);
677
678 // Generating histogram option argument
679 string histOption = "";
680 size_t endPos = optionStr.find(")");
681 if (endPos != string::npos) {
682 TString histOptionTmp = optList[n](startPos + 1, endPos - startPos - 1);
683
684 histOption = (string)histOptionTmp;
685 size_t pos = 0;
686 while ((pos = histOption.find(",", pos)) != string::npos) {
687 histOption.replace(pos, 1, ":");
688 pos = pos + 1;
689 }
690 }
691
692 // Generating histogram pitch argument
693 string pitchOption = "";
694
695 startPos = optionStr.find("[");
696 endPos = optionStr.find("]");
697 Double_t pitch = 0;
698 if (endPos != string::npos) {
699 TString pitchOption = optList[n](startPos + 1, endPos - startPos - 1);
700 pitch = stod((string)pitchOption);
701 }
702
703 if (drawEventOption == "graph") this->DrawGraphs(column);
704
705 if (drawEventOption == "hist") this->DrawHistograms(column, histOption, pitch);
706 }
707
708 return fPad;
709}
710
719 if (fXYHitGraph != nullptr) {
720 delete fXYHitGraph;
721 fXYHitGraph = nullptr;
722 }
723 if (fXZHitGraph != nullptr) {
724 delete fXZHitGraph;
725 fXZHitGraph = nullptr;
726 }
727 if (fYZHitGraph != nullptr) {
728 delete fYZHitGraph;
729 fYZHitGraph = nullptr;
730 }
731
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()));
735
736 /* {{{ Creating xz, yz, and xy arrays and initializing graphs */
737 Int_t nXZ = 0;
738 Int_t nYZ = 0;
739 Int_t nXY = 0;
740
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);
746
747 if (type % XZ == 0) {
748 xz[0][nXZ] = x;
749 xz[1][nXZ] = z;
750 nXZ++;
751 }
752
753 if (type % YZ == 0) {
754 yz[0][nYZ] = y;
755 yz[1][nYZ] = z;
756 nYZ++;
757 }
758
759 if (type % XY == 0) {
760 xy[0][nXY] = x;
761 xy[1][nXY] = y;
762 nXY++;
763 }
764 }
765
766 fXZHitGraph = new TGraph(nXZ, &xz[0][0], &xz[1][0]);
767 fXZHitGraph->SetMarkerColor(kBlue);
768 fXZHitGraph->SetMarkerSize(0.3);
769 fXZHitGraph->SetMarkerStyle(20);
770
771 fYZHitGraph = new TGraph(nYZ, &yz[0][0], &yz[1][0]);
772 fYZHitGraph->SetMarkerColor(kRed);
773 fYZHitGraph->SetMarkerSize(0.3);
774 fYZHitGraph->SetMarkerStyle(20);
775
776 fXYHitGraph = new TGraph(nXY, &xy[0][0], &xy[1][0]);
777 fXYHitGraph->SetMarkerColor(kBlack);
778 fXYHitGraph->SetMarkerSize(0.3);
779 fXYHitGraph->SetMarkerStyle(20);
780 /* }}} */
781
782 char title[256];
783 sprintf(title, "Event ID %d", this->GetID());
784
785 if (nXZ > 0) {
786 fPad->cd(1 + 3 * column);
787 fXZHitGraph->SetTitle(title);
788 fXZHitGraph->Draw("AP*");
789
790 fXZHitGraph->GetXaxis()->SetTitle("X-axis (mm)");
791 fXZHitGraph->GetYaxis()->SetTitle("Z-axis (mm)");
792 }
793
794 if (nYZ > 0) {
795 fPad->cd(2 + 3 * column);
796 fYZHitGraph->SetTitle(title);
797 fYZHitGraph->Draw("AP");
798
799 fYZHitGraph->GetXaxis()->SetTitle("Y-axis (mm)");
800 fYZHitGraph->GetYaxis()->SetTitle("Z-axis (mm)");
801 }
802
803 if (nXY > 0) {
804 fPad->cd(3 + 3 * column);
805 fXYHitGraph->SetTitle(title);
806 fXYHitGraph->Draw("AP");
807
808 fXYHitGraph->GetXaxis()->SetTitle("X-axis (mm)");
809 fXYHitGraph->GetYaxis()->SetTitle("Y-axis (mm)");
810 }
811
812 column++;
813}
814
829void TRestDetectorHitsEvent::DrawHistograms(Int_t& column, const TString& histOption, double pitch) {
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));
835 }
836
837 double maxX, minX, maxY, minY, maxZ, minZ;
838 int nBinsX, nBinsY, nBinsZ;
839 // GetBoundaries reads dist.front()/back(), which is undefined for an empty projection
840 // (e.g. an event with no hits of a given type). Guard it so DrawEvent never crashes.
841 auto getBoundaries = [](std::vector<double>& v, double& mx, double& mn, int& nb) {
842 if (v.empty()) {
843 mn = -1;
844 mx = 1;
845 nb = 1;
846 return;
847 }
848 TRestHits::GetBoundaries(v, mx, mn, nb);
849 };
850 getBoundaries(fX, maxX, minX, nBinsX);
851 getBoundaries(fY, maxY, minY, nBinsY);
852 getBoundaries(fZ, maxZ, minZ, nBinsZ);
853
854 if (pitch > 0) {
855 nBinsX = std::round((maxX - minX) / pitch);
856 nBinsY = std::round((maxY - minY) / pitch);
857 nBinsZ = std::round((maxZ - minZ) / pitch);
858 }
859
860 // A histogram needs at least one bin; ensure we never request 0 bins for a degenerate
861 // event (all hits sharing a coordinate, or a sub-pitch extent when a pitch is given).
862 nBinsX = std::max(1, nBinsX);
863 nBinsY = std::max(1, nBinsY);
864 nBinsZ = std::max(1, nBinsZ);
865
866 delete fXYHisto;
867 fXYHisto = nullptr;
868 delete fXZHisto;
869 fXZHisto = nullptr;
870 delete fYZHisto;
871 fYZHisto = nullptr;
872
873 delete fXHisto;
874 fXHisto = nullptr;
875 delete fYHisto;
876 fYHisto = nullptr;
877 delete fZHisto;
878 fZHisto = nullptr;
879
880 fXYHisto = new TH2F("XY", "", nBinsX, minX, maxX, nBinsY, minY, maxY);
881 fXYHisto->SetDirectory(nullptr);
882 fXZHisto = new TH2F("XZ", "", nBinsX, minX, maxX, nBinsZ, minZ, maxZ);
883 fXZHisto->SetDirectory(nullptr);
884 fYZHisto = new TH2F("YZ", "", nBinsY, minY, maxY, nBinsZ, minZ, maxZ);
885 fYZHisto->SetDirectory(nullptr);
886
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);
893
894 fXYHisto->SetStats(false);
895 fXZHisto->SetStats(false);
896 fYZHisto->SetStats(false);
897
898 fXHisto->SetStats(false);
899 fYHisto->SetStats(false);
900 fZHisto->SetStats(false);
901
902 Int_t nYZ = 0, nXZ = 0, nXY = 0;
903 Int_t nX = 0, nY = 0, nZ = 0;
904
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);
911
912 if (type % XZ == 0) {
913 fXZHisto->Fill(x, z, en);
914 nXZ++;
915 }
916
917 if (type % YZ == 0) {
918 fYZHisto->Fill(y, z, en);
919 nYZ++;
920 }
921
922 if (type % XY == 0) {
923 fXYHisto->Fill(x, y, en);
924 nXY++;
925 }
926
927 if (type % X == 0) {
928 fXHisto->Fill(x);
929 nX++;
930 }
931
932 if (type % Y == 0) {
933 fYHisto->Fill(y);
934 nY++;
935 }
936
937 if (type % Z == 0) {
938 fZHisto->Fill(z);
939 nZ++;
940 }
941 }
942
943 TStyle style;
944 style.SetPalette(1);
945
946 if (nXZ > 0) {
947 fPad->cd(1 + 3 * column);
948 fXZHisto->Draw(histOption);
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);
956 }
957
958 if (nYZ > 0) {
959 fPad->cd(2 + 3 * column);
960 fYZHisto->Draw(histOption);
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);
968 }
969
970 if (nXY > 0) {
971 fPad->cd(3 + 3 * column);
972 fXYHisto->Draw(histOption);
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);
980 } else {
981 // When there is no XY projection (a strip readout, where hits are XZ/YZ) the pad is
982 // otherwise empty, so we use it for a 3D view of the event. A strip hit has one
983 // undetermined coordinate, so it is drawn as a line spanning that axis (XZ -> line
984 // along Y, YZ -> along X, XY -> along Z), colored by energy. An XZ and a YZ line
985 // cross in 3D where they share the same Z; that crossing (x_from_XZ, y_from_YZ, z)
986 // is the reconstructed hit position, so we highlight it with a marker, which sketches
987 // the event in 3D. (With several strips at the same Z these crossings also include
988 // ambiguous "ghost" combinations, inherent to strip readouts.) All objects are owned
989 // by the pad (kCanDelete) so they are freed when fPad is recreated on next DrawEvent.
990 fPad->cd(3 + 3 * column);
991
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);
997 frame->Draw();
998
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;
1004 }
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);
1009 };
1010
1011 std::vector<std::array<Double_t, 3>> xzHits; // {x, z, energy}
1012 std::vector<std::array<Double_t, 3>> yzHits; // {y, z, energy}
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);
1021
1022 TPolyLine3D* line = new TPolyLine3D(2);
1023 if (!hasX) { // undetermined X (e.g. YZ hit): line along X
1024 line->SetPoint(0, minX, y, z);
1025 line->SetPoint(1, maxX, y, z);
1026 yzHits.push_back({y, z, en});
1027 } else if (!hasY) { // undetermined Y (e.g. XZ hit): line along Y
1028 line->SetPoint(0, x, minY, z);
1029 line->SetPoint(1, x, maxY, z);
1030 xzHits.push_back({x, z, en});
1031 } else { // undetermined Z (e.g. XY hit): line along Z
1032 line->SetPoint(0, x, y, minZ);
1033 line->SetPoint(1, x, y, maxZ);
1034 }
1035 line->SetLineColor(energyColor(en));
1036 line->SetBit(kCanDelete);
1037 line->Draw();
1038 }
1039
1040 // Highlight the XZ/YZ crossings (same Z) -> reconstructed 3D positions of the event.
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);
1051 marker->Draw();
1052 }
1053 }
1054 }
1055
1056 column++;
1057
1058 if (nX > 0) {
1059 fPad->cd(1 + 3 * column);
1060 fXHisto->Draw(histOption);
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);
1068 }
1069
1070 if (nY > 0) {
1071 fPad->cd(2 + 3 * column);
1072 fYHisto->Draw(histOption);
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);
1080 }
1081
1082 if (nZ > 0) {
1083 fPad->cd(3 + 3 * column);
1084 fZHisto->Draw(histOption);
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);
1092 }
1093
1094 column++;
1095}
1096
1097void TRestDetectorHitsEvent::PrintEvent(Int_t nHits) const {
1099
1100 cout << "Total energy : " << GetTotalEnergy() << endl;
1101 cout << "Mean position : ( " << GetMeanPositionX() << " , " << GetMeanPositionY() << " , "
1102 << GetMeanPositionZ() << " ) " << endl;
1103 cout << "Number of hits : " << fHits->GetNumberOfHits() << endl;
1104 if (nHits != -1) {
1105 cout << "+++++++++++++++++++++++" << endl;
1106 cout << "Printing only the first " << nHits << " hits" << endl;
1107 }
1108
1109 fHits->PrintHits(nHits);
1110}
1111
1123TH2F* TRestDetectorHitsEvent::GetXYHistogram(std::vector<float> ranges, Double_t pitch, Double_t border) {
1124 double maxX, minX, maxY, minY;
1125 int nBinsX, nBinsY;
1126
1127 if (ranges.size() == 6) {
1128 nBinsX = ranges[0];
1129 minX = ranges[1];
1130 maxX = ranges[2];
1131
1132 nBinsY = ranges[3];
1133 minY = ranges[4];
1134 maxY = ranges[5];
1135 } else {
1136 std::vector<double> x, y, en;
1137
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));
1141 }
1142
1143 if (x.empty() && y.empty()) {
1144 std::cout << "TRestDetectorHitsEvent::GetXYHistogram. Empty histogram!" << std::endl;
1145 return nullptr;
1146 }
1147
1148 TRestHits::GetBoundaries(x, maxX, minX, nBinsX);
1149 TRestHits::GetBoundaries(y, maxY, minY, nBinsY);
1150
1151 maxX += border;
1152 minX -= border;
1153
1154 maxY += border;
1155 minY -= border;
1156
1157 if (pitch > 0) {
1158 nBinsX = std::round((maxX - minX) / pitch);
1159 nBinsY = std::round((maxY - minY) / pitch);
1160 }
1161 }
1162
1163 delete fXYHisto;
1164 fXYHisto = nullptr;
1165 fXYHisto = new TH2F("XY", "", nBinsX, minX, maxX, nBinsY, minY, maxY);
1166 fXYHisto->SetDirectory(nullptr);
1167 fXYHisto->SetStats(false);
1168
1169 Int_t nXY = 0;
1170
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);
1176
1177 if (type % XY == 0 || type % XYZ == 0) {
1178 fXYHisto->Fill(x, y, en);
1179 nXY++;
1180 }
1181 }
1182
1183 TStyle style;
1184 style.SetPalette(1);
1185
1186 if (nXY > 0) {
1187 fXYHisto->Draw("col");
1188 fXYHisto->Draw("cont3 same");
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);
1196 }
1197
1198 return fXYHisto;
1199}
1200
1212TH2F* TRestDetectorHitsEvent::GetXZHistogram(std::vector<float> ranges, Double_t pitch, Double_t border) {
1213 double maxX, minX, maxZ, minZ;
1214 int nBinsX, nBinsZ;
1215
1216 if (ranges.size() == 6) {
1217 nBinsX = ranges[0];
1218 minX = ranges[1];
1219 maxX = ranges[2];
1220
1221 nBinsZ = ranges[3];
1222 minZ = ranges[4];
1223 maxZ = ranges[5];
1224 } else {
1225 std::vector<double> x, z;
1226
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));
1230 }
1231
1232 if (x.empty() || z.empty()) {
1233 std::cout << "TRestDetectorHitsEvent::GetXZHistogram. Empty histogram!" << std::endl;
1234 return nullptr;
1235 }
1236
1237 TRestHits::GetBoundaries(x, maxX, minX, nBinsX);
1238 TRestHits::GetBoundaries(z, maxZ, minZ, nBinsZ);
1239
1240 maxX += border;
1241 minX -= border;
1242
1243 maxZ += border;
1244 minZ -= border;
1245
1246 if (pitch > 0) {
1247 nBinsX = std::round((maxX - minX) / pitch);
1248 nBinsZ = std::round((maxZ - minZ) / pitch);
1249 }
1250 }
1251
1252 delete fXZHisto;
1253 fXZHisto = nullptr;
1254 fXZHisto = new TH2F("XZ", "", nBinsX, minX, maxX, nBinsZ, minZ, maxZ);
1255 fXZHisto->SetDirectory(nullptr);
1256 fXZHisto->SetStats(false);
1257
1258 Int_t nXZ = 0;
1259
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);
1265
1266 if (type % XZ == 0 || type % XYZ == 0) {
1267 fXZHisto->Fill(x, z, en);
1268 nXZ++;
1269 }
1270 }
1271
1272 TStyle style;
1273 style.SetPalette(1);
1274
1275 if (nXZ > 0) {
1276 fXZHisto->Draw("col");
1277 fXZHisto->Draw("cont3 same");
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);
1285 }
1286
1287 return fXZHisto;
1288}
1289
1301TH2F* TRestDetectorHitsEvent::GetYZHistogram(std::vector<float> ranges, Double_t pitch, Double_t border) {
1302 double maxY, minY, maxZ, minZ;
1303 int nBinsY, nBinsZ;
1304
1305 if (ranges.size() == 6) {
1306 nBinsY = ranges[0];
1307 minY = ranges[1];
1308 maxY = ranges[2];
1309
1310 nBinsZ = ranges[3];
1311 minZ = ranges[4];
1312 maxZ = ranges[5];
1313 } else {
1314 std::vector<double> y, z, en;
1315
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));
1319 }
1320
1321 if (y.empty() || z.empty()) {
1322 std::cout << "TRestDetectorHitsEvent::GetYZHistogram. Empty histogram!" << std::endl;
1323 return nullptr;
1324 }
1325
1326 TRestHits::GetBoundaries(y, maxY, minY, nBinsY);
1327 TRestHits::GetBoundaries(z, maxZ, minZ, nBinsZ);
1328
1329 maxY += border;
1330 minY -= border;
1331
1332 maxZ += border;
1333 minZ -= border;
1334
1335 if (pitch > 0) {
1336 nBinsY = std::round((maxY - minZ) / pitch);
1337 nBinsZ = std::round((maxZ - minZ) / pitch);
1338 }
1339 }
1340
1341 delete fYZHisto;
1342 fYZHisto = nullptr;
1343 fYZHisto = new TH2F("YZ", "", nBinsY, minY, maxY, nBinsZ, minZ, maxZ);
1344 fYZHisto->SetDirectory(nullptr);
1345 fYZHisto->SetStats(false);
1346
1347 Int_t nYZ = 0;
1348
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);
1354
1355 if (type % YZ == 0 || type % XYZ == 0) {
1356 fYZHisto->Fill(y, z, en);
1357 nYZ++;
1358 }
1359 }
1360
1361 TStyle style;
1362 style.SetPalette(1);
1363
1364 if (nYZ > 0) {
1365 fYZHisto->Draw("col");
1366 fYZHisto->Draw("cont3 same");
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);
1374 }
1375
1376 return fYZHisto;
1377}
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
Definition: TRestEvent.cxx:187
virtual void Initialize()=0
Definition: TRestEvent.cxx:73
It saves a 3-coordinate position and an energy for each punctual deposition.
Definition: TRestHits.h:39
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,...
Definition: TRestHits.cxx:216
virtual void RemoveHits()
It removes all hits inside the class.
Definition: TRestHits.cxx:371
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...
Definition: TRestHits.cxx:1169
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...
Definition: TRestHits.cxx:738
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 ...
Definition: TRestHits.cxx:262
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,...
Definition: TRestHits.cxx:176
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,...
Definition: TRestHits.cxx:200
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.
Definition: TRestHits.cxx:345
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 ...
Definition: TRestHits.cxx:283
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...
Definition: TRestHits.cxx:230
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,...
Definition: TRestHits.cxx:1095
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.
Definition: TRestHits.cxx:478
virtual void PrintHits(Int_t nHits=-1) const
It prints on screen the first nHits from the list.
Definition: TRestHits.cxx:1380
static std::vector< std::string > GetOptions(std::string optionsStr)
Returns all the options in an option string.
Definition: TRestTools.cxx:86