Including cmath
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationFastPoints.cxx
CommitLineData
b0f5e3fc 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
88cb7938 16/* $Id$ */
7d62fb64 17//////////////////////////////////////////////////////////
18// implements fast simulation //
19// //
20// //
21//////////////////////////////////////////////////////////
22
b9d0a01d 23
e8189707 24#include <TRandom.h>
b0f5e3fc 25
b0f5e3fc 26#include "AliITS.h"
517784f0 27#include "AliITShit.h"
28#include "AliITSRecPoint.h"
29#include "AliITSmodule.h"
30#include "AliITSgeom.h"
e8189707 31#include "AliRun.h"
b0f5e3fc 32#include "AliITSsimulationFastPoints.h"
e8189707 33
b0f5e3fc 34
35ClassImp(AliITSsimulationFastPoints)
36
37AliITSsimulationFastPoints::AliITSsimulationFastPoints()
38{
39 //constructor
e8189707 40 fSigmaRPhi[0] = fSigmaRPhi[1] = 12e-4;
41 fSigmaRPhi[2] = fSigmaRPhi[3] = 38e-4;
42 fSigmaRPhi[4] = fSigmaRPhi[5] = 20e-4;
21d3c626 43 fSigmaZ[0] = fSigmaZ[1] = 120e-4; // resolution for 425 micron pixels
e8189707 44 fSigmaZ[2] = fSigmaZ[3] = 28e-4;
45 fSigmaZ[4] = fSigmaZ[5] = 830e-4;
46 fSigmaDe[0] = fSigmaDe[1] = 0.72e-6;
47 fSigmaDe[2] = fSigmaDe[3] = 0.90e-6;
48 fSigmaDe[4] = fSigmaDe[5] = 5e-6;
49 fThrDe[0] = fThrDe[1] = 7.2e-6;
50 fThrDe[2] = fThrDe[3] = 2.70e-6;
51 fThrDe[4] = fThrDe[5] = 10e-6;
b0f5e3fc 52}
53
e8189707 54//-------------------------------------------------------------
7d62fb64 55void AliITSsimulationFastPoints::CreateFastRecPoints(Int_t module, TClonesArray* recp){
785086f0 56 // Fast points simulator
57 AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
b0f5e3fc 58
785086f0 59 CreateFastRecPoints((AliITSmodule *)(aliITS->GetModule(module)),
7d62fb64 60 module,gRandom,recp);
785086f0 61}
62//-------------------------------------------------------------
63void AliITSsimulationFastPoints::CreateFastRecPoints(AliITSmodule *mod,
64 Int_t module,
7d62fb64 65 TRandom *random,
66 TClonesArray* recp) {
67 // Fast points simulator
68
69 TClonesArray &pt=*recp;
70 AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
71 AliITSgeom *gm = aliITS->GetITSgeom();
72 const Float_t kdEdXtoQ = 2.778e+8;
73
00a7cc50 74 Int_t lay,lad,det;
75 gm->GetModuleId(module,lay,lad,det);
76 Int_t ind=(lad-1)*gm->GetNdetectors(lay)+(det-1);
77 Int_t lyr=(lay-1);
78
79
7d62fb64 80 Int_t ihit,flag,numofhits;
81 Float_t locals[3];
82 Float_t globals[3];
83 Double_t sigmarphi=0., sigmaz=0., sigmade=0., thrde=0.;
84 Float_t deltaXl,deltaZl,deltaDe;
85
86 Int_t hitlay, hitlad, hitdet, hitstatus;
87 Float_t hitpx, hitpy, hitpz, hitdestep;
88
89 Int_t hitstatus1, hittrack1;
90 Float_t hitx1, hity1, hitz1;
91 Float_t hitdestep1;
92 Float_t xMg,yMg,zMg;
93 Int_t irecp=0;
94 numofhits = mod->GetNhits();
95 //printf("numofhits %d \n",numofhits);
96 for(ihit=0;ihit<numofhits;ihit++){
97 AliITShit *hit=mod->GetHit(ihit);
98 hit->GetPositionG(hitx1,hity1,hitz1);
99 hitstatus1 = hit->GetTrackStatus();
100 hitdestep1 = hit->GetIonization();
101 hittrack1 = hit->GetTrack();
102
103 mod->MedianHit(module,hitx1,hity1,hitz1,hitstatus1,xMg,yMg,zMg,flag);
104 if (flag!=1) {
105 hitdestep = hit->GetIonization();
106
107 if (hitdestep > 0) {
108 hit->GetDetectorID(hitlay,hitlad,hitdet);
109 hit->GetMomentumG(hitpx,hitpy,hitpz);
110 hitstatus = hitstatus1;
785086f0 111 // Transform to the module local frame
7d62fb64 112 globals[0] = xMg;
113 globals[1] = yMg;
114 globals[2] = zMg;
115 gm->GtoL(hitlay,hitlad,hitdet,globals,locals);
116 // Retrieve sigma values for position and energy, and energy
117 // threshold
118 sigmarphi = SigmaRPhi(hitlay);
119 sigmaz = SigmaZ(hitlay);
120 sigmade = SigmaDe(hitlay);
121 thrde = ThrDe(hitlay);
122 deltaXl = random->Gaus(0,sigmarphi);
123 deltaZl = random->Gaus(0,sigmaz);
124 deltaDe = random->Gaus(0,sigmade);
125
126 // Apply energy threshold and trasform back to global reference
127 // system
128
129 if ( (hitdestep+deltaDe) > thrde ){
130 locals[0] += deltaXl;
131 locals[2] += deltaZl;
00a7cc50 132 AliITSRecPoint rp(gm);
133 rp.SetLabel(hit->GetTrack(),0);
7d62fb64 134 // rp.fTracks[0]=mod->GetHitTrackIndex(ihit);
00a7cc50 135 rp.SetLabel(-3,1);
136 rp.SetLabel(-3,2);
137 rp.SetXZ(module,locals[0],locals[2]);
7d62fb64 138 rp.SetdEdX(hitdestep+deltaDe);
139 rp.SetQ(kdEdXtoQ*(hitdestep+deltaDe)); // number of e
00a7cc50 140 rp.SetSigmaDetLocX2(sigmarphi*sigmarphi);
7d62fb64 141 rp.SetSigmaZ2(sigmaz*sigmaz);
00a7cc50 142 rp.SetDetectorIndex(ind);
143 rp.SetLayer(lyr);
7d62fb64 144 new (pt[irecp]) AliITSRecPoint(rp);
145 irecp++;
146 } // end if ( (hitdestep+deltaDe)
147 } // end if (hitdestep > 0)
148 } // end if (flag!=1)
149 } // end for ihit
b0f5e3fc 150}
e8189707 151//_______________________________________________________________________
152void AliITSsimulationFastPoints::SetSigmaRPhi(Double_t srphi[6])
153{
154 // set sigmas in rphi
b0f5e3fc 155
e8189707 156 Int_t i;
157 for (i=0; i<6; i++) {
158 fSigmaRPhi[i]=srphi[i];
159 }
b0f5e3fc 160}
161//_______________________________________________________________________
e8189707 162void AliITSsimulationFastPoints::SetSigmaZ(Double_t sz[6])
163{
164 // set sigmas in z
165
166 Int_t i;
167 for (i=0; i<6; i++) {
168 fSigmaZ[i]=sz[i];
169 }
b0f5e3fc 170}
171//_______________________________________________________________________
e8189707 172void AliITSsimulationFastPoints::SetSigmaDe(Double_t sde[6])
173{
174 // set sigmas in energy
175
176 Int_t i;
177 for (i=0; i<6; i++) {
178 fSigmaDe[i]=sde[i];
179 }
b0f5e3fc 180}
181//_______________________________________________________________________
e8189707 182void AliITSsimulationFastPoints::SetThrDe(Double_t thrde[6])
183{
184 // set energy thersholds
185
186 Int_t i;
187 for (i=0; i<6; i++) {
188 fThrDe[i]=thrde[i];
189 }
b0f5e3fc 190}
e8189707 191