29 #include "Riostream.h"
30 #include "TObjArray.h"
31 #include "TClonesArray.h"
35 #include "TParticle.h"
43 #include "TParameter.h"
48 #include "TVirtualMCDecayer.h"
58 AliFlowOnTheFlyEventGenerator::
AliFlowOnTheFlyEventGenerator() : fGenerators(0), fEmbedMe(0), fFlowEvent(0), fDecayer(0), fAddV2Mothers(0), fAddV3Mothers(0), fAddV2Daughters(0), fAddV3Daughters(0), fPsi2(0), fPsi3(0), fPrecisionPhi(.001), fMaxNumberOfIterations(100), fQA(0), fFF(0) {}
60 AliFlowOnTheFlyEventGenerator::AliFlowOnTheFlyEventGenerator(
Bool_t qa,
Int_t ff,
Int_t mult, TVirtualMCDecayer* decayer,
Bool_t a,
Bool_t b,
Bool_t c,
Bool_t d) : fGenerators(0), fEmbedMe(0), fFlowEvent(0), fDecayer(0), fAddV2Mothers(0), fAddV3Mothers(0), fAddV2Daughters(0), fAddV3Daughters(0), fPsi2(0), fPsi3(0), fPrecisionPhi(.001), fMaxNumberOfIterations(100), fQA(qa), fFF(ff) {
87 for(
int i(0); i <
fGenerators->GetEntriesFast(); i++) {
107 name = spectrum->GetName();
110 else name = Form(
"pt_%i", (
int)species);
121 name = v2->GetName();
124 else name = Form(
"v2_%i", (
int)species);
135 name = v3->GetName();
138 else name = Form(
"v3_%i", (
int)species);
150 if(
fFF == 3) fluc_rp = fluc_poi;
152 Int_t multPiKPr[] = {(int)(.7*bg/2.), (int)(.2*bg/2.), (int)(.1*bg/2.)};
153 Int_t fPDGPiKPr[] = {211, 321, 2212};
154 Int_t totalRPMultiplicity(0), totalPOIMultiplicity(0);
155 for(
int i(0); i < nSpecies; i++) totalPOIMultiplicity+=mult[i];
156 for(
int i(0); i < 3; i++) totalRPMultiplicity+=multPiKPr[i];
157 Int_t totalMultiplicity(totalRPMultiplicity+totalPOIMultiplicity);
159 for(
int i(0); i < nSpecies; i++) {
164 for(
int i(0); i < 3; i++) {
199 TParticle* pParticle = 0x0;
200 Int_t iSelParticlesRP(0);
201 for (
Int_t i(0); i <
event->GetEntries(); i++) {
202 pParticle = (TParticle*)event->At(i);
203 if (!pParticle)
continue;
204 if (pParticle->GetNDaughters()!=0)
continue;
207 pTrack->
SetID(pParticle->GetPdgCode());
210 if(pParticle->GetFirstMother()==-1) pTrack->
SetCharge(-1);
232 v2+=TMath::Sqrt(2*(v2*.25)*(v2*.25))*TMath::ErfInverse(2*fluc-1);
233 if(
fQA)
Find(part->GetPdgCode(), kTRUE)->FillV2(part->Pt(), v2);
237 f = phi-phi0+v2*TMath::Sin(2.*(phi-
fPsi2));
238 fp = 1.0+2.0*v2*TMath::Cos(2.*(phi-
fPsi2));
242 part->SetMomentum( part->Pt()*TMath::Cos(phi), part->Pt()*TMath::Sin(phi), part->Pz(), part->Energy() );
251 for(
Int_t nTrack=0; nTrack!=
event->GetEntriesFast(); ++nTrack) {
252 part = (TParticle*) event->At(nTrack);
256 AddV2(part,
Find(part->GetPdgCode(), kTRUE)->GetV2(part->Pt()), fluc);
263 Double_t ph, et, pt, mm, px, py, pz, ee;
267 for(
int i=_tempCounter; i<=mult+_tempCounter; ++i) {
269 TParticle* part = (TParticle*)event->ConstructedAt(i);
270 part->SetStatusCode(1);
271 part->SetFirstMother(-1);
272 part->SetLastMother(-1);
273 part->SetFirstDaughter(-1);
274 part->SetLastDaughter(-1);
275 ph =
gRandom->Uniform(0,TMath::TwoPi());
276 et =
gRandom->Uniform(-1.0,+1.0);
277 pt = generator->
GetPt();
278 part->SetPdgCode( pid );
279 mm = part->GetMass();
280 px = pt*TMath::Cos(ph);
281 py = pt*TMath::Sin(ph);
282 pz = pt*TMath::SinH(et);
283 ee = TMath::Sqrt( mm*mm + pt*pt+pz*pz );
284 part->SetMomentum( px, py, pz, ee );
295 TClonesArray* arr =
new TClonesArray(
"TParticle",10);
298 Int_t nTracks =
event->GetEntriesFast();
299 TParticle *part, *part1;
300 TClonesArray &in = *event;
301 for(
Int_t loop=0; loop!=3; ++loop) {
303 for(
Int_t nTrack=nStart; nTrack!=nTracks; ++nTrack) {
305 part = (TParticle*) event->At( nTrack );
307 kf = TMath::Abs(part->GetPdgCode());
310 TLorentzVector pmom( part->Px(), part->Py(), part->Pz(), part->Energy() );
314 Int_t nDaughters = arr->GetEntries();
315 if(nDaughters<2)
continue;
316 for(
Int_t nDaughter=1; nDaughter!=nDaughters; ++nDaughter) {
317 part1 = (TParticle*) (arr->At(nDaughter));
319 new(in[nTracks+secondaries]) TParticle( part1->GetPdgCode(),
320 part1->GetStatusCode(),
321 part1->GetFirstMother(),
322 part1->GetSecondMother(),
323 part1->GetFirstDaughter(),
324 part1->GetLastDaughter(),
334 if(nDaughter==1) part->SetFirstDaughter(nTracks+secondaries);
335 else if ((nDaughters-1)==nDaughter) part->SetLastDaughter(nTracks+secondaries);
340 nTracks =
event->GetEntries();
350 const Float_t mass_d1(.000511);
351 const Float_t mass_d2(.000511);
352 Double_t p_dec1=sqrt((TMath::Abs(mass1*mass1-(mass_d1+mass_d2)*(mass_d1+mass_d2))*(mass1*mass1-(mass_d1-mass_d2)*(mass_d1-mass_d2))))/2/mass1;
353 TLorentzVector *p_d1=
new TLorentzVector();
354 TLorentzVector *p_d2=
new TLorentzVector();
357 Double_t mt_m=sqrt(mass1*mass1+pt_m*pt_m);
358 Double_t pz_m=mt_m*TMath::SinH(yy_m);
360 Double_t px_m=pt_m*TMath::Cos(phi_m);
361 Double_t py_m=pt_m*TMath::Sin(phi_m);
365 Double_t pt_d=p_dec1*sqrt(1-costh_d*costh_d);
366 Double_t px_d=pt_d*TMath::Cos(phi_d);
367 Double_t py_d=pt_d*TMath::Sin(phi_d);
368 p_d1->SetPxPyPzE(px_d,py_d,pz_d,sqrt(mass_d1*mass_d1+p_dec1*p_dec1));
369 p_d2->SetPxPyPzE(-px_d,-py_d,-pz_d,sqrt(mass_d2*mass_d2+p_dec1*p_dec1));
370 Double_t gamma_b=sqrt(mass1*mass1+pz_m*pz_m+pt_m*pt_m)/mass1;
374 p_d1->Boost(bx,by,bz);
375 p_d2->Boost(bx,by,bz);
376 TParticle* daughter_1 = (TParticle*)arr->ConstructedAt(0);
377 TParticle* daughter_2 = (TParticle*)arr->ConstructedAt(1);
378 daughter_1->SetStatusCode(1);
379 daughter_1->SetFirstMother(-1);
380 daughter_1->SetLastMother(-1);
381 daughter_1->SetFirstDaughter(-1);
382 daughter_1->SetLastDaughter(-1);
383 daughter_1->SetPdgCode(11);
384 TLorentzVector& ref_p_d1 = *p_d1;
385 daughter_1->SetMomentum(ref_p_d1);
386 daughter_2->SetStatusCode(1);
387 daughter_2->SetFirstMother(-1);
388 daughter_2->SetLastMother(-1);
389 daughter_2->SetFirstDaughter(-1);
390 daughter_2->SetLastDaughter(-1);
391 daughter_2->SetPdgCode(-11);
392 TLorentzVector& pp = *p_d2;
393 daughter_2->SetMomentum(pp);
443 printf(
" > PANIC <\n");
446 printf(
" > %i species available in generator\n",
fGenerators->GetEntriesFast());
447 for(
int i(0); i <
fGenerators->GetEntriesFast(); i++)
449 printf(
" more can be created 'on the fly', but beware of non-existent pdg values !");
461 printf(
" > Request has been made for QA plots but QA histograms have been disabled !\n");
464 TFile *QAfile =
new TFile(
"GeneratorfQA.root",
"RECREATE");
465 for(
int i(0); i <
fGenerators->GetEntriesFast(); i++) {
471 if((!QApt)||(!QAv2)||(!QAv3)) {
472 printf(
" > couldn't read qa histogrmas for species %i <\n", gen->
GetPDGCode());
475 if(QApt->GetEntries()==0&&QAv2->GetEntries()==0&&QAv3->GetEntries()==0)
continue;
476 printf(
" > saving QA histograms for sampled species %i <\n", gen->
GetPDGCode());
477 QAfile->mkdir(Form(
"fPDG_%i", gen->
GetPDGCode()));
478 QAfile->cd(Form(
"fPDG_%i", gen->
GetPDGCode()));
479 if(QApt->GetEntries() != 0) {
481 QApt->Scale(gen->
GetPtSpectrum()->Integral(0,20)/QApt->Integral(),
"width");
void SetCharge(Int_t charge)
TH1 * GetQAType(Int_t t) const
AliFlowOnTheFlyEventGenerator()
NaiveFlowAndSpectrumGenerator * Find(Short_t pdg, Bool_t make)
void SetPtSpectrum(TF1 *s)
TVirtualMCDecayer * fDecayer
flow event simple for output
AliFlowEventSimple * GenerateOnTheFlyEvent(TClonesArray *event, Int_t nSpecies, Int_t species[], Int_t mult[], Int_t bg, Bool_t fluc)
AliFlowEventSimple * fFlowEvent
void SetPtDependentV2(const char *func, Short_t pdg)
AliFlowEventSimple * ConvertTClonesToFlowEvent(TClonesArray *event, Int_t totalMultiplicity)
void AddTrack(AliFlowTrackSimple *track)
static Int_t OnTheFlyEventGeneratorCounter
void SetPtDependentV3(const char *func, Short_t pdg)
void SetDifferentialV3(TF1 *v3)
void DecayOnTheFlyTracks(TClonesArray *event)
void DoGeneratorQA(Bool_t v2, Bool_t v3)
void SetForRPSelection(Bool_t b=kTRUE)
void SetNumberOfRPs(Int_t nr)
void ForceGammaDecay(TClonesArray *arr, TParticle *part)
TF1 * GetPtSpectrum() const
Int_t fMaxNumberOfIterations
ClassImp(AliFlowOnTheFlyEventGenerator) AliFlowOnTheFlyEventGenerator
void SetPtSpectrum(const char *func, Short_t pdg)
void GenerateOnTheFlyTracks(Int_t mult, Int_t pid, TClonesArray *event, Double_t fluc)
TF1 * GetDifferentialV2() const
void SetWeight(Double_t weight)
void AddV2(TParticle *particle, Double_t v2, Double_t fluc)
void SetDifferentialV2(TF1 *v2)
void SetMCReactionPlaneAngle(Double_t fPhiRP)
TF1 * GetDifferentialV3() const
virtual ~AliFlowOnTheFlyEventGenerator()
Double_t GetV2(Double_t pt) const
Short_t GetPDGCode() const