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"
80 #include "AliGenCocktailAfterBurner.h"
85 ClassImp(AliGenHBTprocessor)
87 Int_t AliGenHBTprocessor::fgDebug = 0;
88 static TRandom* gAliRandom;//RNG to be used by the fortran code
90 AliGenCocktailAfterBurner* GetGenerator();
91 /*******************************************************************/
93 AliGenHBTprocessor::AliGenHBTprocessor():
98 fTrackRejectionFactor(0),
110 fEventLineCounter(0),
164 // Standard constructor
165 // Sets default veues of all parameters
167 SetName("AliGenHBTprocessor");
168 SetTitle("AliGenHBTprocessor");
170 gAliRandom = fRandom;
171 fHBTprocessor = new THBTprocessor();
176 SetTrackRejectionFactor();
196 SetSwitchCoherence();
198 SetSwitchFermiBose();
199 //SetMomentumRange();
212 SetNBins1DFineMesh();
213 SetBinSize1DFineMesh();
214 SetNBins1DCoarseMesh();
215 SetBinSize1DCoarseMesh();
216 SetNBins3DFineMesh();
217 SetBinSize3DFineMesh();
218 SetNBins3DCoarseMesh();
219 SetBinSize3DCoarseMesh();
220 SetNBins3DFineProjectMesh();
223 /*******************************************************************/
226 /*******************************************************************/
228 AliGenHBTprocessor::~AliGenHBTprocessor()
232 if (fHBTprocessor) delete fHBTprocessor; //delete generator
236 /*******************************************************************/
238 void AliGenHBTprocessor::InitStatusCodes()
240 //creates and inits status codes array to zero
241 AliGenCocktailAfterBurner *cab = GetGenerator();
243 if(!cab) Fatal("InitStatusCodes()","Can not find AliGenCocktailAfterBurner generator");
245 Int_t nev = cab->GetNumberOfEvents();
247 fHbtPStatCodes = new Int_t* [nev];
248 for( Int_t i =0; i<nev;i++)
250 Int_t nprim = cab->GetStack(i)->GetNprimary();
251 fHbtPStatCodes[i] = new Int_t[nprim];
252 for (Int_t k =0 ;k<nprim;k++)
253 fHbtPStatCodes[i][k] =0;
258 /*******************************************************************/
260 void AliGenHBTprocessor::CleanStatusCodes()
262 //Cleans up status codes
265 for (Int_t i =0; i<GetGenerator()->GetNumberOfEvents(); i++)
266 delete [] fHbtPStatCodes[i];
267 delete fHbtPStatCodes;
272 /*******************************************************************/
274 void AliGenHBTprocessor::Init()
276 //sets up parameters in generator
278 THBTprocessor *thbtp = fHBTprocessor;
281 thbtp->SetTrackRejectionFactor(fTrackRejectionFactor);
282 thbtp->SetRefControl(fReferenceControl);
284 if ((fPid[0] == fPid[1]) || (fPid[0] == 0) || (fPid[1] == 0))
287 thbtp->SetPIDs(IdFromPDG(fPid[1]) ,0);
289 thbtp->SetPIDs(IdFromPDG(fPid[0]) ,0);
290 thbtp->SetNPIDtypes(1);
293 Warning("AliGenHBTprocessor::Init","\nThere is only one particle type set,\n\
294 and Switch_Type differnt then 1,\n which does not make sense.\n\
295 Setting it to 1.\n");
301 thbtp->SetPIDs(IdFromPDG(fPid[0]) ,IdFromPDG(fPid[1]));
303 thbtp->SetSwitchType(fSwitchType);
306 thbtp->SetMaxIterations(fMaxit);
307 thbtp->SetDelChi(fDelchi);
308 thbtp->SetIRand(fIrand);
309 thbtp->SetLambda(fLambda);
311 thbtp->SetRSide(fRside);
312 thbtp->SetROut(fRout);
313 thbtp->SetRLong(fRlong);
314 thbtp->SetRPerp(fRperp);
315 thbtp->SetRParallel(fRparallel);
318 thbtp->SetSwitch1D(fSwitch1d);
319 thbtp->SetSwitch3D(fSwitch3d);
320 thbtp->SetSwitchType(fSwitchType);
321 thbtp->SetSwitchCoherence(fSwitchCoherence);
322 thbtp->SetSwitchCoulomb(fSwitchCoulomb);
323 thbtp->SetSwitchFermiBose(fSwitchFermiBose);
324 thbtp->SetPtRange(fPtMin,fPtMax);
325 thbtp->SetPxRange(fPxMin,fPxMax);
326 thbtp->SetPyRange(fPyMin,fPyMax);
327 thbtp->SetPzRange(fPzMin,fPzMax);
328 thbtp->SetPhiRange(fPhiMin*180./((Float_t)TMath::Pi())+180.0, //casting is because if fPhiMin = 180.0 then
329 fPhiMax*180./((Float_t)TMath::Pi())+180.0);//TMath::Pi() != TMath::Pi()*fPhiMin/180.0,
330 thbtp->SetEtaRange(fEtaMin,fEtaMax);
331 thbtp->SetNPtBins(fNPtBins);
332 thbtp->SetNPhiBins(fNPhiBins);
333 thbtp->SetNEtaBins(fNEtaBins);
334 thbtp->SetNPxBins(fNPxBins);
335 thbtp->SetNPyBins(fNPyBins);
336 thbtp->SetNPzBins(fNPzBins);
337 thbtp->SetNBins1DFineMesh(fN1dFine);
338 thbtp->SetBinSize1DFineMesh(fBinsize1dFine);
339 thbtp->SetNBins1DCoarseMesh(fN1dCoarse);
340 thbtp->SetBinSize1DCoarseMesh(fBinsize1dCoarse);
341 thbtp->SetNBins3DFineMesh(fN3dFine);
342 thbtp->SetBinSize3DFineMesh(fBinsize3dFine);
343 thbtp->SetNBins3DCoarseMesh(fN3dCoarse);
344 thbtp->SetBinSize3DCoarseMesh(fBinsize3dCoarse);
345 thbtp->SetNBins3DFineProjectMesh(fN3dFineProject);
347 thbtp->SetPrintFull(fPrintFull);
350 /*******************************************************************/
352 void AliGenHBTprocessor::Generate()
355 AliGenCocktailAfterBurner* cab = GetGenerator();
358 Fatal("Generate()","AliGenHBTprocessor needs AliGenCocktailAfterBurner to be main generator");
360 if (cab->GetNumberOfEvents() <2)
363 "HBT Processor needs more than 1 event to work properly,\
364 but there is only %d set", cab->GetNumberOfEvents());
368 fHBTprocessor->Initialize(); //reset all fields of common blocks
369 //in case there are many HBT processors
370 //run one after one (i.e. in AliCocktailAfterBurner)
371 //between Init() called and Generate there might
372 Init(); //be different instance running - be sure that we have our settings
374 InitStatusCodes(); //Init status codes
376 fHBTprocessor->GenerateEvent(); //Generates event
378 CleanStatusCodes(); //Clean Status codes - thet are not needed anymore
381 /*******************************************************************/
384 /*******************************************************************/
385 void AliGenHBTprocessor::GetParticles(TClonesArray * particles) const
390 Error("GetParticles","Particles has to be initialized");
393 fHBTprocessor->ImportParticles(particles);
396 /*******************************************************************/
398 Int_t AliGenHBTprocessor::GetHbtPStatusCode(Int_t part) const
400 //returns the status code of the given particle in the active event
401 //see SetActiveEvent in the bottom of AliGenHBTprocessor.cxx
402 //and in AliCocktailAfterBurner
404 GetTrackEventIndex(part,ev,idx);
405 if ( (ev<0) || (idx<0) )
407 Error("GetHbtPStatusCode","GetTrackEventIndex returned error");
410 return fHbtPStatCodes[ev][idx];
414 /*******************************************************************/
415 void AliGenHBTprocessor::SetHbtPStatusCode(Int_t hbtstatcode, Int_t part)
417 //Sets the given status code to given particle number (part) in the active event
419 GetTrackEventIndex(part,ev,idx);
420 if ( (ev<0) || (idx<0) )
422 Error("GetHbtPStatusCode","GetTrackEventIndex returned error");
425 else fHbtPStatCodes[ev][idx] = hbtstatcode;
428 /*******************************************************************/
430 void AliGenHBTprocessor::SetTrackRejectionFactor(Float_t trf) //def 1.0
432 //Sets the Track Rejection Factor
433 //variates in range 0.0 <-> 1.0
434 //Describes the factor of particles rejected from the output.
435 //Used only in case of low muliplicity particles e.g. lambdas.
436 //Processor generates addisional particles and builds the
437 //correletions on such a statistics.
438 //At the end these particels are left in the event according
439 //to this factor: 1==all particles are left
440 // 0==all are removed
442 fTrackRejectionFactor=trf;
443 fHBTprocessor->SetTrackRejectionFactor(trf);
445 /*******************************************************************/
447 void AliGenHBTprocessor::SetRefControl(Int_t rc) //default 2
449 //Sets the Refernce Control Switch
450 //switch wether read reference histograms from file =1
451 // compute from input events =2 - default
452 fReferenceControl=rc;
453 fHBTprocessor->SetRefControl(rc);
455 /*******************************************************************/
457 void AliGenHBTprocessor::SetPIDs(Int_t pid1,Int_t pid2)
460 //Sets PDG Codes of particles to be processed, default \\Pi^{+} and \\Pi^{-}
461 //This method accepts PDG codes which is
462 //in opposite to THBBProcessor which accepts GEANT PID
463 if ( (pid1 == 0) && (pid2 == 0) )
465 Error("AliGenHBTprocessor::SetPIDs","Sensless Particle Types setting: 0 0, Ignoring\n");
473 fHBTprocessor->SetPIDs(IdFromPDG(pid1) ,0);
479 fHBTprocessor->SetPIDs(IdFromPDG(pid1) ,IdFromPDG(pid2));
483 /*******************************************************************/
485 void AliGenHBTprocessor::SetNPIDtypes(Int_t npidt)
487 //Number ofparticle types to be processed - default 2
488 //see AliGenHBTprocessor::SetPIDs
491 fHBTprocessor->SetNPIDtypes(npidt);
493 /*******************************************************************/
495 void AliGenHBTprocessor::SetDeltap(Float_t deltp)
498 //maximum range for random momentum shifts in GeV/c;
499 //px,py,pz independent; Default = 0.1 GeV/c.
501 fHBTprocessor->SetDeltap(deltp);
503 /*******************************************************************/
505 void AliGenHBTprocessor::SetMaxIterations(Int_t maxiter)
507 //maximum # allowed iterations thru all the
508 //tracks for each event. Default = 50.
509 //If maxit=0, then calculate the correlations
510 //for the input set of events without doing the
511 //track adjustment procedure.
514 fHBTprocessor->SetMaxIterations(maxiter);
517 /*******************************************************************/
518 void AliGenHBTprocessor::SetDelChi(Float_t dc)
520 //min % change in total chi-square for which
521 //the track adjustment iterations may stop,
525 fHBTprocessor->SetDelChi(dc);
527 /*******************************************************************/
529 void AliGenHBTprocessor::SetIRand(Int_t irnd)
531 //if fact dummy - used only for compatibility
532 //we are using AliRoot built in RNG
533 //dummy in fact since we are using aliroot build-in RNG
534 //Sets renaodom number generator
536 fHBTprocessor->SetIRand(irnd);
538 /*******************************************************************/
540 void AliGenHBTprocessor::SetLambda(Float_t lam)
543 // Sets Chaoticity Parameter
545 fHBTprocessor->SetLambda(lam);
547 /*******************************************************************/
548 void AliGenHBTprocessor::SetR1d(Float_t r)
551 //Sets Spherical source model radius (fm)
553 fHBTprocessor->SetR1d(r);
555 /*******************************************************************/
556 void AliGenHBTprocessor::SetRSide(Float_t rs)
559 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
562 fHBTprocessor->SetRSide(rs);
564 /*******************************************************************/
565 void AliGenHBTprocessor::SetROut(Float_t ro)
568 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
570 fHBTprocessor->SetROut(ro);
572 /*******************************************************************/
573 void AliGenHBTprocessor::SetRLong(Float_t rl)
576 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
578 fHBTprocessor->SetRLong(rl);
580 /*******************************************************************/
581 void AliGenHBTprocessor::SetRPerp(Float_t rp)
584 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
586 fHBTprocessor->SetRPerp(rp);
588 /*******************************************************************/
589 void AliGenHBTprocessor::SetRParallel(Float_t rprl)
592 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
594 fHBTprocessor->SetRParallel(rprl);
596 /*******************************************************************/
597 void AliGenHBTprocessor::SetR0(Float_t r0)
600 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
602 fHBTprocessor->SetR0(r0);
604 /*******************************************************************/
605 void AliGenHBTprocessor::SetQ0(Float_t q0)
608 //Sets Q0 = NA35 Coulomb parameter for finite source size in (GeV/c)
609 // if fSwitchCoulomb = 2
610 // = Spherical Coulomb source radius in (fm)
611 // if switchCoulomb = 3, used to interpolate the
612 // input Pratt/Cramer discrete Coulomb source
615 fHBTprocessor->SetQ0(q0);
618 /*******************************************************************/
619 void AliGenHBTprocessor::SetSwitch1D(Int_t s1d)
623 // = 0 to not compute the 1D two-body //orrelations.
624 // = 1 to compute this using Q-invariant
625 // = 2 to compute this using Q-total
626 // = 3 to compute this using Q-3-ve//tor
629 fHBTprocessor->SetSwitch1D(s1d);
631 /*******************************************************************/
632 void AliGenHBTprocessor::SetSwitch3D(Int_t s3d)
636 // = 0 to not compute the 3D two-body correlations.
637 // = 1 to compute this using the side-out-long form
638 // = 2 to compute this using the Yanno-Koonin-Pogoredskij form.
641 fHBTprocessor->SetSwitch3D(s3d);
643 /*******************************************************************/
644 void AliGenHBTprocessor::SetSwitchType(Int_t st)
647 // Sets switch_type = 1 to fit only the like pair correlations
648 // = 2 to fit only the unlike pair correlations
649 // = 3 to fit both the like and unlike pair correl.
650 //See SetPIDs and Init
651 //If only one particle type is set, unly==1 makes sens
654 fHBTprocessor->SetSwitchType(st);
656 /*******************************************************************/
657 void AliGenHBTprocessor::SetSwitchCoherence(Int_t sc)
660 // switchCoherence = 0 for purely incoherent source (but can have
662 // = 1 for mixed incoherent and coherent source
664 fSwitchCoherence = sc;
665 fHBTprocessor->SetSwitchCoherence(sc);
667 /*******************************************************************/
668 void AliGenHBTprocessor::SetSwitchCoulomb(Int_t scol)
671 // switchCoulomb = 0 no Coulomb correction
672 // = 1 Point source Gamow correction only
673 // = 2 NA35 finite source size correction
674 // = 3 Pratt/Cramer finite source size correction;
675 // interpolated from input tables.
676 fSwitchCoulomb =scol;
677 fHBTprocessor->SetSwitchCoulomb(scol);
679 /*******************************************************************/
680 void AliGenHBTprocessor::SetSwitchFermiBose(Int_t sfb)
683 // switchFermiBose = 1 Boson pairs
684 // = -1 Fermion pairs
686 fSwitchFermiBose = sfb;
687 fHBTprocessor->SetSwitchFermiBose(sfb);
689 /*******************************************************************/
690 void AliGenHBTprocessor::SetPtRange(Float_t ptmin, Float_t ptmax)
692 // default ptmin = 0.1, ptmax = 0.98
693 //Sets Pt range (GeV)
694 AliGenerator::SetPtRange(ptmin,ptmax);
695 fHBTprocessor->SetPtRange(ptmin,ptmax);
698 /*******************************************************************/
699 void AliGenHBTprocessor::SetPxRange(Float_t pxmin, Float_t pxmax)
701 //default pxmin = -1.0, pxmax = 1.0
705 fHBTprocessor->SetPxRange(pxmin,pxmax);
707 /*******************************************************************/
708 void AliGenHBTprocessor::SetPyRange(Float_t pymin, Float_t pymax)
710 //default pymin = -1.0, pymax = 1.0
714 fHBTprocessor->SetPyRange(pymin,pymax);
716 /*******************************************************************/
717 void AliGenHBTprocessor::SetPzRange(Float_t pzmin, Float_t pzmax)
719 //default pzmin = -3.6, pzmax = 3.6
723 fHBTprocessor->SetPzRange(pzmin,pzmax);
725 void AliGenHBTprocessor::SetMomentumRange(Float_t /*pmin*/, Float_t /*pmax*/)
727 //default pmin=0, pmax=0
728 //Do not use this method!
729 MayNotUse("AliGenHBTprocessor::SetMomentumRange Method is Dummy");
732 /*******************************************************************/
733 void AliGenHBTprocessor::SetPhiRange(Float_t phimin, Float_t phimax)
737 AliGenerator::SetPhiRange(phimin,phimax);
739 fHBTprocessor->SetPhiRange(phimin+180.0,phimax+180.0);
741 /*******************************************************************/
742 void AliGenHBTprocessor::SetEtaRange(Float_t etamin, Float_t etamax)
744 //default etamin = -1.5, etamax = 1.5
748 fHBTprocessor->SetEtaRange(etamin,etamax);
750 //set the azimothal angle range in the AliGeneraor -
751 //to keep coherency between azimuthal angle and pseudorapidity
752 //DO NOT CALL this->SetThetaRange, because it calls this method (where we are)
753 //which must cause INFINITE LOOP
754 AliGenerator::SetThetaRange(RadiansToDegrees(EtaToTheta(fEtaMin)),
755 RadiansToDegrees(EtaToTheta(fEtaMax)));
758 /*******************************************************************/
759 void AliGenHBTprocessor::SetThetaRange(Float_t thetamin, Float_t thetamax)
761 //default thetamin = 0, thetamax = 180
762 //Azimuthal angle, override AliGenerator method which uses widely (i.e. wrapper generators)
763 //core fortran HBTProcessor uses Eta (pseudorapidity)
764 //so these methods has to be synchronized
766 AliGenerator::SetThetaRange(thetamin,thetamax);
768 SetEtaRange( ThetaToEta(fThetaMin) , ThetaToEta(fThetaMax) );
772 /*******************************************************************/
773 void AliGenHBTprocessor::SetNPtBins(Int_t nptbin)
775 //default nptbin = 50
776 //set number of Pt bins
778 fHBTprocessor->SetNPtBins(nptbin);
780 /*******************************************************************/
781 void AliGenHBTprocessor::SetNPhiBins(Int_t nphibin)
783 //default nphibin = 50
784 //set number of Phi bins
786 fHBTprocessor->SetNPhiBins(nphibin);
788 /*******************************************************************/
789 void AliGenHBTprocessor::SetNEtaBins(Int_t netabin)
791 //default netabin = 50
792 //set number of Eta bins
794 fHBTprocessor->SetNEtaBins(netabin);
796 /*******************************************************************/
797 void AliGenHBTprocessor::SetNPxBins(Int_t npxbin)
799 //default npxbin = 20
800 //set number of Px bins
802 fHBTprocessor->SetNPxBins(npxbin);
804 /*******************************************************************/
805 void AliGenHBTprocessor::SetNPyBins(Int_t npybin)
807 //default npybin = 20
808 //set number of Py bins
810 fHBTprocessor->SetNPyBins(npybin);
812 /*******************************************************************/
813 void AliGenHBTprocessor::SetNPzBins(Int_t npzbin)
815 //default npzbin = 70
816 //set number of Pz bins
818 fHBTprocessor->SetNPzBins(npzbin);
820 /*******************************************************************/
821 void AliGenHBTprocessor::SetNBins1DFineMesh(Int_t n)
824 //Sets the number of bins in the 1D mesh
826 fHBTprocessor->SetNBins1DFineMesh(n);
829 /*******************************************************************/
830 void AliGenHBTprocessor::SetBinSize1DFineMesh(Float_t x)
833 //Sets the bin size in the 1D mesh
835 fHBTprocessor->SetBinSize1DFineMesh(x);
837 /*******************************************************************/
839 void AliGenHBTprocessor::SetNBins1DCoarseMesh(Int_t n)
842 //Sets the number of bins in the coarse 1D mesh
844 fHBTprocessor->SetNBins1DCoarseMesh(n);
846 /*******************************************************************/
847 void AliGenHBTprocessor::SetBinSize1DCoarseMesh(Float_t x)
850 //Sets the bin size in the coarse 1D mesh
852 fHBTprocessor->SetBinSize1DCoarseMesh(x);
854 /*******************************************************************/
856 void AliGenHBTprocessor::SetNBins3DFineMesh(Int_t n)
859 //Sets the number of bins in the 3D mesh
861 fHBTprocessor->SetNBins3DFineMesh(n);
863 /*******************************************************************/
864 void AliGenHBTprocessor::SetBinSize3DFineMesh(Float_t x)
867 //Sets the bin size in the 3D mesh
869 fHBTprocessor->SetBinSize3DFineMesh(x);
871 /*******************************************************************/
873 void AliGenHBTprocessor::SetNBins3DCoarseMesh(Int_t n)
876 //Sets the number of bins in the coarse 3D mesh
879 fHBTprocessor->SetNBins3DCoarseMesh(n);
881 /*******************************************************************/
882 void AliGenHBTprocessor::SetBinSize3DCoarseMesh(Float_t x)
885 //Sets the bin size in the coarse 3D mesh
886 fBinsize3dCoarse = x;
887 fHBTprocessor->SetBinSize3DCoarseMesh(x);
889 /*******************************************************************/
891 void AliGenHBTprocessor::SetNBins3DFineProjectMesh(Int_t n )
894 //Sets the number of bins in the fine project mesh
896 fHBTprocessor->SetNBins3DFineProjectMesh(n);
898 /*******************************************************************/
899 void AliGenHBTprocessor::SetPrintFull(Int_t flag)
901 //sets the print full flag
903 fHBTprocessor->SetPrintFull(flag);
907 /*******************************************************************/
909 Int_t AliGenHBTprocessor::GetNumberOfEvents()
911 //returns number of available events
912 AliGenerator* g = gAlice->GetMCApp()->Generator();
913 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
916 Fatal("GetNumberOfEvents","Master Generator is not an AliGenCocktailAfterBurner");
919 return (Int_t)TMath::Ceil(cab->GetNumberOfEvents()/((Float_t)fEventMerge));
922 /*******************************************************************/
924 void AliGenHBTprocessor::SetActiveEventNumber(Int_t n)
926 //sets the active event
927 fActiveStack = n*fEventMerge;
928 AliDebug(1,Form("Settimg active event %d passed %d",fActiveStack,n));
930 /*******************************************************************/
932 Int_t AliGenHBTprocessor::GetNumberOfTracks()
934 //returns number of tracks in active event
935 AliGenerator* g = gAlice->GetMCApp()->Generator();
936 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
939 Fatal("GetNumberOfEvents","Master Generator is not an AliGenCocktailAfterBurner");
943 for (Int_t i = fActiveStack;i < fActiveStack+fEventMerge; i++)
945 if (i >= GetNumberOfEvents()) break; //protection not to overshoot nb of events
946 AliStack* stack = cab->GetStack(i);
948 Error("GetNumberOfTracks","There is no stack %d",i);
950 n+=stack->GetNprimary();
954 /*******************************************************************/
956 void AliGenHBTprocessor::SetNEventsToMerge(Int_t nev)
958 //sets number of events to merge
959 if (nev > 0 ) fEventMerge = nev;
961 /*******************************************************************/
963 TParticle* AliGenHBTprocessor::GetTrack(Int_t n)
965 //returns track that hbtp thinks is n in active event
966 AliDebug(5,Form("n = %d",n));
967 AliGenerator* g = gAlice->GetMCApp()->Generator();
968 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
971 Fatal("GetTrackEventIndex","Master Generator is not an AliGenCocktailAfterBurner");
976 GetTrackEventIndex(n,ev,idx);
977 AliDebug(5,Form("Event = %d Particle = %d",ev,idx));
978 if ( (ev<0) || (idx<0) )
980 Error("GetTrack","GetTrackEventIndex returned error");
983 AliDebug(5,Form("Number of Tracks in Event(%d) = %d",ev,cab->GetStack(ev)->GetNprimary()));
984 return cab->GetStack(ev)->Particle(idx);//safe - in case stack does not exist
986 /*******************************************************************/
988 void AliGenHBTprocessor::GetTrackEventIndex(Int_t n, Int_t &evno, Int_t &index) const
990 //returns event(stack) number and particle index
991 AliGenerator* g = gAlice->GetMCApp()->Generator();
992 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
995 Fatal("GetTrackEventIndex","Master Generator is not an AliGenCocktailAfterBurner");
1001 for (Int_t i = fActiveStack;i < fActiveStack+fEventMerge; i++)
1003 AliStack* stack = cab->GetStack(i);
1006 Error("GetTrackEventIndex","There is no stack %d",i);
1010 Int_t ntracks = stack->GetNprimary();
1011 AliDebug(10,Form("Event %d has %d tracks. n = %d",i,ntracks,n));
1025 Error("GetTrackEventIndex","Could not find given track");
1028 /*******************************************************************/
1029 /*******************************************************************/
1030 /*******************************************************************/
1036 void AliGenHBTprocessor::DefineParticles()
1039 // Load standard numbers for GEANT particles and PDG conversion
1040 fNPDGCodes = 0; //this is done in the constructor - but in any case ...
1042 fPDGCode[fNPDGCodes++]=-99; // 0 = unused location
1043 fPDGCode[fNPDGCodes++]=22; // 1 = photon
1044 fPDGCode[fNPDGCodes++]=-11; // 2 = positron
1045 fPDGCode[fNPDGCodes++]=11; // 3 = electron
1046 fPDGCode[fNPDGCodes++]=12; // 4 = neutrino e
1047 fPDGCode[fNPDGCodes++]=-13; // 5 = muon +
1048 fPDGCode[fNPDGCodes++]=13; // 6 = muon -
1049 fPDGCode[fNPDGCodes++]=111; // 7 = pi0
1050 fPDGCode[fNPDGCodes++]=211; // 8 = pi+
1051 fPDGCode[fNPDGCodes++]=-211; // 9 = pi-
1052 fPDGCode[fNPDGCodes++]=130; // 10 = Kaon Long
1053 fPDGCode[fNPDGCodes++]=321; // 11 = Kaon +
1054 fPDGCode[fNPDGCodes++]=-321; // 12 = Kaon -
1055 fPDGCode[fNPDGCodes++]=2112; // 13 = Neutron
1056 fPDGCode[fNPDGCodes++]=2212; // 14 = Proton
1057 fPDGCode[fNPDGCodes++]=-2212; // 15 = Anti Proton
1058 fPDGCode[fNPDGCodes++]=310; // 16 = Kaon Short
1059 fPDGCode[fNPDGCodes++]=221; // 17 = Eta
1060 fPDGCode[fNPDGCodes++]=3122; // 18 = Lambda
1061 fPDGCode[fNPDGCodes++]=3222; // 19 = Sigma +
1062 fPDGCode[fNPDGCodes++]=3212; // 20 = Sigma 0
1063 fPDGCode[fNPDGCodes++]=3112; // 21 = Sigma -
1064 fPDGCode[fNPDGCodes++]=3322; // 22 = Xi0
1065 fPDGCode[fNPDGCodes++]=3312; // 23 = Xi-
1066 fPDGCode[fNPDGCodes++]=3334; // 24 = Omega-
1067 fPDGCode[fNPDGCodes++]=-2112; // 25 = Anti Proton
1068 fPDGCode[fNPDGCodes++]=-3122; // 26 = Anti Proton
1069 fPDGCode[fNPDGCodes++]=-3222; // 27 = Anti Sigma -
1070 fPDGCode[fNPDGCodes++]=-3212; // 28 = Anti Sigma 0
1071 fPDGCode[fNPDGCodes++]=-3112; // 29 = Anti Sigma 0
1072 fPDGCode[fNPDGCodes++]=-3322; // 30 = Anti Xi 0
1073 fPDGCode[fNPDGCodes++]=-3312; // 31 = Anti Xi +
1074 fPDGCode[fNPDGCodes++]=-3334; // 32 = Anti Omega +
1077 /*******************************************************************/
1078 Int_t AliGenHBTprocessor::IdFromPDG(Int_t pdg) const
1081 // Return Geant3 code from PDG and pseudo ENDF code
1083 for(Int_t i=0;i<fNPDGCodes;++i)
1084 if(pdg==fPDGCode[i]) return i;
1087 Int_t AliGenHBTprocessor::PDGFromId(Int_t id) const
1090 // Return PDG code and pseudo ENDF code from Geant3 code
1092 if(id>0 && id<fNPDGCodes) return fPDGCode[id];
1095 Double_t AliGenHBTprocessor::ThetaToEta(Double_t arg)
1097 //converts etha(azimuthal angle) to Eta (pseudorapidity). Argument in radians
1099 if(arg>= TMath::Pi()) return 708.0;//This number is the biggest wich not crashes exp(x)
1100 if(arg<= 0.0) return -708.0;//
1101 if(arg == TMath::Pi()/2.) return 0.0;//
1105 return TMath::Log( TMath::Tan(arg/2.)) ;
1109 return -TMath::Log( TMath::Tan(-arg/2.)) ;
1113 /*******************************************************************/
1114 /****** ROUTINES USED FOR COMMUNUCATION ********/
1115 /******************** WITH FORTRAN ********************/
1116 /*******************************************************************/
1119 # define hbtpran hbtpran_
1120 # define alihbtp_puttrack alihbtp_puttrack_
1121 # define alihbtp_gettrack alihbtp_gettrack_
1122 # define alihbtp_getnumberevents alihbtp_getnumberevents_
1123 # define alihbtp_getnumbertracks alihbtp_getnumbertracks_
1124 # define alihbtp_initialize alihbtp_initialize_
1125 # define alihbtp_setactiveeventnumber alihbtp_setactiveeventnumber_
1126 # define alihbtp_setparameters alihbtp_setparameters_
1127 # define type_ofCall
1130 # define hbtpran HBTPRAN
1131 # define alihbtp_puttrack ALIHBTP_PUTTRACK
1132 # define alihbtp_gettrack ALIHBTP_GETTRACK
1133 # define alihbtp_getnumberevents ALIHBTP_GETNUMBEREVENTS
1134 # define alihbtp_getnumbertracks ALIHBTP_GETNUMBERTRACKS
1135 # define alihbtp_initialize ALIHBTP_INITIALIZE
1136 # define alihbtp_setactiveeventnumber ALIHBTP_SETACTIVEEVENTNUMBER
1137 # define alihbtp_setparameters ALIHBTP_SETPARAMETERS
1138 # define type_ofCall _stdcall
1141 /*******************************************************************/
1143 AliGenCocktailAfterBurner* GetGenerator()
1145 // This function has two tasks:
1146 // Check if environment is OK (exist gAlice and generator)
1147 // Returns pointer to genrator
1148 //to be changed with TFolders
1152 ::Error("AliGenHBTprocessor.cxx: GetGenerator()",
1153 "There is NO gALICE! Check what you are doing!");
1154 ::Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
1155 "Running HBT Processor without gAlice... Exiting \n");
1156 return 0x0;//pro forma
1158 AliGenerator * gen = gAlice->GetMCApp()->Generator();
1162 ::Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
1163 "There is no generator in gAlice, exiting\n");
1167 //we do not sure actual type of the genetator
1168 //and simple casting is risky - we use ROOT machinery to do safe cast
1170 TClass* cabclass = AliGenCocktailAfterBurner::Class(); //get AliGenCocktailAfterBurner TClass
1171 TClass* genclass = gen->IsA();//get TClass of the generator we got from galice
1172 //use casting implemented in TClass
1173 //cast gen to cabclass
1174 AliGenCocktailAfterBurner* cab=(AliGenCocktailAfterBurner*)genclass->DynamicCast(cabclass,gen);
1176 if (cab == 0x0)//if generator that we got is not AliGenCocktailAfterBurner or its descendant we get null
1177 { //then quit with error
1178 ::Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
1179 "The main Generator is not a AliGenCocktailAfterBurner, exiting\n");
1184 /*******************************************************************/
1186 AliGenHBTprocessor* GetAliGenHBTprocessor()
1188 //returns pointer to the current instance of AliGenHBTprocessor in
1189 //AliGenCocktailAfterBurner (can be more than one)
1191 AliGenCocktailAfterBurner* gen = GetGenerator();
1192 AliGenerator* g = gen->GetCurrentGenerator();
1195 ::Fatal("AliGenHBTprocessor.cxx: GetAliGenHBTprocessor()",
1196 "Can not get the current generator. Exiting");
1197 return 0x0;//pro forma
1200 TClass* hbtpclass = AliGenHBTprocessor::Class(); //get AliGenCocktailAfterBurner TClass
1201 TClass* gclass = g->IsA();//get TClass of the current generator we got from CAB
1202 AliGenHBTprocessor* hbtp = (AliGenHBTprocessor*)gclass->DynamicCast(hbtpclass,g);//try to cast
1205 ::Fatal("AliGenHBTprocessor.cxx: GetAliGenHBTprocessor()",
1206 "\nCurrernt generator in AliGenCocktailAfterBurner is not a AliGenHBTprocessor, exiting\n");
1212 /*******************************************************************/
1213 extern "C" void type_ofCall alihbtp_setparameters()
1218 extern "C" void type_ofCall alihbtp_initialize()
1223 /*******************************************************************/
1225 extern "C" void type_ofCall alihbtp_getnumberevents(Int_t &nev)
1227 //passes number of events to the fortran
1228 if(AliGenHBTprocessor::GetDebug())
1229 AliInfoGeneral("alihbtp_getnumberevents",Form("(%d) ....",nev));
1231 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1232 nev = gen->GetNumberOfEvents();
1234 if(AliGenHBTprocessor::GetDebug()>5)
1235 AliInfoGeneral("alihbtp_getnumberevents",Form("EXITED N Ev = %d",nev));
1238 /*******************************************************************/
1240 extern "C" void type_ofCall alihbtp_setactiveeventnumber(Int_t & nev)
1242 //sets active event in generator (AliGenCocktailAfterBurner)
1244 if(AliGenHBTprocessor::GetDebug()>5)
1245 ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","(%d)",nev);
1246 if(AliGenHBTprocessor::GetDebug()>0)
1247 ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","Asked for event %d",nev-1);
1249 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1251 gen->SetActiveEventNumber(nev - 1); //fortran numerates events from 1 to N
1253 if(AliGenHBTprocessor::GetDebug()>5)
1254 ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","EXITED returned %d",nev);
1256 /*******************************************************************/
1258 extern "C" void type_ofCall alihbtp_getnumbertracks(Int_t &ntracks)
1260 //passes number of particles in active event to the fortran
1261 if(AliGenHBTprocessor::GetDebug()>5)
1262 ::Info("AliGenHBTpocessor.cxx: alihbtp_getnumbertracks","(%d)",ntracks);
1264 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1266 ntracks = gen->GetNumberOfTracks();
1267 if(AliGenHBTprocessor::GetDebug()>5)
1268 ::Info("AliGenHBTpocessor.cxx: alihbtp_getnumbertracks","EXITED Ntracks = %d",ntracks);
1271 /*******************************************************************/
1273 extern "C" void type_ofCall
1274 alihbtp_puttrack(Int_t & n,Int_t& flag, Float_t& px,
1275 Float_t& py, Float_t& pz, Int_t& geantpid)
1277 //sets new parameters (momenta) in track number n
1278 // in the active event
1279 // n - number of the track in active event
1280 // flag - flag of the track
1281 // px,py,pz - momenta
1282 // geantpid - type of the particle - Geant Particle ID
1284 if(AliGenHBTprocessor::GetDebug()>5)
1285 ::Info("AliGenHBTpocessor.cxx: alihbtp_puttrack","(%d)",n);
1287 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1289 TParticle * track = gen->GetTrack(n-1);
1292 ::Error("AliGenHBTprocessor.cxx","Can not get track from AliGenHBTprocessor");
1296 //check to be deleted
1297 if (geantpid != (gen->IdFromPDG( track->GetPdgCode() )))
1299 ::Error("AliGenHBTprocessor.cxx: alihbtp_puttrack",
1300 "SOMETHING IS GOING BAD:\n GEANTPIDS ARE NOT THE SAME");
1303 if(AliGenHBTprocessor::GetDebug()>0)
1304 if (px != track->Px())
1305 ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack",
1306 "Px diff. = %f", px - track->Px());
1308 if(AliGenHBTprocessor::GetDebug()>3)
1309 ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack",
1310 "track->GetPdgCode() --> %d",track->GetPdgCode());
1314 Float_t m = track->GetMass();
1315 Float_t e = TMath::Sqrt(m*m+px*px+py*py+pz*pz);
1316 track->SetMomentum(px,py,pz,e);
1318 gen->SetHbtPStatusCode(flag,n-1);
1320 if(AliGenHBTprocessor::GetDebug()>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack","EXITED ");
1323 /*******************************************************************/
1325 extern "C" void type_ofCall
1326 alihbtp_gettrack(Int_t & n,Int_t & flag, Float_t & px,
1327 Float_t & py, Float_t & pz, Int_t & geantpid)
1330 //passes track parameters to the fortran
1331 // n - number of the track in active event
1332 // flag - flag of the track
1333 // px,py,pz - momenta
1334 // geantpid - type of the particle - Geant Particle ID
1336 if(AliGenHBTprocessor::GetDebug()>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","(%d)",n);
1337 AliGenHBTprocessor* g = GetAliGenHBTprocessor();
1339 TParticle * track = g->GetTrack(n-1);
1341 flag = g->GetHbtPStatusCode(n-1);
1343 px = (Float_t)track->Px();
1344 py = (Float_t)track->Py();
1345 pz = (Float_t)track->Pz();
1347 geantpid = g->IdFromPDG( track->GetPdgCode() );
1349 if(AliGenHBTprocessor::GetDebug()>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","EXITED");
1352 /*******************************************************************/
1353 extern "C" Float_t type_ofCall hbtpran(Int_t &)
1355 //interface to the random number generator
1356 return gAliRandom->Rndm();
1359 /*******************************************************************/
1362 /*******************************************************************/