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 "TCanvas.h"
43#include "TRandom.h"
44#include "TRestStringHelper.h"
45#include "TRestTools.h"
46#include "TStyle.h"
47
48using namespace std;
49using namespace TMath;
50
52
66 fHits = new TRestHits();
67
68 fPad = nullptr;
69
70 fXYHitGraph = nullptr;
71 fXZHitGraph = nullptr;
72 fYZHitGraph = nullptr;
73
74 fXYHisto = nullptr;
75 fXZHisto = nullptr;
76 fYZHisto = nullptr;
77
78 fXZHits = nullptr;
79 fYZHits = nullptr;
80 fXYZHits = nullptr;
81
82 fXHisto = nullptr;
83 fYHisto = nullptr;
84 fZHisto = nullptr;
85}
86
91
98void TRestDetectorHitsEvent::AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t,
99 REST_HitType type) {
100 fHits->AddHit(x, y, z, en, t, type);
101}
102
108void TRestDetectorHitsEvent::AddHit(TVector3 pos, Double_t en, Double_t t, REST_HitType type) {
109 fHits->AddHit(pos, en, t, type);
110}
111
117
118 fHits->RemoveHits();
119
120 if (fXZHits) {
121 delete fXZHits;
122 fXZHits = nullptr;
123 }
124 if (fYZHits) {
125 delete fYZHits;
126 fYZHits = nullptr;
127 }
128 if (fXYZHits) {
129 delete fXYZHits;
130 fXYZHits = nullptr;
131 }
132
133 fXZHits = new TRestHits();
134 fYZHits = new TRestHits();
135 fXYZHits = new TRestHits();
136}
137
138void TRestDetectorHitsEvent::Sort(bool(compareCondition)(const TRestHits::iterator& hit1,
139 const TRestHits::iterator& hit2)) {
140 if (compareCondition == 0) {
141 // default sort logic: z from smaller to greater
142 std::sort(fHits->begin(), fHits->end(),
143 [](const TRestHits::iterator& hit1, const TRestHits::iterator& hit2) -> bool {
144 return hit1.z() < hit2.z();
145 });
146 } else {
147 std::sort(fHits->begin(), fHits->end(), compareCondition);
148 }
149}
150
151void TRestDetectorHitsEvent::Shuffle(int NLoop) {
152 Int_t nHits = fHits->GetNumberOfHits();
153 if (nHits >= 2) {
154 for (int n = 0; n < NLoop; n++) {
155 Int_t hit1 = (Int_t)(nHits * gRandom->Uniform(0, 1));
156 Int_t hit2 = (Int_t)(nHits * gRandom->Uniform(0, 1));
157
158 fHits->SwapHits(hit1, hit2);
159 }
160 }
161}
162
172
173 for (unsigned int i = 0; i < this->GetNumberOfHits(); i++)
174 if (GetType(i) == XZ)
175 fXZHits->AddHit(this->GetX(i), this->GetY(i), this->GetZ(i), this->GetEnergy(i), this->GetTime(i),
176 XZ);
177
178 return fXZHits;
179}
180
190
191 for (unsigned int i = 0; i < this->GetNumberOfHits(); i++)
192 if (GetType(i) == YZ)
193 fYZHits->AddHit(this->GetX(i), this->GetY(i), this->GetZ(i), this->GetEnergy(i), this->GetTime(i),
194 YZ);
195
196 return fYZHits;
197}
198
207
208 for (unsigned int i = 0; i < this->GetNumberOfHits(); i++)
209 if (GetType(i) == XYZ)
210 fXYZHits->AddHit(this->GetX(i), this->GetY(i), this->GetZ(i), this->GetEnergy(i),
211 this->GetTime(i), XYZ);
212
213 return fXYZHits;
214}
215
223Bool_t TRestDetectorHitsEvent::anyHitInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
224 if (fHits->GetNumberOfHitsInsideCylinder(x0, x1, radius) > 0) return true;
225
226 return false;
227}
228
236Bool_t TRestDetectorHitsEvent::allHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
237 if ((size_t)fHits->GetNumberOfHitsInsideCylinder(x0, x1, radius) == GetNumberOfHits()) return true;
238
239 return false;
240}
241
250Double_t TRestDetectorHitsEvent::GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
251 return fHits->GetEnergyInCylinder(x0, x1, radius);
252}
253
262Int_t TRestDetectorHitsEvent::GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
263 return fHits->GetNumberOfHitsInsideCylinder(x0, x1, radius);
264}
265
274TVector3 TRestDetectorHitsEvent::GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius) {
275 return fHits->GetMeanPositionInCylinder(x0, x1, radius);
276}
277
287Bool_t TRestDetectorHitsEvent::anyHitInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY,
288 Double_t theta) {
289 if (fHits->GetNumberOfHitsInsidePrism(x0, x1, sizeX, sizeY, theta) > 0) return true;
290
291 return false;
292}
293
303Bool_t TRestDetectorHitsEvent::allHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY,
304 Double_t theta) {
305 if ((size_t)fHits->GetNumberOfHitsInsidePrism(x0, x1, sizeX, sizeY, theta) == GetNumberOfHits())
306 return true;
307
308 return false;
309}
310
321Double_t TRestDetectorHitsEvent::GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY,
322 Double_t theta) {
323 return fHits->GetEnergyInPrism(x0, x1, sizeX, sizeY, theta);
324}
325
336Int_t TRestDetectorHitsEvent::GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX,
337 Double_t sizeY, Double_t theta) {
338 return fHits->GetNumberOfHitsInsidePrism(x0, x1, sizeX, sizeY, theta);
339}
340
351TVector3 TRestDetectorHitsEvent::GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX,
352 Double_t sizeY, Double_t theta) {
353 return fHits->GetMeanPositionInPrism(x0, x1, sizeX, sizeY, theta);
354}
355
367 Double_t radius) {
368 Double_t rad2 = radius * radius;
369 Double_t hitDistance = rad2;
370
371 Double_t d2, l;
372
373 TVector3 axis = x1 - x0;
374 Double_t cylLength = axis.Mag();
375
376 Int_t nhits = 0;
377 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
378 if (fHits->isHitNInsideCylinder(n, x0, x1, radius)) {
379 l = axis.Dot(this->GetPosition(n) - x0) / cylLength;
380
381 d2 = rad2 - (this->GetPosition(n) - x0).Mag2() + l * l;
382
383 if (d2 < hitDistance) hitDistance = d2;
384
385 nhits++;
386 }
387 }
388
389 if (nhits == 0) return -1;
390
391 return TMath::Sqrt(hitDistance);
392}
393
405 Double_t radius) {
406 TVector3 axis = x1 - x0;
407 Double_t cylLength = axis.Mag();
408
409 Double_t hitDistance = cylLength;
410 Double_t d = cylLength;
411
412 Int_t nhits = 0;
413 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
414 if (fHits->isHitNInsideCylinder(n, x0, x1, radius)) {
415 d = cylLength - axis.Dot(this->GetPosition(n) - x0) / cylLength;
416
417 if (d < hitDistance) hitDistance = d;
418
419 nhits++;
420 }
421 }
422
423 if (nhits == 0) return -1;
424
425 return hitDistance;
426}
427
439 Double_t radius) {
440 TVector3 axis = x1 - x0;
441 Double_t cylLength = axis.Mag();
442
443 Double_t hitDistance = cylLength;
444 Double_t d = cylLength;
445
446 Int_t nhits = 0;
447 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
448 if (fHits->isHitNInsideCylinder(n, x0, x1, radius)) {
449 d = axis.Dot(this->GetPosition(n) - x0) / cylLength;
450
451 if (d < hitDistance) hitDistance = d;
452
453 nhits++;
454 }
455 }
456
457 if (nhits == 0) return -1;
458
459 return hitDistance;
460}
461
475 Double_t sizeX, Double_t sizeY,
476 Double_t theta) {
477 Double_t dX = sizeX / 2;
478 Double_t dY = sizeY / 2;
479
480 Double_t hitDistance = max(dX, dY);
481
482 Double_t d;
483 Int_t nhits = 0;
484 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
485 if (fHits->isHitNInsidePrism(n, x0, x1, sizeX, sizeY, theta)) {
486 dX = sizeX / 2 - TMath::Abs((this->GetPosition(n) - x0).X());
487 dY = sizeY / 2 - TMath::Abs((this->GetPosition(n) - x0).Y());
488
489 d = min(dX, dY);
490
491 if (d < hitDistance) hitDistance = d;
492
493 nhits++;
494 }
495 }
496
497 if (nhits == 0) return -1;
498
499 return hitDistance;
500}
501
515 Double_t sizeX, Double_t sizeY,
516 Double_t theta) {
517 TVector3 axis = x1 - x0;
518 Double_t prismLength = axis.Mag();
519
520 Double_t hitDistance = prismLength;
521
522 Double_t d;
523 Int_t nhits = 0;
524 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
525 if (fHits->isHitNInsidePrism(n, x0, x1, sizeX, sizeY, theta)) {
526 d = prismLength - axis.Dot(this->GetPosition(n) - x0) / prismLength;
527
528 if (d < hitDistance) hitDistance = d;
529
530 nhits++;
531 }
532 }
533
534 if (nhits == 0) return -1;
535
536 return hitDistance;
537}
538
552 const TVector3& x1, Double_t sizeX,
553 Double_t sizeY, Double_t theta) {
554 TVector3 axis = x1 - x0;
555 Double_t prismLength = axis.Mag();
556
557 Double_t hitDistance = prismLength;
558
559 Double_t d;
560 Int_t nhits = 0;
561 for (unsigned int n = 0; n < GetNumberOfHits(); n++) {
562 if (fHits->isHitNInsidePrism(n, x0, x1, sizeX, sizeY, theta)) {
563 d = axis.Dot(this->GetPosition(n) - x0) / prismLength;
564
565 if (d < hitDistance) hitDistance = d;
566
567 nhits++;
568 }
569 }
570
571 if (nhits == 0) return -1;
572
573 return hitDistance;
574}
575
600TPad* TRestDetectorHitsEvent::DrawEvent(const TString& option) {
601 vector<TString> optList = Vector_cast<string, TString>(TRestTools::GetOptions((string)option));
602
603 for (unsigned int n = 0; n < optList.size(); n++) {
604 if (optList[n] == "print") this->PrintEvent();
605 }
606
607 optList.erase(std::remove(optList.begin(), optList.end(), "print"), optList.end());
608
610 // which means that it should be extracted from the hit array
611 if (optList.size() == 0) optList.push_back("hist(Cont1,col)[3]");
612
613 if (fPad != nullptr) {
614 delete fPad;
615 fPad = nullptr;
616 }
617
618 fPad = new TPad(this->GetName(), " ", 0, 0, 1, 1);
619 fPad->Divide(3, 2 * optList.size());
620 fPad->Draw();
621
622 Int_t column = 0;
623 for (unsigned int n = 0; n < optList.size(); n++) {
624 string optionStr = (string)optList[n];
625 TString drawEventOption = optList[n];
626
627 // Generating drawOption argument
628 size_t startPos = optionStr.find("(");
629 if (startPos != string::npos) drawEventOption = optList[n](0, startPos);
630
631 // Generating histogram option argument
632 string histOption = "";
633 size_t endPos = optionStr.find(")");
634 if (endPos != string::npos) {
635 TString histOptionTmp = optList[n](startPos + 1, endPos - startPos - 1);
636
637 histOption = (string)histOptionTmp;
638 size_t pos = 0;
639 while ((pos = histOption.find(",", pos)) != string::npos) {
640 histOption.replace(pos, 1, ":");
641 pos = pos + 1;
642 }
643 }
644
645 // Generating histogram pitch argument
646 string pitchOption = "";
647
648 startPos = optionStr.find("[");
649 endPos = optionStr.find("]");
650 Double_t pitch = 0;
651 if (endPos != string::npos) {
652 TString pitchOption = optList[n](startPos + 1, endPos - startPos - 1);
653 pitch = stod((string)pitchOption);
654 }
655
656 if (drawEventOption == "graph") this->DrawGraphs(column);
657
658 if (drawEventOption == "hist") this->DrawHistograms(column, histOption, pitch);
659 }
660
661 return fPad;
662}
663
672 if (fXYHitGraph != nullptr) {
673 delete fXYHitGraph;
674 fXYHitGraph = nullptr;
675 }
676 if (fXZHitGraph != nullptr) {
677 delete fXZHitGraph;
678 fXZHitGraph = nullptr;
679 }
680 if (fYZHitGraph != nullptr) {
681 delete fYZHitGraph;
682 fYZHitGraph = nullptr;
683 }
684
685 vector<vector<Double_t>> xz(2, vector<Double_t>(this->GetNumberOfHits()));
686 vector<vector<Double_t>> yz(2, vector<Double_t>(this->GetNumberOfHits()));
687 vector<vector<Double_t>> xy(2, vector<Double_t>(this->GetNumberOfHits()));
688
689 /* {{{ Creating xz, yz, and xy arrays and initializing graphs */
690 Int_t nXZ = 0;
691 Int_t nYZ = 0;
692 Int_t nXY = 0;
693
694 for (unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
695 Double_t x = fHits->GetX(nhit);
696 Double_t y = fHits->GetY(nhit);
697 Double_t z = fHits->GetZ(nhit);
698 int type = fHits->GetType(nhit);
699
700 if (type % XZ == 0) {
701 xz[0][nXZ] = x;
702 xz[1][nXZ] = z;
703 nXZ++;
704 }
705
706 if (type % YZ == 0) {
707 yz[0][nYZ] = y;
708 yz[1][nYZ] = z;
709 nYZ++;
710 }
711
712 if (type % XY == 0) {
713 xy[0][nXY] = x;
714 xy[1][nXY] = y;
715 nXY++;
716 }
717 }
718
719 fXZHitGraph = new TGraph(nXZ, &xz[0][0], &xz[1][0]);
720 fXZHitGraph->SetMarkerColor(kBlue);
721 fXZHitGraph->SetMarkerSize(0.3);
722 fXZHitGraph->SetMarkerStyle(20);
723
724 fYZHitGraph = new TGraph(nYZ, &yz[0][0], &yz[1][0]);
725 fYZHitGraph->SetMarkerColor(kRed);
726 fYZHitGraph->SetMarkerSize(0.3);
727 fYZHitGraph->SetMarkerStyle(20);
728
729 fXYHitGraph = new TGraph(nXY, &xy[0][0], &xy[1][0]);
730 fXYHitGraph->SetMarkerColor(kBlack);
731 fXYHitGraph->SetMarkerSize(0.3);
732 fXYHitGraph->SetMarkerStyle(20);
733 /* }}} */
734
735 char title[256];
736 sprintf(title, "Event ID %d", this->GetID());
737
738 if (nXZ > 0) {
739 fPad->cd(1 + 3 * column);
740 fXZHitGraph->SetTitle(title);
741 fXZHitGraph->Draw("AP*");
742
743 fXZHitGraph->GetXaxis()->SetTitle("X-axis (mm)");
744 fXZHitGraph->GetYaxis()->SetTitle("Z-axis (mm)");
745 }
746
747 if (nYZ > 0) {
748 fPad->cd(2 + 3 * column);
749 fYZHitGraph->SetTitle(title);
750 fYZHitGraph->Draw("AP");
751
752 fYZHitGraph->GetXaxis()->SetTitle("Y-axis (mm)");
753 fYZHitGraph->GetYaxis()->SetTitle("Z-axis (mm)");
754 }
755
756 if (nXY > 0) {
757 fPad->cd(3 + 3 * column);
758 fXYHitGraph->SetTitle(title);
759 fXYHitGraph->Draw("AP");
760
761 fXYHitGraph->GetXaxis()->SetTitle("X-axis (mm)");
762 fXYHitGraph->GetYaxis()->SetTitle("Y-axis (mm)");
763 }
764
765 column++;
766}
767
782void TRestDetectorHitsEvent::DrawHistograms(Int_t& column, const TString& histOption, double pitch) {
783 std::vector<double> fX, fY, fZ;
784 for (unsigned int i = 0; i < GetNumberOfHits(); i++) {
785 if (GetType(i) % X == 0) fX.emplace_back(GetX(i));
786 if (GetType(i) % Y == 0) fY.emplace_back(GetY(i));
787 if (GetType(i) % Z == 0) fZ.emplace_back(GetZ(i));
788 }
789
790 double maxX, minX, maxY, minY, maxZ, minZ;
791 int nBinsX, nBinsY, nBinsZ;
792 TRestHits::GetBoundaries(fX, maxX, minX, nBinsX);
793 TRestHits::GetBoundaries(fY, maxY, minY, nBinsY);
794 TRestHits::GetBoundaries(fZ, maxZ, minZ, nBinsZ);
795
796 if (pitch > 0) {
797 nBinsX = std::round((maxX - minX) / pitch);
798 nBinsY = std::round((maxY - minY) / pitch);
799 nBinsZ = std::round((maxZ - minZ) / pitch);
800 }
801
802 delete fXYHisto;
803 delete fXZHisto;
804 delete fYZHisto;
805
806 delete fXHisto;
807 delete fYHisto;
808 delete fZHisto;
809
810 fXYHisto = new TH2F("XY", "", nBinsX, minX, maxX, nBinsY, minY, maxY);
811 fXZHisto = new TH2F("XZ", "", nBinsX, minX, maxX, nBinsZ, minZ, maxZ);
812 fYZHisto = new TH2F("YZ", "", nBinsY, minY, maxY, nBinsZ, minZ, maxZ);
813
814 fXHisto = new TH1F("X", "", nBinsX, minX, maxX);
815 fYHisto = new TH1F("Y", "", nBinsY, minY, maxY);
816 fZHisto = new TH1F("Z", "", nBinsZ, minZ, maxZ);
817
818 fXYHisto->SetStats(false);
819 fXZHisto->SetStats(false);
820 fYZHisto->SetStats(false);
821
822 fXHisto->SetStats(false);
823 fYHisto->SetStats(false);
824 fZHisto->SetStats(false);
825
826 Int_t nYZ = 0, nXZ = 0, nXY = 0;
827 Int_t nX = 0, nY = 0, nZ = 0;
828
829 for (unsigned int nhit = 0; nhit < this->GetNumberOfHits(); nhit++) {
830 Double_t x = fHits->GetX(nhit);
831 Double_t y = fHits->GetY(nhit);
832 Double_t z = fHits->GetZ(nhit);
833 Double_t en = fHits->GetEnergy(nhit);
834 int type = fHits->GetType(nhit);
835
836 if (type % XZ == 0) {
837 fXZHisto->Fill(x, z, en);
838 nXZ++;
839 }
840
841 if (type % YZ == 0) {
842 fYZHisto->Fill(y, z, en);
843 nYZ++;
844 }
845
846 if (type % XY == 0) {
847 fXYHisto->Fill(x, y, en);
848 nXY++;
849 }
850
851 if (type % X == 0) {
852 fXHisto->Fill(x);
853 nX++;
854 }
855
856 if (type % Y == 0) {
857 fYHisto->Fill(y);
858 nY++;
859 }
860
861 if (type % Z == 0) {
862 fZHisto->Fill(z);
863 nZ++;
864 }
865 }
866
867 TStyle style;
868 style.SetPalette(1);
869
870 if (nXZ > 0) {
871 fPad->cd(1 + 3 * column);
872 fXZHisto->Draw(histOption);
873 fXZHisto->GetXaxis()->SetTitle("X-axis (mm)");
874 fXZHisto->GetYaxis()->SetTitle("Z-axis (mm)");
875 fXZHisto->GetYaxis()->SetTitleSize(1.4 * fXZHisto->GetYaxis()->GetTitleSize());
876 fXZHisto->GetXaxis()->SetTitleSize(1.4 * fXZHisto->GetXaxis()->GetTitleSize());
877 fXZHisto->GetYaxis()->SetLabelSize(1.25 * fXZHisto->GetYaxis()->GetLabelSize());
878 fXZHisto->GetXaxis()->SetLabelSize(1.25 * fXZHisto->GetXaxis()->GetLabelSize());
879 fXZHisto->GetYaxis()->SetTitleOffset(1.75);
880 }
881
882 if (nYZ > 0) {
883 fPad->cd(2 + 3 * column);
884 fYZHisto->Draw(histOption);
885 fYZHisto->GetXaxis()->SetTitle("Y-axis (mm)");
886 fYZHisto->GetYaxis()->SetTitle("Z-axis (mm)");
887 fYZHisto->GetYaxis()->SetTitleSize(1.4 * fYZHisto->GetYaxis()->GetTitleSize());
888 fYZHisto->GetXaxis()->SetTitleSize(1.4 * fYZHisto->GetXaxis()->GetTitleSize());
889 fYZHisto->GetYaxis()->SetLabelSize(1.25 * fYZHisto->GetYaxis()->GetLabelSize());
890 fYZHisto->GetXaxis()->SetLabelSize(1.25 * fYZHisto->GetXaxis()->GetLabelSize());
891 fYZHisto->GetYaxis()->SetTitleOffset(1.75);
892 }
893
894 if (nXY > 0) {
895 fPad->cd(3 + 3 * column);
896 fXYHisto->Draw(histOption);
897 fXYHisto->GetXaxis()->SetTitle("X-axis (mm)");
898 fXYHisto->GetYaxis()->SetTitle("Y-axis (mm)");
899 fXYHisto->GetYaxis()->SetTitleSize(1.4 * fXYHisto->GetYaxis()->GetTitleSize());
900 fXYHisto->GetXaxis()->SetTitleSize(1.4 * fXYHisto->GetXaxis()->GetTitleSize());
901 fXYHisto->GetYaxis()->SetLabelSize(1.25 * fXYHisto->GetYaxis()->GetLabelSize());
902 fXYHisto->GetXaxis()->SetLabelSize(1.25 * fXYHisto->GetXaxis()->GetLabelSize());
903 fXYHisto->GetYaxis()->SetTitleOffset(1.75);
904 }
905
906 column++;
907
908 if (nX > 0) {
909 fPad->cd(1 + 3 * column);
910 fXHisto->Draw(histOption);
911 fXHisto->GetXaxis()->SetTitle("X-axis (mm)");
912 fXHisto->GetYaxis()->SetTitle("Number of events");
913 fXHisto->GetYaxis()->SetTitleSize(1.4 * fXHisto->GetYaxis()->GetTitleSize());
914 fXHisto->GetXaxis()->SetTitleSize(1.4 * fXHisto->GetXaxis()->GetTitleSize());
915 fXHisto->GetYaxis()->SetLabelSize(1.25 * fXHisto->GetYaxis()->GetLabelSize());
916 fXHisto->GetXaxis()->SetLabelSize(1.25 * fXHisto->GetXaxis()->GetLabelSize());
917 fXHisto->GetYaxis()->SetTitleOffset(1.75);
918 }
919
920 if (nY > 0) {
921 fPad->cd(2 + 3 * column);
922 fYHisto->Draw(histOption);
923 fYHisto->GetXaxis()->SetTitle("Y-axis (mm)");
924 fYHisto->GetYaxis()->SetTitle("Number of events");
925 fYHisto->GetYaxis()->SetTitleSize(1.4 * fYHisto->GetYaxis()->GetTitleSize());
926 fYHisto->GetXaxis()->SetTitleSize(1.4 * fYHisto->GetXaxis()->GetTitleSize());
927 fYHisto->GetYaxis()->SetLabelSize(1.25 * fYHisto->GetYaxis()->GetLabelSize());
928 fYHisto->GetXaxis()->SetLabelSize(1.25 * fYHisto->GetXaxis()->GetLabelSize());
929 fYHisto->GetYaxis()->SetTitleOffset(1.75);
930 }
931
932 if (nZ > 0) {
933 fPad->cd(3 + 3 * column);
934 fZHisto->Draw(histOption);
935 fZHisto->GetXaxis()->SetTitle("Z-axis (mm)");
936 fZHisto->GetYaxis()->SetTitle("Number of events");
937 fZHisto->GetYaxis()->SetTitleSize(1.4 * fYHisto->GetYaxis()->GetTitleSize());
938 fZHisto->GetXaxis()->SetTitleSize(1.4 * fYHisto->GetXaxis()->GetTitleSize());
939 fZHisto->GetYaxis()->SetLabelSize(1.25 * fYHisto->GetYaxis()->GetLabelSize());
940 fZHisto->GetXaxis()->SetLabelSize(1.25 * fYHisto->GetXaxis()->GetLabelSize());
941 fZHisto->GetYaxis()->SetTitleOffset(1.75);
942 }
943
944 column++;
945}
946
947void TRestDetectorHitsEvent::PrintEvent(Int_t nHits) const {
949
950 cout << "Total energy : " << GetEnergy() << endl;
951 cout << "Mean position : ( " << GetMeanPositionX() << " , " << GetMeanPositionY() << " , "
952 << GetMeanPositionZ() << " ) " << endl;
953 cout << "Number of hits : " << fHits->GetNumberOfHits() << endl;
954 if (nHits != -1) {
955 cout << "+++++++++++++++++++++++" << endl;
956 cout << "Printing only the first " << nHits << " hits" << endl;
957 }
958
959 fHits->PrintHits(nHits);
960}
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.
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.
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:181
virtual void Initialize()=0
Definition: TRestEvent.cxx:71
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