]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUv11Layer.cxx
Added loop for extraction of clusters really attached to its track.
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUv11Layer.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 // This class Defines the Geometry for the ITS Upgrade using TGeo
18 // This is a work class used to study different configurations
19 // during the development of the new ITS structure.
20 //
21 //  Mario Sitta <sitta@to.infn.it>
22 //*************************************************************************
23
24
25 /* $Id: AliITSUv11Layer.cxx  */
26 // General Root includes
27 #include <TMath.h>
28 // Root Geometry includes
29 //#include <AliLog.h>
30 #include <TGeoManager.h>
31 #include <TGeoVolume.h>
32 #include <TGeoPcon.h>
33 #include <TGeoCone.h>
34 #include <TGeoTube.h> // contaings TGeoTubeSeg
35 #include <TGeoArb8.h>
36 #include <TGeoXtru.h>
37 #include <TGeoCompositeShape.h>
38 #include <TGeoMatrix.h>
39 #include "AliITSUv11Layer.h"
40 #include "AliITSUGeomTGeo.h"
41 using namespace TMath;
42
43 const Double_t AliITSUv11Layer::fgkDefaultSensorThick = 300*fgkmicron;
44 const Double_t AliITSUv11Layer::fgkDefaultLadderThick =   1*fgkcm;
45
46 ClassImp(AliITSUv11Layer)
47
48 #define SQ(A) (A)*(A)
49
50 //________________________________________________________________________
51 AliITSUv11Layer::AliITSUv11Layer(): 
52   AliITSv11Geometry(),
53   fLayerNumber(0),
54   fPhi0(0),
55   fLayRadius(0),
56   fZLength(0),
57   fSensorThick(0),
58   fLadderThick(0),
59   fLadderWidth(0),
60   fLadderTilt(0),
61   fNLadders(0),
62   fNModules(0),
63   fDetTypeID(0),
64   fIsTurbo(0)
65 {
66   //
67   // Standard constructor
68   //
69 }
70
71 //________________________________________________________________________
72 AliITSUv11Layer::AliITSUv11Layer(Int_t debug): 
73   AliITSv11Geometry(debug),
74   fLayerNumber(0),
75   fPhi0(0),
76   fLayRadius(0),
77   fZLength(0),
78   fSensorThick(0),
79   fLadderThick(0),
80   fLadderWidth(0),
81   fLadderTilt(0),
82   fNLadders(0),
83   fNModules(0),
84   fDetTypeID(0),
85   fIsTurbo(0)
86 {
87   //
88   // Constructor setting debugging level
89   //
90 }
91
92 //________________________________________________________________________
93 AliITSUv11Layer::AliITSUv11Layer(Int_t lay, Int_t debug): 
94   AliITSv11Geometry(debug),
95   fLayerNumber(lay),
96   fPhi0(0),
97   fLayRadius(0),
98   fZLength(0),
99   fSensorThick(0),
100   fLadderThick(0),
101   fLadderWidth(0),
102   fLadderTilt(0),
103   fNLadders(0),
104   fNModules(0),
105   fDetTypeID(0),
106   fIsTurbo(0)
107 {
108   //
109   // Constructor setting layer number and debugging level
110   //
111 }
112
113 //________________________________________________________________________
114 AliITSUv11Layer::AliITSUv11Layer(Int_t lay, Bool_t turbo, Int_t debug): 
115   AliITSv11Geometry(debug),
116   fLayerNumber(lay),
117   fPhi0(0),
118   fLayRadius(0),
119   fZLength(0),
120   fSensorThick(0),
121   fLadderThick(0),
122   fLadderWidth(0),
123   fLadderTilt(0),
124   fNLadders(0),
125   fNModules(0),
126   fDetTypeID(0),
127   fIsTurbo(turbo)
128 {
129   //
130   // Constructor setting layer number and debugging level
131   // for a "turbo" layer (i.e. where ladders overlap in phi)
132   //
133 }
134
135 //________________________________________________________________________
136 AliITSUv11Layer::AliITSUv11Layer(const AliITSUv11Layer &s):
137   AliITSv11Geometry(s.GetDebug()),
138   fLayerNumber(s.fLayerNumber),
139   fPhi0(s.fPhi0),
140   fLayRadius(s.fLayRadius),
141   fZLength(s.fZLength),
142   fSensorThick(s.fSensorThick),
143   fLadderThick(s.fLadderThick),
144   fLadderWidth(s.fLadderWidth),
145   fLadderTilt(s.fLadderTilt),
146   fNLadders(s.fNLadders),
147   fNModules(s.fNModules),
148   fDetTypeID(0),
149   fIsTurbo(s.fIsTurbo)
150 {
151   //
152   // Copy constructor
153   //
154 }
155
156 //________________________________________________________________________
157 AliITSUv11Layer& AliITSUv11Layer::operator=(const AliITSUv11Layer &s)
158 {
159   //
160   // Assignment operator 
161   //
162   if(&s == this) return *this;
163
164   fLayerNumber = s.fLayerNumber;
165   fPhi0        = s.fPhi0;
166   fLayRadius   = s.fLayRadius;
167   fZLength     = s.fZLength;
168   fSensorThick = s.fSensorThick;
169   fLadderThick = s.fLadderThick;
170   fLadderWidth = s.fLadderWidth;
171   fLadderTilt  = s.fLadderTilt;
172   fNLadders    = s.fNLadders;
173   fNModules    = s.fNModules;
174   fIsTurbo     = s.fIsTurbo;
175   fDetTypeID   = s.fDetTypeID;
176   return *this;
177 }
178
179 //________________________________________________________________________
180 AliITSUv11Layer::~AliITSUv11Layer() {
181   //
182   // Destructor
183   //
184 }
185
186 //________________________________________________________________________
187 void AliITSUv11Layer::CreateLayer(TGeoVolume *moth,const TGeoManager *mgr){
188 //
189 // Creates the actual Layer and places inside its mother volume
190 //
191 // Input:
192 //         moth : the TGeoVolume owing the volume structure
193 //         mgr  : the GeoManager (used only to get the proper material)
194 //
195 // Output:
196 //
197 // Return:
198 //
199 // Created:      17 Jun 2011  Mario Sitta
200 // Updated:      08 Jul 2011  Mario Sitta
201 //
202   // Local variables
203   char volname[30];
204   Double_t rmin, rmax;
205   Double_t xpos, ypos, zpos;
206   Double_t alpha;
207
208
209   // Check if the user set the proper parameters
210   if (fLayRadius <= 0) AliFatal(Form("Wrong layer radius (%f)",fLayRadius));
211   if (fZLength   <= 0) AliFatal(Form("Wrong layer length (%f)",fZLength));
212   if (fNLadders  <= 0) AliFatal(Form("Wrong number of ladders (%d)",fNLadders));
213   if (fNModules  <= 0) AliFatal(Form("Wrong number of modules (%d)",fNModules));
214
215   if (fLadderThick <= 0) {
216     AliInfo(Form("Ladder thickness wrong or not set (%f), using default (%f)",
217                  fLadderThick,fgkDefaultLadderThick));
218     fLadderThick = fgkDefaultLadderThick;
219   }
220
221   if (fSensorThick <= 0) {
222     AliInfo(Form("Sensor thickness wrong or not set (%f), using default (%f)",
223                  fSensorThick,fgkDefaultSensorThick));
224     fSensorThick = fgkDefaultSensorThick;
225   }
226
227   if (fSensorThick > fLadderThick) {
228     AliWarning(Form("Sensor thickness (%f) is greater than ladder thickness (%f), fixing",
229                  fSensorThick,fLadderThick));
230     fSensorThick = fLadderThick;
231   }
232
233
234   // If a Turbo layer is requested, do it and exit
235   if (fIsTurbo) {
236     CreateLayerTurbo(moth, mgr);
237     return;
238   }
239
240
241   // First create the ladder container
242   alpha = (360./(2*fNLadders))*DegToRad();
243
244   //  fLadderWidth = fLayRadius*Tan(alpha);
245
246   rmin = 0.98*fLayRadius;
247   rmax = 1.02*Sqrt( fLadderWidth*fLadderWidth +
248                           (rmin+fLadderThick)*(rmin+fLadderThick) );
249
250   TGeoTube *layer = new TGeoTube(rmin, rmax, 0.5*fZLength);
251
252
253   // We have all shapes: now create the real volumes
254   TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
255
256   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),fLayerNumber);
257   TGeoVolume *layVol = new TGeoVolume(volname, layer, medAir);
258   layVol->SetUniqueID(fDetTypeID);
259
260 //  layVol->SetVisibility(kFALSE);
261   layVol->SetVisibility(kTRUE);
262   layVol->SetLineColor(1);
263
264   TGeoVolume *laddVol = CreateLadder();
265
266
267   // Now build up the layer
268   alpha = 360./fNLadders;
269   Double_t r = fLayRadius + ((TGeoBBox*)laddVol->GetShape())->GetDY();
270   for (Int_t j=0; j<fNLadders; j++) {
271     Double_t phi = j*alpha + fPhi0;
272     xpos = r*CosD(phi);// r*SinD(-phi);
273     ypos = r*SinD(phi);// r*CosD(-phi);
274     zpos = 0.;
275     phi += 90;
276     layVol->AddNode(laddVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
277                                                     new TGeoRotation("",phi,0,0)));
278   }
279
280
281   // Finally put everything in the mother volume
282   moth->AddNode(layVol, 1, 0);
283
284
285   // Upgrade geometry is served
286   return;
287 }
288
289 //________________________________________________________________________
290 void AliITSUv11Layer::CreateLayerTurbo(TGeoVolume *moth,
291                                           const TGeoManager *mgr){
292 //
293 // Creates the actual Layer and places inside its mother volume
294 // A so-called "turbo" layer is a layer where ladders overlap in phi
295 // User can set width and tilt angle, no check is performed here
296 // to avoid volume overlaps
297 //
298 // Input:
299 //         moth : the TGeoVolume owing the volume structure
300 //         mgr  : the GeoManager (used only to get the proper material)
301 //
302 // Output:
303 //
304 // Return:
305 //
306 // Created:      08 Jul 2011  Mario Sitta
307 // Updated:      08 Mar 2012  Mario Sitta  Correct way to compute container R
308 //
309
310
311   // Local variables
312   char volname[30];
313   Double_t rmin, rmax, rladd, rcont, d;
314   Double_t xpos, ypos, zpos;
315   Double_t alpha, gamma;
316
317
318   // Check if the user set the proper (remaining) parameters
319   if (fLadderWidth <= 0)
320     AliFatal(Form("Wrong ladder width (%f)",fLadderWidth));
321   if (Abs(fLadderTilt) > 45)
322     AliWarning(Form("Ladder tilt angle (%f) greater than 45deg",fLadderTilt));
323
324
325   // First create the ladder container
326   // d is half the diagonal of the ladder section
327   // rladd is the radius at the ladder's center-of-gravity
328   // alpha here is the angle between the diagonal and rladd
329   d = 0.5*Sqrt(fLadderThick*fLadderThick + fLadderWidth*fLadderWidth);
330   alpha = ACos(0.5*fLadderThick/d)*RadToDeg();
331   gamma = alpha - fLadderTilt;
332   rladd = fLayRadius + 0.5*fLadderThick;
333
334   // rcont is the radius of the air container
335   rcont = RadiusOfTurboContainer();
336   
337   if (rcont > 0)
338     rmin = 0.98*rcont;
339   else
340     rmin = 0.98*Sqrt( rladd*rladd + d*d - 2*rladd*d*CosD(gamma) );
341   
342   rmax = 1.02*Sqrt( rladd*rladd + d*d + 2*rladd*d*CosD(gamma) );
343   
344   TGeoTube *layer = new TGeoTube(rmin, rmax, 0.5*fZLength);
345
346
347   // We have all shapes: now create the real volumes
348   TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
349
350   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(), fLayerNumber);
351   TGeoVolume *layVol = new TGeoVolume(volname, layer, medAir);
352   layVol->SetUniqueID(fDetTypeID);
353   layVol->SetVisibility(kTRUE);
354   layVol->SetLineColor(1);
355   TGeoVolume *laddVol = CreateLadder();
356
357
358   // Now build up the layer
359
360
361   // Now build up the layer
362   alpha = 360./fNLadders;
363   Double_t r = fLayRadius + ((TGeoBBox*)laddVol->GetShape())->GetDY();
364   for (Int_t j=0; j<fNLadders; j++) {
365     Double_t phi = j*alpha + fPhi0;
366     xpos = r*CosD(phi);// r*SinD(-phi);
367     ypos = r*SinD(phi);// r*CosD(-phi);
368     zpos = 0.;
369     phi += 90;
370     layVol->AddNode(laddVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
371                                                     new TGeoRotation("", phi-fLadderTilt,0,0)));
372   }
373
374
375   // Finally put everything in the mother volume
376   moth->AddNode(layVol, 1, 0);
377
378   return;
379 }
380
381 //________________________________________________________________________
382 TGeoVolume* AliITSUv11Layer::CreateLadder(const TGeoManager *mgr){
383 //
384 // Creates the actual Ladder
385 //
386 // Input:
387 //         mgr  : the GeoManager (used only to get the proper material)
388 //
389 // Output:
390 //
391 // Return:
392 //
393 // Created:      22 Jun 2011  Mario Sitta
394 //
395
396   char volname[30];
397   Double_t xlen, ylen, zlen;
398   Double_t xpos, ypos, zpos, zmod;
399   Double_t alpha;
400
401
402   // First create all needed shapes
403   alpha = (360./(2*fNLadders))*DegToRad();
404
405   // The ladder
406   xlen = fLayRadius*Tan(alpha);
407   if (fIsTurbo) xlen = 0.5*fLadderWidth;
408   ylen = 0.5*fLadderThick;
409   zlen = 0.5*fZLength;
410
411   TGeoBBox *ladder = new TGeoBBox(xlen, ylen, zlen);
412
413
414   // We have all shapes: now create the real volumes
415   TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
416
417   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
418   TGeoVolume *laddVol = new TGeoVolume(volname, ladder, medAir);
419
420 //  laddVol->SetVisibility(kFALSE);
421   laddVol->SetVisibility(kTRUE);
422   laddVol->SetLineColor(2);
423   TGeoVolume *modVol = CreateModule(ladder->GetDX(), ladder->GetDY(),
424                                     ladder->GetDZ());
425
426
427   // Now build up the ladder
428   zmod = ((TGeoBBox*)modVol->GetShape())->GetDZ();
429   for (Int_t j=0; j<fNModules; j++) {
430     xpos = 0.;
431     ypos = 0.;
432     zpos = -ladder->GetDZ() + j*2*zmod + zmod;
433     laddVol->AddNode(modVol, j, new TGeoTranslation(xpos, ypos, zpos));
434   }
435
436
437   // Done, return the ladder
438   return laddVol;
439 }
440
441 //________________________________________________________________________
442 TGeoVolume* AliITSUv11Layer::CreateModule(const Double_t xlad,
443                                                    const Double_t ylad,
444                                                    const Double_t zlad,
445                                                    const TGeoManager *mgr){
446 //
447 // Creates the actual Module
448 //
449 // Input:
450 //         xlad,ylad,zlad : the ladder dimensions
451 //         mgr  : the GeoManager (used only to get the proper material)
452 //
453 // Output:
454 //
455 // Return:
456 //
457 // Created:      22 Jun 2011  Mario Sitta
458 //
459
460   char volname[30];
461   Double_t xlen, ylen, zlen;
462   Double_t xpos, ypos, zpos;
463
464
465   // First create all needed shapes
466
467   // The module
468   TGeoBBox *module = new TGeoBBox(xlad, ylad, zlad/fNModules);
469
470   // The sensor
471   xlen = module->GetDX();
472   ylen = 0.5*fSensorThick;
473   zlen = module->GetDZ();
474   TGeoBBox *sensor = new TGeoBBox(xlen, ylen, zlen);
475
476
477   // We have all shapes: now create the real volumes
478   //  TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
479   TGeoMedium *medSi  = mgr->GetMedium("ITS_SI$");
480
481   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSModulePattern() ,fLayerNumber);
482   //  TGeoVolume *modVol = new TGeoVolume(volname, module, medAir);
483   TGeoVolume *modVol = new TGeoVolume(volname, module, medSi);
484   modVol->SetVisibility(kFALSE);
485   modVol->SetLineColor(1);
486
487   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSSensorPattern(), fLayerNumber);
488   TGeoVolume *sensVol = new TGeoVolume(volname, sensor, medSi);
489   sensVol->SetVisibility(kTRUE);
490   sensVol->SetLineColor(8);
491   sensVol->SetLineWidth(1);
492   sensVol->SetFillColor(sensVol->GetLineColor());
493   sensVol->SetFillStyle(4000); // 0% transparent
494
495
496   // Now build up the module
497   xpos = 0.;
498   ypos = -module->GetDY() + sensor->GetDY();
499   zpos = 0.;
500
501   modVol->AddNode(sensVol, 1, new TGeoTranslation(xpos, ypos, zpos));
502
503
504   // Done, return the module
505   return modVol;
506 }
507
508 //________________________________________________________________________
509 Double_t AliITSUv11Layer::RadiusOfTurboContainer(){
510 //
511 // Computes the inner radius of the air container for the Turbo configuration
512 // as the radius of either the circle tangent to the ladder or the circle
513 // passing for the ladder's lower vertex
514 //
515 // Input:
516 //         none (all needed parameters are class members)
517 //
518 // Output:
519 //
520 // Return:
521 //        the radius of the container if >0, else flag to use the lower vertex
522 //
523 // Created:      08 Mar 2012  Mario Sitta
524 //
525
526   Double_t rr, delta, z, lladd, rladd;
527
528   if (fLadderThick > 89.) // Very big angle: avoid overflows since surely
529     return -1;            // the radius from lower vertex is the right value
530
531   rladd = fLayRadius + 0.5*fLadderThick;
532   delta = (0.5*fLadderThick)/CosD(fLadderTilt);
533   z     = (0.5*fLadderThick)*TanD(fLadderTilt);
534
535   rr = rladd - delta;
536   lladd = (0.5*fLadderWidth) - z;
537
538   if ( (rr*SinD(fLadderTilt) < lladd) )
539     return (rr*CosD(fLadderTilt));
540   else
541     return -1;
542 }
543
544 //________________________________________________________________________
545 void AliITSUv11Layer::SetLadderTilt(const Double_t t)
546 {
547 //
548 // Sets the Ladder tilt angle (for turbo layers only)
549 //
550 // Input:
551 //         t :  the ladder tilt angle
552 //
553 // Output:
554 //
555 // Return:
556 //
557 // Created:      08 Jul 2011  Mario Sitta
558 //
559
560   if (fIsTurbo)
561     fLadderTilt = t;
562   else
563     AliError("Not a Turbo layer");
564
565 }
566
567 //________________________________________________________________________
568 void AliITSUv11Layer::SetLadderWidth(const Double_t w){
569 //
570 // Sets the Ladder width (for turbo layers only)
571 //
572 // Input:
573 //         w :  the ladder width
574 //
575 // Output:
576 //
577 // Return:
578 //
579 // Created:      08 Jul 2011  Mario Sitta
580 //
581
582   if (fIsTurbo)
583     fLadderWidth = w;
584   else
585     AliError("Not a Turbo layer");
586
587 }