]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/AliPWG0depHelper.cxx
generate spectrum from N SPD FO triggers
[u/mrichter/AliRoot.git] / PWG0 / AliPWG0depHelper.cxx
CommitLineData
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//____________________________________________________________________
32ClassImp(AliPWG0depHelper)
33
34//____________________________________________________________________
447c325d 35Int_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//____________________________________________________________________
76TParticle* 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
82ac9fc4 83 Int_t motherLabel = FindPrimaryMotherLabel(stack, label);
84 if (motherLabel < 0)
447c325d 85 return 0;
82ac9fc4 86
87 return stack->Particle(motherLabel);
88}
89
90//____________________________________________________________________
91Int_t AliPWG0depHelper::FindPrimaryMotherLabel(AliStack* stack, Int_t label)
92{
93 //
94 // Finds the first mother among the primary particles of the particle identified by <label>,
95 // i.e. the primary that "caused" this particle
96 //
97 // returns its label
98 //
99
100 Int_t nPrim = stack->GetNprimary();
447c325d 101
102 while (label >= nPrim)
103 {
104 //printf("Particle %d (pdg %d) is not a primary. Let's check its mother %d\n", label, mother->GetPdgCode(), mother->GetMother(0));
105
82ac9fc4 106 TParticle* particle = stack->Particle(label);
107 if (!particle)
447c325d 108 {
82ac9fc4 109 AliDebugGeneral("FindPrimaryMother", AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack.", label));
110 return -1;
447c325d 111 }
82ac9fc4 112
113 // find mother
114 if (particle->GetMother(0) < 0)
447c325d 115 {
82ac9fc4 116 AliDebugGeneral("FindPrimaryMother", AliLog::kError, Form("UNEXPECTED: Could not find mother of secondary particle %d.", label));
117 return -1;
447c325d 118 }
82ac9fc4 119
120 label = particle->GetMother(0);
447c325d 121 }
122
82ac9fc4 123 return label;
447c325d 124}
82ac9fc4 125
126