]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/ESD/AliMultiplicity.h
Update timestamp for new data points simulation
[u/mrichter/AliRoot.git] / STEER / ESD / AliMultiplicity.h
CommitLineData
32e449be 1#ifndef ALIMULTIPLICITY_H
2#define ALIMULTIPLICITY_H
3
ff44c37c 4#include <TBits.h>
59495bf1 5#include <TMath.h>
9a003bdc 6#include "AliVMultiplicity.h"
59495bf1 7class AliRefArray;
32e449be 8
9////////////////////////////////////////////////////////
10//// Class containing multiplicity information //
11//// to stored in the ESD //
12////////////////////////////////////////////////////////
13
9a003bdc 14class AliMultiplicity : public AliVMultiplicity {
32e449be 15
16 public:
59495bf1 17 //
32e449be 18 AliMultiplicity(); // default constructor
fa9ed8e9 19 AliMultiplicity(Int_t ntr,Float_t *th, Float_t *ph, Float_t *dth, Float_t *dph, Int_t *labels,
d7c5c1e4 20 Int_t* labelsL2, Int_t ns, Float_t *ts, Float_t *ps, Int_t *labelss, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOrFiredChips);
1f9831ab 21 AliMultiplicity(Int_t ntr, Int_t ns, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr);
32e449be 22 AliMultiplicity(const AliMultiplicity& m);
23 AliMultiplicity& operator=(const AliMultiplicity& m);
732a24fe 24 virtual void Copy(TObject &obj) const;
1f9831ab 25 virtual void Clear(Option_t* opt="");
32e449be 26 virtual ~AliMultiplicity();
59495bf1 27 // methods to access tracklet information
28 Bool_t GetMultTrackRefs() const {return TestBit(kMultTrackRefs);}
29 void SetMultTrackRefs(Bool_t v) {SetBit(kMultTrackRefs,v);}
30 Bool_t GetScaleDThetaBySin2T() const {return TestBit(kScaleDThtbySin2);}
31 void SetScaleDThetaBySin2T(Bool_t v) {SetBit(kScaleDThtbySin2,v);}
59495bf1 32 //
9a003bdc 33 // methods supported on AliVMultiplicity level >>>
34 //
35 virtual Int_t GetNumberOfTracklets() const {return fNtracks;}
36 virtual Double_t GetTheta(Int_t i) const {
4f499767 37 if(i>=0 && i<fNtracks) return fTh[i];
38 Error("GetTheta","Invalid track number %d",i); return -9999.;
39 }
9a003bdc 40 virtual Double_t GetPhi(Int_t i) const {
4f499767 41 if(i>=0 && i<fNtracks) return fPhi[i];
42 Error("GetPhi","Invalid track number %d",i); return -9999.;
43 }
9a003bdc 44 virtual Double_t GetDeltaPhi(Int_t i) const {
4f499767 45 if(i>=0 && i<fNtracks) return fDeltPhi[i];
46 Error("GetDeltaPhi","Invalid track number %d",i); return -9999.;
47 }
9a003bdc 48 virtual Int_t GetLabel(Int_t i, Int_t layer) const;
49 virtual void SetLabel(Int_t i, Int_t layer, Int_t label);
50 //
51 // array getters
52 virtual Double_t* GetTheta() const {return (Double_t*)fTh;}
53 virtual Double_t* GetPhi() const {return (Double_t*)fPhi;}
54 virtual Double_t* GetDeltPhi() const {return (Double_t*)fDeltPhi;}
55 virtual Int_t* GetLabels() const {return (Int_t*)fLabels;}
56 virtual Int_t* GetLabels2() const {return (Int_t*)fLabelsL2;}
57 //
58 virtual void Print(Option_t *opt="") const;
59 //
60 // methods supported on AliVMultiplicity level <<<
61 //
62 Double_t GetDeltaTheta(Int_t i) const {
63 if(fDeltTh && i>=0 && i<fNtracks) return fDeltTh[i];
64 Error("GetDeltaTheta","DeltaTheta not available in data or Invalid track number %d(max %d)",i, fNtracks); return -9999.;
65 }
eda42f29 66
59495bf1 67 Double_t CalcDist(Int_t it) const;
b9be2602 68 Float_t GetThetaAll(int icl, int lr) const;
69 Float_t GetPhiAll(int icl, int lr) const;
70 Int_t GetLabelAll(int icl, int lr) const;
59495bf1 71
d7c5c1e4 72 Int_t GetLabelSingle(Int_t i) const;
b9be2602 73 Int_t GetLabelSingleLr(Int_t i, Int_t layer) const;
d7c5c1e4 74 void SetLabelSingle(Int_t i, Int_t label);
75
34581d1e 76 Bool_t FreeClustersTracklet(Int_t i, Int_t mode) const;
77 Bool_t FreeSingleCluster(Int_t i, Int_t mode) const;
eda42f29 78
9a003bdc 79 // methods to access single cluster information
b9be2602 80 Int_t SetNumberOfSingleClustersSPD2(Int_t n) {return fNsingleSPD2 = n;}
968e8539 81 Int_t GetNumberOfSingleClusters() const {return fNsingle;}
b9be2602 82 Int_t GetNumberOfSingleClustersLr(Int_t lr) const;
83 Bool_t AreSPD2SinglesStored() const {return TestBit(kSPD2Sng);}
84 void SetSPD2SinglesStored(Bool_t v=kTRUE) {return SetBit(kSPD2Sng,v);}
85
4f499767 86 Double_t GetThetaSingle(Int_t i) const {
87 if(i>=0 && i<fNsingle) return fThsingle[i];
88 Error("GetThetaSingle","Invalid cluster number %d",i); return -9999.;
89 }
90
b9be2602 91 Double_t GetThetaSingleLr(Int_t i, Int_t lr) const {
92 if (lr==1) {
93 if (!AreSPD2SinglesStored()) {Error("GetThetaSingle","Invalid cluster number %d for lr %d",i,lr); return -9999.;}
94 else i += GetNumberOfSingleClustersLr(0);
95 }
96 if(i>=0 && i<fNsingle) return fThsingle[i];
97 Error("GetThetaSingle","Invalid cluster number %d",i); return -9999.;
98 }
9a003bdc 99
4f499767 100 Double_t GetPhiSingle(Int_t i) const {
101 if(i>=0 && i<fNsingle) return fPhisingle[i];
102 Error("GetPhisingle","Invalid cluster number %d",i); return -9999.;
103 }
9a003bdc 104
b9be2602 105 Double_t GetPhiSingleLr(Int_t i, Int_t lr) const {
106 if (lr==1) {
107 if (!AreSPD2SinglesStored()) {Error("GetPhiSingle","Invalid cluster number %d for lr %d",i,lr); return -9999.;}
108 else i += GetNumberOfSingleClustersLr(0);
109 }
110 if(i>=0 && i<fNsingle) return fPhisingle[i];
111 Error("GetPhisingle","Invalid cluster number %d",i); return -9999.;
112 }
113
ab37e14c 114 Short_t GetNumberOfFiredChips(Int_t layer) const { return fFiredChips[layer]; }
115 void SetFiredChips(Int_t layer, Short_t firedChips) { fFiredChips[layer] = firedChips; }
466ffa28 116
d325d83f 117 UInt_t GetNumberOfITSClusters(Int_t layer) const { return layer<6 ? fITSClusters[layer] : 0; }
118 UInt_t GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const ;
119 void SetITSClusters(Int_t layer, UInt_t clusters) { fITSClusters[layer] = clusters; }
120
ee87788b 121 void SetFastOrFiredChips(UInt_t chipKey){fFastOrFiredChips.SetBitNumber(chipKey);}
adc4b00f 122 const TBits & GetFastOrFiredChips() const {return fFastOrFiredChips;}
ee87788b 123 Bool_t TestFastOrFiredChips(UInt_t chipKey) const {return fFastOrFiredChips.TestBitNumber(chipKey);}
ff44c37c 124
ab37e14c 125 void SetFiredChipMap(TBits & firedChips){fClusterFiredChips = firedChips;}
126 void SetFiredChipMap(UInt_t chipKey){fClusterFiredChips.SetBitNumber(chipKey);}
127 const TBits & GetFiredChipMap() const {return fClusterFiredChips;}
128 Bool_t TestFiredChipMap(UInt_t chipKey) const {return fClusterFiredChips.TestBitNumber(chipKey);}
adc4b00f 129
34581d1e 130 Bool_t GetTrackletTrackIDs(Int_t i, Int_t mode, Int_t &spd1, Int_t &spd2) const;
59495bf1 131 Int_t GetTrackletTrackIDsLay(Int_t lr,Int_t i, Int_t mode, UInt_t* refs, UInt_t maxRef) const;
34581d1e 132 Bool_t GetSingleClusterTrackID(Int_t i, Int_t mode, Int_t &tr) const;
59495bf1 133 Int_t GetSingleClusterTrackIDs(Int_t i, Int_t mode, UInt_t* refs, UInt_t maxRef) const;
1f9831ab 134
135 // array getters
1f9831ab 136 Double_t* GetDeltTheta() const {return (Double_t*)fDeltTh;}
1f9831ab 137 Double_t* GetThetaSingle() const {return (Double_t*)fThsingle;}
138 Double_t* GetPhiSingle() const {return (Double_t*)fPhisingle;}
d7c5c1e4 139 Int_t* GetLabelsSingle() const {return (Int_t*)fLabelssingle;}
1f9831ab 140
59495bf1 141 void AttachTracklet2TrackRefs(AliRefArray* l1t1,AliRefArray* l1t2,AliRefArray* l2t1,AliRefArray* l2t2) {
142 fTCl2Tracks[0][0] = l1t1; fTCl2Tracks[0][1] = l1t2; fTCl2Tracks[1][0] = l2t1; fTCl2Tracks[1][1] = l2t2;
143 }
144 void AttachCluster2TrackRefs(AliRefArray* l1t1,AliRefArray* l1t2) {
145 fSCl2Tracks[0] = l1t1; fSCl2Tracks[1] = l1t2;
146 }
147 void SetTrackletData(Int_t id, const Float_t* tlet, UInt_t trSPD1=0, UInt_t trSPD2=0);
148 void SetSingleClusterData(Int_t id, const Float_t* scl,UInt_t tr=0);
149 void CompactBits();
150 //
151 void SetDPhiWindow2(Float_t v=-1) {fDPhiWindow2 = v;}
152 void SetDThetaWindow2(Float_t v=-1) {fDThetaWindow2 = v;}
153 void SetDPhiShift(Float_t v=-1) {fDPhiShift = v;}
154 void SetNStdDev(Float_t v=1) {fNStdDev = v;}
155 //
156 Float_t GetDPhiWindow2() const {return fDPhiWindow2;}
157 Float_t GetDThetaWindow2() const {return fDThetaWindow2;}
158 Float_t GetDPhiShift() const {return fDPhiShift;}
159 Float_t GetNStdDev() const {return fNStdDev;}
160
161 //
32e449be 162 protected:
163 void Duplicate(const AliMultiplicity &m); // used by copy ctr.
32e449be 164
cd888a89 165 Int_t fNtracks; // Number of tracklets
b9be2602 166 Int_t fNsingle; // Number of clusters on SPD layer 1 and 2 (if storage of spd2 singles requested), not associated with a tracklet on otherSPD
167 Int_t fNsingleSPD2; // Number of clusters on SPD layer 2 not associated (if stored)
59495bf1 168 //
169 Float_t fDPhiWindow2; // sigma^2 in dphi used in reco
170 Float_t fDThetaWindow2; // sigma^2 in dtheta used in reco
171 Float_t fDPhiShift; // bending shift used
172 Float_t fNStdDev; // number of standard deviations kept
173 //
0939e22a 174 Int_t *fLabels; //[fNtracks] array with labels of cluster in L1 used for tracklet
175 Int_t *fLabelsL2; //[fNtracks] array with labels of cluster in L2 used for tracklet
59495bf1 176 UInt_t* fUsedClusS; //[fNsingle] id+1 of the tracks using cluster, coded as (TPC/ITS+ITS_SA)+(ITS_SA_PURE<<16) !!! Outphased for multiple refs
c8122432 177 ULong64_t* fUsedClusT; //[fNtracks] id+1 of the tracks using clusters, coded as (TPC/ITS+ITS_SA)+(ITS_SA_PURE<<16) for SPD1 and SPD2 in low and high parts
59495bf1 178 AliRefArray *fTCl2Tracks[2][2]; // container with multiple tracklet_cluster->track references
179 AliRefArray *fSCl2Tracks[2]; // container with multiple single_cluster->track references
cd888a89 180 Double32_t *fTh; //[fNtracks] array with theta values
181 Double32_t *fPhi; //[fNtracks] array with phi values
fa9ed8e9 182 Double32_t *fDeltTh; //[fNtracks] array with delta theta values
cd888a89 183 Double32_t *fDeltPhi; //[fNtracks] array with delta phi values
184 Double32_t *fThsingle; //[fNsingle] array with theta values of L1 clusters
1f9831ab 185 Double32_t *fPhisingle; //[fNsingle] array with phi values of L1 clusters
d7c5c1e4 186 Int_t *fLabelssingle; //[fNsingle] array with labels of clusters in L1 not used for tracklets
ab37e14c 187 Short_t fFiredChips[2]; // Number of fired chips in the two SPD layers
d7c5c1e4 188 UInt_t fITSClusters[6]; // Number of ITS cluster per layer
ff44c37c 189 TBits fFastOrFiredChips; // Map of FastOr fired chips
1f9831ab 190 TBits fClusterFiredChips; // Map of fired chips (= at least one cluster)
ff44c37c 191
9a003bdc 192 ClassDef(AliMultiplicity,20);
32e449be 193};
194
eda42f29 195inline Int_t AliMultiplicity::GetLabel(Int_t i, Int_t layer) const
196{
197 if(i>=0 && i<fNtracks) {
198 if (layer == 0) {
199 return fLabels[i];
200 } else if (layer == 1) {
201 if (fLabelsL2) {
202 return fLabelsL2[i];
203 } else {
204 Warning("GetLabel", "No information for layer 2 available !");
205 return -9999;
206 }
207 } else {
208 Error("GetLabel","Invalid layer number %d",layer); return -9999;
209 }
210 } else {
211 Error("GetLabel","Invalid track number %d",i); return -9999;
212 }
4f499767 213 return -9999;
eda42f29 214}
d7c5c1e4 215
216inline Int_t AliMultiplicity::GetLabelSingle(Int_t i) const
217{
218 if(i>=0 && i<fNsingle) {
219 return fLabelssingle[i];
220 } else {
221 Error("GetLabelSingle","Invalid cluster number %d",i); return -9999;
222 }
223 return -9999;
224}
225
226
59495bf1 227inline Double_t AliMultiplicity::CalcDist(Int_t i) const
228{
229 // calculate eliptical distance. theta is the angle of cl1, dtheta = tht(cl1)-tht(cl2)
230 if (i<0 && i>=fNtracks) return -1;
231 if (fDPhiWindow2<1E-9 || fDThetaWindow2<1E-9) return -1; // not stored
232 double dphi = TMath::Abs(fDeltPhi[i]) - fDPhiShift;
233 double dtheta = fDeltTh[i];
234 if (GetScaleDThetaBySin2T()) {
235 double sinTI = TMath::Sin(fTh[i]-dtheta/2);
236 sinTI *= sinTI;
237 dtheta /= sinTI>1.e-6 ? sinTI : 1.e-6;
238 }
239 return dphi*dphi/fDPhiWindow2 + dtheta*dtheta/fDThetaWindow2;
240}
241
b9be2602 242inline Int_t AliMultiplicity::GetNumberOfSingleClustersLr(Int_t lr) const
243{
244 // return number of singles at given layer
245 if (lr==0) return fNsingle - fNsingleSPD2;
246 return AreSPD2SinglesStored() ? fNsingleSPD2 : -1;
247}
248
d7c5c1e4 249
250
32e449be 251#endif