Double check if SM is running added. Some redundant output removed from SM
[u/mrichter/AliRoot.git] / ITS / AliITSBaseGeometry.cxx
CommitLineData
aa9bc63b 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 **************************************************************************/
aa9bc63b 15/*
541f7ba6 16 $Id:
17 */
aa9bc63b 18
541f7ba6 19#include <TObject.h>
aa9bc63b 20#include <TObjArray.h>
162acd47 21
541f7ba6 22#include <TGeoMaterial.h>
541f7ba6 23#include <TGeoMatrix.h>
541f7ba6 24#include <TGeoMedium.h>
25#include <TGeoPgon.h>
541f7ba6 26#include "AliITSBaseGeometry.h"
aa9bc63b 27
aa9bc63b 28
541f7ba6 29ClassImp(AliITSMixture)
162acd47 30
541f7ba6 31AliITSMixture::AliITSMixture(const char *name,Int_t N,Double_t *w,TObjArray *m,
32 Double_t rho,Double_t radlen,Double_t intleng)
33 :TGeoMixture(name,1,rho){
34 // Defines a new mixture from a number of Mixtures, and put the
35 // resulting mixture into this object. This will compute avarage
36 // isotopic value between different elements.
aa9bc63b 37 // Inputs:
541f7ba6 38 // Int_t N The number of mixtures in te TObjArray
39 // Double_t *w The array of weights of each mixture
40 // TObjArray *m The array of AliITSMixture (TGeoMixture)s
41 // to be mixed.
aa9bc63b 42 // Output:
43 // none.
44 // Return:
aa9bc63b 45 // none.
541f7ba6 46 Int_t i,z=0,j,Nel;
47 Double_t tw,*nw,wel[110],Ael[110],el[110];
48 TGeoMixture *mix;
bc825688 49
541f7ba6 50 if(N>m->GetEntries()){ // Error not enough mixtures defined
51 Error("Mixing","There are more weight defined than mixtures");
52 return;
53 } // end if
54 // First normilize the weights just in case.
55 tw = 0.0;
56 for(i=0;i<N;i++) if(w[i]>0.0) tw += w[i];
57 nw = new Double_t[N];
58 for(i=0;i<N;i++) {if(w[i]>0.0) nw[i] = w[i]/tw;else nw[i] = 0.0;}
59 //
60 Nel=0;
61 for(i=0;i<110;i++) {el[i] = wel[i] = Ael[i] = 0.0;}
62 for(i=0;i<N;i++)if(w[i]>0.0) {
63 mix = (TGeoMixture*) (m->At(i));
64 for(j=0;j<mix->GetNelements();j++) {
65 z = (Int_t) ((mix->GetZmixt())[j]);
66 wel[z] += nw[i]*((mix->GetWmixt())[j]);
67 el[z] += wel[z]*((mix->GetZmixt())[j]);
68 Ael[z] += wel[z]*((mix->GetAmixt())[j]);
69 } // end for j
aa9bc63b 70 } // end for i
541f7ba6 71 tw = 0.0;
72 for(i=1;i<110;i++) if(wel[i]>0.0){
73 Nel++;
74 tw += wel[i];
75 } // end for
76 if(tw<=0.0) { // Error no elements defined.
77 Error("Mixing","Total weight of this mixture is zero");
78 delete[] nw;
79 return;
aa9bc63b 80 } // end if
541f7ba6 81 // setup TGeoMixture data members.
82 fNelements = Nel;
83 if(fZmixture!=0) delete[] fZmixture;
84 if(fAmixture!=0) delete[] fAmixture;
85 if(fWeights!=0) delete[] fWeights;
86 fZmixture = new Double_t[Nel];
87 fAmixture = new Double_t[Nel];
88 fWeights = new Double_t[Nel];
89 if(rho>0.) fDensity = rho;
90 else { // try to compute density form mixture.
91 rho = 0.0;
92 for(i=0;i<N;i++) if(nw[i]>0.0) {
93 mix = (TGeoMixture*) (m->At(i));
94 rho += nw[i]*(mix->GetDensity());
95 } // end for i
96 fDensity = rho;
aa9bc63b 97 } // end if
541f7ba6 98 if(radlen>0.) fRadLen = radlen;
99 else { // try to compute radiation form mixture.
100 // From "Review of Particle Physics" Particle Data Group Section
101 // 26.4.1 equation 26.21 (2002).
102 radlen = 0.0;
103 for(i=0;i<N;i++) if(nw[i]>0.0) {
104 mix = (TGeoMixture*) (m->At(i));
105 if(mix->GetRadLen()>0.0) rho += 1.0/(nw[i]*(mix->GetRadLen()));
106 } // end for i
107 fRadLen = 1.0/radlen;
aa9bc63b 108 } // end if
541f7ba6 109 if(intleng>0.) fIntLen = intleng;
110 else { // try to compute interaction form mixture.
111 intleng = 0.0;
112 for(i=0;i<N;i++) if(nw[i]>0.0) {
113 mix = (TGeoMixture*) (m->At(i));
114 if(mix->GetIntLen()>0.0) intleng += 1.0/(nw[i]*(mix->GetIntLen()));
115 } // end for i
116 fIntLen = 1.0/intleng;
aa9bc63b 117 } // end if
541f7ba6 118 j = 0;
119 for(z=1;z<110;z++){
120 wel[z] /= tw;
121 el[z] /= tw;
122 Ael[z] /= tw;
123 if(wel[z]>0.0) this->DefineElement(j++,Ael[z],el[z],wel[z]);
162acd47 124 } // end for i
541f7ba6 125 delete[] nw;
162acd47 126}
5a30b198 127//======================================================================
128ClassImp(AliITSGeoCable)
129;
546f3bea 130AliITSGeoCable::AliITSGeoCable(){
5a30b198 131 //
bc825688 132
5a30b198 133 fRmin = fRmax = 0.0;
134 fNs.SetXYZ(0.0,0.0,0.0);
135 fNe.SetXYZ(0.0,0.0,0.0);
136 fTubes = 0;
137 fTranRot = 0;
138}
139//----------------------------------------------------------------------
546f3bea 140AliITSGeoCable::AliITSGeoCable(const char *name,const TObjArray *vect,
141 const Double_t Rmin,const Double_t Rmax,
5a30b198 142 const TVector3 ns,const TVector3 ne){
143 //
144 // Inputs:
145 // char *name Name of this compound object
146 // TObjArray *vect Array of TVector3's of points representing the
147 // path of the cable
148 // TVector3 ns=0 Normal vector representing the angle of the
149 // starting surface, default perpendicular
150 // TVector3 ne=0 Normal vector representing the angle of the
151 // ending surface, default perpendicular
152 // Outputs:
153 // none.
154 // Return:
155 // A fully initilized and created AliITSGeoCable class.
156 Char_t nam[500];
157 Int_t i,n;
158 Double_t s,th,ph;
546f3bea 159 TVector3 x0,x1,x2,d,t,n0,n1;
162acd47 160
b4a4a5e6 161 fRmin = Rmin;
162 fRmax = Rmax;
5a30b198 163 fRmin = fRmax = 0.0;
164 fNs.SetXYZ(0.0,0.0,-1.0);
165 fNe.SetXYZ(0.0,0.0,1.0);
546f3bea 166 n = vect->GetEntries();
5a30b198 167 fTubes = new TObjArray(n-1);
546f3bea 168 fTranRot = new TObjArray(n-1);
169 fNs = ns*(1./ns.Mag());
170 fNe = ne*(1./ne.Mag());
5a30b198 171 //
546f3bea 172 x0 = *((TVector3 *)(vect->At(0)));
5a30b198 173 n0 = ns;
174 for(i=1;i<n;i++){
546f3bea 175 x1 = *((TVector3 *)(vect->At(i)));
5a30b198 176 d = x1 - x0;
177 if(i<n-1) {
546f3bea 178 x2 = *((TVector3 *)(vect->At(i+1)));
5a30b198 179 n1 = d + (x2-x1);
546f3bea 180 n1 *= 1./n1.Mag();
5a30b198 181 }else{
182 n1 = fNe;
183 } // end if
184 t = 0.5*(x1 + x0);
185 th = TMath::ATan2(TMath::Sqrt(2.*d.Mag2()-d.z()-2.*d.Mag()*d.y()-
186 2.*d.Mag()*d.x()),
187 TMath::Sqrt(d.z()*d.z()-2.*d.Mag()*d.z()+d.Mag2()));
188 th *= TMath::RadToDeg();
189 ph = TMath::ATan2(d.y()-d.Mag(),d.x()-d.Mag());
190 ph *= TMath::RadToDeg();
191 sprintf(nam,"%sCombiTrans%dCable",name,i-1);
546f3bea 192 fTranRot->AddAt(new TGeoCombiTrans(nam,t.x(),t.y(),t.z(),
193 new TGeoRotation("",ph,th,0.0)),i-1);
5a30b198 194 s = d.Mag();
195 sprintf(nam,"%sPart%dCable",name,i-1);
546f3bea 196 fTubes->AddAt( new TGeoCtub(nam,fRmin,fRmax,0.5*s,0.0,360.0,n0.x(),
197 n0.y(),n0.z(),n1.x(),n1.y(),n1.z()),i-1);
5a30b198 198 n0 = -n1;
199 x0 = x1;
200 } // end for i
201}
202//----------------------------------------------------------------------
546f3bea 203AliITSGeoCable::~AliITSGeoCable(){
5a30b198 204 //
205 // Inputs:
206 // none.
207 // Outputs:
208 // none.
209 // Return:
210 // none.
211 Int_t i;
162acd47 212
5a30b198 213 if(fTubes){
546f3bea 214 for(i=0;i<fTubes->GetEntries();i++)
5a30b198 215 delete (TGeoCtub*)(fTubes->At(i));
216 delete fTubes;
217 } // end if
218 fTubes = 0;
546f3bea 219 if(fTranRot){
220 for(i=0;i<fTranRot->GetEntries();i++)
221 delete (TGeoCombiTrans*)(fTranRot->At(i));
222 delete fTranRot;
5a30b198 223 } // end if
546f3bea 224 fTranRot = 0;
5a30b198 225}
226//----------------------------------------------------------------------