For primary tracks, when mother-particle is defined, add label and
[u/mrichter/AliRoot.git] / STEER / AliESDRun.cxx
CommitLineData
d5ebf00e 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 **************************************************************************/
f009b5c1 15#include <TNamed.h>
d5ebf00e 16
17#include "AliESDRun.h"
18#include "AliESDVertex.h"
f009b5c1 19#include "AliLog.h"
d5ebf00e 20
21//-------------------------------------------------------------------------
22// Implementation Class AliESDRun
23// Run by run data
24// for the ESD
25// Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
26//-------------------------------------------------------------------------
27
28ClassImp(AliESDRun)
29
30//______________________________________________________________________________
31AliESDRun::AliESDRun() :
694aad0c 32 TObject(),
33 fMagneticField(0),
d5ebf00e 34 fPeriodNumber(0),
694aad0c 35 fRunNumber(0),
f009b5c1 36 fRecoVersion(0),
37 fTriggerClasses(kNTriggerClasses)
d5ebf00e 38{
39 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
40 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
f009b5c1 41 fTriggerClasses.SetOwner(kTRUE);
d5ebf00e 42}
43
44//______________________________________________________________________________
45AliESDRun::AliESDRun(const AliESDRun &esd) :
46 TObject(esd),
694aad0c 47 fMagneticField(esd.fMagneticField),
d5ebf00e 48 fPeriodNumber(esd.fPeriodNumber),
694aad0c 49 fRunNumber(esd.fRunNumber),
f009b5c1 50 fRecoVersion(esd.fRecoVersion),
51 fTriggerClasses(TObjArray(kNTriggerClasses))
d5ebf00e 52{
53 // Copy constructor
54 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
55 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
f009b5c1 56
57 for(Int_t i = 0; i < kNTriggerClasses; i++) {
58 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
59 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
60 }
d5ebf00e 61}
62
63//______________________________________________________________________________
64AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
65{
66 // assigment operator
67 if(this!=&esd) {
68 TObject::operator=(esd);
69 fRunNumber=esd.fRunNumber;
70 fPeriodNumber=esd.fPeriodNumber;
71 fRecoVersion=esd.fRecoVersion;
72 fMagneticField=esd.fMagneticField;
73 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
74 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
f009b5c1 75 fTriggerClasses.Clear();
76 for(Int_t i = 0; i < kNTriggerClasses; i++) {
77 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
78 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
79 }
d5ebf00e 80 }
81 return *this;
82}
83
84void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
85 // set the interaction diamond
86 fDiamondXY[0]=vertex->GetXv();
87 fDiamondXY[1]=vertex->GetYv();
88 Double32_t cov[6];
89 vertex->GetCovMatrix(cov);
90 fDiamondCovXY[0]=cov[0];
91 fDiamondCovXY[1]=cov[1];
92 fDiamondCovXY[2]=cov[2];
93}
94
95
96//______________________________________________________________________________
97void AliESDRun::Print(const Option_t *) const
98{
99 // Print some data members
100 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f cm\n",
101 GetRunNumber(),GetDiamondX(),GetDiamondY());
102 printf("Magnetic field = %f T\n",
103 GetMagneticField());
104 printf("Event from reconstruction version %d \n",fRecoVersion);
f009b5c1 105
106 printf("List of active trigger classes: ");
107 for(Int_t i = 0; i < kNTriggerClasses; i++) {
108 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
109 printf("%s ",str->GetName());
110 }
111 printf("\n");
d5ebf00e 112}
113
114void AliESDRun::Reset()
115{
116 // reset data members
117 fRunNumber = 0;
118 fPeriodNumber = 0;
119 fRecoVersion = 0;
120 fMagneticField = 0;
121 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
122 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
f009b5c1 123 fTriggerClasses.Clear();
124}
125
126//______________________________________________________________________________
127void AliESDRun::SetTriggerClass(const char*name, Int_t index)
128{
129 // Fill the trigger class name
130 // into the corresponding array
131 if (index >= kNTriggerClasses || index < 0) {
132 AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
133 return;
134 }
135
136 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
137}
138
139//______________________________________________________________________________
140const char* AliESDRun::GetTriggerClass(Int_t index) const
141{
142 // Get the trigger class name at
143 // specified position in the trigger mask
144 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
145 if (trclass)
146 return trclass->GetName();
147 else
148 return "";
149}
150
151//______________________________________________________________________________
152TString AliESDRun::GetActiveTriggerClasses() const
153{
154 // Construct and return
155 // the list of trigger classes
156 // which are present in the run
157 TString trclasses;
158 for(Int_t i = 0; i < kNTriggerClasses; i++) {
159 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
160 if (str) {
161 trclasses += " ";
162 trclasses += str->GetName();
163 trclasses += " ";
164 }
165 }
166
167 return trclasses;
168}
169
170//______________________________________________________________________________
171TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
172{
173 // Constructs and returns the
174 // list of trigger classes that
175 // have been fired. Uses the trigger
176 // class mask as an argument.
177 TString trclasses;
178 for(Int_t i = 0; i < kNTriggerClasses; i++) {
2c736180 179 if (mask & (1 << i)) {
f009b5c1 180 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
181 if (str) {
182 trclasses += " ";
183 trclasses += str->GetName();
184 trclasses += " ";
185 }
186 }
187 }
188
189 return trclasses;
d5ebf00e 190}
191
f009b5c1 192//______________________________________________________________________________
193Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
194{
195 // Checks if the trigger class
196 // identified by 'name' has been
197 // fired. Uses the trigger class mask.
198
199 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
200 if (!trclass) return kFALSE;
201
202 Int_t iclass = fTriggerClasses.IndexOf(trclass);
203 if (iclass < 0) return kFALSE;
204
2c736180 205 if (mask & (1 << iclass))
f009b5c1 206 return kTRUE;
207 else
208 return kFALSE;
209}