]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDRun.cxx
AliESDHeader: AliTriggerConfiguration and more trigger scalers added
[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 #include <TGeoMatrix.h>
17 #include <TGeoGlobalMagField.h>
18
19 #include "AliESDRun.h"
20 #include "AliESDVertex.h"
21 #include "AliLog.h"
22 #include "AliMagF.h"
23
24 //-------------------------------------------------------------------------
25 //                     Implementation Class AliESDRun
26 //   Run by run data
27 //   for the ESD   
28 //   Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch 
29 //-------------------------------------------------------------------------
30
31 ClassImp(AliESDRun)  
32  
33 //______________________________________________________________________________
34 AliESDRun::AliESDRun() :
35   TObject(),
36   fCurrentL3(0),
37   fCurrentDip(0),
38   fBeamEnergy(0),
39   fMagneticField(0),
40   fDiamondZ(0),
41   fDiamondSig2Z(0),
42   fPeriodNumber(0),
43   fRunNumber(0),
44   fRecoVersion(0),
45   fBeamType(""),
46   fTriggerClasses(kNTriggerClasses),
47   fDetInDAQ(0),
48   fDetInReco(0)
49   
50 {
51   for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
52   fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
53   fDiamondCovXY[1]=0.;
54   fTriggerClasses.SetOwner(kTRUE);
55   fMeanBeamInt[0][0]=fMeanBeamInt[0][1]=fMeanBeamInt[1][0]=fMeanBeamInt[1][1]=-1;
56   for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
57   for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
58   for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=0.;
59   for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=0;
60 }
61
62 //______________________________________________________________________________
63 AliESDRun::AliESDRun(const AliESDRun &esd) :
64   TObject(esd),
65   fCurrentL3(0),
66   fCurrentDip(0),
67   fBeamEnergy(0),
68   fMagneticField(esd.fMagneticField),
69   fDiamondZ(esd.fDiamondZ),
70   fDiamondSig2Z(esd.fDiamondSig2Z),
71   fPeriodNumber(esd.fPeriodNumber),
72   fRunNumber(esd.fRunNumber),
73   fRecoVersion(esd.fRecoVersion),
74   fBeamType(""),
75   fTriggerClasses(TObjArray(kNTriggerClasses)),
76   fDetInDAQ(0),
77   fDetInReco(0)
78
79   // Copy constructor
80   for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
81   for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
82
83   for(Int_t i = 0; i < kNTriggerClasses; i++) {
84     TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
85     if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
86   }
87
88   for(Int_t m=0; m<kNPHOSMatrix; m++){
89     if(esd.fPHOSMatrix[m])
90       fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
91     else
92       fPHOSMatrix[m]=NULL;
93   }
94   
95   for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
96
97   for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
98         if(esd.fEMCALMatrix[sm])
99                 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
100         else
101                 fEMCALMatrix[sm]=NULL;
102   }
103   for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
104   for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
105
106 }
107
108 //______________________________________________________________________________
109 AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
110
111   // assigment operator
112   if(this!=&esd) {
113     TObject::operator=(esd);
114     fRunNumber=esd.fRunNumber;
115     fPeriodNumber=esd.fPeriodNumber;
116     fRecoVersion=esd.fRecoVersion;
117     fMagneticField=esd.fMagneticField;
118     fDiamondZ=esd.fDiamondZ;
119     fDiamondSig2Z=esd.fDiamondSig2Z;
120     fBeamType = esd.fBeamType;
121     fCurrentL3  = esd.fCurrentL3;
122     fCurrentDip = esd.fCurrentDip;
123     fBeamEnergy = esd.fBeamEnergy;
124     for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
125     for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
126     fTriggerClasses.Clear();
127     for(Int_t i = 0; i < kNTriggerClasses; i++) {
128       TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
129       if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
130     }
131
132     fDetInDAQ   = esd.fDetInDAQ;
133     fDetInReco  = esd.fDetInReco;
134
135     for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
136
137     for(Int_t m=0; m<kNPHOSMatrix; m++){
138       if(esd.fPHOSMatrix[m])
139         fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
140       else
141         fPHOSMatrix[m]=0;
142     }
143           
144         for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
145           if(esd.fEMCALMatrix[sm])
146                   fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
147           else
148                   fEMCALMatrix[sm]=0;
149         }
150   } 
151   for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
152   for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
153   return *this;
154 }
155
156 void AliESDRun::Copy(TObject &obj) const{
157
158   // this overwrites the virtual TOBject::Copy()
159   // to allow run time copying without casting
160   // in AliESDEvent
161
162   if(this==&obj)return;
163   AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
164   if(!robj)return; // not an aliesdrun
165   *robj = *this;
166
167 }
168
169 //______________________________________________________________________________
170 AliESDRun::~AliESDRun() {
171   // Destructor
172   // Delete PHOS position matrices
173   for(Int_t m=0; m<kNPHOSMatrix; m++) {
174     if(fPHOSMatrix[m]) delete fPHOSMatrix[m] ;
175     fPHOSMatrix[m] = NULL;
176   }
177   // Delete PHOS position matrices
178   for(Int_t sm=0; sm<kNEMCALMatrix; sm++) {
179         if(fEMCALMatrix[sm]) delete fEMCALMatrix[sm] ;
180         fEMCALMatrix[sm] = NULL;
181   }
182 }
183
184 void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
185   // set the interaction diamond
186   if (vertex) {
187     fDiamondXY[0]=vertex->GetXv();
188     fDiamondXY[1]=vertex->GetYv();
189     fDiamondZ=vertex->GetZv();
190     Double32_t cov[6];
191     vertex->GetCovMatrix(cov);
192     fDiamondCovXY[0]=cov[0];
193     fDiamondCovXY[1]=cov[1];
194     fDiamondCovXY[2]=cov[2];
195     fDiamondSig2Z=cov[5];
196   }
197 }
198
199
200 //______________________________________________________________________________
201 void AliESDRun::Print(const Option_t *) const
202 {
203   // Print some data members
204   printf("Mean vertex in RUN %d: X=%.4f Y=%.4f Z=%.4f cm\n",
205          GetRunNumber(),GetDiamondX(),GetDiamondY(),GetDiamondZ());
206   printf("Beam Type: %s, Energy: %.1f GeV\n",fBeamType.IsNull() ? "N/A":fBeamType.Data(),fBeamEnergy);
207   printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
208          GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
209   printf("Event from reconstruction version %d \n",fRecoVersion);
210   
211   printf("List of active trigger classes: ");
212   for(Int_t i = 0; i < kNTriggerClasses; i++) {
213     TNamed *str = (TNamed *)((fTriggerClasses).At(i));
214     if (str) printf("%s ",str->GetName());
215   }
216   printf("Mean intenstity for interacting   : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][0],fMeanBeamInt[1][0]);
217   printf("Mean intenstity for non-intecting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][1],fMeanBeamInt[1][1]);
218   printf("\n");
219 }
220
221 void AliESDRun::Reset() 
222 {
223   // reset data members
224   fRunNumber = 0;
225   fPeriodNumber = 0;
226   fRecoVersion = 0;
227   fMagneticField = 0;
228   fCurrentL3 = 0;
229   fCurrentDip = 0;
230   fBeamEnergy = 0;
231   fBeamType = "";
232   ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
233   for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
234   fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
235   fDiamondCovXY[1]=0.;
236   fDiamondZ=0.;
237   fDiamondSig2Z=10.*10.;
238   fTriggerClasses.Clear();
239   fDetInDAQ   = 0;
240   fDetInReco  = 0;
241 }
242
243 //______________________________________________________________________________
244 void AliESDRun::SetTriggerClass(const char*name, Int_t index)
245 {
246   // Fill the trigger class name
247   // into the corresponding array
248   if (index >= kNTriggerClasses || index < 0) {
249     AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
250     return;
251   }
252
253   fTriggerClasses.AddAt(new TNamed(name,NULL),index);
254 }
255
256 //______________________________________________________________________________
257 const char* AliESDRun::GetTriggerClass(Int_t index) const
258 {
259   // Get the trigger class name at
260   // specified position in the trigger mask
261   TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
262   if (trclass)
263     return trclass->GetName();
264   else
265     return "";
266 }
267
268 //______________________________________________________________________________
269 TString AliESDRun::GetActiveTriggerClasses() const
270 {
271   // Construct and return
272   // the list of trigger classes
273   // which are present in the run
274   TString trclasses;
275   for(Int_t i = 0; i < kNTriggerClasses; i++) {
276     TNamed *str = (TNamed *)((fTriggerClasses).At(i));
277     if (str) {
278       trclasses += " ";
279       trclasses += str->GetName();
280       trclasses += " ";
281     }
282   }
283
284   return trclasses;
285 }
286
287 //______________________________________________________________________________
288 TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
289 {
290   // Constructs and returns the
291   // list of trigger classes that
292   // have been fired. Uses the trigger
293   // class mask as an argument.
294   TString trclasses;
295   for(Int_t i = 0; i < kNTriggerClasses; i++) {
296     if (mask & (1ull << i)) {
297       TNamed *str = (TNamed *)((fTriggerClasses).At(i));
298       if (str) {
299         trclasses += " ";
300         trclasses += str->GetName();
301       trclasses += " ";
302       }
303     }
304   }
305
306   return trclasses;
307 }
308
309 //______________________________________________________________________________
310 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
311 {
312   // Checks if the trigger class
313   // identified by 'name' has been
314   // fired. Uses the trigger class mask.
315
316   TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
317   if (!trclass) return kFALSE;
318
319   Int_t iclass = fTriggerClasses.IndexOf(trclass);
320   if (iclass < 0) return kFALSE;
321
322   if (mask & (1ull << iclass))
323     return kTRUE;
324   else
325     return kFALSE;
326 }
327
328 //_____________________________________________________________________________
329 Bool_t AliESDRun::InitMagneticField() const
330 {
331   // Create mag field from stored information
332   //
333   if (!TestBit(kBInfoStored)) {
334     AliError("No information on currents, cannot create field from run header");
335     return kFALSE;
336   }
337   //
338   if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
339     if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
340       AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
341       AliInfo("ExpertMode!!! Running with the externally locked B field !");
342       return kTRUE;
343     }
344     else {
345       AliInfo("Destroying existing B field instance!");
346       delete TGeoGlobalMagField::Instance();
347     }
348   }
349   //
350   AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
351                                          TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
352   if (fld) {
353     TGeoGlobalMagField::Instance()->SetField( fld );
354     TGeoGlobalMagField::Instance()->Lock();
355     AliInfo("Running with the B field constructed out of the Run Header !");
356     return kTRUE;
357   }
358   else {
359     AliError("Failed to create a B field map !");
360     return kFALSE;
361   }
362   //
363 }
364
365 //_____________________________________________________________________________
366 void AliESDRun::SetT0spread(Int_t i,Float_t t) 
367 {
368   //
369   // Setting the T0 spread value at index i 
370   //
371
372   if ( (i>=0) && (i<kT0spreadSize)) {
373     fT0spread[i]=t;
374   } else {
375     AliError(Form("Index %d out of bound",i));
376   }
377   return;
378 }
379
380 //_____________________________________________________________________________
381 void AliESDRun::SetT0spread(Float_t *t) 
382 {
383   //
384   // Setting the T0 spread values
385   //
386   if (t == 0x0){
387     AliError(Form("Null pointer passed"));
388   }
389   else{
390     for (Int_t i=0;i<kT0spreadSize;i++) fT0spread[i]=t[i];
391   }
392   return;
393 }
394