]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HMPID/AliHMPIDDigit.h
move one varibels from AliEMCALv2 to AliEMCAL
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDDigit.h
CommitLineData
d3da6dc4 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#include <AliDigit.h> //base class
7#include <TMath.h> //Mathieson()
8#include <TRandom.h> //IsOverTh()
9#include <AliBitPacking.h> //Raw()
1d4857c5 10
d3da6dc4 11
d3da6dc4 12class TClonesArray; //Hit2Sdi()
3c6274c1 13
d3da6dc4 14class AliHMPIDDigit :public AliDigit //TObject-AliDigit-AliHMPIDDigit
15{
16public:
a1d55ff3 17 enum EChamberData{kMinCh=0,kMaxCh=6,kMinPc=0,kMaxPc=5}; //Segmenation
18 enum EPadxData{kPadPcX=80,kMinPx=0,kMaxPx=79,kMaxPcx=159}; //Segmentation structure along x
19 enum EPadyData{kPadPcY=48,kMinPy=0,kMaxPy=47,kMaxPcy=143}; //Segmentation structure along y
d3da6dc4 20//ctor&dtor
1d4857c5 21 AliHMPIDDigit( ):AliDigit( ),fPad(Abs(-1,-1,-1,-1)),fQ(-1) {} //default ctor
22 AliHMPIDDigit(Int_t pad,Int_t q,Int_t *t):AliDigit(t),fPad(pad ),fQ(q ) {} //digit ctor
23 AliHMPIDDigit(const AliHMPIDDigit &d ):AliDigit(d),fPad(d.fPad),fQ(d.fQ) {} //copy ctor
24 virtual ~AliHMPIDDigit() {} //dtor
d3da6dc4 25//framework part
26 Bool_t IsSortable ( )const{return kTRUE;} //provision to use TObject::Sort()
27 inline Int_t Compare (const TObject *pObj )const; //provision to use TObject::Sort()
d1bf51e1 28 void Draw (Option_t *opt="" ); //TObject::Draw() overloaded
d3da6dc4 29 void Print (Option_t *opt="" )const; //TObject::Print() overloaded
30//private part
1d4857c5 31 static Int_t Abs (Int_t c,Int_t s,Int_t x,Int_t y) {return c*100000000+s*1000000+x*1000+y; } //(ch,pc,padx,pady)-> abs pad
32 static Int_t A2C (Int_t pad ) {return pad/100000000; } //abs pad -> chamber
33 static Int_t A2P (Int_t pad ) {return pad%100000000/1000000; } //abs pad -> pc
34 static Int_t A2X (Int_t pad ) {return pad%1000000/1000; } //abs pad -> pad X
35 static Int_t A2Y (Int_t pad ) {return pad%1000; } //abs pad -> pad Y
36 void AddTidOffset(Int_t offset ) {for (Int_t i=0; i<3; i++) if (fTracks[i]>0) fTracks[i]+=offset; } //needed for merging
37 Int_t Ch ( )const{return A2C(fPad); } //chamber number
38 static Bool_t IsOverTh (Float_t q ) {return q >= 4; } //is digit over threshold????
39 static Bool_t IsInside (Float_t x,Float_t y ) {return x>0&&y>0&&x<SizeAllX()&&y<SizeAllY(); } //is point inside chamber boundary?
40 Float_t LorsX ( )const{return LorsX(A2P(fPad),A2X(fPad)); } //center of the pad x, [cm]
d1bf51e1 41 static Float_t LorsX (Int_t pc,Int_t padx ) {return (padx +0.5)*SizePadX()+(pc %2)*(SizePcX()+SizeDead());} //center of the pad x, [cm]
1d4857c5 42 Float_t LorsY ( )const{return LorsY(A2P(fPad),A2Y(fPad)); } //center of the pad y, [cm]
d1bf51e1 43 static Float_t LorsY (Int_t pc,Int_t pady ) {return (pady +0.5)*SizePadY()+(pc /2)*(SizePcY()+SizeDead());} //center of the pad y, [cm]
d3da6dc4 44 inline Float_t Mathieson (Float_t x,Float_t y )const; //Mathieson distribution
3c6274c1 45 Int_t PadPcX ( )const{return A2X(fPad);} //pad pc x # 0..79
46 Int_t PadPcY ( )const{return A2Y(fPad);} //pad pc y # 0..47
47 Int_t PadChX ( )const{return (Pc()%2)*kPadPcX+PadPcX();} //pad ch x # 0..159
48 Int_t PadChY ( )const{return (Pc()/2)*kPadPcY+PadPcY();} //pad ch y # 0..143
d3da6dc4 49 Int_t Pad ( )const{return fPad;} //absolute id of this pad
d3da6dc4 50 Int_t Pc ( )const{return A2P(fPad);} //PC position number
da08475b 51 Float_t Q ( )const{return fQ;} //charge, [QDC]
1d4857c5 52 inline void Raw (UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const; //digit->(w32,ddl,r,d,a)
53 inline void Raw (UInt_t w32,Int_t ddl ); //(w32,ddl)->digit
54 inline Bool_t Set (Int_t c,Int_t p,Int_t x,Int_t y,Float_t q=0,Int_t tid=0); //manual creation
55 static void WriteRaw (TObjArray *pDigLst ); //write as raw stream
d3da6dc4 56
1d4857c5 57 static Float_t SizeAllX ( ) {return fMaxPcX[5];} //all PCs size x, [cm]
58 static Float_t SizeAllY ( ) {return fMaxPcY[5];} //all PCs size y, [cm]
59 static Float_t SizeArea ( ) {return SizePcX()*SizePcY()*(kMaxPc-kMinPc+1);} //sence area, [cm^2]
d3da6dc4 60 static Float_t SizeDead ( ) {return 2.6;} //dead zone size x, [cm]
61 static Float_t SizeGap ( ) {return 8; }
62 static Float_t SizePadX ( ) {return 0.8;} //pad size x, [cm]
63 static Float_t SizePadY ( ) {return 0.84;} //pad size y, [cm]
1d4857c5 64 static Float_t SizePcX ( ) {return fMaxPcX[0];} //PC size x, [cm]
65 static Float_t SizePcY ( ) {return fMaxPcY[0];} //PC size y, [cm]
da08475b 66 static Float_t SizeWin ( ) {return 0.5;} //Quartz window width
67 static Float_t SizeRad ( ) {return 1.5;} //Rad width
d1bf51e1 68 static const Float_t fMinPcX[6];
69 static const Float_t fMinPcY[6];
70 static const Float_t fMaxPcX[6];
71 static const Float_t fMaxPcY[6];
72
1d4857c5 73 inline static Bool_t IsInDead(Float_t x,Float_t y ); //is point in dead area?
74 inline static void Lors2Pad(Float_t x,Float_t y,Int_t &pc,Int_t &px,Int_t &py); //(x,y)->(pc,px,py)
d1bf51e1 75
d3da6dc4 76protected: //AliDigit has fTracks[3]
3c6274c1 77 Int_t fPad; //absolute pad number
da08475b 78 Float_t fQ; //QDC value, fractions are permitted for summable procedure
d3da6dc4 79 ClassDef(AliHMPIDDigit,4) //HMPID digit class
80};//class AliHMPIDDigitN
cf7e313e 81
82typedef AliHMPIDDigit AliRICHDigit; // for backward compatibility
83
d3da6dc4 84//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1d4857c5 85void AliHMPIDDigit::Lors2Pad(Float_t x,Float_t y,Int_t &pc,Int_t &px,Int_t &py)
d3da6dc4 86{
1d4857c5 87// Check the pad of given position
88// Arguments: x,y- position [cm] in LORS; pc,px,py- pad where to store the result
89// Returns: none
90 pc=px=py=-1;
3c6274c1 91 if (x>= 0 && x<= SizePcX() ) {pc=0; px=Int_t( x / SizePadX());}//PC 0 or 2 or 4
92 else if(x>=SizePcX()+SizeDead() && x<= SizeAllX() ) {pc=1; px=Int_t((x- SizePcX()- SizeDead()) / SizePadX());}//PC 2 or 4 or 6
1d4857c5 93 else return;
3c6274c1 94 if (y>= 0 && y<= SizePcY() ) { py=Int_t( y / SizePadY());}//PC 0 or 1
95 else if(y>=SizePcY()+SizeDead() && y<=2*SizePcY()+SizeDead() ) {pc+=2;py=Int_t((y- SizePcY()- SizeDead()) / SizePadY());}//PC 2 or 3
96 else if(y>=SizeAllY()-SizePcY() && y<= SizeAllY() ) {pc+=4;py=Int_t((y-2*SizePcY()-2*SizeDead()) / SizePadY());}//PC 4 or 5
1d4857c5 97 else return;
98}
d3da6dc4 99//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
100Int_t AliHMPIDDigit::Compare(const TObject *pObj) const
101{
102// 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.
103// This feature is used in digitizer to facilitate finding of sdigits for the same pad since they all will come together after sorting.
104// Arguments: pObj - pointer to object to compare with
105// Retunrs: -1 if AbsPad less then in pObj, 1 if more and 0 if they are the same
106 if (fPad==((AliHMPIDDigit*)pObj)->Pad()) return 0;
107 else if(fPad >((AliHMPIDDigit*)pObj)->Pad()) return 1;
da08475b 108 else return -1;
d3da6dc4 109}
110//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
111Bool_t AliHMPIDDigit::IsInDead(Float_t x,Float_t y)
112{
113// Check is the current point is outside of sensitive area or in dead zones
114// Arguments: x,y -position
115// Returns: 1 if not in sensitive zone
116 if(x<0 || x>SizeAllX() || y<0 || y>SizeAllY()) return kTRUE; //out of pc
117
118 if(x>SizePcX() && x<SizePcX()+SizeDead()) return kTRUE; //in dead zone along x
119
120 if(y>SizePcY() && y<SizePcY()+SizeDead()) return kTRUE; //in first dead zone along y
121 if(y>SizeAllY()-SizePcY()-SizeDead() && y<SizeAllY()-SizePcY()) return kTRUE; //in second dead zone along y
122 return kFALSE;
123}
124//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
125Float_t AliHMPIDDigit::Mathieson(Float_t x,Float_t y)const
126{
127// This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
128// Arguments: x,y- position of the center of Mathieson distribution
129// Returns: a charge fraction [0-1] imposed into the pad
130 const Float_t kSqrtK3=0.77459667,k2=0.962,k4=0.379;
131
132 Float_t ux1=kSqrtK3*TMath::TanH(k2*(x-LorsX()+0.5*SizePadX())/0.425);
133 Float_t ux2=kSqrtK3*TMath::TanH(k2*(x-LorsX()-0.5*SizePadX())/0.425);
134 Float_t uy1=kSqrtK3*TMath::TanH(k2*(y-LorsY()+0.5*SizePadY())/0.425);
135 Float_t uy2=kSqrtK3*TMath::TanH(k2*(y-LorsY()-0.5*SizePadY())/0.425);
136 return 4*k4*(TMath::ATan(ux2)-TMath::ATan(ux1))*k4*(TMath::ATan(uy2)-TMath::ATan(uy1));
137}
138//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1d4857c5 139void AliHMPIDDigit::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const
d3da6dc4 140{
141// Convert digit structure to raw word format
1d4857c5 142// Arguments: w32,ddl,r,d,a where to write the results
143// Returns: none
144 Int_t y2a[6]={5,3,1,0,2,4};
145
146 ddl=2*Ch()+Pc()%2; //DDL# 0..13
147 Int_t tmp=1+Pc()/2*8+PadPcY()/6; r=(Pc()%2)? 25-tmp:tmp; //row r=1..24
148 d=1+PadPcX()/8; //DILOGIC# 1..10
149 a=y2a[PadPcY()%6]+6*(PadPcX()%8); //ADDRESS 0..47
150
151 w32=0;
152 AliBitPacking::PackWord((UInt_t)fQ,w32, 0,11); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc bits (00..11) counts (0..4095)
153 AliBitPacking::PackWord( a ,w32,12,17); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC address bits (12..17) counts (0..47)
154 AliBitPacking::PackWord( d ,w32,18,21); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC number bits (18..21) counts (1..10)
155 AliBitPacking::PackWord( r ,w32,22,26); // Row number bits (22..26) counts (1..24)
d3da6dc4 156}
157//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1d4857c5 158void AliHMPIDDigit::Raw(UInt_t w32,Int_t ddl)
d3da6dc4 159{
160// Converts a given raw data word to a digit
161// Arguments: w32 - 32 bits raw data word
162// ddl - DDL idx 0 1 2 3 4 ... 13
163// Returns: none
1d4857c5 164 Int_t a2y[6]={3,2,4,1,5,0};//pady for a given address (for single DILOGIC chip)
165 Int_t r = AliBitPacking::UnpackWord(w32,22,26); assert(1<=r&&r<=24); // Row number (1..24)
166 Int_t d = AliBitPacking::UnpackWord(w32,18,21); assert(1<=d&&d<=10); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC number (1..10)
167 Int_t a = AliBitPacking::UnpackWord(w32,12,17); assert(0<=a&&a<=47); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC address (0..47)
168 Int_t q = AliBitPacking::UnpackWord(w32, 0,11); assert(0<=q&&q<=4095); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc (0..4095)
169 Int_t ch=ddl/2;
170 Int_t tmp=(r-1)/8; Int_t pc=(ddl%2)? 5-2*tmp:2*tmp;
171 Int_t px=(d-1)*8+a/6;
172 tmp=(ddl%2)?(24-r):r-1; Int_t py=6*(tmp%8)+a2y[a%6];
173 fPad=Abs(ch,pc,px,py);fQ=q;
d3da6dc4 174}
175//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1d4857c5 176Bool_t AliHMPIDDigit::Set(Int_t ch,Int_t pc,Int_t px,Int_t py,Float_t qdc,Int_t tid)
177{
178// Manual creation of digit
179// Arguments: ch,pc,px,py,qdc,tid
180// Returns: none
181 if(px<kMinPx || px>kMaxPx) return kTRUE;
182 if(py<kMinPy || py>kMaxPy) return kTRUE;
183
184 fPad=Abs(ch,pc,px,py);fQ=qdc;fTracks[0]=tid;
185 return kFALSE;
186}
d3da6dc4 187#endif