18#include "FairGeoInterface.h"
19#include "FairGeoLoader.h"
20#include "FairGeoMedia.h"
21#include "FairGeoNode.h"
22#include "FairGeoVolume.h"
23#include "FairRootManager.h"
25#include "FairRuntimeDb.h"
26#include "FairVolume.h"
29#include "TClonesArray.h"
30#include "TGeoManager.h"
31#include "TGeoMaterial.h"
32#include "TGeoMatrix.h"
35#include "TVirtualMC.h"
48 , fTrdPoints(new TClonesArray(
"CbmTrdPoint"))
50 , fUseGlobalPhysicsProcesses(kFALSE)
51 , fCombiTrans(nullptr)
69 , fTrdPoints(new TClonesArray(
"CbmTrdPoint"))
71 , fUseGlobalPhysicsProcesses(kFALSE)
72 , fCombiTrans(nullptr)
94 FairDetector::Initialize();
98 Bool_t isSimulation = kTRUE;
107 FairRun* fRun = FairRun::Instance();
112 if (strcmp(fRun->GetName(),
"TGeant3") == 0) {
116 Int_t mat = gGeoManager->GetMaterialIndex(
"TRDgas");
117 TGeoMaterial* trdgas = gGeoManager->GetMaterial(mat);
119 Double_t mass = trdgas->GetA();
120 Double_t charge = trdgas->GetZ();
124 Int_t matIdVMC = mat + 1;
134 gMC->GetMaterial(matIdVMC, name, a, z, dens, radl, inter, par);
140 if ((TMath::Abs(mass - a) > 0.0001) || (TMath::Abs(charge - z)) > 0.0001) {
141 LOG(fatal) <<
"**********************************";
142 LOG(fatal) << TMath::Abs(mass - a) <<
" , " << TMath::Abs(charge - z);
143 LOG(fatal) <<
"Parameters from Geomanager:";
145 LOG(fatal) <<
"Parameters from Virtual Montecarlo:";
146 LOG(fatal) <<
"Name " << name <<
" Aeff=" << a <<
" Zeff=" << z;
147 Fatal(
"CbmTrd::SetSpecialPhysicsCuts",
"Material parameters different between TVirtualMC and TGeomanager");
152 LOG(info) <<
"Using special parameters for TRDgas";
153 gMC->Gstpar(matIdVMC,
"STRA", 1.0);
154 gMC->Gstpar(matIdVMC,
"PAIR", 1.0);
155 gMC->Gstpar(matIdVMC,
"COMP", 1.0);
156 gMC->Gstpar(matIdVMC,
"PHOT", 1.0);
157 gMC->Gstpar(matIdVMC,
"LOSS", 2.0);
159 gMC->Gstpar(matIdVMC,
"ANNI", 1.0);
160 gMC->Gstpar(matIdVMC,
"BREM", 1.0);
161 gMC->Gstpar(matIdVMC,
"HADR", 1.0);
163 gMC->Gstpar(matIdVMC,
"DCAY", 1.0);
164 gMC->Gstpar(matIdVMC,
"MULS", 1.0);
166 gMC->Gstpar(matIdVMC,
"DRAY", 1.0);
167 gMC->Gstpar(matIdVMC,
"RAYL", 1.0);
170 LOG(info) <<
"!! Using global parameters for TRDgas";
173 gMC->Gstpar(matIdVMC,
"CUTELE", 10.e-6);
174 gMC->Gstpar(matIdVMC,
"CUTGAM", 10.e-6);
175 gMC->Gstpar(matIdVMC,
"CUTNEU", 10.e-4);
176 gMC->Gstpar(matIdVMC,
"CUTHAD", 10.e-4);
177 gMC->Gstpar(matIdVMC,
"CUTMUO", 10.e-6);
178 gMC->Gstpar(matIdVMC,
"BCUTE", 10.e-6);
179 gMC->Gstpar(matIdVMC,
"BCUTM", 10.e-6);
180 gMC->Gstpar(matIdVMC,
"DCUTE", 10.e-6);
181 gMC->Gstpar(matIdVMC,
"DCUTM", 10.e-6);
182 gMC->Gstpar(matIdVMC,
"PPCUTM", -1.);
192 if (gMC->IsTrackEntering()) {
194 fTime = gMC->TrackTime() * 1.0e09;
196 gMC->TrackPosition(
fPosIn);
197 gMC->TrackMomentum(
fMomIn);
204 if (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) {
209 if (
fELoss == 0.)
return kFALSE;
211 Int_t trackId = gMC->GetStack()->GetCurrentTrackNumber();
215 new ((*fTrdPoints)[
size])
235 if (fVerboseLevel)
Print();
261 LOG(info) << fName <<
": " << nHits <<
" points registered in this event.";
263 if (fVerboseLevel > 1) {
264 for (Int_t i = 0; i < nHits; i++) {
265 (*fTrdPoints)[i]->Print();
284 Int_t nEntries = cl1->GetEntriesFast();
285 LOG(info) <<
"CbmTrd: " << nEntries <<
" entries to add.";
286 TClonesArray& clref = *cl2;
287 for (Int_t i = 0; i < nEntries; i++) {
289 Int_t index = oldpoint->GetTrackID() + offset;
290 oldpoint->SetTrackID(index);
294 LOG(info) <<
"CbmTrd: " << cl2->GetEntriesFast() <<
" merged entries.";
302 TString fileName = GetGeometryFileName();
305 LOG(fatal) <<
"Geometry format of TRD file " << fileName.Data() <<
" not supported.";
314 LOG(info) <<
"Importing TRD geometry from ROOT file " << fgeoName.Data();
318 LOG(info) <<
"Constructing TRD geometry from ROOT file " << fgeoName.Data();
319 FairModule::ConstructRootGeometry();
326 TString tsname = name;
327 if (tsname.EqualTo(
"gas")) {
328 LOG(debug) <<
"CbmTrd::CheckIfSensitive: Register active volume: " << tsname;
ClassImp(CbmConverterManager)
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
@ kTrd
Transition Radiation Detector.
Helper class to extract information from the GeoManager.
Defines the active detector TRD. Constructs the geometry and registers MCPoints.
static constexpr size_t size()
void AddPoint(ECbmModuleId iDet)
void Init(Bool_t isSimulation=kFALSE)
Int_t GetModuleAddress()
Return module address calculated based on the current node in the TGeoManager.
Defines the active detector TRD. Constructs the geometry and registers MCPoints.
Bool_t CheckIfSensitive(std::string name)
TGeoMatrix * fCombiTrans
weather to follow the global switch for physics cuts for the TRDgas
virtual void EndOfEvent()
If verbosity level is set, print hit collection at the end of the event and resets it afterwards.
virtual void Print(Option_t *="") const
Screen output of hit collection.
TLorentzVector fMomIn
position at entrance
CbmTrdGeoHandler * fGeoHandler
MC point collection.
virtual Bool_t IsSensitive(const std::string &name)
Bool_t fUseGlobalPhysicsProcesses
Interface to gMC and gGeoManager.
virtual void ConstructGeometry()
Constructs the TRD geometry.
virtual void Reset()
Clears the hit collection.
virtual ~CbmTrd()
Destructor.
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Copies the hit collection with a given track index offset.
CbmTrd()
Default constructor.
void ResetParameters()
Transformation matrix for geometry positioning.
virtual void ConstructRootGeometry(TGeoMatrix *shift=NULL)
TLorentzVector fMomOut
position at exit
virtual TClonesArray * GetCollection(Int_t iColl) const
Accessor to the hit collection.
virtual void SetSpecialPhysicsCuts()
virtual void Register()
Registers the hit collection in the ROOT manager.
TClonesArray * fTrdPoints
position index
Double32_t fTime
momentum at exit
virtual void Initialize()
Int_t fPosIndex
energy loss
TLorentzVector fPosOut
momentum at entrance
virtual Bool_t ProcessHits(FairVolume *vol=NULL)
Defines the action to be taken when a step is inside the active volume. Creates CbmTrdPoints and adds...
Bool_t IsNewGeometryFile(TString &filename)
void ImportRootGeometry(TString &filename, FairModule *mod, TGeoMatrix *mat)