//-----------------------------------------------------------------------
/*
Example for generation :
-
AliGenTHnSparse *gener = new AliGenTHnSparse();
gener->SetNumberParticles(10);
- gener->SetPart(13);
+ gener->SetPart(13,kTRUE); // for generating id 13 and -13
gener->SetThnSparse("file_name","thn_name");
gener->Init();
*/
#include "AliGenTHnSparse.h"
+// NEW
+#include "AliRun.h"
+#include "AliLog.h"
+#include "AliGenEventHeader.h"
+//
+
ClassImp(AliGenTHnSparse)
//_______________________________________________________________________
AliGenerator(),
fHn(0),
fFile(0),
- fIpart(0)
+ fIpart(0),
+ fBoth(kFALSE)
{
// Default constructor
SetNumberParticles(1);
AliGenerator(),
fHn(func.fHn),
fFile(func.fFile),
- fIpart(func.fIpart)
+ fIpart(func.fIpart),
+ fBoth(func.fBoth)
{
// Copy constructor
SetNumberParticles(1);
fHn = func.fHn;
fFile = func.fFile;
fIpart = func.fIpart;
+ fBoth = func.fBoth;
+
return *this;
}
//_______________________________________________________________________
void AliGenTHnSparse::Generate()
{
-
// Generate Npart of id Ipart
+ Int_t naccepted =0;
Double_t rand[4]; // z, ptot, r, theta
Float_t pos[3], phi, ptot, theta, pt, z, r;
Float_t mom[3];
Int_t pdg = fIpart;
- for (Int_t ipart = 0; ipart < fNpart; ipart++) {
+ for (Int_t ipart = 0; ipart < fNpart && naccepted<fNpart; ipart++) {
fHn->GetRandom(rand);
z=rand[0];
// propagation
- Float_t polarization[3]= {0,0,0};
+ Float_t polarization[3] = {0,0,0};
Int_t nt;
+
+// Part and anti-part
+
+ if(fBoth){
+ Double_t sign = gRandom->Rndm();
+ if(sign < 0.5) pdg = -fIpart;
+ else pdg = fIpart;
+ }
+
PushTrack(fTrackIt,-1,pdg,mom, pos, polarization,0,kPPrimary,nt);
+ naccepted++;
}
+ AliGenEventHeader* header = new AliGenEventHeader("THn");
+ gAlice->SetGenEventHeader(header);
return;
+
}
//_______________________________________________________________________
{
// Open the file and get object
- TFile *fFile = new TFile(file_name);
- fHn = (THnSparseF*)(fFile->Get(thn_name));
+ fFile = new TFile(file_name);
+ fHn = (THnSparseF*)(fFile->Get(thn_name));
}