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