15#include "FairRunAna.h"
16#include "FairRuntimeDb.h"
17#include "TDirectory.h"
22#include "TGeoManager.h"
23#include "TGeoMatrix.h"
24#include "TGeoMedium.h"
27#include "TGeoSphere.h"
28#include "TGeoVolume.h"
29#include "TProfile2D.h"
47 , fNofMuchStations(-1)
77 cout <<
"Getting MUCH layout for parallel version of tracking...\n";
80 TString parDir = TString(gSystem->Getenv(
"VMCWORKDIR")) + TString(
"/parameters");
81 TString matBudgetFile = parDir +
"/littrack/much_v12b.silicon.root";
82 TFile* oldFile = gFile;
83 TDirectory* oldDirectory = gDirectory;
84 TFile* file =
new TFile(matBudgetFile,
"READ");
90 TGeoNode* much =
nullptr;
91 TObjArray* nodes = gGeoManager->GetTopVolume()->GetNodes();
92 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
93 TGeoNode* node = (TGeoNode*) nodes->At(iNode);
94 if (TString(node->GetName()).Contains(
"much", TString::kIgnoreCase)) {
100 TObjArray* muchNodes = much->GetNodes();
101 Int_t currentStation = 0;
102 Int_t currentLayer = 0;
103 for (Int_t iMuchNode = 0; iMuchNode < muchNodes->GetEntriesFast(); iMuchNode++) {
104 const TGeoNode* muchNode =
static_cast<const TGeoNode*
>(muchNodes->At(iMuchNode));
106 if (TString(muchNode->GetName()).Contains(
"station")) {
107 TObjArray* layerNodes = muchNode->GetNodes();
109 for (Int_t iLayerNode = 0; iLayerNode < layerNodes->GetEntriesFast(); iLayerNode++) {
110 const TGeoNode* layer =
static_cast<const TGeoNode*
>(layerNodes->At(iLayerNode));
112 Double_t z = much->GetMatrix()->GetTranslation()[2] + muchNode->GetMatrix()->GetTranslation()[2]
113 + layer->GetMatrix()->GetTranslation()[2];
116 TProfile2D* profile =
117 (iLayerNode == 0) ? hm.
P2(
"hrl_ThicknessSilicon_MuchAbsorber_" +
Cbm::ToString<Int_t>(currentStation) +
"_P2")
139 gDirectory = oldDirectory;
144 cout <<
"Finish getting MUCH layout for parallel version of tracking\n";
160 cout <<
"Getting TRD layout for parallel version of tracking...\n";
163 TString parDir = TString(gSystem->Getenv(
"VMCWORKDIR")) + TString(
"/parameters");
164 TString matBudgetFile = parDir +
"/littrack/trd_v13p_3e.silicon.root";
165 TFile* oldFile = gFile;
166 TDirectory* oldDirectory = gDirectory;
167 TFile* file =
new TFile(matBudgetFile,
"READ");
173 Double_t startZPosition = 100.;
181 Int_t nofVirtualStations = 31;
182 for (Int_t iStation = 0; iStation < nofVirtualStations; iStation++) {
183 Double_t z = startZPosition + iStation * dZ;
190 if (iStation == 10) station.
SetMaterial(richMaterial);
197 for (Int_t iStation = 0; iStation < nofStations; iStation++) {
214 gDirectory = oldDirectory;
219 cout <<
"Finish getting TRD layout for parallel version of tracking\n";
226 TString parDir = TString(gSystem->Getenv(
"VMCWORKDIR")) + TString(
"/parameters");
227 TString matBudgetFile = parDir +
"/littrack/rich_v08a.silicon.root";
228 TFile* oldFile = gFile;
229 TDirectory* oldDirectory = gDirectory;
230 TFile* file =
new TFile(matBudgetFile,
"READ");
234 TProfile2D* profile = hm.
P2(
"hrl_ThicknessSilicon_Rich_P2");
239 gDirectory = oldDirectory;
246 Double_t maximumValue)
265 Int_t nofBinsX = profile->GetNbinsX();
266 Int_t nofBinsY = profile->GetNbinsY();
267 Int_t minShrinkBinX = std::numeric_limits<Double_t>::max();
268 Int_t maxShrinkBinX = std::numeric_limits<Double_t>::min();
269 Int_t minShrinkBinY = std::numeric_limits<Double_t>::max();
270 Int_t maxShrinkBinY = std::numeric_limits<Double_t>::min();
271 Bool_t isSet =
false;
272 for (Int_t iBinX = 1; iBinX <= nofBinsX; iBinX++) {
273 for (Int_t iBinY = 1; iBinY <= nofBinsY; iBinY++) {
274 Double_t content = profile->GetBinContent(iBinX, iBinY);
276 minShrinkBinX = std::min(iBinX, minShrinkBinX);
277 maxShrinkBinX = std::max(iBinX, maxShrinkBinX);
278 minShrinkBinY = std::min(iBinY, minShrinkBinY);
279 maxShrinkBinY = std::max(iBinY, maxShrinkBinY);
285 Int_t nofShrinkBinsX = maxShrinkBinX - minShrinkBinX + 1;
286 Int_t nofShrinkBinsY = maxShrinkBinY - minShrinkBinY + 1;
287 vector<vector<fscal>> material(nofShrinkBinsX);
288 for (Int_t i = 0; i < nofShrinkBinsX; i++)
289 material[i].resize(nofShrinkBinsY);
291 for (Int_t iX = minShrinkBinX; iX <= maxShrinkBinX; iX++) {
292 for (Int_t iY = minShrinkBinY; iY <= maxShrinkBinY; iY++) {
293 Double_t content = profile->GetBinContent(iX, iY);
294 if (maximumValue > 0 && content > maximumValue) content = maximumValue;
295 material[iX - minShrinkBinX][iY - minShrinkBinY] = content;
298 Double_t xmin = profile->GetXaxis()->GetBinLowEdge(minShrinkBinX);
299 Double_t xmax = profile->GetXaxis()->GetBinUpEdge(maxShrinkBinX);
300 Double_t ymin = profile->GetYaxis()->GetBinLowEdge(minShrinkBinY);
301 Double_t ymax = profile->GetYaxis()->GetBinUpEdge(maxShrinkBinY);
302 grid->
SetMaterial(material, xmin, xmax, ymin, ymax, nofShrinkBinsX, nofShrinkBinsY);
307 static Bool_t firstTime =
true;
309 Int_t layerCounter = 0;
310 TObjArray* topNodes =
fGeo->GetTopNode()->GetNodes();
311 for (Int_t iTopNode = 0; iTopNode < topNodes->GetEntriesFast(); iTopNode++) {
312 TGeoNode* topNode =
static_cast<TGeoNode*
>(topNodes->At(iTopNode));
313 if (TString(topNode->GetName()).Contains(
"trd")) {
314 TObjArray* layers = topNode->GetNodes();
315 for (Int_t iLayer = 0; iLayer < layers->GetEntriesFast(); iLayer++) {
316 TGeoNode* layer =
static_cast<TGeoNode*
>(layers->At(iLayer));
317 if (TString(layer->GetName()).Contains(
"layer")) {
331 static Bool_t firstTime =
true;
334 TGeoNode* much =
nullptr;
335 TObjArray* nodes = gGeoManager->GetTopVolume()->GetNodes();
336 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
337 TGeoNode* node = (TGeoNode*) nodes->At(iNode);
338 if (TString(node->GetName()).Contains(
"much", TString::kIgnoreCase)) {
347 TObjArray* muchNodes = much->GetNodes();
348 for (Int_t iMuchNode = 0; iMuchNode < muchNodes->GetEntriesFast(); iMuchNode++) {
349 const TGeoNode* muchNode =
static_cast<const TGeoNode*
>(muchNodes->At(iMuchNode));
350 if (TString(muchNode->GetName()).Contains(
"station")) {
352 if (TString(muchNode->GetName()).Contains(
"muchstation")) {
353 TObjArray* layerNodes = muchNode->GetNodes();
358 TObjArray* muchSubNodes = muchNode->GetNodes();
359 for (Int_t iMuchSubNode = 0; iMuchSubNode < muchSubNodes->GetEntriesFast(); iMuchSubNode++) {
360 const TGeoNode* muchSubNode =
static_cast<const TGeoNode*
>(muchSubNodes->At(iMuchSubNode));
361 TObjArray* layerNodes = muchSubNode->GetNodes();
374 static Bool_t firstTime =
true;
377 const TGeoNode* much =
static_cast<const TGeoNode*
>(
fGeo->GetTopNode()->GetNodes()->FindObject(
"much_0"));
382 TObjArray* muchNodes = much->GetNodes();
383 for (Int_t iMuchNode = 0; iMuchNode < muchNodes->GetEntriesFast(); iMuchNode++) {
384 const TGeoNode* muchNode =
static_cast<const TGeoNode*
>(muchNodes->At(iMuchNode));
385 if (TString(muchNode->GetName()).Contains(
"absorber")) {
387 if (TString(muchNode->GetName()).Contains(
"muchabsorber")) {
392 TObjArray* muchSubNodes = muchNode->GetNodes();
406 static Bool_t firstTime =
true;
409 TGeoNode* topNode = gGeoManager->GetTopVolume()->FindNode(
"pipevac1_0");
411 TObjArray* nodes = topNode->GetNodes();
412 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
413 TGeoNode* node = (TGeoNode*) nodes->At(iNode);
414 if (TString(node->GetName()).Contains(
"mvdstation")) {
420 TObjArray* nodes = gGeoManager->GetTopNode()->GetNodes();
421 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
422 TGeoNode* node = (TGeoNode*) nodes->At(iNode);
423 TString nodeName = node->GetName();
425 if (nodeName.Contains(
"pipe")) {
426 TObjArray* nodes2 = node->GetNodes();
427 for (Int_t iiNode = 0; iiNode < nodes2->GetEntriesFast(); iiNode++) {
428 TGeoNode* node2 = (TGeoNode*) nodes2->At(iiNode);
429 TString nodeName2 = node2->GetName();
431 if (nodeName2.Contains(
"pipevac1")) {
433 TObjArray* nodes3 = node2->GetNodes();
434 for (Int_t iiiNode = 0; iiiNode < nodes3->GetEntriesFast(); iiiNode++) {
435 TGeoNode* node3 = (TGeoNode*) nodes3->At(iiiNode);
436 TString nodeName3 = node3->GetName();
438 if (nodeName3.Contains(
"mvd")) {
443 TObjArray* nodes4 = node3->GetNodes();
444 for (Int_t iiiiNode = 0; iiiiNode < nodes4->GetEntriesFast(); iiiiNode++) {
445 TGeoNode* node4 = (TGeoNode*) nodes4->At(iiiiNode);
446 TString nodeName4 = node4->GetName();
448 if (nodeName4.Contains(
"mvd")) {
469 static Bool_t firstTime =
true;
472 TObjArray* nodes = gGeoManager->GetTopVolume()->GetNodes();
473 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
474 TGeoNode* node = (TGeoNode*) nodes->At(iNode);
475 if (TString(node->GetName()).Contains(
"STS_")) {
487 static Bool_t firstTime =
true;
488 static vector<Int_t> sumOfLayers;
491 const TGeoNode* much =
static_cast<const TGeoNode*
>(
fGeo->GetTopNode()->GetNodes()->FindObject(
"much_0"));
496 map<Int_t, Int_t> nofLayersPerStation;
497 TObjArray* muchNodes = much->GetNodes();
498 for (Int_t iMuchNode = 0; iMuchNode < muchNodes->GetEntriesFast(); iMuchNode++) {
499 const TGeoNode* muchNode =
static_cast<const TGeoNode*
>(muchNodes->At(iMuchNode));
500 if (TString(muchNode->GetName()).Contains(
"station")) {
502 if (TString(muchNode->GetName()).Contains(
"muchstation")) {
503 Int_t station = std::atoi(
string(muchNode->GetName() + 11, 2).c_str()) - 1;
504 TObjArray* layerNodes = muchNode->GetNodes();
505 nofLayersPerStation[station] = layerNodes->GetEntriesFast();
509 TObjArray* muchSubNodes = muchNode->GetNodes();
510 for (Int_t iMuchSubNode = 0; iMuchSubNode < muchSubNodes->GetEntriesFast(); iMuchSubNode++) {
511 const TGeoNode* muchSubNode =
static_cast<const TGeoNode*
>(muchSubNodes->At(iMuchSubNode));
512 Int_t station = std::atoi(
string(muchSubNode->GetName() + 11, 2).c_str()) - 1;
513 TObjArray* layerNodes = muchSubNode->GetNodes();
514 nofLayersPerStation[station] += layerNodes->GetEntriesFast();
519 map<Int_t, Int_t>::const_iterator it;
521 sumOfLayers.push_back(0);
522 for (it = nofLayersPerStation.begin(); it != nofLayersPerStation.end(); it++) {
524 sumOfLayers.push_back(sum);
528 return sumOfLayers[station] + layer;
@ kRich
Ring-Imaging Cherenkov Detector.
Class creates grid with magnetic field values at a certain Z position.
Tracking geometry constructor.
TProfile2D * P2(const std::string &name) const
Return pointer to TProfile2D.
void ReadFromFile(TFile *file)
Read histograms from file.
void DetermineSetup()
Determines detector presence using TGeoManager.
bool GetDet(ECbmModuleId detId) const
Return detector presence in setup.
void CreateGrid(fscal Z, lit::parallel::LitFieldGrid &grid)
Main function which creates grid with magnetic field values in (X, Y) slice.
virtual ~CbmLitTrackingGeometryConstructor()
Destructor.
Int_t GetNofStsStations()
Return number of stations in STS.
void GetMuchLayoutVec(lit::parallel::LitDetectorLayoutVec &layout)
Return MUCH detector layout for parallel MUCH tracking in SIMD format.
static CbmLitTrackingGeometryConstructor * Instance()
Return pointer to singleton object.
Int_t GetNofMuchTrdStations()
Return number of stations in MUCH + TRD.
Int_t ConvertMuchToAbsoluteStationNr(Int_t station, Int_t layer)
void GetMuchLayoutScal(lit::parallel::LitDetectorLayoutScal &layout)
Return MUCH detector layout for parallel MUCH tracking in scalar format.
void GetRichMaterial(lit::parallel::LitMaterialGrid *material)
void GetMuchLayout(lit::parallel::LitDetectorLayout< T > &layout)
Return MUCH detector layout for parallel MUCH tracking.
Int_t GetNofMvdStations()
Return number of stations in MVD.
void GetTrdLayoutVec(lit::parallel::LitDetectorLayoutVec &layout)
Return TRD detector layout for TRD parallel tracking in SIMD format.
void GetTrdLayoutScal(lit::parallel::LitDetectorLayoutScal &layout)
Return TRD detector layout for TRD parallel tracking in scalar format.
Int_t GetNofMuchStations()
Return number of stations in MUCH.
void GetTrdLayout(lit::parallel::LitDetectorLayout< T > &layout)
Return TRD detector layout for TRD parallel tracking.
Int_t GetNofMuchAbsorbers()
Return number of MUCH absorbers.
void ConvertTProfile2DToLitMaterialGrid(const TProfile2D *profile, lit::parallel::LitMaterialGrid *grid, Double_t maximumValue=0)
Int_t GetNofTrdStations()
Return number of stations in TRD.
CbmLitTrackingGeometryConstructor()
Constructor. Constructor is protected since singleton pattern is used. Pointer to object is returned ...
Represents detector layout.
void AddVirtualStation(const LitVirtualStation< T > &virtualStation)
Add virtual station to detector layout.
void AddStation(const LitStation< T > &station)
Add station to detector layout.
Class stores a grid of magnetic field values in XY slice at Z position.
Class stores a grid of material thickness in silicon equivalent.
void SetMaterial(const vector< vector< fscal > > &material, fscal xmin, fscal xmax, fscal ymin, fscal ymax, int nofBinsX, int nofBinsY)
Returns Z position of the grid.
void AddVirtualStation(const LitVirtualStation< T > &virtualStation)
Add virtual station to detector layout.
Virtual detector station which stores information needed for track propagation.
void SetMaterial(const LitMaterialGrid &material)
void SetField(const LitFieldGrid &field)
std::string ToString(const T &value)