KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVRing.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 $Id: KVRing.cpp,v 1.22 2007/05/31 09:59:22 franklan Exp $
3  kvring.cpp - description
4  -------------------
5  begin : Thu May 16 2002
6  copyright : (C) 2002 by J.D. Frankland
7  email : frankland@ganil.fr
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 #include "KVRing.h"
19 #include "KVLayer.h"
20 #include "TGeoManager.h"
21 #include "TGeoMatrix.h"
22 #include "KVTelescope.h"
23 
24 using namespace std;
25 
27 
28 
29 
30 
33 {
34  init();
35 }
36 
37 
38 
40 
42 {
43  SetType("RING");
44 }
45 
46 
47 
49 
50 KVRing::~KVRing()
51 {
52 }
53 
54 
55 
58 
60 {
61  // Only KVTelescope-derived structures can be placed in a KVRing
62 
63  if (!b->InheritsFrom("KVTelescope")) return;
65 }
66 
67 
68 
69 
72 
74 {
75  // give pointer to telescope in ring which covers azimuthal angle phi
76  TIter next(GetTelescopes());
77  KVTelescope* obj;
78  while ((obj = (KVTelescope*) next())) { // loop over telescopes in ring
79  if (obj->IsInPhiRange(phi))
80  return obj;
81  }
82  return NULL;
83 }
84 
85 
86 
89 
91 {
92  // give pointer to telescope in ring with name
93  return (KVTelescope*)GetStructure("TELESCOPE", name);
94 }
95 
96 
97 
100 
101 Int_t KVRing::Compare(const TObject* obj) const
102 {
103  // rings are sorted according to lower edge polar angle
104  if (GetThetaMin() < ((KVRing*) obj)->GetThetaMin())
105  return -1;
106  else if (GetThetaMin() > ((KVRing*) obj)->GetThetaMin())
107  return 1;
108  else
109  return 0;
110 }
111 
112 
113 
117 
119 {
120  // redefinition of KVPosition::GetSolidAngle() to take into account
121  // only KVTelescope of the considered KVLayer which define the KVRing
122  Double_t sol_ang = 0;
123  KVTelescope* tel;
124  TIter nxttel(GetTelescopes());
125  while ((tel = (KVTelescope*) nxttel())) sol_ang += tel->GetSolidAngle();
126  return sol_ang;
127 
128 }
129 
130 
131 
132 
133 
134 
135 
138 
140 {
141  // Create and return TGeoVolume representing detectors in this ring.
142 
143  TString name(GetName());
144  name.ToUpper();
145  name.ReplaceAll(" ", "_");
146  TGeoVolume* mother_vol = gGeoManager->MakeVolumeAssembly(name.Data());
147  //**** BUILD & ADD TELESCOPEs ****
148  TIter next(GetTelescopes());
149  KVTelescope* det;
150  while ((det = (KVTelescope*)next())) {
151  TGeoVolume* det_vol = det->GetGeoVolume();
152  // position telescope in ring
153  // rotate telescope to orientation corresponding to (theta,phi)
154  Double_t theta = det->GetTheta();
155  Double_t phi = det->GetPhi();
156  TGeoRotation rot1, rot2;
157  rot2.SetAngles(phi + 90., theta, 0.);
158  rot1.SetAngles(-90., 0., 0.);
159  Double_t tot_len_tel = det->GetTotalLengthInCM();
160  // distance to telescope centre = distance to telescope + half total length of telescope
161  Double_t dist = det->GetDistance() + tot_len_tel / 2.;
162  // translate telescope to correct distance from target (note: reference is CENTRE of telescope)
163  Double_t trans_1 = dist;
164  // translate telescope so that centre of ring is on origin
165  Double_t trans_2 = dist * TMath::Cos(theta * TMath::DegToRad());
166  // set distance for ring = distance between origin and centre of ring
167  SetDistance(trans_2);// distance in cm
168 
169  TGeoTranslation tran1(0, 0, trans_1);
170  TGeoTranslation tran2(0, 0, -trans_2);
171  TGeoHMatrix h = tran2 * rot2 * tran1 * rot1;
172  TGeoHMatrix* ph = new TGeoHMatrix(h);
173 
174  mother_vol->AddNode(det_vol, 1, ph);
175  }
176  return mother_vol;
177 }
178 
179 
180 
183 
185 {
186  // Construct and position a TGeoVolume shape to represent this ring in the current geometry
187  if (!gGeoManager) return;
188 
189  // get volume for ring
190  TGeoVolume* vol = GetGeoVolume();
191 
192  // translate ring to correct distance
193  TGeoTranslation* tr = new TGeoTranslation(0, 0, GetDistance()); //distance set in GetGeoVolume()
194 
195  // add ring volume to geometry
196  gGeoManager->GetTopVolume()->AddNode(vol, 1, tr);
197 }
198 
199 
200 
201 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define b(i)
char Char_t
double Double_t
float Float_t
R__EXTERN TGeoManager * gGeoManager
Base class for KaliVeda framework.
Definition: KVBase.h:141
virtual void Add(KVBase *)
Bool_t IsInPhiRange(const Double_t phi)
Definition: KVPosition.cpp:336
virtual Double_t GetSolidAngle(void) const
Definition: KVPosition.cpp:567
virtual Double_t GetTheta() const
Definition: KVPosition.h:159
virtual Double_t GetPhi() const
Definition: KVPosition.h:171
virtual Double_t GetDistance(void) const
Definition: KVPosition.h:189
Ring in INDRA array (obsolete)
Definition: KVRing.h:19
virtual TGeoVolume * GetGeoVolume()
Create and return TGeoVolume representing detectors in this ring.
Definition: KVRing.cpp:139
KVTelescope * GetTelescope(Float_t phi) const
give pointer to telescope in ring which covers azimuthal angle phi
Definition: KVRing.cpp:73
void init()
Definition: KVRing.cpp:41
void Add(KVBase *)
Only KVTelescope-derived structures can be placed in a KVRing.
Definition: KVRing.cpp:59
virtual void AddToGeometry()
Construct and position a TGeoVolume shape to represent this ring in the current geometry.
Definition: KVRing.cpp:184
Double_t GetSolidAngle(void) const
Definition: KVRing.cpp:118
Int_t Compare(const TObject *obj) const
rings are sorted according to lower edge polar angle
Definition: KVRing.cpp:101
Associates two detectors placed one behind the other.
Definition: KVTelescope.h:35
virtual TGeoVolume * GetGeoVolume()
Create and return TGeoVolume representing detectors in this telescope.
Double_t GetTotalLengthInCM() const
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
TGeoVolume * GetTopVolume() const
void SetAngles(Double_t phi, Double_t theta, Double_t psi)
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
void ToUpper()
const char * Data() const
TString & ReplaceAll(const char *s1, const char *s2)
TH1 * h
double dist(AxisAngle const &r1, AxisAngle const &r2)
constexpr Double_t DegToRad()
Double_t Cos(Double_t)