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