BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnHit.cxx
Go to the documentation of this file.
1
2
#include "
BmnHit.h
"
3
4
#include "FairRootManager.h"
5
6
#include <
TBranch.h
>
7
#include <
TChain.h
>
8
#include <
TClonesArray.h
>
9
#include <map>
10
#include <string>
11
12
BmnHit::BmnHit
()
13
:
FairHit
()
14
{
15
fUsing
=
kFALSE
;
16
fFlag
=
kTRUE
;
17
fIndex
= -1;
18
fDetId
=
kREF
;
19
fStation
= -1;
20
fModule
= -1;
21
fType
= -1;
22
fLength
= -1.0;
23
fResX
= -1000.;
24
fResY
= -1000.;
25
fCovXY
= -1000.;
26
fPseudo
=
false
;
27
}
28
29
BmnHit::BmnHit
(
Int_t
detID,
TVector3
pos,
TVector3
dpos,
Int_t
index)
30
:
FairHit
(detID, pos, dpos, index)
31
{
32
fUsing
=
kFALSE
;
33
fFlag
=
kTRUE
;
34
fIndex
= -1;
35
fDetId
=
kREF
;
36
fStation
= -1;
37
fModule
= -1;
38
fType
= -1;
39
fLength
= -1.0;
40
fResX
= -1000.;
41
fResY
= -1000.;
42
fCovXY
= -1000.;
43
fPseudo
=
false
;
44
}
45
46
BmnHit::~BmnHit
() {}
47
48
// Strip cluster of the hit in the given strip layer, taken from the cluster branch of this layer
49
StripCluster
*
BmnHit::GetCluster
(
const
char
* cluster_branch_name, StripLayerType layer)
50
{
51
// a pseudo hit is reconstructed from a lower layer cluster only
52
if
(layer ==
UpperStripLayer
&&
fPseudo
)
53
return
nullptr
;
54
Int_t
cluster_index = (layer ==
LowerStripLayer
) ?
fLowerClusterIndex
:
fUpperClusterIndex
;
55
56
// each branch is looked up only once for the current FairRootManager, because every GetObject call
57
// for a branch which is not in memory takes a new slot of the internal array of FairRootManager
58
static
thread_local
FairRootManager* cached_manager =
nullptr
;
59
static
thread_local
map<string, TClonesArray*> cluster_arrays;
60
61
FairRootManager* ioman = FairRootManager::Instance();
62
if
(ioman != cached_manager) {
63
cluster_arrays.clear();
64
cached_manager = ioman;
65
}
66
67
auto
it = cluster_arrays.find(cluster_branch_name);
68
if
(it == cluster_arrays.end()) {
69
TClonesArray
* clusters =
dynamic_cast<
TClonesArray
*
>
(ioman->GetObject(cluster_branch_name));
70
// a branch of the input file activated only now does not contain the current event yet, so it is read here
71
TChain
* input_chain = ioman->GetInChain();
72
if
(clusters && input_chain && input_chain->
GetTree
()) {
73
TBranch
* branch = input_chain->
GetTree
()->
GetBranch
(cluster_branch_name);
74
if
(branch)
75
branch->
GetEntry
(input_chain->
GetTree
()->
GetReadEntry
());
76
}
77
it = cluster_arrays.emplace(cluster_branch_name, clusters).first;
78
}
79
80
TClonesArray
* clusters = it->second;
81
if
(!clusters || cluster_index < 0 || cluster_index >= clusters->
GetEntriesFast
())
82
return
nullptr
;
83
return
static_cast<
StripCluster
*
>
(clusters->
UncheckedAt
(cluster_index));
84
}
Int_t
int Int_t
kFALSE
constexpr Bool_t kFALSE
kTRUE
constexpr Bool_t kTRUE
TBranch.h
TChain.h
TClonesArray.h
kREF
@ kREF
Definition
BmnDetectorList.h:13
BmnHit.h
UpperStripLayer
@ UpperStripLayer
Definition
BmnStripData.h:13
LowerStripLayer
@ LowerStripLayer
Definition
BmnStripData.h:12
BmnHit::fIndex
Int_t fIndex
Index in hits array.
Definition
BmnHit.h:79
BmnHit::fModule
Int_t fModule
Definition
BmnHit.h:84
BmnHit::fStation
Short_t fStation
station number.
Definition
BmnHit.h:83
BmnHit::fResY
Double_t fResY
Definition
BmnHit.h:89
BmnHit::fUpperClusterIndex
Int_t fUpperClusterIndex
Definition
BmnHit.h:96
BmnHit::fType
Int_t fType
Definition
BmnHit.h:85
BmnHit::fCovXY
Double_t fCovXY
Definition
BmnHit.h:91
BmnHit::fResX
Double_t fResX
Definition
BmnHit.h:88
BmnHit::fLowerClusterIndex
Int_t fLowerClusterIndex
Definition
BmnHit.h:97
BmnHit::GetCluster
StripCluster * GetCluster(const char *cluster_branch_name, StripLayerType layer)
Strip cluster of the hit in the given strip layer, taken from the cluster branch of this layer (e....
Definition
BmnHit.cxx:49
BmnHit::fLength
Double_t fLength
Definition
BmnHit.h:86
BmnHit::BmnHit
BmnHit()
Default constructor.
Definition
BmnHit.cxx:12
BmnHit::fDetId
DetectorId fDetId
Id of detector which creates hit.
Definition
BmnHit.h:81
BmnHit::fPseudo
Bool_t fPseudo
Definition
BmnHit.h:99
BmnHit::fFlag
Bool_t fFlag
Is hit good or not.
Definition
BmnHit.h:77
BmnHit::~BmnHit
virtual ~BmnHit()
Destructor.
Definition
BmnHit.cxx:46
BmnHit::fUsing
Bool_t fUsing
Is hit used or not.
Definition
BmnHit.h:75
FairHit
StripCluster
Definition
BmnStripData.h:177
TBranch
TBranch::GetEntry
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
TChain
TChain::GetTree
TTree * GetTree() const override
TClonesArray
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::UncheckedAt
TObject * UncheckedAt(Int_t i) const
TTree::GetBranch
virtual TBranch * GetBranch(const char *name)
TTree::GetReadEntry
virtual Long64_t GetReadEntry() const
TVector3
base
data
BmnHit.cxx
Generated on
for BmnRoot by
1.17.0