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"
81 #include <TParticle.h>
82 #include "THBTprocessor.h"
86 #include "AliGenCocktailAfterBurner.h"
90 ClassImp(AliGenHBTprocessor)
92 Int_t AliGenHBTprocessor::fgDebug = 0;
93 static TRandom* sRandom;
95 AliGenCocktailAfterBurner* GetGenerator();
96 /*******************************************************************/
97 AliGenHBTprocessor::AliGenHBTprocessor(const AliGenHBTprocessor& in):
101 // AliGenHBTprocessor::AliGenHBTprocessor();
104 AliGenHBTprocessor::AliGenHBTprocessor() : AliGenerator(), fEventMerge(1)
107 // Standard constructor
108 // Sets default veues of all parameters
109 fHbtPStatCodes = 0x0;
112 SetName("AliGenHBTprocessor");
113 SetTitle("AliGenHBTprocessor");
116 fHBTprocessor = new THBTprocessor();
121 SetTrackRejectionFactor();
141 SetSwitchCoherence();
143 SetSwitchFermiBose();
144 //SetMomentumRange();
157 SetNBins1DFineMesh();
158 SetBinSize1DFineMesh();
159 SetNBins1DCoarseMesh();
160 SetBinSize1DCoarseMesh();
161 SetNBins3DFineMesh();
162 SetBinSize3DFineMesh();
163 SetNBins3DCoarseMesh();
164 SetBinSize3DCoarseMesh();
165 SetNBins3DFineProjectMesh();
168 /*******************************************************************/
171 /*******************************************************************/
173 AliGenHBTprocessor::~AliGenHBTprocessor()
177 if (fHBTprocessor) delete fHBTprocessor; //delete generator
181 /*******************************************************************/
183 void AliGenHBTprocessor::InitStatusCodes()
185 //creates and inits status codes array to zero
186 AliGenCocktailAfterBurner *cab = GetGenerator();
188 if(!cab) Fatal("InitStatusCodes()","Can not find AliGenCocktailAfterBurner generator");
190 Int_t nev = cab->GetNumberOfEvents();
192 fHbtPStatCodes = new Int_t* [nev];
193 for( Int_t i =0; i<nev;i++)
195 Int_t nprim = cab->GetStack(i)->GetNprimary();
196 fHbtPStatCodes[i] = new Int_t[nprim];
197 for (Int_t k =0 ;k<nprim;k++)
198 fHbtPStatCodes[i][k] =0;
203 /*******************************************************************/
205 void AliGenHBTprocessor::CleanStatusCodes()
207 //Cleans up status codes
210 for (Int_t i =0; i<GetGenerator()->GetNumberOfEvents(); i++)
211 delete [] fHbtPStatCodes[i];
212 delete fHbtPStatCodes;
217 /*******************************************************************/
219 void AliGenHBTprocessor::Init()
221 //sets up parameters in generator
223 THBTprocessor *thbtp = fHBTprocessor;
226 thbtp->SetTrackRejectionFactor(fTrackRejectionFactor);
227 thbtp->SetRefControl(fReferenceControl);
229 if ((fPid[0] == fPid[1]) || (fPid[0] == 0) || (fPid[1] == 0))
232 thbtp->SetPIDs(IdFromPDG(fPid[1]) ,0);
234 thbtp->SetPIDs(IdFromPDG(fPid[0]) ,0);
235 thbtp->SetNPIDtypes(1);
238 Warning("AliGenHBTprocessor::Init","\nThere is only one particle type set,\n\
239 and Switch_Type differnt then 1,\n which does not make sense.\n\
240 Setting it to 1.\n");
246 thbtp->SetPIDs(IdFromPDG(fPid[0]) ,IdFromPDG(fPid[1]));
248 thbtp->SetSwitchType(fSwitchType);
251 thbtp->SetMaxIterations(fMaxit);
252 thbtp->SetDelChi(fDelchi);
253 thbtp->SetIRand(fIrand);
254 thbtp->SetLambda(fLambda);
256 thbtp->SetRSide(fRside);
257 thbtp->SetROut(fRout);
258 thbtp->SetRLong(fRlong);
259 thbtp->SetRPerp(fRperp);
260 thbtp->SetRParallel(fRparallel);
263 thbtp->SetSwitch1D(fSwitch1d);
264 thbtp->SetSwitch3D(fSwitch3d);
265 thbtp->SetSwitchType(fSwitchType);
266 thbtp->SetSwitchCoherence(fSwitchCoherence);
267 thbtp->SetSwitchCoulomb(fSwitchCoulomb);
268 thbtp->SetSwitchFermiBose(fSwitchFermiBose);
269 thbtp->SetPtRange(fPtMin,fPtMax);
270 thbtp->SetPxRange(fPxMin,fPxMax);
271 thbtp->SetPyRange(fPyMin,fPyMax);
272 thbtp->SetPzRange(fPzMin,fPzMax);
273 thbtp->SetPhiRange(fPhiMin*180./((Float_t)TMath::Pi())+180.0, //casting is because if fPhiMin = 180.0 then
274 fPhiMax*180./((Float_t)TMath::Pi())+180.0);//TMath::Pi() != TMath::Pi()*fPhiMin/180.0,
275 thbtp->SetEtaRange(fEtaMin,fEtaMax);
276 thbtp->SetNPtBins(fNPtBins);
277 thbtp->SetNPhiBins(fNPhiBins);
278 thbtp->SetNEtaBins(fNEtaBins);
279 thbtp->SetNPxBins(fNPxBins);
280 thbtp->SetNPyBins(fNPyBins);
281 thbtp->SetNPzBins(fNPzBins);
282 thbtp->SetNBins1DFineMesh(fN1dFine);
283 thbtp->SetBinSize1DFineMesh(fBinsize1dFine);
284 thbtp->SetNBins1DCoarseMesh(fN1dCoarse);
285 thbtp->SetBinSize1DCoarseMesh(fBinsize1dCoarse);
286 thbtp->SetNBins3DFineMesh(fN3dFine);
287 thbtp->SetBinSize3DFineMesh(fBinsize3dFine);
288 thbtp->SetNBins3DCoarseMesh(fN3dCoarse);
289 thbtp->SetBinSize3DCoarseMesh(fBinsize3dCoarse);
290 thbtp->SetNBins3DFineProjectMesh(fN3dFineProject);
292 thbtp->SetPrintFull(fPrintFull);
295 /*******************************************************************/
297 void AliGenHBTprocessor::Generate()
300 AliGenCocktailAfterBurner* cab = GetGenerator();
303 Fatal("Generate()","AliGenHBTprocessor needs AliGenCocktailAfterBurner to be main generator");
305 if (cab->GetNumberOfEvents() <2)
308 "HBT Processor needs more than 1 event to work properly,\
309 but there is only %d set", cab->GetNumberOfEvents());
313 fHBTprocessor->Initialize(); //reset all fields of common blocks
314 //in case there are many HBT processors
315 //run one after one (i.e. in AliCocktailAfterBurner)
316 //between Init() called and Generate there might
317 Init(); //be different instance running - be sure that we have our settings
319 InitStatusCodes(); //Init status codes
321 fHBTprocessor->GenerateEvent(); //Generates event
323 CleanStatusCodes(); //Clean Status codes - thet are not needed anymore
326 /*******************************************************************/
329 /*******************************************************************/
330 void AliGenHBTprocessor::GetParticles(TClonesArray * particles) const
335 Error("GetParticles","Particles has to be initialized");
338 fHBTprocessor->ImportParticles(particles);
341 /*******************************************************************/
343 Int_t AliGenHBTprocessor::GetHbtPStatusCode(Int_t part) const
345 //returns the status code of the given particle in the active event
346 //see SetActiveEvent in the bottom of AliGenHBTprocessor.cxx
347 //and in AliCocktailAfterBurner
349 GetTrackEventIndex(part,ev,idx);
350 if ( (ev<0) || (idx<0) )
352 Error("GetHbtPStatusCode","GetTrackEventIndex returned error");
355 else return fHbtPStatCodes[ev][idx];
360 /*******************************************************************/
361 void AliGenHBTprocessor::SetHbtPStatusCode(Int_t hbtstatcode, Int_t part)
363 //Sets the given status code to given particle number (part) in the active event
365 GetTrackEventIndex(part,ev,idx);
366 if ( (ev<0) || (idx<0) )
368 Error("GetHbtPStatusCode","GetTrackEventIndex returned error");
371 else fHbtPStatCodes[ev][idx] = hbtstatcode;
374 /*******************************************************************/
376 void AliGenHBTprocessor::SetTrackRejectionFactor(Float_t trf) //def 1.0
378 //Sets the Track Rejection Factor
379 //variates in range 0.0 <-> 1.0
380 //Describes the factor of particles rejected from the output.
381 //Used only in case of low muliplicity particles e.g. lambdas.
382 //Processor generates addisional particles and builds the
383 //correletions on such a statistics.
384 //At the end these particels are left in the event according
385 //to this factor: 1==all particles are left
386 // 0==all are removed
388 fTrackRejectionFactor=trf;
389 fHBTprocessor->SetTrackRejectionFactor(trf);
391 /*******************************************************************/
393 void AliGenHBTprocessor::SetRefControl(Int_t rc) //default 2
395 //Sets the Refernce Control Switch
396 //switch wether read reference histograms from file =1
397 // compute from input events =2 - default
398 fReferenceControl=rc;
399 fHBTprocessor->SetRefControl(rc);
401 /*******************************************************************/
403 void AliGenHBTprocessor::SetPIDs(Int_t pid1,Int_t pid2)
406 //Sets PDG Codes of particles to be processed, default \\Pi^{+} and \\Pi^{-}
407 //This method accepts PDG codes which is
408 //in opposite to THBBProcessor which accepts GEANT PID
409 if ( (pid1 == 0) && (pid2 == 0) )
411 Error("AliGenHBTprocessor::SetPIDs","Sensless Particle Types setting: 0 0, Ignoring\n");
419 fHBTprocessor->SetPIDs(IdFromPDG(pid1) ,0);
425 fHBTprocessor->SetPIDs(IdFromPDG(pid1) ,IdFromPDG(pid2));
429 /*******************************************************************/
431 void AliGenHBTprocessor::SetNPIDtypes(Int_t npidt)
433 //Number ofparticle types to be processed - default 2
434 //see AliGenHBTprocessor::SetPIDs
437 fHBTprocessor->SetNPIDtypes(npidt);
439 /*******************************************************************/
441 void AliGenHBTprocessor::SetDeltap(Float_t deltp)
444 //maximum range for random momentum shifts in GeV/c;
445 //px,py,pz independent; Default = 0.1 GeV/c.
447 fHBTprocessor->SetDeltap(deltp);
449 /*******************************************************************/
451 void AliGenHBTprocessor::SetMaxIterations(Int_t maxiter)
453 //maximum # allowed iterations thru all the
454 //tracks for each event. Default = 50.
455 //If maxit=0, then calculate the correlations
456 //for the input set of events without doing the
457 //track adjustment procedure.
460 fHBTprocessor->SetMaxIterations(maxiter);
463 /*******************************************************************/
464 void AliGenHBTprocessor::SetDelChi(Float_t dc)
466 //min % change in total chi-square for which
467 //the track adjustment iterations may stop,
471 fHBTprocessor->SetDelChi(dc);
473 /*******************************************************************/
475 void AliGenHBTprocessor::SetIRand(Int_t irnd)
477 //if fact dummy - used only for compatibility
478 //we are using AliRoot built in RNG
479 //dummy in fact since we are using aliroot build-in RNG
480 //Sets renaodom number generator
482 fHBTprocessor->SetIRand(irnd);
484 /*******************************************************************/
486 void AliGenHBTprocessor::SetLambda(Float_t lam)
489 // Sets Chaoticity Parameter
491 fHBTprocessor->SetLambda(lam);
493 /*******************************************************************/
494 void AliGenHBTprocessor::SetR1d(Float_t r)
497 //Sets Spherical source model radius (fm)
499 fHBTprocessor->SetR1d(r);
501 /*******************************************************************/
502 void AliGenHBTprocessor::SetRSide(Float_t rs)
505 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
508 fHBTprocessor->SetRSide(rs);
510 /*******************************************************************/
511 void AliGenHBTprocessor::SetROut(Float_t ro)
514 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
516 fHBTprocessor->SetROut(ro);
518 /*******************************************************************/
519 void AliGenHBTprocessor::SetRLong(Float_t rl)
522 //Rside,Rout,Rlong = Non-spherical Bertsch-Pratt source model (fm)
524 fHBTprocessor->SetRLong(rl);
526 /*******************************************************************/
527 void AliGenHBTprocessor::SetRPerp(Float_t rp)
530 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
532 fHBTprocessor->SetRPerp(rp);
534 /*******************************************************************/
535 void AliGenHBTprocessor::SetRParallel(Float_t rprl)
538 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
540 fHBTprocessor->SetRParallel(rprl);
542 /*******************************************************************/
543 void AliGenHBTprocessor::SetR0(Float_t r0)
546 //Rperp,Rparallel,R0= Non-spherical Yano-Koonin-Podgoretski source model (fm).
548 fHBTprocessor->SetR0(r0);
550 /*******************************************************************/
551 void AliGenHBTprocessor::SetQ0(Float_t q0)
554 //Sets Q0 = NA35 Coulomb parameter for finite source size in (GeV/c)
555 // if fSwitchCoulomb = 2
556 // = Spherical Coulomb source radius in (fm)
557 // if switchCoulomb = 3, used to interpolate the
558 // input Pratt/Cramer discrete Coulomb source
561 fHBTprocessor->SetQ0(q0);
564 /*******************************************************************/
565 void AliGenHBTprocessor::SetSwitch1D(Int_t s1d)
569 // = 0 to not compute the 1D two-body //orrelations.
570 // = 1 to compute this using Q-invariant
571 // = 2 to compute this using Q-total
572 // = 3 to compute this using Q-3-ve//tor
575 fHBTprocessor->SetSwitch1D(s1d);
577 /*******************************************************************/
578 void AliGenHBTprocessor::SetSwitch3D(Int_t s3d)
582 // = 0 to not compute the 3D two-body correlations.
583 // = 1 to compute this using the side-out-long form
584 // = 2 to compute this using the Yanno-Koonin-Pogoredskij form.
587 fHBTprocessor->SetSwitch3D(s3d);
589 /*******************************************************************/
590 void AliGenHBTprocessor::SetSwitchType(Int_t st)
593 // Sets switch_type = 1 to fit only the like pair correlations
594 // = 2 to fit only the unlike pair correlations
595 // = 3 to fit both the like and unlike pair correl.
596 //See SetPIDs and Init
597 //If only one particle type is set, unly==1 makes sens
600 fHBTprocessor->SetSwitchType(st);
602 /*******************************************************************/
603 void AliGenHBTprocessor::SetSwitchCoherence(Int_t sc)
606 // switchCoherence = 0 for purely incoherent source (but can have
608 // = 1 for mixed incoherent and coherent source
610 fSwitchCoherence = sc;
611 fHBTprocessor->SetSwitchCoherence(sc);
613 /*******************************************************************/
614 void AliGenHBTprocessor::SetSwitchCoulomb(Int_t scol)
617 // switchCoulomb = 0 no Coulomb correction
618 // = 1 Point source Gamow correction only
619 // = 2 NA35 finite source size correction
620 // = 3 Pratt/Cramer finite source size correction;
621 // interpolated from input tables.
622 fSwitchCoulomb =scol;
623 fHBTprocessor->SetSwitchCoulomb(scol);
625 /*******************************************************************/
626 void AliGenHBTprocessor::SetSwitchFermiBose(Int_t sfb)
629 // switchFermiBose = 1 Boson pairs
630 // = -1 Fermion pairs
632 fSwitchFermiBose = sfb;
633 fHBTprocessor->SetSwitchFermiBose(sfb);
635 /*******************************************************************/
636 void AliGenHBTprocessor::SetPtRange(Float_t ptmin, Float_t ptmax)
638 // default ptmin = 0.1, ptmax = 0.98
639 //Sets Pt range (GeV)
640 AliGenerator::SetPtRange(ptmin,ptmax);
641 fHBTprocessor->SetPtRange(ptmin,ptmax);
644 /*******************************************************************/
645 void AliGenHBTprocessor::SetPxRange(Float_t pxmin, Float_t pxmax)
647 //default pxmin = -1.0, pxmax = 1.0
651 fHBTprocessor->SetPxRange(pxmin,pxmax);
653 /*******************************************************************/
654 void AliGenHBTprocessor::SetPyRange(Float_t pymin, Float_t pymax)
656 //default pymin = -1.0, pymax = 1.0
660 fHBTprocessor->SetPyRange(pymin,pymax);
662 /*******************************************************************/
663 void AliGenHBTprocessor::SetPzRange(Float_t pzmin, Float_t pzmax)
665 //default pzmin = -3.6, pzmax = 3.6
669 fHBTprocessor->SetPzRange(pzmin,pzmax);
671 void AliGenHBTprocessor::SetMomentumRange(Float_t pmin, Float_t pmax)
673 //default pmin=0, pmax=0
674 //Do not use this method!
675 MayNotUse("AliGenHBTprocessor::SetMomentumRange Method is Dummy");
678 /*******************************************************************/
679 void AliGenHBTprocessor::SetPhiRange(Float_t phimin, Float_t phimax)
683 AliGenerator::SetPhiRange(phimin,phimax);
685 fHBTprocessor->SetPhiRange(phimin+180.0,phimax+180.0);
687 /*******************************************************************/
688 void AliGenHBTprocessor::SetEtaRange(Float_t etamin, Float_t etamax)
690 //default etamin = -1.5, etamax = 1.5
694 fHBTprocessor->SetEtaRange(etamin,etamax);
696 //set the azimothal angle range in the AliGeneraor -
697 //to keep coherency between azimuthal angle and pseudorapidity
698 //DO NOT CALL this->SetThetaRange, because it calls this method (where we are)
699 //which must cause INFINITE LOOP
700 AliGenerator::SetThetaRange(RadiansToDegrees(EtaToTheta(fEtaMin)),
701 RadiansToDegrees(EtaToTheta(fEtaMax)));
704 /*******************************************************************/
705 void AliGenHBTprocessor::SetThetaRange(Float_t thetamin, Float_t thetamax)
707 //default thetamin = 0, thetamax = 180
708 //Azimuthal angle, override AliGenerator method which uses widely (i.e. wrapper generators)
709 //core fortran HBTProcessor uses Eta (pseudorapidity)
710 //so these methods has to be synchronized
712 AliGenerator::SetThetaRange(thetamin,thetamax);
714 SetEtaRange( ThetaToEta(fThetaMin) , ThetaToEta(fThetaMax) );
718 /*******************************************************************/
719 void AliGenHBTprocessor::SetNPtBins(Int_t nptbin)
721 //default nptbin = 50
722 //set number of Pt bins
724 fHBTprocessor->SetNPtBins(nptbin);
726 /*******************************************************************/
727 void AliGenHBTprocessor::SetNPhiBins(Int_t nphibin)
729 //default nphibin = 50
730 //set number of Phi bins
732 fHBTprocessor->SetNPhiBins(nphibin);
734 /*******************************************************************/
735 void AliGenHBTprocessor::SetNEtaBins(Int_t netabin)
737 //default netabin = 50
738 //set number of Eta bins
740 fHBTprocessor->SetNEtaBins(netabin);
742 /*******************************************************************/
743 void AliGenHBTprocessor::SetNPxBins(Int_t npxbin)
745 //default npxbin = 20
746 //set number of Px bins
748 fHBTprocessor->SetNPxBins(npxbin);
750 /*******************************************************************/
751 void AliGenHBTprocessor::SetNPyBins(Int_t npybin)
753 //default npybin = 20
754 //set number of Py bins
756 fHBTprocessor->SetNPyBins(npybin);
758 /*******************************************************************/
759 void AliGenHBTprocessor::SetNPzBins(Int_t npzbin)
761 //default npzbin = 70
762 //set number of Pz bins
764 fHBTprocessor->SetNPzBins(npzbin);
766 /*******************************************************************/
767 void AliGenHBTprocessor::SetNBins1DFineMesh(Int_t n)
770 //Sets the number of bins in the 1D mesh
772 fHBTprocessor->SetNBins1DFineMesh(n);
775 /*******************************************************************/
776 void AliGenHBTprocessor::SetBinSize1DFineMesh(Float_t x)
779 //Sets the bin size in the 1D mesh
781 fHBTprocessor->SetBinSize1DFineMesh(x);
783 /*******************************************************************/
785 void AliGenHBTprocessor::SetNBins1DCoarseMesh(Int_t n)
788 //Sets the number of bins in the coarse 1D mesh
790 fHBTprocessor->SetNBins1DCoarseMesh(n);
792 /*******************************************************************/
793 void AliGenHBTprocessor::SetBinSize1DCoarseMesh(Float_t x)
796 //Sets the bin size in the coarse 1D mesh
798 fHBTprocessor->SetBinSize1DCoarseMesh(x);
800 /*******************************************************************/
802 void AliGenHBTprocessor::SetNBins3DFineMesh(Int_t n)
805 //Sets the number of bins in the 3D mesh
807 fHBTprocessor->SetNBins3DFineMesh(n);
809 /*******************************************************************/
810 void AliGenHBTprocessor::SetBinSize3DFineMesh(Float_t x)
813 //Sets the bin size in the 3D mesh
815 fHBTprocessor->SetBinSize3DFineMesh(x);
817 /*******************************************************************/
819 void AliGenHBTprocessor::SetNBins3DCoarseMesh(Int_t n)
822 //Sets the number of bins in the coarse 3D mesh
825 fHBTprocessor->SetNBins3DCoarseMesh(n);
827 /*******************************************************************/
828 void AliGenHBTprocessor::SetBinSize3DCoarseMesh(Float_t x)
831 //Sets the bin size in the coarse 3D mesh
832 fBinsize3dCoarse = x;
833 fHBTprocessor->SetBinSize3DCoarseMesh(x);
835 /*******************************************************************/
837 void AliGenHBTprocessor::SetNBins3DFineProjectMesh(Int_t n )
840 //Sets the number of bins in the fine project mesh
842 fHBTprocessor->SetNBins3DFineProjectMesh(n);
844 /*******************************************************************/
845 void AliGenHBTprocessor::SetPrintFull(Int_t flag)
848 fHBTprocessor->SetPrintFull(flag);
852 /*******************************************************************/
854 Int_t AliGenHBTprocessor::GetNumberOfEvents()
856 AliGenerator* g = gAlice->Generator();
857 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
860 Fatal("GetNumberOfEvents","Master Generator is not an AliGenCocktailAfterBurner");
863 return (Int_t)TMath::Ceil(cab->GetNumberOfEvents()/((Float_t)fEventMerge));
866 /*******************************************************************/
868 void AliGenHBTprocessor::SetActiveEventNumber(Int_t n)
870 fActiveStack = n*fEventMerge;
872 Info("SetActiveEventNumber","Settimg active event %d passed %d",
875 /*******************************************************************/
877 Int_t AliGenHBTprocessor::GetNumberOfTracks()
879 AliGenerator* g = gAlice->Generator();
880 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
883 Fatal("GetNumberOfEvents","Master Generator is not an AliGenCocktailAfterBurner");
887 for (Int_t i = fActiveStack;i < fActiveStack+fEventMerge; i++)
889 if (i >= GetNumberOfEvents()) break; //protection not to overshoot nb of events
890 AliStack* stack = cab->GetStack(i);
892 Error("GetNumberOfTracks","There is no stack %d",i);
894 n+=stack->GetNprimary();
898 /*******************************************************************/
900 void AliGenHBTprocessor::SetNEventsToMerge(Int_t nev)
902 if (nev > 0 ) fEventMerge = nev;
904 /*******************************************************************/
906 TParticle* AliGenHBTprocessor::GetTrack(Int_t n)
908 //returns track that hbtp thinks is n in active event
909 if (fgDebug > 5) Info("GetTrack","n = %d",n);
910 AliGenerator* g = gAlice->Generator();
911 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
914 Fatal("GetTrackEventIndex","Master Generator is not an AliGenCocktailAfterBurner");
919 GetTrackEventIndex(n,ev,idx);
920 if (fgDebug > 5) Info("GetTrack","Event = %d Particle = %d",ev,idx);
921 if ( (ev<0) || (idx<0) )
923 Error("GetTrack","GetTrackEventIndex returned error");
928 if (fgDebug > 5) Info("GetTrack","Number of Tracks in Event(%d) = %d",ev,cab->GetStack(ev)->GetNprimary());
929 return cab->GetStack(ev)->Particle(idx); //safe - in case stack does not exist
930 } //GetTrackEventIndex would have returned error
933 /*******************************************************************/
935 void AliGenHBTprocessor::GetTrackEventIndex(Int_t n, Int_t &evno, Int_t &index) const
937 //returns event(stack) number and particle index
938 AliGenerator* g = gAlice->Generator();
939 AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
942 Fatal("GetTrackEventIndex","Master Generator is not an AliGenCocktailAfterBurner");
948 for (Int_t i = fActiveStack;i < fActiveStack+fEventMerge; i++)
950 AliStack* stack = cab->GetStack(i);
953 Error("GetTrackEventIndex","There is no stack %d",i);
957 Int_t ntracks = stack->GetNprimary();
958 if (fgDebug > 10) Info("GetTrackEventIndex","Event %d has %d tracks. n = %d",i,ntracks,n);
972 Error("GetTrackEventIndex","Could not find given track");
975 /*******************************************************************/
976 /*******************************************************************/
977 /*******************************************************************/
983 void AliGenHBTprocessor::DefineParticles()
986 // Load standard numbers for GEANT particles and PDG conversion
987 fNPDGCodes = 0; //this is done in the constructor - but in any case ...
989 fPDGCode[fNPDGCodes++]=-99; // 0 = unused location
990 fPDGCode[fNPDGCodes++]=22; // 1 = photon
991 fPDGCode[fNPDGCodes++]=-11; // 2 = positron
992 fPDGCode[fNPDGCodes++]=11; // 3 = electron
993 fPDGCode[fNPDGCodes++]=12; // 4 = neutrino e
994 fPDGCode[fNPDGCodes++]=-13; // 5 = muon +
995 fPDGCode[fNPDGCodes++]=13; // 6 = muon -
996 fPDGCode[fNPDGCodes++]=111; // 7 = pi0
997 fPDGCode[fNPDGCodes++]=211; // 8 = pi+
998 fPDGCode[fNPDGCodes++]=-211; // 9 = pi-
999 fPDGCode[fNPDGCodes++]=130; // 10 = Kaon Long
1000 fPDGCode[fNPDGCodes++]=321; // 11 = Kaon +
1001 fPDGCode[fNPDGCodes++]=-321; // 12 = Kaon -
1002 fPDGCode[fNPDGCodes++]=2112; // 13 = Neutron
1003 fPDGCode[fNPDGCodes++]=2212; // 14 = Proton
1004 fPDGCode[fNPDGCodes++]=-2212; // 15 = Anti Proton
1005 fPDGCode[fNPDGCodes++]=310; // 16 = Kaon Short
1006 fPDGCode[fNPDGCodes++]=221; // 17 = Eta
1007 fPDGCode[fNPDGCodes++]=3122; // 18 = Lambda
1008 fPDGCode[fNPDGCodes++]=3222; // 19 = Sigma +
1009 fPDGCode[fNPDGCodes++]=3212; // 20 = Sigma 0
1010 fPDGCode[fNPDGCodes++]=3112; // 21 = Sigma -
1011 fPDGCode[fNPDGCodes++]=3322; // 22 = Xi0
1012 fPDGCode[fNPDGCodes++]=3312; // 23 = Xi-
1013 fPDGCode[fNPDGCodes++]=3334; // 24 = Omega-
1014 fPDGCode[fNPDGCodes++]=-2112; // 25 = Anti Proton
1015 fPDGCode[fNPDGCodes++]=-3122; // 26 = Anti Proton
1016 fPDGCode[fNPDGCodes++]=-3222; // 27 = Anti Sigma -
1017 fPDGCode[fNPDGCodes++]=-3212; // 28 = Anti Sigma 0
1018 fPDGCode[fNPDGCodes++]=-3112; // 29 = Anti Sigma 0
1019 fPDGCode[fNPDGCodes++]=-3322; // 30 = Anti Xi 0
1020 fPDGCode[fNPDGCodes++]=-3312; // 31 = Anti Xi +
1021 fPDGCode[fNPDGCodes++]=-3334; // 32 = Anti Omega +
1024 /*******************************************************************/
1025 Int_t AliGenHBTprocessor::IdFromPDG(Int_t pdg) const
1028 // Return Geant3 code from PDG and pseudo ENDF code
1030 for(Int_t i=0;i<fNPDGCodes;++i)
1031 if(pdg==fPDGCode[i]) return i;
1034 Int_t AliGenHBTprocessor::PDGFromId(Int_t id) const
1037 // Return PDG code and pseudo ENDF code from Geant3 code
1039 if(id>0 && id<fNPDGCodes) return fPDGCode[id];
1042 Double_t AliGenHBTprocessor::ThetaToEta(Double_t arg)
1044 //converts etha(azimuthal angle) to Eta (pseudorapidity). Argument in radians
1046 if(arg>= TMath::Pi()) return 708.0;//This number is the biggest wich not crashes exp(x)
1047 if(arg<= 0.0) return -708.0;//
1048 if(arg == TMath::Pi()/2.) return 0.0;//
1052 return TMath::Log( TMath::Tan(arg/2.)) ;
1056 return -TMath::Log( TMath::Tan(-arg/2.)) ;
1060 /*******************************************************************/
1061 /****** ROUTINES USED FOR COMMUNUCATION ********/
1062 /******************** WITH FORTRAN ********************/
1063 /*******************************************************************/
1066 # define hbtpran hbtpran_
1067 # define alihbtp_puttrack alihbtp_puttrack_
1068 # define alihbtp_gettrack alihbtp_gettrack_
1069 # define alihbtp_getnumberevents alihbtp_getnumberevents_
1070 # define alihbtp_getnumbertracks alihbtp_getnumbertracks_
1071 # define alihbtp_initialize alihbtp_initialize_
1072 # define alihbtp_setactiveeventnumber alihbtp_setactiveeventnumber_
1073 # define alihbtp_setparameters alihbtp_setparameters_
1074 # define type_ofCall
1077 # define hbtpran HBTPRAN
1078 # define alihbtp_puttrack ALIHBTP_PUTTRACK
1079 # define alihbtp_gettrack ALIHBTP_GETTRACK
1080 # define alihbtp_getnumberevents ALIHBTP_GETNUMBEREVENTS
1081 # define alihbtp_getnumbertracks ALIHBTP_GETNUMBERTRACKS
1082 # define alihbtp_initialize ALIHBTP_INITIALIZE
1083 # define alihbtp_setactiveeventnumber ALIHBTP_SETACTIVEEVENTNUMBER
1084 # define alihbtp_setparameters ALIHBTP_SETPARAMETERS
1085 # define type_ofCall _stdcall
1088 /*******************************************************************/
1090 AliGenCocktailAfterBurner* GetGenerator()
1092 // This function has two tasks:
1093 // Check if environment is OK (exist gAlice and generator)
1094 // Returns pointer to genrator
1095 //to be changed with TFolders
1099 ::Error("AliGenHBTprocessor.cxx: GetGenerator()",
1100 "There is NO gALICE! Check what you are doing!");
1101 ::Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
1102 "Running HBT Processor without gAlice... Exiting \n");
1103 return 0x0;//pro forma
1105 AliGenerator * gen = gAlice->Generator();
1109 ::Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
1110 "There is no generator in gAlice, exiting\n");
1114 //we do not sure actual type of the genetator
1115 //and simple casting is risky - we use ROOT machinery to do safe cast
1117 TClass* cabclass = AliGenCocktailAfterBurner::Class(); //get AliGenCocktailAfterBurner TClass
1118 TClass* genclass = gen->IsA();//get TClass of the generator we got from galice
1119 //use casting implemented in TClass
1120 //cast gen to cabclass
1121 AliGenCocktailAfterBurner* cab=(AliGenCocktailAfterBurner*)genclass->DynamicCast(cabclass,gen);
1123 if (cab == 0x0)//if generator that we got is not AliGenCocktailAfterBurner or its descendant we get null
1124 { //then quit with error
1125 ::Fatal("AliGenHBTprocessor.cxx: GetGenerator()",
1126 "The main Generator is not a AliGenCocktailAfterBurner, exiting\n");
1131 /*******************************************************************/
1133 AliGenHBTprocessor* GetAliGenHBTprocessor()
1135 //returns pointer to the current instance of AliGenHBTprocessor in
1136 //AliGenCocktailAfterBurner (can be more than one)
1138 AliGenCocktailAfterBurner* gen = GetGenerator();
1139 AliGenerator* g = gen->GetCurrentGenerator();
1142 ::Fatal("AliGenHBTprocessor.cxx: GetAliGenHBTprocessor()",
1143 "Can not get the current generator. Exiting");
1144 return 0x0;//pro forma
1147 TClass* hbtpclass = AliGenHBTprocessor::Class(); //get AliGenCocktailAfterBurner TClass
1148 TClass* gclass = g->IsA();//get TClass of the current generator we got from CAB
1149 AliGenHBTprocessor* hbtp = (AliGenHBTprocessor*)gclass->DynamicCast(hbtpclass,g);//try to cast
1152 ::Fatal("AliGenHBTprocessor.cxx: GetAliGenHBTprocessor()",
1153 "\nCurrernt generator in AliGenCocktailAfterBurner is not a AliGenHBTprocessor, exiting\n");
1159 /*******************************************************************/
1160 extern "C" void type_ofCall alihbtp_setparameters()
1165 extern "C" void type_ofCall alihbtp_initialize()
1170 /*******************************************************************/
1172 extern "C" void type_ofCall alihbtp_getnumberevents(Int_t &nev)
1174 //passes number of events to the fortran
1175 if(AliGenHBTprocessor::fgDebug)
1176 ::Info("AliGenHBTprocessor.cxx: alihbtp_getnumberevents","(%d) ....",nev);
1178 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1179 nev = gen->GetNumberOfEvents();
1181 if(AliGenHBTprocessor::fgDebug>5)
1182 ::Info("AliGenHBTprocessor.cxx: alihbtp_getnumberevents","EXITED N Ev = %d",nev);
1185 /*******************************************************************/
1187 extern "C" void type_ofCall alihbtp_setactiveeventnumber(Int_t & nev)
1189 //sets active event in generator (AliGenCocktailAfterBurner)
1191 if(AliGenHBTprocessor::fgDebug>5)
1192 ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","(%d)",nev);
1193 if(AliGenHBTprocessor::fgDebug>0)
1194 ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","Asked for event %d",nev-1);
1196 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1198 gen->SetActiveEventNumber(nev - 1); //fortran numerates events from 1 to N
1200 if(AliGenHBTprocessor::fgDebug>5)
1201 ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","EXITED returned %d",nev);
1203 /*******************************************************************/
1205 extern "C" void type_ofCall alihbtp_getnumbertracks(Int_t &ntracks)
1207 //passes number of particles in active event to the fortran
1208 if(AliGenHBTprocessor::fgDebug>5)
1209 ::Info("AliGenHBTpocessor.cxx: alihbtp_getnumbertracks","(%d)",ntracks);
1211 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1213 ntracks = gen->GetNumberOfTracks();
1214 if(AliGenHBTprocessor::fgDebug>5)
1215 ::Info("AliGenHBTpocessor.cxx: alihbtp_getnumbertracks","EXITED Ntracks = %d",ntracks);
1218 /*******************************************************************/
1220 extern "C" void type_ofCall
1221 alihbtp_puttrack(Int_t & n,Int_t& flag, Float_t& px,
1222 Float_t& py, Float_t& pz, Int_t& geantpid)
1224 //sets new parameters (momenta) in track number n
1225 // in the active event
1226 // n - number of the track in active event
1227 // flag - flag of the track
1228 // px,py,pz - momenta
1229 // geantpid - type of the particle - Geant Particle ID
1231 if(AliGenHBTprocessor::fgDebug>5)
1232 ::Info("AliGenHBTpocessor.cxx: alihbtp_puttrack","(%d)",n);
1234 AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
1236 TParticle * track = gen->GetTrack(n-1);
1239 ::Error("AliGenHBTprocessor.cxx","Can not get track from AliGenHBTprocessor");
1243 //check to be deleted
1244 if (geantpid != (gen->IdFromPDG( track->GetPdgCode() )))
1246 ::Error("AliGenHBTprocessor.cxx: alihbtp_puttrack",
1247 "SOMETHING IS GOING BAD:\n GEANTPIDS ARE NOT THE SAME");
1250 if(AliGenHBTprocessor::fgDebug>0)
1251 if (px != track->Px())
1252 ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack",
1253 "Px diff. = %f", px - track->Px());
1255 if(AliGenHBTprocessor::fgDebug>3)
1256 ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack",
1257 "track->GetPdgCode() --> %d",track->GetPdgCode());
1261 Float_t m = track->GetMass();
1262 Float_t e = TMath::Sqrt(m*m+px*px+py*py+pz*pz);
1263 track->SetMomentum(px,py,pz,e);
1265 gen->SetHbtPStatusCode(flag,n-1);
1267 if(AliGenHBTprocessor::fgDebug>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack","EXITED ");
1270 /*******************************************************************/
1272 extern "C" void type_ofCall
1273 alihbtp_gettrack(Int_t & n,Int_t & flag, Float_t & px,
1274 Float_t & py, Float_t & pz, Int_t & geantpid)
1277 //passes track parameters to the fortran
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::fgDebug>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","(%d)",n);
1284 AliGenHBTprocessor* g = GetAliGenHBTprocessor();
1286 TParticle * track = g->GetTrack(n-1);
1288 flag = g->GetHbtPStatusCode(n-1);
1290 px = (Float_t)track->Px();
1291 py = (Float_t)track->Py();
1292 pz = (Float_t)track->Pz();
1294 geantpid = g->IdFromPDG( track->GetPdgCode() );
1296 if(AliGenHBTprocessor::fgDebug>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","EXITED");
1299 /*******************************************************************/
1300 extern "C" Float_t type_ofCall hbtpran(Int_t &)
1302 //interface to the random number generator
1303 return sRandom->Rndm();
1306 /*******************************************************************/
1309 /*******************************************************************/