]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSsimulationFastPoints.cxx
Use global gRandom generator (M.Ivanov)
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationFastPoints.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 $Log$
18 Revision 1.7  2001/05/11 09:15:21  barbera
19 Corrected to make fast point creation working with PPR geometry
20
21 Revision 1.6  2000/10/29 18:30:14  barbera
22 Z resolution of pixel changed according with the default lenght of 425 microns
23
24 Revision 1.1.2.6  2000/10/29 18:29:51  barbera
25 Z resolution of pixel changed according with the default lenght of 425 microns
26
27 Revision 1.1.2.5  2000/10/02 16:03:20  barbera
28 Forward declarations added
29
30 Revision 1.4  2000/09/22 12:43:59  nilsen
31 Default track number set to -3 and not 0.
32
33 */
34 #include <TRandom.h>
35
36 #include "AliITS.h"
37 #include "AliITShit.h"
38 #include "AliITSRecPoint.h"
39 #include "AliITSmodule.h"
40 #include "AliITSgeom.h"
41 #include "AliRun.h"
42 #include "AliITSsimulationFastPoints.h"
43
44
45 ClassImp(AliITSsimulationFastPoints)
46
47 AliITSsimulationFastPoints::AliITSsimulationFastPoints()
48 {
49   //constructor
50   fSigmaRPhi[0] = fSigmaRPhi[1] = 12e-4;
51   fSigmaRPhi[2] = fSigmaRPhi[3] = 38e-4;
52   fSigmaRPhi[4] = fSigmaRPhi[5] = 20e-4;
53   fSigmaZ[0] = fSigmaZ[1] = 120e-4;        // resolution for 425 micron pixels
54   fSigmaZ[2] = fSigmaZ[3] = 28e-4;
55   fSigmaZ[4] = fSigmaZ[5] = 830e-4;
56   fSigmaDe[0] = fSigmaDe[1] = 0.72e-6;
57   fSigmaDe[2] = fSigmaDe[3] = 0.90e-6;
58   fSigmaDe[4] = fSigmaDe[5] =  5e-6;
59   fThrDe[0] = fThrDe[1] = 7.2e-6;
60   fThrDe[2] = fThrDe[3] = 2.70e-6;
61   fThrDe[4] = fThrDe[5] = 10e-6;
62 }
63
64 //-------------------------------------------------------------
65 void AliITSsimulationFastPoints::CreateFastRecPoints(AliITSmodule *mod, Int_t module, TRandom *random){
66   // Fast points simulator 
67
68    AliITS *aliITS  = (AliITS*)gAlice->GetModule("ITS");
69    AliITSgeom *gm = aliITS->GetITSgeom();
70
71    const Float_t kdEdXtoQ = 2.778e+8; 
72
73    Int_t ihit,flag,numofhits;
74    Float_t xg,yg,zg,xl,yl,zl;
75    Float_t px,py,pz;
76    //Double_t p, theta, pt, ps;
77    Float_t locals[3];
78    Float_t globals[3];
79    //Float_t xg1,yg1,zg1;
80    Double_t sigmarphi=0., sigmaz=0., sigmade=0., thrde=0.;
81    Float_t deltaXl,deltaZl,deltaDe;
82
83    Int_t hitlay, hitlad, hitdet, hitstatus, hittrack;
84    Float_t hitx, hity, hitz, hitpx, hitpy, hitpz, hitdestep;
85    
86
87    Int_t   hitstatus1, hittrack1;
88    Float_t hitx1, hity1, hitz1;
89    Float_t hitdestep1;
90
91    Float_t xMg,yMg,zMg;
92    //Float_t dx,dy,dz,ds;
93
94
95    numofhits = mod->GetNhits();
96    //printf("numofhits %d \n",numofhits);
97    flag = 1;
98    for(ihit=0;ihit<numofhits;ihit++){
99      AliITShit *hit=mod->GetHit(ihit);
100      hit->GetPositionG(hitx1,hity1,hitz1);
101      hitstatus1 = hit->GetTrackStatus();
102      hitdestep1 = hit->GetIonization();
103
104      hittrack1 = hit->GetTrack();
105
106      mod->MedianHit(module,hitx1,hity1,hitz1,hitstatus1,xMg,yMg,zMg,flag);
107      if (flag!=1) {
108        hitx      = xMg;
109        hity      = yMg;
110        hitz      = zMg;
111        hit->GetDetectorID(hitlay,hitlad,hitdet);
112        hit->GetMomentumG(hitpx,hitpy,hitpz);            
113        hitdestep = hit->GetIonization();
114        hitstatus = hitstatus1;
115        hittrack  = hit->GetTrack();
116
117        if (hitdestep > 0) {
118            xg = hitx;
119            yg = hity;
120            zg = hitz;
121            // Transform to the module local frame
122            globals[0] = hitx;
123            globals[1] = hity;
124            globals[2] = hitz;
125            gm->GtoL(hitlay,hitlad,hitdet,globals,locals);
126            xl = locals[0];
127            yl = locals[1];
128            zl = locals[2];
129            px = hitpx;
130            py = hitpy;
131            pz = hitpz;
132            /*
133            // Calculate transverse momentum and pseudorapidity
134            // to allow pt and eta dependence in sigma values
135            // of the spatial resolution
136            p  = TMath::Sqrt((px*px)+(py*py)+(pz*pz));
137            theta = TMath::ACos(pz/p);
138            pt = p * TMath::Sin(theta);
139            ps = -TMath::Log(TMath::Tan(theta/2));
140            */
141
142            // Retrieve sigma values for position and energy, and energy
143            // threshold 
144            
145            sigmarphi = SigmaRPhi(hitlay);
146            sigmaz = SigmaZ(hitlay);
147            sigmade = SigmaDe(hitlay);
148            thrde = ThrDe(hitlay);
149            // Randomize position and deposited energy
150            Int_t k=3*(Int_t)((hitlay-1)/2);
151
152            //      deltaXl = (float)(random[k].Gaus(0,sigmarphi));
153            //      deltaZl = (float)(random[k+1].Gaus(0,sigmaz));
154            //      deltaDe = (float)(random[k+2].Gaus(0,sigmade));
155            deltaXl = random->Gaus(0,sigmarphi);
156            deltaZl = random->Gaus(0,sigmaz);
157            deltaDe = random->Gaus(0,sigmade);
158            // Apply energy threshold and trasform back to global reference 
159            // system
160
161            if ( (hitdestep+deltaDe) > thrde ){
162                locals[0] = xl + deltaXl;
163                locals[1] = yl;
164                locals[2] = zl + deltaZl;
165                AliITSRecPoint rp;
166                rp.fTracks[0]=hittrack;
167                rp.fTracks[1]=-3;
168                rp.fTracks[2]=-3;
169                rp.SetX(locals[0]);
170                rp.SetZ(locals[2]);
171                rp.SetdEdX(hitdestep+deltaDe);
172                rp.SetQ(kdEdXtoQ*(hitdestep+deltaDe));  // number of e
173                rp.SetSigmaX2(sigmarphi*sigmarphi);
174                rp.SetSigmaZ2(sigmaz*sigmaz);
175                aliITS->AddRecPoint(rp);
176                /*
177                gm->LtoG(hitlay,hitlad,hitdet,locals,globals);
178                xg1 = globals[0];
179                yg1 = globals[1];
180                zg1 = globals[2];
181                dx = TMath::Abs(xg1-hitx);
182                dy = TMath::Abs(yg1-hity);
183                dz = TMath::Abs(zg1-hitz);
184                ds = TMath::Abs(deltaDe);
185                */
186            } // if ( (hitdestep+deltaDe)
187            else flag=1;
188        } // if (hitdestep > 0)
189        else flag=1;
190      } // if (flag!=1)
191    }   
192
193 }
194 //_______________________________________________________________________
195 void AliITSsimulationFastPoints::SetSigmaRPhi(Double_t  srphi[6])
196 {
197   // set sigmas in rphi
198
199     Int_t i;
200     for (i=0; i<6; i++) {
201         fSigmaRPhi[i]=srphi[i];
202     }
203 }
204 //_______________________________________________________________________
205 void AliITSsimulationFastPoints::SetSigmaZ(Double_t  sz[6])
206 {
207   // set sigmas in z
208
209     Int_t i;
210     for (i=0; i<6; i++) {
211         fSigmaZ[i]=sz[i];
212     }
213 }
214 //_______________________________________________________________________
215 void AliITSsimulationFastPoints::SetSigmaDe(Double_t  sde[6])
216 {
217   // set sigmas in energy
218
219     Int_t i;
220     for (i=0; i<6; i++) {
221         fSigmaDe[i]=sde[i];
222     }
223 }
224 //_______________________________________________________________________
225 void AliITSsimulationFastPoints::SetThrDe(Double_t  thrde[6])
226 {
227   // set energy thersholds
228
229     Int_t i;
230     for (i=0; i<6; i++) {
231         fThrDe[i]=thrde[i];
232     }
233 }
234