1 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
2 * See cxx source for full Copyright notice */
3 // Implementation of the interface for THBTprocessor
4 // Author: Piotr Krzysztof Skowronski <Piotr.Skowronski@cern.ch>
5 //////////////////////////////////////////////////////////////////////////////////
6 //Wrapper class for "hbt processor" after burner
7 //The origibal code is written in fortran by Lanny Ray
8 //and is put in the directory $ALICE_ROOT/HBTprocessor
9 //Detailed description is on the top of the file hbt_event_processor.f
11 //This class can be used ONLY with AliGenCocktailAfterBurner wrapper generator
14 // AliGenCocktailAfterBurner = gener = new AliGenCocktailAfterBurner();
15 // gener->SetPhiRange(0, 360); //Set global parameters
16 // gener->SetThetaRange(35., 145.);
17 // AliGenHIJINGpara *hijing = new AliGenHIJINGpara(10000); //Add some generator
18 // hijing->SetMomentumRange(0, 999);
19 // gener->AddGenerator(hijing,"HIJING PARAMETRIZATION",1);
21 // AliGenHBTprocessor *hbtp = new AliGenHBTprocessor(); //create object
22 // hbtp->SetRefControl(2); //set parameters
23 // hbtp->SetSwitch1D(1);
24 // hbtp->SetR0(6);//fm - radius
25 // hbtp->SetLambda(0.7);//chaocity parameter
26 // gener->AddAfterBurner(hbtp,"HBT PROCESSOR",1); //add to the main generator
31 // A) HBT PROCESSOR NEEDS MORE THAN ONE EVENT TO WORK
32 // AS MORE AS IT BETTER WORKS
33 // B) IT IS ABLE TO "ADD" CORRELATIONS ONLY UP TO TWO PARTICLE TYPES AT ONES
36 // Artificial particle dennsity enhancment feature
37 // HBT Processor is unable to process correctly low multiplicity particles
38 // even if the high statistics (more events) is supplied.
39 // For that reason was implemented artificial multiplicity enhancement
40 // - see also comments in HBT Processor source file (HBTP/hbt_event_processor.f)
41 // or web page (http://alisoft.cern.ch/people/skowron/hbtprocessor/hbteventprocessor.html)
42 // concerning trk_accep or SetTrackRejectionFactor method in this class
43 // Fortran is cheated by masking several events a single one. Number is defined by fEventMerge
44 // variable. In case it is equal to 1, there is no masking and the feature is off.
45 // But, for example if it is 5, and we have 100 events, number of events passed to fortran is 100/5=20
46 // When fortran asks about multiplcity of event, let sey, 1 - multiplicity of events 5 to 9 is summed up
50 //////////////////////////////////////////////////////////////////////////////////
52 // 11.11.2001 Piotr Skowronski
53 // Setting seed (date) in RNG in the constructor
55 // 09.10.2001 Piotr Skowronski
57 // Theta - Eta cohernecy facilities added:
58 // AliGenerator::SetThetaRange method overriden
59 // Static methods added
65 // Class description comments put on proper place
67 // 27.09.2001 Piotr Skowronski
68 // removing of redefinition of defaults velues
69 // in method's implementation.
73 #include "AliGenHBTprocessor.h"
75 #include <TParticle.h>
76 #include "THBTprocessor.h"
79 #include "AliGenCocktailAfterBurner.h"
84 ClassImp(AliGenHBTprocessor)
86 Int_t AliGenHBTprocessor::fgDebug = 0;
87 static TRandom* gAliRandom;//RNG to be used by the fortran code
89 AliGenCocktailAfterBurner* GetGenerator();
90 /*******************************************************************/
92 AliGenHBTprocessor::AliGenHBTprocessor():
97 fTrackRejectionFactor(0),
109 fEventLineCounter(0),
163 // Standard constructor
164 // Sets default veues of all parameters
166 SetName("AliGenHBTprocessor");
167 SetTitle("AliGenHBTprocessor");
169 gAliRandom = fRandom;
170 fHBTprocessor = new THBTprocessor();
175 SetTrackRejectionFactor();
195 SetSwitchCoherence();
197 SetSwitchFermiBose();
198 //SetMomentumRange();
211 SetNBins1DFineMesh();
212 SetBinSize1DFineMesh();
213 SetNBins1DCoarseMesh();
214 SetBinSize1DCoarseMesh();
215 SetNBins3DFineMesh();
216 SetBinSize3DFineMesh();
217 SetNBins3DCoarseMesh();
218 SetBinSize3DCoarseMesh();
219 SetNBins3DFineProjectMesh();
222 /*******************************************************************/
225 /*******************************************************************/
227 AliGenHBTprocessor::~AliGenHBTprocessor()
231 if (fHBTprocessor) delete fHBTprocessor; //delete generator
235 /*******************************************************************/
237 void AliGenHBTprocessor::InitStatusCodes()
239 //creates and inits status codes array to zero
240 AliGenCocktailAfterBurner *cab = GetGenerator();
242 if(!cab) Fatal("InitStatusCodes()","Can not find AliGenCocktailAfterBurner generator");
244 Int_t nev = cab->GetNumberOfEvents();
246 fHbtPStatCodes = new Int_t* [nev];
247 for( Int_t i =0; i<nev;i++)
249 Int_t nprim = cab->GetStack(i)->GetNprimary();
250 fHbtPStatCodes[i] = new Int_t[nprim];
251 for (Int_t k =0 ;k<nprim;k++)
252 fHbtPStatCodes[i][k] =0;
257 /*******************************************************************/
259 void AliGenHBTprocessor::CleanStatusCodes()
261 //Cleans up status codes
264 for (Int_t i =0; i<GetGenerator()->GetNumberOfEvents(); i++)
265 delete [] fHbtPStatCodes[i];
266 delete fHbtPStatCodes;
271 /*******************************************************************/
273 void AliGenHBTprocessor::Init()
275 //sets up parameters in generator
277 THBTprocessor *thbtp = fHBTprocessor;
280 thbtp->SetTrackRejectionFactor(fTrackRejectionFactor);
281 thbtp->SetRefControl(fReferenceControl);
283 if ((fPid[0] == fPid[1]) || (fPid[0] == 0) || (fPid[1] == 0))
286 thbtp->SetPIDs(IdFromPDG(fPid[1]) ,0);
288 thbtp->SetPIDs(IdFromPDG(fPid[0]) ,0);
289 thbtp->SetNPIDtypes(1);
292 Warning("AliGenHBTprocessor::Init","\nThere is only one particle type set,\n\
293 and Switch_Type differnt then 1,\n which does not make sense.\n\
294 Setting it to 1.\n");
300 thbtp->SetPIDs(IdFromPDG(fPid[0]) ,IdFromPDG(fPid[1]));
302 thbtp->SetSwitchType(fSwitchType);
305 thbtp->SetMaxIterations(fMaxit);
306 thbtp->SetDelChi(fDelchi);
307 thbtp->SetIRand(fIrand);
308 thbtp->SetLambda(fLambda);
310 thbtp->SetRSide(fRside);
311 thbtp->SetROut(fRout);
312 thbtp->SetRLong(fRlong);
313 thbtp->SetRPerp(fRperp);
314 thbtp->SetRParallel(fRparallel);
317 thbtp->SetSwitch1D(fSwitch1d);
318 thbtp->SetSwitch3D(fSwitch3d);
319 thbtp->SetSwitchType(fSwitchType);
320 thbtp->SetSwitchCoherence(fSwitchCoherence);
321 thbtp->SetSwitchCoulomb(fSwitchCoulomb);
322 thbtp->SetSwitchFermiBose(fSwitchFermiBose);
323 thbtp->SetPtRange(fPtMin,fPtMax);
324 thbtp->SetPxRange(fPxMin,fPxMax);
325 thbtp->SetPyRange(fPyMin,fPyMax);
326 thbtp->SetPzRange(fPzMin,fPzMax);
327 thbtp->SetPhiRange(fPhiMin*180./((Float_t)TMath::Pi())+180.0, //casting is because if fPhiMin = 180.0 then
328 fPhiMax*180./((Float_t)TMath::Pi())+180.0);//TMath::Pi() != TMath::Pi()*fPhiMin/180.0,
329 thbtp->SetEtaRange(fEtaMin,fEtaMax);
330 thbtp->SetNPtBins(fNPtBins);
331 thbtp->SetNPhiBins(fNPhiBins);
332 thbtp->SetNEtaBins(fNEtaBins);
333 thbtp->SetNPxBins(fNPxBins);
334 thbtp->SetNPyBins(fNPyBins);
335 thbtp->SetNPzBins(fNPzBins);
336 thbtp->SetNBins1DFineMesh(fN1dFine);
337 thbtp->SetBinSize1DFineMesh(fBinsize1dFine);
338 thbtp->SetNBins1DCoarseMesh(fN1dCoarse);
339 thbtp->SetBinSize1DCoarseMesh(fBinsize1dCoarse);
340 thbtp->SetNBins3DFineMesh(fN3dFine);
341 thbtp->SetBinSize3DFineMesh(fBinsize3dFine);
342 thbtp->SetNBins3DCoarseMesh(fN3dCoarse);
343 thbtp->SetBinSize3DCoarseMesh(fBinsize3dCoarse);
344 thbtp->SetNBins3DFineProjectMesh(fN3dFineProject);
346 thbtp->SetPrintFull(fPrintFull);
349 /*******************************************************************/
351 void AliGenHBTprocessor::Generate()
354 AliGenCocktailAfterBurner* cab = GetGenerator();
357 Fatal("Generate()","AliGenHBTprocessor needs AliGenCocktailAfterBurner to be main generator");
359 if (cab->GetNumberOfEvents() <2)
362 "HBT Processor needs more than 1 event to work properly,\
363 but there is only %d set", cab->GetNumberOfEvents());
367 fHBTprocessor->Initialize(); //reset all fields of common blocks
368 //in case there are many HBT processors
369 //run one after one (i.e. in AliCocktailAfterBurner)
370 //between Init() called and Generate there might
371 Init(); //be different instance running - be sure that we have our settings
373 InitStatusCodes(); //Init status codes
375 fHBTprocessor->GenerateEvent(); //Generates event
377 CleanStatusCodes(); //Clean Status codes - thet are not needed anymore
380 /*******************************************************************/
383 /*******************************************************************/
384 void AliGenHBTprocessor::GetParticles(TClonesArray * particles) const
389 Error("GetParticles","Particles has to be initialized");
392 fHBTprocessor->ImportParticles(particles);
395 /*******************************************************************/
397 Int_t AliGenHBTprocessor::GetHbtPStatusCode(Int_t part) const
399 //returns the status code of the given particle in the active event
400 //see SetActiveEvent in the bottom of AliGenHBTprocessor.cxx
401 //and in AliCocktailAfterBurner
403 GetTrackEventIndex(part,ev,idx);
404 if ( (ev<0) || (idx<0) )
406 Error("GetHbtPStatusCode","GetTrackEventIndex returned error");
409 return fHbtPStatCodes[ev][idx];
413 /*******************************************************************/
414 void AliGenHBTprocessor::SetHbtPStatusCode(Int_t hbtstatcode, Int_t part)
416 //Sets the given status code to given particle number (part) in the active event
418 GetTrackEventIndex(part,ev,idx);
419 if ( (ev<0) || (idx<0) )
421 Error("GetHbtPStatusCode","GetTrackEventIndex returned error");
424 else fHbtPStatCodes[ev][idx] = hbtstatcode;
427 /*******************************************************************/
429 void AliGenHBTprocessor::SetTrackRejectionFactor(Float_t trf) //def 1.0
431 //Sets the Track Rejection Factor
432 //variates in range 0.0 <-> 1.0
433 //Describes the factor of particles rejected from the output.
434 //Used only in case of low muliplicity particles e.g. lambdas.
435 //Processor generates addisional particles and builds the
436 //correletions on such a statistics.
437 //At the end these particels are left in the event according
438 //to this factor: 1==all particles are left
439 // 0==all are removed
441 fTrackRejectionFactor=trf;
442 fHBTprocessor->SetTrackRejectionFactor(trf);
444 /*******************************************************************/
446 void AliGenHBTprocessor::SetRefControl(Int_t rc) //default 2
448 //Sets the Refernce Control Switch
449 //switch wether read reference histograms from file =1
450 // compute from input events =2 - default
451 fReferenceControl=rc;
452 fHBTprocessor->SetRefControl(rc);
454 /*******************************************************************/
456 void AliGenHBTprocessor::SetPIDs(Int_t pid1,Int_t pid2)
459 //Sets PDG Codes of particles to be processed, default \\Pi^{+} and \\Pi^{-}
460 //This method accepts PDG codes which is
461 //in opposite to THBBProcessor which accepts GEANT PID
462 if ( (pid1 == 0) && (pid2 == 0) )
464 Error("AliGenHBTprocessor::SetPIDs","Sensless Particle Types setting: 0 0, Ignoring\n");
472 fHBTprocessor->SetPIDs(IdFromPDG(pid1) ,0);
478 fHBTprocessor->SetPIDs(IdFromPDG(pid1) ,IdFromPDG(pid2));
482 /*******************************************************************/
484 void AliGenHBTprocessor::SetNPIDtypes(Int_t npidt)
486 //Number ofparticle types to be processed - default 2
487 //see AliGenHBTprocessor::SetPIDs
490 fHBTprocessor->SetNPIDtypes(npidt);
492 /*******************************************************************/
494 void AliGenHBTprocessor::SetDeltap(Float_t deltp)
497 //maximum range for random momentum shifts in GeV/c;
498 //px,py,pz independent; Default = 0.1 GeV/c.
500 fHBTprocessor->SetDeltap(deltp);
502 /*******************************************************************/
504 void AliGenHBTprocessor::SetMaxIterations(Int_t maxiter)
506 //maximum # allowed iterations thru all the
507 //tracks for each event. Default = 50.
508 //If maxit=0, then calculate the correlations
509 //for the input set of events without doing the
510 //track adjustment procedure.
513 fHBTprocessor->SetMaxIterations(maxiter);
516 /*******************************************************************/
517 void AliGenHBTprocessor::SetDelChi(Float_t dc)
519 //min % change in total chi-square for which
520 //the track adjustment iterations may stop,
524 fHBTprocessor->SetDelChi(dc);
526 /*******************************************************************/
528 void AliGenHBTprocessor::SetIRand(Int_t irnd)
530 //if fact dummy - used only for compatibility
531 //we are using AliRoot built in RNG
532 //dummy in fact since we are using aliroot build-in RNG
533 //Sets renaodom number generator
535 fHBTprocessor->SetIRand(irnd);
537 /*******************************************************************/
539 void AliGenHBTprocessor::SetLambda(Float_t lam)
542 // Sets Chaoticity Parameter
544 fHBTprocessor->SetLambda(lam);
546 /*******************************************************************/
547 void AliGenHBTprocessor::SetR1d(Float_t r)
550 //Sets Spherical source model radius (fm)
552 fHBTprocessor->SetR1d(r);
554 /*******************************************************************/
555 void AliGenHBTprocessor::SetRSide(Float_t rs)
558 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
561 fHBTprocessor->SetRSide(rs);
563 /*******************************************************************/
564 void AliGenHBTprocessor::SetROut(Float_t ro)
567 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
569 fHBTprocessor->SetROut(ro);
571 /*******************************************************************/
572 void AliGenHBTprocessor::SetRLong(Float_t rl)
575 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
577 fHBTprocessor->SetRLong(rl);
579 /*******************************************************************/
580 void AliGenHBTprocessor::SetRPerp(Float_t rp)
583 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
585 fHBTprocessor->SetRPerp(rp);
587 /*******************************************************************/
588 void AliGenHBTprocessor::SetRParallel(Float_t rprl)
591 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
593 fHBTprocessor->SetRParallel(rprl);
595 /*******************************************************************/
596 void AliGenHBTprocessor::SetR0(Float_t r0)
599 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
601 fHBTprocessor->SetR0(r0);
603 /*******************************************************************/
604 void AliGenHBTprocessor::SetQ0(Float_t q0)
607 //Sets Q0 = NA35 Coulomb parameter for finite source size in (GeV/c)
608 // if fSwitchCoulomb = 2
609 // = Spherical Coulomb source radius in (fm)
610 // if switchCoulomb = 3, used to interpolate the
611 // input Pratt/Cramer discrete Coulomb source
614 fHBTprocessor->SetQ0(q0);
617 /*******************************************************************/
618 void AliGenHBTprocessor::SetSwitch1D(Int_t s1d)
622 // = 0 to not compute the 1D two-body //orrelations.
623 // = 1 to compute this using Q-invariant
624 // = 2 to compute this using Q-total
625 // = 3 to compute this using Q-3-ve//tor
628 fHBTprocessor->SetSwitch1D(s1d);
630 /*******************************************************************/
631 void AliGenHBTprocessor::SetSwitch3D(Int_t s3d)
635 // = 0 to not compute the 3D two-body correlations.
636 // = 1 to compute this using the side-out-long form
637 // = 2 to compute this using the Yanno-Koonin-Pogoredskij form.
640 fHBTprocessor->SetSwitch3D(s3d);
642 /*******************************************************************/
643 void AliGenHBTprocessor::SetSwitchType(Int_t st)
646 // Sets switch_type = 1 to fit only the like pair correlations
647 // = 2 to fit only the unlike pair correlations
648 // = 3 to fit both the like and unlike pair correl.
649 //See SetPIDs and Init
650 //If only one particle type is set, unly==1 makes sens
653 fHBTprocessor->SetSwitchType(st);
655 /*******************************************************************/
656 void AliGenHBTprocessor::SetSwitchCoherence(Int_t sc)
659 // switchCoherence = 0 for purely incoherent source (but can have
661 // = 1 for mixed incoherent and coherent source
663 fSwitchCoherence = sc;
664 fHBTprocessor->SetSwitchCoherence(sc);
666 /*******************************************************************/
667 void AliGenHBTprocessor::SetSwitchCoulomb(Int_t scol)
670 // switchCoulomb = 0 no Coulomb correction
671 // = 1 Point source Gamow correction only
672 // = 2 NA35 finite source size correction
673 // = 3 Pratt/Cramer finite source size correction;
674 // interpolated from input tables.
675 fSwitchCoulomb =scol;
676 fHBTprocessor->SetSwitchCoulomb(scol);
678 /*******************************************************************/
679 void AliGenHBTprocessor::SetSwitchFermiBose(Int_t sfb)
682 // switchFermiBose = 1 Boson pairs
683 // = -1 Fermion pairs
685 fSwitchFermiBose = sfb;
686 fHBTprocessor->SetSwitchFermiBose(sfb);
688 /*******************************************************************/
689 void AliGenHBTprocessor::SetPtRange(Float_t ptmin, Float_t ptmax)
691 // default ptmin = 0.1, ptmax = 0.98
692 //Sets Pt range (GeV)
693 AliGenerator::SetPtRange(ptmin,ptmax);
694 fHBTprocessor->SetPtRange(ptmin,ptmax);
697 /*******************************************************************/
698 void AliGenHBTprocessor::SetPxRange(Float_t pxmin, Float_t pxmax)
700 //default pxmin = -1.0, pxmax = 1.0
704 fHBTprocessor->SetPxRange(pxmin,pxmax);
706 /*******************************************************************/
707 void AliGenHBTprocessor::SetPyRange(Float_t pymin, Float_t pymax)
709 //default pymin = -1.0, pymax = 1.0
713 fHBTprocessor->SetPyRange(pymin,pymax);
715 /*******************************************************************/
716 void AliGenHBTprocessor::SetPzRange(Float_t pzmin, Float_t pzmax)
718 //default pzmin = -3.6, pzmax = 3.6
722 fHBTprocessor->SetPzRange(pzmin,pzmax);
724 void AliGenHBTprocessor::SetMomentumRange(Float_t /*pmin*/, Float_t /*pmax*/)
726 //default pmin=0, pmax=0
727 //Do not use this method!
728 MayNotUse("AliGenHBTprocessor::SetMomentumRange Method is Dummy");
731 /*******************************************************************/
732 void AliGenHBTprocessor::SetPhiRange(Float_t phimin, Float_t phimax)
736 AliGenerator::SetPhiRange(phimin,phimax);
738 fHBTprocessor->SetPhiRange(phimin+180.0,phimax+180.0);
740 /*******************************************************************/
741 void AliGenHBTprocessor::SetEtaRange(Float_t etamin, Float_t etamax)
743 //default etamin = -1.5, etamax = 1.5
747 fHBTprocessor->SetEtaRange(etamin,etamax);
749 //set the azimothal angle range in the AliGeneraor -
750 //to keep coherency between azimuthal angle and pseudorapidity
751 //DO NOT CALL this->SetThetaRange, because it calls this method (where we are)
752 //which must cause INFINITE LOOP
753 AliGenerator::SetThetaRange(RadiansToDegrees(EtaToTheta(fEtaMin)),
754 RadiansToDegrees(EtaToTheta(fEtaMax)));
757 /*******************************************************************/
758 void AliGenHBTprocessor::SetThetaRange(Float_t thetamin, Float_t thetamax)
760 //default thetamin = 0, thetamax = 180
761 //Azimuthal angle, override AliGenerator method which uses widely (i.e. wrapper generators)
762 //core fortran HBTProcessor uses Eta (pseudorapidity)
763 //so these methods has to be synchronized
765 AliGenerator::SetThetaRange(thetamin,thetamax);
767 SetEtaRange( ThetaToEta(fThetaMin) , ThetaToEta(fThetaMax) );
771 /*******************************************************************/
772 void AliGenHBTprocessor::SetNPtBins(Int_t nptbin)
774 //default nptbin = 50
775 //set number of Pt bins
777 fHBTprocessor->SetNPtBins(nptbin);
779 /*******************************************************************/
780 void AliGenHBTprocessor::SetNPhiBins(Int_t nphibin)
782 //default nphibin = 50
783 //set number of Phi bins
785 fHBTprocessor->SetNPhiBins(nphibin);
787 /*******************************************************************/
788 void AliGenHBTprocessor::SetNEtaBins(Int_t netabin)
790 //default netabin = 50
791 //set number of Eta bins
793 fHBTprocessor->SetNEtaBins(netabin);
795 /*******************************************************************/
796 void AliGenHBTprocessor::SetNPxBins(Int_t npxbin)
798 //default npxbin = 20
799 //set number of Px bins
801 fHBTprocessor->SetNPxBins(npxbin);
803 /*******************************************************************/
804 void AliGenHBTprocessor::SetNPyBins(Int_t npybin)
806 //default npybin = 20
807 //set number of Py bins
809 fHBTprocessor->SetNPyBins(npybin);
811 /*******************************************************************/
812 void AliGenHBTprocessor::SetNPzBins(Int_t npzbin)
814 //default npzbin = 70
815 //set number of Pz bins
817 fHBTprocessor->SetNPzBins(npzbin);
819 /*******************************************************************/
820 void AliGenHBTprocessor::SetNBins1DFineMesh(Int_t n)
823 //Sets the number of bins in the 1D mesh
825 fHBTprocessor->SetNBins1DFineMesh(n);
828 /*******************************************************************/
829 void AliGenHBTprocessor::SetBinSize1DFineMesh(Float_t x)
832 //Sets the bin size in the 1D mesh
834 fHBTprocessor->SetBinSize1DFineMesh(x);
836 /*******************************************************************/
838 void AliGenHBTprocessor::SetNBins1DCoarseMesh(Int_t n)
841 //Sets the number of bins in the coarse 1D mesh
843 fHBTprocessor->SetNBins1DCoarseMesh(n);
845 /*******************************************************************/
846 void AliGenHBTprocessor::SetBinSize1DCoarseMesh(Float_t x)
849 //Sets the bin size in the coarse 1D mesh
851 fHBTprocessor->SetBinSize1DCoarseMesh(x);
853 /*******************************************************************/
855 void AliGenHBTprocessor::SetNBins3DFineMesh(Int_t n)
858 //Sets the number of bins in the 3D mesh
860 fHBTprocessor->SetNBins3DFineMesh(n);
862 /*******************************************************************/
863 void AliGenHBTprocessor::SetBinSize3DFineMesh(Float_t x)
866 //Sets the bin size in the 3D mesh
868 fHBTprocessor->SetBinSize3DFineMesh(x);
870 /*******************************************************************/
872 void AliGenHBTprocessor::SetNBins3DCoarseMesh(Int_t n)
875 //Sets the number of bins in the coarse 3D mesh
878 fHBTprocessor->SetNBins3DCoarseMesh(n);
880 /*******************************************************************/
881 void AliGenHBTprocessor::SetBinSize3DCoarseMesh(Float_t x)
884 //Sets the bin size in the coarse 3D mesh
885 fBinsize3dCoarse = x;
886 fHBTprocessor->SetBinSize3DCoarseMesh(x);
888 /*******************************************************************/
890 void AliGenHBTprocessor::SetNBins3DFineProjectMesh(Int_t n )
893 //Sets the number of bins in the fine project mesh
895 fHBTprocessor->SetNBins3DFineProjectMesh(n);
897 /*******************************************************************/
898 void AliGenHBTprocessor::SetPrintFull(Int_t flag)
900 //sets the print full flag
902 fHBTprocessor->SetPrintFull(flag);
906 /*******************************************************************/
908 Int_t AliGenHBTprocessor::GetNumberOfEvents()
910 //returns number of available events
911 AliGenerator* g = gAlice->Generator();
912 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
915 Fatal("GetNumberOfEvents","Master Generator is not an AliGenCocktailAfterBurner");
918 return (Int_t)TMath::Ceil(cab->GetNumberOfEvents()/((Float_t)fEventMerge));
921 /*******************************************************************/
923 void AliGenHBTprocessor::SetActiveEventNumber(Int_t n)
925 //sets the active event
926 fActiveStack = n*fEventMerge;
927 AliDebug(1,Form("Settimg active event %d passed %d",fActiveStack,n));
929 /*******************************************************************/
931 Int_t AliGenHBTprocessor::GetNumberOfTracks()
933 //returns number of tracks in active event
934 AliGenerator* g = gAlice->Generator();
935 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
938 Fatal("GetNumberOfEvents","Master Generator is not an AliGenCocktailAfterBurner");
942 for (Int_t i = fActiveStack;i < fActiveStack+fEventMerge; i++)
944 if (i >= GetNumberOfEvents()) break; //protection not to overshoot nb of events
945 AliStack* stack = cab->GetStack(i);
947 Error("GetNumberOfTracks","There is no stack %d",i);
949 n+=stack->GetNprimary();
953 /*******************************************************************/
955 void AliGenHBTprocessor::SetNEventsToMerge(Int_t nev)
957 //sets number of events to merge
958 if (nev > 0 ) fEventMerge = nev;
960 /*******************************************************************/
962 TParticle* AliGenHBTprocessor::GetTrack(Int_t n)
964 //returns track that hbtp thinks is n in active event
965 AliDebug(5,Form("n = %d",n));
966 AliGenerator* g = gAlice->Generator();
967 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
970 Fatal("GetTrackEventIndex","Master Generator is not an AliGenCocktailAfterBurner");
975 GetTrackEventIndex(n,ev,idx);
976 AliDebug(5,Form("Event = %d Particle = %d",ev,idx));
977 if ( (ev<0) || (idx<0) )
979 Error("GetTrack","GetTrackEventIndex returned error");
982 AliDebug(5,Form("Number of Tracks in Event(%d) = %d",ev,cab->GetStack(ev)->GetNprimary()));
983 return cab->GetStack(ev)->Particle(idx);//safe - in case stack does not exist
985 /*******************************************************************/
987 void AliGenHBTprocessor::GetTrackEventIndex(Int_t n, Int_t &evno, Int_t &index) const
989 //returns event(stack) number and particle index
990 AliGenerator* g = gAlice->Generator();
991 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
994 Fatal("GetTrackEventIndex","Master Generator is not an AliGenCocktailAfterBurner");
1000 for (Int_t i = fActiveStack;i < fActiveStack+fEventMerge; i++)
1002 AliStack* stack = cab->GetStack(i);
1005 Error("GetTrackEventIndex","There is no stack %d",i);
1009 Int_t ntracks = stack->GetNprimary();
1010 AliDebug(10,Form("Event %d has %d tracks. n = %d",i,ntracks,n));
1024 Error("GetTrackEventIndex","Could not find given track");
1027 /*******************************************************************/
1028 /*******************************************************************/
1029 /*******************************************************************/
1035 void AliGenHBTprocessor::DefineParticles()
1038 // Load standard numbers for GEANT particles and PDG conversion
1039 fNPDGCodes = 0; //this is done in the constructor - but in any case ...
1041 fPDGCode[fNPDGCodes++]=-99; // 0 = unused location
1042 fPDGCode[fNPDGCodes++]=22; // 1 = photon
1043 fPDGCode[fNPDGCodes++]=-11; // 2 = positron
1044 fPDGCode[fNPDGCodes++]=11; // 3 = electron
1045 fPDGCode[fNPDGCodes++]=12; // 4 = neutrino e
1046 fPDGCode[fNPDGCodes++]=-13; // 5 = muon +
1047 fPDGCode[fNPDGCodes++]=13; // 6 = muon -
1048 fPDGCode[fNPDGCodes++]=111; // 7 = pi0
1049 fPDGCode[fNPDGCodes++]=211; // 8 = pi+
1050 fPDGCode[fNPDGCodes++]=-211; // 9 = pi-
1051 fPDGCode[fNPDGCodes++]=130; // 10 = Kaon Long
1052 fPDGCode[fNPDGCodes++]=321; // 11 = Kaon +
1053 fPDGCode[fNPDGCodes++]=-321; // 12 = Kaon -
1054 fPDGCode[fNPDGCodes++]=2112; // 13 = Neutron
1055 fPDGCode[fNPDGCodes++]=2212; // 14 = Proton
1056 fPDGCode[fNPDGCodes++]=-2212; // 15 = Anti Proton
1057 fPDGCode[fNPDGCodes++]=310; // 16 = Kaon Short
1058 fPDGCode[fNPDGCodes++]=221; // 17 = Eta
1059 fPDGCode[fNPDGCodes++]=3122; // 18 = Lambda
1060 fPDGCode[fNPDGCodes++]=3222; // 19 = Sigma +
1061 fPDGCode[fNPDGCodes++]=3212; // 20 = Sigma 0
1062 fPDGCode[fNPDGCodes++]=3112; // 21 = Sigma -
1063 fPDGCode[fNPDGCodes++]=3322; // 22 = Xi0
1064 fPDGCode[fNPDGCodes++]=3312; // 23 = Xi-
1065 fPDGCode[fNPDGCodes++]=3334; // 24 = Omega-
1066 fPDGCode[fNPDGCodes++]=-2112; // 25 = Anti Proton
1067 fPDGCode[fNPDGCodes++]=-3122; // 26 = Anti Proton
1068 fPDGCode[fNPDGCodes++]=-3222; // 27 = Anti Sigma -
1069 fPDGCode[fNPDGCodes++]=-3212; // 28 = Anti Sigma 0
1070 fPDGCode[fNPDGCodes++]=-3112; // 29 = Anti Sigma 0
1071 fPDGCode[fNPDGCodes++]=-3322; // 30 = Anti Xi 0
1072 fPDGCode[fNPDGCodes++]=-3312; // 31 = Anti Xi +
1073 fPDGCode[fNPDGCodes++]=-3334; // 32 = Anti Omega +
1076 /*******************************************************************/
1077 Int_t AliGenHBTprocessor::IdFromPDG(Int_t pdg) const
1080 // Return Geant3 code from PDG and pseudo ENDF code
1082 for(Int_t i=0;i<fNPDGCodes;++i)
1083 if(pdg==fPDGCode[i]) return i;
1086 Int_t AliGenHBTprocessor::PDGFromId(Int_t id) const
1089 // Return PDG code and pseudo ENDF code from Geant3 code
1091 if(id>0 && id<fNPDGCodes) return fPDGCode[id];
1094 Double_t AliGenHBTprocessor::ThetaToEta(Double_t arg)
1096 //converts etha(azimuthal angle) to Eta (pseudorapidity). Argument in radians
1098 if(arg>= TMath::Pi()) return 708.0;//This number is the biggest wich not crashes exp(x)
1099 if(arg<= 0.0) return -708.0;//
1100 if(arg == TMath::Pi()/2.) return 0.0;//
1104 return TMath::Log( TMath::Tan(arg/2.)) ;
1108 return -TMath::Log( TMath::Tan(-arg/2.)) ;
1112 /*******************************************************************/
1113 /****** ROUTINES USED FOR COMMUNUCATION ********/
1114 /******************** WITH FORTRAN ********************/
1115 /*******************************************************************/
1118 # define hbtpran hbtpran_
1119 # define alihbtp_puttrack alihbtp_puttrack_
1120 # define alihbtp_gettrack alihbtp_gettrack_
1121 # define alihbtp_getnumberevents alihbtp_getnumberevents_
1122 # define alihbtp_getnumbertracks alihbtp_getnumbertracks_
1123 # define alihbtp_initialize alihbtp_initialize_
1124 # define alihbtp_setactiveeventnumber alihbtp_setactiveeventnumber_
1125 # define alihbtp_setparameters alihbtp_setparameters_
1126 # define type_ofCall
1129 # define hbtpran HBTPRAN
1130 # define alihbtp_puttrack ALIHBTP_PUTTRACK
1131 # define alihbtp_gettrack ALIHBTP_GETTRACK
1132 # define alihbtp_getnumberevents ALIHBTP_GETNUMBEREVENTS
1133 # define alihbtp_getnumbertracks ALIHBTP_GETNUMBERTRACKS
1134 # define alihbtp_initialize ALIHBTP_INITIALIZE
1135 # define alihbtp_setactiveeventnumber ALIHBTP_SETACTIVEEVENTNUMBER
1136 # define alihbtp_setparameters ALIHBTP_SETPARAMETERS
1137 # define type_ofCall _stdcall
1140 /*******************************************************************/
1142 AliGenCocktailAfterBurner* GetGenerator()
1144 // This function has two tasks:
1145 // Check if environment is OK (exist gAlice and generator)
1146 // Returns pointer to genrator
1147 //to be changed with TFolders
1151 ::Error("AliGenHBTprocessor.cxx: GetGenerator()",
1152 "There is NO gALICE! Check what you are doing!");
1153 ::Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
1154 "Running HBT Processor without gAlice... Exiting \n");
1155 return 0x0;//pro forma
1157 AliGenerator * gen = gAlice->Generator();
1161 ::Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
1162 "There is no generator in gAlice, exiting\n");
1166 //we do not sure actual type of the genetator
1167 //and simple casting is risky - we use ROOT machinery to do safe cast
1169 TClass* cabclass = AliGenCocktailAfterBurner::Class(); //get AliGenCocktailAfterBurner TClass
1170 TClass* genclass = gen->IsA();//get TClass of the generator we got from galice
1171 //use casting implemented in TClass
1172 //cast gen to cabclass
1173 AliGenCocktailAfterBurner* cab=(AliGenCocktailAfterBurner*)genclass->DynamicCast(cabclass,gen);
1175 if (cab == 0x0)//if generator that we got is not AliGenCocktailAfterBurner or its descendant we get null
1176 { //then quit with error
1177 ::Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
1178 "The main Generator is not a AliGenCocktailAfterBurner, exiting\n");
1183 /*******************************************************************/
1185 AliGenHBTprocessor* GetAliGenHBTprocessor()
1187 //returns pointer to the current instance of AliGenHBTprocessor in
1188 //AliGenCocktailAfterBurner (can be more than one)
1190 AliGenCocktailAfterBurner* gen = GetGenerator();
1191 AliGenerator* g = gen->GetCurrentGenerator();
1194 ::Fatal("AliGenHBTprocessor.cxx: GetAliGenHBTprocessor()",
1195 "Can not get the current generator. Exiting");
1196 return 0x0;//pro forma
1199 TClass* hbtpclass = AliGenHBTprocessor::Class(); //get AliGenCocktailAfterBurner TClass
1200 TClass* gclass = g->IsA();//get TClass of the current generator we got from CAB
1201 AliGenHBTprocessor* hbtp = (AliGenHBTprocessor*)gclass->DynamicCast(hbtpclass,g);//try to cast
1204 ::Fatal("AliGenHBTprocessor.cxx: GetAliGenHBTprocessor()",
1205 "\nCurrernt generator in AliGenCocktailAfterBurner is not a AliGenHBTprocessor, exiting\n");
1211 /*******************************************************************/
1212 extern "C" void type_ofCall alihbtp_setparameters()
1217 extern "C" void type_ofCall alihbtp_initialize()
1222 /*******************************************************************/
1224 extern "C" void type_ofCall alihbtp_getnumberevents(Int_t &nev)
1226 //passes number of events to the fortran
1227 if(AliGenHBTprocessor::GetDebug())
1228 AliInfoGeneral("alihbtp_getnumberevents",Form("(%d) ....",nev));
1230 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1231 nev = gen->GetNumberOfEvents();
1233 if(AliGenHBTprocessor::GetDebug()>5)
1234 AliInfoGeneral("alihbtp_getnumberevents",Form("EXITED N Ev = %d",nev));
1237 /*******************************************************************/
1239 extern "C" void type_ofCall alihbtp_setactiveeventnumber(Int_t & nev)
1241 //sets active event in generator (AliGenCocktailAfterBurner)
1243 if(AliGenHBTprocessor::GetDebug()>5)
1244 ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","(%d)",nev);
1245 if(AliGenHBTprocessor::GetDebug()>0)
1246 ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","Asked for event %d",nev-1);
1248 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1250 gen->SetActiveEventNumber(nev - 1); //fortran numerates events from 1 to N
1252 if(AliGenHBTprocessor::GetDebug()>5)
1253 ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","EXITED returned %d",nev);
1255 /*******************************************************************/
1257 extern "C" void type_ofCall alihbtp_getnumbertracks(Int_t &ntracks)
1259 //passes number of particles in active event to the fortran
1260 if(AliGenHBTprocessor::GetDebug()>5)
1261 ::Info("AliGenHBTpocessor.cxx: alihbtp_getnumbertracks","(%d)",ntracks);
1263 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1265 ntracks = gen->GetNumberOfTracks();
1266 if(AliGenHBTprocessor::GetDebug()>5)
1267 ::Info("AliGenHBTpocessor.cxx: alihbtp_getnumbertracks","EXITED Ntracks = %d",ntracks);
1270 /*******************************************************************/
1272 extern "C" void type_ofCall
1273 alihbtp_puttrack(Int_t & n,Int_t& flag, Float_t& px,
1274 Float_t& py, Float_t& pz, Int_t& geantpid)
1276 //sets new parameters (momenta) in track number n
1277 // in the active event
1278 // n - number of the track in active event
1279 // flag - flag of the track
1280 // px,py,pz - momenta
1281 // geantpid - type of the particle - Geant Particle ID
1283 if(AliGenHBTprocessor::GetDebug()>5)
1284 ::Info("AliGenHBTpocessor.cxx: alihbtp_puttrack","(%d)",n);
1286 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1288 TParticle * track = gen->GetTrack(n-1);
1291 ::Error("AliGenHBTprocessor.cxx","Can not get track from AliGenHBTprocessor");
1295 //check to be deleted
1296 if (geantpid != (gen->IdFromPDG( track->GetPdgCode() )))
1298 ::Error("AliGenHBTprocessor.cxx: alihbtp_puttrack",
1299 "SOMETHING IS GOING BAD:\n GEANTPIDS ARE NOT THE SAME");
1302 if(AliGenHBTprocessor::GetDebug()>0)
1303 if (px != track->Px())
1304 ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack",
1305 "Px diff. = %f", px - track->Px());
1307 if(AliGenHBTprocessor::GetDebug()>3)
1308 ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack",
1309 "track->GetPdgCode() --> %d",track->GetPdgCode());
1313 Float_t m = track->GetMass();
1314 Float_t e = TMath::Sqrt(m*m+px*px+py*py+pz*pz);
1315 track->SetMomentum(px,py,pz,e);
1317 gen->SetHbtPStatusCode(flag,n-1);
1319 if(AliGenHBTprocessor::GetDebug()>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack","EXITED ");
1322 /*******************************************************************/
1324 extern "C" void type_ofCall
1325 alihbtp_gettrack(Int_t & n,Int_t & flag, Float_t & px,
1326 Float_t & py, Float_t & pz, Int_t & geantpid)
1329 //passes track parameters to the fortran
1330 // n - number of the track in active event
1331 // flag - flag of the track
1332 // px,py,pz - momenta
1333 // geantpid - type of the particle - Geant Particle ID
1335 if(AliGenHBTprocessor::GetDebug()>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","(%d)",n);
1336 AliGenHBTprocessor* g = GetAliGenHBTprocessor();
1338 TParticle * track = g->GetTrack(n-1);
1340 flag = g->GetHbtPStatusCode(n-1);
1342 px = (Float_t)track->Px();
1343 py = (Float_t)track->Py();
1344 pz = (Float_t)track->Pz();
1346 geantpid = g->IdFromPDG( track->GetPdgCode() );
1348 if(AliGenHBTprocessor::GetDebug()>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","EXITED");
1351 /*******************************************************************/
1352 extern "C" Float_t type_ofCall hbtpran(Int_t &)
1354 //interface to the random number generator
1355 return gAliRandom->Rndm();
1358 /*******************************************************************/
1361 /*******************************************************************/