ACORDEv1 is now the default
[u/mrichter/AliRoot.git] / STEER / AliHeader.cxx
CommitLineData
4c039060 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
acd84897 16/* $Id$ */
e2afb3b6 17
116cbefd 18//-----------------------------------------------------------------------
116cbefd 19// Simulation event header class
5d8718b8 20// Collaborates with AliRun, AliStack, and AliGenReaderTreeK classes
21// Many other classes depend on it
22// Author:
116cbefd 23//-----------------------------------------------------------------------
24
b961264c 25
fb17acd4 26#include <stdio.h>
b961264c 27#include <TObjArray.h>
4c039060 28
594d8990 29#include "AliLog.h"
fe4da5cc 30#include "AliHeader.h"
b961264c 31#include "AliDetectorEventHeader.h"
32#include "AliGenEventHeader.h"
33
fe4da5cc 34
35ClassImp(AliHeader)
36
e2afb3b6 37//_______________________________________________________________________
38AliHeader::AliHeader():
3d45e923 39 fRun(-1),
e2afb3b6 40 fNvertex(0),
41 fNprimary(0),
42 fNtrack(0),
43 fEvent(0),
44 fEventNrInRun(0),
45 fStack(0),
b961264c 46 fGenHeader(0),
47 fDetHeaders(0)
fe4da5cc 48{
8918e700 49 //
50 // Default constructor
51 //
f7882672 52 printf("I was here\n");
fe4da5cc 53}
54
e2afb3b6 55//_______________________________________________________________________
56AliHeader::AliHeader(const AliHeader& head):
57 TObject(head),
3d45e923 58 fRun(-1),
e2afb3b6 59 fNvertex(0),
60 fNprimary(0),
61 fNtrack(0),
62 fEvent(0),
63 fEventNrInRun(0),
64 fStack(0),
b961264c 65 fGenHeader(0),
66 fDetHeaders(0)
fe4da5cc 67{
8918e700 68 //
e2afb3b6 69 // Copy constructor
8918e700 70 //
e2afb3b6 71 head.Copy(*this);
fe4da5cc 72}
73
e2afb3b6 74//_______________________________________________________________________
75AliHeader::AliHeader(Int_t run, Int_t event):
76 fRun(run),
77 fNvertex(0),
78 fNprimary(0),
79 fNtrack(0),
80 fEvent(event),
81 fEventNrInRun(0),
82 fStack(0),
b961264c 83 fGenHeader(0),
84 fDetHeaders(0)
eef4b160 85{
86 //
87 // Standard constructor
88 //
eef4b160 89}
90
e2afb3b6 91//_______________________________________________________________________
92AliHeader::AliHeader(Int_t run, Int_t event, Int_t evNumber):
93 fRun(run),
94 fNvertex(0),
95 fNprimary(0),
96 fNtrack(0),
97 fEvent(event),
98 fEventNrInRun(evNumber),
99 fStack(0),
b961264c 100 fGenHeader(0),
101 fDetHeaders(0)
e2afb3b6 102{
103 //
104 // Standard constructor
105 //
106}
eef4b160 107
b961264c 108AliHeader::~AliHeader()
109{
110 //
111 // Destructor
112 //
113 if (fDetHeaders) {
114 fDetHeaders->Delete();
115 delete fDetHeaders;
116 }
117 delete fGenHeader;
118}
119
120
121
e2afb3b6 122//_______________________________________________________________________
fe4da5cc 123void AliHeader::Reset(Int_t run, Int_t event)
124{
8918e700 125 //
126 // Resets the header with new run and event number
127 //
fe4da5cc 128 fRun=run;
129 fNvertex=0;
130 fNprimary=0;
131 fNtrack=0;
132 fEvent=event;
816276f1 133 if (fDetHeaders) fDetHeaders->Delete();
fe4da5cc 134}
135
e2afb3b6 136//_______________________________________________________________________
eef4b160 137void AliHeader::Reset(Int_t run, Int_t event, Int_t evNumber)
138{
139 //
140 // Resets the header with new run and event number
141 //
142 fRun=run;
143 fNvertex=0;
144 fNprimary=0;
145 fNtrack=0;
146 fEvent=event;
147 fEventNrInRun=evNumber;
b961264c 148 if (fDetHeaders) fDetHeaders->Clear();
eef4b160 149}
150
e2afb3b6 151//_______________________________________________________________________
152void AliHeader::Print(const char*) const
fe4da5cc 153{
8918e700 154 //
155 // Dumps header content
156 //
fe4da5cc 157 printf(
158"\n=========== Header for run %d Event %d = beginning ======================================\n",
159 fRun,fEvent);
160 printf(" Number of Vertex %d\n",fNvertex);
161 printf(" Number of Primary %d\n",fNprimary);
162 printf(" Number of Tracks %d\n",fNtrack);
163 printf(
164 "=========== Header for run %d Event %d = end ============================================\n\n",
165 fRun,fEvent);
9e1a0ddb 166
167}
168
e2afb3b6 169//_______________________________________________________________________
bdbd0f7a 170AliStack* AliHeader::Stack() const
9e1a0ddb 171{
172// Return pointer to stack
173 return fStack;
174}
175
e2afb3b6 176//_______________________________________________________________________
bdbd0f7a 177void AliHeader::SetStack(AliStack* stack)
9e1a0ddb 178{
179// Set pointer to stack
180 fStack = stack;
181}
182
e2afb3b6 183//_______________________________________________________________________
bdbd0f7a 184void AliHeader::SetGenEventHeader(AliGenEventHeader* header)
9e1a0ddb 185{
186// Set pointer to header for generated event
187 fGenHeader = header;
188}
189
b961264c 190void AliHeader::AddDetectorEventHeader(AliDetectorEventHeader* header)
191{
192// Add a detector specific header
193//
194// Create the array of headers
195 if (!fDetHeaders) fDetHeaders = new TObjArray(77);
196
197// Some basic checks
198
199 if (!header) {
200 Warning("AddDetectorEventHeader","Detector %s tries to add empty header \n", header->GetName());
201 return;
202 }
203
204 if (strlen(header->GetName()) == 0) {
205 Warning("AddDetectorEventHeader","Detector %s tries to add header without name \n", header->GetName());
206 return;
207 }
208
209 TObject *mod=fDetHeaders->FindObject(header->GetName());
210 if(mod) {
211 Warning("AddDetectorEventHeader","Detector %s tries to add more than one header \n", header->GetName());
212 return;
213 }
214
215
216// Add the header to the list
217 fDetHeaders->Add(header);
218}
219
220AliDetectorEventHeader* AliHeader::GetDetectorEventHeader(const char *name) const
221{
222//
223// Returns detector specific event header
224//
225 if (!fDetHeaders) {
226 Warning("GetDetectorEventHeader","There are no detector specific headers for this event");
227 return 0x0;
228 }
229 return dynamic_cast<AliDetectorEventHeader*>(fDetHeaders->FindObject(name)) ;
230}
231
232
e2afb3b6 233//_______________________________________________________________________
5d34b719 234AliGenEventHeader* AliHeader::GenEventHeader() const
9e1a0ddb 235{
236// Get pointer to header for generated event
237 return fGenHeader;
fe4da5cc 238}
bdbd0f7a 239
e2afb3b6 240//_______________________________________________________________________
6c4904c2 241void AliHeader::Copy(TObject&) const
e2afb3b6 242{
594d8990 243 AliFatal("Not implemented");
e2afb3b6 244}
bdbd0f7a 245
246
247