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