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