for Jens and Martin
[u/mrichter/AliRoot.git] / TPC / Upgrade / ToyMCEventGeneratorSimple.cxx
CommitLineData
526ddf0e 1#include <iostream>
2#include "ToyMCEventGeneratorSimple.h"
3#include <TDatabasePDG.h>
4#include <TRandom.h>
5#include <TF1.h>
6#include "ToyMCEvent.h"
7
8ClassImp(ToyMCEventGeneratorSimple);
9
10
11ToyMCEventGeneratorSimple::ToyMCEventGeneratorSimple()
12 :ToyMCEventGenerator()
13 ,fVertexMean(0.)
14 ,fVertexSigma(7.)
15{
16 //
17
18}
19//________________________________________________________________
20ToyMCEventGeneratorSimple::ToyMCEventGeneratorSimple(const ToyMCEventGeneratorSimple &gen)
21 :ToyMCEventGenerator(gen)
22 ,fVertexMean(gen.fVertexMean)
23 ,fVertexSigma(gen.fVertexSigma)
24{
25}
26//________________________________________________________________
27ToyMCEventGeneratorSimple::~ToyMCEventGeneratorSimple()
28{
29}
30 //________________________________________________________________
31ToyMCEventGeneratorSimple& ToyMCEventGeneratorSimple::operator = (const ToyMCEventGeneratorSimple &gen)
32{
33 //assignment operator
34 if (&gen == this) return *this;
35 new (this) ToyMCEventGeneratorSimple(gen);
36
37 return *this;
38}
39//________________________________________________________________
40void ToyMCEventGeneratorSimple::SetParameters(Double_t vertexMean, Double_t vertexSigma) {
41 fVertexMean = vertexMean;
42 fVertexSigma = vertexSigma;
43}
44//________________________________________________________________
45ToyMCEvent* ToyMCEventGeneratorSimple::Generate(Double_t time) {
46
47 ToyMCEvent *retEvent = new ToyMCEvent();
48 retEvent->SetT0(time);
49 retEvent->SetX(0);
50 retEvent->SetX(0);
51 retEvent->SetZ(gRandom->Gaus(fVertexMean,fVertexSigma));
52
53 Double_t etaCuts=.9;
54 Double_t mass = TDatabasePDG::Instance()->GetParticle("pi+")->Mass();
55 TF1 fpt("fpt",Form("x*(1+(sqrt(x*x+%f^2)-%f)/([0]*[1]))^(-[0])",mass,mass),0.4,10);
56 fpt.SetParameters(7.24,0.120);
57 fpt.SetNpx(10000);
58 Int_t nTracks = 400; //TODO: draw from experim dist
59
60 for(Int_t iTrack=0; iTrack<nTracks; iTrack++){
61 Double_t phi = gRandom->Uniform(0.0, 2*TMath::Pi());
62 Double_t eta = gRandom->Uniform(-etaCuts, etaCuts);
63 Double_t pt = fpt.GetRandom(); // momentum for f1
64 Short_t sign=1;
65 if(gRandom->Rndm() < 0.5){
66 sign =1;
67 }else{
68 sign=-1;
69 }
70
71 Double_t theta = 2*TMath::ATan(TMath::Exp(-eta))-TMath::Pi()/2.;
72 Double_t pxyz[3];
73 pxyz[0]=pt*TMath::Cos(phi);
74 pxyz[1]=pt*TMath::Sin(phi);
75 pxyz[2]=pt*TMath::Tan(theta);
76 Double_t vertex[3]={0,0,retEvent->GetZ()};
77 Double_t cv[21]={0};
78 ToyMCTrack *tempTrack = new ToyMCTrack(vertex,pxyz,cv,sign);
79
80 Bool_t trackDist = DistortTrack(*tempTrack, time);
81 if(trackDist) retEvent->AddTrack(*tempTrack);
82 delete tempTrack;
83 }
84
85 return retEvent;
86}
87
88