New files for folders and Stack
[u/mrichter/AliRoot.git] / FMD / AliFMDv0.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 // Forward Multiplicity detector based on Silicon version 0        //
18 //
19 //Begin Html       
20 /*
21 <img src="gif/AliFMDv0Class.gif">
22 */
23 //End Html
24 //                                                                  //
25 //                                                                  //
26 //////////////////////////////////////////////////////////////////////
27
28 #include <TMath.h>
29 #include <TGeometry.h>
30 #include <TTUBE.h>
31 #include <TNode.h>
32 #include <TLorentzVector.h>
33 #include "AliFMDv0.h"
34 #include "AliRun.h"
35 #include "AliMC.h"
36 #include <iostream.h>
37 #include <fstream.h>
38 //#include <AliRandom.h>
39 #include "AliMagF.h"
40 #include "AliFMDhit.h"
41 #include <stdlib.h>
42
43 //class TGeant3;
44 ClassImp(AliFMDv0)
45
46 //--------------------------------------------------------------------
47 AliFMDv0::AliFMDv0(const char *name, const char *title):
48  AliFMD(name,title)
49 {
50   //
51   // Standart constructor for Forward Multiplicity Detector version 0
52   //
53   fIdSens1=0;
54 //  setBufferSize(128000);
55 }
56 //-------------------------------------------------------------------------
57 void AliFMDv0::CreateGeometry()
58 {
59  //
60   // Create the geometry of Forward Multiplicity Detector version 0
61   //
62   //Detector consists of 6 volumes: 
63   // 1st covered pseudorapidity interval from 3.3 to 2.0
64   // and placed on 65cm in Z-direction;
65   // 2nd - from 2.0 to 1.6 and Z=85 cm;
66   // 3d  - the same pseudorapidity interval as the 1st 
67   // but on the other side from the interaction point z=-65cm;
68   // 4th - simmetricaly with the 2nd : 
69   // pseudorapidity from 2.0 to 1.6, Z=-85cm   
70   // 5th - from 3.6 to 4.7, Z=-270cm
71   // 6th - from 4.5 to 5.5 , Z=-630cm.
72   // Each part has 400mkm Si (sensetive area, detector itself),
73   // 0.75cm of plastic simulated electronics material,
74   // Al support ring 2cm thickness and 1cm width placed on 
75   // the outer radius of each Si disk;
76   //    
77   // begin Html
78   /*
79    <img src="gif/AliFMDv0.gif">
80   */
81   //
82
83   Int_t *idtmed = fIdtmed->GetArray();
84    
85   Int_t ifmd;
86   Int_t idrotm[999];
87   Float_t zfmd,par[3];
88   char name[5];
89
90   Float_t rin[6], rout[6],zpos;
91   Float_t etain[6]= {3.3, 2.0, 3.3, 2.0, 4.7, 5.5};
92   Float_t etaout[6]={2.0, 1.6, 2.0, 1.6, 3.6, 4.5};
93   Float_t z[6]={64., 85., -64., -85., -270., -630};
94   Float_t zDet=0.04;
95   Float_t zElectronic=0.75;
96   Float_t zSupport=1.;
97   Float_t zFMD=3.;
98 //-------------------------------------------------------------------
99  //  FMD 
100  //------------------------------------------------------------------
101
102   AliMatrix(idrotm[901], 90, 0, 90, 90, 180, 0);
103
104   gMC->Gsvolu("GFSI","TUBE", idtmed[1], par, 0);
105   gMC->Gsvolu("GEL ","TUBE", idtmed[4], par, 0);
106   gMC->Gsvolu("GSUP","TUBE", idtmed[2], par, 0);
107
108   for (ifmd =0; ifmd < 6; ifmd++){
109
110     sprintf(name,"FMD%d",ifmd);
111     if(fDebug) 
112       printf("%s: %s",ClassName(),name);
113     
114     zfmd=TMath::Abs(z[ifmd]);
115     if(fDebug) printf("zfmd %f z[ifmd] %f",zfmd,z[ifmd]);
116     AliFMD::Eta2Radius(etain[ifmd],zfmd,&rin[ifmd]);
117     AliFMD::Eta2Radius(etaout[ifmd],zfmd,&rout[ifmd]);
118     
119     par[0]=rin[ifmd]; // pipe size
120     par[1]=rout[ifmd];
121     par[2]=zFMD/2;
122     gMC->Gsvolu(name,"TUBE", idtmed[3], par, 3);
123     
124     if(fDebug) printf ("rin %f rout %f ZFMD %f\n",par[0],par[1],z[ifmd]);
125     if (z[ifmd] < 0){  
126       gMC->Gspos(name,1,"ALIC",0,0,z[ifmd],0, "ONLY");}
127     else { 
128       gMC->Gspos(name,1,"ALIC",0,0,z[ifmd],idrotm[901], "ONLY");}
129   //Silicon detector
130     par[2]=zDet/2;
131     zpos=zFMD/2 -par[2];
132     gMC->Gsposp("GFSI",ifmd+1,name,0,0,zpos,0, "ONLY",par,3);
133
134     //Plastic slice for electronics
135     par[2]=zElectronic/2;
136     zpos=zpos-zDet/2-par[2];
137     gMC->Gsposp("GEL ",ifmd+1,name,0,0,zpos,0, "ONLY",par,3);
138
139    //Simple Al support
140    par[1]=rout[ifmd];
141    par[0]=rout[ifmd]-2;
142    par[2]=zSupport/2;
143    zpos=zpos-zElectronic/2-par[2];
144    gMC->Gsposp("GSUP",ifmd+1,name,0,0,zpos,0, "ONLY",par,3);
145    
146
147   }  
148   //Silicon
149
150   
151     
152
153 }    
154 //------------------------------------------------------------------------
155 void AliFMDv0::CreateMaterials()
156 {
157  Int_t isxfld   = gAlice->Field()->Integ();
158  Float_t sxmgmx = gAlice->Field()->Max();
159
160  // Plastic CH
161  Float_t aPlastic[2]={1.01,12.01};
162  Float_t zPlastic[2]={1,6};
163  Float_t wPlastic[2]={1,1};
164  Float_t denPlastic=1.03;
165    //
166  
167  //*** Definition Of avaible FMD materials ***
168  AliMaterial(0, "Si chip$", 28.0855,14.,2.33,9.36,999);
169  AliMaterial(1, "Al supprt$", 26.980,13.,2.70,8.9,999);
170  AliMaterial(2, "FMD Air$", 14.61, 7.3, .001205, 30423.,999); 
171  AliMixture( 5, "Plastic$",aPlastic,zPlastic,denPlastic,-2,wPlastic);
172  
173
174 //**
175  AliMedium(1, "Si chip$", 0, 1, isxfld, sxmgmx, 1., .001, 1., .001, .001);
176  AliMedium(2, "Al support$", 1, 0, isxfld, sxmgmx, 1., .001, 1., .001, .001);
177  AliMedium(3, "FMD air$", 2, 0, isxfld, sxmgmx, 1., .001, 1., .001, .001);
178  AliMedium(4, "Plastic$", 5, 0,isxfld, sxmgmx,  10., .01, 1., .003, .003);
179  
180
181
182 }
183 //---------------------------------------------------------------------
184 void AliFMDv0::DrawDetector()
185 {
186 //
187 // Draw a shaded view of the Forward multiplicity detector version 0
188 //
189
190 AliMC* pMC = AliMC::GetMC();
191
192 //Set ALIC mother transparent
193 pMC->Gsatt("ALIC","SEEN",0);
194 //
195 //Set volumes visible
196 gMC->Gsatt("FMD0","SEEN",1);
197 gMC->Gsatt("FMD1","SEEN",1);
198 gMC->Gsatt("FMD2","SEEN",1);
199 gMC->Gsatt("FMD3","SEEN",1);
200 gMC->Gsatt("FMD4","SEEN",1);
201 gMC->Gsatt("FMD5","SEEN",1);
202
203 //
204 gMC->Gdopt("hide","on");
205 gMC->Gdopt("shad","on");
206 gMC->SetClipBox(".");
207 gMC->SetClipBox("*",0,1000,-1000,1000,-1000,1000);
208 gMC->DefaultRange();
209 gMC->Gdraw("alic",40,30,0,12,9.5,.2,0.2);
210 gMC->Gdhead(1111,"Forward multiplicity detector");
211 gMC->Gdopt("hide","off");
212 }
213 //-------------------------------------------------------------------
214 void AliFMDv0::Init()
215 {
216 // Initialises version 0 of the Forward Multiplicity Detector
217 //
218 AliMC* gMC=AliMC::GetMC();
219 AliFMD::Init();
220 fIdSens1=gMC->VolId("GFSI");
221 if(fDebug) printf("%s: *** FMD version 0 initialized ***\n",ClassName());
222 }
223
224 //-------------------------------------------------------------------
225
226 void AliFMDv0::StepManager()
227 {
228   //
229   // Called for every step in the Forward Multiplicity Detector
230   //
231   Int_t id,copy;
232   static Float_t hits[9];
233   static Int_t vol[1];
234   static Float_t de;
235   TLorentzVector pos;
236   TLorentzVector mom;
237
238
239   TClonesArray &lhits = *fHits;
240   AliMC* gMC=AliMC::GetMC();
241   if(!gMC->IsTrackAlive()) return; // particle has disappeared
242
243   Float_t charge = gMC->TrackCharge();
244   if(TMath::Abs(charge)<=0.) return; //take only charged particles
245
246   //  ((TGeant3*)gMC)->Gpcxyz();
247
248   id=gMC->CurrentVolID(copy);
249   
250 // Check the sensetive volume
251    if(id==fIdSens1)
252      {
253        if(gMC->IsTrackEntering())
254          {
255            vol[0]=copy;
256            gMC->TrackPosition(pos);
257            hits[0]=pos[0];
258            hits[1]=pos[1];
259            hits[2]=pos[2];
260            
261            gMC->TrackMomentum(mom);
262            hits[3]=mom[0];
263            hits[4]=mom[1];
264            hits[5]=mom[2];
265
266            Int_t iPart= gMC->TrackPid();
267            Int_t partId=gMC->IdFromPDG(iPart);
268            hits[7]=partId;
269            hits[8]=1e9*gMC->TrackTime();
270            de=0.;
271          }
272        if(gMC->IsTrackInside()){
273            de=de+1000.*gMC->Edep();
274        }
275        
276        if(gMC->IsTrackExiting()
277           ||gMC->IsTrackDisappeared()||
278           gMC->IsTrackStop())
279          {
280              hits[6]=de+1000.*gMC->Edep();
281     new(lhits[fNhits++]) AliFMDhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
282          } // IsTrackExiting()
283      }
284  }
285