]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx
simplified
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowEventSimpleMakerOnTheFly.cxx
CommitLineData
93ff27bd 1/*************************************************************************
2* Copyright(c) 1998-2008, 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
93417736 16/************************************
17 * Create an event and perform full *
18 * flow analysis 'on the fly'. *
19 * *
20 * author: Ante Bilandzic *
21 * (abilandzic@gmail.com) *
22 ************************************/
93ff27bd 23
24#include "Riostream.h"
25#include "TMath.h"
26#include "TF1.h"
27#include "TRandom3.h"
93ff27bd 28#include "AliFlowEventSimpleMakerOnTheFly.h"
29#include "AliFlowEventSimple.h"
30#include "AliFlowTrackSimple.h"
31
32ClassImp(AliFlowEventSimpleMakerOnTheFly)
33
93417736 34//========================================================================================================================================
35
36AliFlowEventSimpleMakerOnTheFly::AliFlowEventSimpleMakerOnTheFly(UInt_t uiSeed):
37fCount(0),
38fMinMult(0),
39fMaxMult(0),
40fPtSpectra(NULL),
41fMass(0.13957),
42fTemperature(0.44),
43fPhiDistribution(NULL),
44fV1(0.),
45fV2(0.05),
46fV3(0.),
47fV4(0.),
48fUniformFluctuationsV2(kFALSE),
49fMinV2(0.04),
50fMaxV2(0.06),
51fPtDependentV2(kFALSE),
52fV2vsPtCutOff(2.0),
53fV2vsPtMax(0.2),
54fEtaMinA(-0.8),
55fEtaMaxA(-0.5),
56fEtaMinB(0.5),
57fEtaMaxB(0.8),
58fNTimes(1),
59fUniformAcceptance(kTRUE),
60fPhiMin1(0.),
61fPhiMax1(0.),
62fProbability1(0.),
63fPhiMin2(0.),
64fPhiMax2(0.),
65fProbability2(0.),
66fPi(TMath::Pi())
678f8252 67{
93417736 68 // Constructor.
69
70 // Determine seed for gRandom:
71 delete gRandom;
72 gRandom = new TRandom3(uiSeed); // if uiSeed is 0, the seed is determined uniquely in space and time via TUUID
73
74} // end of AliFlowEventSimpleMakerOnTheFly::AliFlowEventSimpleMakerOnTheFly(UInt_t uiSeed):
93ff27bd 75
93417736 76//====================================================================================================================
93ff27bd 77
78AliFlowEventSimpleMakerOnTheFly::~AliFlowEventSimpleMakerOnTheFly()
79{
93417736 80 // Destructor.
93ff27bd 81
93417736 82 if(fPtSpectra){delete fPtSpectra;}
83 if(fPhiDistribution){delete fPhiDistribution;}
93ff27bd 84
93417736 85} // end of AliFlowEventSimpleMakerOnTheFly::~AliFlowEventSimpleMakerOnTheFly()
93ff27bd 86
93417736 87//====================================================================================================================
93ff27bd 88
4d603348 89void AliFlowEventSimpleMakerOnTheFly::Init()
90{
93417736 91 // Book all objects in this method.
92
93 // a) Define the pt spectra;
94 // b) Define the phi distribution.
95
96 // a) Define the pt spectra:
97 Double_t dPtMin = 0.;
98 Double_t dPtMax = 10.;
99 fPtSpectra = new TF1("fPtSpectra","x*TMath::Exp(-pow([0]*[0]+x*x,0.5)/[1])",dPtMin,dPtMax); // hardwired is Boltzmann distribution
100 fPtSpectra->SetParName(0,"Mass");
101 fPtSpectra->SetParameter(0,fMass);
102 fPtSpectra->SetParName(1,"Temperature");
103 fPtSpectra->SetParameter(1,fTemperature);
104 fPtSpectra->SetTitle("Boltzmann Distribution: f(p_{t}) = p_{t}exp[-(m^{2}+p_{t}^{2})^{1/2}/T];p_{t};f(p_{t})");
105
106 // b) Define the phi distribution:
107 Double_t dPhiMin = 0.;
108 Double_t dPhiMax = TMath::TwoPi();
109 fPhiDistribution = new TF1("fPhiDistribution","1+2.*[1]*TMath::Cos(x-[0])+2.*[2]*TMath::Cos(2.*(x-[0]))+2.*[3]*TMath::Cos(3.*(x-[0]))+2.*[4]*TMath::Cos(4.*(x-[0]))",dPhiMin,dPhiMax);
110 fPhiDistribution->SetParName(0,"Reaction Plane");
111 fPhiDistribution->SetParameter(0,0.);
112 fPhiDistribution->SetParName(1,"Directed Flow (v1)");
113 fPhiDistribution->SetParameter(1,fV1);
114 fPhiDistribution->SetParName(2,"Elliptic Flow (v2)");
115 fPhiDistribution->SetParameter(2,fV2);
116 fPhiDistribution->SetParName(3,"Triangular Flow (v3)");
117 fPhiDistribution->SetParameter(3,fV3);
118 fPhiDistribution->SetParName(4,"Quadrangular Flow (v4)");
119 fPhiDistribution->SetParameter(4,fV4);
120
121} // end of void AliFlowEventSimpleMakerOnTheFly::Init()
4d603348 122
93417736 123//====================================================================================================================
4d603348 124
93417736 125Bool_t AliFlowEventSimpleMakerOnTheFly::AcceptOrNot(AliFlowTrackSimple *pTrack)
93ff27bd 126{
93417736 127 // For the case of non-uniform acceptance determine in this method if particle is accepted or rejected.
598d292e 128
93417736 129 Bool_t bAccept = kTRUE;
598d292e 130
93417736 131 if((pTrack->Phi() >= fPhiMin1*fPi/180.) && (pTrack->Phi() < fPhiMax1*fPi/180.) && gRandom->Uniform(0,1) > fProbability1)
132 {
133 bAccept = kFALSE; // particle is rejected in the first non-uniform sector
134 } else if((pTrack->Phi() >= fPhiMin2*fPi/180.) && (pTrack->Phi() < fPhiMax2*fPi/180.) && gRandom->Uniform(0,1) > fProbability2)
135 {
136 bAccept = kFALSE; // particle is rejected in the second non-uniform sector
137 }
fe2e7868 138
93417736 139 return bAccept;
598d292e 140
93417736 141} // end of Bool_t AliFlowEventSimpleMakerOnTheFly::AcceptOrNot(AliFlowTrackSimple *pTrack);
598d292e 142
93417736 143//====================================================================================================================
598d292e 144
93417736 145AliFlowEventSimple* AliFlowEventSimpleMakerOnTheFly::CreateEventOnTheFly(AliFlowTrackSimpleCuts *cutsRP, AliFlowTrackSimpleCuts *cutsPOI)
598d292e 146{
93417736 147 // Method to create event 'on the fly'.
598d292e 148
93417736 149 // a) Determine the multiplicity of an event;
150 // b) Determine the reaction plane of an event;
151 // c) If v2 fluctuates uniformly event-by-event, sample its value from [fMinV2,fMaxV2];
152 // d) Create event 'on the fly';
153 // e) Cosmetics for the printout on the screen.
598d292e 154
93417736 155 // a) Determine the multiplicity of an event:
156 Int_t iMult = (Int_t)gRandom->Uniform(fMinMult,fMaxMult);
598d292e 157
93417736 158 // b) Determine the reaction plane of an event:
159 Double_t dReactionPlane = gRandom->Uniform(0.,TMath::TwoPi());
160 fPhiDistribution->SetParameter(0,dReactionPlane);
598d292e 161
93417736 162 // c) If v2 fluctuates uniformly event-by-event, sample its value from [fMinV2,fMaxV2]:
163 if(fUniformFluctuationsV2)
164 {
165 fPhiDistribution->SetParameter(2,gRandom->Uniform(fMinV2,fMaxV2));
166 }
167
168 // d) Create event 'on the fly':
169 AliFlowEventSimple *pEvent = new AliFlowEventSimple(iMult);
170 pEvent->SetReferenceMultiplicity(iMult);
171 pEvent->SetMCReactionPlaneAngle(dReactionPlane);
172 Int_t nRPs = 0; // number of particles tagged RP in this event
173 Int_t nPOIs = 0; // number of particles tagged POI in this event
174 for(Int_t p=0;p<iMult;p++)
175 {
176 AliFlowTrackSimple *pTrack = new AliFlowTrackSimple();
177 pTrack->SetPt(fPtSpectra->GetRandom());
178 if(fPtDependentV2 && !fUniformFluctuationsV2)
bdb5c432 179 {
93417736 180 // v2(pt): for pt < fV2vsPtCutOff v2 increases linearly, for pt >= fV2vsPtCutOff v2 = fV2vsPtMax
181 (pTrack->Pt() < fV2vsPtCutOff ?
182 fPhiDistribution->SetParameter(2,pTrack->Pt()*fV2vsPtMax/fV2vsPtCutOff) :
183 fPhiDistribution->SetParameter(2,fV2vsPtMax)
184 );
185 } // end of if(fPtDependentV2)
186 pTrack->SetPhi(fPhiDistribution->GetRandom());
187 pTrack->SetEta(gRandom->Uniform(-1.,1.));
188 pTrack->SetCharge((gRandom->Integer(2)>0.5 ? 1 : -1));
189 // Check uniform acceptance:
190 if(!fUniformAcceptance && !AcceptOrNot(pTrack)){continue;}
191 // Checking the RP cuts:
192 if(cutsRP->PassesCuts(pTrack))
1f89f68d 193 {
93417736 194 pTrack->TagRP(kTRUE);
195 nRPs++;
e23cbd39 196 }
93417736 197 // Checking the POI cuts:
198 if(cutsPOI->PassesCuts(pTrack))
2a54d329 199 {
93417736 200 pTrack->TagPOI(kTRUE);
201 nPOIs++;
202 }
203 // Assign particles to eta subevents (needed only for Scalar Product method):
204 if(pTrack->Eta()>=fEtaMinA && pTrack->Eta()<fEtaMaxA)
205 {
206 pTrack->SetForSubevent(0);
207 }
208 if(pTrack->Eta()>=fEtaMinB && pTrack->Eta()<fEtaMaxB)
209 {
210 pTrack->SetForSubevent(1);
211 }
212 pEvent->AddTrack(pTrack);
213 // Simulating nonflow:
214 if(fNTimes>1)
215 {
216 for(Int_t nt=1;nt<fNTimes;nt++)
2a54d329 217 {
93417736 218 pEvent->AddTrack(pTrack->Clone());
219 }
220 } // end of if(fNTimes>1)
221 } // end of for(Int_t p=0;p<iMult;p++)
222 pEvent->SetNumberOfRPs(fNTimes*nRPs);
223
224 // e) Cosmetics for the printout on the screen:
225 Int_t cycle = (fPtDependentV2 ? 10 : 100);
226 if((++fCount % cycle) == 0)
227 {
228 if(TMath::Abs(dReactionPlane)>1.e-44)
229 {
230 cout<<" MC Reaction Plane Angle = "<<dReactionPlane<<endl;
231 } else
2a54d329 232 {
93417736 233 cout<<" MC Reaction Plane Angle is unknown :'( "<< endl;
234 }
235 cout<<" # of simulated tracks = "<<fNTimes*iMult<<endl;
236 cout<<" # of RP tagged tracks = "<<fNTimes*nRPs<<endl;
237 cout<<" # of POI tagged tracks = "<<fNTimes*nPOIs<<endl;
238 cout <<" .... "<<fCount<< " events processed ...."<<endl;
239 } // end of if((++fCount % cycle) == 0)
240
241 return pEvent;
242
93ff27bd 243} // end of CreateEventOnTheFly()
1f89f68d 244
93417736 245//====================================================================================================================
1f89f68d 246