1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 #include <TObjArray.h>
22 #include <TGeoMaterial.h>
23 #include <TGeoMatrix.h>
24 #include <TGeoMedium.h>
26 #include "AliITSBaseGeometry.h"
29 ClassImp(AliITSMixture)
31 AliITSMixture::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.
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
47 Double_t tw,*nw,wel[110],Ael[110],el[110];
50 if(N>m->GetEntries()){ // Error not enough mixtures defined
51 Error("Mixing","There are more weight defined than mixtures");
54 // First normilize the weights just in case.
56 for(i=0;i<N;i++) if(w[i]>0.0) tw += w[i];
58 for(i=0;i<N;i++) {if(w[i]>0.0) nw[i] = w[i]/tw;else nw[i] = 0.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]);
72 for(i=1;i<110;i++) if(wel[i]>0.0){
76 if(tw<=0.0) { // Error no elements defined.
77 Error("Mixing","Total weight of this mixture is zero");
81 // setup TGeoMixture data members.
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.
92 for(i=0;i<N;i++) if(nw[i]>0.0) {
93 mix = (TGeoMixture*) (m->At(i));
94 rho += nw[i]*(mix->GetDensity());
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).
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()));
107 fRadLen = 1.0/radlen;
109 if(intleng>0.) fIntLen = intleng;
110 else { // try to compute interaction form mixture.
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()));
116 fIntLen = 1.0/intleng;
123 if(wel[z]>0.0) this->DefineElement(j++,Ael[z],el[z],wel[z]);
127 //======================================================================
128 ClassImp(AliITSGeoCable)
130 AliITSGeoCable::AliITSGeoCable(){
134 fNs.SetXYZ(0.0,0.0,0.0);
135 fNe.SetXYZ(0.0,0.0,0.0);
139 //----------------------------------------------------------------------
140 AliITSGeoCable::AliITSGeoCable(const char *name,const TObjArray *vect,
141 const Double_t Rmin,const Double_t Rmax,
142 const TVector3 ns,const TVector3 ne){
145 // char *name Name of this compound object
146 // TObjArray *vect Array of TVector3's of points representing the
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
155 // A fully initilized and created AliITSGeoCable class.
159 TVector3 x0,x1,x2,d,t,n0,n1;
164 fNs.SetXYZ(0.0,0.0,-1.0);
165 fNe.SetXYZ(0.0,0.0,1.0);
166 n = vect->GetEntries();
167 fTubes = new TObjArray(n-1);
168 fTranRot = new TObjArray(n-1);
169 fNs = ns*(1./ns.Mag());
170 fNe = ne*(1./ne.Mag());
172 x0 = *((TVector3 *)(vect->At(0)));
175 x1 = *((TVector3 *)(vect->At(i)));
178 x2 = *((TVector3 *)(vect->At(i+1)));
185 th = TMath::ATan2(TMath::Sqrt(2.*d.Mag2()-d.z()-2.*d.Mag()*d.y()-
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);
192 fTranRot->AddAt(new TGeoCombiTrans(nam,t.x(),t.y(),t.z(),
193 new TGeoRotation("",ph,th,0.0)),i-1);
195 sprintf(nam,"%sPart%dCable",name,i-1);
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);
202 //----------------------------------------------------------------------
203 AliITSGeoCable::~AliITSGeoCable(){
214 for(i=0;i<fTubes->GetEntries();i++)
215 delete (TGeoCtub*)(fTubes->At(i));
220 for(i=0;i<fTranRot->GetEntries();i++)
221 delete (TGeoCombiTrans*)(fTranRot->At(i));
226 //----------------------------------------------------------------------