Line data Source code
1 : #ifndef AliHMPIDDigit_h
2 : #define AliHMPIDDigit_h
3 : /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 : * See cxx source for full Copyright notice */
5 :
6 : // Class of HMPID to manage digits ---> pads
7 : //.
8 : //.
9 : //.
10 :
11 : #include <AliDigit.h> //base class
12 : #include <AliRawReader.h>
13 : #include <AliLog.h>
14 : #include "TMath.h" //Mathieson()
15 : #include <AliBitPacking.h> //Raw()
16 : #include "AliHMPIDParam.h"
17 : //#include "AliHMPIDRawStream.h"
18 :
19 : class TClonesArray; //Hit2Sdi()
20 :
21 : class AliHMPIDDigit :public AliDigit //TObject-AliDigit-AliHMPIDDigit
22 : {
23 : public:
24 :
25 : //ctor&dtor
26 : AliHMPIDDigit():
27 2960 : AliDigit( ),
28 2960 : fPad(AliHMPIDParam::Abs(-1,-1,-1,-1)),
29 2960 : fQ(-1)
30 17760 : {} //default ctor
31 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32 : AliHMPIDDigit(Int_t pad,Int_t q,Int_t *t):
33 531 : AliDigit(t),
34 531 : fPad(pad),
35 531 : fQ(q)
36 3718 : {if(fQ>4095) fQ=4095;} //digit ctor
37 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38 : AliHMPIDDigit(Int_t pad,Int_t q):
39 531 : AliDigit( ),
40 531 : fPad(pad),
41 531 : fQ(q )
42 3717 : {if(fQ>4095) fQ=4095;} //digit ctor
43 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
44 : AliHMPIDDigit& operator=(const AliHMPIDDigit& d)
45 : {
46 : //
47 : // Assignment operator
48 : //
49 0 : if(this!=&d){
50 0 : AliDigit::operator=(d);
51 0 : fPad = d.fPad;
52 0 : fQ = d.fQ;
53 0 : }
54 0 : return *this;
55 : }
56 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57 : AliHMPIDDigit(const AliHMPIDDigit &d):
58 5613 : AliDigit(d),
59 5613 : fPad(d.fPad),
60 5613 : fQ(d.fQ)
61 33678 : {} //copy ctor
62 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
63 33180 : virtual ~AliHMPIDDigit() {} //dtor
64 :
65 : //framework part
66 5232 : Bool_t IsSortable ( )const{return kTRUE;} //provision to use TObject::Sort()
67 : inline Int_t Compare (const TObject *pObj )const; //provision to use TObject::Sort()
68 : void Draw (Option_t *opt="" ); //TObject::Draw() overloaded
69 : void Print (Option_t *opt="" )const; //TObject::Print() overloaded
70 : //private part
71 :
72 36624 : void AddTidOffset(Int_t offset ) {for (Int_t i=0; i<3; i++) if (fTracks[i]>0) fTracks[i]+=offset; } //needed for merging
73 6870 : Int_t Ch ( )const{return AliHMPIDParam::A2C(fPad); } //chamber number
74 :
75 1085940 : Float_t LorsX ( )const{return AliHMPIDParam::LorsX(AliHMPIDParam::A2P(fPad),AliHMPIDParam::A2X(fPad)); } //center of the pad x, [cm]
76 :
77 1085940 : Float_t LorsY ( )const{return AliHMPIDParam::LorsY(AliHMPIDParam::A2P(fPad),AliHMPIDParam::A2Y(fPad)); } //center of the pad y, [cm]
78 : //
79 : inline Double_t MathiesonX (Double_t x )const; //Mathieson distribution along wires X
80 : inline Double_t MathiesonY (Double_t x )const; //Mathieson distribution perp to wires Y
81 : inline Double_t IntPartMathiX(Double_t z )const; //integral in 1-dim of Mathieson X
82 : inline Double_t IntPartMathiY(Double_t z )const; //integral in 1-dim of Mathieson Y
83 : inline Double_t IntMathieson (Double_t x,Double_t y )const; //integral in 2-dim of Mathieson
84 46616 : Int_t PadPcX ( )const{return AliHMPIDParam::A2X(fPad);} //pad pc x # 0..79
85 46514 : Int_t PadPcY ( )const{return AliHMPIDParam::A2Y(fPad);} //pad pc y # 0..47
86 22834 : Int_t PadChX ( )const{return (Pc()%2)*AliHMPIDParam::kPadPcX+PadPcX();} //pad ch x # 0..159
87 22834 : Int_t PadChY ( )const{return (Pc()/2)*AliHMPIDParam::kPadPcY+PadPcY();} //pad ch y # 0..143
88 136222 : Int_t Pad ( )const{return fPad;} //absolute id of this pad
89 64682 : Int_t Pc ( )const{return AliHMPIDParam::A2P(fPad);} //PC position number
90 740132 : Float_t Q ( )const{return fQ;} //charge, [QDC]
91 : inline void Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const;
92 : inline Bool_t Set (Int_t c,Int_t p,Int_t x,Int_t y,Int_t tid=0); //manual creation
93 7849 : void SetQ (Float_t q ) {fQ=q;if(fQ>4095)fQ=4095;} //setter for charge
94 0 : void SetPad (Int_t pad ) {fPad=pad;} //setter for pad
95 :
96 : protected: //AliDigit has fTracks[3]
97 :
98 :
99 : Int_t fPad; //absolute pad number
100 : Float_t fQ; //QDC value, fractions are permitted for summable procedure
101 26 : ClassDef(AliHMPIDDigit,4) //HMPID digit class
102 : };//class AliHMPIDDigit
103 :
104 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
105 :
106 : Int_t AliHMPIDDigit::Compare(const TObject *pObj) const
107 : {
108 : // Used in Sort() method to compare to objects. Note that abs pad structure is first x then y, hence will be sorted on column basis.
109 : // This feature is used in digitizer to facilitate finding of sdigits for the same pad since they all will come together after sorting.
110 : // Arguments: pObj - pointer to object to compare with
111 : // Retunrs: -1 if AbsPad less then in pObj, 1 if more and 0 if they are the same
112 67160 : if (fPad==((AliHMPIDDigit*)pObj)->Pad()) return 0;
113 49369 : else if(fPad >((AliHMPIDDigit*)pObj)->Pad()) return 1;
114 11917 : else return -1;
115 32601 : }
116 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
117 :
118 : Double_t AliHMPIDDigit::MathiesonX(Double_t x)const
119 : {
120 : // Mathieson function.
121 : // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
122 : // Arguments: x- position of the center of Mathieson distribution
123 : // Returns: value of the Mathieson function
124 :
125 21724 : Double_t lambda = x/AliHMPIDParam::PitchAnodeCathode();
126 10862 : Double_t tanh = TMath::TanH(AliHMPIDParam::K2x()*lambda);
127 10862 : Double_t a=1-tanh*tanh;
128 10862 : Double_t b=1+AliHMPIDParam::SqrtK3x()*AliHMPIDParam::SqrtK3x()*tanh*tanh;
129 10862 : Double_t mathi = AliHMPIDParam::K1x()*a/b;
130 10862 : return mathi;
131 : }
132 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
133 :
134 : Double_t AliHMPIDDigit::MathiesonY(Double_t y)const
135 : {
136 : // Mathieson function.
137 : // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
138 : // Arguments: x- position of the center of Mathieson distribution
139 : // Returns: value of the Mathieson function
140 :
141 21724 : Double_t lambda = y/AliHMPIDParam::PitchAnodeCathode();
142 10862 : Double_t tanh = TMath::TanH(AliHMPIDParam::K2y()*lambda);
143 10862 : Double_t a=1-tanh*tanh;
144 10862 : Double_t b=1+AliHMPIDParam::SqrtK3y()*AliHMPIDParam::SqrtK3y()*tanh*tanh;
145 10862 : Double_t mathi = AliHMPIDParam::K1y()*a/b;
146 10862 : return mathi;
147 : }
148 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
149 :
150 : Double_t AliHMPIDDigit::IntPartMathiX(Double_t x)const
151 : {
152 : // Integration of Mathieson.
153 : // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
154 : // Arguments: x,y- position of the center of Mathieson distribution
155 : // Returns: a charge fraction [0-1] imposed into the pad
156 530976 : Double_t shift1 = -LorsX()+0.5*AliHMPIDParam::SizePadX();
157 265488 : Double_t shift2 = -LorsX()-0.5*AliHMPIDParam::SizePadX();
158 :
159 265488 : Double_t ux1=AliHMPIDParam::SqrtK3x()*TMath::TanH(AliHMPIDParam::K2x()*(x+shift1)/AliHMPIDParam::PitchAnodeCathode());
160 265488 : Double_t ux2=AliHMPIDParam::SqrtK3x()*TMath::TanH(AliHMPIDParam::K2x()*(x+shift2)/AliHMPIDParam::PitchAnodeCathode());
161 :
162 265488 : return AliHMPIDParam::K4x()*(TMath::ATan(ux2)-TMath::ATan(ux1));
163 : }
164 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
165 :
166 : Double_t AliHMPIDDigit::IntPartMathiY(Double_t y)const
167 : {
168 : // Integration of Mathieson.
169 : // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
170 : // Arguments: x,y- position of the center of Mathieson distribution
171 : // Returns: a charge fraction [0-1] imposed into the pad
172 530976 : Double_t shift1 = -LorsY()+0.5*AliHMPIDParam::SizePadY();
173 265488 : Double_t shift2 = -LorsY()-0.5*AliHMPIDParam::SizePadY();
174 :
175 265488 : Double_t uy1=AliHMPIDParam::SqrtK3y()*TMath::TanH(AliHMPIDParam::K2y()*(y+shift1)/AliHMPIDParam::PitchAnodeCathode());
176 265488 : Double_t uy2=AliHMPIDParam::SqrtK3y()*TMath::TanH(AliHMPIDParam::K2y()*(y+shift2)/AliHMPIDParam::PitchAnodeCathode());
177 :
178 265488 : return AliHMPIDParam::K4y()*(TMath::ATan(uy2)-TMath::ATan(uy1));
179 :
180 : }
181 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
182 :
183 : Double_t AliHMPIDDigit::IntMathieson(Double_t x,Double_t y)const
184 : {
185 : // Integration of Mathieson.
186 : // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
187 : // Arguments: x,y- position of the center of Mathieson distribution
188 : // Returns: a charge fraction [0-1] imposed into the pad
189 :
190 520114 : Double_t xm = IntPartMathiX(x);
191 260057 : Double_t ym = IntPartMathiY(y);
192 260057 : return 4*xm*ym;
193 : }
194 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
195 : void AliHMPIDDigit::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const
196 : {
197 : // Convert digit structure to raw word format
198 : // Arguments: w32,ddl,r,d,a where to write the results
199 : // Returns: none
200 2124 : Int_t y2a[6]={5,3,1,0,2,4};
201 :
202 1062 : ddl=2*Ch()+Pc()%2; //DDL# 0..13
203 1062 : Int_t tmp=1+Pc()/2*8+PadPcY()/6; r=(Pc()%2)? tmp:25-tmp; //row r=1..24
204 1062 : d=1+PadPcX()/8; //DILOGIC# 1..10
205 : // d=AliHMPIDRawStream::kNDILOGICAdd+1-d; ////flip according to Paolo (2-9-2008)
206 1062 : d=10+1-d; ////flip according to Paolo (2-9-2008)
207 1062 : a=y2a[PadPcY()%6]+6*(7-PadPcX()%8); //ADDRESS 0..47
208 :
209 1062 : w32=0;
210 6372 : if(r<1 || r>24 || d<1 || d>10 || a<0 || a>47) {w32=0;ddl=-1;r=-1;d=-1;a=-1; return;} //clm: the assert is removed not to break the reconstruction code
211 1062 : AliBitPacking::PackWord((UInt_t)fQ,w32, 0,11); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc bits (00..11) counts (0..4095)
212 1062 : AliBitPacking::PackWord( a ,w32,12,17); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC address bits (12..17) counts (0..47)
213 1062 : AliBitPacking::PackWord( d ,w32,18,21); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC number bits (18..21) counts (1..10)
214 1062 : AliBitPacking::PackWord( r ,w32,22,26); // Row number bits (22..26) counts (1..24)
215 1062 : AliBitPacking::PackWord((UInt_t)0, w32,27,27); //To make sure set the 27th bit to Zero so we can distinguis it from the EoE
216 2124 : }
217 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
218 : Bool_t AliHMPIDDigit::Set(Int_t ch,Int_t pc,Int_t px,Int_t py,Int_t tid)
219 : {
220 : // Manual creation of digit
221 : // Arguments: ch,pc,px,py,qdc,tid
222 : // Returns: kTRUE if wrong digit
223 5292 : if(ch<AliHMPIDParam::kMinCh || ch>AliHMPIDParam::kMaxCh) return kTRUE;
224 2646 : if(pc<AliHMPIDParam::kMinPc || pc>AliHMPIDParam::kMaxPc) return kTRUE;
225 2646 : if(px<AliHMPIDParam::kMinPx || px>AliHMPIDParam::kMaxPx) return kTRUE;
226 2676 : if(py<AliHMPIDParam::kMinPy || py>AliHMPIDParam::kMaxPy) return kTRUE;
227 :
228 :
229 2616 : fPad=AliHMPIDParam::Abs(ch,pc,px,py);fTracks[0]=tid;
230 2616 : fQ=0;
231 2616 : return kFALSE;
232 2646 : }
233 : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
234 :
235 : #endif
|