Last minute changes and new code for event mixing and reconstruction (A.Maevskaia)
[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 "/afs/cern.ch/alice/offline/new/RALICE/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     printf(name);
112     
113     zfmd=TMath::Abs(z[ifmd]);
114     printf("zfmd %f z[ifmd] %f",zfmd,z[ifmd]);
115     AliFMD::Eta2Radius(etain[ifmd],zfmd,&rin[ifmd]);
116     AliFMD::Eta2Radius(etaout[ifmd],zfmd,&rout[ifmd]);
117     
118     par[0]=rin[ifmd]; // pipe size
119     par[1]=rout[ifmd];
120     par[2]=zFMD/2;
121     gMC->Gsvolu(name,"TUBE", idtmed[3], par, 3);
122     
123     printf ("rin %f rout %f ZFMD %f\n",par[0],par[1],z[ifmd]);
124     if (z[ifmd] < 0){  
125       gMC->Gspos(name,1,"ALIC",0,0,z[ifmd],0, "ONLY");}
126     else { 
127       gMC->Gspos(name,1,"ALIC",0,0,z[ifmd],idrotm[901], "ONLY");}
128   //Silicon detector
129     par[2]=zDet/2;
130     zpos=zFMD/2 -par[2];
131     gMC->Gsposp("GFSI",ifmd+1,name,0,0,zpos,0, "ONLY",par,3);
132
133     //Plastic slice for electronics
134     par[2]=zElectronic/2;
135     zpos=zpos-zDet/2-par[2];
136     gMC->Gsposp("GEL ",ifmd+1,name,0,0,zpos,0, "ONLY",par,3);
137
138    //Simple Al support
139    par[1]=rout[ifmd];
140    par[0]=rout[ifmd]-2;
141    par[2]=zSupport/2;
142    zpos=zpos-zElectronic/2-par[2];
143    gMC->Gsposp("GSUP",ifmd+1,name,0,0,zpos,0, "ONLY",par,3);
144    
145
146   }  
147   //Silicon
148
149   
150     
151
152 }    
153 //------------------------------------------------------------------------
154 void AliFMDv0::CreateMaterials()
155 {
156  Int_t isxfld   = gAlice->Field()->Integ();
157  Float_t sxmgmx = gAlice->Field()->Max();
158
159  // Plastic CH
160  Float_t aPlastic[2]={1.01,12.01};
161  Float_t zPlastic[2]={1,6};
162  Float_t wPlastic[2]={1,1};
163  Float_t denPlastic=1.03;
164    //
165  
166  //*** Definition Of avaible FMD materials ***
167  AliMaterial(0, "Si chip$", 28.0855,14.,2.33,9.36,999);
168  AliMaterial(1, "Al supprt$", 26.980,13.,2.70,8.9,999);
169  AliMaterial(2, "FMD Air$", 14.61, 7.3, .001205, 30423.,999); 
170  AliMixture( 5, "Plastic$",aPlastic,zPlastic,denPlastic,-2,wPlastic);
171  
172
173 //**
174  AliMedium(1, "Si chip$", 0, 1, isxfld, sxmgmx, 1., .001, 1., .001, .001);
175  AliMedium(2, "Al support$", 1, 0, isxfld, sxmgmx, 1., .001, 1., .001, .001);
176  AliMedium(3, "FMD air$", 2, 0, isxfld, sxmgmx, 1., .001, 1., .001, .001);
177  AliMedium(4, "Plastic$", 5, 0,isxfld, sxmgmx,  10., .01, 1., .003, .003);
178  
179
180
181 }
182 //---------------------------------------------------------------------
183 void AliFMDv0::DrawDetector()
184 {
185 //
186 // Draw a shaded view of the Forward multiplicity detector version 0
187 //
188
189 AliMC* pMC = AliMC::GetMC();
190
191 //Set ALIC mother transparent
192 pMC->Gsatt("ALIC","SEEN",0);
193 //
194 //Set volumes visible
195 gMC->Gsatt("FMD0","SEEN",1);
196 gMC->Gsatt("FMD1","SEEN",1);
197 gMC->Gsatt("FMD2","SEEN",1);
198 gMC->Gsatt("FMD3","SEEN",1);
199 gMC->Gsatt("FMD4","SEEN",1);
200 gMC->Gsatt("FMD5","SEEN",1);
201
202 //
203 gMC->Gdopt("hide","on");
204 gMC->Gdopt("shad","on");
205 gMC->SetClipBox(".");
206 gMC->SetClipBox("*",0,1000,-1000,1000,-1000,1000);
207 gMC->DefaultRange();
208 gMC->Gdraw("alic",40,30,0,12,9.5,.2,0.2);
209 gMC->Gdhead(1111,"Forward multiplicity detector");
210 gMC->Gdopt("hide","off");
211 }
212 //-------------------------------------------------------------------
213 void AliFMDv0::Init()
214 {
215 // Initialises version 0 of the Forward Multiplicity Detector
216 //
217 AliMC* gMC=AliMC::GetMC();
218 AliFMD::Init();
219 fIdSens1=gMC->VolId("GFSI");
220 printf("*** FMD version 0 initialized ***\n");
221 }
222
223 //-------------------------------------------------------------------
224
225 void AliFMDv0::StepManager()
226 {
227   //
228   // Called for every step in the Forward Multiplicity Detector
229   //
230   Int_t id,copy;
231   static Float_t hits[9];
232   static Int_t vol[1];
233   static Float_t de;
234   TLorentzVector pos;
235   TLorentzVector mom;
236
237
238   TClonesArray &lhits = *fHits;
239   AliMC* gMC=AliMC::GetMC();
240   if(!gMC->IsTrackAlive()) return; // particle has disappeared
241
242   Float_t charge = gMC->TrackCharge();
243   if(TMath::Abs(charge)<=0.) return; //take only charged particles
244
245   //  ((TGeant3*)gMC)->Gpcxyz();
246
247   id=gMC->CurrentVolID(copy);
248   
249 // Check the sensetive volume
250    if(id==fIdSens1)
251      {
252        if(gMC->IsTrackEntering())
253          {
254            vol[0]=copy;
255            gMC->TrackPosition(pos);
256            hits[0]=pos[0];
257            hits[1]=pos[1];
258            hits[2]=pos[2];
259            
260            gMC->TrackMomentum(mom);
261            hits[3]=mom[0];
262            hits[4]=mom[1];
263            hits[5]=mom[2];
264
265            Int_t iPart= gMC->TrackPid();
266            Int_t partId=gMC->IdFromPDG(iPart);
267            hits[7]=partId;
268            hits[8]=1e9*gMC->TrackTime();
269            de=0.;
270          }
271        if(gMC->IsTrackInside()){
272            de=de+1000.*gMC->Edep();
273        }
274        
275        if(gMC->IsTrackExiting()
276           ||gMC->IsTrackDisappeared()||
277           gMC->IsTrackStop())
278          {
279              hits[6]=de+1000.*gMC->Edep();
280     new(lhits[fNhits++]) AliFMDhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
281          } // IsTrackExiting()
282      }
283  }
284