1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 #include <TGeoMatrix.h>
17 #include <TGeoGlobalMagField.h>
19 #include "AliESDRun.h"
20 #include "AliESDVertex.h"
24 //-------------------------------------------------------------------------
25 // Implementation Class AliESDRun
28 // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
29 //-------------------------------------------------------------------------
33 //______________________________________________________________________________
34 AliESDRun::AliESDRun() :
46 fTriggerClasses(kNTriggerClasses),
50 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
51 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
53 fTriggerClasses.SetOwner(kTRUE);
54 fMeanBeamInt[0][0]=fMeanBeamInt[0][1]=fMeanBeamInt[1][0]=fMeanBeamInt[1][1]=-1;
55 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
56 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
59 //______________________________________________________________________________
60 AliESDRun::AliESDRun(const AliESDRun &esd) :
65 fMagneticField(esd.fMagneticField),
66 fDiamondZ(esd.fDiamondZ),
67 fDiamondSig2Z(esd.fDiamondSig2Z),
68 fPeriodNumber(esd.fPeriodNumber),
69 fRunNumber(esd.fRunNumber),
70 fRecoVersion(esd.fRecoVersion),
72 fTriggerClasses(TObjArray(kNTriggerClasses)),
77 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
78 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
80 for(Int_t i = 0; i < kNTriggerClasses; i++) {
81 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
82 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
85 for(Int_t m=0; m<kNPHOSMatrix; m++){
86 if(esd.fPHOSMatrix[m])
87 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
92 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
94 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
95 if(esd.fEMCALMatrix[sm])
96 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
98 fEMCALMatrix[sm]=NULL;
102 //______________________________________________________________________________
103 AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
105 // assigment operator
107 TObject::operator=(esd);
108 fRunNumber=esd.fRunNumber;
109 fPeriodNumber=esd.fPeriodNumber;
110 fRecoVersion=esd.fRecoVersion;
111 fMagneticField=esd.fMagneticField;
112 fDiamondZ=esd.fDiamondZ;
113 fDiamondSig2Z=esd.fDiamondSig2Z;
114 fBeamType = esd.fBeamType;
115 fCurrentL3 = esd.fCurrentL3;
116 fCurrentDip = esd.fCurrentDip;
117 fBeamEnergy = esd.fBeamEnergy;
118 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
119 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
120 fTriggerClasses.Clear();
121 for(Int_t i = 0; i < kNTriggerClasses; i++) {
122 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
123 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
126 fDetInDAQ = esd.fDetInDAQ;
127 fDetInReco = esd.fDetInReco;
129 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
131 for(Int_t m=0; m<kNPHOSMatrix; m++){
132 if(esd.fPHOSMatrix[m])
133 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
138 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
139 if(esd.fEMCALMatrix[sm])
140 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
148 void AliESDRun::Copy(TObject &obj) const{
150 // this overwrites the virtual TOBject::Copy()
151 // to allow run time copying without casting
154 if(this==&obj)return;
155 AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
156 if(!robj)return; // not an aliesdrun
161 //______________________________________________________________________________
162 AliESDRun::~AliESDRun() {
164 // Delete PHOS position matrices
165 for(Int_t m=0; m<kNPHOSMatrix; m++) {
166 if(fPHOSMatrix[m]) delete fPHOSMatrix[m] ;
167 fPHOSMatrix[m] = NULL;
169 // Delete PHOS position matrices
170 for(Int_t sm=0; sm<kNEMCALMatrix; sm++) {
171 if(fEMCALMatrix[sm]) delete fEMCALMatrix[sm] ;
172 fEMCALMatrix[sm] = NULL;
176 void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
177 // set the interaction diamond
178 fDiamondXY[0]=vertex->GetXv();
179 fDiamondXY[1]=vertex->GetYv();
180 fDiamondZ=vertex->GetZv();
182 vertex->GetCovMatrix(cov);
183 fDiamondCovXY[0]=cov[0];
184 fDiamondCovXY[1]=cov[1];
185 fDiamondCovXY[2]=cov[2];
186 fDiamondSig2Z=cov[5];
190 //______________________________________________________________________________
191 void AliESDRun::Print(const Option_t *) const
193 // Print some data members
194 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f Z=%.4f cm\n",
195 GetRunNumber(),GetDiamondX(),GetDiamondY(),GetDiamondZ());
196 printf("Beam Type: %s, Energy: %.1f GeV\n",fBeamType.IsNull() ? "N/A":fBeamType.Data(),fBeamEnergy);
197 printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
198 GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
199 printf("Event from reconstruction version %d \n",fRecoVersion);
201 printf("List of active trigger classes: ");
202 for(Int_t i = 0; i < kNTriggerClasses; i++) {
203 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
204 if (str) printf("%s ",str->GetName());
206 printf("Mean intenstity for interacting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][0],fMeanBeamInt[1][0]);
207 printf("Mean intenstity for non-intecting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][1],fMeanBeamInt[1][1]);
211 void AliESDRun::Reset()
213 // reset data members
222 ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
223 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
224 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
227 fDiamondSig2Z=10.*10.;
228 fTriggerClasses.Clear();
233 //______________________________________________________________________________
234 void AliESDRun::SetTriggerClass(const char*name, Int_t index)
236 // Fill the trigger class name
237 // into the corresponding array
238 if (index >= kNTriggerClasses || index < 0) {
239 AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
243 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
246 //______________________________________________________________________________
247 const char* AliESDRun::GetTriggerClass(Int_t index) const
249 // Get the trigger class name at
250 // specified position in the trigger mask
251 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
253 return trclass->GetName();
258 //______________________________________________________________________________
259 TString AliESDRun::GetActiveTriggerClasses() const
261 // Construct and return
262 // the list of trigger classes
263 // which are present in the run
265 for(Int_t i = 0; i < kNTriggerClasses; i++) {
266 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
269 trclasses += str->GetName();
277 //______________________________________________________________________________
278 TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
280 // Constructs and returns the
281 // list of trigger classes that
282 // have been fired. Uses the trigger
283 // class mask as an argument.
285 for(Int_t i = 0; i < kNTriggerClasses; i++) {
286 if (mask & (1ull << i)) {
287 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
290 trclasses += str->GetName();
299 //______________________________________________________________________________
300 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
302 // Checks if the trigger class
303 // identified by 'name' has been
304 // fired. Uses the trigger class mask.
306 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
307 if (!trclass) return kFALSE;
309 Int_t iclass = fTriggerClasses.IndexOf(trclass);
310 if (iclass < 0) return kFALSE;
312 if (mask & (1ull << iclass))
318 //_____________________________________________________________________________
319 Bool_t AliESDRun::InitMagneticField() const
321 // Create mag field from stored information
323 if (!TestBit(kBInfoStored)) {
324 AliError("No information on currents, cannot create field from run header");
328 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
329 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
330 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
331 AliInfo("ExpertMode!!! Running with the externally locked B field !");
335 AliInfo("Destroying existing B field instance!");
336 delete TGeoGlobalMagField::Instance();
340 AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
341 TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
343 TGeoGlobalMagField::Instance()->SetField( fld );
344 TGeoGlobalMagField::Instance()->Lock();
345 AliInfo("Running with the B field constructed out of the Run Header !");
349 AliError("Failed to create a B field map !");