KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVTelescope.cpp
1#include "KVTelescope.h"
2#include "KVDetector.h"
3#include "KVNucleus.h"
4#include "KVUnits.h"
5#include "TGraph.h"
6#include "Riostream.h"
7#include "TString.h"
8#include "TROOT.h"
9#include "TMath.h"
10#include "TGeoManager.h"
11#include "TGeoMatrix.h"
12
13using namespace std;
14
17// KVTelescope
18//
19
20
21
22
24{
25 init();
26};
27
28
29
30
34
36{
37 //default initialisation. a KVList is created to hold telescope detectors.
38 //the telescope owns its detectors and will delete them when deleted itself.
39 fNdets = 0;
40 fDepth = 0;
41 SetType("TELESCOPE");
43}
44
45
46
47
49
51{
52 if (fDepth)
53 delete[]fDepth;
54 fDepth = 0;
55 fNdets = 0;
56}
57
58
59
64
66{
67 // Add a detector or a daughter structure to this telescope.
68 // For detectors we set up the KVDetectorNode (in front of - behind
69 // relationships) information.
70
71 if (element->InheritsFrom(KVDetector::Class())) {
72 Int_t ndets = GetSize();
73 if (ndets) {
74 KVDetector* d = dynamic_cast<KVDetector*>(element);
75 KVDetector* ld = GetDetector(ndets);
76 ld->GetNode()->AddBehind(d);
77 d->GetNode()->AddInFront(ld);
78 }
79 }
81}
82
83
84
111
113{
114 //Simulates the passage of a charged particle through all detectors of the telescope, in the order in which they
115 //were added to it (corresponding to rank given by GetDetectorRank()).
116 //Begin_Html
117 //<img src="http://indra.in2p3.fr/KaliVedaDoc/images/kvtelescope_detectparticle.gif">
118 //End_Html
119 //It should be noted that
120 // (1) the small variations in effective detector thickness due to the particle's angle of incidence are not, for the moment, taken into account
121 // (2) the simplified description of detector geometry used here does not take into account trajectories such as that marked "b" shown in the figure.
122 // All particles impinging on the first detector of the telescope are assumed to pass through all subsequent detectors as in "c"
123 // (unless they stop in one of the detectors)
124 //
125 //The KVNameValueList, if it's defined, allows to store
126 //the energy loss in the different detectors the particle goes through
127 //exemple : for a Silicon-CsI telescope named SI_CSI_0401 , you will obtain:
128 // {
129 // KVNucleus nn(6,12); nn.SetKE(1000);
130 // KVTelescope* tel = gMultiDetArray->GetTelescope("SI_CSI_0401");
131 // KVNameValueList* nvl = new KVNameValueList;
132 // tel->DetectParticle(&nn,nvl);
133 // nvl->Print();
134 // }
135 // Collection name='KVNameValueList', class='KVNameValueList', size=2
136 // OBJ: TNamed SI_0401 8.934231
137 // OBJ: TNamed CSI_0401 991.065769
138 //The energy loss in each detector corresponds to those lost in active layer
139
140 KVDetector* obj;
141
142 TIter next(GetDetectors());
143 while ((obj = (KVDetector*) next())) {
144 Double_t ebefore = obj->GetEnergy(); //Energie dans le detecteur avant passage
145 obj->DetectParticle(kvp); //Detection de la particule
146 ebefore -= obj->GetEnergy(); //la difference d energie avant et apres passage (donc l energie laissee par la particule)
147 if (nvl)
148 nvl->SetValue(obj->GetName(), TMath::Abs(ebefore)); //Enregistrement de la perte d energie
149 if (kvp->GetEnergy() <= 0.0)
150 break;
151 }
152}
153
154
155
158
160{
161 //returns position (1=front, 2=next, etc.) detector in the telescope structure
162 if ((KVTelescope*)kvd->GetParentStructure("TELESCOPE") != this) {
163 Warning("GetDetectorRank", "Detector does not belong to this telescope!");
164 cout << endl;
165 return 0;
166 }
167 TIter next(GetDetectors());
168 KVDetector* d;
169 UInt_t i = 1;
170 while ((d = (KVDetector*) next())) {
171 if (d == kvd)
172 return i;
173 i++;
174 }
175 return 0;
176}
177
178
179
180
183
185{
186 // Reset Energy losses to be ready for the next event
187 const_cast<KVSeqCollection*>(GetDetectors())->Execute("Clear", "");
188}
189
190
191
192
195
197{
198 //set the depth of detector number ndet(=1,2,...) in mm.
199
200 fNdets = GetSize();
201 if (!fNdets) {
202 Error("SetDepth",
203 "Add detectors to telescope before setting depth.");
204 return;
205 }
206 if ((int) ndet > fNdets) {
207 Error("SetDepth",
208 "Cannot set depth for detector %d in %d-member telescope.",
209 ndet, fNdets);
210 return;
211 }
212 if (!fDepth)
213 fDepth = new Float_t[fNdets];
214 fDepth[ndet - 1] = depth;
216}
217
218
219
220
223
225{
226 //get depth of detector ndet(=1,2,...) in mm
227 if (!fDepth) {
228 Error("GetDepth", "Depths have not been set.");
229 return -1.0;
230 }
231 if ((int) ndet > fNdets) {
232 Error("SetDepth",
233 "Cannot get depth for detector %d in %d-member telescope.",
234 ndet, fNdets);
235 return -1.0;
236 }
237 return fDepth[ndet - 1];
238}
239
240
241
242
245
247{
248 //get depth of entire telescope in mm (sum of depths of detectors)
249 if (!fDepth) {
250 Error("GetDepth", "Depths have not been set.");
251 return -1.0;
252 }
253 Float_t sum = 0.0;
254 for (int ndet = 0; ndet < fNdets; ndet++) {
255 sum += fDepth[ndet];
256 }
257 return sum;
258}
259
260
261
262
265
267{
268 // Create and return TGeoVolume representing detectors in this telescope.
269
270 int no_of_dets = GetDetectors()->GetEntries();
271 if (no_of_dets == 1) {
272 // single detector "telescope": just return detector volume
273 return GetDetector(1)->GetGeoVolume();
274 }
275 TGeoVolume* mother_vol = gGeoManager->MakeVolumeAssembly(Form("%s_TEL", GetName()));
276 // total length of telescope = depth of last detector + thickness of last detector
277 Double_t tot_len_tel = GetTotalLengthInCM();
278 //**** BUILD & ADD DETECTOR VOLUMES ****
279 TIter next(GetDetectors());
280 KVDetector* det;
281 while ((det = (KVDetector*)next())) {
282 TGeoVolume* det_vol = det->GetGeoVolume();
283 // position detector in telescope
284 Double_t dist = -tot_len_tel / 2. + det->GetDepthInTelescope() + det->GetTotalThicknessInCM() / 2.;
285 TGeoTranslation* tran = new TGeoTranslation(0., 0., dist);
286 mother_vol->AddNode(det_vol, 1, tran);
287 }
288 return mother_vol;
289}
290
291
292
295
297{
298 // Construct and position a TGeoVolume shape to represent this telescope in the current geometry
299 if (!gGeoManager) return;
300
301 // get volume for telescope
302 TGeoVolume* vol = GetGeoVolume();
303
304 // rotate telescope to orientation corresponding to (theta,phi)
305 Double_t theta = GetTheta();
306 Double_t phi = GetPhi();
307 TGeoRotation rot1, rot2;
308 rot2.SetAngles(phi + 90., theta, 0.);
309 rot1.SetAngles(-90., 0., 0.);
310 Double_t tot_len_tel = GetTotalLengthInCM();
311 // distance to telescope centre = distance to telescope + half total lenght of telescope
312 Double_t dist = GetDistance() + tot_len_tel / 2.;
313 // translate telescope to correct distance from target (note: reference is CENTRE of telescope)
314 Double_t trans_z = dist;
315
316 TGeoTranslation tran(0, 0, trans_z);
317 TGeoHMatrix h = rot2 * tran * rot1;
318 TGeoHMatrix* ph = new TGeoHMatrix(h);
319
320 // add telescope volume to geometry
321 gGeoManager->GetTopVolume()->AddNode(vol, 1, ph);
322}
323
324
325
329
331{
332 // calculate total length of telescope from entrance of first detector to
333 // backside of last detector
334 int no_of_dets = GetDetectors()->GetEntries();
335 Double_t tot_len_tel = GetDepthInCM(no_of_dets) + GetDetector(no_of_dets)->GetTotalThicknessInCM();
336 return tot_len_tel;
337}
338
339
340
int Int_t
unsigned int UInt_t
#define d(i)
float Float_t
double Double_t
R__EXTERN TGeoManager * gGeoManager
char * Form(const char *fmt,...)
Base class for KaliVeda framework.
Definition KVBase.h:142
virtual void SetType(const Char_t *str)
Definition KVBase.h:173
Base class for detector geometry description.
Definition KVDetector.h:160
KVGeoStrucElement * GetParentStructure(const Char_t *type, const Char_t *name="") const
virtual TGeoVolume * GetGeoVolume()
virtual Double_t GetEnergy() const
Definition KVDetector.h:349
KVGeoDetectorNode * GetNode()
Definition KVDetector.h:326
Double_t GetTotalThicknessInCM()
Definition KVDetector.h:315
virtual Double_t GetDepthInTelescope() const
Definition KVDetector.h:310
virtual void DetectParticle(KVNucleus *, TVector3 *norm=0)
void AddBehind(KVDetector *)
void SetOwnsDetectors(Bool_t yes=kTRUE)
virtual void Add(KVBase *)
const KVSeqCollection * GetDetectors() const
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
void SetValue(const Char_t *name, value_type value)
Description of properties and kinematics of atomic nuclei.
Definition KVNucleus.h:126
Double_t GetEnergy() const
Definition KVParticle.h:621
virtual Double_t GetTheta() const
Definition KVPosition.h:160
void SetDistance(Double_t d)
Definition KVPosition.h:186
virtual Double_t GetPhi() const
Definition KVPosition.h:172
virtual Double_t GetDistance(void) const
Definition KVPosition.h:190
KaliVeda extensions to ROOT collection classes.
Associates two detectors placed one behind the other.
Definition KVTelescope.h:36
Int_t fNdets
number of detectors in telescope
Definition KVTelescope.h:39
virtual TGeoVolume * GetGeoVolume()
Create and return TGeoVolume representing detectors in this telescope.
Double_t GetTotalLengthInCM() const
void SetDepth(UInt_t ndet, Float_t depth)
set the depth of detector number ndet(=1,2,...) in mm.
KVDetector * GetDetector(Int_t n) const
Definition KVTelescope.h:50
Int_t GetDetectorRank(KVDetector *kvd)
returns position (1=front, 2=next, etc.) detector in the telescope structure
Float_t * fDepth
[fNdets] depth of each element starting from nearest target
Definition KVTelescope.h:40
void ResetDetectors()
Reset Energy losses to be ready for the next event.
void Add(KVBase *element)
Double_t GetDepthInCM(Int_t ndet) const
Definition KVTelescope.h:74
Float_t GetDepth() const
get depth of entire telescope in mm (sum of depths of detectors)
virtual void AddToGeometry()
Construct and position a TGeoVolume shape to represent this telescope in the current geometry.
virtual ~KVTelescope()
virtual void DetectParticle(KVNucleus *kvp, KVNameValueList *nvl=0)
Int_t GetSize() const
Definition KVTelescope.h:62
virtual Int_t GetEntries() const
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
TGeoVolume * GetTopVolume() const
void SetAngles(Double_t phi, Double_t theta, Double_t psi)
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
const char * GetName() const override
static TClass * Class()
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Execute(const char *method, const char *params, Int_t *error=nullptr)
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Error(const char *method, const char *msgfmt,...) const
TH1 * h
const long double mm
Definition KVUnits.h:69
double dist(AxisAngle const &r1, AxisAngle const &r2)
void init()
Double_t Abs(Double_t d)
ClassImp(TPyArg)