_ROOT Version: 6.14.04
_Platform: Ubuntu
Compiler: Not Provided
Dear Root users,
I am using an adapted version of the pythia tutorial macro provided in the root tutorials. In this macro I am trying to fill a histogram with the transverse momenta of pions with sigma c baryons as mother particles. To achieve this I want to use the GetFirstDaughter command. The code I am using is the following:
void test(Int_t nev = 10000, Int_t ndeb = 1)
{
const char *p8dataenv = gSystem->Getenv("PYTHIA8DATA");
if (!p8dataenv) {
const char *p8env = gSystem->Getenv("PYTHIA8");
if (!p8env) {
Error("pythia8.C",
"Environment variable PYTHIA8 must contain path to pythia directory!");
return;
}
TString p8d = p8env;
p8d += "/xmldoc";
gSystem->Setenv("PYTHIA8DATA", p8d);
}
const char* path = gSystem->ExpandPathName("$PYTHIA8DATA");
if (gSystem->AccessPathName(path)) {
Error("pythia8.C",
"Environment variable PYTHIA8DATA must contain path to $PYTHIA8/xmldoc directory !");
return;
}
// Load libraries
#ifndef G__WIN32 // Pythia8 is a static library on Windows
if (gSystem->Getenv("PYTHIA8")) {
gSystem->Load("$PYTHIA8/lib/libpythia8");
} else {
gSystem->Load("libpythia8");
}
#endif
gSystem->Load("libEG");
gSystem->Load("libEGPythia8");
TH1D* ptPionSigmaH2 = new TH1D("ptPionSigmaH2","pion from #Sigma_{c} p_{t}", 10000, 0., 3);
Float_t etamin = -0.9;
Float_t etamax = 0.9;
// Array of all particles
TClonesArray* particles = new TClonesArray("TParticle", 1000);
// Create pythia8 object
TPythia8* pythia8 = new TPythia8();
// Configure
pythia8->ReadString("HardQCD:all = on");
pythia8->ReadString("HardQCD:gg2ccbar = on");
pythia8->ReadString("HardQCD:qqbar2ccbar = on");
pythia8->ReadString("phaseSpace:pTHatMin = 50.");
// Initialize
pythia8->Initialize(2212 /* p */, 2212 /* p */, 10000. /* GeV */);
for (Int_t iev = 0; iev < nev; iev++) {
pythia8->GenerateEvent();
if (iev < ndeb) pythia8->EventListing();
pythia8->ImportParticles(particles,"All");
Int_t np = particles->GetEntriesFast();
//-------------------------Particle-loop------------------------------
for (Int_t ip = 0; ip < np; ip++) {
TParticle* part = (TParticle*) particles->At(ip);
Int_t pdg = part->GetPdgCode();
Float_t pt = part->Pt();
Float_t eta = part->Eta();
Int_t daughterindex = part->GetFirstDaughter();
if (daughterindex < 0) continue;
TParticle* dpart = (TParticle*) particles->At(daughterindex);
Int_t dpdg = dpart->GetPdgCode();
Float_t dpt = dpart->Pt();
Float_t deta = dpart->Eta();
if ( ((dpdg == 211) || (dpdg == -211)) && (pdg == 4112) && (pt >= 0) && ((eta >= etamin) && (eta <= etamax)) && ((deta >= etamin) && (deta <= etamax))) ptPionSigmaH2->Fill(dpt);
The problem is that this code does not seem to find any particles, while when using the GetFirstMother command for the same amount of events (and trying to achieve the same), I do find pions originating from sigma c baryons. I need to be able to do the same using GetFirstDaughter to proceed with my research. Does anyone see what is wrong with my code or know how I could achieve what I want to?
Best regards,
Loek Meijers