1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /************************************
17 * Create an event and perform full *
18 * flow analysis 'on the fly'. *
20 * author: Ante Bilandzic *
21 * (abilandzic@gmail.com) *
22 ************************************/
24 #include "Riostream.h"
28 #include "AliFlowEventSimpleMakerOnTheFly.h"
29 #include "AliFlowEventSimple.h"
30 #include "AliFlowTrackSimple.h"
31 #include "AliFlowTrackSimpleCuts.h"
33 ClassImp(AliFlowEventSimpleMakerOnTheFly)
35 //========================================================================================================================================
37 AliFlowEventSimpleMakerOnTheFly::AliFlowEventSimpleMakerOnTheFly(UInt_t uiSeed):
44 fPhiDistribution(NULL),
49 fUniformFluctuationsV2(kFALSE),
52 fPtDependentV2(kFALSE),
60 fUniformAcceptance(kTRUE),
71 // Determine seed for gRandom:
73 gRandom = new TRandom3(uiSeed); // if uiSeed is 0, the seed is determined uniquely in space and time via TUUID
75 } // end of AliFlowEventSimpleMakerOnTheFly::AliFlowEventSimpleMakerOnTheFly(UInt_t uiSeed):
77 //====================================================================================================================
79 AliFlowEventSimpleMakerOnTheFly::~AliFlowEventSimpleMakerOnTheFly()
83 if(fPtSpectra){delete fPtSpectra;}
84 if(fPhiDistribution){delete fPhiDistribution;}
86 } // end of AliFlowEventSimpleMakerOnTheFly::~AliFlowEventSimpleMakerOnTheFly()
88 //====================================================================================================================
90 void AliFlowEventSimpleMakerOnTheFly::Init()
92 // Book all objects in this method.
94 // a) Define the pt spectra;
95 // b) Define the phi distribution.
97 // a) Define the pt spectra:
99 Double_t dPtMax = 10.;
100 fPtSpectra = new TF1("fPtSpectra","x*TMath::Exp(-pow([0]*[0]+x*x,0.5)/[1])",dPtMin,dPtMax); // hardwired is Boltzmann distribution
101 fPtSpectra->SetParName(0,"Mass");
102 fPtSpectra->SetParameter(0,fMass);
103 fPtSpectra->SetParName(1,"Temperature");
104 fPtSpectra->SetParameter(1,fTemperature);
105 fPtSpectra->SetTitle("Boltzmann Distribution: f(p_{t}) = p_{t}exp[-(m^{2}+p_{t}^{2})^{1/2}/T];p_{t};f(p_{t})");
107 // b) Define the phi distribution:
108 Double_t dPhiMin = 0.;
109 Double_t dPhiMax = TMath::TwoPi();
110 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);
111 fPhiDistribution->SetParName(0,"Reaction Plane");
112 fPhiDistribution->SetParameter(0,0.);
113 fPhiDistribution->SetParName(1,"Directed Flow (v1)");
114 fPhiDistribution->SetParameter(1,fV1);
115 fPhiDistribution->SetParName(2,"Elliptic Flow (v2)");
116 fPhiDistribution->SetParameter(2,fV2);
117 fPhiDistribution->SetParName(3,"Triangular Flow (v3)");
118 fPhiDistribution->SetParameter(3,fV3);
119 fPhiDistribution->SetParName(4,"Quadrangular Flow (v4)");
120 fPhiDistribution->SetParameter(4,fV4);
122 } // end of void AliFlowEventSimpleMakerOnTheFly::Init()
124 //====================================================================================================================
126 Bool_t AliFlowEventSimpleMakerOnTheFly::AcceptOrNot(AliFlowTrackSimple *pTrack)
128 // For the case of non-uniform acceptance determine in this method if particle is accepted or rejected.
130 Bool_t bAccept = kTRUE;
132 if((pTrack->Phi() >= fPhiMin1*fPi/180.) && (pTrack->Phi() < fPhiMax1*fPi/180.) && gRandom->Uniform(0,1) > fProbability1)
134 bAccept = kFALSE; // particle is rejected in the first non-uniform sector
135 } else if((pTrack->Phi() >= fPhiMin2*fPi/180.) && (pTrack->Phi() < fPhiMax2*fPi/180.) && gRandom->Uniform(0,1) > fProbability2)
137 bAccept = kFALSE; // particle is rejected in the second non-uniform sector
142 } // end of Bool_t AliFlowEventSimpleMakerOnTheFly::AcceptOrNot(AliFlowTrackSimple *pTrack);
144 //====================================================================================================================
146 AliFlowEventSimple* AliFlowEventSimpleMakerOnTheFly::CreateEventOnTheFly(AliFlowTrackSimpleCuts const *cutsRP, AliFlowTrackSimpleCuts const *cutsPOI)
148 // Method to create event 'on the fly'.
150 // a) Determine the multiplicity of an event;
151 // b) Determine the reaction plane of an event;
152 // c) If v2 fluctuates uniformly event-by-event, sample its value from [fMinV2,fMaxV2];
153 // d) Create event 'on the fly';
154 // e) Cosmetics for the printout on the screen.
156 // a) Determine the multiplicity of an event:
157 Int_t iMult = (Int_t)gRandom->Uniform(fMinMult,fMaxMult);
159 // b) Determine the reaction plane of an event:
160 Double_t dReactionPlane = gRandom->Uniform(0.,TMath::TwoPi());
161 fPhiDistribution->SetParameter(0,dReactionPlane);
163 // c) If v2 fluctuates uniformly event-by-event, sample its value from [fMinV2,fMaxV2]:
164 if(fUniformFluctuationsV2)
166 fPhiDistribution->SetParameter(2,gRandom->Uniform(fMinV2,fMaxV2));
169 // d) Create event 'on the fly':
170 AliFlowEventSimple *pEvent = new AliFlowEventSimple(iMult);
171 pEvent->SetReferenceMultiplicity(iMult);
172 pEvent->SetMCReactionPlaneAngle(dReactionPlane);
173 Int_t nRPs = 0; // number of particles tagged RP in this event
174 Int_t nPOIs = 0; // number of particles tagged POI in this event
175 for(Int_t p=0;p<iMult;p++)
177 AliFlowTrackSimple *pTrack = new AliFlowTrackSimple();
178 pTrack->SetPt(fPtSpectra->GetRandom());
179 if(fPtDependentV2 && !fUniformFluctuationsV2)
181 // v2(pt): for pt < fV2vsPtCutOff v2 increases linearly, for pt >= fV2vsPtCutOff v2 = fV2vsPtMax
182 (pTrack->Pt() < fV2vsPtCutOff ?
183 fPhiDistribution->SetParameter(2,pTrack->Pt()*fV2vsPtMax/fV2vsPtCutOff) :
184 fPhiDistribution->SetParameter(2,fV2vsPtMax)
186 } // end of if(fPtDependentV2)
187 pTrack->SetPhi(fPhiDistribution->GetRandom());
188 pTrack->SetEta(gRandom->Uniform(-1.,1.));
189 pTrack->SetCharge((gRandom->Integer(2)>0.5 ? 1 : -1));
190 // Check uniform acceptance:
191 if(!fUniformAcceptance && !AcceptOrNot(pTrack)){continue;}
192 // Checking the RP cuts:
193 if(cutsRP->PassesCuts(pTrack))
195 pTrack->TagRP(kTRUE);
198 // Checking the POI cuts:
199 if(cutsPOI->PassesCuts(pTrack))
201 pTrack->TagPOI(kTRUE);
204 // Assign particles to eta subevents (needed only for Scalar Product method):
205 if(pTrack->Eta()>=fEtaMinA && pTrack->Eta()<fEtaMaxA)
207 pTrack->SetForSubevent(0);
209 if(pTrack->Eta()>=fEtaMinB && pTrack->Eta()<fEtaMaxB)
211 pTrack->SetForSubevent(1);
213 pEvent->AddTrack(pTrack);
214 // Simulating nonflow:
217 for(Int_t nt=1;nt<fNTimes;nt++)
219 pEvent->AddTrack(pTrack->Clone());
221 } // end of if(fNTimes>1)
222 } // end of for(Int_t p=0;p<iMult;p++)
223 pEvent->SetNumberOfRPs(fNTimes*nRPs);
225 // e) Cosmetics for the printout on the screen:
226 Int_t cycle = (fPtDependentV2 ? 10 : 100);
227 if((++fCount % cycle) == 0)
229 if(TMath::Abs(dReactionPlane)>1.e-44)
231 cout<<" MC Reaction Plane Angle = "<<dReactionPlane<<endl;
234 cout<<" MC Reaction Plane Angle is unknown :'( "<< endl;
236 cout<<" # of simulated tracks = "<<fNTimes*iMult<<endl;
237 cout<<" # of RP tagged tracks = "<<fNTimes*nRPs<<endl;
238 cout<<" # of POI tagged tracks = "<<fNTimes*nPOIs<<endl;
239 cout <<" .... "<<fCount<< " events processed ...."<<endl;
240 } // end of if((++fCount % cycle) == 0)
244 } // end of CreateEventOnTheFly()
246 //====================================================================================================================