1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 #include <TParticle.h>
21 #include <AliPWG0depHelper.h>
23 #include <AliHeader.h>
27 #include <AliGenEventHeader.h>
28 #include <AliGenPythiaEventHeader.h>
29 #include <AliGenCocktailEventHeader.h>
31 //____________________________________________________________________
32 ClassImp(AliPWG0depHelper)
34 //____________________________________________________________________
35 Int_t AliPWG0depHelper::GetPythiaEventProcessType(AliHeader* aHeader, Bool_t adebug) {
37 // get the process type of the event.
40 // can only read pythia headers, either directly or from cocktalil header
41 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader->GenEventHeader());
43 if (!pythiaGenHeader) {
45 AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(aHeader->GenEventHeader());
46 if (!genCocktailHeader) {
47 printf("AliPWG0depHelper::GetProcessType : Unknown header type (not Pythia or Cocktail). \n");
51 TList* headerList = genCocktailHeader->GetHeaders();
56 for (Int_t i=0; i<headerList->GetEntries(); i++) {
57 pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
62 if (!pythiaGenHeader) {
63 printf("AliPWG0depHelper::GetProcessType : Could not find Pythia header. \n");
69 printf("AliPWG0depHelper::GetProcessType : Pythia process type found: %d \n",pythiaGenHeader->ProcessType());
72 return pythiaGenHeader->ProcessType();
75 //____________________________________________________________________
76 TParticle* AliPWG0depHelper::FindPrimaryMother(AliStack* stack, Int_t label)
79 // Finds the first mother among the primary particles of the particle identified by <label>,
80 // i.e. the primary that "caused" this particle
83 Int_t motherLabel = FindPrimaryMotherLabel(stack, label);
87 return stack->Particle(motherLabel);
90 //____________________________________________________________________
91 Int_t AliPWG0depHelper::FindPrimaryMotherLabel(AliStack* stack, Int_t label)
94 // Finds the first mother among the primary particles of the particle identified by <label>,
95 // i.e. the primary that "caused" this particle
100 Int_t nPrim = stack->GetNprimary();
102 while (label >= nPrim)
104 //printf("Particle %d (pdg %d) is not a primary. Let's check its mother %d\n", label, mother->GetPdgCode(), mother->GetMother(0));
106 TParticle* particle = stack->Particle(label);
109 AliDebugGeneral("FindPrimaryMother", AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack.", label));
114 if (particle->GetMother(0) < 0)
116 AliDebugGeneral("FindPrimaryMother", AliLog::kError, Form("UNEXPECTED: Could not find mother of secondary particle %d.", label));
120 label = particle->GetMother(0);