]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONFactoryV2.cxx
Update TriggerSegmention (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONFactoryV2.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 ////////////////////////////////////////////////////////////
17 //  Factory for muon chambers, segmentations and response //
18 ////////////////////////////////////////////////////////////
19
20 /* $Id$ */
21
22 #include "AliMUONFactoryV2.h"
23 #include "AliRun.h"
24 #include "AliSegmentation.h"
25 #include "AliLog.h"
26
27 #include "AliMUON.h"
28 #include "AliMUONConstants.h"
29 #include "AliMUONTriggerConstants.h"
30 #include "AliMUONChamber.h"
31 #include "AliMUONResponseV0.h"
32 #include "AliMUONGeometryModule.h"
33 #include "AliMUONGeometryStore.h"
34 #include "AliMUONGeometrySegmentation.h"
35 #include "AliMUONSt12QuadrantSegmentation.h"
36 #include "AliMUONSt345SlatSegmentation.h"
37 #include "AliMUONTriggerSegmentation.h"
38 #include "AliMUONResponseTrigger.h"
39
40 ClassImp(AliMUONFactoryV2)
41
42 //__________________________________________________________________________
43   AliMUONFactoryV2::AliMUONFactoryV2()
44     : AliMUONFactory(),
45       fMUON(0),
46       fResponse0(0)
47 {
48   // FactoryV2 inherite from Factory for switching in AliMUONv1::Init()
49   // to be changed when old segmentation will be removed.
50 }
51
52 //__________________________________________________________________________
53 AliMUONFactoryV2::AliMUONFactoryV2(const AliMUONFactoryV2& rhs)
54   : AliMUONFactory(rhs)
55 {
56   // Protected copy constructor
57
58   AliFatal("Not implemented.");
59 }
60
61 //__________________________________________________________________________
62
63 AliMUONFactoryV2::~AliMUONFactoryV2()
64 {
65   //
66 }
67
68 //__________________________________________________________________________
69 AliMUONFactoryV2&  AliMUONFactoryV2::operator=(const AliMUONFactoryV2& rhs)
70 {
71   // Protected assignement operator
72
73   if (this == &rhs) return *this;
74
75   AliFatal("Not implemented.");
76     
77   return *this;  
78 }    
79           
80 //__________________________________________________________________________
81 void AliMUONFactoryV2::BuildCommon() 
82 {
83   //
84   // Construct the default response.
85   //
86
87   // Default response: 5 mm of gas
88   fResponse0 = new AliMUONResponseV0;
89   fResponse0->SetSqrtKx3AndDeriveKx2Kx4(0.7131); // sqrt(0.5085)
90   fResponse0->SetSqrtKy3AndDeriveKy2Ky4(0.7642); // sqrt(0.5840)
91   fResponse0->SetPitch(AliMUONConstants::Pitch()); // anode-cathode distance
92   fResponse0->SetSigmaIntegration(10.);
93   fResponse0->SetChargeSlope(10);
94   fResponse0->SetChargeSpread(0.18, 0.18);
95   fResponse0->SetMaxAdc(4096);
96   fResponse0->SetSaturation(3000);
97   fResponse0->SetZeroSuppression(6);
98 }       
99         
100 //__________________________________________________________________________
101 void AliMUONFactoryV2::BuildStation1() 
102 {
103   //--------------------------------------------------------
104   // Configuration for Chamber TC1/2  (Station 1) ----------           
105   //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106
107
108   // Response for 4 mm of gas (station 1)
109   // automatic consistency with width of sensitive medium in CreateGeometry ????
110   AliMUONResponseV0* responseSt1 = new AliMUONResponseV0;
111   // Mathieson parameters from L.Kharmandarian's thesis, page 190
112   responseSt1->SetSqrtKx3AndDeriveKx2Kx4(0.7000); // sqrt(0.4900)
113   responseSt1->SetSqrtKy3AndDeriveKy2Ky4(0.7550); // sqrt(0.5700)
114   responseSt1->SetPitch(AliMUONConstants::PitchSt1()); // anode-cathode distance
115   responseSt1->SetSigmaIntegration(10.);
116   // ChargeSlope larger to compensate for the smaller anode-cathode distance
117   // and keep the same most probable ADC channel for mip's
118   responseSt1->SetChargeSlope(62.5); 
119   // assumed proportionality to anode-cathode distance for ChargeSpread
120   responseSt1->SetChargeSpread(0.144, 0.144);
121   responseSt1->SetMaxAdc(4096);
122   responseSt1->SetSaturation(3000);
123   responseSt1->SetZeroSuppression(6);
124
125   // Quadrant segmentations:
126   AliMUONSt12QuadrantSegmentation* bendSt1
127     = new AliMUONSt12QuadrantSegmentation(kStation1, kBendingPlane);
128   AliMUONSt12QuadrantSegmentation* nonbendSt1
129     = new AliMUONSt12QuadrantSegmentation(kStation1, kNonBendingPlane);
130
131   AliMUONGeometrySegmentation* segmentation[2];
132
133   for (Int_t chamber = 0; chamber < 2; chamber++) {
134
135     segmentation[0] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
136     segmentation[1] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
137         
138     // id detection elt for chamber 1
139     Int_t id0 = (chamber+1)*100;
140
141     //--------------------------------------------------------
142     // Configuration for Chamber TC1/2  (Station 1) ----------           
143
144
145     fMUON->SetNsec(chamber,2);
146
147     // cathode 0
148     segmentation[0]->Add(id0,      bendSt1);
149     segmentation[0]->Add(id0 +  1, nonbendSt1);
150     segmentation[0]->Add(id0 + 50, bendSt1);
151     segmentation[0]->Add(id0 + 51, nonbendSt1); 
152     fMUON->SetSegmentationModel(chamber, 1, segmentation[0]);   
153
154     // cathode 1
155     segmentation[1]->Add(id0,      nonbendSt1);
156     segmentation[1]->Add(id0 +  1, bendSt1);
157     segmentation[1]->Add(id0 + 50, nonbendSt1);
158     segmentation[1]->Add(id0 + 51, bendSt1);
159     fMUON->SetSegmentationModel(chamber, 2, segmentation[1]);
160         
161     fMUON->SetResponseModel(chamber, responseSt1); // special response      
162     fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
163         
164   }
165 }
166
167 //__________________________________________________________________________
168 void AliMUONFactoryV2::BuildStation2() 
169 {
170   //
171   //--------------------------------------------------------
172   // Configuration for Chamber TC3/4 (Station 2) -----------
173   ///^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174
175
176   // Quadrant segmentations:
177   AliMUONSt12QuadrantSegmentation* bendSt2
178     = new AliMUONSt12QuadrantSegmentation(kStation2, kBendingPlane);
179   AliMUONSt12QuadrantSegmentation* nonbendSt2
180     = new AliMUONSt12QuadrantSegmentation(kStation2, kNonBendingPlane);
181
182   AliMUONGeometrySegmentation* segmentation[2];
183
184   for (Int_t chamber = 2; chamber < 4; chamber++) {
185
186     segmentation[0] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
187     segmentation[1] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
188         
189     // id detection elt for chamber 1
190     Int_t id0 = (chamber+1)*100;
191
192     //--------------------------------------------------------
193     // Configuration for Chamber TC3/4  (Station 2) ----------           
194
195
196     fMUON->SetNsec(chamber,2);
197
198     // cathode 0
199     segmentation[0]->Add(id0,      bendSt2);
200     segmentation[0]->Add(id0 +  1, nonbendSt2);
201     segmentation[0]->Add(id0 + 50, bendSt2);
202     segmentation[0]->Add(id0 + 51, nonbendSt2); 
203     fMUON->SetSegmentationModel(chamber, 1, segmentation[0]);   
204
205     // cathode 1
206     segmentation[1]->Add(id0,      nonbendSt2);
207     segmentation[1]->Add(id0 +  1, bendSt2);
208     segmentation[1]->Add(id0 + 50, nonbendSt2);
209     segmentation[1]->Add(id0 + 51, bendSt2);
210     fMUON->SetSegmentationModel(chamber, 2, segmentation[1]);
211         
212     fMUON->SetResponseModel(chamber, fResponse0); // normal response        
213     fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
214         
215   }
216 }       
217         
218         
219 //__________________________________________________________________________
220 void AliMUONFactoryV2::BuildStation3() 
221 {
222   //--------------------------------------------------------
223   // Configuration for Chamber TC5/6  (Station 3) ----------          
224   //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
225
226   AliMUONGeometrySegmentation* segmentation[2];
227
228   //Slats Segmentations
229   AliMUONSt345SlatSegmentation *slatsegB[4]; // Types of segmentation for St3
230   AliMUONSt345SlatSegmentation *slatsegNB[4]; 
231   // Bending
232
233   Int_t ndiv[4] ={ 4, 4, 2, 1};  // densities zones 
234   for(Int_t i=0; i<4; i++) {
235     slatsegB[i] = new AliMUONSt345SlatSegmentation(1);
236     slatsegB[i]->SetPadSize(10.,0.5);
237     slatsegB[i]->SetPadDivision(ndiv);
238     slatsegB[i]->SetId(1); // Id elt ????
239     slatsegB[i]->SetDAnod(AliMUONConstants::Pitch());
240     slatsegNB[i] = new AliMUONSt345SlatSegmentation(0);
241     slatsegNB[i]->SetPadSize(0.713,10.); // Nbending
242     slatsegNB[i]->SetPadDivision(ndiv);
243     slatsegNB[i]->SetId(1);
244     slatsegNB[i]->SetDAnod(AliMUONConstants::Pitch());
245   }
246
247   // Type 112200 for 500, 501, 508, 509, 510, 517 
248   // in Ch5 (similar for Ch6) for the futur official numbering
249   // Type 112200 for 503, 504, 505, 555, 554, 553 
250   // in Ch5 (similar for Ch6) actual numbering in the code to be changed in jan05
251   Int_t n0[4] = { 0, 2, 2, 0 };
252   slatsegB[0]->SetPcbBoards(n0);
253   slatsegB[0]->Init(0);
254   slatsegNB[0]->SetPcbBoards(n0);
255   slatsegNB[0]->Init(0);
256     
257   // Type 122200 for 502, 507, 511, 516 (similar in Ch6) 
258   // for future official numbering of ALICE
259   // Type 122200 for 502, 506, 556, 552 (similiarin Ch6) 
260   // for actual numbering in muon code to be changed in jan05
261   Int_t n1[4] = { 0, 1, 3, 0 }; 
262   slatsegB[1]->SetPcbBoards(n1);
263   slatsegB[1]->Init(0); 
264   slatsegNB[1]->SetPcbBoards(n1);
265   slatsegNB[1]->Init(0); 
266     
267   // Type 222000 for 503, 506, 512, 515 (similar in Ch6) 
268   // for future official numbering of ALICE
269   // Type 222000 for 501, 507, 557, 551 (similiarin Ch6) 
270   // for actual numbering in muon code to be changed in jan05
271   Int_t n2[4] = { 0, 0, 3, 0 };
272   slatsegB[2]->SetPcbBoards(n2);
273   slatsegB[2]->Init(0);
274   slatsegNB[2]->SetPcbBoards(n2);
275   slatsegNB[2]->Init(0);
276     
277   // Type 220000 for 504, 505, 513, 514 (similar in Ch6) 
278   // for future official numbering of ALICE
279   // Type 220000 for 500, 508, 558, 550 (similiarin Ch6) 
280   // for actual numbering in muon code to be changed in jan05
281   Int_t n3[4] = { 0, 0, 2, 0 };
282   slatsegB[3]->SetPcbBoards(n3);
283   slatsegB[3]->Init(0); 
284   slatsegNB[3]->SetPcbBoards(n3);
285   slatsegNB[3]->Init(0); 
286
287   for (Int_t chamber = 4; chamber < 6; chamber++) {
288
289     segmentation[0] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
290     segmentation[1] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
291         
292     // id detection elt for chamber 1
293     Int_t id0 = (chamber+1)*100;
294
295     //--------------------------------------------------------
296     // Configuration for Chamber TC3/4  (Station 2) ----------           
297
298
299     fMUON->SetNsec(chamber,2);
300
301     // cathode 0
302     // type 220000
303     segmentation[0]->Add(id0, slatsegB[3]);
304     segmentation[0]->Add(id0+ 8, slatsegB[3]);  
305     segmentation[0]->Add(id0+50, slatsegB[3]);  
306     segmentation[0]->Add(id0+58, slatsegB[3]);
307     // type 222000
308     segmentation[0]->Add(id0+ 1, slatsegB[2]);
309     segmentation[0]->Add(id0+ 7, slatsegB[2]);  
310     segmentation[0]->Add(id0+51, slatsegB[2]);  
311     segmentation[0]->Add(id0+57, slatsegB[2]);
312     // type 122200
313     segmentation[0]->Add(id0+ 2, slatsegB[1]);
314     segmentation[0]->Add(id0+ 6, slatsegB[1]);  
315     segmentation[0]->Add(id0+52, slatsegB[1]);  
316     segmentation[0]->Add(id0+56, slatsegB[1]);
317     // type 112200
318     segmentation[0]->Add(id0+ 3, slatsegB[0]);
319     segmentation[0]->Add(id0+ 4, slatsegB[0]);  
320     segmentation[0]->Add(id0+ 5, slatsegB[0]);  
321     segmentation[0]->Add(id0+53, slatsegB[0]);
322     segmentation[0]->Add(id0+54, slatsegB[0]);     
323     segmentation[0]->Add(id0+55, slatsegB[0]);
324     fMUON->SetSegmentationModel(chamber, 1, segmentation[0]);   
325
326     // cathode 1
327     // type 220000
328     segmentation[1]->Add(id0, slatsegNB[3]);
329     segmentation[1]->Add(id0+ 8, slatsegNB[3]);  
330     segmentation[1]->Add(id0+50, slatsegNB[3]);  
331     segmentation[1]->Add(id0+58, slatsegNB[3]);
332     // type 222000
333     segmentation[1]->Add(id0+ 1, slatsegNB[2]);
334     segmentation[1]->Add(id0+ 7, slatsegNB[2]);  
335     segmentation[1]->Add(id0+51, slatsegNB[2]);  
336     segmentation[1]->Add(id0+57, slatsegNB[2]);
337     // type 122200
338     segmentation[1]->Add(id0+ 2, slatsegNB[1]);
339     segmentation[1]->Add(id0+ 6, slatsegNB[1]);  
340     segmentation[1]->Add(id0+52, slatsegNB[1]);  
341     segmentation[1]->Add(id0+56, slatsegNB[1]);
342     // type 112200
343     segmentation[1]->Add(id0+ 3, slatsegNB[0]);
344     segmentation[1]->Add(id0+ 4, slatsegNB[0]);  
345     segmentation[1]->Add(id0+ 5, slatsegNB[0]);  
346     segmentation[1]->Add(id0+53, slatsegNB[0]);
347     segmentation[1]->Add(id0+54, slatsegNB[0]);     
348     segmentation[1]->Add(id0+55, slatsegNB[0]);
349     fMUON->SetSegmentationModel(chamber, 2, segmentation[1]);
350
351     fMUON->SetResponseModel(chamber, fResponse0);      
352     fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
353   }
354 }
355
356         
357 //__________________________________________________________________________
358 void AliMUONFactoryV2::BuildStation4() 
359 {
360   //--------------------------------------------------------
361   // Configuration for Chamber TC7/8  (Station 4) ----------           
362   //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
363
364
365   AliMUONGeometrySegmentation* segmentation[2];
366
367   //Slats Segmentations
368   AliMUONSt345SlatSegmentation *slatsegB[7]; // Types of segmentation for St4
369   AliMUONSt345SlatSegmentation *slatsegNB[7]; 
370   // Bending
371
372   Int_t ndiv[4] ={ 4, 4, 2, 1};  // densities zones 
373   for(Int_t i = 0; i < 7; i++) {
374     slatsegB[i] = new AliMUONSt345SlatSegmentation(1);
375     slatsegB[i]->SetPadSize(10.,0.5);
376     slatsegB[i]->SetPadDivision(ndiv);
377     slatsegB[i]->SetId(1);
378     slatsegB[i]->SetDAnod(AliMUONConstants::Pitch());
379     slatsegNB[i] = new AliMUONSt345SlatSegmentation(0);
380     slatsegNB[i]->SetPadSize(0.713,10.); 
381     slatsegNB[i]->SetPadDivision(ndiv);
382     slatsegNB[i]->SetId(1);
383     slatsegNB[i]->SetDAnod(AliMUONConstants::Pitch());
384   }
385
386   Int_t n4[4] = { 0, 1, 2, 2 };
387   slatsegB[0]->SetPcbBoards(n4);
388   slatsegB[0]->Init(0); // 0 detection element id
389   slatsegNB[0]->SetPcbBoards(n4);
390   slatsegNB[0]->Init(0); // 0 detection element id
391     
392   // Type 112233 for 701, 712, 714, 725 in Ch7 (similar for Ch8) 
393   // for the futur official numbering
394   // Type 112233 for 705, 707, 755, 757 in Ch7 (similar for Ch8) 
395   // actual numbering in the code to be changed in jan05
396   // Type 112233 for 901, 902, 911, 912, 914, 915, 924, 925 in Ch9 
397   // (similar for Ch10) for the futur official numbering
398   // Type 112233 for 904, 905, 907, 908, 954, 955, 957, 958 in Ch9 
399   // (similar for Ch10) actual numbering in the code to be changed in jan05
400   Int_t n5[4] = { 0, 2, 2, 2 };
401   slatsegB[1]->SetPcbBoards(n5);
402   slatsegB[1]->Init(0); // 0 detection element id
403   slatsegNB[1]->SetPcbBoards(n5);
404   slatsegNB[1]->Init(0); // 0 detection element id
405     
406   // Type 112230 for 702, 711, 715, 724 in Ch7 (similar for Ch8) 
407   // for the futur official numbering
408   // Type 112230 for 704, 708, 754, 758 in Ch7 (similar for Ch8) 
409   // actual numbering in the code to be changed in jan05
410   Int_t n6[4] = { 0, 2, 2, 1 };
411   slatsegB[2]->SetPcbBoards(n6);
412   slatsegB[2]->Init(0); // 0 detection element id
413   slatsegNB[2]->SetPcbBoards(n6);
414   slatsegNB[2]->Init(0); // 0 detection element id
415     
416   // Type 222330 for 703, 710, 716, 723 in Ch7 (similar for Ch8) 
417   // for the futur official numbering
418   // Type 222330 for 703, 709, 753, 759 in Ch7 (similar for Ch8) 
419   // actual numbering in the code to be changed in jan05
420   Int_t n7[4] = { 0, 0, 3, 2 };
421   slatsegB[3]->SetPcbBoards(n7);
422   slatsegB[3]->Init(0); // 0 detection element id
423   slatsegNB[3]->SetPcbBoards(n7);
424   slatsegNB[4]->Init(0); // 0 detection element id
425     
426   // Type 223300 for 704, 709, 717, 722 in Ch7 (similar for Ch8) 
427   // for the futur official numbering
428   // Type 223300 for 702, 710, 752, 760 in Ch7 (similar for Ch8) 
429   // actual numbering in the code to be changed in jan05
430   Int_t n8[4] = { 0, 0, 2, 2 };
431   slatsegB[4]->SetPcbBoards(n8);
432   slatsegB[4]->Init(0); // 0 detection element id
433   slatsegNB[4]->SetPcbBoards(n8);
434   slatsegNB[4]->Init(0); // 0 detection element id
435     
436   // Type 333000 for 705, 708, 718, 721 in Ch7 (similar for Ch8) 
437   // for the futur official numbering
438   // Type 333000 for 701, 711, 751, 761 in Ch7 (similar for Ch8) 
439   // actual numbering in the code to be changed in jan05
440   // Type 333000 for 906, 907, 919, 920 in Ch9 (similar for Ch10) 
441   // for the futur official numbering
442   // Type 333000 for 900, 912, 950, 962 in Ch9 (similar for Ch10) 
443   // actual numbering in the code to be changed in jan05
444   Int_t n9[4] = { 0, 0, 0, 3 };
445   slatsegB[5]->SetPcbBoards(n9);
446   slatsegB[5]->Init(0); // 0 detection element id
447   slatsegNB[5]->SetPcbBoards(n9);
448   slatsegNB[5]->Init(0); // 0 detection element id
449     
450   // Type 330000 for 706, 707, 719, 720 in Ch7 (similar for Ch8) 
451   // for the futur official numbering
452   // Type 330000 for 700, 712, 750, 762 in Ch7 (similar for Ch8) 
453   // actual numbering in the code to be changed in jan05
454   Int_t n10[4] = { 0, 0, 0, 2 };
455   slatsegB[6]->SetPcbBoards(n10);
456   slatsegB[6]->Init(0); // 0 detection element id
457   slatsegNB[6]->SetPcbBoards(n10);
458   slatsegNB[6]->Init(0); // 0 detection element id
459
460
461   for (Int_t chamber = 6; chamber < 8; chamber++) {
462
463     segmentation[0] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
464     segmentation[1] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
465         
466     // id detection elt for chamber 1
467     Int_t id0 = (chamber+1)*100;
468
469     //--------------------------------------------------------
470     // Configuration for Chamber TC6/7  (Station 4) ----------           
471
472
473     fMUON->SetNsec(chamber,2);
474
475     // cathode 0
476     // type 122330
477     segmentation[0]->Add(id0+ 6, slatsegB[0]);
478     segmentation[0]->Add(id0+56, slatsegB[0]);
479   
480     // type 112233
481     segmentation[0]->Add(id0+ 5, slatsegB[1]);
482     segmentation[0]->Add(id0+ 7, slatsegB[1]);  
483     segmentation[0]->Add(id0+55, slatsegB[1]);  
484     segmentation[0]->Add(id0+57, slatsegB[1]);
485    
486     // type 112230
487     segmentation[0]->Add(id0+ 4, slatsegB[2]);
488     segmentation[0]->Add(id0+ 8, slatsegB[2]);  
489     segmentation[0]->Add(id0+54, slatsegB[2]);  
490     segmentation[0]->Add(id0+58, slatsegB[2]);
491
492     // type 222330 
493     segmentation[0]->Add(id0+ 3, slatsegB[3]);
494     segmentation[0]->Add(id0+ 9, slatsegB[3]);  
495     segmentation[0]->Add(id0+53, slatsegB[3]);
496     segmentation[0]->Add(id0+59, slatsegB[3]);
497
498     // type 223300 
499     segmentation[0]->Add(id0+ 2, slatsegB[4]);
500     segmentation[0]->Add(id0+10, slatsegB[4]);  
501     segmentation[0]->Add(id0+52, slatsegB[4]);
502     segmentation[0]->Add(id0+60, slatsegB[4]);
503
504     // type 333000 
505     segmentation[0]->Add(id0+ 1, slatsegB[5]);
506     segmentation[0]->Add(id0+11, slatsegB[5]);  
507     segmentation[0]->Add(id0+51, slatsegB[5]);
508     segmentation[0]->Add(id0+61, slatsegB[5]);
509
510     // type 330000 
511     segmentation[0]->Add(id0   , slatsegB[6]);
512     segmentation[0]->Add(id0+12, slatsegB[6]);  
513     segmentation[0]->Add(id0+50, slatsegB[6]);
514     segmentation[0]->Add(id0+62, slatsegB[6]);
515     fMUON->SetSegmentationModel(chamber, 1, segmentation[0]);   
516
517     // cathode 1
518     // type 122330
519     segmentation[1]->Add(id0+ 6, slatsegNB[0]);
520     segmentation[1]->Add(id0+56, slatsegNB[0]);
521
522     // type 112233
523     segmentation[1]->Add(id0+ 5, slatsegNB[1]);
524     segmentation[1]->Add(id0+ 7, slatsegNB[1]);  
525     segmentation[1]->Add(id0+55, slatsegNB[1]);  
526     segmentation[1]->Add(id0+57, slatsegNB[1]);
527   
528     // type 112230
529     segmentation[1]->Add(id0+ 4, slatsegNB[2]);
530     segmentation[1]->Add(id0+ 8, slatsegNB[2]);  
531     segmentation[1]->Add(id0+54, slatsegNB[2]);  
532     segmentation[1]->Add(id0+58, slatsegNB[2]);
533
534     // type 222330 
535     segmentation[1]->Add(id0+ 3, slatsegNB[3]);
536     segmentation[1]->Add(id0+ 9, slatsegNB[3]);  
537     segmentation[1]->Add(id0+53, slatsegNB[3]);
538     segmentation[1]->Add(id0+59, slatsegNB[3]);
539
540     // type 223300 
541     segmentation[1]->Add(id0+ 2, slatsegNB[4]);
542     segmentation[1]->Add(id0+10, slatsegNB[4]);  
543     segmentation[1]->Add(id0+52, slatsegNB[4]);
544     segmentation[1]->Add(id0+60, slatsegNB[4]);
545
546     // type 333000 
547     segmentation[1]->Add(id0+ 1, slatsegNB[5]);
548     segmentation[1]->Add(id0+11, slatsegNB[5]);  
549     segmentation[1]->Add(id0+51, slatsegNB[5]);
550     segmentation[1]->Add(id0+61, slatsegNB[5]);
551
552     // type 330000 
553     segmentation[1]->Add(id0   , slatsegNB[6]);
554     segmentation[1]->Add(id0+12, slatsegNB[6]);  
555     segmentation[1]->Add(id0+50, slatsegNB[6]);
556     segmentation[1]->Add(id0+62, slatsegNB[6]);
557     fMUON->SetSegmentationModel(chamber, 2, segmentation[1]);
558
559     fMUON->SetResponseModel(chamber, fResponse0);      
560     fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
561   }
562 }
563
564 //__________________________________________________________________________
565 void AliMUONFactoryV2::BuildStation5() 
566 {       
567   //--------------------------------------------------------
568   // Configuration for Chamber TC9/10  (Station 5) ---------           
569   //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
570
571   AliMUONGeometrySegmentation* segmentation[2];
572
573   //Slats Segmentations
574   AliMUONSt345SlatSegmentation *slatsegB[6]; // Types of segmentation for St5
575   AliMUONSt345SlatSegmentation *slatsegNB[6]; 
576   // Bending
577
578   Int_t ndiv[4] ={ 4, 4, 2, 1};  // densities zones 
579   for(Int_t i = 0; i < 6; i++) {
580     slatsegB[i] = new AliMUONSt345SlatSegmentation(1);
581     slatsegB[i]->SetPadSize(10.,0.5);
582     slatsegB[i]->SetPadDivision(ndiv);
583     slatsegB[i]->SetId(1);
584     slatsegB[i]->SetDAnod(AliMUONConstants::Pitch());
585     slatsegNB[i] = new AliMUONSt345SlatSegmentation(0);
586     slatsegNB[i]->SetPadSize(0.713,10.); 
587     slatsegNB[i]->SetPadDivision(ndiv);
588     slatsegNB[i]->SetId(1);
589     slatsegNB[i]->SetDAnod(AliMUONConstants::Pitch());
590   }
591
592   // Type 122330 for 900, 913 in Ch9 (similar for Ch10) 
593   // for the futur official numbering
594   // Type 122330 for 906, 956 in Ch9 (similar for Ch10) 
595   // actual numbering in the code to be changed in jan05
596   Int_t n4[4] = { 0, 1, 2, 2 };
597   slatsegB[0]->SetPcbBoards(n4);
598   slatsegB[0]->Init(0); // 0 detection element id
599   slatsegNB[0]->SetPcbBoards(n4);
600   slatsegNB[0]->Init(0); // 0 detection element id
601     
602   // Type 112233 for 901, 902, 911, 912, 914, 915, 924, 925 in Ch9 
603   // (similar for Ch10) for the futur official numbering
604   // Type 112233 for 904, 905, 907, 908, 954, 955, 957, 958 in Ch9 
605   // (similar for Ch10) actual numbering in the code to be changed in jan05
606   Int_t n5[4] = { 0, 2, 2, 2 };
607   slatsegB[1]->SetPcbBoards(n5);
608   slatsegB[1]->Init(0); // 0 detection element id
609   slatsegNB[1]->SetPcbBoards(n5);
610   slatsegNB[1]->Init(0); // 0 detection element id
611
612   // Type 333000 for 906, 907, 919, 920 in Ch9 (similar for Ch10) 
613   // for the futur official numbering
614   // Type 333000 for 900, 912, 950, 962 in Ch9 (similar for Ch10) 
615   // actual numbering in the code to be changed in jan05
616   Int_t n9[4] = { 0, 0, 0, 3 };
617   slatsegB[2]->SetPcbBoards(n9);
618   slatsegB[2]->Init(0); // 0 detection element id
619   slatsegNB[2]->SetPcbBoards(n9);
620   slatsegNB[2]->Init(0); // 0 detection element id
621
622   // Type 222333 for 903, 910, 916, 923 in Ch9 (similar for Ch10) 
623   // for the futur official numbering
624   // Type 222333 for 903, 909, 953, 959 in Ch9 (similar for Ch10) 
625   // actual numbering in the code to be changed in jan05
626   Int_t n11[4] = { 0, 0, 3, 3 };
627   slatsegB[3]->SetPcbBoards(n11);
628   slatsegB[3]->Init(0); // 0 detection element id
629   slatsegNB[3]->SetPcbBoards(n11);
630   slatsegNB[3]->Init(0); // 0 detection element id
631   
632   // Type 223330 for 904, 909, 917, 922 in Ch9 (similar for Ch10) 
633   // for the futur official numbering
634   // Type 223330 for 902, 910, 952, 960 in Ch9 (similar for Ch10) 
635   // actual numbering in the code to be changed in jan05
636   Int_t n12[4] = { 0, 0, 2, 3 };
637   slatsegB[4]->SetPcbBoards(n12);
638   slatsegB[4]->Init(0); // 0 detection element id
639   slatsegNB[4]->SetPcbBoards(n12);
640   slatsegNB[4]->Init(0); // 0 detection element id
641     
642   // Type 333300 for 905, 908, 918, 921 in Ch9 (similar for Ch10) 
643   // for the futur official numbering
644   // Type 333300 for 901, 911, 951, 961 in Ch9 (similar for Ch10) 
645   // actual numbering in the code to be changed in jan05
646   Int_t n13[4] = { 0, 0, 0, 4 };
647   slatsegB[5]->SetPcbBoards(n13);
648   slatsegB[5]->Init(0); // 0 detection element id
649   slatsegNB[5]->SetPcbBoards(n13);
650   slatsegNB[5]->Init(0); // 0 detection element id
651
652   for (Int_t chamber = 8; chamber < 10; chamber++) {
653
654     segmentation[0] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
655     segmentation[1] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
656
657     // id detection elt for chamber 1
658     Int_t id0 = (chamber+1)*100;
659
660     //--------------------------------------------------------
661     // Configuration for Chamber TC8/9  (Station 5) ----------           
662
663
664     fMUON->SetNsec(chamber,2);
665
666     // cathode 0
667     // type 122330
668     segmentation[0]->Add(id0+ 6, slatsegB[0]);
669     segmentation[0]->Add(id0+56, slatsegB[0]);
670   
671     // type 112233
672     segmentation[0]->Add(id0+ 4, slatsegB[1]);
673     segmentation[0]->Add(id0+ 5, slatsegB[1]);
674     segmentation[0]->Add(id0+ 7, slatsegB[1]);  
675     segmentation[0]->Add(id0+ 8, slatsegB[1]);  
676     segmentation[0]->Add(id0+54, slatsegB[1]);  
677     segmentation[0]->Add(id0+55, slatsegB[1]);  
678     segmentation[0]->Add(id0+57, slatsegB[1]);
679     segmentation[0]->Add(id0+58, slatsegB[1]);
680
681     // type 333000 
682     segmentation[0]->Add(id0   , slatsegB[2]);
683     segmentation[0]->Add(id0+12, slatsegB[2]);  
684     segmentation[0]->Add(id0+50, slatsegB[2]);
685     segmentation[0]->Add(id0+62, slatsegB[2]);
686  
687     // type 222333 
688     segmentation[0]->Add(id0+ 3, slatsegB[3]);
689     segmentation[0]->Add(id0+ 9, slatsegB[3]);  
690     segmentation[0]->Add(id0+53, slatsegB[3]);
691     segmentation[0]->Add(id0+59, slatsegB[3]);
692  
693     // type 223330 
694     segmentation[0]->Add(id0+ 2, slatsegB[4]);
695     segmentation[0]->Add(id0+10, slatsegB[4]);  
696     segmentation[0]->Add(id0+52, slatsegB[4]);
697     segmentation[0]->Add(id0+60, slatsegB[4]);
698   
699     // type 333300 
700     segmentation[0]->Add(id0+ 1, slatsegB[5]);
701     segmentation[0]->Add(id0+11, slatsegB[5]);  
702     segmentation[0]->Add(id0+51, slatsegB[5]);
703     segmentation[0]->Add(id0+61, slatsegB[5]);
704     fMUON->SetSegmentationModel(chamber, 1, segmentation[0]);
705
706     // cathode 1
707     // type 122330
708     segmentation[1]->Add(id0+ 6, slatsegNB[0]);
709     segmentation[1]->Add(id0+56, slatsegNB[0]);
710   
711     // type 112233
712     segmentation[1]->Add(id0+ 4, slatsegNB[1]);
713     segmentation[1]->Add(id0+ 5, slatsegNB[1]);
714     segmentation[1]->Add(id0+ 7, slatsegNB[1]);  
715     segmentation[1]->Add(id0+ 8, slatsegNB[1]);  
716     segmentation[1]->Add(id0+54, slatsegNB[1]);  
717     segmentation[1]->Add(id0+55, slatsegNB[1]);  
718     segmentation[1]->Add(id0+57, slatsegNB[1]);
719     segmentation[1]->Add(id0+58, slatsegNB[1]);
720
721     // type 333000 
722     segmentation[1]->Add(id0   , slatsegNB[2]);
723     segmentation[1]->Add(id0+12, slatsegNB[2]);  
724     segmentation[1]->Add(id0+50, slatsegNB[2]);
725     segmentation[1]->Add(id0+62, slatsegNB[2]);
726  
727     // type 222333 
728     segmentation[1]->Add(id0+ 3, slatsegNB[3]);
729     segmentation[1]->Add(id0+ 9, slatsegNB[3]);  
730     segmentation[1]->Add(id0+53, slatsegNB[3]);
731     segmentation[1]->Add(id0+59, slatsegNB[3]);
732  
733     // type 223330 
734     segmentation[1]->Add(id0+ 2, slatsegNB[4]);
735     segmentation[1]->Add(id0+10, slatsegNB[4]);  
736     segmentation[1]->Add(id0+52, slatsegNB[4]);
737     segmentation[1]->Add(id0+60, slatsegNB[4]);
738   
739     // type 333300 
740     segmentation[1]->Add(id0+ 1, slatsegNB[5]);
741     segmentation[1]->Add(id0+11, slatsegNB[5]);  
742     segmentation[1]->Add(id0+51, slatsegNB[5]);
743     segmentation[1]->Add(id0+61, slatsegNB[5]);
744     fMUON->SetSegmentationModel(chamber, 2, segmentation[1]);
745         
746     fMUON->SetResponseModel(chamber, fResponse0);           
747     fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
748   }
749 }
750
751 //__________________________________________________________________________
752 void AliMUONFactoryV2::BuildStation6() 
753 {       
754  // Create Trigger geometry segmentation for given chamber and cathod
755
756  
757     AliMUONGeometrySegmentation *chamberSeg[2];
758 // Cluster-size off
759         AliMUONResponseTrigger* responseTrigger0 =  new AliMUONResponseTrigger;
760 // Cluster-size on  
761 //  AliMUONResponseTriggerV1* responseTrigger0 =  new AliMUONResponseTriggerV1;
762
763     for (Int_t chamber = 10; chamber < 14; chamber++) {
764
765       //Trigger Segmentation
766       AliMUONTriggerSegmentation *trigSegX[9]; 
767       AliMUONTriggerSegmentation *trigSegY[9]; 
768       for(Int_t i=0; i<9; i++) {
769         trigSegX[i] = new AliMUONTriggerSegmentation(1);
770         trigSegY[i] = new AliMUONTriggerSegmentation(0);
771         trigSegX[i]->SetLineNumber(9-i);    
772         trigSegY[i]->SetLineNumber(9-i);    
773       }
774
775       AliMUONChamber *iChamber, *iChamber1;
776       iChamber1 = &fMUON->Chamber(10);
777       iChamber  = &fMUON->Chamber(chamber);
778       Float_t zpos1= - iChamber1->Z();  
779       Float_t zpos = - iChamber->Z();        
780       Float_t zRatio = zpos / zpos1;
781
782       // init
783       Float_t stripWidth[3]={0.,0.,0.};     // 1.0625 2.125 4.25
784       Float_t stripLength[4]={0.,0.,0.,0.}; // 17. 34. 51. 68.
785       for (Int_t i=0; i<3; i++) 
786         stripWidth[i]=AliMUONTriggerConstants::StripWidth(i)*zRatio;
787       for (Int_t i=0; i<4; i++) 
788         stripLength[i]=AliMUONTriggerConstants::StripLength(i)*zRatio;
789       Int_t nStrip[7]={0,0,0,0,0,0,0};    
790       Float_t stripYsize[7]={0.,0.,0.,0.,0.,0.,0.};
791       Float_t stripXsize[7]={0.,0.,0.,0.,0.,0.,0.};
792
793       // chamber 8 0 cathode 0
794       for (Int_t i=0; i<7; i++) nStrip[i]=16;
795       for (Int_t i=0; i<7; i++) stripYsize[i]=stripWidth[2];
796       for (Int_t i=0; i<6; i++) stripXsize[i]=stripLength[1];
797       stripXsize[6]=stripLength[2];
798       trigSegX[8]->Init(0,nStrip,stripYsize,stripXsize,0.); 
799       trigSegX[0]->Init(0,nStrip,stripYsize,stripXsize,0.); 
800
801       // chamber 8 7 1 0 cathode 1
802       for (Int_t i=0; i<6; i++) nStrip[i]=8;
803       nStrip[7]=16;
804       for (Int_t i=0; i<7; i++) stripYsize[i]=stripLength[3];  
805       for (Int_t i=0; i<7; i++) stripXsize[i]=stripWidth[2];
806       trigSegY[8]->Init(0,nStrip,stripYsize,stripXsize,0.);  
807       trigSegY[7]->Init(0,nStrip,stripYsize,stripXsize,0.);
808       trigSegY[1]->Init(0,nStrip,stripYsize,stripXsize,0.);
809       trigSegY[0]->Init(0,nStrip,stripYsize,stripXsize,0.);
810  
811       // chamber 7 6 2 1 cathode 0
812       for (Int_t i=0; i<6; i++) nStrip[i]=32;
813       nStrip[6]=16;  
814       for (Int_t i=0; i<6; i++) stripYsize[i]=stripWidth[1];
815       stripYsize[6]=stripWidth[2];
816       for (Int_t i=0; i<6; i++) stripXsize[i]=stripLength[1];
817       stripXsize[6]=stripLength[2];
818       trigSegX[7]->Init(0,nStrip,stripYsize,stripXsize,0.);  
819       trigSegX[6]->Init(0,nStrip,stripYsize,stripXsize,0.);
820       trigSegX[2]->Init(0,nStrip,stripYsize,stripXsize,0.);  
821       trigSegX[1]->Init(0,nStrip,stripYsize,stripXsize,0.);
822
823       // chamber 6 2 cathode 1
824       for (Int_t i=0; i<5; i++) nStrip[i]=16;
825       for (Int_t i=5; i<6; i++) nStrip[i]=8;
826       nStrip[6]=16;
827       for (Int_t i=0; i<7; i++) stripYsize[i]=stripLength[3];
828       for (Int_t i=0; i<5; i++) stripXsize[i]=stripWidth[1];
829       for (Int_t i=5; i<7; i++) stripXsize[i]=stripWidth[2];
830       trigSegY[6]->Init(0,nStrip,stripYsize,stripXsize,0.);  
831       trigSegY[2]->Init(0,nStrip,stripYsize,stripXsize,0.);  
832
833       // chamber 5 3 cathode 0
834       nStrip[0]=48;
835       for (Int_t i=1; i<3; i++) nStrip[i]=64;
836       for (Int_t i=3; i<6; i++) nStrip[i]=32;
837       nStrip[6]=16;  
838       for (Int_t i=0; i<3; i++) stripYsize[i]=stripWidth[0];
839       for (Int_t i=3; i<6; i++) stripYsize[i]=stripWidth[1];
840       stripYsize[6]=stripWidth[2];
841       for (Int_t i=0; i<6; i++) stripXsize[i]=stripLength[1];
842       stripXsize[6]=stripLength[2];
843       trigSegX[5]->Init(0,nStrip,stripYsize,stripXsize,stripLength[0]);  
844       trigSegX[3]->Init(0,nStrip,stripYsize,stripXsize,0.);
845
846       // chamber 5 3 cathode 1
847       for (Int_t i=0; i<5; i++) nStrip[i]=16;
848       for (Int_t i=5; i<6; i++) nStrip[5]=8;  
849       nStrip[6]=16;  
850       stripYsize[0]=stripLength[2];
851       for (Int_t i=1; i<8; i++) stripYsize[i]=stripLength[3];
852       for (Int_t i=0; i<5; i++) stripXsize[i]=stripWidth[1];
853       for (Int_t i=5; i<7; i++) stripXsize[i]=stripWidth[2];
854       trigSegY[5]->Init(0,nStrip,stripYsize,stripXsize,stripLength[0]);  
855       trigSegY[3]->Init(0,nStrip,stripYsize,stripXsize,0.);
856
857       // chamber 4 cathode 0
858       nStrip[0]=0;
859       for (Int_t i=1; i<3; i++) nStrip[i]=64;  
860       for (Int_t i=3; i<6; i++) nStrip[i]=32;  
861       nStrip[6]=16;
862       stripYsize[0]=0.;
863       for (Int_t i=1; i<3; i++) stripYsize[i]=stripWidth[0];
864       for (Int_t i=3; i<6; i++) stripYsize[i]=stripWidth[1];
865       stripYsize[6]=stripWidth[2];
866       stripXsize[0]=0;  
867       stripXsize[1]=stripLength[0];  
868       for (Int_t i=2; i<6; i++) stripXsize[i]=stripLength[1];
869       stripXsize[6]=stripLength[2];
870       trigSegX[4]->Init(0,nStrip,stripYsize,stripXsize,0.);  
871
872       // chamber 4 cathode 1
873       nStrip[0]=0;  
874       nStrip[1]=8;  
875       for (Int_t i=2; i<5; i++) nStrip[i]=16;
876       for (Int_t i=5; i<6; i++) nStrip[i]=8;
877       nStrip[6]=16;
878       stripYsize[0]=0.;  
879       for (Int_t i=1; i<7; i++) stripYsize[i]=stripLength[3];
880       stripXsize[0]=0.;
881       for (Int_t i=1; i<5; i++) stripXsize[i]=stripWidth[1];
882       for (Int_t i=5; i<7; i++) stripXsize[i]=stripWidth[2];
883       trigSegY[4]->Init(0,nStrip,stripYsize,stripXsize,0.);
884
885       chamberSeg[0] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
886       chamberSeg[1] = new AliMUONGeometrySegmentation(fMUON->Chamber(chamber).GetGeometry());
887
888       fMUON->SetNsec(chamber,2);
889       Int_t icount=chamber-10;  // chamber counter (0 1 2 3)
890       Int_t id0=(10+icount+1)*100;
891
892
893       //  printf("in CreateTriggerSegmentation here 0 id0=%i \n",id0);  
894
895       for (Int_t i = 0; i < 9; i++) {       
896
897         // cathode 0
898         chamberSeg[0]->Add(id0+i,     trigSegX[i]);
899         chamberSeg[0]->Add(id0+50+i,  trigSegX[i]);
900         fMUON->SetSegmentationModel(chamber, 1, chamberSeg[0]);
901
902         // cathode 1
903         chamberSeg[1]->Add(id0+i,     trigSegY[i]);
904         chamberSeg[1]->Add(id0+50+i,  trigSegY[i]);
905         fMUON->SetSegmentationModel(chamber, 2, chamberSeg[1]);
906
907       }
908
909       fMUON->SetResponseModel(chamber, responseTrigger0);      
910       fMUON->Chamber(chamber).SetChargeCorrel(0); // same charge on cathodes
911
912   
913       //  printf("in CreateTriggerSegmentation here 1\n");  
914
915       if (!id0) {
916         AliWarning(Form("Segmentation for chamber %d is not yet defined",chamber));
917         return ;      
918       }
919     }
920 }       
921 //__________________________________________________________________________
922 void AliMUONFactoryV2::Build(AliMUON* where, const char* what) 
923 {
924   //
925   // Construct MUON from chambers, segmentation and responses
926   //
927
928   fMUON = where;
929   char tmp[20];
930   strcpy(tmp, what);
931
932   if (strcmp(tmp, "default")==0) {
933     // Set default parameters
934     fMUON->SetIshunt(0);
935     fMUON->SetMaxStepGas(0.1);
936     fMUON->SetMaxStepAlu(0.1);
937
938     // Build all stations
939     BuildCommon();
940     BuildStation1();
941     BuildStation2();
942     BuildStation3();
943     BuildStation4();
944     BuildStation5();
945     BuildStation6();
946   } 
947   else
948     AliDebug(0,"Non default version of MUON selected. You have to construct yourself the MUON elements !!");
949 }
950
951 //__________________________________________________________________________
952 void AliMUONFactoryV2::BuildStation(AliMUON* where, Int_t stationNumber) 
953 {
954   //
955   // Construct MUON from chambers, segmentation and responses
956   //
957   // Version 0
958   //
959   // First define the number of planes that are segmented (1 or 2) by a call
960   // to SetNsec.
961   // Then chose for each chamber (chamber plane) the segmentation
962   // and response model.
963   // They should be equal for the two chambers of each station. In a future
964   // version this will be enforced.
965   //
966
967   fMUON = where;
968   if (!fResponse0) BuildCommon(); 
969     
970   switch (stationNumber) {    
971   case 1:  BuildStation1(); break;
972   case 2:  BuildStation2(); break;
973   case 3:  BuildStation3(); break;
974   case 4:  BuildStation4(); break;
975   case 5:  BuildStation5(); break;
976   case 6:  BuildStation6(); break;
977     
978   default: AliFatal("Wrong station number");
979   }  
980 }