Coverity fixes
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALSpaceFrame.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 #include <TVirtualMC.h>
17 #include <TGeoManager.h>
18 #include <TGeoVolume.h>
19 #include <TGeoMedium.h>
20 #include <TGeoMatrix.h>
21 #include <TGeoVolume.h>
22 #include <TGeoTube.h>
23 #include <TGeoCone.h>
24 #include <TGeoPcon.h>
25 #include <TGeoCompositeShape.h>
26
27 #include "AliConst.h"
28 #include "AliEMCALSpaceFrame.h"
29 #include "AliMagF.h"
30 #include "AliRun.h"
31 #include "AliLog.h"
32  
33 ClassImp(AliEMCALSpaceFrame)
34  
35 //_____________________________________________________________________________
36 AliEMCALSpaceFrame::AliEMCALSpaceFrame() 
37   : TNamed("EMCALSpaceFrame","Steel Space Frame that supports EMCAL"),
38     fNumCross(0),
39     fNumSubSets(0),
40     fTotalHalfWidth(0.),
41     fBeginPhi(0.),
42     fEndPhi(0.),
43     fTotalPhi(0.),
44     fBeginRadius(0.),
45     fHalfFrameTrans(0.),
46     fFlangeHeight(0.),
47     fFlangeWidth(0.),
48     fRibHeight(0.),
49     fRibWidth(0.),
50     fCrossBottomWidth(0.),
51     fCrossTopWidth(0.),
52     fCrossBottomHeight(0.),
53     fCrossBottomRadThick(0.),
54     fCrossBeamArcLength(0.),
55     fCrossBottomStartRadius(0.),
56     fCrossTopHeight(0.),
57     fCrossTopRadThick(0.),
58     fCrossTopStart(0.),
59     fEndRadius(0.),
60     fEndBeamRadThick(0),
61     fEndBeamBeginRadius(0)
62 {
63   // default constructor for EMCAL Space Frame
64   //initialize parameters
65   fNumCross = 12; 
66   fNumSubSets = 3;
67   fTotalHalfWidth = 152.3;   // Half Width of a Half Frame
68                              // (CalFrame comes in 2 sections) 
69   fBeginPhi = 76.8;
70   fEndPhi = 193.03;
71   fBeginRadius = 490.;
72   
73   fHalfFrameTrans = fTotalHalfWidth+57.2/2.;  // Half Frame Connector is 57.2cm wide,
74                             // Supermodule is 340cm wide
75                             // Sources: HALF-FRAME-CONNECTOR-27E226A.pdf
76                             // provided by LBL
77
78   fFlangeWidth = 15.2;
79   fRibWidth = 1.5;
80   fCrossBottomHeight = 15.2;
81   fCrossBottomRadThick = 1.5;
82   fCrossTopHeight = 1.5;
83   fCrossTopRadThick = 35./2.;
84
85   fTotalPhi = fEndPhi - fBeginPhi;
86   fFlangeHeight = fBeginRadius + 3.;
87   fRibHeight = fFlangeHeight + 35;
88   fCrossBottomWidth = 0.5/(Double_t)fNumSubSets * (2.*fTotalHalfWidth - 8. * fFlangeWidth);
89   fCrossTopWidth = fCrossBottomWidth; // fCrossBottomWidth + fFlangeWidth - fRibWidth;
90                                       // for future release pending
91                                       // overlap correction - new TGeoVolume creation
92
93   fCrossBeamArcLength = (112.62597)/(fNumCross-1)-.001; // To account for shape of TGeoBBox
94   fCrossBottomStartRadius = fBeginRadius + fCrossBottomRadThick;
95   fCrossTopStart = fBeginRadius + 2.*fCrossBottomRadThick + fCrossTopRadThick+0.015; // 0.015 is a 
96                                                                                      // bubblegum and duct tape
97                                                                                      // fix for an overlap problem
98                                                                                      // will be worked out in future releases 
99   fEndRadius = fRibHeight+1.15;
100   fEndBeamRadThick = fCrossBottomRadThick+fCrossTopRadThick;
101   fEndBeamBeginRadius = fBeginRadius + fEndBeamRadThick;
102 }
103
104 //_____________________________________________________________________________
105 AliEMCALSpaceFrame::AliEMCALSpaceFrame(const AliEMCALSpaceFrame &frame) 
106   : TNamed(frame.GetName(),frame.GetTitle()),
107     fNumCross(frame.fNumCross),
108     fNumSubSets(frame.fNumSubSets),
109     fTotalHalfWidth(frame.fTotalHalfWidth),
110     fBeginPhi(frame.fBeginPhi),
111     fEndPhi(frame.fEndPhi),
112     fTotalPhi(frame.fTotalPhi),
113     fBeginRadius(frame.fBeginRadius),
114     fHalfFrameTrans(frame.fHalfFrameTrans),
115     fFlangeHeight(frame.fFlangeHeight),
116     fFlangeWidth(frame.fFlangeWidth),
117     fRibHeight(frame.fRibHeight),
118     fRibWidth(frame.fRibWidth),
119     fCrossBottomWidth(frame.fCrossBottomWidth),
120     fCrossTopWidth(frame.fCrossTopWidth),
121     fCrossBottomHeight(frame.fCrossBottomHeight),
122     fCrossBottomRadThick(frame.fCrossBottomRadThick),
123     fCrossBeamArcLength(frame.fCrossBeamArcLength),
124     fCrossBottomStartRadius(frame.fCrossBottomStartRadius),
125     fCrossTopHeight(frame.fCrossTopHeight),
126     fCrossTopRadThick(frame.fCrossTopRadThick),
127     fCrossTopStart(frame.fCrossTopStart),
128     fEndRadius(frame.fEndRadius),
129     fEndBeamRadThick(frame.fEndBeamRadThick),
130     fEndBeamBeginRadius(frame.fEndBeamBeginRadius)
131 {
132   // copy constructor for EMCAL Space Frame
133
134 }
135
136 //_____________________________________________________________________________
137 void AliEMCALSpaceFrame::CreateGeometry()
138 {
139   AliDebug(1,"Create CalFrame Geometry");
140   //////////////////////////////////////Setup/////////////////////////////////////////
141   TGeoVolume* top = gGeoManager->GetVolume("ALIC");
142   TGeoMedium *steel = gGeoManager->GetMedium("EMCAL_S steel$");
143   TGeoMedium *air = gGeoManager->GetMedium("EMCAL_Air$");
144
145         
146   //////////////////////////////////// Volumes ///////////////////////////////////////  
147   TGeoVolume *calFrameMO = 
148     gGeoManager->MakeTubs("CalFrame", air, fBeginRadius-2.1,fEndRadius,
149                           fTotalHalfWidth*3,fBeginPhi-3,fEndPhi+3);     // Mother Volume
150
151   calFrameMO->SetVisibility(kFALSE);
152
153   // Half Frame Mother Volume
154   TGeoVolume *calHalfFrameMO = 
155     gGeoManager->MakeTubs("HalfFrame", air, fBeginRadius-2,fEndRadius,
156                           fTotalHalfWidth,fBeginPhi-2.9,fEndPhi+2.9);
157
158   calHalfFrameMO->SetVisibility(kFALSE);
159
160   TGeoVolume *endBeams = 
161     gGeoManager->MakeBox("End Beams", steel, fEndBeamRadThick, fCrossTopHeight, fTotalHalfWidth); // End Beams
162
163   TGeoVolume *skin = 
164     gGeoManager->MakeTubs("skin", steel, fRibHeight+0.15, fEndRadius, 
165                           fTotalHalfWidth, fBeginPhi, fEndPhi);// back frame
166
167   TGeoVolume *flangeVolume = 
168     gGeoManager->MakeTubs("supportBottom", steel, fBeginRadius, fFlangeHeight, 
169                           fFlangeWidth, fBeginPhi, fEndPhi);            // FlangeVolume Beams
170
171   TGeoVolume *ribVolume = 
172     gGeoManager->MakeTubs("RibVolume", steel, fFlangeHeight, fRibHeight, fRibWidth, fBeginPhi, fEndPhi);
173
174   TGeoVolume *subSetCross = 
175     gGeoManager->MakeTubs("subSetCross", air, fBeginRadius-1,  fBeginRadius+2*fCrossBottomRadThick+
176                           2*fCrossTopRadThick+0.15, fCrossBottomWidth, fBeginPhi, fEndPhi);             // Cross Beam Containers
177   subSetCross->SetVisibility(kFALSE);
178   /*                                            // Obsolete for now
179   TGeoVolume *subSetCrossTop = 
180     gGeoManager->MakeTubs("SubSetCrossTop", air, fBeginRadius+2*fCrossBottomRadThick-1, fBeginRadius+2*fCrossBottomRadThick+
181                           2*fCrossTopRadThick+1, fCrossTopWidth, fBeginPhi, fEndPhi);   // Cross 
182   subSetCrossTop->SetVisibility(kFALSE);
183   */                    
184   TGeoVolume *crossBottomBeams = 
185     gGeoManager->MakeBox("crossBottom", steel, fCrossBottomRadThick, fCrossBottomHeight, fCrossBottomWidth); // Cross Beams
186
187   TGeoVolume *crossTopBeams = 
188     gGeoManager->MakeBox("crossTop", steel, fCrossTopRadThick, fCrossTopHeight, fCrossTopWidth); // Cross Beams
189   
190   TGeoTranslation *trTEST = new TGeoTranslation();
191   TGeoRotation *rotTEST = new TGeoRotation();
192   
193   Double_t conv = TMath::Pi()/180.;
194   Double_t radAngle = 0;
195   Double_t endBeamParam=.4;
196   //cout<<"\nfCrossBottomStartRadius: "<<fCrossBottomStartRadius<<"\n";
197   
198   for(Int_t i = 0; i < fNumCross; i++){
199     
200     Double_t loopPhi = fBeginPhi + 1.8;
201
202     // Cross Bottom Beams
203     
204     radAngle = (loopPhi + i*fCrossBeamArcLength)*conv; 
205     
206     rotTEST->SetAngles(fBeginPhi + i*fCrossBeamArcLength, 0, 0); //  SetTranslation(Double_t dx, Double_t dy, Double_t dz);
207     trTEST->SetTranslation(cos(radAngle)*fCrossBottomStartRadius, sin(radAngle)*fCrossBottomStartRadius,0);
208
209     TGeoCombiTrans *combo = new TGeoCombiTrans(*trTEST, *rotTEST);      // TGeoTranslation &tr, const TGeoRotation &rot);
210     combo->RegisterYourself();
211     crossBottomBeams->SetVisibility(1);
212     subSetCross->AddNode(crossBottomBeams, i+1, combo);
213     if (i != 0 && i!=fNumCross-1){
214     // Cross Bottom Beams
215     rotTEST->SetAngles(fBeginPhi + i*fCrossBeamArcLength, 0, 0); //  SetTranslation(Double_t dx, Double_t dy, Double_t dz);
216     trTEST->SetTranslation(cos(radAngle)*fCrossTopStart, sin(radAngle)*fCrossTopStart,0);
217     crossTopBeams->SetVisibility(1);
218     subSetCross->AddNode(crossTopBeams, i+1,  new TGeoCombiTrans(*trTEST, *rotTEST));
219     }
220     
221
222     else if(i ==0){
223                 rotTEST->SetAngles(fBeginPhi + i*fCrossBeamArcLength, 0, 0); //  SetTranslation(Double_t dx, Double_t dy, Double_t dz);
224     trTEST->SetTranslation(cos((77-endBeamParam)*conv)*(fEndBeamBeginRadius), sin((77-endBeamParam)*conv)*(fEndBeamBeginRadius),0);
225     endBeams->SetVisibility(1);
226     calHalfFrameMO->AddNode(endBeams, 1,  new TGeoCombiTrans(*trTEST, *rotTEST));
227     }
228     else{
229     rotTEST->SetAngles(193.03, 0, 0); //  SetTranslation(Double_t dx, Double_t dy, Double_t dz);
230     trTEST->SetTranslation(cos((193.03+endBeamParam)*conv)*(fEndBeamBeginRadius)/*more duct tape*/, sin((193.03+endBeamParam)*conv)*(fEndBeamBeginRadius),0);
231     endBeams->SetVisibility(1);
232     calHalfFrameMO->AddNode(endBeams, 2,  new TGeoCombiTrans(*trTEST, *rotTEST));
233     }  
234   }
235   
236   //Beam Containers
237
238   // Translations 
239
240   TGeoTranslation *origin1 = new TGeoTranslation(0,0,0); // Equivalent to gGeoIdentity
241   TGeoTranslation *origin2 = new TGeoTranslation(0,0,2*(fCrossBottomWidth+fFlangeWidth));
242   TGeoTranslation *origin3 = new TGeoTranslation(0,0,-2*(fCrossBottomWidth+fFlangeWidth));
243
244   // FlangeVolume translations  
245   TGeoTranslation *str1 = new TGeoTranslation(0,0,-3*(fCrossBottomWidth+fFlangeWidth));
246   TGeoTranslation *str2 = new TGeoTranslation(0,0,-(fCrossBottomWidth+fFlangeWidth));
247   TGeoTranslation *str3 = new TGeoTranslation(0,0,(fCrossBottomWidth+fFlangeWidth));
248   TGeoTranslation *str4 = new TGeoTranslation(0,0,3*(fCrossBottomWidth+fFlangeWidth));
249
250   // Half Frame Translations
251   TGeoTranslation *halfTrans1 =  new TGeoTranslation(0,0,fHalfFrameTrans);
252   TGeoTranslation *halfTrans2 =  new TGeoTranslation(0,0,-fHalfFrameTrans);
253
254   // Beams Volume 
255   calHalfFrameMO->AddNode(flangeVolume, 1, str1);
256   calHalfFrameMO->AddNode(flangeVolume, 2, str2);
257   calHalfFrameMO->AddNode(flangeVolume, 3, str3);
258   calHalfFrameMO->AddNode(flangeVolume, 4, str4);
259   
260   calHalfFrameMO->AddNode(ribVolume, 1, str1);
261   calHalfFrameMO->AddNode(ribVolume, 2, str2);
262   calHalfFrameMO->AddNode(ribVolume, 3, str3);
263   calHalfFrameMO->AddNode(ribVolume, 4, str4);
264   
265   // Cross Beams  
266   calHalfFrameMO->AddNode(subSetCross, 1, origin1);
267   calHalfFrameMO->AddNode(subSetCross, 2, origin2);
268   calHalfFrameMO->AddNode(subSetCross, 3, origin3);
269 /*                                      // Obsolete for now
270   calHalfFrameMO->AddNode(subSetCrossTop, 1, origin1);
271   calHalfFrameMO->AddNode(subSetCrossTop, 2, origin2);
272   calHalfFrameMO->AddNode(subSetCrossTop, 3, origin3);
273 */
274
275   calHalfFrameMO->AddNode(skin, 1, gGeoIdentity);
276   
277   calFrameMO->AddNode(calHalfFrameMO, 1, halfTrans1);
278   calFrameMO->AddNode(calHalfFrameMO, 2, halfTrans2);
279  
280   top->AddNode(calFrameMO,1,gGeoIdentity);
281 //  cout<<"**********************************\nfEndRadius:\t"<<fEndRadius;
282 }
283