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