]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDRun.cxx
Include cstdlib (gcc 4.3.0)
[u/mrichter/AliRoot.git] / STEER / AliESDRun.cxx
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 #include <TNamed.h>
16
17 #include "AliESDRun.h"
18 #include "AliESDVertex.h"
19 #include "AliLog.h"
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
28 ClassImp(AliESDRun)  
29  
30 //______________________________________________________________________________
31 AliESDRun::AliESDRun() :
32   TObject(),
33   fMagneticField(0),
34   fPeriodNumber(0),
35   fRunNumber(0),
36   fRecoVersion(0),
37   fTriggerClasses(kNTriggerClasses)
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.;
41   fTriggerClasses.SetOwner(kTRUE);
42 }
43
44 //______________________________________________________________________________
45 AliESDRun::AliESDRun(const AliESDRun &esd) :
46   TObject(esd),
47   fMagneticField(esd.fMagneticField),
48   fPeriodNumber(esd.fPeriodNumber),
49   fRunNumber(esd.fRunNumber),
50   fRecoVersion(esd.fRecoVersion),
51   fTriggerClasses(TObjArray(kNTriggerClasses))
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];
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   }
61 }
62
63 //______________________________________________________________________________
64 AliESDRun& 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];
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   }
80     
81   } 
82   return *this;
83 }
84
85 void AliESDRun::Copy(TObject &obj) const{
86
87   // this overwrites the virtual TOBject::Copy()
88   // to allow run time copying without casting
89   // in AliESDEvent
90
91   if(this==&obj)return;
92   AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
93   if(!robj)return; // not an aliesdrun
94   *robj = *this;
95
96 }
97
98 void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
99   // set the interaction diamond
100   fDiamondXY[0]=vertex->GetXv();
101   fDiamondXY[1]=vertex->GetYv();
102   Double32_t cov[6];
103   vertex->GetCovMatrix(cov);
104   fDiamondCovXY[0]=cov[0];
105   fDiamondCovXY[1]=cov[1];
106   fDiamondCovXY[2]=cov[2];
107 }
108
109
110 //______________________________________________________________________________
111 void AliESDRun::Print(const Option_t *) const
112 {
113   // Print some data members
114   printf("Mean vertex in RUN %d: X=%.4f Y=%.4f cm\n",
115          GetRunNumber(),GetDiamondX(),GetDiamondY());
116   printf("Magnetic field = %f T\n",
117          GetMagneticField());
118   printf("Event from reconstruction version %d \n",fRecoVersion);
119   
120   printf("List of active trigger classes: ");
121   for(Int_t i = 0; i < kNTriggerClasses; i++) {
122     TNamed *str = (TNamed *)((fTriggerClasses).At(i));
123     printf("%s ",str->GetName());
124   }
125   printf("\n");
126 }
127
128 void AliESDRun::Reset() 
129 {
130   // reset data members
131   fRunNumber = 0;
132   fPeriodNumber = 0;
133   fRecoVersion = 0;
134   fMagneticField = 0;
135   for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
136   for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
137   fTriggerClasses.Clear();
138 }
139
140 //______________________________________________________________________________
141 void AliESDRun::SetTriggerClass(const char*name, Int_t index)
142 {
143   // Fill the trigger class name
144   // into the corresponding array
145   if (index >= kNTriggerClasses || index < 0) {
146     AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
147     return;
148   }
149
150   fTriggerClasses.AddAt(new TNamed(name,NULL),index);
151 }
152
153 //______________________________________________________________________________
154 const char* AliESDRun::GetTriggerClass(Int_t index) const
155 {
156   // Get the trigger class name at
157   // specified position in the trigger mask
158   TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
159   if (trclass)
160     return trclass->GetName();
161   else
162     return "";
163 }
164
165 //______________________________________________________________________________
166 TString AliESDRun::GetActiveTriggerClasses() const
167 {
168   // Construct and return
169   // the list of trigger classes
170   // which are present in the run
171   TString trclasses;
172   for(Int_t i = 0; i < kNTriggerClasses; i++) {
173     TNamed *str = (TNamed *)((fTriggerClasses).At(i));
174     if (str) {
175       trclasses += " ";
176       trclasses += str->GetName();
177       trclasses += " ";
178     }
179   }
180
181   return trclasses;
182 }
183
184 //______________________________________________________________________________
185 TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
186 {
187   // Constructs and returns the
188   // list of trigger classes that
189   // have been fired. Uses the trigger
190   // class mask as an argument.
191   TString trclasses;
192   for(Int_t i = 0; i < kNTriggerClasses; i++) {
193     if (mask & (1 << i)) {
194       TNamed *str = (TNamed *)((fTriggerClasses).At(i));
195       if (str) {
196         trclasses += " ";
197         trclasses += str->GetName();
198       trclasses += " ";
199       }
200     }
201   }
202
203   return trclasses;
204 }
205
206 //______________________________________________________________________________
207 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
208 {
209   // Checks if the trigger class
210   // identified by 'name' has been
211   // fired. Uses the trigger class mask.
212
213   TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
214   if (!trclass) return kFALSE;
215
216   Int_t iclass = fTriggerClasses.IndexOf(trclass);
217   if (iclass < 0) return kFALSE;
218
219   if (mask & (1 << iclass))
220     return kTRUE;
221   else
222     return kFALSE;
223 }