]>
Commit | Line | Data |
---|---|---|
bc9ab547 | 1 | ///////////////////////////////////////////////////////// |
2 | // Manager and hits classes for set:PHOS version 3 // | |
3 | ///////////////////////////////////////////////////////// | |
4 | ||
5 | // --- ROOT system --- | |
6 | #include "TH1.h" | |
7 | #include "TRandom.h" | |
8 | #include "TFile.h" | |
9 | #include "TTree.h" | |
10 | #include "TBRIK.h" | |
11 | #include "TNode.h" | |
12 | ||
13 | // --- galice header files --- | |
14 | #include "AliPHOSv3.h" | |
15 | #include "AliRun.h" | |
cfce8870 | 16 | #include "AliMC.h" |
bc9ab547 | 17 | |
18 | ClassImp(AliPHOSv3) | |
19 | ||
20 | //______________________________________________________________________________ | |
21 | ||
22 | ||
8c933dd7 | 23 | AliPHOSv3::AliPHOSv3() |
bc9ab547 | 24 | { |
25 | } | |
26 | ||
27 | //______________________________________________________________________________ | |
28 | ||
29 | AliPHOSv3::AliPHOSv3(const char *name, const char *title) | |
30 | : AliPHOS(name, title) | |
31 | { | |
32 | } | |
33 | ||
34 | //___________________________________________ | |
35 | void AliPHOSv3::CreateGeometry() | |
36 | { | |
37 | ||
38 | cout << "AliPHOSv3::CreateGeometry() PHOS creation\n"; | |
39 | ||
bc9ab547 | 40 | AliPHOS *PHOS_tmp = (AliPHOS*)gAlice->GetModule("PHOS"); |
41 | if( NULL==PHOS_tmp ) | |
42 | { | |
43 | printf("There isn't PHOS detector!\n"); | |
44 | return; | |
45 | } | |
46 | // AliPHOS &PHOS = *PHOS_tmp; | |
47 | ||
48 | ////////////////////////////////////////////////////////////////////////////// | |
49 | ||
50 | Int_t rotation_matrix_number=0; | |
51 | Float_t par[11], | |
52 | x,y,z; | |
53 | ||
54 | const float cell_length = GetCrystalLength()+GetAirThickness()+GetWrapThickness()+GetPIN_Length(), | |
55 | cell_side_size = GetCrystalSideSize()+2*GetAirThickness()+2*GetWrapThickness(), | |
56 | // cell_angle = 180/kPI * 2 * atan(cell_side_size/2 / GetRadius()), // radians | |
57 | cradle_thikness = cell_length + GetCPV_Thickness() + GetCPV_PHOS_Distance(), | |
58 | distance_to_CPV = GetRadius() - GetCPV_Thickness() - GetCPV_PHOS_Distance(); | |
59 | ||
60 | ////////////////////////////////////////////////////////////////////////////// | |
61 | // CELL volume and subvolumes creation | |
62 | ////////////////////////////////////////////////////////////////////////////// | |
63 | ||
64 | par[0] = GetCrystalSideSize()/2 + GetWrapThickness(); | |
65 | par[1] = GetCrystalSideSize()/2 + GetWrapThickness(); | |
66 | par[2] = GetCrystalLength() /2 + GetWrapThickness()/2; | |
cfce8870 | 67 | gMC->Gsvolu("WRAP","BOX ",GetPHOS_IDTMED_Tyvek(),par,3); |
bc9ab547 | 68 | |
69 | par[0] = GetCrystalSideSize()/2; | |
70 | par[1] = GetCrystalSideSize()/2; | |
71 | par[2] = GetCrystalLength()/2; | |
cfce8870 | 72 | gMC->Gsvolu("CRST","BOX ",GetPHOS_IDTMED_PbWO4(),par,3); |
bc9ab547 | 73 | |
74 | // PIN | |
75 | par[0] = GetPIN_SideSize()/2; | |
76 | par[1] = GetPIN_SideSize()/2; | |
77 | par[2] = GetPIN_Length()/2; | |
cfce8870 | 78 | gMC->Gsvolu("PIN ","BOX ",GetPHOS_IDTMED_PIN(),par,3); |
bc9ab547 | 79 | |
80 | ////////////////////////////////////////////////////////////////////////////// | |
81 | // CRADLE,CPV creation. | |
82 | ////////////////////////////////////////////////////////////////////////////// | |
83 | ||
84 | par[0] = cell_side_size/2 * GetNz(); | |
85 | par[1] = cell_side_size/2 * GetNphi(); | |
86 | par[2] = cradle_thikness/2; | |
cfce8870 | 87 | gMC->Gsvolu("PHOS","BOX ",GetPHOS_IDTMED_AIR(),par,3); |
bc9ab547 | 88 | |
89 | //par[0] : the same as above | |
90 | //par[1] : the same as above | |
91 | par[2] = GetCPV_Thickness()/2; | |
cfce8870 | 92 | gMC->Gsvolu("CPV ","BOX ",GetPHOS_IDTMED_CPV(),par,3); |
bc9ab547 | 93 | |
94 | x = 0; | |
95 | y = 0; | |
96 | z = (cell_length+GetCPV_PHOS_Distance())/2; | |
cfce8870 | 97 | gMC->Gspos("CPV ",1,"PHOS",x,y,z,0,"ONLY"); |
bc9ab547 | 98 | |
99 | par[0] = cell_side_size/2 * GetNz(); | |
100 | par[1] = cell_side_size/2 * GetNphi(); | |
101 | par[2] = cell_length/2; | |
cfce8870 | 102 | gMC->Gsvolu("CRS0","BOX ",GetPHOS_IDTMED_AIR(),par,3); |
bc9ab547 | 103 | |
104 | x = 0; | |
105 | y = 0; | |
106 | z = -(cradle_thikness-cell_length)/2; | |
cfce8870 | 107 | gMC->Gspos("CRS0",1,"PHOS",x,y,z,0,"ONLY"); |
bc9ab547 | 108 | |
cfce8870 | 109 | gMC->Gsdvn("CRS1","CRS0",GetNphi(),2); |
110 | gMC->Gsdvn("CELL","CRS1",GetNz() ,1); | |
bc9ab547 | 111 | |
112 | ////////////////////////////////////////////////////////////////////////////// | |
113 | // CELL creation | |
114 | ////////////////////////////////////////////////////////////////////////////// | |
115 | ||
116 | x = 0; | |
117 | y = 0; | |
118 | z = -GetWrapThickness()/2; | |
cfce8870 | 119 | gMC->Gspos("CRST",1,"WRAP",x,y,z,0,"ONLY"); |
bc9ab547 | 120 | |
121 | x = 0; | |
122 | y = 0; | |
123 | z = GetPIN_Length()/2; | |
cfce8870 | 124 | gMC->Gspos("WRAP",1,"CELL",x,y,z,0,"ONLY"); |
bc9ab547 | 125 | |
126 | x = 0; | |
127 | y = 0; | |
128 | z = -GetCrystalLength()/2-GetWrapThickness()/2; | |
cfce8870 | 129 | gMC->Gspos("PIN ",1,"CELL",x,y,z,0,"ONLY"); |
bc9ab547 | 130 | |
131 | ////////////////////////////////////////////////////////////////////////////// | |
132 | // CELL has been created. | |
133 | ////////////////////////////////////////////////////////////////////////////// | |
134 | ||
135 | // int n=0; | |
136 | // z = -(GetCPV_Thickness()+GetCPV_PHOS_Distance())/2; | |
137 | // | |
138 | // for( int iy=0; iy<GetNphi(); iy++ ) | |
139 | // { | |
140 | // y = (iy-(GetNphi()-1)/2.)*cell_side_size; | |
141 | // for( int ix=0; ix<GetNz(); ix++ ) | |
142 | // { | |
143 | // x = (ix-(GetNz()-1)/2.)*cell_side_size; | |
cfce8870 | 144 | // gMC->Gspos("CELL",++n,"PHOS",x,y,z,0,"ONLY"); |
bc9ab547 | 145 | // } |
146 | // } | |
147 | ||
148 | ////////////////////////////////////////////////////////////////////////////// | |
149 | // End of CRADLE creation. | |
150 | ////////////////////////////////////////////////////////////////////////////// | |
151 | ||
152 | ||
153 | ////////////////////////////////////////////////////////////////////////////// | |
154 | // PHOS creation | |
155 | ////////////////////////////////////////////////////////////////////////////// | |
156 | ||
157 | for( int i=0; i<GetCradlesAmount(); i++ ) | |
158 | { | |
159 | float c = distance_to_CPV, // Distance to CPV | |
160 | l = cell_side_size*GetNphi()/2, // Cradle half size around beam (for rect. geom.) | |
161 | cradle_angle = 360/kPI*atan(l/c), | |
162 | cradle_angle_pos = -90+(i-(GetCradlesAmount()-1)/2.) * (cradle_angle+GetAngleBetweenCradles()); | |
163 | // Cradles are numerated in clock reversed order. (general way of angle increment) | |
164 | ||
165 | float r = GetRadius() + cradle_thikness/2; | |
166 | x = r*cos(cradle_angle_pos*kPI/180); | |
167 | y = r*sin(cradle_angle_pos*kPI/180); | |
168 | z = 0; | |
169 | AliMatrix(rotation_matrix_number, 0,0 , 90,90+cradle_angle_pos , 90,180+cradle_angle_pos); | |
cfce8870 | 170 | gMC->Gspos("PHOS",i+1,"ALIC",x,y,z,rotation_matrix_number,"ONLY"); |
bc9ab547 | 171 | |
172 | GetCradleAngle(i) = cradle_angle_pos; | |
173 | // | |
174 | // int n = PHOS.fCradles->GetEntries(); | |
175 | // PHOS.fCradles->Add(new AliPHOSCradle( 1, // geometry. | |
176 | // GetCrystalSideSize (), | |
177 | // GetCrystalLength (), | |
178 | // GetWrapThickness (), | |
179 | // GetAirThickness (), | |
180 | // GetPIN_SideSize (), | |
181 | // GetPIN_Length (), | |
182 | // GetRadius (), | |
183 | // GetCPV_Thickness (), | |
184 | // GetCPV_PHOS_Distance (), | |
185 | // GetNz (), | |
186 | // GetNphi (), | |
187 | // cradle_angle_pos )); | |
188 | // | |
189 | // if( n+1 != PHOS.fCradles->GetEntries() || | |
190 | // NULL == PHOS.fCradles->At(n) ) | |
191 | // { | |
192 | // cout << " Can not create or add AliPHOSCradle.\n"; | |
193 | // exit(1); | |
194 | // } | |
195 | } | |
196 | AddPHOSCradles(); | |
197 | ||
198 | ////////////////////////////////////////////////////////////////////////////// | |
199 | // All is done. | |
200 | // Print some information. | |
201 | ////////////////////////////////////////////////////////////////////////////// | |
202 | } | |
203 | ||
204 | void AliPHOSv3::StepManager() | |
205 | { | |
206 | static Bool_t inwold=0; // Status of previous ctrak->inwvol | |
bc9ab547 | 207 | Int_t copy; |
208 | ||
cfce8870 | 209 | // if( gMC->TrackEntering() ) { |
210 | // Int_t Volume_ID = gMC->CurrentVol(Volume_name, copy); | |
bc9ab547 | 211 | // cout << "AliPHOSv3::StepManager() entered to PHOS to the volume " << Volume_name << "!\n"; |
212 | // } | |
213 | ||
214 | int cradle_number, cell_Z, cell_Phi; // Variables that describe cell position. | |
215 | ||
cfce8870 | 216 | if( gMC->GetMedium()==GetPHOS_IDTMED_PIN() && gMC->TrackEntering() && gMC->TrackCharge()!=0 ) |
bc9ab547 | 217 | { |
218 | // GEANT particle just have entered into PIN diode. | |
219 | ||
220 | AliPHOS &PHOS = *(AliPHOS*)gAlice->GetModule("PHOS"); | |
221 | ||
cfce8870 | 222 | gMC->CurrentVolOff(4,0,copy); |
bc9ab547 | 223 | cradle_number = copy-1; |
cfce8870 | 224 | gMC->CurrentVolOff(1,0,copy); |
bc9ab547 | 225 | cell_Z = copy-1; |
cfce8870 | 226 | gMC->CurrentVolOff(2,0,copy); |
bc9ab547 | 227 | cell_Phi = copy-1; |
228 | ||
229 | TH2S &h = PHOS.GetCradle(cradle_number).fChargedTracksInPIN; | |
230 | h.AddBinContent(h.GetBin(cell_Z,cell_Phi)); | |
231 | ||
232 | // cout << "AliPHOSv3::StepManager() entered to PHOS pin diode\n"; | |
233 | // cout << " cradle_nimber = " << cradle_number << endl; | |
234 | // cout << " cell_z = " << cell_Z << endl; | |
235 | // cout << " cell_Phi = " << cell_Phi << endl; | |
236 | } | |
237 | ||
238 | ////////////////////////////////////////////////////////////////////////////// | |
239 | ||
cfce8870 | 240 | if( gMC->GetMedium() == GetPHOS_IDTMED_PbWO4() ) |
bc9ab547 | 241 | { |
242 | // GEANT particle into crystal. | |
243 | ||
244 | AliPHOS &PHOS = *(AliPHOS*)gAlice->GetModule("PHOS"); | |
245 | ||
cfce8870 | 246 | gMC->CurrentVolOff(5,0,copy); |
bc9ab547 | 247 | cradle_number = copy-1; |
cfce8870 | 248 | gMC->CurrentVolOff(2,0,copy); |
bc9ab547 | 249 | cell_Z = copy-1; |
cfce8870 | 250 | gMC->CurrentVolOff(3,0,copy); |
bc9ab547 | 251 | cell_Phi = copy-1; |
252 | ||
253 | TH2F &h = PHOS.GetCradle(cradle_number).fCellEnergy; | |
cfce8870 | 254 | h.AddBinContent(h.GetBin(cell_Z,cell_Phi),gMC->Edep()); |
bc9ab547 | 255 | } |
256 | ||
257 | ////////////////////////////////////////////////////////////////////////////// | |
258 | ||
cfce8870 | 259 | if( gMC->GetMedium()==GetPHOS_IDTMED_CPV() && gMC->TrackEntering() ) |
bc9ab547 | 260 | { |
261 | // GEANT particle just have entered into CPV detector. | |
262 | ||
263 | AliPHOS &PHOS = *(AliPHOS*)gAlice->GetModule("PHOS"); | |
264 | ||
cfce8870 | 265 | gMC->CurrentVolOff(1,0,cradle_number); |
bc9ab547 | 266 | cradle_number--; |
267 | ||
268 | // Save CPV x,y hits position of charged particles. | |
269 | ||
270 | AliPHOSCradle &cradle = PHOS.GetCradle(cradle_number); | |
271 | ||
272 | Float_t xyz[3]; | |
cfce8870 | 273 | gMC->TrackPosition(xyz); |
bc9ab547 | 274 | TVector3 p(xyz[0],xyz[1],xyz[2]),v; |
275 | ||
276 | float x,y,l; | |
277 | float R = cradle.GetRadius() - cradle.GetCPV_PHOS_Distance() - cradle.GetCPV_Thikness(); | |
278 | cradle.GetXY(p,v,R,x,y,l); | |
279 | if( PHOS.fDebugLevel>0 ) | |
280 | if( l<0 ) | |
281 | printf("PHOS_STEP: warning: negative distance to CPV!! %f\n", l); | |
282 | ||
283 | // Store current particle in the list of Cradle particles. | |
284 | Float_t pmom[4]; | |
cfce8870 | 285 | gMC->TrackMomentum(pmom); |
bc9ab547 | 286 | Float_t Px = pmom[0] * pmom[3], |
287 | Py = pmom[1] * pmom[3], | |
288 | Pz = pmom[2] * pmom[3]; | |
cfce8870 | 289 | Float_t Getot = gMC->Etot(); |
290 | Int_t Ipart = gMC->TrackPid(); | |
bc9ab547 | 291 | |
292 | cradle.GetParticles().Add(new AliPHOSgamma(x,y,Getot,Px,Py,Pz,Ipart)); | |
293 | ||
294 | // printf ("Cradle %i, x,y = %8.3f, %8.3f cm, E,Px,Py,Pz = %8.3f, %8.3f, %8.3f GeV, %8.3f, Ipart = %i\n", | |
295 | // cradle_number,x,y,Getot,Px,Py,Pz,Ipart); | |
296 | ||
297 | } | |
298 | ||
cfce8870 | 299 | inwold=gMC->TrackEntering(); // Save current status of GEANT variable. |
bc9ab547 | 300 | } |