1 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
2 * See cxx source for full Copyright notice */
6 // Implementation of the interface for THBTprocessor
7 // Author: Piotr Krzysztof Skowronski <Piotr.Skowronski@cern.ch>
9 // 09.10.2001 Piotr Skowronski
11 // Theta - Eta cohernecy facilities added:
12 // AliGenerator::SetThetaRange method overriden
13 // Static methods added
19 // Class description comments put on proper place
21 // 27.09.2001 Piotr Skowronski
22 // removing of redefinition of defaults velues
23 // in method's implementation.
26 //////////////////////////////////////////////////////////////////////////////////
27 //Wrapper class for "hbt processor" after burner
28 //The origibal code is written in fortran by Lanny Ray
29 //and is put in the directory $ALICE_ROOT/HBTprocessor
30 //Detailed description is on the top of the file hbt_event_processor.f
32 //This class can be used ONLY with AliGenCocktailAfterBurner wrapper generator
35 // AliGenCocktailAfterBurner = gener = new AliGenCocktailAfterBurner();
36 // gener->SetPhiRange(0, 360); //Set global parameters
37 // gener->SetThetaRange(35., 145.);
38 // AliGenHIJINGpara *hijing = new AliGenHIJINGpara(10000); //Add some generator
39 // hijing->SetMomentumRange(0, 999);
40 // gener->AddGenerator(hijing,"HIJING PARAMETRIZATION",1);
42 // AliGenHBTprocessor *hbtp = new AliGenHBTprocessor(); //create object
43 // hbtp->SetRefControl(2); //set parameters
44 // hbtp->SetSwitch1D(1);
45 // hbtp->SetR0(6);//fm - radius
46 // hbtp->SetLambda(0.7);//chaocity parameter
47 // gener->AddAfterBurner(hbtp,"HBT PROCESSOR",1); //add to the main generator
52 // A) HBT PROCESSOR NEEDS MORE THAN ONE EVENT TO WORK
53 // AS MORE AS IT BETTER WORKS
54 // B) IT IS ABLE TO "ADD" CORRELATIONS ONLY UP TO TWO PARTICLE TYPES AT ONES
55 //////////////////////////////////////////////////////////////////////////////////
57 #include "AliGenHBTprocessor.h"
63 #include "TParticle.h"
64 #include "AliGenCocktailAfterBurner.h"
68 const Int_t AliGenHBTprocessor::fgkHBTPMAXPART = 100000;
70 ClassImp(AliGenHBTprocessor)
74 AliGenCocktailAfterBurner* GetGenerator();
75 /*******************************************************************/
77 AliGenHBTprocessor::AliGenHBTprocessor() : AliGenerator(-1)
80 // Standard constructor
81 // Sets default veues of all parameters
82 SetName("AliGenHBTprocessor");
83 SetTitle("AliGenHBTprocessor");
86 fHBTprocessor = new THBTprocessor();
91 SetTrackRejectionFactor();
111 SetSwitchCoherence();
113 SetSwitchFermiBose();
114 //SetMomentumRange();
127 SetNBins1DFineMesh();
128 SetBinSize1DFineMesh();
129 SetNBins1DCoarseMesh();
130 SetBinSize1DCoarseMesh();
131 SetNBins3DFineMesh();
132 SetBinSize3DFineMesh();
133 SetNBins3DCoarseMesh();
134 SetBinSize3DCoarseMesh();
135 SetNBins3DFineProjectMesh();
138 /*******************************************************************/
141 /*******************************************************************/
143 AliGenHBTprocessor::~AliGenHBTprocessor()
147 if (fHBTprocessor) delete fHBTprocessor; //delete generator
151 /*******************************************************************/
153 void AliGenHBTprocessor::InitStatusCodes()
155 //creates and inits status codes array to zero
156 AliGenCocktailAfterBurner *cab = GetGenerator();
158 if(!cab) Fatal("AliGenHBTprocessor::InitStatusCodes()","Can not find AliGenCocktailAfterBurner generator");
160 Int_t nev = cab->GetNumberOfEvents();
162 fHbtPStatCodes = new Int_t* [nev];
163 for( Int_t i =0; i<nev;i++)
165 Int_t nprim = cab->GetStack(i)->GetNprimary();
166 fHbtPStatCodes[i] = new Int_t[nprim];
167 for (Int_t k =0 ;k<nprim;k++)
168 fHbtPStatCodes[i][k] =0;
173 /*******************************************************************/
175 void AliGenHBTprocessor::CleanStatusCodes()
176 {//Cleans up status codes
179 for (Int_t i =0; i<GetGenerator()->GetNumberOfEvents(); i++)
180 delete [] fHbtPStatCodes[i];
181 delete fHbtPStatCodes;
186 /*******************************************************************/
188 void AliGenHBTprocessor::Init()
190 //sets up parameters in generator
191 THBTprocessor *thbtp = fHBTprocessor;
194 thbtp->SetTrackRejectionFactor(fTrackRejectionFactor);
195 thbtp->SetRefControl(fReferenceControl);
197 if ((fPid[0] == fPid[1]) || (fPid[0] == 0) || (fPid[1] == 0))
200 thbtp->SetPIDs(IdFromPDG(fPid[1]) ,0);
202 thbtp->SetPIDs(IdFromPDG(fPid[0]) ,0);
203 thbtp->SetNPIDtypes(1);
205 if (fSwitch_type !=1)
206 Warning("AliGenHBTprocessor::Init","\nThere is only one particle type set,\n\
207 and Switch_Type differnt then 1,\n which does not make sense.\n\
208 Setting it to 1.\n");
214 thbtp->SetPIDs(IdFromPDG(fPid[0]) ,IdFromPDG(fPid[1]));
216 thbtp->SetSwitchType(fSwitch_type);
219 thbtp->SetMaxIterations(fMaxit);
220 thbtp->SetDelChi(fDelchi);
221 thbtp->SetIRand(fIrand);
222 thbtp->SetLambda(fLambda);
223 thbtp->SetR1d(fR_1d);
224 thbtp->SetRSide(fRside);
225 thbtp->SetROut(fRout);
226 thbtp->SetRLong(fRlong);
227 thbtp->SetRPerp(fRperp);
228 thbtp->SetRParallel(fRparallel);
231 thbtp->SetSwitch1D(fSwitch_1d);
232 thbtp->SetSwitch3D(fSwitch_3d);
233 thbtp->SetSwitchType(fSwitch_type);
234 thbtp->SetSwitchCoherence(fSwitch_coherence);
235 thbtp->SetSwitchCoulomb(fSwitch_coulomb);
236 thbtp->SetSwitchFermiBose(fSwitch_fermi_bose);
237 thbtp->SetPtRange(fPtMin,fPtMax);
238 thbtp->SetPxRange(fPx_min,fPx_max);
239 thbtp->SetPyRange(fPy_min,fPy_max);
240 thbtp->SetPzRange(fPz_min,fPz_max);
241 thbtp->SetPhiRange(fPhiMin*180./TMath::Pi(),fPhiMax*180./TMath::Pi());
242 thbtp->SetEtaRange(fEta_min,fEta_max);
243 thbtp->SetNPtBins(fN_pt_bins);
244 thbtp->SetNPhiBins(fN_phi_bins);
245 thbtp->SetNEtaBins(fN_eta_bins);
246 thbtp->SetNPxBins(fN_px_bins);
247 thbtp->SetNPyBins(fN_py_bins);
248 thbtp->SetNPzBins(fN_pz_bins);
249 thbtp->SetNBins1DFineMesh(fN_1d_fine);
250 thbtp->SetBinSize1DFineMesh(fBinsize_1d_fine);
251 thbtp->SetNBins1DCoarseMesh(fN_1d_coarse);
252 thbtp->SetBinSize1DCoarseMesh(fBinsize_1d_coarse);
253 thbtp->SetNBins3DFineMesh(fN_3d_fine);
254 thbtp->SetBinSize3DFineMesh(fBinsize_3d_fine);
255 thbtp->SetNBins3DCoarseMesh(fN_3d_coarse);
256 thbtp->SetBinSize3DCoarseMesh(fBinsize_3d_coarse);
257 thbtp->SetNBins3DFineProjectMesh(fN_3d_fine_project);
260 /*******************************************************************/
262 void AliGenHBTprocessor::Generate()
266 if (gAlice->GetEventsPerRun() <2)
268 Fatal("AliGenHBTprocessor::Generate()",
269 "HBT Processor needs more than 1 event to work properly,\
270 but there is only %d set", gAlice->GetEventsPerRun());
273 fHBTprocessor->Initialize(); //reset all fields of common blocks
274 //in case there are many HBT processors
275 //run one after one (i.e. in AliCocktailAfterBurner)
276 //between Init() called and Generate there might
277 Init(); //be different instance running - be sure that we have our settings
279 InitStatusCodes(); //Init status codes
281 fHBTprocessor->GenerateEvent(); //Generates event
283 CleanStatusCodes(); //Clean Status codes - thet are not needed anymore
286 /*******************************************************************/
289 /*******************************************************************/
290 void AliGenHBTprocessor::GetParticles(TClonesArray * particles)
294 cout<<"Particles has to be initialized"<<endl;
297 fHBTprocessor->ImportParticles(particles);
300 /*******************************************************************/
302 Int_t AliGenHBTprocessor::GetHbtPStatusCode(Int_t part) const
304 //returns the status code of the given particle in the active event
305 //see SetActiveEvent in the bottom of AliGenHBTprocessor.cxx
306 //and in AliCocktailAfterBurner
307 Int_t ActiveEvent = GetGenerator()->GetActiveEventNumber();
308 return fHbtPStatCodes[ActiveEvent][part];
311 /*******************************************************************/
312 void AliGenHBTprocessor::SetHbtPStatusCode(Int_t hbtstatcode, Int_t part)
314 //Sets the given status code to given particle number (part) in the active event
315 Int_t ActiveEvent = GetGenerator()->GetActiveEventNumber();
316 fHbtPStatCodes[ActiveEvent][part] = hbtstatcode;
319 /*******************************************************************/
321 void AliGenHBTprocessor::SetTrackRejectionFactor(Float_t trf) //def 1.0
323 //Sets the Track Rejection Factor
324 //variates in range 0.0 <-> 1.0
325 //Describes the factor of particles rejected from the output.
326 //Used only in case of low muliplicity particles e.g. lambdas.
327 //Processor generates addisional particles and builds the
328 //correletions on such a statistics.
329 //At the end these particels are left in the event according
330 //to this factor: 1==all particles are left
331 // 0==all are removed
333 fTrackRejectionFactor=trf;
334 fHBTprocessor->SetTrackRejectionFactor(trf);
336 /*******************************************************************/
338 void AliGenHBTprocessor::SetRefControl(Int_t rc) //default 2
340 //Sets the Refernce Control Switch
341 //switch wether read reference histograms from file =1
342 // compute from input events =2 - default
343 fReferenceControl=rc;
344 fHBTprocessor->SetRefControl(rc);
346 /*******************************************************************/
348 void AliGenHBTprocessor::SetPIDs(Int_t pid1,Int_t pid2)
351 //Sets PDG Codes of particles to be processed, default \\Pi^{+} and \\Pi^{-}
352 //This method accepts PDG codes which is
353 //in opposite to THBBProcessor which accepts GEANT PID
354 if ( (pid1 == 0) && (pid2 == 0) )
356 Error("AliGenHBTprocessor::SetPIDs","Sensless Particle Types setting: 0 0, Ignoring\n");
364 fHBTprocessor->SetPIDs(IdFromPDG(pid1) ,0);
370 fHBTprocessor->SetPIDs(IdFromPDG(pid1) ,IdFromPDG(pid2));
374 /*******************************************************************/
376 void AliGenHBTprocessor::SetNPIDtypes(Int_t npidt)
378 //Number ofparticle types to be processed - default 2
379 //see AliGenHBTprocessor::SetPIDs
382 fHBTprocessor->SetNPIDtypes(npidt);
384 /*******************************************************************/
386 void AliGenHBTprocessor::SetDeltap(Float_t deltp)
389 //maximum range for random momentum shifts in GeV/c;
390 //px,py,pz independent; Default = 0.1 GeV/c.
392 fHBTprocessor->SetDeltap(deltp);
394 /*******************************************************************/
396 void AliGenHBTprocessor::SetMaxIterations(Int_t maxiter)
398 //maximum # allowed iterations thru all the
399 //tracks for each event. Default = 50.
400 //If maxit=0, then calculate the correlations
401 //for the input set of events without doing the
402 //track adjustment procedure.
405 fHBTprocessor->SetMaxIterations(maxiter);
408 /*******************************************************************/
409 void AliGenHBTprocessor::SetDelChi(Float_t dc)
411 //min % change in total chi-square for which
412 //the track adjustment iterations may stop,
416 fHBTprocessor->SetDelChi(dc);
418 /*******************************************************************/
420 void AliGenHBTprocessor::SetIRand(Int_t irnd)
422 //if fact dummy - used only for compatibility
423 //we are using AliRoot built in RNG
424 //dummy in fact since we are using aliroot build-in RNG
425 //Sets renaodom number generator
427 fHBTprocessor->SetIRand(irnd);
429 /*******************************************************************/
431 void AliGenHBTprocessor::SetLambda(Float_t lam)
434 // Sets Chaoticity Parameter
436 fHBTprocessor->SetLambda(lam);
438 /*******************************************************************/
439 void AliGenHBTprocessor::SetR1d(Float_t r)
442 //Sets Spherical source model radius (fm)
444 fHBTprocessor->SetR1d(r);
446 /*******************************************************************/
447 void AliGenHBTprocessor::SetRSide(Float_t rs)
450 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
453 fHBTprocessor->SetRSide(rs);
455 /*******************************************************************/
456 void AliGenHBTprocessor::SetROut(Float_t ro)
459 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
461 fHBTprocessor->SetROut(ro);
463 /*******************************************************************/
464 void AliGenHBTprocessor::SetRLong(Float_t rl)
467 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
469 fHBTprocessor->SetRLong(rl);
471 /*******************************************************************/
472 void AliGenHBTprocessor::SetRPerp(Float_t rp)
475 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
477 fHBTprocessor->SetRPerp(rp);
479 /*******************************************************************/
480 void AliGenHBTprocessor::SetRParallel(Float_t rprl)
483 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
485 fHBTprocessor->SetRParallel(rprl);
487 /*******************************************************************/
488 void AliGenHBTprocessor::SetR0(Float_t r0)
491 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
493 fHBTprocessor->SetR0(r0);
495 /*******************************************************************/
496 void AliGenHBTprocessor::SetQ0(Float_t q0)
499 //Sets Q0 = NA35 Coulomb parameter for finite source size in (GeV/c)
500 // if fSwitchCoulomb = 2
501 // = Spherical Coulomb source radius in (fm)
502 // if switch_coulomb = 3, used to interpolate the
503 // input Pratt/Cramer discrete Coulomb source
506 fHBTprocessor->SetQ0(q0);
509 /*******************************************************************/
510 void AliGenHBTprocessor::SetSwitch1D(Int_t s1d)
514 // = 0 to not compute the 1D two-body //orrelations.
515 // = 1 to compute this using Q-invariant
516 // = 2 to compute this using Q-total
517 // = 3 to compute this using Q-3-ve//tor
520 fHBTprocessor->SetSwitch1D(s1d);
522 /*******************************************************************/
523 void AliGenHBTprocessor::SetSwitch3D(Int_t s3d)
527 // = 0 to not compute the 3D two-body correlations.
528 // = 1 to compute this using the side-out-long form
529 // = 2 to compute this using the Yanno-Koonin-Pogoredskij form.
532 fHBTprocessor->SetSwitch3D(s3d);
534 /*******************************************************************/
535 void AliGenHBTprocessor::SetSwitchType(Int_t st)
538 // Sets switch_type = 1 to fit only the like pair correlations
539 // = 2 to fit only the unlike pair correlations
540 // = 3 to fit both the like and unlike pair correl.
541 //See SetPIDs and Init
542 //If only one particle type is set, unly==1 makes sens
545 fHBTprocessor->SetSwitchType(st);
547 /*******************************************************************/
548 void AliGenHBTprocessor::SetSwitchCoherence(Int_t sc)
551 // switch_coherence = 0 for purely incoherent source (but can have
553 // = 1 for mixed incoherent and coherent source
555 fSwitch_coherence = sc;
556 fHBTprocessor->SetSwitchCoherence(sc);
558 /*******************************************************************/
559 void AliGenHBTprocessor::SetSwitchCoulomb(Int_t scol)
562 // switch_coulomb = 0 no Coulomb correction
563 // = 1 Point source Gamow correction only
564 // = 2 NA35 finite source size correction
565 // = 3 Pratt/Cramer finite source size correction;
566 // interpolated from input tables.
567 fSwitch_coulomb =scol;
568 fHBTprocessor->SetSwitchCoulomb(scol);
570 /*******************************************************************/
571 void AliGenHBTprocessor::SetSwitchFermiBose(Int_t sfb)
574 // switch_fermi_bose = 1 Boson pairs
575 // = -1 Fermion pairs
577 fSwitch_fermi_bose = sfb;
578 fHBTprocessor->SetSwitchFermiBose(sfb);
580 /*******************************************************************/
581 void AliGenHBTprocessor::SetPtRange(Float_t ptmin, Float_t ptmax)
583 // default ptmin = 0.1, ptmax = 0.98
584 //Sets Pt range (GeV)
585 AliGenerator::SetPtRange(ptmin,ptmax);
586 fHBTprocessor->SetPtRange(ptmin,ptmax);
589 /*******************************************************************/
590 void AliGenHBTprocessor::SetPxRange(Float_t pxmin, Float_t pxmax)
592 //default pxmin = -1.0, pxmax = 1.0
596 fHBTprocessor->SetPxRange(pxmin,pxmax);
598 /*******************************************************************/
599 void AliGenHBTprocessor::SetPyRange(Float_t pymin, Float_t pymax)
601 //default pymin = -1.0, pymax = 1.0
605 fHBTprocessor->SetPyRange(pymin,pymax);
607 /*******************************************************************/
608 void AliGenHBTprocessor::SetPzRange(Float_t pzmin, Float_t pzmax)
610 //default pzmin = -3.6, pzmax = 3.6
614 fHBTprocessor->SetPzRange(pzmin,pzmax);
616 void AliGenHBTprocessor::SetMomentumRange(Float_t pmin, Float_t pmax)
618 //default pmin=0, pmax=0
619 //Do not use this method!
620 MayNotUse("AliGenHBTprocessor::SetMomentumRange Method is Dummy");
623 /*******************************************************************/
624 void AliGenHBTprocessor::SetPhiRange(Float_t phimin, Float_t phimax)
628 AliGenerator::SetPhiRange(phimin,phimax);
630 fHBTprocessor->SetPhiRange(phimin,phimax);
632 /*******************************************************************/
633 void AliGenHBTprocessor::SetEtaRange(Float_t etamin, Float_t etamax)
635 //default etamin = -1.5, etamax = 1.5
639 fHBTprocessor->SetEtaRange(etamin,etamax);
641 //set the azimothal angle range in the AliGeneraor -
642 //to keep coherency between azimuthal angle and pseudorapidity
643 //DO NOT CALL this->SetThetaRange, because it calls this method (where we are)
644 //which must cause INFINITE LOOP
645 AliGenerator::SetThetaRange(RadiansToDegrees(EtaToTheta(fEta_min)),
646 RadiansToDegrees(EtaToTheta(fEta_max)));
649 /*******************************************************************/
650 void AliGenHBTprocessor::SetThetaRange(Float_t thetamin, Float_t thetamax)
652 //default thetamin = 0, thetamax = 180
653 //Azimuthal angle, override AliGenerator method which uses widely (i.e. wrapper generators)
654 //core fortran HBTProcessor uses Eta (pseudorapidity)
655 //so these methods has to be synchronized
657 AliGenerator::SetThetaRange(thetamin,thetamax);
659 SetEtaRange( ThetaToEta(fThetaMin) , ThetaToEta(fThetaMax) );
663 /*******************************************************************/
664 void AliGenHBTprocessor::SetNPtBins(Int_t nptbin)
666 //default nptbin = 50
667 //set number of Pt bins
669 fHBTprocessor->SetNPtBins(nptbin);
671 /*******************************************************************/
672 void AliGenHBTprocessor::SetNPhiBins(Int_t nphibin)
674 //default nphibin = 50
675 //set number of Phi bins
677 fHBTprocessor->SetNPhiBins(nphibin);
679 /*******************************************************************/
680 void AliGenHBTprocessor::SetNEtaBins(Int_t netabin)
682 //default netabin = 50
683 //set number of Eta bins
684 fN_eta_bins = netabin;
685 fHBTprocessor->SetNEtaBins(netabin);
687 /*******************************************************************/
688 void AliGenHBTprocessor::SetNPxBins(Int_t npxbin)
690 //default npxbin = 20
691 //set number of Px bins
693 fHBTprocessor->SetNPxBins(npxbin);
695 /*******************************************************************/
696 void AliGenHBTprocessor::SetNPyBins(Int_t npybin)
698 //default npybin = 20
699 //set number of Py bins
701 fHBTprocessor->SetNPyBins(npybin);
703 /*******************************************************************/
704 void AliGenHBTprocessor::SetNPzBins(Int_t npzbin)
706 //default npzbin = 70
707 //set number of Pz bins
709 fHBTprocessor->SetNPzBins(npzbin);
711 /*******************************************************************/
712 void AliGenHBTprocessor::SetNBins1DFineMesh(Int_t n)
715 //Sets the number of bins in the 1D mesh
717 fHBTprocessor->SetNBins1DFineMesh(n);
720 /*******************************************************************/
721 void AliGenHBTprocessor::SetBinSize1DFineMesh(Float_t x)
724 //Sets the bin size in the 1D mesh
725 fBinsize_1d_fine = x;
726 fHBTprocessor->SetBinSize1DFineMesh(x);
728 /*******************************************************************/
730 void AliGenHBTprocessor::SetNBins1DCoarseMesh(Int_t n)
733 //Sets the number of bins in the coarse 1D mesh
735 fHBTprocessor->SetNBins1DCoarseMesh(n);
737 /*******************************************************************/
738 void AliGenHBTprocessor::SetBinSize1DCoarseMesh(Float_t x)
741 //Sets the bin size in the coarse 1D mesh
742 fBinsize_1d_coarse =x;
743 fHBTprocessor->SetBinSize1DCoarseMesh(x);
745 /*******************************************************************/
747 void AliGenHBTprocessor::SetNBins3DFineMesh(Int_t n)
750 //Sets the number of bins in the 3D mesh
752 fHBTprocessor->SetNBins3DFineMesh(n);
754 /*******************************************************************/
755 void AliGenHBTprocessor::SetBinSize3DFineMesh(Float_t x)
758 //Sets the bin size in the 3D mesh
760 fHBTprocessor->SetBinSize3DFineMesh(x);
762 /*******************************************************************/
764 void AliGenHBTprocessor::SetNBins3DCoarseMesh(Int_t n)
767 //Sets the number of bins in the coarse 3D mesh
770 fHBTprocessor->SetNBins3DCoarseMesh(n);
772 /*******************************************************************/
773 void AliGenHBTprocessor::SetBinSize3DCoarseMesh(Float_t x)
776 //Sets the bin size in the coarse 3D mesh
777 fBinsize_3d_coarse = x;
778 fHBTprocessor->SetBinSize3DCoarseMesh(x);
780 /*******************************************************************/
782 void AliGenHBTprocessor::SetNBins3DFineProjectMesh(Int_t n )
785 //Sets the number of bins in the fine project mesh
786 fN_3d_fine_project = n;
787 fHBTprocessor->SetNBins3DFineProjectMesh(n);
789 /*******************************************************************/
792 /*******************************************************************/
799 void AliGenHBTprocessor::DefineParticles()
802 // Load standard numbers for GEANT particles and PDG conversion
803 fNPDGCodes = 0; //this is done in the constructor - but in any case ...
805 fPDGCode[fNPDGCodes++]=-99; // 0 = unused location
806 fPDGCode[fNPDGCodes++]=22; // 1 = photon
807 fPDGCode[fNPDGCodes++]=-11; // 2 = positron
808 fPDGCode[fNPDGCodes++]=11; // 3 = electron
809 fPDGCode[fNPDGCodes++]=12; // 4 = neutrino e
810 fPDGCode[fNPDGCodes++]=-13; // 5 = muon +
811 fPDGCode[fNPDGCodes++]=13; // 6 = muon -
812 fPDGCode[fNPDGCodes++]=111; // 7 = pi0
813 fPDGCode[fNPDGCodes++]=211; // 8 = pi+
814 fPDGCode[fNPDGCodes++]=-211; // 9 = pi-
815 fPDGCode[fNPDGCodes++]=130; // 10 = Kaon Long
816 fPDGCode[fNPDGCodes++]=321; // 11 = Kaon +
817 fPDGCode[fNPDGCodes++]=-321; // 12 = Kaon -
818 fPDGCode[fNPDGCodes++]=2112; // 13 = Neutron
819 fPDGCode[fNPDGCodes++]=2212; // 14 = Proton
820 fPDGCode[fNPDGCodes++]=-2212; // 15 = Anti Proton
821 fPDGCode[fNPDGCodes++]=310; // 16 = Kaon Short
822 fPDGCode[fNPDGCodes++]=221; // 17 = Eta
823 fPDGCode[fNPDGCodes++]=3122; // 18 = Lambda
824 fPDGCode[fNPDGCodes++]=3222; // 19 = Sigma +
825 fPDGCode[fNPDGCodes++]=3212; // 20 = Sigma 0
826 fPDGCode[fNPDGCodes++]=3112; // 21 = Sigma -
827 fPDGCode[fNPDGCodes++]=3322; // 22 = Xi0
828 fPDGCode[fNPDGCodes++]=3312; // 23 = Xi-
829 fPDGCode[fNPDGCodes++]=3334; // 24 = Omega-
830 fPDGCode[fNPDGCodes++]=-2112; // 25 = Anti Proton
831 fPDGCode[fNPDGCodes++]=-3122; // 26 = Anti Proton
832 fPDGCode[fNPDGCodes++]=-3222; // 27 = Anti Sigma -
833 fPDGCode[fNPDGCodes++]=-3212; // 28 = Anti Sigma 0
834 fPDGCode[fNPDGCodes++]=-3112; // 29 = Anti Sigma 0
835 fPDGCode[fNPDGCodes++]=-3322; // 30 = Anti Xi 0
836 fPDGCode[fNPDGCodes++]=-3312; // 31 = Anti Xi +
837 fPDGCode[fNPDGCodes++]=-3334; // 32 = Anti Omega +
840 /*******************************************************************/
841 Int_t AliGenHBTprocessor::IdFromPDG(Int_t pdg) const
844 // Return Geant3 code from PDG and pseudo ENDF code
846 for(Int_t i=0;i<fNPDGCodes;++i)
847 if(pdg==fPDGCode[i]) return i;
850 Int_t AliGenHBTprocessor::PDGFromId(Int_t id) const
853 // Return PDG code and pseudo ENDF code from Geant3 code
855 if(id>0 && id<fNPDGCodes) return fPDGCode[id];
858 Double_t AliGenHBTprocessor::ThetaToEta(Double_t arg)
860 //converts etha(azimuthal angle) to Eta (pseudorapidity). Argument in radians
862 if(arg>= TMath::Pi()) return 709.0;//This number is the biggest wich not crashes exp(x)
863 if(arg<= 0.0) return -709.0;//
865 arg -= TMath::Pi()/2.;
868 return -TMath::Log( TMath::Tan(arg/2.)) ;
872 return TMath::Log( TMath::Tan(-arg/2.)) ;
876 /*******************************************************************/
877 /****** ROUTINES USED FOR COMMUNUCATION ********/
878 /******************** WITH FORTRAN ********************/
879 /*******************************************************************/
882 # define hbtpran hbtpran_
883 # define alihbtp_puttrack alihbtp_puttrack_
884 # define alihbtp_gettrack alihbtp_gettrack_
885 # define alihbtp_getnumberevents alihbtp_getnumberevents_
886 # define alihbtp_getnumbertracks alihbtp_getnumbertracks_
887 # define alihbtp_initialize alihbtp_initialize_
888 # define alihbtp_setactiveeventnumber alihbtp_setactiveeventnumber_
889 # define alihbtp_setparameters alihbtp_setparameters_
890 # define type_of_call
893 # define hbtpran HBTPRAN
894 # define alihbtp_puttrack ALIHBTP_PUTTRACK
895 # define alihbtp_gettrack ALIHBTP_GETTRACK
896 # define alihbtp_getnumberevents ALIHBTP_GETNUMBEREVENTS
897 # define alihbtp_getnumbertracks ALIHBTP_GETNUMBERTRACKS
898 # define alihbtp_initialize ALIHBTP_INITIALIZE
899 # define alihbtp_setactiveeventnumber ALIHBTP_SETACTIVEEVENTNUMBER
900 # define alihbtp_setparameters ALIHBTP_SETPARAMETERS
901 # define type_of_call _stdcall
904 #include "AliGenCocktailAfterBurner.h"
906 /*******************************************************************/
908 AliGenCocktailAfterBurner* GetGenerator()
910 // This function has two tasks:
911 // Check if environment is OK (exist gAlice and generator)
912 // Returns pointer to genrator
913 //to be changed with TFolders
917 cout<<endl<<"ERROR: There is NO gALICE! Check what you are doing!"<<endl;
918 gAlice->Fatal("AliGenHBTprocessor.cxx: alihbtp_getnumofev()",
919 "\nRunning HBT Processor without gAlice... Exiting \n");
922 AliGenerator * gen = gAlice->Generator();
926 gAlice->Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
927 "\nThere is no generator in gAlice, exiting\n");
931 const Char_t *genname = gen->GetName();
933 strcpy(name,"AliGenCocktailAfterBurner");
935 if (strcmp(name,genname))
937 gAlice->Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
938 "\nThe main Generator is not a AliGenCocktailAfterBurner, exiting\n");
942 AliGenCocktailAfterBurner* CAB= (AliGenCocktailAfterBurner*) gen;
944 // cout<<endl<<"Got generator"<<endl;
948 /*******************************************************************/
950 AliGenHBTprocessor* GetAliGenHBTprocessor()
952 //returns pointer to the current instance of AliGenHBTprocessor in
953 //AliGenCocktailAfterBurner (can be more than one)
955 AliGenCocktailAfterBurner* gen = GetGenerator();
956 AliGenerator * g = gen->GetCurrentGenerator();
958 const Char_t *genname = g->GetName();
960 strcpy(name,"AliGenHBTprocessor");
962 if (strcmp(name,genname))
964 gAlice->Fatal("AliGenHBTprocessor.cxx: GetAliGenHBTprocessor()",
965 "\nCurrernt generator in AliGenCocktailAfterBurner is not a AliGenHBTprocessor, exiting\n");
969 AliGenHBTprocessor* hbtp = (AliGenHBTprocessor*)g;
973 /*******************************************************************/
974 extern "C" void type_of_call alihbtp_setparameters()
979 extern "C" void type_of_call alihbtp_initialize()
984 /*******************************************************************/
986 extern "C" void type_of_call alihbtp_getnumberevents(Int_t &nev)
988 //passes number of events to the fortran
989 if(gDebug) cout<<"alihbtp_getnumberevents("<<nev<<") ....";
990 AliGenCocktailAfterBurner* gen = GetGenerator();
997 nev = gen->GetNumberOfEvents();
999 if(gDebug>5) cout<<"EXITED N Ev = "<<nev<<endl;
1003 /*******************************************************************/
1005 extern "C" void type_of_call alihbtp_setactiveeventnumber(Int_t & nev)
1007 //sets active event in generator (AliGenCocktailAfterBurner)
1009 if(gDebug>5) cout<<"alihbtp_setactiveeventnumber("<<nev<<") ....";
1010 if(gDebug>0) cout<<"Asked for event "<<nev-1<<endl;
1011 AliGenCocktailAfterBurner* gen = GetGenerator();
1013 gen->SetActiveEventNumber(nev - 1); //fortran numerates events from 1 to N
1015 if(gDebug>5) cout<<"EXITED returned "<<nev<<endl;
1018 /*******************************************************************/
1020 extern "C" void type_of_call alihbtp_getnumbertracks(Int_t &ntracks)
1022 //passes number of particles in active event to the fortran
1023 if(gDebug>5) cout<<"alihbtp_getnumbertracks("<<ntracks<<") ....";
1025 AliGenCocktailAfterBurner* gen = GetGenerator();
1032 ntracks = gen->GetActiveStack()->GetNprimary();
1033 if(gDebug>5) cout<<"EXITED Ntracks = "<<ntracks<<endl;
1036 /*******************************************************************/
1038 extern "C" void type_of_call
1039 alihbtp_puttrack(Int_t & n,Int_t& flag, Float_t& px,
1040 Float_t& py, Float_t& pz, Int_t& geantpid)
1042 //sets new parameters (momenta) in track number n
1043 // in the active event
1044 // n - number of the track in active event
1045 // flag - flag of the track
1046 // px,py,pz - momenta
1047 // geantpid - type of the particle - Geant Particle ID
1049 if(gDebug>5) cout<<"alihbtp_puttrack("<<n<<") ....";
1051 AliGenCocktailAfterBurner* gen = GetGenerator();
1054 TParticle * track = gen->GetActiveStack()->Particle(n-1);
1056 AliGenHBTprocessor* g = GetAliGenHBTprocessor();
1058 //check to be deleted
1059 if (geantpid != (g->IdFromPDG( track->GetPdgCode() )))
1061 cout<<endl<<" AliGenHBTprocessor.cxx: alihbtp_puttrack: SOMETHING IS GOING BAD:\n GEANTPIDS ARE NOT THE SAME"<<endl;
1065 if (px != track->Px())
1066 cout<<"Px diff. = "<<px - track->Px()<<endl;
1068 if(gDebug>3) cout<<" track->GetPdgCode() --> "<<track->GetPdgCode()<<endl;
1072 Float_t m = track->GetMass();
1073 Float_t E = TMath::Sqrt(m*m+px*px+py*py+pz*pz);
1074 track->SetMomentum(px,py,pz,E);
1076 g->SetHbtPStatusCode(flag,n-1);
1078 if(gDebug>5) cout<<"EXITED "<<endl;
1081 /*******************************************************************/
1083 extern "C" void type_of_call
1084 alihbtp_gettrack(Int_t & n,Int_t & flag, Float_t & px,
1085 Float_t & py, Float_t & pz, Int_t & geantpid)
1088 //passes track parameters to the fortran
1089 // n - number of the track in active event
1090 // flag - flag of the track
1091 // px,py,pz - momenta
1092 // geantpid - type of the particle - Geant Particle ID
1094 if(gDebug>5) cout<<"alihbtp_gettrack("<<n<<") ....";
1095 AliGenCocktailAfterBurner* gen = GetGenerator();
1106 TParticle * track = gen->GetActiveStack()->Particle(n-1);
1107 AliGenHBTprocessor* g = GetAliGenHBTprocessor();
1109 flag = g->GetHbtPStatusCode(n-1);
1111 px = (Float_t)track->Px();
1112 py = (Float_t)track->Py();
1113 pz = (Float_t)track->Pz();
1115 geantpid = g->IdFromPDG( track->GetPdgCode() );
1117 if(gDebug>5) cout<<"EXITED "<<endl;
1120 /*******************************************************************/
1121 extern "C" Float_t type_of_call hbtpran(Int_t &)
1123 //interface to the random number generator
1124 return sRandom->Rndm();
1127 /*******************************************************************/
1130 /*******************************************************************/