]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDDigit.h
AliTriggerAnalisys:
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDDigit.h
index 16665542ca221d4d89629363a0b1c9c49719c29b..6b7f300b4e28dbd6edb55eed11892902c415fe2f 100644 (file)
@@ -14,6 +14,7 @@
 #include "TMath.h"         //Mathieson()
 #include <AliBitPacking.h> //Raw()
 #include "AliHMPIDParam.h"
+//#include "AliHMPIDRawStream.h"
 
 class TClonesArray;        //Hit2Sdi()
   
@@ -23,9 +24,9 @@ public:
     
 //ctor&dtor    
   AliHMPIDDigit(                          ):AliDigit( ),fPad(AliHMPIDParam::Abs(-1,-1,-1,-1)),fQ(-1)  {}                         //default ctor
-  AliHMPIDDigit(Int_t pad,Int_t q,Int_t *t):AliDigit(t),fPad(pad             ),fQ(q )  {}                         //digit ctor
-  AliHMPIDDigit(Int_t pad,Int_t q         ):AliDigit( ),fPad(pad             ),fQ(q )  {}                         //digit ctor
-  AliHMPIDDigit(const AliHMPIDDigit &d    ):AliDigit(d),fPad(d.fPad),fQ(d.fQ)          {}                         //copy ctor
+  AliHMPIDDigit(Int_t pad,Int_t q,Int_t *t):AliDigit(t),fPad(pad             ),fQ(q )  {if(fQ>4095)fQ=4095;}                     //digit ctor
+  AliHMPIDDigit(Int_t pad,Int_t q         ):AliDigit( ),fPad(pad             ),fQ(q )  {if(fQ>4095)fQ=4095;}                     //digit ctor
+  AliHMPIDDigit(const AliHMPIDDigit &d    ):AliDigit(d),fPad(d.fPad),fQ(d.fQ)          {}                                        //copy ctor
   virtual ~AliHMPIDDigit()                                                             {}                         //dtor   
 //framework part    
          Bool_t  IsSortable  (                               )const{return kTRUE;}                                                     //provision to use TObject::Sort() 
@@ -41,9 +42,11 @@ public:
 
          Float_t LorsY       (                               )const{return AliHMPIDParam::LorsY(AliHMPIDParam::A2P(fPad),AliHMPIDParam::A2Y(fPad));                               } //center of the pad y, [cm]
 //  
-  inline Float_t Mathieson   (Float_t x                      )const;                                                                   //Mathieson distribution 
-  inline Float_t IntPartMathi(Float_t z, Int_t axis          )const;                                                                   //integral in 1-dim of Mathieson
-  inline Float_t IntMathieson(Float_t x,Float_t y            )const;                                                                   //integral in 2-dim of Mathieson  
+  inline Double_t MathiesonX   (Double_t x                   )const;                                                                   //Mathieson distribution along wires X 
+  inline Double_t MathiesonY   (Double_t x                   )const;                                                                   //Mathieson distribution perp to wires Y
+  inline Double_t IntPartMathiX(Double_t z                   )const;                                                                   //integral in 1-dim of Mathieson X
+  inline Double_t IntPartMathiY(Double_t z                   )const;                                                                   //integral in 1-dim of Mathieson Y
+  inline Double_t IntMathieson (Double_t x,Double_t y        )const;                                                                   //integral in 2-dim of Mathieson  
          Int_t   PadPcX      (                               )const{return AliHMPIDParam::A2X(fPad);}                                                 //pad pc x # 0..79
          Int_t   PadPcY      (                               )const{return AliHMPIDParam::A2Y(fPad);}                                                 //pad pc y # 0..47
          Int_t   PadChX      (                               )const{return (Pc()%2)*AliHMPIDParam::kPadPcX+PadPcX();}                                 //pad ch x # 0..159
@@ -53,8 +56,8 @@ public:
          Float_t Q           (                               )const{return fQ;}                                                        //charge, [QDC]
   inline void    Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const;
   inline Bool_t  Set         (Int_t c,Int_t p,Int_t x,Int_t y,Int_t tid=0);                                                            //manual creation 
-         void    SetQ        (Float_t q                      )     {fQ=q;}                                                             //manual creation 
-
+         void    SetQ        (Float_t q                      )     {fQ=q;if(fQ>4095)fQ=4095;}                                          //setter for charge 
+         void    SetPad      (Int_t pad                      )     {fPad=pad;}                                                         //setter for pad
  
 protected:                                                                   //AliDigit has fTracks[3]
                                                                                
