]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx
61dba5c517447018babc22fa83e886512f8c2cb3
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowEventSimpleMakerOnTheFly.cxx
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
16 /********************************** 
17  * create an event and perform    *
18  * flow analysis 'on the fly'     * 
19  *                                * 
20  * authors: Raimond Snellings     *
21  *           (snelling@nikhef.nl) * 
22  *          Ante Bilandzic        * 
23  *           (anteb@nikhef.nl)    *
24  *********************************/
25   
26 #include "Riostream.h"
27 #include "TMath.h"
28 #include "TF1.h"
29 #include "TRandom3.h"
30
31 #include "AliFlowEventSimpleMakerOnTheFly.h"
32 #include "AliFlowEventSimple.h"
33 #include "AliFlowTrackSimple.h"
34
35 ClassImp(AliFlowEventSimpleMakerOnTheFly)
36
37
38 //========================================================================
39
40
41 AliFlowEventSimpleMakerOnTheFly::AliFlowEventSimpleMakerOnTheFly(UInt_t iseed):
42   fMultiplicityOfRP(0),
43   fMultiplicitySpreadOfRP(0.),
44   fV1RP(0.), 
45   fV1SpreadRP(0.), 
46   fV2RP(0.), 
47   fV2SpreadRP(0.), 
48   fPtSpectra(NULL),
49   fPhiDistribution(NULL),
50   fMyTRandom3(NULL),
51   fCount(0)
52  {
53   // constructor
54    fMyTRandom3 = new TRandom3(iseed); 
55  }
56
57
58 //========================================================================
59
60
61 AliFlowEventSimpleMakerOnTheFly::~AliFlowEventSimpleMakerOnTheFly()
62 {
63  // destructor
64   if (fPtSpectra) delete fPtSpectra;
65   if (fPhiDistribution) delete fPhiDistribution;
66   if (fMyTRandom3) delete  fMyTRandom3;
67 }
68
69
70 //========================================================================
71
72
73 AliFlowEventSimple* AliFlowEventSimpleMakerOnTheFly::CreateEventOnTheFly()
74 {
75   // method to create event on the fly
76   
77   AliFlowEventSimple* pEvent = new AliFlowEventSimple(fMultiplicityOfRP);
78   
79   //reaction plane
80   Double_t fMCReactionPlaneAngle = fMyTRandom3->Uniform(0.,TMath::TwoPi());
81   
82   // pt:   
83   Double_t dPtMin = 0.; // to be improved 
84   Double_t dPtMax = 10.; // to be improved 
85   
86   fPtSpectra = new TF1("fPtSpectra","[0]*x*TMath::Exp(-x*x)",dPtMin,dPtMax);  
87   fPtSpectra->SetParName(0,"Multiplicity of RPs");  
88   // sampling the multiplicity:
89   Int_t fNewMultiplicityOfRP = fMyTRandom3->Gaus(fMultiplicityOfRP,fMultiplicitySpreadOfRP);
90   fPtSpectra->SetParameter(0,fNewMultiplicityOfRP);
91   
92   
93   // phi:
94   Double_t dPhiMin = 0.; // to be improved 
95   Double_t dPhiMax = TMath::TwoPi(); // to be improved 
96   
97   fPhiDistribution = new TF1("fPhiDistribution","1+2.*[0]*TMath::Cos(x)+2.*[1]*TMath::Cos(2*x)",dPhiMin,dPhiMax);
98
99   // sampling the V1:
100   fPhiDistribution->SetParName(0,"directed flow");
101   if(fV1RP>0.0) fV1RP = fMyTRandom3->Gaus(fV1RP,fV1SpreadRP);
102   fPhiDistribution->SetParameter(0,fV1RP);
103  
104   // sampling the V2:
105   fPhiDistribution->SetParName(1,"elliptic flow");
106   fV2RP = fMyTRandom3->Gaus(fV2RP,fV2SpreadRP);
107   fPhiDistribution->SetParameter(1,fV2RP);
108    
109   // eta:
110   Double_t dEtaMin = -1.; // to be improved 
111   Double_t dEtaMax = 1.; // to be improved 
112   
113   Int_t iGoodTracks = 0;
114   Int_t iSelParticlesRP = 0;
115   Int_t iSelParticlesPOI = 0;
116   for(Int_t i=0;i<fNewMultiplicityOfRP;i++) {
117     AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
118     pTrack->SetPt(fPtSpectra->GetRandom());
119     pTrack->SetEta(fMyTRandom3->Uniform(dEtaMin,dEtaMax));
120     pTrack->SetPhi(fPhiDistribution->GetRandom()+fMCReactionPlaneAngle);
121     pTrack->SetForRPSelection(kTRUE);
122     iSelParticlesRP++;
123     pTrack->SetForPOISelection(kTRUE);
124     iSelParticlesPOI++;
125
126     pEvent->TrackCollection()->Add(pTrack);
127     iGoodTracks++;
128   }
129  
130   pEvent->SetEventNSelTracksRP(iSelParticlesRP);  
131   pEvent->SetNumberOfTracks(iGoodTracks);//tracks used either for RP or for POI selection
132   pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
133
134   if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
135   else cout<<" MC Reaction Plane Angle = unknown "<< endl;
136
137   cout<<" iGoodTracks = "<< iGoodTracks << endl;
138   cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
139   cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
140   cout << "# " << ++fCount << " events processed" << endl;
141
142   delete fPhiDistribution;
143   delete fPtSpectra;
144   return pEvent;  
145  
146 } // end of CreateEventOnTheFly()
147
148
149