fTRDsignal is added to AliAODPid class (copied from AliESDtrack).
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODMCHeader.cxx
CommitLineData
dce1b636 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
16//-------------------------------------------------------------------------
17// Implementation of Class AliAODMCHeader
18// Header data
19// for the ESD
20// Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
21//-------------------------------------------------------------------------
22
08078824 23#include "TList.h"
dce1b636 24#include "AliAODMCHeader.h"
08078824 25#include "AliGenEventHeader.h"
26#include "AliGenCocktailEventHeader.h"
27
28
dce1b636 29
30
31ClassImp(AliAODMCHeader)
32
33// Without a trailing dot root does not support
34// direct drawing of some variables if the name is not unique on top label
35// bnrach e.g. fEventType is found here and in AliAODHeader....
36TString AliAODMCHeader::fgkStdBranchName("mcHeader");
37
38//______________________________________________________________________________
34477296 39
dce1b636 40AliAODMCHeader::AliAODMCHeader() :
41 AliVHeader()
42 ,fGenerator("")
43 ,fImpactPar(0)
0fd37a1f 44 ,fPtHard(0)
210dd0f3 45 ,fXsection(0)
46 ,fTrials(0)
dce1b636 47 ,fEventType(0)
34477296 48 ,fReactionPlaneAngle(0)
08078824 49 ,fHeaders(0)
dce1b636 50{
51 // default constructor
52 fVertex[0] = fVertex[1] = fVertex[2] = 0;
53 SetName(fgkStdBranchName.Data());
54}
55
56
57AliAODMCHeader::~AliAODMCHeader()
58{
08078824 59
60 Reset();
61 delete fHeaders;
dce1b636 62 // destructor
63}
64
65
66AliAODMCHeader::AliAODMCHeader(const AliAODMCHeader &header) :
67 AliVHeader(header)
68 ,fGenerator(header.fGenerator)
69 ,fImpactPar(header.fImpactPar)
0fd37a1f 70 ,fPtHard(header.fPtHard)
210dd0f3 71 ,fXsection(0)
72 ,fTrials(0)
dce1b636 73 ,fEventType(header.fEventType)
34477296 74 ,fReactionPlaneAngle(header.fReactionPlaneAngle)
08078824 75 ,fHeaders(0)
dce1b636 76{
77 // copy constructor
78 for(int i = 0;i<3;++i)fVertex[i] = header.fVertex[i];
79 SetName(header.fName);
80 SetTitle(header.fTitle);
81}
82
83AliAODMCHeader& AliAODMCHeader::operator=(const AliAODMCHeader &header)
84{
85 // assigment operator
08078824 86
dce1b636 87 if(this!=&header) {
08078824 88 Reset();
dce1b636 89 AliVHeader::operator=(header);
90 fGenerator = header.fGenerator;
91 for(int i = 0;i<3;++i)fVertex[i] = header.fVertex[i];
92 fImpactPar = header.fImpactPar;
0fd37a1f 93 fPtHard = header.fPtHard;
210dd0f3 94 fXsection = header.fXsection;
95 fTrials = header.fTrials;
dce1b636 96 fEventType = header.fEventType;
34477296 97 fReactionPlaneAngle = header.fReactionPlaneAngle;
08078824 98
99 if(header.fHeaders){
100 for(int i = 0;i < header.fHeaders->GetEntries();i++){
101 AddCocktailHeader(dynamic_cast<AliGenEventHeader*>(header.fHeaders->At(i)));
102 }
103 }
dce1b636 104 }
105 return *this;
106}
107
08078824 108void AliAODMCHeader::AddCocktailHeader(const AliGenEventHeader* header)
109{
110// Add a header to the list
111 if(!header)return;
112 if (!fHeaders){
113 fHeaders = new TList();
114 fHeaders->SetOwner(kTRUE);
115 }
116 fHeaders->Add(header->Clone());
117}
118
dce1b636 119void AliAODMCHeader::Copy(TObject &obj) const {
120
121 // this overwrites the virtual TOBject::Copy()
122 // to allow run time copying without casting
123 // in AliESDEvent
124
125 if(this==&obj)return;
126 AliAODMCHeader *robj = dynamic_cast<AliAODMCHeader*>(&obj);
127 if(!robj)return; // not an AliAODMCHeader
128 *robj = *this;
129
130}
131
132
133
134//______________________________________________________________________________
135void AliAODMCHeader::Reset()
136{
137 // reset all data members
138 fGenerator = "";
139 fImpactPar = 0;
140 fEventType = 0;
0fd37a1f 141 fPtHard = 0;
210dd0f3 142 fXsection = 0;
143 fTrials = 0;
dce1b636 144 fVertex[0] = fVertex[1] = fVertex[2] = 0;
34477296 145 fReactionPlaneAngle = 0;
08078824 146 if(fHeaders)fHeaders->Delete();
dce1b636 147}
148
149//______________________________________________________________________________
150void AliAODMCHeader::Print(const Option_t *) const
151{
152 // Print some data members
08078824 153 Printf("MC EventHeader Generators: %s # EventType %d Vtx = (%3.3f,%3.3f,%3.3f) ptHard = %3.3f GeV Impact parameter %3.3f \n",
dce1b636 154 GetGeneratorName(),
155 GetEventType(),
0fd37a1f 156 GetVtxX(),GetVtxY(),GetVtxZ(),GetPtHard(),
dce1b636 157 GetImpactParameter());
08078824 158 if(fHeaders){
159 fHeaders->Print();
160 for(int i = 0;i<fHeaders->GetEntries();++i){
161 TObject *obj = fHeaders->At(i);
162 if(obj){
163 Printf(">> %d: %s %s",i,obj->GetName(),obj->GetTitle());
164 }
165 }
166 }
167}
168
169AliGenEventHeader* AliAODMCHeader::GetCocktailHeader(Int_t i){
170 if(i<0)return 0;
171 return (AliGenEventHeader*)(fHeaders->At(i));
dce1b636 172}
173
08078824 174void AliAODMCHeader::AddCocktailHeaders(AliGenEventHeader* header){
175 AliGenCocktailEventHeader *cHeader = dynamic_cast<AliGenCocktailEventHeader*>(header);
176 if(cHeader){
177 TList *genHeaders = cHeader->GetHeaders();
178 AliGenEventHeader* gH = 0;
179 for (int i=0; i<genHeaders->GetEntries(); i++) {
180 gH = (AliGenEventHeader*)genHeaders->At(i);
181 if(gH){
182 AddGeneratorName(gH->GetName());
183 AddCocktailHeader(dynamic_cast<AliGenEventHeader*>(genHeaders->At(i)));
184 }
185 }
186 }
187 else{
188 // no cocktail header just addd the global header
189 AddCocktailHeader(header);
190 }
191}
192
193void AliAODMCHeader::AddGeneratorName(const char* c){
194 if(fGenerator.Length()==0)fGenerator += c;
195 else {
196 fGenerator += " ";
197 fGenerator += c;
198 }
199}