]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HMPID/AliHMPIDDigit.h
New AliPoissonCalculator class
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDDigit.h
... / ...
CommitLineData
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
19class TClonesArray; //Hit2Sdi()
20
21class AliHMPIDDigit :public AliDigit //TObject-AliDigit-AliHMPIDDigit
22{
23public:
24
25//ctor&dtor
26 AliHMPIDDigit( ):AliDigit( ),fPad(AliHMPIDParam::Abs(-1,-1,-1,-1)),fQ(-1) {} //default ctor
27 AliHMPIDDigit(Int_t pad,Int_t q,Int_t *t):AliDigit(t),fPad(pad ),fQ(q ) {if(fQ>4095)fQ=4095;} //digit ctor
28 AliHMPIDDigit(Int_t pad,Int_t q ):AliDigit( ),fPad(pad ),fQ(q ) {if(fQ>4095)fQ=4095;} //digit ctor
29 AliHMPIDDigit(const AliHMPIDDigit &d ):AliDigit(d),fPad(d.fPad),fQ(d.fQ) {} //copy ctor
30 virtual ~AliHMPIDDigit() {} //dtor
31//framework part
32 Bool_t IsSortable ( )const{return kTRUE;} //provision to use TObject::Sort()
33 inline Int_t Compare (const TObject *pObj )const; //provision to use TObject::Sort()
34 void Draw (Option_t *opt="" ); //TObject::Draw() overloaded
35 void Print (Option_t *opt="" )const; //TObject::Print() overloaded
36//private part
37
38 void AddTidOffset(Int_t offset ) {for (Int_t i=0; i<3; i++) if (fTracks[i]>0) fTracks[i]+=offset; } //needed for merging
39 Int_t Ch ( )const{return AliHMPIDParam::A2C(fPad); } //chamber number
40
41 Float_t LorsX ( )const{return AliHMPIDParam::LorsX(AliHMPIDParam::A2P(fPad),AliHMPIDParam::A2X(fPad)); } //center of the pad x, [cm]
42
43 Float_t LorsY ( )const{return AliHMPIDParam::LorsY(AliHMPIDParam::A2P(fPad),AliHMPIDParam::A2Y(fPad)); } //center of the pad y, [cm]
44//
45 inline Double_t MathiesonX (Double_t x )const; //Mathieson distribution along wires X
46 inline Double_t MathiesonY (Double_t x )const; //Mathieson distribution perp to wires Y
47 inline Double_t IntPartMathiX(Double_t z )const; //integral in 1-dim of Mathieson X
48 inline Double_t IntPartMathiY(Double_t z )const; //integral in 1-dim of Mathieson Y
49 inline Double_t IntMathieson (Double_t x,Double_t y )const; //integral in 2-dim of Mathieson
50 Int_t PadPcX ( )const{return AliHMPIDParam::A2X(fPad);} //pad pc x # 0..79
51 Int_t PadPcY ( )const{return AliHMPIDParam::A2Y(fPad);} //pad pc y # 0..47
52 Int_t PadChX ( )const{return (Pc()%2)*AliHMPIDParam::kPadPcX+PadPcX();} //pad ch x # 0..159
53 Int_t PadChY ( )const{return (Pc()/2)*AliHMPIDParam::kPadPcY+PadPcY();} //pad ch y # 0..143
54 Int_t Pad ( )const{return fPad;} //absolute id of this pad
55 Int_t Pc ( )const{return AliHMPIDParam::A2P(fPad);} //PC position number
56 Float_t Q ( )const{return fQ;} //charge, [QDC]
57 inline void Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const;
58 inline Bool_t Set (Int_t c,Int_t p,Int_t x,Int_t y,Int_t tid=0); //manual creation
59 void SetQ (Float_t q ) {fQ=q;if(fQ>4095)fQ=4095;} //setter for charge
60 void SetPad (Int_t pad ) {fPad=pad;} //setter for pad
61
62protected: //AliDigit has fTracks[3]
63
64
65 Int_t fPad; //absolute pad number
66 Float_t fQ; //QDC value, fractions are permitted for summable procedure
67 ClassDef(AliHMPIDDigit,4) //HMPID digit class
68};//class AliHMPIDDigit
69
70//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
71
72Int_t AliHMPIDDigit::Compare(const TObject *pObj) const
73{
74// 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.
75// This feature is used in digitizer to facilitate finding of sdigits for the same pad since they all will come together after sorting.
76// Arguments: pObj - pointer to object to compare with
77// Retunrs: -1 if AbsPad less then in pObj, 1 if more and 0 if they are the same
78 if (fPad==((AliHMPIDDigit*)pObj)->Pad()) return 0;
79 else if(fPad >((AliHMPIDDigit*)pObj)->Pad()) return 1;
80 else return -1;
81}
82//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
83
84Double_t AliHMPIDDigit::MathiesonX(Double_t x)const
85{
86// Mathieson function.
87// This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
88// Arguments: x- position of the center of Mathieson distribution
89// Returns: value of the Mathieson function
90
91 Double_t lambda = x/AliHMPIDParam::PitchAnodeCathode();
92 Double_t tanh = TMath::TanH(AliHMPIDParam::K2x()*lambda);
93 Double_t a=1-tanh*tanh;
94 Double_t b=1+AliHMPIDParam::SqrtK3x()*AliHMPIDParam::SqrtK3x()*tanh*tanh;
95 Double_t mathi = AliHMPIDParam::K1x()*a/b;
96 return mathi;
97}
98//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
99
100Double_t AliHMPIDDigit::MathiesonY(Double_t y)const
101{
102// Mathieson function.
103// This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
104// Arguments: x- position of the center of Mathieson distribution
105// Returns: value of the Mathieson function
106
107 Double_t lambda = y/AliHMPIDParam::PitchAnodeCathode();
108 Double_t tanh = TMath::TanH(AliHMPIDParam::K2y()*lambda);
109 Double_t a=1-tanh*tanh;
110 Double_t b=1+AliHMPIDParam::SqrtK3y()*AliHMPIDParam::SqrtK3y()*tanh*tanh;
111 Double_t mathi = AliHMPIDParam::K1y()*a/b;
112 return mathi;
113}
114//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
115
116Double_t AliHMPIDDigit::IntPartMathiX(Double_t x)const
117{
118// Integration of Mathieson.
119// This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
120// Arguments: x,y- position of the center of Mathieson distribution
121// Returns: a charge fraction [0-1] imposed into the pad
122 Double_t shift1 = -LorsX()+0.5*AliHMPIDParam::SizePadX();
123 Double_t shift2 = -LorsX()-0.5*AliHMPIDParam::SizePadX();
124
125 Double_t ux1=AliHMPIDParam::SqrtK3x()*TMath::TanH(AliHMPIDParam::K2x()*(x+shift1)/AliHMPIDParam::PitchAnodeCathode());
126 Double_t ux2=AliHMPIDParam::SqrtK3x()*TMath::TanH(AliHMPIDParam::K2x()*(x+shift2)/AliHMPIDParam::PitchAnodeCathode());
127
128 return AliHMPIDParam::K4x()*(TMath::ATan(ux2)-TMath::ATan(ux1));
129}
130//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
131
132Double_t AliHMPIDDigit::IntPartMathiY(Double_t y)const
133{
134// Integration of Mathieson.
135// This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
136// Arguments: x,y- position of the center of Mathieson distribution
137// Returns: a charge fraction [0-1] imposed into the pad
138 Double_t shift1 = -LorsY()+0.5*AliHMPIDParam::SizePadY();
139 Double_t shift2 = -LorsY()-0.5*AliHMPIDParam::SizePadY();
140
141 Double_t uy1=AliHMPIDParam::SqrtK3y()*TMath::TanH(AliHMPIDParam::K2y()*(y+shift1)/AliHMPIDParam::PitchAnodeCathode());
142 Double_t uy2=AliHMPIDParam::SqrtK3y()*TMath::TanH(AliHMPIDParam::K2y()*(y+shift2)/AliHMPIDParam::PitchAnodeCathode());
143
144 return AliHMPIDParam::K4y()*(TMath::ATan(uy2)-TMath::ATan(uy1));
145
146}
147//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
148
149Double_t AliHMPIDDigit::IntMathieson(Double_t x,Double_t y)const
150{
151// Integration of Mathieson.
152// This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
153// Arguments: x,y- position of the center of Mathieson distribution
154// Returns: a charge fraction [0-1] imposed into the pad
155
156 Double_t xm = IntPartMathiX(x);
157 Double_t ym = IntPartMathiY(y);
158 return 4*xm*ym;
159}
160//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
161void AliHMPIDDigit::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const
162{
163// Convert digit structure to raw word format
164// Arguments: w32,ddl,r,d,a where to write the results
165// Returns: none
166 Int_t y2a[6]={5,3,1,0,2,4};
167
168 ddl=2*Ch()+Pc()%2; //DDL# 0..13
169 Int_t tmp=1+Pc()/2*8+PadPcY()/6; r=(Pc()%2)? tmp:25-tmp; //row r=1..24
170 d=1+PadPcX()/8; //DILOGIC# 1..10
171// d=AliHMPIDRawStream::kNDILOGICAdd+1-d; ////flip according to Paolo (2-9-2008)
172 d=10+1-d; ////flip according to Paolo (2-9-2008)
173 a=y2a[PadPcY()%6]+6*(7-PadPcX()%8); //ADDRESS 0..47
174
175 w32=0;
176 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
177 AliBitPacking::PackWord((UInt_t)fQ,w32, 0,11); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc bits (00..11) counts (0..4095)
178 AliBitPacking::PackWord( a ,w32,12,17); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC address bits (12..17) counts (0..47)
179 AliBitPacking::PackWord( d ,w32,18,21); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC number bits (18..21) counts (1..10)
180 AliBitPacking::PackWord( r ,w32,22,26); // Row number bits (22..26) counts (1..24)
181 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
182}
183//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
184Bool_t AliHMPIDDigit::Set(Int_t ch,Int_t pc,Int_t px,Int_t py,Int_t tid)
185{
186// Manual creation of digit
187// Arguments: ch,pc,px,py,qdc,tid
188// Returns: kTRUE if wrong digit
189 if(ch<AliHMPIDParam::kMinCh || ch>AliHMPIDParam::kMaxCh) return kTRUE;
190 if(pc<AliHMPIDParam::kMinPc || pc>AliHMPIDParam::kMaxPc) return kTRUE;
191 if(px<AliHMPIDParam::kMinPx || px>AliHMPIDParam::kMaxPx) return kTRUE;
192 if(py<AliHMPIDParam::kMinPy || py>AliHMPIDParam::kMaxPy) return kTRUE;
193
194
195 fPad=AliHMPIDParam::Abs(ch,pc,px,py);fTracks[0]=tid;
196 fQ=0;
197 return kFALSE;
198}
199//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
200
201#endif