]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AOD/AliAODHeader.h
Added possibility to load automatically the field in analysis via AliInputEventHandle...
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODHeader.h
1 #ifndef ALIAODHEADER_H
2 #define ALIAODHEADER_H
3 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 //-------------------------------------------------------------------------
9 //     AOD event header class
10 //     Author: Markus Oldenburg, CERN
11 //-------------------------------------------------------------------------
12
13 #include <TVector2.h>
14
15 #include "AliVHeader.h"
16 #include "AliAODVertex.h"
17 #include <TString.h>
18 #include <TBits.h>
19 #include "AliCentrality.h"
20 #include "AliEventplane.h"
21
22 class TGeoHMatrix;
23 class TString;
24
25
26 class AliAODHeader : public AliVHeader {
27
28  public :
29   AliAODHeader();
30  
31   AliAODHeader(Int_t nRun, UShort_t nBunchX, UInt_t nOrbit, UInt_t nPeriod, const Char_t *title="");
32   AliAODHeader(Int_t nRun, 
33                UShort_t nBunchX,
34                UInt_t nOrbit,
35                UInt_t nPeriod,
36                Int_t refMult,
37                Int_t refMultPos,
38                Int_t refMultNeg,
39                Int_t refMultComb05,
40                Int_t refMultComb08,
41                Double_t magField,
42                Double_t muonMagFieldScale,
43                Double_t cent,
44                Double_t eventplane,
45                Double_t n1Energy,
46                Double_t p1Energy,
47                Double_t n2Energy,
48                Double_t p2Energy,
49                Double_t *emEnergy,
50                ULong64_t fTriggerMask,
51                UChar_t   fTriggerCluster,
52                UInt_t    fEventType,
53                const Float_t *vzeroEqFactors,
54                const Char_t *title="",
55                Int_t nMuons=0,
56                Int_t nDimuons=0);
57   
58   virtual ~AliAODHeader();
59   AliAODHeader(const AliAODHeader& evt); 
60   AliAODHeader& operator=(const AliAODHeader& evt);
61   Bool_t    InitMagneticField() const;
62
63   Int_t     GetRunNumber()          const { return fRunNumber;}
64   Int_t     GetEventNumberESDFile() const { return fEventNumberESDFile;}
65   Int_t     GetNumberOfESDTracks()    const { return fNumberESDTracks;}
66   UShort_t  GetBunchCrossNumber()   const { return fBunchCrossNumber; }
67   UInt_t    GetOrbitNumber()        const { return fOrbitNumber; }
68   UInt_t    GetPeriodNumber()       const { return fPeriodNumber; }
69   ULong64_t GetTriggerMask()        const { return fTriggerMask; }
70   UChar_t   GetTriggerCluster()     const { return fTriggerCluster; }
71   TString   GetFiredTriggerClasses()const { return fFiredTriggers;}
72   UInt_t    GetEventType()          const { return fEventType; }
73   Double_t  GetMagneticField()      const { return fMagneticField; }
74   Double_t  GetMuonMagFieldScale()  const { return fMuonMagFieldScale; }
75   
76   Double_t  GetCentrality()         const { return fCentrality; }
77   Double_t  GetEventplane()         const { return fEventplane; }
78   Double_t  GetEventplaneMag()      const { return fEventplaneMag; }
79   Double_t  GetEventplaneQx()       const { return fEventplaneQx; }
80   Double_t  GetEventplaneQy()       const { return fEventplaneQy; }
81   Double_t  GetZDCN1Energy()        const { return fZDCN1Energy; }
82   Double_t  GetZDCP1Energy()        const { return fZDCP1Energy; }
83   Double_t  GetZDCN2Energy()        const { return fZDCN2Energy; }
84   Double_t  GetZDCP2Energy()        const { return fZDCP2Energy; }
85   Double_t  GetZDCEMEnergy(Int_t i) const { return fZDCEMEnergy[i]; }
86   Int_t     GetRefMultiplicity()    const { return fRefMult; }
87   Int_t     GetRefMultiplicityPos() const { return fRefMultPos; }
88   Int_t     GetRefMultiplicityNeg() const { return fRefMultNeg; }
89   Int_t     GetNumberOfMuons()      const { return fNMuons; }
90   Int_t     GetNumberOfDimuons()    const { return fNDimuons; }
91   Int_t     GetRefMultiplicityComb05() const { return fRefMultComb05; }
92   Int_t     GetRefMultiplicityComb08() const { return fRefMultComb08; }
93
94   Double_t  GetQTheta(UInt_t i) const;
95   UInt_t    GetNQTheta() const { return (UInt_t)fNQTheta; }
96
97   Double_t GetDiamondX() const {return fDiamondXY[0];}
98   Double_t GetDiamondY() const {return fDiamondXY[1];}
99   Double_t GetDiamondZ() const {return fDiamondZ;}
100   Double_t GetSigma2DiamondX() const {return fDiamondCovXY[0];}
101   Double_t GetSigma2DiamondY() const {return fDiamondCovXY[2];}
102   Double_t GetSigma2DiamondZ() const {return fDiamondSig2Z;}
103   void GetDiamondCovXY(Float_t cov[3]) const {
104     for(Int_t i=0;i<3;i++) cov[i]=fDiamondCovXY[i]; return;
105   }
106   UInt_t   GetL0TriggerInputs() const {return fL0TriggerInputs;}  
107   UInt_t   GetL1TriggerInputs() const {return fL1TriggerInputs;} 
108   UShort_t GetL2TriggerInputs() const {return fL2TriggerInputs;} 
109   AliCentrality* GetCentralityP()  const { return fCentralityP; }
110   AliEventplane* GetEventplaneP()  const { return fEventplaneP; }
111
112   
113   void SetRunNumber(Int_t nRun)                { fRunNumber = nRun; }
114   void SetEventNumberESDFile(Int_t n)          { fEventNumberESDFile=n; }
115   void SetNumberOfESDTracks(Int_t n)           { fNumberESDTracks=n; }
116   void SetBunchCrossNumber(UShort_t nBx)       { fBunchCrossNumber = nBx; }
117   void SetOrbitNumber(UInt_t nOr)              { fOrbitNumber = nOr; }
118   void SetPeriodNumber(UInt_t nPer)            { fPeriodNumber = nPer; }
119   void SetTriggerMask(ULong64_t trigMsk)       { fTriggerMask = trigMsk; }
120   void SetFiredTriggerClasses(TString trig)    { fFiredTriggers = trig;}
121   void SetTriggerCluster(UChar_t trigClus)     { fTriggerCluster = trigClus; }
122   void SetEventType(UInt_t evttype)            { fEventType = evttype; }
123   void SetMagneticField(Double_t magFld)       { fMagneticField = magFld; }
124   void SetMuonMagFieldScale(Double_t magFldScl){ fMuonMagFieldScale = magFldScl; }
125   void SetCentrality(const AliCentrality* cent);
126   void SetEventplane(AliEventplane* eventplane);
127   void SetZDCN1Energy(Double_t n1Energy)       { fZDCN1Energy = n1Energy; }
128   void SetZDCP1Energy(Double_t p1Energy)       { fZDCP1Energy = p1Energy; }
129   void SetZDCN2Energy(Double_t n2Energy)       { fZDCN2Energy = n2Energy; }
130   void SetZDCP2Energy(Double_t p2Energy)       { fZDCP2Energy = p2Energy; }
131   void SetZDCEMEnergy(Double_t emEnergy1, Double_t emEnergy2)      
132         { fZDCEMEnergy[0] = emEnergy1; fZDCEMEnergy[1] = emEnergy2;}
133   void SetRefMultiplicity(Int_t refMult)       { fRefMult = refMult; }
134   void SetRefMultiplicityPos(Int_t refMultPos) { fRefMultPos = refMultPos; }
135   void SetRefMultiplicityNeg(Int_t refMultNeg) { fRefMultNeg = refMultNeg; }
136   void SetNumberOfMuons(Int_t nMuons) { fNMuons = nMuons; }
137   void SetNumberOfDimuons(Int_t nDimuons) { fNDimuons = nDimuons; }
138   void SetRefMultiplicityComb05(Int_t refMult)   { fRefMultComb05 = refMult; }
139   void SetRefMultiplicityComb08(Int_t refMult)   { fRefMultComb08 = refMult; }  
140
141   void SetQTheta(Double_t *QTheta, UInt_t size = 5);  
142   void RemoveQTheta();
143
144   void ResetEventplanePointer();
145   
146   void SetDiamond(Float_t xy[2],Float_t cov[3]) { 
147     for(Int_t i=0;i<3;i++) {fDiamondCovXY[i] = cov[i];}
148     for(Int_t i=0;i<2;i++) {fDiamondXY[i]    = xy[i] ;}
149   }
150   void SetDiamondZ(Float_t z, Float_t sig2z){
151     fDiamondZ=z; fDiamondSig2Z=sig2z;
152   }
153   void SetL0TriggerInputs(UInt_t n)   {fL0TriggerInputs=n;}
154   void SetL1TriggerInputs(UInt_t n)   {fL1TriggerInputs=n;}
155   void SetL2TriggerInputs(UShort_t n) {fL2TriggerInputs=n;}
156   void SetESDFileName(TString name)   {fESDFileName = name;}
157   void Print(Option_t* option = "") const;
158
159   void    SetPHOSMatrix(TGeoHMatrix*matrix, Int_t i) {
160       if ((i >= 0) && (i < kNPHOSMatrix)) fPHOSMatrix[i] = matrix;
161   }
162   const TGeoHMatrix* GetPHOSMatrix(Int_t i) const {
163       return ((i >= 0) && (i < kNPHOSMatrix)) ? fPHOSMatrix[i] : NULL;
164   }
165   
166   void    SetEMCALMatrix(TGeoHMatrix*matrix, Int_t i) {
167       if ((i >= 0) && (i < kNEMCALMatrix)) fEMCALMatrix[i] = matrix;
168   }
169   const TGeoHMatrix* GetEMCALMatrix(Int_t i) const {
170       return ((i >= 0) && (i < kNEMCALMatrix)) ? fEMCALMatrix[i] : NULL;
171   }
172   
173   UInt_t GetOfflineTrigger() { return fOfflineTrigger; }
174   void   SetOfflineTrigger(UInt_t trigger) { fOfflineTrigger = trigger; }
175   UInt_t GetNumberOfITSClusters(Int_t ilay) const {return fITSClusters[ilay];}
176   void   SetITSClusters(Int_t ilay, UInt_t nclus);
177   Int_t  GetTPConlyRefMultiplicity() const {return fTPConlyRefMult;}
178   void   SetTPConlyRefMultiplicity(Int_t mult) {fTPConlyRefMult = mult;} 
179   
180   TString GetESDFileName() const  {return fESDFileName;}
181   void Clear(Option_t* = "");
182   enum {kNPHOSMatrix = 5};
183   enum {kNEMCALMatrix = 12};
184   enum {kT0SpreadSize = 4};
185
186   void           SetVZEROEqFactors(const Float_t* factors) {
187     if (factors)
188       for (Int_t i = 0; i < 64; ++i) fVZEROEqFactors[i] = factors[i];}
189   const Float_t* GetVZEROEqFactors() const {return fVZEROEqFactors;}
190   Float_t        GetVZEROEqFactors(Int_t i) const {return fVZEROEqFactors[i];}
191   Float_t    GetT0spread(Int_t i) const {
192     return ((i >= 0)  && (i<kT0SpreadSize)) ? fT0spread[i] : 0;}
193   void       SetT0spread(Int_t i, Float_t t) {
194     if ((i>=0)&&(i<kT0SpreadSize)) fT0spread[i]=t;}
195
196   Int_t  FindIRIntInteractionsBXMap(Int_t difference) const;
197   void   SetIRInt2InteractionMap(TBits bits) { fIRInt2InteractionsMap = bits; }
198   void   SetIRInt1InteractionMap(TBits bits) { fIRInt1InteractionsMap = bits; }
199   TBits  GetIRInt2InteractionMap() const { return fIRInt2InteractionsMap; }
200   TBits  GetIRInt1InteractionMap() const { return fIRInt1InteractionsMap; }
201   Int_t  GetIRInt2ClosestInteractionMap() const;
202   Int_t  GetIRInt1ClosestInteractionMap(Int_t gap = 3) const;
203   Int_t  GetIRInt2LastInteractionMap() const;
204   
205  private :
206   
207   Double32_t  fMagneticField;       // Solenoid Magnetic Field in kG
208   Double32_t  fMuonMagFieldScale;   // magnetic field scale of muon arm magnet
209   Double32_t  fCentrality;          // Centrality
210   Double32_t  fEventplane;          // Event plane angle
211   Double32_t  fEventplaneMag;       // Length of Q vector from TPC event plance
212   Double32_t  fEventplaneQx;        // Q vector component x from TPC event plance
213   Double32_t  fEventplaneQy;        // Q vector component y from TPC event plance
214   Double32_t  fZDCN1Energy;         // reconstructed energy in the neutron1 ZDC
215   Double32_t  fZDCP1Energy;         // reconstructed energy in the proton1 ZDC
216   Double32_t  fZDCN2Energy;         // reconstructed energy in the neutron2 ZDC
217   Double32_t  fZDCP2Energy;         // reconstructed energy in the proton2 ZDC
218   Double32_t  fZDCEMEnergy[2];      // reconstructed energy in the electromagnetic ZDCs
219   Int_t       fNQTheta;             // number of QTheta elements
220   Double32_t *fQTheta;              // [fNQTheta] values to store Lee-Yang-Zeros
221   ULong64_t   fTriggerMask;         // Trigger Type (mask)
222   TString     fFiredTriggers;       // String with fired triggers
223   Int_t       fRunNumber;           // Run Number
224   Int_t       fRefMult;             // reference multiplicity
225   Int_t       fRefMultPos;          // reference multiplicity of positive particles
226   Int_t       fRefMultNeg;          // reference multiplicity of negative particles
227   Int_t       fNMuons;              // number of muons in the forward spectrometer
228   Int_t       fNDimuons;            // number of dimuons in the forward spectrometer
229   UInt_t      fEventType;           // Type of Event
230   UInt_t      fOrbitNumber;         // Orbit Number
231   UInt_t      fPeriodNumber;        // Period Number
232   UShort_t    fBunchCrossNumber;    // BunchCrossingNumber
233   Short_t     fRefMultComb05;       // combined reference multiplicity (tracklets + ITSTPC) in |eta|<0.5
234   Short_t     fRefMultComb08;       // combined reference multiplicity (tracklets + ITSTPC) in |eta|<0.8
235   UChar_t     fTriggerCluster;      // Trigger cluster (mask)
236   Double32_t      fDiamondXY[2];    // Interaction diamond (x,y) in RUN
237   Double32_t      fDiamondCovXY[3]; // Interaction diamond covariance (x,y) in RUN
238   Double32_t      fDiamondZ;        // Interaction diamond (z) in RUN
239   Double32_t      fDiamondSig2Z;    // Interaction diamond sigma^2 (z) in RUN
240   TGeoHMatrix*    fPHOSMatrix[kNPHOSMatrix];   //PHOS module position and orientation matrices
241   TGeoHMatrix*    fEMCALMatrix[kNEMCALMatrix]; //EMCAL supermodule position and orientation matrices
242   UInt_t      fOfflineTrigger;      // fired offline triggers for this event
243   TString     fESDFileName;         // ESD file name to which this event belongs
244   Int_t       fEventNumberESDFile;  // Event number in ESD file
245   Int_t       fNumberESDTracks;     // Number of tracks in origingal ESD event
246   UInt_t      fL0TriggerInputs;     // L0 Trigger Inputs (mask)
247   UInt_t      fL1TriggerInputs;     // L1 Trigger Inputs (mask)
248   UShort_t    fL2TriggerInputs;     // L2 Trigger Inputs (mask)
249   UInt_t      fITSClusters[6];      // Number of ITS cluster per layer
250   Int_t       fTPConlyRefMult;      // Reference multiplicty for standard TPC only tracks
251   AliCentrality* fCentralityP;      // Pointer to full centrality information
252   AliEventplane* fEventplaneP;      // Pointer to full event plane information
253   Float_t     fVZEROEqFactors[64];  // V0 channel equalization factors for event-plane reconstruction
254   Float_t     fT0spread[kT0SpreadSize]; // spread of time distributions: (TOA+T0C/2), T0A, T0C, (T0A-T0C)/2
255   TBits   fIRInt2InteractionsMap;  // map of the Int2 events (normally 0TVX) near the event, that's Int2Id-EventId in a -90 to 90 window
256   TBits   fIRInt1InteractionsMap;  // map of the Int1 events (normally V0A&V0C) near the event, that's Int1Id-EventId in a -90 to 90 window
257   ClassDef(AliAODHeader, 23);
258 };
259 inline
260 void AliAODHeader::SetCentrality(const AliCentrality* cent)      { 
261     if(cent){
262         if(fCentralityP)*fCentralityP = *cent;
263         else fCentralityP = new AliCentrality(*cent);
264         fCentrality = cent->GetCentralityPercentile("V0M");
265     }
266     else{
267         fCentrality = -999;
268     }
269 }
270 inline
271 void AliAODHeader::SetEventplane(AliEventplane* eventplane)      { 
272     if(eventplane){
273         if(fEventplaneP)*fEventplaneP = *eventplane;
274         else fEventplaneP = new AliEventplane(*eventplane);
275         fEventplane = eventplane->GetEventplane("Q");
276         const TVector2* qvect=eventplane->GetQVector();
277         fEventplaneMag = -999;
278         fEventplaneQx = -999;
279         fEventplaneQy = -999;
280         if (qvect) {
281           fEventplaneMag=qvect->Mod();
282           fEventplaneQx=qvect->X();
283           fEventplaneQy=qvect->Y();
284         }
285     }
286     else{
287         fEventplane = -999;
288         fEventplaneMag = -999;
289         fEventplaneQx = -999;
290         fEventplaneQy = -999;
291     }
292 }
293 inline
294 void AliAODHeader::ResetEventplanePointer()      {
295   delete fEventplaneP;
296   fEventplaneP = 0x0;
297 }
298
299 inline
300 void AliAODHeader::SetITSClusters(Int_t ilay, UInt_t nclus)
301 {
302     if (ilay >= 0 && ilay < 6) fITSClusters[ilay] = nclus;
303 }
304
305
306 #endif