BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnGemHitProducer.cxx
Go to the documentation of this file.
1#include "BmnGemHitProducer.h"
2
3#include "BmnHit.h"
4#include "CbmStsPoint.h"
5#include "FairRootManager.h"
6#include "TRandom.h"
7#include "TSystem.h"
8
9using std::cout;
10
12{
13 fInputBranchName = "StsPoint";
14 fOutputHitsBranchName = "BmnHit";
15 fOutputGemHitMatchesBranchName = "BmnGemStripHitMatch";
16}
17
19
21{
22
23 cout << " BmnGemHitProducer::Init() " << endl;
24
25 // Get ROOT Manager
26 FairRootManager* ioman = FairRootManager::Instance();
27
28 fBmnPointsArray = (TClonesArray*)ioman->GetObject(fInputBranchName);
29 fMCTracksArray = (TClonesArray*)ioman->GetObject("MCTrack");
30
32 ioman->Register("BmnGemStripHit", "GEM", fBmnHitsArray, kTRUE);
33
36
37 TString gPathGemConfig = gSystem->Getenv("VMCWORKDIR");
38 gPathGemConfig += "/parameters/gem/XMLConfigs/";
39 GemStationSet = new BmnGemStripStationSet(gPathGemConfig + "GemRunSpring2018.xml");
40
41 return kSUCCESS;
42}
43
45{
46
47 fBmnHitsArray->Delete();
49
50 if (!fBmnPointsArray) {
51 Error("BmnGemHitProducer::Init()", " !!! Unknown branch name !!! ");
52 return;
53 }
54
55 Float_t err[3] = {0.03, 0.03, 0.03}; // Uncertainties of coordinates
56 // Float_t err[3] = {0.0, 0.0, 0.0}; // Uncertainties of coordinates
57
58 for (Int_t iPoint = 0; iPoint < fBmnPointsArray->GetEntriesFast(); iPoint++) {
59
60 TRandom* rand_gen = new TRandom();
61
62 CbmStsPoint* gemPoint = (CbmStsPoint*)fBmnPointsArray->UncheckedAt(iPoint);
63
64 const Float_t dX = rand_gen->Gaus(0, err[0]);
65 const Float_t dY = rand_gen->Gaus(0, err[1]);
66 const Float_t dZ = rand_gen->Gaus(0, err[2]);
67
68 const Float_t x_smeared = gemPoint->GetXIn() + dX;
69 const Float_t y_smeared = gemPoint->GetYIn() + dY;
70 const Float_t z_smeared = gemPoint->GetZIn() + dZ;
71
72 BmnHit* hit = new ((*fBmnHitsArray)[fBmnHitsArray->GetEntriesFast()])
73 BmnHit(0, TVector3(x_smeared, y_smeared, z_smeared), TVector3(err[0], err[1], err[2]), iPoint);
74 // BmnHit* hit = new ((*fBmnHitsArray)[fBmnHitsArray->GetEntriesFast()]) BmnHit(kGEM, TVector3(x_smeared,
75 // y_smeared, z_smeared), TVector3(1.0, 1.0, 0.0), iPoint);
76 hit->SetIndex(fBmnHitsArray->GetEntriesFast() - 1);
77 hit->SetType(1);
78 hit->SetStation(GemStationSet->GetPointStationOwnership(gemPoint->GetZIn()));
79 // hit->SetStation(DefineStationByZ(gemPoint->GetZIn()));
80
82 new ((*fBmnGemStripHitMatchesArray)[fBmnGemStripHitMatchesArray->GetEntriesFast()]) BmnMatch();
83 match->AddLink(100.0, iPoint);
84
85 delete rand_gen;
86 }
87}
88
90{
91 const Int_t nStation = 7;
92 Int_t minIdx = -1;
93 Double_t minDz = 10000;
94
95 Double_t zPos[nStation] = {100.0, 120.0, 140.0, 160.0, 180.0, 200.0, 220.0};
96
97 for (Int_t i = 0; i < nStation; ++i) {
98 Double_t dz = Abs(z - zPos[i]);
99 if (dz < minDz) {
100 minDz = dz;
101 minIdx = i;
102 }
103 }
104 return minIdx;
105}
106
int i
Definition P4_F32vec4.h:22
int Int_t
float Float_t
double Double_t
constexpr Bool_t kTRUE
const char Option_t
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TSystem * gSystem
TClonesArray * fBmnPointsArray
Input array of Gem Points.
virtual InitStatus Init()
Virtual method Init.
TClonesArray * fMCTracksArray
Input array of MC Tracks.
virtual void Finish()
Virtual method Finish.
Int_t DefineStationByZ(Double_t z)
virtual void Exec(Option_t *opt)
Virtual method Exec.
virtual ~BmnGemHitProducer()
Destructor.
BmnGemHitProducer()
Default constructor.
TClonesArray * fBmnHitsArray
Output array of Gem Hits.
TString fOutputGemHitMatchesBranchName
TClonesArray * fBmnGemStripHitMatchesArray
Output array of GEM Hit Matches.
BmnGemStripStationSet * GemStationSet
void SetType(Int_t type)
Definition BmnHit.h:54
void SetIndex(Int_t id)
Definition BmnHit.h:49
void SetStation(Short_t st)
Definition BmnHit.h:52
Double_t GetXIn() const
Accessors.
Definition CbmStsPoint.h:64
Double_t GetZIn() const
Definition CbmStsPoint.h:66
Double_t GetYIn() const
Definition CbmStsPoint.h:65
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Double_t Abs(Double_t d)