-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathFairDetector.cxx
More file actions
118 lines (99 loc) · 3.74 KB
/
FairDetector.cxx
File metadata and controls
118 lines (99 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/********************************************************************************
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
// -------------------------------------------------------------------------
// ----- FairDetector source file -----
// ----- Created 06/01/04 by M. Al-Turany/ D. Bertini -----
// -------------------------------------------------------------------------
#include "FairDetector.h"
#include "FairGeoNode.h" // for FairGeoNode
#include "FairRootManager.h"
#include "FairRunSim.h"
#include "FairVolume.h" // for FairVolume
#include <TFolder.h> // for TFolder
#include <TGeoManager.h> // for gGeoManager
#include <TList.h> // for TList
#include <TObject.h> // for TObject
#include <TROOT.h> // for TROOT, gROOT
#include <TRefArray.h> // for TRefArray
#include <TString.h> // for TString
#include <TVirtualMC.h> // for TVirtualMC
#include <fairlogger/Logger.h>
FairDetector::FairDetector(const char* Name, Bool_t Active, Int_t DetId)
: FairModule(Name, "FAIR Detector", Active)
, fDetId(DetId)
{
flGeoPar = new TList();
TString lname(GetName());
lname += "GeoPar";
flGeoPar->SetName(lname.Data());
fGeoSaved = kFALSE;
}
FairDetector::FairDetector(const FairDetector& rhs)
: FairModule(rhs)
, fDetId(rhs.fDetId)
{}
FairDetector::~FairDetector() { delete flGeoPar; }
FairDetector& FairDetector::operator=(const FairDetector& rhs)
{
// check assignment to self
if (this == &rhs)
return *this;
// base class assignment
FairModule::operator=(rhs);
// assignment operator
fDetId = rhs.fDetId;
return *this;
}
FairDetector::FairDetector()
: fDetId(0)
{}
// -------------------------------------------------------------------------
void FairDetector::DefineSensitiveVolumes()
{
LOG(info) << "FairDetector::DefineSensitiveVolumes";
TObjArray* volumes = gGeoManager->GetListOfVolumes();
TIter next(volumes);
TGeoVolume* volume;
while ((volume = static_cast<TGeoVolume*>(next()))) {
if (IsSensitive(volume->GetName())) {
LOG(debug) << "Sensitive Volume " << volume->GetName();
AddSensitiveVolume(volume);
}
}
}
// -------------------------------------------------------------------------
void FairDetector::Initialize()
{
// Registers hits collection in Root manager;
// sets sensitive volumes.
// ---
// Define sensitive volumes if in MT
if (gMC->IsMT()) {
std::cout << "Define sensitive volume " << std::endl;
DefineSensitiveVolumes();
}
GetRunSim().UpdateSensitiveVolumesForModule(*this);
// Initialize cached pointer to MC (on master in sequential mode)
fMC = TVirtualMC::GetMC();
}
void FairDetector::SaveGeoParams()
{
if (!fGeoSaved) {
LOG(info) << "Detector: " << GetName() << " Geometry parameters saved ... ";
TFolder* mf = dynamic_cast<TFolder*>(gROOT->FindObjectAny(FairRootManager::GetFolderName()));
TFolder* stsf = nullptr;
if (mf) {
stsf = dynamic_cast<TFolder*>(mf->FindObjectAny(GetName()));
}
if (stsf) {
TFolder* newf = stsf->AddFolder("Parameters", "Detector parameters", nullptr);
newf->Add(flGeoPar);
}
fGeoSaved = kTRUE;
}
}