Line data Source code
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 :
23 : #include "TList.h"
24 : #include "AliAODMCHeader.h"
25 : #include "AliGenEventHeader.h"
26 : #include "AliGenCocktailEventHeader.h"
27 :
28 :
29 :
30 :
31 170 : ClassImp(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....
36 170 : TString AliAODMCHeader::fgkStdBranchName("mcHeader");
37 :
38 : //______________________________________________________________________________
39 :
40 : AliAODMCHeader::AliAODMCHeader() :
41 1 : AliVHeader()
42 1 : ,fGenerator("")
43 1 : ,fImpactPar(0)
44 1 : ,fPtHard(0)
45 1 : ,fXsection(0)
46 1 : ,fTrials(0)
47 1 : ,fEventType(0)
48 1 : ,fReactionPlaneAngle(0)
49 1 : ,fHeaders(0)
50 5 : {
51 : // default constructor
52 1 : fVertex[0] = fVertex[1] = fVertex[2] = 0;
53 2 : SetName(fgkStdBranchName.Data());
54 2 : }
55 :
56 :
57 : AliAODMCHeader::~AliAODMCHeader()
58 0 : {
59 :
60 0 : Reset();
61 0 : delete fHeaders;
62 : // destructor
63 0 : }
64 :
65 :
66 : AliAODMCHeader::AliAODMCHeader(const AliAODMCHeader &header) :
67 0 : AliVHeader(header)
68 0 : ,fGenerator(header.fGenerator)
69 0 : ,fImpactPar(header.fImpactPar)
70 0 : ,fPtHard(header.fPtHard)
71 0 : ,fXsection(0)
72 0 : ,fTrials(0)
73 0 : ,fEventType(header.fEventType)
74 0 : ,fReactionPlaneAngle(header.fReactionPlaneAngle)
75 0 : ,fHeaders(0)
76 0 : {
77 : // copy constructor
78 0 : for(int i = 0;i<3;++i)fVertex[i] = header.fVertex[i];
79 0 : SetName(header.fName);
80 0 : SetTitle(header.fTitle);
81 0 : }
82 :
83 : AliAODMCHeader& AliAODMCHeader::operator=(const AliAODMCHeader &header)
84 : {
85 : // assigment operator
86 :
87 0 : if(this!=&header) {
88 0 : Reset();
89 0 : AliVHeader::operator=(header);
90 0 : fGenerator = header.fGenerator;
91 0 : for(int i = 0;i<3;++i)fVertex[i] = header.fVertex[i];
92 0 : fImpactPar = header.fImpactPar;
93 0 : fPtHard = header.fPtHard;
94 0 : fXsection = header.fXsection;
95 0 : fTrials = header.fTrials;
96 0 : fEventType = header.fEventType;
97 0 : fReactionPlaneAngle = header.fReactionPlaneAngle;
98 :
99 0 : if(header.fHeaders){
100 0 : for(int i = 0;i < header.fHeaders->GetEntries();i++){
101 0 : AddCocktailHeader(dynamic_cast<AliGenEventHeader*>(header.fHeaders->At(i)));
102 : }
103 0 : }
104 : }
105 0 : return *this;
106 : }
107 :
108 : void AliAODMCHeader::AddCocktailHeader(const AliGenEventHeader* header)
109 : {
110 : // Add a header to the list
111 32 : if(!header)return;
112 16 : if (!fHeaders){
113 2 : fHeaders = new TList();
114 1 : fHeaders->SetOwner(kTRUE);
115 1 : }
116 16 : fHeaders->Add(header->Clone());
117 32 : }
118 :
119 : void 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 0 : if(this==&obj)return;
126 0 : AliAODMCHeader *robj = dynamic_cast<AliAODMCHeader*>(&obj);
127 0 : if(!robj)return; // not an AliAODMCHeader
128 0 : *robj = *this;
129 :
130 0 : }
131 :
132 :
133 :
134 : //______________________________________________________________________________
135 : void AliAODMCHeader::Reset()
136 : {
137 : // reset all data members
138 8 : fGenerator = "";
139 4 : fImpactPar = 0;
140 4 : fEventType = 0;
141 4 : fPtHard = 0;
142 4 : fXsection = 0;
143 4 : fTrials = 0;
144 4 : fVertex[0] = fVertex[1] = fVertex[2] = 0;
145 4 : fReactionPlaneAngle = 0;
146 8 : if(fHeaders)fHeaders->Delete();
147 4 : }
148 :
149 : //______________________________________________________________________________
150 : void AliAODMCHeader::Print(const Option_t *) const
151 : {
152 : // Print some data members
153 0 : Printf("MC EventHeader Generators: %s # EventType %d Vtx = (%3.3f,%3.3f,%3.3f) ptHard = %3.3f GeV Impact parameter %3.3f \n",
154 0 : GetGeneratorName(),
155 0 : GetEventType(),
156 0 : GetVtxX(),GetVtxY(),GetVtxZ(),GetPtHard(),
157 0 : GetImpactParameter());
158 0 : if(fHeaders){
159 0 : fHeaders->Print();
160 0 : for(int i = 0;i<fHeaders->GetEntries();++i){
161 0 : TObject *obj = fHeaders->At(i);
162 0 : if(obj){
163 0 : Printf(">> %d: %s %s",i,obj->GetName(),obj->GetTitle());
164 0 : }
165 : }
166 0 : }
167 0 : }
168 :
169 : AliGenEventHeader* AliAODMCHeader::GetCocktailHeader(Int_t i){
170 0 : if(i<0)return 0;
171 0 : return (AliGenEventHeader*)(fHeaders->At(i));
172 0 : }
173 :
174 : void AliAODMCHeader::AddCocktailHeaders(AliGenEventHeader* header){
175 16 : AliGenCocktailEventHeader *cHeader = dynamic_cast<AliGenCocktailEventHeader*>(header);
176 4 : if(cHeader){
177 4 : TList *genHeaders = cHeader->GetHeaders();
178 : AliGenEventHeader* gH = 0;
179 40 : for (int i=0; i<genHeaders->GetEntries(); i++) {
180 16 : gH = (AliGenEventHeader*)genHeaders->At(i);
181 16 : if(gH){
182 16 : AddGeneratorName(gH->GetName());
183 48 : AddCocktailHeader(dynamic_cast<AliGenEventHeader*>(genHeaders->At(i)));
184 16 : }
185 : }
186 4 : }
187 : else{
188 : // no cocktail header just addd the global header
189 0 : AddCocktailHeader(header);
190 : }
191 4 : }
192 :
193 : void AliAODMCHeader::AddGeneratorName(const char* c){
194 44 : if(fGenerator.Length()==0)fGenerator += c;
195 : else {
196 16 : fGenerator += " ";
197 16 : fGenerator += c;
198 : }
199 20 : }
|