]>
Commit | Line | Data |
---|---|---|
7ca4655f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
4c351225 | 16 | /* $Id$ */ |
17 | ||
7ca4655f | 18 | #include <TList.h> |
447c325d | 19 | #include <TParticle.h> |
7ca4655f | 20 | |
4c351225 | 21 | #include <AliPWG0depHelper.h> |
22 | ||
23 | #include <AliHeader.h> | |
447c325d | 24 | #include <AliStack.h> |
25 | #include <AliLog.h> | |
4c351225 | 26 | |
27 | #include <AliGenEventHeader.h> | |
28 | #include <AliGenPythiaEventHeader.h> | |
29 | #include <AliGenCocktailEventHeader.h> | |
30 | ||
31 | //____________________________________________________________________ | |
32 | ClassImp(AliPWG0depHelper) | |
33 | ||
34 | //____________________________________________________________________ | |
447c325d | 35 | Int_t AliPWG0depHelper::GetPythiaEventProcessType(AliHeader* aHeader, Bool_t adebug) { |
4c351225 | 36 | // |
37 | // get the process type of the event. | |
38 | // | |
39 | ||
40 | // can only read pythia headers, either directly or from cocktalil header | |
41 | AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader->GenEventHeader()); | |
42 | ||
43 | if (!pythiaGenHeader) { | |
44 | ||
45 | AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(aHeader->GenEventHeader()); | |
46 | if (!genCocktailHeader) { | |
47 | printf("AliPWG0depHelper::GetProcessType : Unknown header type (not Pythia or Cocktail). \n"); | |
48 | return -1; | |
49 | } | |
50 | ||
51 | TList* headerList = genCocktailHeader->GetHeaders(); | |
52 | if (!headerList) { | |
53 | return -1; | |
54 | } | |
55 | ||
56 | for (Int_t i=0; i<headerList->GetEntries(); i++) { | |
57 | pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i)); | |
58 | if (pythiaGenHeader) | |
59 | break; | |
60 | } | |
61 | ||
62 | if (!pythiaGenHeader) { | |
63 | printf("AliPWG0depHelper::GetProcessType : Could not find Pythia header. \n"); | |
64 | return -1; | |
65 | } | |
66 | } | |
67 | ||
68 | if (adebug) { | |
69 | printf("AliPWG0depHelper::GetProcessType : Pythia process type found: %d \n",pythiaGenHeader->ProcessType()); | |
70 | } | |
71 | ||
72 | return pythiaGenHeader->ProcessType(); | |
73 | } | |
447c325d | 74 | |
75 | //____________________________________________________________________ | |
76 | TParticle* AliPWG0depHelper::FindPrimaryMother(AliStack* stack, Int_t label) | |
77 | { | |
78 | // | |
79 | // Finds the first mother among the primary particles of the particle identified by <label>, | |
80 | // i.e. the primary that "caused" this particle | |
81 | // | |
82 | ||
83 | Int_t nPrim = stack->GetNprimary(); | |
84 | TParticle* mother = stack->Particle(label); | |
85 | ||
86 | if (!mother) | |
87 | { | |
88 | AliDebugGeneral("FindPrimaryMother", AliLog::kError, Form("UNEXPECTED: Could not retrieve particle with label %d.", label)); | |
89 | return 0; | |
90 | } | |
91 | ||
92 | while (label >= nPrim) | |
93 | { | |
94 | //printf("Particle %d (pdg %d) is not a primary. Let's check its mother %d\n", label, mother->GetPdgCode(), mother->GetMother(0)); | |
95 | ||
96 | if (mother->GetMother(0) == -1) | |
97 | { | |
98 | AliDebugGeneral("FindPrimaryMother", AliLog::kError, Form("UNEXPECTED: Could not find mother of secondary particle %d.", label)); | |
99 | mother = 0; | |
100 | break; | |
101 | } | |
102 | ||
103 | label = mother->GetMother(0); | |
104 | ||
105 | mother = stack->Particle(label); | |
106 | if (!mother) | |
107 | { | |
108 | AliDebugGeneral("FindPrimaryMother", AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (find mother loop).", label)); | |
109 | break; | |
110 | } | |
111 | } | |
112 | ||
113 | return mother; | |
114 | } |