@@ -78,54 +81,80 @@ Int_t AliHMPIDDigit::Compare(const TObject *pObj) const
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-Float_t AliHMPIDDigit::Mathieson(Float_t x)const
+Double_t AliHMPIDDigit::MathiesonX(Double_t x)const
+{
+// Mathieson function.
+// This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
+// Arguments: x- position of the center of Mathieson distribution
+//  Returns: value of the Mathieson function
+  
+  Double_t lambda = x/AliHMPIDParam::PitchAnodeCathode();
+  Double_t tanh = TMath::TanH(AliHMPIDParam::K2x()*lambda);
+  Double_t a=1-tanh*tanh;
+  Double_t b=1+AliHMPIDParam::SqrtK3x()*AliHMPIDParam::SqrtK3x()*tanh*tanh;
+  Double_t mathi = AliHMPIDParam::K1x()*a/b;
+  return mathi;
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+Double_t AliHMPIDDigit::MathiesonY(Double_t y)const
 {
 // Mathieson function.
 // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
 // Arguments: x- position of the center of Mathieson distribution
 //  Returns: value of the Mathieson function
-  Float_t  kK1=0.28278795,kK2=0.96242952, kSqrtK3 =0.77459667, kD=0.445;
-  Float_t lambda = x/kD;
-  Float_t a=1-TMath::TanH(kK2*lambda)*TMath::TanH(kK2*lambda);
-  Float_t b=1+kSqrtK3*kSqrtK3*TMath::TanH(kK2*lambda)*TMath::TanH(kK2*lambda);
-  Float_t mathi = kK1*a/b;
+  
+  Double_t lambda = y/AliHMPIDParam::PitchAnodeCathode();
+  Double_t tanh = TMath::TanH(AliHMPIDParam::K2y()*lambda);
+  Double_t a=1-tanh*tanh;
+  Double_t b=1+AliHMPIDParam::SqrtK3y()*AliHMPIDParam::SqrtK3y()*tanh*tanh;
+  Double_t mathi = AliHMPIDParam::K1y()*a/b;
   return mathi;
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-Float_t AliHMPIDDigit::IntPartMathi(Float_t z, Int_t axis)const
+Double_t AliHMPIDDigit::IntPartMathiX(Double_t x)const
 {
 // Integration of Mathieson.
 // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
 // Arguments: x,y- position of the center of Mathieson distribution
 //  Returns: a charge fraction [0-1] imposed into the pad
-  Float_t shift1,shift2;
-  if(axis==1) {
-    shift1 = -LorsX()+0.5*AliHMPIDParam::SizePadX();
-    shift2 = -LorsX()-0.5*AliHMPIDParam::SizePadX();
-  } else {
-    shift1 = -LorsY()+0.5*AliHMPIDParam::SizePadY();
-    shift2 = -LorsY()-0.5*AliHMPIDParam::SizePadY();
-  }
+  Double_t shift1 = -LorsX()+0.5*AliHMPIDParam::SizePadX();
+  Double_t shift2 = -LorsX()-0.5*AliHMPIDParam::SizePadX();
     
-  Float_t  kK2=0.96242952, kSqrtK3 =0.77459667,  kK4=0.37932926, kD=0.445;
+  Double_t ux1=AliHMPIDParam::SqrtK3x()*TMath::TanH(AliHMPIDParam::K2x()*(x+shift1)/AliHMPIDParam::PitchAnodeCathode());
+  Double_t ux2=AliHMPIDParam::SqrtK3x()*TMath::TanH(AliHMPIDParam::K2x()*(x+shift2)/AliHMPIDParam::PitchAnodeCathode());
+  
+  return AliHMPIDParam::K4x()*(TMath::ATan(ux2)-TMath::ATan(ux1));
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-  Float_t ux1=kSqrtK3*TMath::TanH(kK2*(z+shift1)/kD);
-  Float_t ux2=kSqrtK3*TMath::TanH(kK2*(z+shift2)/kD);
+Double_t AliHMPIDDigit::IntPartMathiY(Double_t y)const
+{
+// Integration of Mathieson.
+// This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
+// Arguments: x,y- position of the center of Mathieson distribution
+//  Returns: a charge fraction [0-1] imposed into the pad
+  Double_t shift1 = -LorsY()+0.5*AliHMPIDParam::SizePadY();
+  Double_t shift2 = -LorsY()-0.5*AliHMPIDParam::SizePadY();
+    
+  Double_t uy1=AliHMPIDParam::SqrtK3y()*TMath::TanH(AliHMPIDParam::K2y()*(y+shift1)/AliHMPIDParam::PitchAnodeCathode());
+  Double_t uy2=AliHMPIDParam::SqrtK3y()*TMath::TanH(AliHMPIDParam::K2y()*(y+shift2)/AliHMPIDParam::PitchAnodeCathode());
+  
+  return AliHMPIDParam::K4y()*(TMath::ATan(uy2)-TMath::ATan(uy1));
   
-  return kK4*(TMath::ATan(ux2)-TMath::ATan(ux1));
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-Float_t AliHMPIDDigit::IntMathieson(Float_t x,Float_t y)const
+Double_t AliHMPIDDigit::IntMathieson(Double_t x,Double_t y)const
 {
 // Integration of Mathieson.
 // This is the answer to electrostatic problem of charge distrubution in MWPC described elsewhere. (NIM A370(1988)602-603)
 // Arguments: x,y- position of the center of Mathieson distribution
 //  Returns: a charge fraction [0-1] imposed into the pad
 
-  Float_t xm = IntPartMathi(x,1);
-  Float_t ym = IntPartMathi(y,2);
+  Double_t xm = IntPartMathiX(x);
+  Double_t ym = IntPartMathiY(y);
   return 4*xm*ym;
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -137,37 +166,19 @@ void AliHMPIDDigit::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const
   Int_t y2a[6]={5,3,1,0,2,4};
 
   ddl=2*Ch()+Pc()%2;                    //DDL# 0..13
- // Int_t tmp=1+Pc()/2*8+PadPcY()/6;  r=(Pc()%2)? 25-tmp:tmp;               //row r=1..24
   Int_t tmp=1+Pc()/2*8+PadPcY()/6;  r=(Pc()%2)? tmp:25-tmp;               //row r=1..24
   d=1+PadPcX()/8;                       //DILOGIC# 1..10
-  a=y2a[PadPcY()%6]+6*(PadPcX()%8);     //ADDRESS 0..47        
+//  d=AliHMPIDRawStream::kNDILOGICAdd+1-d;                   ////flip according to Paolo (2-9-2008)
+  d=10+1-d;                                                  ////flip according to Paolo (2-9-2008)
+  a=y2a[PadPcY()%6]+6*(7-PadPcX()%8);   //ADDRESS 0..47        
     
-   /*
-   Int_t a2y[6]={3,2,4,1,5,0};     //pady for a given padress (for single DILOGIC chip)
-                                  Int_t ch=ddl/2;
-  Int_t tmp=(24-row)/8;
-  Int_t pc=(ddl%2)?5-2*tmp:2*tmp;
-  Int_t px=(dil-1)*8+pad/6;
-
-  tmp=(ddl%2)?row-1:(24-row);
-  Int_t py=6*(tmp%8)+a2y[pad%6];
-
-   */                                 
-                                    
-                                      
   w32=0;   
-  //Printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-  //
-  //Printf("AliHMPIDDigit::Raw ddl: %d r: %d d: %d a: %d",ddl,r,d,a);
-  //Printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-//  Bool_t isOK=kTRUE; isOK=
-  AliBitPacking::PackWord((fQ>4095)?(UInt_t)4095:(UInt_t)fQ,w32, 0,11);       // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq        Qdc               bits (00..11) counts (0..4095)
-  //Printf("isOK: %d",isOK);
-  //molnarl: Since in simulation the the charge can be > than 4095 but not in real life we need to protect. If fQ>4095 after packing we will get 0 for the charge! 
-  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)
-  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)
-  assert(1<=r&&r<=24);AliBitPacking::PackWord(        r ,w32,22,26);  //                                                Row number        bits (22..26) counts (1..24)  
-                      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
+  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 
+  AliBitPacking::PackWord((UInt_t)fQ,w32, 0,11);                      // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq        Qdc               bits (00..11) counts (0..4095)
+  AliBitPacking::PackWord(        a ,w32,12,17);                      // 3322 2222 2222 1111 1111 1000 0000 0000        DILOGIC address   bits (12..17) counts (0..47)
+  AliBitPacking::PackWord(        d ,w32,18,21);                      // 1098 7654 3210 9876 5432 1098 7654 3210        DILOGIC number    bits (18..21) counts (1..10)
+  AliBitPacking::PackWord(        r ,w32,22,26);                      //                                                Row number        bits (22..26) counts (1..24)  
+  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
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Bool_t AliHMPIDDigit::Set(Int_t ch,Int_t pc,Int_t px,Int_t py,Int_t tid)
@@ -175,8 +186,11 @@ Bool_t AliHMPIDDigit::Set(Int_t ch,Int_t pc,Int_t px,Int_t py,Int_t tid)
 // Manual creation of digit
 // Arguments: ch,pc,px,py,qdc,tid  
 //   Returns: kTRUE if wrong digit
+  if(ch<AliHMPIDParam::kMinCh || ch>AliHMPIDParam::kMaxCh) return kTRUE;
+  if(pc<AliHMPIDParam::kMinPc || pc>AliHMPIDParam::kMaxPc) return kTRUE;
   if(px<AliHMPIDParam::kMinPx || px>AliHMPIDParam::kMaxPx) return kTRUE;
   if(py<AliHMPIDParam::kMinPy || py>AliHMPIDParam::kMaxPy) return kTRUE;
+  
 
   fPad=AliHMPIDParam::Abs(ch,pc,px,py);fTracks[0]=tid;
   fQ=0;