ROOT logo
/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                          *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/* $Id$ */
//////////////////////////////////////////////////////////
// implements fast simulation                           //
//                                                      //
//                                                      //
//////////////////////////////////////////////////////////


#include <TRandom.h>

#include "AliITS.h"
#include "AliITShit.h"
#include "AliITSRecPoint.h"
#include "AliITSmodule.h"
#include "AliITSgeom.h"
#include "AliRun.h"
#include "AliITSsimulationFastPoints.h"


ClassImp(AliITSsimulationFastPoints)

AliITSsimulationFastPoints::AliITSsimulationFastPoints()
{
  //constructor
  fSigmaRPhi[0] = fSigmaRPhi[1] = 12e-4;
  fSigmaRPhi[2] = fSigmaRPhi[3] = 38e-4;
  fSigmaRPhi[4] = fSigmaRPhi[5] = 20e-4;
  fSigmaZ[0] = fSigmaZ[1] = 120e-4;        // resolution for 425 micron pixels
  fSigmaZ[2] = fSigmaZ[3] = 28e-4;
  fSigmaZ[4] = fSigmaZ[5] = 830e-4;
  fSigmaDe[0] = fSigmaDe[1] = 0.72e-6;
  fSigmaDe[2] = fSigmaDe[3] = 0.90e-6;
  fSigmaDe[4] = fSigmaDe[5] =  5e-6;
  fThrDe[0] = fThrDe[1] = 7.2e-6;
  fThrDe[2] = fThrDe[3] = 2.70e-6;
  fThrDe[4] = fThrDe[5] = 10e-6;
}

