GRSISort
"v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TDetector.cxx
Go to the documentation of this file.
1
#include "
TDetector.h
"
2
#include "TClass.h"
3
4
TDetector::TDetector
(
const
TDetector
& rhs) : TObject(rhs)
5
{
6
/// Default Copy constructor.
7
rhs.
Copy
(*
this
);
8
}
9
10
TDetector::TDetector
(
TDetector
&& rhs) noexcept : TObject(rhs)
11
{
12
/// Default Move constructor.
13
rhs.Copy(*
this
);
14
}
15
16
TDetector::~TDetector
()
17
{
18
/// Default Destructor.
19
for
(
auto
* hit :
fHits
) {
20
delete
hit;
21
}
22
}
23
24
void
TDetector::Copy
(TObject& rhs)
const
25
{
26
// if(!rhs.InheritsFrom("TDetector"))
27
// return;
28
TObject::Copy(rhs);
29
static_cast<
TDetector
&
>
(rhs).
fHits
.resize(
fHits
.size());
30
for
(
size_t
i = 0; i <
fHits
.size(); ++i) {
31
// we need to use IsA()->New() to make a new hit of whatever derived type this actually is
32
static_cast<
TDetector
&
>
(rhs).
fHits
[i] =
static_cast<
TDetectorHit
*
>
(
fHits
[i]->IsA()->New());
33
fHits
[i]->Copy(*(
static_cast<
TDetector
&
>
(rhs).
fHits
[i]));
34
}
35
}
36
37
void
TDetector::Print
(Option_t*)
const
38
{
39
/// Default print statement for TDetector.
40
Print
(std::cout);
41
}
42
43
void
TDetector::Print
(std::ostream& out)
const
44
{
45
/// Print detector to stream out. Iterates over hits and prints them.
46
std::ostringstream str;
47
str <<
"TDetector "
<<
this
<<
":"
<< std::endl;
48
for
(
auto
* hit :
fHits
) {
49
hit->Print(str);
50
}
51
out << str.str();
52
}
53
54
void
TDetector::ClearTransients
()
55
{
56
for
(
auto
* hit :
fHits
) {
57
hit->ClearTransients();
58
}
59
}
60
61
TDetectorHit
*
TDetector::GetHit
(
const
int
& index)
const
62
{
63
try
{
64
return
fHits
.at(index);
65
}
catch
(
const
std::out_of_range& oor) {
66
std::cerr << ClassName() <<
" is out of range: "
<< oor.what() << std::endl;
67
throw
grsi::exit_exception
(1);
68
}
69
return
nullptr
;
70
}
TDetector.h
TDetectorHit
Definition
TDetectorHit.h:48
TDetector
Definition
TDetector.h:34
TDetector::fHits
std::vector< TDetectorHit * > fHits
Definition
TDetector.h:88
TDetector::Print
void Print(Option_t *opt="") const override
!
Definition
TDetector.cxx:37
TDetector::ClearTransients
virtual void ClearTransients()
!
Definition
TDetector.cxx:54
TDetector::Copy
void Copy(TObject &) const override
!
Definition
TDetector.cxx:24
TDetector::~TDetector
~TDetector()
Definition
TDetector.cxx:16
TDetector::GetHit
virtual TDetectorHit * GetHit(const int &index) const
Definition
TDetector.cxx:61
TDetector::TDetector
TDetector()=default
grsi::exit_exception
Definition
Globals.h:74
libraries
TFormat
TDetector.cxx
GRSISort ("v4.0.0.5") Reference Guide Generated on Mon Feb 3 2025 16:38:05.