]>
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 | ||
ea925242 | 6 | // Class of HMPID to manage digits ---> pads |
1b10372c | 7 | //. |
8 | //. | |
9 | //. | |
ea925242 | 10 | |
d3da6dc4 | 11 | #include <AliDigit.h> //base class |
49dfd67a | 12 | #include <AliRawReader.h> |
13 | #include <AliLog.h> | |
ea925242 | 14 | #include "TMath.h" //Mathieson() |
d3da6dc4 | 15 | #include <AliBitPacking.h> //Raw() |
ae5a42aa | 16 | #include "AliHMPIDParam.h" |
d3da6dc4 | 17 | |
d3da6dc4 | 18 | class TClonesArray; //Hit2Sdi() |
3c6274c1 | 19 | |
d3da6dc4 | 20 | class AliHMPIDDigit :public AliDigit //TObject-AliDigit-AliHMPIDDigit |
21 | { | |
22 | public: | |
ae5a42aa | 23 | |
d3da6dc4 | 24 | //ctor&dtor |
ae5a42aa | 25 | AliHMPIDDigit( ):AliDigit( ),fPad(AliHMPIDParam::Abs(-1,-1,-1,-1)),fQ(-1) {} //default ctor |
1d4857c5 | 26 | AliHMPIDDigit(Int_t pad,Int_t q,Int_t *t):AliDigit(t),fPad(pad ),fQ(q ) {} //digit ctor |
27 | AliHMPIDDigit(const AliHMPIDDigit &d ):AliDigit(d),fPad(d.fPad),fQ(d.fQ) {} //copy ctor | |
28 | virtual ~AliHMPIDDigit() {} //dtor | |
d3da6dc4 | 29 | //framework part |
30 | Bool_t IsSortable ( )const{return kTRUE;} //provision to use TObject::Sort() | |
31 | inline Int_t Compare (const TObject *pObj )const; //provision to use TObject::Sort() | |
d1bf51e1 | 32 | void Draw (Option_t *opt="" ); //TObject::Draw() overloaded |
d3da6dc4 | 33 | void Print (Option_t *opt="" )const; //TObject::Print() overloaded |
34 | //private part | |
ae5a42aa | 35 | |
1d4857c5 | 36 | void AddTidOffset(Int_t offset ) {for (Int_t i=0; i<3; i++) if (fTracks[i]>0) fTracks[i]+=offset; } //needed for merging |
ae5a42aa | 37 | Int_t Ch ( )const{return AliHMPIDParam::A2C(fPad); } //chamber number |
38 | ||
39 | Float_t LorsX ( )const{return AliHMPIDParam::LorsX(AliHMPIDParam::A2P(fPad),AliHMPIDParam::A2X(fPad)); } //center of the pad x, [cm] | |
40 | ||
41 | Float_t LorsY ( )const{return AliHMPIDParam::LorsY(AliHMPIDParam::A2P(fPad),AliHMPIDParam::A2Y(fPad)); } //center of the pad y, [cm] | |
42 | // | |
76fd1a96 | 43 | inline Float_t Mathieson (Float_t x )const; //Mathieson distribution |
44 | inline Float_t IntPartMathi(Float_t z, Int_t axis )const; //integral in 1-dim of Mathieson | |
45 | inline Float_t IntMathieson(Float_t x,Float_t y )const; //integral in 2-dim of Mathieson | |
ae5a42aa | 46 | Int_t PadPcX ( )const{return AliHMPIDParam::A2X(fPad);} //pad pc x # 0..79 |
47 | Int_t PadPcY ( )const{return AliHMPIDParam::A2Y(fPad);} //pad pc y # 0..47 | |
48 | Int_t PadChX ( )const{return (Pc()%2)*AliHMPIDParam::kPadPcX+PadPcX();} //pad ch x # 0..159 | |
49 | Int_t PadChY ( )const{return (Pc()/2)*AliHMPIDParam::kPadPcY+PadPcY();} //pad ch y # 0..143 | |
d3da6dc4 | 50 | Int_t Pad ( )const{return fPad;} //absolute id of this pad |
ae5a42aa | 51 | Int_t Pc ( )const{return AliHMPIDParam::A2P(fPad);} //PC position number |
da08475b | 52 | Float_t Q ( )const{return fQ;} //charge, [QDC] |
1d4857c5 | 53 | 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) |
49dfd67a | 54 | inline Bool_t Raw (UInt_t w32,Int_t ddl,AliRawReader *pRR); //(w32,ddl)->digit |
a0e5c1b9 | 55 | inline void Raw (Int_t ddl,Int_t r,Int_t d,Int_t a); //raw->abs pad number |
f3bae3e2 | 56 | inline Bool_t Set (Int_t c,Int_t p,Int_t x,Int_t y,Int_t tid=0); //manual creation |
57 | void SetQ (Float_t q ) {fQ=q;} //manual creation | |
ae5a42aa | 58 | void SetNsig (Int_t sigmas ) {AliHMPIDParam::fgSigmas=sigmas;} //set n sigmas |
1d4857c5 | 59 | static void WriteRaw (TObjArray *pDigLst ); //write as raw stream |
49dfd67a | 60 | enum EHMPIDRawError { |
61 | kInvalidRawDataWord = 1 | |
62 | }; | |
ae5a42aa | 63 | |
c5c19d6a | 64 | protected: //AliDigit has fTracks[3] |
ae5a42aa | 65 | |
66 | ||
1b10372c | 67 | Int_t fPad; //absolute pad number |
c5c19d6a | 68 | Float_t fQ; //QDC value, fractions are permitted for summable procedure |
69 | ClassDef(AliHMPIDDigit,4) //HMPID digit class | |
70 | };//class AliHMPIDDigit | |
cf7e313e | 71 | |
d3da6dc4 | 72 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
ae5a42aa | 73 | |
d3da6dc4 | 74 | Int_t AliHMPIDDigit::Compare(const TObject *pObj) const |
75 | { | |
76 | // 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. | |
77 | // This feature is used in digitizer to facilitate finding of sdigits for the same pad since they all will come together after sorting. | |
78 | // Arguments: pObj - pointer to object to compare with | |
79 | // Retunrs: -1 if AbsPad less then in pObj, 1 if more and 0 if they are the same | |
80 | if (fPad==((AliHMPIDDigit*)pObj)->Pad()) return 0; | |
81 | else if(fPad >((AliHMPIDDigit*)pObj)->Pad()) return 1; | |
da08475b | 82 | else return -1; |
d3da6dc4 | 83 | } |
84 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
ae5a42aa | 85 | |
76fd1a96 | 86 | Float_t AliHMPIDDigit::Mathieson(Float_t x)const |
87 | { | |
88 | // Mathieson function. | |
89 | // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603) | |
90 | // Arguments: x- position of the center of Mathieson distribution | |
91 | // Returns: value of the Mathieson function | |
92 | Float_t kK1=0.28278795,kK2=0.96242952, kSqrtK3 =0.77459667, kD=0.445; | |
93 | Float_t lambda = x/kD; | |
94 | Float_t a=1-TMath::TanH(kK2*lambda)*TMath::TanH(kK2*lambda); | |
95 | Float_t b=1+kSqrtK3*kSqrtK3*TMath::TanH(kK2*lambda)*TMath::TanH(kK2*lambda); | |
96 | Float_t mathi = kK1*a/b; | |
97 | return mathi; | |
98 | } | |
99 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
100 | ||
101 | Float_t AliHMPIDDigit::IntPartMathi(Float_t z, Int_t axis)const | |
102 | { | |
103 | // Integration of Mathieson. | |
104 | // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603) | |
105 | // Arguments: x,y- position of the center of Mathieson distribution | |
106 | // Returns: a charge fraction [0-1] imposed into the pad | |
107 | Float_t shift1,shift2; | |
108 | if(axis==1) { | |
109 | shift1 = -LorsX()+0.5*AliHMPIDParam::SizePadX(); | |
110 | shift2 = -LorsX()-0.5*AliHMPIDParam::SizePadX(); | |
111 | } else { | |
112 | shift1 = -LorsY()+0.5*AliHMPIDParam::SizePadY(); | |
113 | shift2 = -LorsY()-0.5*AliHMPIDParam::SizePadY(); | |
114 | } | |
115 | ||
116 | Float_t kK2=0.96242952, kSqrtK3 =0.77459667, kK4=0.37932926, kD=0.445; | |
117 | ||
118 | Float_t ux1=kSqrtK3*TMath::TanH(kK2*(z+shift1)/kD); | |
119 | Float_t ux2=kSqrtK3*TMath::TanH(kK2*(z+shift2)/kD); | |
120 | ||
121 | return kK4*(TMath::ATan(ux2)-TMath::ATan(ux1)); | |
122 | } | |
123 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
124 | ||
c5c19d6a | 125 | Float_t AliHMPIDDigit::IntMathieson(Float_t x,Float_t y)const |
d3da6dc4 | 126 | { |
c5c19d6a | 127 | // Integration of Mathieson. |
d3da6dc4 | 128 | // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603) |
129 | // Arguments: x,y- position of the center of Mathieson distribution | |
130 | // Returns: a charge fraction [0-1] imposed into the pad | |
d3da6dc4 | 131 | |
76fd1a96 | 132 | Float_t xm = IntPartMathi(x,1); |
133 | Float_t ym = IntPartMathi(y,2); | |
134 | return 4*xm*ym; | |
d3da6dc4 | 135 | } |
136 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1d4857c5 | 137 | void AliHMPIDDigit::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const |
d3da6dc4 | 138 | { |
139 | // Convert digit structure to raw word format | |
1d4857c5 | 140 | // Arguments: w32,ddl,r,d,a where to write the results |
141 | // Returns: none | |
142 | Int_t y2a[6]={5,3,1,0,2,4}; | |
143 | ||
144 | ddl=2*Ch()+Pc()%2; //DDL# 0..13 | |
145 | Int_t tmp=1+Pc()/2*8+PadPcY()/6; r=(Pc()%2)? 25-tmp:tmp; //row r=1..24 | |
146 | d=1+PadPcX()/8; //DILOGIC# 1..10 | |
147 | a=y2a[PadPcY()%6]+6*(PadPcX()%8); //ADDRESS 0..47 | |
148 | ||
149 | w32=0; | |
d4522894 | 150 | //Protection for charge > 4095 |
151 | AliBitPacking::PackWord((fQ>4095)?4095:(UInt_t)fQ,w32,0,11); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc bits (00..11) counts (0..4095) | |
152 | AliBitPacking::PackWord( a ,w32,12,17); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC address bits (12..17) counts (0..47) | |
153 | AliBitPacking::PackWord( d ,w32,18,21); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC number bits (18..21) counts (1..10) | |
154 | AliBitPacking::PackWord( r ,w32,22,26); // Row number bits (22..26) counts (1..24) | |
d3da6dc4 | 155 | } |
156 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
49dfd67a | 157 | Bool_t AliHMPIDDigit::Raw(UInt_t w32,Int_t ddl, AliRawReader *pRR) |
d3da6dc4 | 158 | { |
159 | // Converts a given raw data word to a digit | |
160 | // Arguments: w32 - 32 bits raw data word | |
161 | // ddl - DDL idx 0 1 2 3 4 ... 13 | |
162 | // Returns: none | |
1d4857c5 | 163 | Int_t r = AliBitPacking::UnpackWord(w32,22,26); assert(1<=r&&r<=24); // Row number (1..24) |
164 | 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) | |
165 | 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) | |
a0e5c1b9 | 166 | Int_t q = AliBitPacking::UnpackWord(w32, 0,11); assert(0<=q&&q<=4095); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc (0..4095) |
49dfd67a | 167 | if (r<1 || r>24 || d<1 || d>10 || a<0 || a>47 || q<0 || q>4095) { |
168 | AliWarning(Form("Invalid raw data word %x",w32)); | |
169 | pRR->AddMajorErrorLog(kInvalidRawDataWord,Form("w=%x",w32)); | |
170 | return kFALSE; | |
171 | } | |
a0e5c1b9 | 172 | Raw(ddl,r,d,a); |
173 | fQ=q; | |
49dfd67a | 174 | return kTRUE; |
a0e5c1b9 | 175 | } |
176 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
177 | void AliHMPIDDigit::Raw(Int_t ddl,Int_t r,Int_t d,Int_t a) | |
178 | { | |
56d2de52 | 179 | assert(0<=ddl&&ddl<=13); assert(1<=r&&r<=24); assert(1<=d&&d<=10); assert(0<=a&&a<=47); |
a0e5c1b9 | 180 | Int_t a2y[6]={3,2,4,1,5,0};//pady for a given address (for single DILOGIC chip) |
1d4857c5 | 181 | Int_t ch=ddl/2; |
182 | Int_t tmp=(r-1)/8; Int_t pc=(ddl%2)? 5-2*tmp:2*tmp; | |
183 | Int_t px=(d-1)*8+a/6; | |
184 | tmp=(ddl%2)?(24-r):r-1; Int_t py=6*(tmp%8)+a2y[a%6]; | |
ae5a42aa | 185 | fPad=AliHMPIDParam::Abs(ch,pc,px,py); |
d3da6dc4 | 186 | } |
a0e5c1b9 | 187 | |
188 | ||
d3da6dc4 | 189 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
f3bae3e2 | 190 | Bool_t AliHMPIDDigit::Set(Int_t ch,Int_t pc,Int_t px,Int_t py,Int_t tid) |
1d4857c5 | 191 | { |
192 | // Manual creation of digit | |
193 | // Arguments: ch,pc,px,py,qdc,tid | |
f3bae3e2 | 194 | // Returns: kTRUE if wrong digit |
ae5a42aa | 195 | if(px<AliHMPIDParam::kMinPx || px>AliHMPIDParam::kMaxPx) return kTRUE; |
196 | if(py<AliHMPIDParam::kMinPy || py>AliHMPIDParam::kMaxPy) return kTRUE; | |
1d4857c5 | 197 | |
ae5a42aa | 198 | fPad=AliHMPIDParam::Abs(ch,pc,px,py);fTracks[0]=tid; |
f3bae3e2 | 199 | fQ=0; |
1d4857c5 | 200 | return kFALSE; |
201 | } | |
d3da6dc4 | 202 | #endif |