//-------------------------------------------------------------
void AliITSsimulationFastPoints::CreateFastRecPoints(Int_t module, TClonesArray* recp){
    // Fast points simulator
    AliITS *aliITS  = (AliITS*)gAlice->GetModule("ITS");

    CreateFastRecPoints((AliITSmodule *)(aliITS->GetModule(module)),
			module,gRandom,recp);
}
//-------------------------------------------------------------
void AliITSsimulationFastPoints::CreateFastRecPoints(AliITSmodule *mod,
						     Int_t module,
						     TRandom *random,
						     TClonesArray* recp) {
  // Fast points simulator 

  TClonesArray &pt=*recp;
  AliITS *aliITS  = (AliITS*)gAlice->GetModule("ITS");
  AliITSgeom *gm = aliITS->GetITSgeom();
  const Float_t kdEdXtoQ = 1.0e+6;  // GeV->KeV

  Int_t lay,lad,det;
  gm->GetModuleId(module,lay,lad,det);
  Int_t ind=(lad-1)*gm->GetNdetectors(lay)+(det-1);
  Int_t lyr=(lay-1);


  Int_t ihit,flag,numofhits;
  Float_t locals[3];
  Float_t globals[3];
  Double_t sigmarphi=0., sigmaz=0., sigmade=0., thrde=0.;
  Float_t deltaXl,deltaZl,deltaDe;

  Int_t hitlay, hitlad, hitdet, hitstatus;
  Float_t hitpx, hitpy, hitpz, hitdestep;

  Int_t   hitstatus1, hittrack1;
  Float_t hitx1, hity1, hitz1;
  Float_t hitdestep1;
  Float_t xMg,yMg,zMg;
  Int_t irecp=0;
  numofhits = mod->GetNhits();
  //printf("numofhits %d \n",numofhits);
  for(ihit=0;ihit<numofhits;ihit++){
    AliITShit *hit=mod->GetHit(ihit);
    hit->GetPositionG(hitx1,hity1,hitz1);
    hitstatus1 = hit->GetTrackStatus();
    hitdestep1 = hit->GetIonization();
    hittrack1 = hit->GetTrack();
    
    mod->MedianHit(module,hitx1,hity1,hitz1,hitstatus1,xMg,yMg,zMg,flag);
    if (flag!=1) {
      hitdestep = hit->GetIonization();
      
      if (hitdestep > 0) {
	hit->GetDetectorID(hitlay,hitlad,hitdet);
	hit->GetMomentumG(hitpx,hitpy,hitpz);            
	hitstatus = hitstatus1;
		// Transform to the module local frame
	globals[0] = xMg; 
	globals[1] = yMg;
	globals[2] = zMg;
	gm->GtoL(hitlay,hitlad,hitdet,globals,locals);
	// Retrieve sigma values for position and energy, and energy
	// threshold
	sigmarphi = SigmaRPhi(hitlay);
	sigmaz = SigmaZ(hitlay);
	sigmade = SigmaDe(hitlay);
	thrde = ThrDe(hitlay);
	deltaXl = random->Gaus(0,sigmarphi);
	deltaZl = random->Gaus(0,sigmaz);
	deltaDe = random->Gaus(0,sigmade);
	
	// Apply energy threshold and trasform back to global reference
	// system
	
	if ( (hitdestep+deltaDe) > thrde ){
	  locals[0] += deltaXl;
	  locals[2] += deltaZl;
	  Int_t lab[4] = {hit->GetTrack(),-3,-3,ind};
	  Float_t q=kdEdXtoQ*(hitdestep+deltaDe);
	  if(hitlay<3) q=1.; // SPD binary readout
	  Float_t hitv[6] = {locals[0],locals[2],static_cast<Float_t>(sigmarphi*sigmarphi),static_cast<Float_t>(sigmaz*sigmaz),q,q};
	  Int_t info[3] = {0,0,lyr};
	  AliITSRecPoint rp(lab,hitv,info,kTRUE);

	  new (pt[irecp]) AliITSRecPoint(rp);
	  irecp++;
	} // end if ( (hitdestep+deltaDe)
      } // end if (hitdestep > 0)
    } // end if (flag!=1)
  } // end for ihit
}
//_______________________________________________________________________
void AliITSsimulationFastPoints::SetSigmaRPhi(Double_t  srphi[6])
{
  // set sigmas in rphi

    Int_t i;
    for (i=0; i<6; i++) {
	fSigmaRPhi[i]=srphi[i];
    }
}
//_______________________________________________________________________
void AliITSsimulationFastPoints::SetSigmaZ(Double_t  sz[6])
{
  // set sigmas in z

    Int_t i;
    for (i=0; i<6; i++) {
	fSigmaZ[i]=sz[i];
    }
}
//_______________________________________________________________________
void AliITSsimulationFastPoints::SetSigmaDe(Double_t  sde[6])
{
  // set sigmas in energy

    Int_t i;
    for (i=0; i<6; i++) {
	fSigmaDe[i]=sde[i];
    }
}
//_______________________________________________________________________
void AliITSsimulationFastPoints::SetThrDe(Double_t  thrde[6])
{
  // set energy thersholds

    Int_t i;
    for (i=0; i<6; i++) {
	fThrDe[i]=thrde[i];
    }
}

 AliITSsimulationFastPoints.cxx:1
 AliITSsimulationFastPoints.cxx:2
 AliITSsimulationFastPoints.cxx:3
 AliITSsimulationFastPoints.cxx:4
 AliITSsimulationFastPoints.cxx:5
 AliITSsimulationFastPoints.cxx:6
 AliITSsimulationFastPoints.cxx:7
 AliITSsimulationFastPoints.cxx:8
 AliITSsimulationFastPoints.cxx:9
 AliITSsimulationFastPoints.cxx:10
 AliITSsimulationFastPoints.cxx:11
 AliITSsimulationFastPoints.cxx:12
 AliITSsimulationFastPoints.cxx:13
 AliITSsimulationFastPoints.cxx:14
 AliITSsimulationFastPoints.cxx:15
 AliITSsimulationFastPoints.cxx:16
 AliITSsimulationFastPoints.cxx:17
 AliITSsimulationFastPoints.cxx:18
 AliITSsimulationFastPoints.cxx:19
 AliITSsimulationFastPoints.cxx:20
 AliITSsimulationFastPoints.cxx:21
 AliITSsimulationFastPoints.cxx:22
 AliITSsimulationFastPoints.cxx:23
 AliITSsimulationFastPoints.cxx:24
 AliITSsimulationFastPoints.cxx:25
 AliITSsimulationFastPoints.cxx:26
 AliITSsimulationFastPoints.cxx:27
 AliITSsimulationFastPoints.cxx:28
 AliITSsimulationFastPoints.cxx:29
 AliITSsimulationFastPoints.cxx:30
 AliITSsimulationFastPoints.cxx:31
 AliITSsimulationFastPoints.cxx:32
 AliITSsimulationFastPoints.cxx:33
 AliITSsimulationFastPoints.cxx:34
 AliITSsimulationFastPoints.cxx:35
 AliITSsimulationFastPoints.cxx:36
 AliITSsimulationFastPoints.cxx:37
 AliITSsimulationFastPoints.cxx:38
 AliITSsimulationFastPoints.cxx:39
 AliITSsimulationFastPoints.cxx:40
 AliITSsimulationFastPoints.cxx:41
 AliITSsimulationFastPoints.cxx:42
 AliITSsimulationFastPoints.cxx:43
 AliITSsimulationFastPoints.cxx:44
 AliITSsimulationFastPoints.cxx:45
 AliITSsimulationFastPoints.cxx:46
 AliITSsimulationFastPoints.cxx:47
 AliITSsimulationFastPoints.cxx:48
 AliITSsimulationFastPoints.cxx:49
 AliITSsimulationFastPoints.cxx:50
 AliITSsimulationFastPoints.cxx:51
 AliITSsimulationFastPoints.cxx:52
 AliITSsimulationFastPoints.cxx:53
 AliITSsimulationFastPoints.cxx:54
 AliITSsimulationFastPoints.cxx:55
 AliITSsimulationFastPoints.cxx:56
 AliITSsimulationFastPoints.cxx:57
 AliITSsimulationFastPoints.cxx:58
 AliITSsimulationFastPoints.cxx:59
 AliITSsimulationFastPoints.cxx:60
 AliITSsimulationFastPoints.cxx:61
 AliITSsimulationFastPoints.cxx:62
 AliITSsimulationFastPoints.cxx:63
 AliITSsimulationFastPoints.cxx:64
 AliITSsimulationFastPoints.cxx:65
 AliITSsimulationFastPoints.cxx:66
 AliITSsimulationFastPoints.cxx:67
 AliITSsimulationFastPoints.cxx:68
 AliITSsimulationFastPoints.cxx:69
 AliITSsimulationFastPoints.cxx:70
 AliITSsimulationFastPoints.cxx:71
 AliITSsimulationFastPoints.cxx:72
 AliITSsimulationFastPoints.cxx:73
 AliITSsimulationFastPoints.cxx:74
 AliITSsimulationFastPoints.cxx:75
 AliITSsimulationFastPoints.cxx:76
 AliITSsimulationFastPoints.cxx:77
 AliITSsimulationFastPoints.cxx:78
 AliITSsimulationFastPoints.cxx:79
 AliITSsimulationFastPoints.cxx:80
 AliITSsimulationFastPoints.cxx:81
 AliITSsimulationFastPoints.cxx:82
 AliITSsimulationFastPoints.cxx:83
 AliITSsimulationFastPoints.cxx:84
 AliITSsimulationFastPoints.cxx:85
 AliITSsimulationFastPoints.cxx:86
 AliITSsimulationFastPoints.cxx:87
 AliITSsimulationFastPoints.cxx:88
 AliITSsimulationFastPoints.cxx:89
 AliITSsimulationFastPoints.cxx:90
 AliITSsimulationFastPoints.cxx:91
 AliITSsimulationFastPoints.cxx:92
 AliITSsimulationFastPoints.cxx:93
 AliITSsimulationFastPoints.cxx:94
 AliITSsimulationFastPoints.cxx:95
 AliITSsimulationFastPoints.cxx:96
 AliITSsimulationFastPoints.cxx:97
 AliITSsimulationFastPoints.cxx:98
 AliITSsimulationFastPoints.cxx:99
 AliITSsimulationFastPoints.cxx:100
 AliITSsimulationFastPoints.cxx:101
 AliITSsimulationFastPoints.cxx:102
 AliITSsimulationFastPoints.cxx:103
 AliITSsimulationFastPoints.cxx:104
 AliITSsimulationFastPoints.cxx:105
 AliITSsimulationFastPoints.cxx:106
 AliITSsimulationFastPoints.cxx:107
 AliITSsimulationFastPoints.cxx:108
 AliITSsimulationFastPoints.cxx:109
 AliITSsimulationFastPoints.cxx:110
 AliITSsimulationFastPoints.cxx:111
 AliITSsimulationFastPoints.cxx:112
 AliITSsimulationFastPoints.cxx:113
 AliITSsimulationFastPoints.cxx:114
 AliITSsimulationFastPoints.cxx:115
 AliITSsimulationFastPoints.cxx:116
 AliITSsimulationFastPoints.cxx:117
 AliITSsimulationFastPoints.cxx:118
 AliITSsimulationFastPoints.cxx:119
 AliITSsimulationFastPoints.cxx:120
 AliITSsimulationFastPoints.cxx:121
 AliITSsimulationFastPoints.cxx:122
 AliITSsimulationFastPoints.cxx:123
 AliITSsimulationFastPoints.cxx:124
 AliITSsimulationFastPoints.cxx:125
 AliITSsimulationFastPoints.cxx:126
 AliITSsimulationFastPoints.cxx:127
 AliITSsimulationFastPoints.cxx:128
 AliITSsimulationFastPoints.cxx:129
 AliITSsimulationFastPoints.cxx:130
 AliITSsimulationFastPoints.cxx:131
 AliITSsimulationFastPoints.cxx:132
 AliITSsimulationFastPoints.cxx:133
 AliITSsimulationFastPoints.cxx:134
 AliITSsimulationFastPoints.cxx:135
 AliITSsimulationFastPoints.cxx:136
 AliITSsimulationFastPoints.cxx:137
 AliITSsimulationFastPoints.cxx:138
 AliITSsimulationFastPoints.cxx:139
 AliITSsimulationFastPoints.cxx:140
 AliITSsimulationFastPoints.cxx:141
 AliITSsimulationFastPoints.cxx:142
 AliITSsimulationFastPoints.cxx:143
 AliITSsimulationFastPoints.cxx:144
 AliITSsimulationFastPoints.cxx:145
 AliITSsimulationFastPoints.cxx:146
 AliITSsimulationFastPoints.cxx:147
 AliITSsimulationFastPoints.cxx:148
 AliITSsimulationFastPoints.cxx:149
 AliITSsimulationFastPoints.cxx:150
 AliITSsimulationFastPoints.cxx:151
 AliITSsimulationFastPoints.cxx:152
 AliITSsimulationFastPoints.cxx:153
 AliITSsimulationFastPoints.cxx:154
 AliITSsimulationFastPoints.cxx:155
 AliITSsimulationFastPoints.cxx:156
 AliITSsimulationFastPoints.cxx:157
 AliITSsimulationFastPoints.cxx:158
 AliITSsimulationFastPoints.cxx:159
 AliITSsimulationFastPoints.cxx:160
 AliITSsimulationFastPoints.cxx:161
 AliITSsimulationFastPoints.cxx:162
 AliITSsimulationFastPoints.cxx:163
 AliITSsimulationFastPoints.cxx:164
 AliITSsimulationFastPoints.cxx:165
 AliITSsimulationFastPoints.cxx:166
 AliITSsimulationFastPoints.cxx:167
 AliITSsimulationFastPoints.cxx:168
 AliITSsimulationFastPoints.cxx:169
 AliITSsimulationFastPoints.cxx:170
 AliITSsimulationFastPoints.cxx:171
 AliITSsimulationFastPoints.cxx:172
 AliITSsimulationFastPoints.cxx:173
 AliITSsimulationFastPoints.cxx:174
 AliITSsimulationFastPoints.cxx:175
 AliITSsimulationFastPoints.cxx:176
 AliITSsimulationFastPoints.cxx:177
 AliITSsimulationFastPoints.cxx:178
 AliITSsimulationFastPoints.cxx:179
 AliITSsimulationFastPoints.cxx:180
 AliITSsimulationFastPoints.cxx:181
 AliITSsimulationFastPoints.cxx:182
 AliITSsimulationFastPoints.cxx:183
 AliITSsimulationFastPoints.cxx:184
 AliITSsimulationFastPoints.cxx:185
 AliITSsimulationFastPoints.cxx:186