6 #include "FairLogger.h"
7 #include "TClonesArray.h"
8 #include "TGeoManager.h"
34 static Double_t
GetRMS(
const char* name) {
35 Double_t result = -1.;
37 sprintf(fileName,
"%s.root", name);
38 TFile* curFile = TFile::CurrentFile();
39 TFile*
f =
new TFile(fileName);
42 TH1F*
h =
static_cast<TH1F*
>(
f->Get(name));
44 if (0 !=
h) result =
h->GetRMS();
48 TFile::CurrentFile() = curFile;
53 FairRootManager* ioman = FairRootManager::Instance();
55 if (0 == ioman) LOG(fatal) <<
"No FairRootManager";
57 fMCTracks =
static_cast<TClonesArray*
>(ioman->GetObject(
"MCTrack"));
58 fMuchPoints =
static_cast<TClonesArray*
>(ioman->GetObject(
"MuchPoint"));
59 fTrdPoints =
static_cast<TClonesArray*
>(ioman->GetObject(
"TrdPoint"));
62 LOG(fatal) <<
"No MC tracks or points";
66 for (
int i = 0;
i < 4; ++
i) {
67 for (
int j = 0; j < 3; ++j) {
68 sprintf(name,
"noise_e_x_%d_%d",
i, j);
72 sprintf(name,
"Couldn't read noise_e_x_%d_%d",
i, j);
76 sprintf(name,
"noise_e_y_%d_%d",
i, j);
80 sprintf(name,
"Couldn't read noise_e_y_%d_%d",
i, j);
87 gRandom->SetSeed(time(&initTime));
104 Int_t nofMCTracks =
fMCTracks->GetEntriesFast();
107 for (Int_t
i = 0;
i < nofMCTracks; ++
i) {
113 Int_t nofMuchPoints =
fMuchPoints->GetEntriesFast();
116 for (Int_t
i = 0;
i < nofMuchPoints; ++
i) {
122 Int_t nofTrdPoints =
fTrdPoints->GetEntriesFast();
125 for (Int_t
i = 0;
i < nofTrdPoints; ++
i) {
131 Int_t ind = nofMuchPoints;
133 for (Int_t
i = 0;
i < nofMuchPoints; ++
i) {
136 Int_t stationNumber =
146 TVector3 posDelta = posOut - posIn;
148 for (
int k = 0; k < 20; ++k) {
150 gRandom->Gaus(0,
x_rmss[stationNumber][layerNumber]),
151 gRandom->Gaus(0,
y_rmss[stationNumber][layerNumber]),
153 TVector3 newIn = posIn + noiseDelta;
154 TGeoNode* node = gGeoManager->FindNode(newIn.X(), newIn.Y(), newIn.Z());
156 if (0 == node)
continue;
158 TString nodeName(node->GetName());
160 if (!nodeName.Contains(
"active", TString::kIgnoreCase))
continue;
162 TVector3 newOut = newIn + 0.5 * posDelta;
163 node = gGeoManager->FindNode(newOut.X(), newOut.Y(), newOut.Z());
165 if (0 == node)
continue;
167 TString nodeName2(node->GetName());
169 if (!nodeName2.Contains(
"active", TString::kIgnoreCase))
continue;
172 noiseMuchPt.SetPosition(newIn);
174 noiseMuchPt.SetTrackID(-1);