R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
create_neuland_geo.C
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2023 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2023 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
15#include "TGeoManager.h"
16#include "TMath.h"
17#include <iomanip>
18#include <iostream>
19
20void create_neuland_geo(const Int_t nPlanes = 26, const TString geoTag = "v3")
21{
22 new FairGeoLoader("TGeo", "FairGeoLoader");
23 gGeoManager->SetName("NEULANDgeom");
24
25 TGeoVolume* volPaddle = BuildPaddleVolume();
26 TGeoRotation* rot0 = nullptr;
27 TGeoRotation* rot90 = new TGeoRotation();
28 rot90->RotateZ(90.);
29 TGeoRotation* rot45 = new TGeoRotation();
30 rot45->RotateY(45.);
31
32 TGeoVolume* volNeuland = new TGeoVolumeAssembly("volNeuland");
33 Int_t nindex = 0, nPlane = 0;
35 b += gPaddleDistance * 2)
36 {
37 nPlane++;
39 a += gPaddleDistance * 2)
40 {
41 nindex++;
42 if (nPlane % 2 == 1)
43 {
44 volNeuland->AddNode(volPaddle, nindex, new TGeoTranslation(0, a, b));
45 }
46 else
47 {
48 volNeuland->AddNode(volPaddle, nindex, new TGeoCombiTrans(a, 0, b, rot90));
49 }
50 }
51 }
52
53 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
54 gGeoManager->SetTopVolume(top);
55 top->AddNode(volNeuland, 1, new TGeoCombiTrans(0., 0., 0., rot0));
56
57 // --------------- Finish -----------------------------------------------
58 gGeoManager->CloseGeometry();
59 gGeoManager->CheckOverlaps(0.001);
60 gGeoManager->PrintOverlaps();
61 gGeoManager->Test();
62
63 // ------- Geometry file name (output) ----------------------------------
64 TString geoFileName = TString::Format("%s/geometry/neuland_%s_%ddp.geo.root",
65 TString(gSystem->Getenv("VMCWORKDIR")).Data(),
66 geoTag.Data(),
67 nPlanes / 2);
68 TFile* geoFile = new TFile(geoFileName, "RECREATE");
69 top->Write();
70 geoFile->Close();
71
72 std::cout << std::endl;
73 std::cout << "Done. " << nindex << " Paddles in " << nPlane << " Planes" << std::endl;
74 std::cout << std::endl;
75 std::cout << "\033[34m Creating geometry:\033[0m "
76 << "\033[33m" << geoFileName << " \033[0m" << std::endl;
77 std::cout << "Macro finished successfully." << std::endl;
78}
void create_neuland_geo(const Int_t nPlanes=26, const TString geoTag="v3")
const Int_t gPaddlesPerPlane
const Double_t gPaddleDistance
TGeoVolume * BuildPaddleVolume()
A paddle consists of the scintillator volume, wrapped with Al and Tape.
constexpr Int_t nPlanes