BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnBdHitProducer.cxx
Go to the documentation of this file.
1
// -------------------------------------------------------------------------
2
// ----- BmnBdHitProducer source file -----
3
// ----- Created 12/07/18 by A. Zinchenko -----
4
// -------------------------------------------------------------------------
5
6
#include "
BmnBdHitProducer.h
"
7
8
#include "
BmnBdHit.h
"
9
#include "
BmnBdPoint.h
"
10
#include "FairRootManager.h"
11
#include "
TClonesArray.h
"
12
13
#include <iostream>
14
15
using
std::cout;
16
using
std::endl;
17
18
// ----- Default constructor -------------------------------------------
19
BmnBdHitProducer::BmnBdHitProducer
()
20
:
FairTask
(
"Bmn Bd Hit Producer"
)
21
,
fPointArray
(NULL)
22
,
fHitArray
()
23
{}
24
// -------------------------------------------------------------------------
25
26
// ----- Destructor ----------------------------------------------------
27
BmnBdHitProducer::~BmnBdHitProducer
() {}
28
// -------------------------------------------------------------------------
29
30
// ----- Public method Init --------------------------------------------
31
InitStatus
BmnBdHitProducer::Init
()
32
{
33
34
// Get RootManager
35
FairRootManager* ioman = FairRootManager::Instance();
36
if
(!ioman) {
37
cout <<
"-E- BmnBdHitProducer::Init: "
38
<<
"RootManager not instantiated!"
<< endl;
39
return
kFATAL;
40
}
41
42
// Get input array
43
fPointArray
= (
TClonesArray
*)ioman->GetObject(
"BdPoint"
);
44
if
(!
fPointArray
) {
45
cout <<
"-W- BmnBdHitProducer::Init: "
46
<<
"No BdPoint array!"
<< endl;
47
return
kERROR;
48
}
49
50
// Create and register output array
51
fHitArray
=
new
TClonesArray
(
"BmnBdHit"
);
52
ioman->Register(
"BdHit"
,
"BD"
,
fHitArray
,
kTRUE
);
53
54
cout <<
"-I- BmnBdHitProducer: Intialization successfull"
<< endl;
55
return
kSUCCESS;
56
}
57
// -------------------------------------------------------------------------
58
59
// ----- Public method Exec --------------------------------------------
60
void
BmnBdHitProducer::Exec
(
Option_t
* opt)
61
{
62
63
// Reset output array
64
if
(!
fHitArray
)
65
Fatal
(
"Exec"
,
"No BdHit array"
);
66
67
fHitArray
->Delete();
68
fHitMap
.clear();
69
70
// Declare some variables
71
BmnBdPoint
* point = NULL;
72
Int_t
detID = 0;
// Detector ID
73
// Int_t trackID = 0; // Track index
74
Double_t
x, y, z;
// Position
75
Double_t
dx = 0.0001;
// Position error
76
TVector3
pos, dpos;
// Position and error vectors
77
78
// Loop over BdPoints
79
Int_t
nPoints =
fPointArray
->GetEntriesFast();
80
81
for
(
Int_t
iPoint = 0; iPoint < nPoints; iPoint++) {
82
point = (
BmnBdPoint
*)
fPointArray
->UncheckedAt(iPoint);
83
if
(!point)
84
continue
;
85
86
// Detector ID
87
detID = point->
GetCopy
();
88
89
// MCTrack ID
90
// trackID = point->GetTrackID();
91
92
// Hit position
93
x = point->GetX();
94
y = point->GetY();
95
z = point->GetZ();
96
97
// Create new hit
98
pos.
SetXYZ
(x, y, z);
99
dpos.
SetXYZ
(dx, dx, 0.);
100
// new ((*fHitArray)[iPoint]) BmnBdHit(detID, pos, dpos, iPoint);
101
if
(
fHitMap
.find(detID) ==
fHitMap
.end())
102
fHitMap
[detID] =
BmnBdHit
(detID, pos, dpos, iPoint);
103
// Add point to the hit links
104
fHitMap
[detID].AddLink(FairLink(0, iPoint));
105
106
}
// Loop over MCPoints
107
108
// Store hits
109
Int_t
ihit = 0;
110
for
(map<Int_t, BmnBdHit>::iterator mit =
fHitMap
.begin(); mit !=
fHitMap
.end(); ++mit)
111
new
((*fHitArray)[ihit++])
BmnBdHit
(mit->second);
112
113
// Event summary
114
cout <<
"-I- BmnBdHitProducer: "
<< nPoints <<
" BdPoints, "
<<
fHitMap
.size() <<
" Hits created."
<< endl;
115
}
116
// -------------------------------------------------------------------------
Int_t
int Int_t
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
Option_t
const char Option_t
TClonesArray.h
Fatal
void Fatal(const char *location, const char *msgfmt,...)
BmnBdHitProducer::fHitMap
std::map< Int_t, BmnBdHit > fHitMap
Definition
BmnBdHitProducer.h:46
BmnBdHitProducer::BmnBdHitProducer
BmnBdHitProducer()
Default constructor.
Definition
BmnBdHitProducer.cxx:19
BmnBdHitProducer::Init
virtual InitStatus Init()
Virtual method Init.
Definition
BmnBdHitProducer.cxx:31
BmnBdHitProducer::Exec
virtual void Exec(Option_t *opt)
Virtual method Exec.
Definition
BmnBdHitProducer.cxx:60
BmnBdHitProducer::fPointArray
TClonesArray * fPointArray
Input array of BmnBdPoints.
Definition
BmnBdHitProducer.h:41
BmnBdHitProducer::~BmnBdHitProducer
~BmnBdHitProducer()
Destructor.
Definition
BmnBdHitProducer.cxx:27
BmnBdHitProducer::fHitArray
TClonesArray * fHitArray
Output array of BmnBdHits.
Definition
BmnBdHitProducer.h:44
BmnBdHit
BmnBdHit.h.
Definition
BmnBdHit.h:22
BmnBdPoint
Definition
BmnBdPoint.h:17
BmnBdPoint::GetCopy
Short_t GetCopy() const
Accessors.
Definition
BmnBdPoint.h:61
FairTask
TClonesArray
TVector3
TVector3::SetXYZ
void SetXYZ(Double_t x, Double_t y, Double_t z)
BmnBdHitProducer.h
BmnBdHit.h
BmnBdPoint.h
detectors
bd
BmnBdHitProducer.cxx
Generated on
for BmnRoot by
1.17.0