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