FairRoot/PandaRoot
GeCluster.cxx
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 #include "TClonesArray.h"
5 #include "TGeoMCGeometry.h"
6 #include "TGeoManager.h"
7 #include "TLorentzVector.h"
8 #include "TVector3.h"
9 #include "TRotation.h"
10 
11 #include "TParticle.h"
12 #include "TVirtualMC.h"
13 #include "TGeoArb8.h"
14 #include "TGeoMedium.h"
15 
16 #include "FairGeoInterface.h"
17 #include "FairGeoLoader.h"
18 #include "FairGeoNode.h"
19 #include "PndGeoHypGe.h"
20 #include "FairGeoRootBuilder.h"
21 #include "TGeoMatrix.h"
22 #include "PndStack.h"
23 #include "PndHypGe.h"
24 #include "PndHypGeReader.h"
25 #include "PndHypGePoint.h"
26 #include "FairGeoMedium.h"
27 #include "FairRootManager.h"
28 #include "FairModule.h"
29 #include "FairVolume.h"
30 #include "GeCluster.h"
31 // add on for debug
32 //#include "FairGeoG3Builder.h"
33 #include "FairRuntimeDb.h"
34 #include "TObjArray.h"
35 #include "FairRun.h"
36 
37 
38 
40 
41 
43 
44  SenVolList = new TList();
45 
46 }
48  delete SenVolList;
49 }
50 //
51 
52 TList *GeCluster::CreateCluster(TGeoPgon* logicCrystal_test,
53  TGeoPgon* lay_sci,
54  TGeoCompositeShape* lay_cap,
55  TGeoVolume& sphere,
56  Double_t distance,
57  Double_t theta,
58  Double_t phi,
59  Double_t depth_first_interaction,
60  int id_start)
61 
62 //#### real geometry(Euroball)
63 // TList *GeCluster::CreateCluster(TGeoCompositeShape* logicCrystal_test,
64 // TGeoVolume& sphere,
65 // Double_t distance,
66 // Double_t theta,
67 // Double_t phi,
68 // Double_t depth_first_interaction,
69 // int id_start)
70 
71 // void GeCluster::CreateCluster(TGeoCompositeShape* logicCrystal_test,
72 // TGeoVolume& sphere,
73 // Double_t distance,
74 // Double_t theta,
75 // Double_t phi,
76 // Double_t depth_first_interaction,
77 // int id_start)
78 
79 {
80 
81  SenVolList->Clear();
82 
83  //G4SDManager* SDman = G4SDManager::GetSDMpointer();
84 
85  char cluster_name[10];
86  if(id_start==800) sprintf(cluster_name,"J");
87  if(id_start==700) sprintf(cluster_name,"G");
88  if(id_start==100) sprintf(cluster_name,"A");
89  if(id_start==200) sprintf(cluster_name,"B");
90  if(id_start==900) sprintf(cluster_name,"K");
91 
92  if(id_start==1100) sprintf(cluster_name,"M");
93  if(id_start==300) sprintf(cluster_name,"C");
94  if(id_start==500) sprintf(cluster_name,"E");
95  if(id_start==1500) sprintf(cluster_name,"R");
96  if(id_start==1300) sprintf(cluster_name,"P");
97 
98  if(id_start== 400) sprintf(cluster_name,"D");
99  if(id_start== 600) sprintf(cluster_name,"F");
100  if(id_start==1000) sprintf(cluster_name,"L");
101  if(id_start==1200) sprintf(cluster_name,"N");
102 
103  if(id_start==1400) sprintf(cluster_name,"Q");
104 
105  Double_t deg = TMath::Pi()/180.;
106  Double_t phi1;
107 
108  fnum_crystal = 0; // each cluster consists of several crystals
109  fnum_cluster = 0; // cluster number
110 
111  distance = distance + 2.5;
112 
113  phi1=phi*deg;
114 
115  if(phi1 >360.0*deg) phi1 = phi1 - 360.0*deg;
116  if(phi1>=0.0 && phi1 <=180.0*deg) phi1 = 180.0*deg - phi1;
117  if(phi1>180.0*deg && phi1 <360.0*deg) phi1 = 540.0*deg - phi1;
118  phi1 = phi1+90.0*deg;
119 
120  if(phi >360.0) phi = phi - 360.0;
121  if(phi>=0.0 && phi <=180.0) phi = 180.0 - phi;
122  if(phi>180.0 && phi <360.0) phi = 540.0 - phi;
123  phi = phi+90.0;
124 
125 
126  TString pclus,psci;
127  pclus = fpath;
128  psci = fpath;
129  pclus += "/hypGe/GeGlusterPos3Clus.dat";
130  psci += "/hypGe/GeClusterPosSci31.dat";
131 
132  PndHypGeReader *read;
133  read = new PndHypGeReader(pclus.Data());
134  PndHypGeReader *readsci;
135  readsci = new PndHypGeReader(psci.Data());
136 
137  TGeoRotation rot3D;
138  TRotation rho;
139  TRotation rho2;
140  TVector3 rotatedPos,PosOrb;
141 
142  //TGeoCombiTrans *c1;
143 
144  TGeoRotation rot3D2;
145  TVector3 rotatedPos2;
146  //TGeoCombiTrans *c2;
147  rot3D2.SetAngles(0, 0, 0);
148  rot3D2.RotateX(theta);
149  rot3D2.RotateZ(phi);
150 
151  rho2(0,0);
152  rho2.RotateX(theta*deg);
153  rho2.RotateZ(phi1);
154 
155  rot3D.SetAngles(0, 0, 0);
156  rot3D.RotateX(theta);
157  rot3D.RotateZ(phi);
158 
159  rho(0,0);
160  rho.RotateX(theta*deg);
161  rho.RotateZ(phi1);
162 
163 
164 
165 
166 
167 
168 
169  TGeoMedium *Ge = gGeoManager->GetMedium("germanium");
170  //scintillator plate
171  TGeoMedium *sci = gGeoManager->GetMedium("polypropylene");
172  //capsule
173  TGeoMedium *cap = gGeoManager->GetMedium("HYPaluminium");
174 
175  //Int_t geid = Ge->GetId();
176  //cout<<" media "<<geid<<endl;
177 
178  //TGeoMedium *Si= gGeoManager->GetMedium("air");
179  //TGeoMedium *Ge= gGeoManager->Medium("germanium",700,1,1,30.,10.0, 0.1, 0.1, 0.1, 0.1);
180  // Germanium
181  // a = 72.61*g/mole;
182  //density = 5.323*g/cm3;
183  //G4Material* Ge = new G4Material(name="Germanium" , z=32., a, density);
184  // Definition of materials
185 
186 
187  //cout<<"media "<<medPWO<<endl;
188 
189  char name_crystal[13];
190  sprintf (name_crystal,"GeCrystal%02d",id_start+6);
191 
192 
193  char name_lay[13];
194  char name_cap[13];
195  //scint.
196  sprintf (name_lay,"laySci%02d",id_start+6);
197  //capsula
198  sprintf (name_cap,"Cap%02d",id_start+6);
199 
200 
201  crystal_centre[fnum_crystal] = new TGeoVolume(name_crystal,
202  (const TGeoShape *)logicCrystal_test,
203  (const TGeoMedium *)Ge );
204 
205  laySci[fnum_crystal] = new TGeoVolume(name_lay,
206  (const TGeoShape *)lay_sci,
207  (const TGeoMedium *)sci );
208 
209  Cap[fnum_crystal] = new TGeoVolume(name_cap,(const TGeoShape *)lay_cap,
210  (const TGeoMedium *)cap );
211 
212  DataG4 data;
213  data = read->GetData(id_start+6);
214 
215  // sphere.AddNode(crystal_centre[fnum_crystal],id_start+6,
216  // new TGeoCombiTrans(rotatedPos.X(),
217  // rotatedPos.Y(),
218  // rotatedPos.Z(),
219  // new TGeoRotation (rot3D)));
220 
221  sphere.AddNode(crystal_centre[fnum_crystal],id_start+6,
222  new TGeoCombiTrans(data.posX/10.,
223  data.posY/10.,
224  data.posZ/10.,
225  new TGeoRotation (rot3D)));
226 
227  sphere.AddNode(Cap[fnum_crystal],id_start+6,
228  new TGeoCombiTrans(data.posX/10.,
229  data.posY/10.,
230  (data.posZ/10.),
231  new TGeoRotation (rot3D)));
232 
233  //scint
234  DataG4 data2;
235  data2 = readsci->GetData(id_start+6);
237 
238 
239  sphere.AddNode(laySci[fnum_crystal],id_start+6,
240  new TGeoCombiTrans(data2.posX/10.,
241  data2.posY/10.,
242  (data2.posZ/10.),
243  new TGeoRotation (rot3D)));
244 
245 
246 
247  //------------------------------------------------
248  // Sensitive detectors
249  //------------------------------------------------
250 
251  //AddSensitiveVolume(crystal_centre[fnum_crystal]);
252  SenVolList->AddLast(crystal_centre[fnum_crystal]);
253  SenVolList->AddLast(laySci[fnum_crystal]);
254  SenVolList->AddLast(Cap[fnum_crystal]);
255 
256 
257 
258 
259  // cout << id_start+6 << " " << rotatedPos.X() << " "
260 // << rotatedPos.Y() << " "
261 // << rotatedPos.Z() << std::endl;
262 
263 
264 
265 
266 
267 
268  //------------------------------------------------
269  // Crystals surrounding the central one.
270  //------------------------------------------------
271 
272  fnum_crystal = fnum_crystal + 1;
273 
274  //Float_t v1[6],v2[6],v3[6];
275 
276  TRotation a;
277  TVector3 b;
278  a.RotateZ(90.*deg);
279  b=TVector3(0,1.,0).Transform(a);
280 
281  char tempname[100];
282  char periname[13];
283  char cappname[13];
284  for(int iii=0;iii<=1;iii++)
285  {
286 
287 
288  rot3D.SetAngles(0., 0., 0.);
289  rot3D.RotateX(-6.66);
290  rot3D.RotateZ((-1*iii+1)*60.0);
291  rot3D.RotateX(theta);
292  rot3D.RotateZ(phi);
293 
294  //rho(0,0,0);
295  rho.RotateX(0.*deg);
296  rho.RotateY(0.*deg);
297  rho.RotateZ(0.*deg);
298 
299  rho.RotateX(-6.66*deg);
300  rho.RotateZ((-1*iii+1)*60.0*deg);
301  rho.RotateX(theta*deg);
302  rho.RotateZ(phi1);
303 
304  rotatedPos.SetXYZ(0.,0.,0.);
305  rotatedPos2.SetXYZ(0.,0.,0.);
306 
307 
308 
309 
310 
311  sprintf(tempname,"GeCrystal%04d",id_start+iii);
312  //TGeoVolume *crystal[fnum_crystal];
313 
314  //scint
315  sprintf (periname,"laySci%04d",id_start+iii);
316  //capsula
317  sprintf (cappname,"Cap%04d",id_start+iii);
318 
319  crystal[fnum_crystal] = new TGeoVolume(tempname,
320  (const TGeoShape *)logicCrystal_test,
321  (const TGeoMedium *)Ge);
322 
323  laySci_peri[fnum_crystal] = new TGeoVolume(periname,
324  (const TGeoShape *)lay_sci,
325  (const TGeoMedium *)sci);
326 
327  Cap_peri[fnum_crystal] = new TGeoVolume(cappname,
328  (const TGeoShape *)lay_cap,
329  (const TGeoMedium *)cap);
330 
331 
332  DataG4 data3;
333  data3 = read->GetData(id_start+iii);
334 
335  // sphere.AddNode(crystal[fnum_crystal],id_start+iii,
336  // new TGeoCombiTrans(PosOrb.X(),PosOrb.Y(),
337  // PosOrb.Z(), new TGeoRotation (rot3D)));
338 
339  sphere.AddNode(crystal[fnum_crystal],id_start+iii,
340  new TGeoCombiTrans(data3.posX/10.,data3.posY/10.,
341  data3.posZ/10., new TGeoRotation (rot3D)));
342 
343  //capsula
344  sphere.AddNode(Cap_peri[fnum_crystal],id_start+iii,
345  new TGeoCombiTrans(data3.posX/10.,
346  data3.posY/10.,
347  (data3.posZ/10.),
348  new TGeoRotation (rot3D)));
349 
350  DataG4 data4;
351  data4 = readsci->GetData(id_start+iii);
352 
353 
354 
355  sphere.AddNode(laySci_peri[fnum_crystal],id_start+iii,
356  new TGeoCombiTrans(data4.posX/10.,
357  data4.posY/10.,
358  (data4.posZ/10.),
359  new TGeoRotation (rot3D)));
360 
361 
362  //------------------------------------------------
363  // Sensitive detectors
364  //------------------------------------------------
365 
366  //AddSensitiveVolume(crystal[fnum_crystal]);
367 
368  SenVolList->AddLast(crystal[fnum_crystal]);
369  SenVolList->AddLast(laySci_peri[fnum_crystal]);
370  SenVolList->AddLast(Cap_peri[fnum_crystal]);
371 
372 
373 
374  cout << id_start+iii << " " << data.posX << " "
375  << data.posY << " "
376  << data.posZ << " "<<std::endl;
377 
378  fnum_crystal = fnum_crystal + 1;
379 
380  }
381 
383 
384  return SenVolList;
385 
386 }
int fnum_crystal
Definition: GeCluster.h:69
TGeoVolume * laySci_peri[105]
Definition: GeCluster.h:87
virtual ~GeCluster()
Definition: GeCluster.cxx:47
TTree * b
TList * SenVolList
Definition: GeCluster.h:90
TGeoVolume * laySci[105]
Definition: GeCluster.h:86
TGeoManager * gGeoManager
int fnum_cluster
Definition: GeCluster.h:70
TGeoVolume * crystal[105]
Definition: GeCluster.h:85
TGeoVolume * crystal_centre[105]
Definition: GeCluster.h:84
TString fpath
Definition: GeCluster.h:71
Int_t a
Definition: anaLmdDigi.C:126
ClassImp(GeCluster) GeCluster
Definition: GeCluster.cxx:39
Double_t
TList * CreateCluster(TGeoPgon *logicCrystal_test, TGeoPgon *lay_sci, TGeoCompositeShape *lay_cap, TGeoVolume &sphere, double distance, double theta, double phi, double depth_first_interaction, int id_start)
Definition: GeCluster.cxx:52
double posX
Definition: PndEmcReader.h:21
double posZ
Definition: PndEmcReader.h:21
double posY
Definition: PndEmcReader.h:21
DataG4 GetData(int crystal)
Double_t Pi
TGeoVolume * Cap[105]
Definition: GeCluster.h:88
TGeoVolume * Cap_peri[105]
Definition: GeCluster.h:89