R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeutronWindowAndSomeAir.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2020 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2020-2026 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
16#include <FairGeoBuilder.h>
17#include <FairGeoInterface.h>
18#include <FairGeoLoader.h>
19#include <FairGeoMedia.h>
20#include <FairLogger.h>
21
22#include <TGeoManager.h>
23#include <TGeoMedium.h>
24
26 : FairModule("NeutronWindowAndSomeAir", "NeutronWindowAndSomeAir", false)
27 , fStart(xstart)
28 , fStop(xstop)
29{
30}
31
33{
34 if (gGeoManager == nullptr)
35 {
36 LOG(fatal) << __FUNCTION__ << ": No gGeoManager";
37 }
38
39 auto volSomeAir = gGeoManager->MakeBox("SomeAir", FindMaterial("Air"), 125, 125, (fStop - fStart) / 2.);
40 gGeoManager->GetTopVolume()->AddNode(volSomeAir, 1, new TGeoTranslation(0, 0, fStart + (fStop - fStart) / 2.));
41 auto volWindow = gGeoManager->MakeTube("NeutronWindow", FindMaterial("Steel"), 0, 70, 0.2);
42 gGeoManager->GetTopVolume()->AddNode(volWindow, 1, new TGeoTranslation(0, 0, fStart - 0.2));
43}
44
45// TODO: Simulation crashes without this. It should not be necessary to do this?!
46TGeoMedium* R3BNeutronWindowAndSomeAir::FindMaterial(const std::string& mat) const
47{
48 auto geoLoad = FairGeoLoader::Instance();
49 auto geoFace = geoLoad->getGeoInterface();
50 auto geoBuild = geoLoad->getGeoBuilder();
51 auto geoMedia = geoFace->getMedia();
52
53 auto fairMedium = geoMedia->getMedium(mat.c_str());
54 if (!fairMedium)
55 {
56 LOG(fatal) << __FUNCTION__ << ": FairGeoMedium " << mat << " not found";
57 }
58 geoBuild->createMedium(fairMedium);
59
60 auto med = gGeoManager->GetMedium(mat.c_str());
61 if (!med)
62 {
63 LOG(fatal) << __FUNCTION__ << ": TGeoMedium " << mat << " not found";
64 }
65 return med;
66}
67
ClassImp(R3B::Neuland::Cal2HitPar)
void ConstructRootGeometry(TGeoMatrix *_=nullptr) override
TGeoMedium * FindMaterial(const std::string &mat) const
R3BNeutronWindowAndSomeAir(double start=700, double stop=1300)