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