FairRoot/PandaRoot
PndGeoHypGeCluster.cxx
Go to the documentation of this file.
1 // ******** Implementation of class to build HypGe Triple Cluster Geometry *************
2 // by steinen@kph.uni-mainz.de
3 #include "PndGeoHypGeCluster.h"
4 //#include "PndGeoHypGeCrystal.h"
5 #include <iostream>
6 #include <stdio.h>
7 #include <stdlib.h>
8 
9 using namespace std;
10 
12 
13 
14 
15 
16 
17 
18 // -------- gives the copy number of the last placed cluster. If no cluster placed yet, returns the starting cluster number ----
19 Int_t PndGeoHypGeCluster::GetClusterNumber()
20 {
21  if (ClusterNumber == StartClusterNumber)
22  {
23  return ClusterNumber;
24  cout << "No Cluster placed yet!" << endl;
25  }
26  else
27  {
28  return ClusterNumber -1;
29  }
30 };
31 
32 // -------- gives the starting cluster number (number giving @ construction) ------
34 {
35  return StartClusterNumber;
36 }
37 
38 // -------- gives the number of placed clusters -----
40 {
41  return ClusterNumber-StartClusterNumber;
42 }
43 
44 void PndGeoHypGeCluster::GetExternalParameters(Int_t NumberOfValues,Double_t *DataArray)
45 {
46  if (!ParametersInputFile)
47  {
48  cout << "Inputfile does not exist!" << endl;
49  }
50  else if (ParametersInputFile.good())
51  {
52  string InputBuffer;
53  char* pEnd;
54  getline(ParametersInputFile,InputBuffer);
55  //cout << InputBuffer << endl;
56 
57  DataArray[0] = strtod(InputBuffer.data(),&pEnd);
58  for (Int_t iValues = 1; iValues < NumberOfValues; iValues++)
59  {
60  DataArray[iValues] = strtod(pEnd,&pEnd);
61  //cout << "Value_" << iValues <<": " <<DataArray[iValues] << endl;
62  }
63  }
64 }
66 {
67  if (!ParametersInputFile)
68  {
69  cout << "Inputfile does not exist!" << endl;
70  }
71  else if (ParametersInputFile.good())
72  {
73  string InputBuffer;
74  getline(ParametersInputFile,InputBuffer);
75  }
76 }
78 {
79  //some make-up ;D
80  CryostatTransparency = ExtTransparency;
81 
82  Cryostat->SetTransparency(CryostatTransparency);
83 
84 }
85 
86 void PndGeoHypGeCluster::SetCryostatColor( Color_t ExtColor)
87 {
88  //some make-up ;D
89 
90  Cryostat->SetLineColor(ExtColor);
91 
92 }
93 
94  //place the cluster with external TGeoMatrix
95 void PndGeoHypGeCluster::PlaceCluster(TGeoVolume *top, TGeoMatrix* ClusterPlaceAndDirectionTranslation,Int_t *CrystalNumber)
96 {
97  ClusterAssembly = new TGeoVolumeAssembly("ClusterAssembly");
98  BuildCrystals(CrystalNumber);
99  BuildCryostat();
100  SetCryostatColor(kGreen);
101  SetCryostatTransparency(0);
102  top->AddNode(ClusterAssembly,ClusterNumber,ClusterPlaceAndDirectionTranslation);
103  ClusterNumber++;
104 };
105 
106  //place the cluster by giving just the coordinates and euler-angles
107 void PndGeoHypGeCluster::PlaceCluster(TGeoVolume *top, Double_t x, Double_t y, Double_t z, Double_t GlobalZOffset , Double_t psi, Double_t theta, Double_t phi,Int_t *CrystalNumber)
108 {
109  ClusterAssembly = new TGeoVolumeAssembly("ClusterAssembly");
110  BuildCrystals(CrystalNumber);
111  BuildCryostat();
112  SetCryostatColor(kGreen);
113  SetCryostatTransparency(0);
114 
115  ClusterPositionX = x;
116  ClusterPositionY = y;
117  ClusterPositionZ = z + GlobalZOffset;
118  ClusterEulerAnglePsi = psi;
119  ClusterEulerAngleTheta = theta;
120  ClusterEulerAnglePhi = phi;
121  TGeoRotation *TempClusterRotation = new TGeoRotation("TempClusterRotation",ClusterEulerAnglePsi,ClusterEulerAngleTheta,ClusterEulerAnglePhi);
122  TempClusterRotation->RegisterYourself();
123  top->AddNode(ClusterAssembly,ClusterNumber,new TGeoCombiTrans(ClusterPositionX,ClusterPositionY,ClusterPositionZ,TempClusterRotation));
124  ClusterNumber++;
125 };
126 
127 void PndGeoHypGeCluster::PlaceCluster(TGeoVolume *top, Double_t GlobalZOffset, Double_t Radius , Double_t psi, Double_t theta, Double_t phi,Int_t *CrystalNumber)
128 {
129  ClusterAssembly = new TGeoVolumeAssembly("ClusterAssembly");
130  BuildCrystals(CrystalNumber);
131  BuildCryostat();
132  SetCryostatColor(kGreen);
133  SetCryostatTransparency(0);
134 
135  ClusterPositionX = -Radius*TMath::Sin(TMath::Pi()/180*psi)*TMath::Sin(TMath::Pi()/180*theta);
136  ClusterPositionY = Radius*TMath::Cos(TMath::Pi()/180*psi)*TMath::Sin(TMath::Pi()/180*theta);
137  ClusterPositionZ = -Radius*TMath::Cos(TMath::Pi()/180*theta) + GlobalZOffset;
138  //cout << ClusterPositionZ << endl << endl;
139  ClusterEulerAnglePsi = psi;
140  ClusterEulerAngleTheta = theta;
141  ClusterEulerAnglePhi = phi;
142  TGeoRotation *TempClusterRotation = new TGeoRotation("TempClusterRotation",ClusterEulerAnglePsi,ClusterEulerAngleTheta,ClusterEulerAnglePhi);
143  TempClusterRotation->RegisterYourself();
144  top->AddNode(ClusterAssembly,ClusterNumber,new TGeoCombiTrans(ClusterPositionX,ClusterPositionY,ClusterPositionZ,TempClusterRotation));
145  ClusterNumber++;
146 
147 };
148 
149 
150 
void GetExternalParameters(Int_t NumberOfValues, Double_t *DataArray)
static T Sin(const T &x)
Definition: PndCAMath.h:42
void SetCryostatColor(Color_t ExtColor)
static T Cos(const T &x)
Definition: PndCAMath.h:43
TGeoVolume * top
Double_t
Double_t z
ClassImp(PndGeoHypGeCluster) Int_t PndGeoHypGeCluster
Double_t x
void PlaceCluster(TGeoVolume *top, TGeoMatrix *ClusterPlaceAndDirectionTranslation, Int_t *CrystalNumber)
void SetCryostatTransparency(Int_t ExtTransparency)
Double_t y
Double_t Pi