ROOT logo
// $Id$
//
// Macro for checking mother-daughter particles relationship in stack.
// By A. Morsch, 24/10/2013

void testMD(Int_t evNumber1 = 0, Int_t evNumber2 = 0) 
{
// Connect the Root Galice file containing Geometry, Kine and Hits

    AliRunLoader* rl = AliRunLoader::Open("galice.root");
//
    TDatabasePDG*  DataBase = new TDatabasePDG();
    
//
//   Loop over events 
//
    rl->LoadKinematics();
    rl->LoadHeader();    
    for (Int_t nev = evNumber1; nev <= evNumber2; nev++) {
	rl->GetEvent(nev);
	AliStack* stack = rl->Stack();
	Int_t npart = stack->GetNtrack();
	if (nev < evNumber1) continue;
	printf("Event %5d \n", nev);
//
// Particle loop
//       
	
	for (Int_t part = 0; part < npart; part++) {
	  TParticle *particle = stack->Particle(part);
	  Int_t pdg  = particle->GetPdgCode();
	  Int_t child1 = particle->GetFirstDaughter();
	  Int_t child2 = particle->GetLastDaughter();
	  if (child1 == -1 || part < 8) continue;
	  
	  for (Int_t i = child1; i<= child2; i++) 
	    {
	      TParticle *daughter = stack->Particle(i);
	      Int_t mo = daughter->GetFirstMother();
	      Int_t dodg = daughter->GetPdgCode();
	      if (mo != part) 
		printf("Particle with index %5d (pdg %5d) has daughters from index %5d to %5d, however, daughter %5d (pdg %5d) points back to %5d \n", 
		       part, pdg, child1, child2, i, dodg, mo);
	    }
	} // primary loop
    }
}







 testMD.C:1
 testMD.C:2
 testMD.C:3
 testMD.C:4
 testMD.C:5
 testMD.C:6
 testMD.C:7
 testMD.C:8
 testMD.C:9
 testMD.C:10
 testMD.C:11
 testMD.C:12
 testMD.C:13
 testMD.C:14
 testMD.C:15
 testMD.C:16
 testMD.C:17
 testMD.C:18
 testMD.C:19
 testMD.C:20
 testMD.C:21
 testMD.C:22
 testMD.C:23
 testMD.C:24
 testMD.C:25
 testMD.C:26
 testMD.C:27
 testMD.C:28
 testMD.C:29
 testMD.C:30
 testMD.C:31
 testMD.C:32
 testMD.C:33
 testMD.C:34
 testMD.C:35
 testMD.C:36
 testMD.C:37
 testMD.C:38
 testMD.C:39
 testMD.C:40
 testMD.C:41
 testMD.C:42
 testMD.C:43
 testMD.C:44
 testMD.C:45
 testMD.C:46
 testMD.C:47
 testMD.C:48
 testMD.C:49
 testMD.C:50
 testMD.C:51
 testMD.C:52
 testMD.C:53
 testMD.C:54
 testMD.C:55