1 #ifndef ALIMULTIPLICITY_H
2 #define ALIMULTIPLICITY_H
9 ////////////////////////////////////////////////////////
10 //// Class containing multiplicity information //
11 //// to stored in the ESD //
12 ////////////////////////////////////////////////////////
14 class AliMultiplicity : public TObject {
18 enum {kMultTrackRefs =BIT(14), // in new format (old is default for bwd.comp.) multiple cluster->track references are allowed
19 kScaleDThtbySin2=BIT(15), // scale Dtheta by 1/sin^2(theta). Default is DON'T scale, for bwd.comp.
20 kSPD2Sng =BIT(16) // are SPD2 singles stored?
22 AliMultiplicity(); // default constructor
23 // standard constructor
24 AliMultiplicity(Int_t ntr,Float_t *th, Float_t *ph, Float_t *dth, Float_t *dph, Int_t *labels,
25 Int_t* labelsL2, Int_t ns, Float_t *ts, Float_t *ps, Int_t *labelss, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOrFiredChips);
26 AliMultiplicity(Int_t ntr, Int_t ns, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr);
27 AliMultiplicity(const AliMultiplicity& m);
28 AliMultiplicity& operator=(const AliMultiplicity& m);
29 virtual void Copy(TObject &obj) const;
30 virtual void Clear(Option_t* opt="");
31 virtual ~AliMultiplicity();
32 // methods to access tracklet information
33 Bool_t GetMultTrackRefs() const {return TestBit(kMultTrackRefs);}
34 void SetMultTrackRefs(Bool_t v) {SetBit(kMultTrackRefs,v);}
35 Bool_t GetScaleDThetaBySin2T() const {return TestBit(kScaleDThtbySin2);}
36 void SetScaleDThetaBySin2T(Bool_t v) {SetBit(kScaleDThtbySin2,v);}
39 Int_t GetNumberOfTracklets() const {return fNtracks;}
40 Double_t GetTheta(Int_t i) const {
41 if(i>=0 && i<fNtracks) return fTh[i];
42 Error("GetTheta","Invalid track number %d",i); return -9999.;
44 Double_t GetEta(Int_t i) const {
45 if(i>=0 && i<fNtracks) return -TMath::Log(TMath::Tan(fTh[i]/2.));
46 Error("GetEta","Invalid track number %d",i); return -9999.;
48 Double_t GetPhi(Int_t i) const {
49 if(i>=0 && i<fNtracks) return fPhi[i];
50 Error("GetPhi","Invalid track number %d",i); return -9999.;
52 Double_t GetDeltaTheta(Int_t i) const {
53 if(fDeltTh && i>=0 && i<fNtracks) return fDeltTh[i];
54 Error("GetDeltaTheta","DeltaTheta not available in data or Invalid track number %d(max %d)",i, fNtracks); return -9999.;
56 Double_t GetDeltaPhi(Int_t i) const {
57 if(i>=0 && i<fNtracks) return fDeltPhi[i];
58 Error("GetDeltaPhi","Invalid track number %d",i); return -9999.;
61 Double_t CalcDist(Int_t it) const;
62 Float_t GetThetaAll(int icl, int lr) const;
63 Float_t GetPhiAll(int icl, int lr) const;
64 Int_t GetLabelAll(int icl, int lr) const;
66 Int_t GetLabel(Int_t i, Int_t layer) const;
67 void SetLabel(Int_t i, Int_t layer, Int_t label);
68 Int_t GetLabelSingle(Int_t i) const;
69 Int_t GetLabelSingleLr(Int_t i, Int_t layer) const;
70 void SetLabelSingle(Int_t i, Int_t label);
72 Bool_t FreeClustersTracklet(Int_t i, Int_t mode) const;
73 Bool_t FreeSingleCluster(Int_t i, Int_t mode) const;
76 // methods to access single cluster information
77 Int_t SetNumberOfSingleClustersSPD2(Int_t n) {return fNsingleSPD2 = n;}
78 Int_t GetNumberOfSingleClusters() const {return fNsingle;}
79 Int_t GetNumberOfSingleClustersLr(Int_t lr) const;
80 Bool_t AreSPD2SinglesStored() const {return TestBit(kSPD2Sng);}
81 void SetSPD2SinglesStored(Bool_t v=kTRUE) {return SetBit(kSPD2Sng,v);}
83 Double_t GetThetaSingle(Int_t i) const {
84 if(i>=0 && i<fNsingle) return fThsingle[i];
85 Error("GetThetaSingle","Invalid cluster number %d",i); return -9999.;
88 Double_t GetThetaSingleLr(Int_t i, Int_t lr) const {
90 if (!AreSPD2SinglesStored()) {Error("GetThetaSingle","Invalid cluster number %d for lr %d",i,lr); return -9999.;}
91 else i += GetNumberOfSingleClustersLr(0);
93 if(i>=0 && i<fNsingle) return fThsingle[i];
94 Error("GetThetaSingle","Invalid cluster number %d",i); return -9999.;
97 Double_t GetPhiSingle(Int_t i) const {
98 if(i>=0 && i<fNsingle) return fPhisingle[i];
99 Error("GetPhisingle","Invalid cluster number %d",i); return -9999.;
102 Double_t GetPhiSingleLr(Int_t i, Int_t lr) const {
104 if (!AreSPD2SinglesStored()) {Error("GetPhiSingle","Invalid cluster number %d for lr %d",i,lr); return -9999.;}
105 else i += GetNumberOfSingleClustersLr(0);
107 if(i>=0 && i<fNsingle) return fPhisingle[i];
108 Error("GetPhisingle","Invalid cluster number %d",i); return -9999.;
111 Short_t GetNumberOfFiredChips(Int_t layer) const { return fFiredChips[layer]; }
112 void SetFiredChips(Int_t layer, Short_t firedChips) { fFiredChips[layer] = firedChips; }
114 UInt_t GetNumberOfITSClusters(Int_t layer) const { return layer<6 ? fITSClusters[layer] : 0; }
115 UInt_t GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const ;
116 void SetITSClusters(Int_t layer, UInt_t clusters) { fITSClusters[layer] = clusters; }
118 void SetFastOrFiredChips(UInt_t chipKey){fFastOrFiredChips.SetBitNumber(chipKey);}
119 const TBits & GetFastOrFiredChips() const {return fFastOrFiredChips;}
120 Bool_t TestFastOrFiredChips(UInt_t chipKey) const {return fFastOrFiredChips.TestBitNumber(chipKey);}
122 void SetFiredChipMap(TBits & firedChips){fClusterFiredChips = firedChips;}
123 void SetFiredChipMap(UInt_t chipKey){fClusterFiredChips.SetBitNumber(chipKey);}
124 const TBits & GetFiredChipMap() const {return fClusterFiredChips;}
125 Bool_t TestFiredChipMap(UInt_t chipKey) const {return fClusterFiredChips.TestBitNumber(chipKey);}
127 Bool_t GetTrackletTrackIDs(Int_t i, Int_t mode, Int_t &spd1, Int_t &spd2) const;
128 Int_t GetTrackletTrackIDsLay(Int_t lr,Int_t i, Int_t mode, UInt_t* refs, UInt_t maxRef) const;
129 Bool_t GetSingleClusterTrackID(Int_t i, Int_t mode, Int_t &tr) const;
130 Int_t GetSingleClusterTrackIDs(Int_t i, Int_t mode, UInt_t* refs, UInt_t maxRef) const;
133 Double_t* GetTheta() const {return (Double_t*)fTh;}
134 Double_t* GetPhi() const {return (Double_t*)fPhi;}
135 Double_t* GetDeltTheta() const {return (Double_t*)fDeltTh;}
136 Double_t* GetDeltPhi() const {return (Double_t*)fDeltPhi;}
137 Double_t* GetThetaSingle() const {return (Double_t*)fThsingle;}
138 Double_t* GetPhiSingle() const {return (Double_t*)fPhisingle;}
139 Int_t* GetLabels() const {return (Int_t*)fLabels;}
140 Int_t* GetLabels2() const {return (Int_t*)fLabelsL2;}
141 Int_t* GetLabelsSingle() const {return (Int_t*)fLabelssingle;}
143 void AttachTracklet2TrackRefs(AliRefArray* l1t1,AliRefArray* l1t2,AliRefArray* l2t1,AliRefArray* l2t2) {
144 fTCl2Tracks[0][0] = l1t1; fTCl2Tracks[0][1] = l1t2; fTCl2Tracks[1][0] = l2t1; fTCl2Tracks[1][1] = l2t2;
146 void AttachCluster2TrackRefs(AliRefArray* l1t1,AliRefArray* l1t2) {
147 fSCl2Tracks[0] = l1t1; fSCl2Tracks[1] = l1t2;
149 void SetTrackletData(Int_t id, const Float_t* tlet, UInt_t trSPD1=0, UInt_t trSPD2=0);
150 void SetSingleClusterData(Int_t id, const Float_t* scl,UInt_t tr=0);
153 void SetDPhiWindow2(Float_t v=-1) {fDPhiWindow2 = v;}
154 void SetDThetaWindow2(Float_t v=-1) {fDThetaWindow2 = v;}
155 void SetDPhiShift(Float_t v=-1) {fDPhiShift = v;}
156 void SetNStdDev(Float_t v=1) {fNStdDev = v;}
158 Float_t GetDPhiWindow2() const {return fDPhiWindow2;}
159 Float_t GetDThetaWindow2() const {return fDThetaWindow2;}
160 Float_t GetDPhiShift() const {return fDPhiShift;}
161 Float_t GetNStdDev() const {return fNStdDev;}
164 virtual void Print(Option_t *opt="") const;
167 void Duplicate(const AliMultiplicity &m); // used by copy ctr.
169 Int_t fNtracks; // Number of tracklets
170 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
171 Int_t fNsingleSPD2; // Number of clusters on SPD layer 2 not associated (if stored)
173 Float_t fDPhiWindow2; // sigma^2 in dphi used in reco
174 Float_t fDThetaWindow2; // sigma^2 in dtheta used in reco
175 Float_t fDPhiShift; // bending shift used
176 Float_t fNStdDev; // number of standard deviations kept
178 Int_t *fLabels; //[fNtracks] array with labels of cluster in L1 used for tracklet
179 Int_t *fLabelsL2; //[fNtracks] array with labels of cluster in L2 used for tracklet
180 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
181 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
182 AliRefArray *fTCl2Tracks[2][2]; // container with multiple tracklet_cluster->track references
183 AliRefArray *fSCl2Tracks[2]; // container with multiple single_cluster->track references
184 Double32_t *fTh; //[fNtracks] array with theta values
185 Double32_t *fPhi; //[fNtracks] array with phi values
186 Double32_t *fDeltTh; //[fNtracks] array with delta theta values
187 Double32_t *fDeltPhi; //[fNtracks] array with delta phi values
188 Double32_t *fThsingle; //[fNsingle] array with theta values of L1 clusters
189 Double32_t *fPhisingle; //[fNsingle] array with phi values of L1 clusters
190 Int_t *fLabelssingle; //[fNsingle] array with labels of clusters in L1 not used for tracklets
191 Short_t fFiredChips[2]; // Number of fired chips in the two SPD layers
192 UInt_t fITSClusters[6]; // Number of ITS cluster per layer
193 TBits fFastOrFiredChips; // Map of FastOr fired chips
194 TBits fClusterFiredChips; // Map of fired chips (= at least one cluster)
196 ClassDef(AliMultiplicity,19);
199 inline Int_t AliMultiplicity::GetLabel(Int_t i, Int_t layer) const
201 if(i>=0 && i<fNtracks) {
204 } else if (layer == 1) {
208 Warning("GetLabel", "No information for layer 2 available !");
212 Error("GetLabel","Invalid layer number %d",layer); return -9999;
215 Error("GetLabel","Invalid track number %d",i); return -9999;
220 inline Int_t AliMultiplicity::GetLabelSingle(Int_t i) const
222 if(i>=0 && i<fNsingle) {
223 return fLabelssingle[i];
225 Error("GetLabelSingle","Invalid cluster number %d",i); return -9999;
231 inline Double_t AliMultiplicity::CalcDist(Int_t i) const
233 // calculate eliptical distance. theta is the angle of cl1, dtheta = tht(cl1)-tht(cl2)
234 if (i<0 && i>=fNtracks) return -1;
235 if (fDPhiWindow2<1E-9 || fDThetaWindow2<1E-9) return -1; // not stored
236 double dphi = TMath::Abs(fDeltPhi[i]) - fDPhiShift;
237 double dtheta = fDeltTh[i];
238 if (GetScaleDThetaBySin2T()) {
239 double sinTI = TMath::Sin(fTh[i]-dtheta/2);
241 dtheta /= sinTI>1.e-6 ? sinTI : 1.e-6;
243 return dphi*dphi/fDPhiWindow2 + dtheta*dtheta/fDThetaWindow2;
246 inline Int_t AliMultiplicity::GetNumberOfSingleClustersLr(Int_t lr) const
248 // return number of singles at given layer
249 if (lr==0) return fNsingle - fNsingleSPD2;
250 return AreSPD2SinglesStored() ? fNsingleSPD2 : -1;