check if STAGE_POOL and STAGE_HOST are set, if not warn user.
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerGeometryBuilder.cxx
1 // $Id$
2 //
3 // Class AliMUONTriggerGeometryBuilder
4 // -----------------------------------
5 // MUON Trigger stations geometry construction class.
6 //
7 // Author: Philippe Crochette, LPC Clermont-Ferrand
8
9 #include <TVirtualMC.h>
10 #include <TGeoMatrix.h>
11
12 #include "AliMUONTriggerGeometryBuilder.h"
13 #include "AliMUON.h"
14 #include "AliMUONChamber.h"
15 #include "AliMUONChamberGeometry.h"
16
17 ClassImp(AliMUONTriggerGeometryBuilder)
18
19 //______________________________________________________________________________
20 AliMUONTriggerGeometryBuilder::AliMUONTriggerGeometryBuilder(AliMUON* muon)
21  : AliMUONVGeometryBuilder(&muon->Chamber(10), &muon->Chamber(11),&muon->Chamber(12),&muon->Chamber(13)),
22    fMUON(muon)
23 {
24 // Standard constructor
25
26 }
27
28 //______________________________________________________________________________
29 AliMUONTriggerGeometryBuilder::AliMUONTriggerGeometryBuilder()
30  : AliMUONVGeometryBuilder(),
31    fMUON(0)
32 {
33 // Default constructor
34 }
35
36
37 //______________________________________________________________________________
38 AliMUONTriggerGeometryBuilder::AliMUONTriggerGeometryBuilder(const AliMUONTriggerGeometryBuilder& rhs)
39   : AliMUONVGeometryBuilder(rhs)
40 {
41   Fatal("Copy constructor", 
42         "Copy constructor is not implemented.");
43 }
44
45 //______________________________________________________________________________
46 AliMUONTriggerGeometryBuilder::~AliMUONTriggerGeometryBuilder() {
47 //
48 }
49
50 //______________________________________________________________________________
51 AliMUONTriggerGeometryBuilder& 
52 AliMUONTriggerGeometryBuilder::operator = (const AliMUONTriggerGeometryBuilder& rhs) 
53 {
54   // check assignement to self
55   if (this == &rhs) return *this;
56
57   Fatal("operator=", 
58         "Assignment operator is not implemented.");
59     
60   return *this;  
61 }
62
63 //
64 // public methods
65 //
66
67 //______________________________________________________________________________
68 void AliMUONTriggerGeometryBuilder::CreateGeometry()
69 {
70 // From AliMUONv1::CreateGeometry()
71
72     /* 
73        zpos1 and zpos2 are the middle of the first and second
74        planes of station 1 (+1m for second station):
75        zpos1=(zpos1m+zpos1p)/2=(15999+16071)/2=16035 mm, thick/2=40 mm
76        zpos2=(zpos2m+zpos2p)/2=(16169+16241)/2=16205 mm, thick/2=40 mm
77        zposxm and zposxp= middles of gaz gaps within a detection plane
78        rem: the total thickness accounts for 1 mm of al on both
79        side of the RPCs (see zpos1 and zpos2)
80     */
81     
82     Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
83     Int_t idAir= idtmed[1100]; // medium 1
84     Int_t idAlu1=idtmed[1103]; // medium 4
85     Float_t tpar[3];
86     Double_t dpar[3];    
87     
88 // vertical gap between right and left chambers (kDXZERO*2=4cm)
89     const Float_t kDXZERO=2.; 
90 // main distances for chamber definition in first plane/first station
91     const Float_t kXMIN=34.;       
92     const Float_t kXMED=51.;                                
93     const Float_t kXMAX=272.; 
94 // kXMAX will become 255. in real life. segmentation to be updated accordingly
95 // (see fig.2-4 & 2-5 of Local Trigger Board PRR)
96     const Float_t kYMIN=34.;                              
97     const Float_t kYMAX=51.;                              
98 // inner/outer radius of flange between beam shield. and chambers (1/station)
99     const Float_t kRMIN[2]={50.,50.};
100     const Float_t kRMAX[2]={64.,68.};
101 // z position of the middle of the gas gap in mother vol 
102     const Float_t kZm=-3.6;
103     const Float_t kZp=+3.6;     
104
105     AliMUONChamber *iChamber, *iChamber1;
106     iChamber1 = GetChamber(10);
107     Float_t zpos1=-iChamber1->Z(); 
108     
109 // ratio of zpos1m/zpos1p and inverse for first plane
110     Float_t zmp=(zpos1-3.6)/(zpos1+3.6);
111     Float_t zpm=1./zmp;
112     
113     Int_t icount=0;  // chamber counter (0 1 2 3)
114     
115     for (Int_t istation=0; istation<2; istation++) { // loop on stations
116         for (Int_t iplane=0; iplane<2; iplane++) { // loop on detection planes
117             
118             Int_t iVolNum=1; // counter Volume Number
119             icount = Int_t(iplane*TMath::Power(2,0))+
120                 Int_t(istation*TMath::Power(2,1));
121             
122             iChamber = GetChamber(10+icount);
123             Float_t zpos = - iChamber->Z();          
124             
125 // Flange between beam shielding and RPC 
126             tpar[0]= kRMIN[istation];
127             tpar[1]= kRMAX[istation];
128             tpar[2]= 4.0;           
129             char volFlange[5];
130             sprintf(volFlange,"SF%dA",icount+1);         
131             gMC->Gsvolu(volFlange,"TUBE",idAlu1,tpar,3);     // Al
132             // changed by ivana
133             //gMC->Gspos(volFlange,1,"ALIC",0.,0.,zpos,0,"MANY");
134             iChamber->GetGeometry()->AddEnvelope(volFlange, false);
135             
136 // scaling factor
137             Float_t zRatio = zpos / zpos1;
138             
139 // envelopes (same size except line 5, all virtual)
140             char volEnv[18][5];
141             tpar[1] = kYMIN * zRatio; 
142             tpar[2] = 0.4;
143             Int_t i=0;    // counter
144             for (Int_t icolumn=0; icolumn<2; icolumn++) {
145                 for (Int_t iline=1; iline<10; iline++){
146                     tpar[0] = (kXMAX/2.) * zRatio;
147                     if (iline==5) tpar[0] = ((kXMAX-kXMED)/2.)*zRatio;
148                     if (icolumn==0) 
149                         sprintf(volEnv[i],"S%dL%d",icount,iline);
150                     else
151                         sprintf(volEnv[i],"S%dR%d",icount,iline);
152                     gMC->Gsvolu(volEnv[i],"BOX",idAir,tpar,0); 
153                     i++;
154                 }
155             }
156
157 // chamber prototype
158             tpar[0]= 0.;
159             tpar[1]= 0.;
160             tpar[2]= 0.;            
161             char volAlu[5];     // Alu 
162             char volBak[5];     // Bakelite
163             char volGaz[5];     // Gas streamer     
164             sprintf(volAlu,"SC%dA",icount+1);
165             sprintf(volBak,"SB%dA",icount+1);
166             sprintf(volGaz,"SG%dA",icount+1);
167             gMC->Gsvolu(volAlu,"BOX",idAlu1,tpar,0);         // Al
168             gMC->Gsvolu(volBak,"BOX",idtmed[1107],tpar,0);   // Bakelite
169             gMC->Gsvolu(volGaz,"BOX",idtmed[1106],tpar,0);   // Gas streamer
170             tpar[0] = -1.;
171             tpar[1] = -1.;
172             tpar[2] = 0.1;    
173             gMC->Gsposp(volGaz,1,volBak,0.,0.,0.,0,"ONLY",tpar,3);
174             tpar[2] = 0.3;
175             gMC->Gsposp(volBak,1,volAlu,0.,0.,0.,0,"ONLY",tpar,3);
176
177 // chamber type A
178             Float_t xEnv = (kDXZERO+kXMED+(kXMAX-kXMED)/2.)*zRatio;
179             Float_t yEnvM = 0.;  // y low position of envelope in chamber
180             Float_t yEnvP = 0.;  // y up position of envelope in chamber
181             Float_t yEnvPsave = 0.; // tmp data
182             Float_t yEnvMsave = 0.; // tmp data
183             Float_t xpos = 0.; // x position of RPC in envelope     
184             Float_t ypos = 0.; // y position of RPC in envelope
185             dpar[2] = 0.4;          
186             dpar[0] = ((kXMAX-kXMED)/2.)*zRatio;
187             dpar[1] = kYMIN * zRatio;
188
189             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[4], true, TGeoTranslation(xEnv,yEnvM,kZm));
190             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[13], true, TGeoTranslation(-xEnv,yEnvP,kZp));
191
192             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[4],iVolNum++,3, dpar);
193             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[13],iVolNum++,3, dpar);         
194
195 // chamber type B (plus envelope chambers B & C)   
196             xEnv = (kDXZERO+kXMAX/2.)*zRatio;
197             yEnvPsave = yEnvP;
198             yEnvMsave = yEnvM;
199             yEnvP = (yEnvMsave + kYMIN * zRatio ) * zpm + kYMIN * zRatio;
200             yEnvM = (yEnvPsave + kYMIN * zRatio ) * zmp + kYMIN * zRatio;
201             dpar[0] = ((kXMAX-kXMIN)/2.) * zRatio;
202             dpar[1] = ((kYMAX-kYMIN)/2.) * zRatio;
203             xpos = kXMIN/2. * zRatio;
204             ypos = (kYMIN - kYMIN/4.) * zRatio;
205
206             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[3], true, TGeoTranslation( xEnv,-yEnvP,kZp));
207             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[5], true, TGeoTranslation( xEnv, yEnvP,kZp));
208             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[12], true, TGeoTranslation(-xEnv,-yEnvM,kZm));
209             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[14], true, TGeoTranslation(-xEnv, yEnvM,kZm));
210
211             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[3],iVolNum++,TGeoTranslation(xpos, ypos,0.),3,dpar);
212             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[5],iVolNum++,TGeoTranslation(xpos,-ypos,0.),3,dpar);
213             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[12],iVolNum++,TGeoTranslation(-xpos, ypos,0.),3,dpar);
214             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[14],iVolNum++,TGeoTranslation(-xpos,-ypos,0.),3,dpar);
215
216 // chamber type C (note: same Z than type B)
217             dpar[0] = (kXMAX/2)*zRatio;
218             dpar[1] = (kYMAX/2)*zRatio;
219             xpos = 0.;      
220             ypos = ((kYMAX - kYMIN)/2.) * zRatio;
221
222             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[3],iVolNum++,TGeoTranslation(xpos,-ypos,0.),3,dpar);
223             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[5],iVolNum++,TGeoTranslation(xpos, ypos,0.),3,dpar);
224             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[12],iVolNum++,TGeoTranslation(-xpos,-ypos,0.),3,dpar);
225             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[14],iVolNum++,TGeoTranslation(-xpos, ypos,0.),3,dpar);
226     
227 // chamber type D, E and F (same size)
228 // D        
229             yEnvPsave = yEnvP;
230             yEnvMsave = yEnvM;
231             yEnvP = (yEnvMsave + kYMIN * zRatio ) * zpm + kYMIN * zRatio;
232             yEnvM = (yEnvPsave + kYMIN * zRatio ) * zmp + kYMIN * zRatio;
233             dpar[0] = (kXMAX/2.)*zRatio;
234             dpar[1] =  kYMIN*zRatio;
235
236             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[2], true, TGeoTranslation(xEnv, yEnvM,kZm));
237             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[6], true, TGeoTranslation(-xEnv, yEnvP,kZp));          
238             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[11], true, TGeoTranslation(xEnv,-yEnvM,kZm));
239             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[15], true, TGeoTranslation(-xEnv,-yEnvP,kZp));
240
241             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[2],iVolNum++,3, dpar);
242             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[6],iVolNum++,3, dpar);
243             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[11],iVolNum++,3, dpar);
244             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[15],iVolNum++,3, dpar);
245
246 // E
247             yEnvPsave = yEnvP;
248             yEnvMsave = yEnvM;
249             yEnvP = (yEnvMsave + kYMIN * zRatio ) * zpm + kYMIN * zRatio;
250             yEnvM = (yEnvPsave + kYMIN * zRatio ) * zmp + kYMIN * zRatio;
251
252             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[1], true, TGeoTranslation(xEnv, yEnvP,kZp));
253             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[7], true, TGeoTranslation(-xEnv, yEnvM,kZm));          
254             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[10], true, TGeoTranslation(xEnv,-yEnvP,kZp));
255             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[16], true, TGeoTranslation(-xEnv,-yEnvM,kZm));
256
257             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[1],iVolNum++,3,dpar);
258             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[7],iVolNum++,3,dpar);
259             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[10],iVolNum++,3,dpar);
260             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[16],iVolNum++,3,dpar);
261
262
263 // F
264             yEnvPsave = yEnvP;
265             yEnvMsave = yEnvM;
266             yEnvP = (yEnvMsave + kYMIN * zRatio ) * zpm + kYMIN * zRatio;
267             yEnvM = (yEnvPsave + kYMIN * zRatio ) * zmp + kYMIN * zRatio;
268
269             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[0], true, TGeoTranslation(xEnv, yEnvM,kZm));
270             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[8], true, TGeoTranslation(-xEnv, yEnvP,kZp));          
271             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[9], true, TGeoTranslation(xEnv,-yEnvM,kZm));
272             GetChamber(10+icount)->GetGeometry()->AddEnvelope(volEnv[17], true, TGeoTranslation(-xEnv,-yEnvP,kZp));
273
274             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[0],iVolNum++,3,dpar);
275             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[8],iVolNum++,3,dpar);
276             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[9],iVolNum++,3,dpar);
277             GetChamber(10+icount)->GetGeometry()->AddEnvelopeConstituentParam(volAlu,volEnv[17],iVolNum++,3,dpar);
278
279         } // end loop on detection planes
280     } // end loop on stations    
281 }
282
283 //______________________________________________________________________________
284 void AliMUONTriggerGeometryBuilder::SetTransformations() 
285 {
286 // Defines the transformations for the trigger chambers.
287 // ---
288     Double_t zpos1, zpos2;    
289     AliMUONChamber *iChamber1, *iChamber2;
290
291     iChamber1 = GetChamber(10);
292     zpos1= - iChamber1->Z(); 
293     iChamber1->GetGeometry()
294         ->SetTranslation(TGeoTranslation(0., 0., zpos1));
295     
296     iChamber2 = GetChamber(11);
297     zpos2 = - iChamber2->Z(); 
298     iChamber2->GetGeometry()
299         ->SetTranslation(TGeoTranslation(0., 0., zpos2));
300
301     iChamber1 = GetChamber(12);
302     zpos1 = - iChamber1->Z(); 
303     iChamber1->GetGeometry()
304         ->SetTranslation(TGeoTranslation(0., 0., zpos1));
305     
306     iChamber2 = GetChamber(13);
307     zpos2 = - iChamber2->Z(); 
308     iChamber2->GetGeometry()
309         ->SetTranslation(TGeoTranslation(0., 0., zpos2));
310 }
311
312 //______________________________________________________________________________
313 void AliMUONTriggerGeometryBuilder::SetSensitiveVolumes()
314 {
315 // Defines the sensitive volumes for trigger station chambers.
316 // ---
317
318   GetChamber(10)->GetGeometry()->SetSensitiveVolume("SG1A");
319   GetChamber(11)->GetGeometry()->SetSensitiveVolume("SG2A");
320   GetChamber(12)->GetGeometry()->SetSensitiveVolume("SG3A");
321   GetChamber(13)->GetGeometry()->SetSensitiveVolume("SG4A");
322 }
323