]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New TPC files from M.Kowalski.
authorfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 9 Jun 1999 14:51:55 +0000 (14:51 +0000)
committerfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 9 Jun 1999 14:51:55 +0000 (14:51 +0000)
24 files changed:
TPC/AliTPC.cxx
TPC/AliTPC.h
TPC/AliTPCD.cxx [new file with mode: 0644]
TPC/AliTPCD.h [new file with mode: 0644]
TPC/AliTPCDigitsDisplay.C [new file with mode: 0644]
TPC/AliTPCHits2Digits.C [new file with mode: 0644]
TPC/AliTPCPRF2D.cxx [new file with mode: 0644]
TPC/AliTPCPRF2D.h [new file with mode: 0644]
TPC/AliTPCParam.cxx [new file with mode: 0644]
TPC/AliTPCParam.h [new file with mode: 0644]
TPC/AliTPCRF1D.cxx [new file with mode: 0644]
TPC/AliTPCRF1D.h [new file with mode: 0644]
TPC/AliTPCSecGeo.h
TPC/AliTPCTestClustering.C [new file with mode: 0644]
TPC/AliTPCTestTracking.C [new file with mode: 0644]
TPC/AliTPCv0.cxx
TPC/AliTPCv0.h
TPC/AliTPCv1.cxx
TPC/AliTPCv1.h
TPC/AliTPCv2.cxx
TPC/AliTPCv2.h
TPC/Make-depend
TPC/Makefile
TPC/TPCLinkDef.h

index e0d7bd71937e3ab0187c71628ba1f156d6c0b908..181af9f2a11065a820620ad88a8e81d58a28e3b0 100644 (file)
 */
 //End_Html
 //                                                                           //
-//                                                                           //
+//                                                                          //
 ///////////////////////////////////////////////////////////////////////////////
 
 #include <TMath.h>
 #include <TRandom.h>
 #include <TVector.h>
+#include <TMatrix.h>
 #include <TGeometry.h>
 #include <TNode.h>
 #include <TTUBS.h>
 #include <fstream.h>
 #include "AliMC.h"
 
+//MI change
+#include "AliTPCParam.h"
+#include "AliTPCD.h"
+#include "AliTPCPRF2D.h"
+#include "AliTPCRF1D.h"
+
+
 ClassImp(AliTPC) 
 
 //_____________________________________________________________________________
@@ -44,6 +52,9 @@ AliTPC::AliTPC()
   fNsectors = 0;
   fNtracks  = 0;
   fNclusters= 0;
+  //MI changes
+  fDigParam= new AliTPCD();
+  fDigits = fDigParam->GetArray();
 }
  
 //_____________________________________________________________________________
@@ -57,7 +68,10 @@ AliTPC::AliTPC(const char *name, const char *title)
   //
   // Initialise arrays of hits and digits 
   fHits     = new TClonesArray("AliTPChit",  176);
-  fDigits   = new TClonesArray("AliTPCdigit",10000);
+  //  fDigits   = new TClonesArray("AliTPCdigit",10000);
+  //MI change
+  fDigParam= new AliTPCD;
+  fDigits = fDigParam->GetArray();
   //
   // Initialise counters
   fClusters = 0;
@@ -85,6 +99,7 @@ AliTPC::~AliTPC()
   delete fDigits;
   delete fClusters;
   delete fTracks;
+  delete fDigParam;
   if (fDigitsIndex)   delete [] fDigitsIndex;
   if (fClustersIndex) delete [] fClustersIndex;
 }
@@ -117,7 +132,9 @@ void AliTPC::AddDigit(Int_t *tracks, Int_t *digits)
   //
   // Add a TPC digit to the list
   //
-  TClonesArray &ldigits = *fDigits;
+  //  TClonesArray &ldigits = *fDigits;
+  //MI change 
+  TClonesArray &ldigits = *fDigParam->GetArray();
   new(ldigits[fNdigits++]) AliTPCdigit(tracks,digits);
 }
  
@@ -162,7 +179,7 @@ void AliTPC::BuildGeometry()
   TTUBS *tubs;
   Int_t i;
   const int kColorTPC=19;
-  char name[5], title[18];
+  char name[5], title[20];
   const Double_t kDegrad=TMath::Pi()/180;
   const Double_t loAng=30;
   const Double_t hiAng=15;
@@ -197,312 +214,6 @@ void AliTPC::BuildGeometry()
     fNodes->Add(Node);
   }
 }
-
-//_____________________________________________________________________________
-void AliTPC::CreateList(Int_t *tracks,Float_t signal[][MAXTPCTBK+1],
-                       Int_t ntr,Int_t time)
-{
-  //
-  // Creates list of tracks contributing to a given digit
-  // Only the 3 most significant tracks are taken into account
-  //
-  
-  Int_t i,j;
-  
-  for(i=0;i<3;i++) tracks[i]=-1;
-  
-  //
-  //  Loop over signals, only 3 times
-  //
-  
-  Float_t qmax;
-  Int_t jmax;
-  Int_t jout[3] = {-1,-1,-1};
-
-  for(i=0;i<3;i++){
-    qmax=0.;
-    jmax=0;
-    
-    for(j=0;j<ntr;j++){
-      
-      if((i == 1 && j == jout[i-1]) 
-        ||(i == 2 && (j == jout[i-1] || j == jout[i-2]))) continue;
-      
-      if(signal[j][time] > qmax) {
-       qmax = signal[j][time];
-       jmax=j;
-      }       
-    } 
-    
-    if(qmax > 0.) {
-      tracks[i]=jmax; 
-      jout[i]=jmax;
-    }
-    
-  } 
-  
-  for(i=0;i<3;i++){
-    if(tracks[i] < 0){
-      tracks[i]=0;
-    }
-    else {
-      tracks[i]=(Int_t) signal[tracks[i]][0]; // first element is a track number
-    }
-  }
-}
-
-//_____________________________________________________________________________
-void AliTPC::DigSignal(Int_t isec,Int_t irow,TObjArray *pointer)
-{
-  //
-  // Digitalise TPC signal
-  //
-  Int_t pad_c,n_of_pads;
-  Int_t pad_number;
-  
-  n_of_pads = (isec < 25) ? npads_low[irow] : npads_up[irow];
-  pad_c=(n_of_pads+1)/2; // this is the "central" pad for a row
-
-  Int_t track,idx;
-  Int_t entries;
-  TVector *pp;
-  TVector *ppp;
-  Float_t y,yy,z;
-  Float_t pad_signal = 0;
-  Float_t signal[MAXTPCTBK]; // Integrated signal over all tracks
-  Float_t signal_tr[100][MAXTPCTBK+1]; // contribution from less than 50 tracks
-  Int_t flag; // flag indicating a track contributing to a pad signal
-  
-  //
-
-  Int_t ntracks = pointer->GetEntriesFast();
-
-  if(ntracks == 0) return; // no signal on this row!
-  
-  //--------------------------------------------------------------
-  // For each electron calculate the pad number and the avalanche
-  //             This is only once per pad row
-  //--------------------------------------------------------------
-  
-  TVector **el = new TVector* [ntracks]; // each track is a new vector
-
-  TObjArray *arr = new TObjArray; // array of tracks for this row
-  
-  for(track=0;track<ntracks;track++) {
-    pp = (TVector*) pointer->At(track);
-    entries = pp->GetNrows();
-    el[track] = new TVector(entries-1);
-    TVector &v1 = *el[track];
-    TVector &v2 = *pp;
-    
-    for(idx=0;idx<entries-2;idx+=2)
-      {
-       y=v2(idx+1);
-       yy=TMath::Abs(y);
-       
-       Float_t range=((n_of_pads-1)/2 + 0.5)*pad_pitch_w;
-       //
-       // Pad number and pad range
-       //
-       if(yy < 0.5*pad_pitch_w){
-         pad_number=pad_c;
-       }
-       else if (yy < range){
-         pad_number=(Int_t) ((yy-0.5*pad_pitch_w)/pad_pitch_w +1.);
-         pad_number=(Int_t) (pad_number*TMath::Sign(1.,(double) y)+pad_c);
-       }  
-       else{
-         pad_number=0;
-       }
-       
-       v1(idx) = (Float_t) pad_number;
-       
-       // Avalanche, taking the fluctuations into account
-       
-       Int_t gain_fluct = (Int_t) (-gas_gain*TMath::Log(gRandom->Rndm()));
-       v1(idx+1)= (Float_t) gain_fluct;
-       
-      } // end of loop over electrons
-    
-    arr->Add(el[track]); // add the vector to the array
-    
-  }// end of loop over tracks
-  
-  delete [] el; //  delete an array of pointers
-  
-  //-------------------------------------------------------------
-  //  Calculation of signal for every pad 
-  //-------------------------------------------------------------
-
-  //-------------------------------------------------------------
-  // Loop over pads
-  //-------------------------------------------------------------
-
-
-  for(Int_t np=1;np<n_of_pads+1;np++)
-    {
-      for(Int_t l =0;l<MAXTPCTBK;l++) signal[l]=0.; // set signals for this pad to 0
-      
-      for(Int_t k1=0;k1<100;k1++){
-       for(Int_t k2=0;k2<MAXTPCTBK+1;k2++) signal_tr[k1][k2]=0.;
-      }
-      Int_t track_counter=0; 
-      //
-      
-      //---------------------------------------------------------
-      // Loop over tracks
-      // --------------------------------------------------------
-      
-      for(track=0;track<ntracks;track++)
-       {
-          flag = 0;
-          pp = (TVector*) pointer->At(track);
-          ppp = (TVector*) arr->At(track);
-         
-          TVector &v1 = *pp;
-          TVector &v2 = *ppp;
-          
-          entries = pp->GetNrows();
-         
-
-         //----------------------------------------------------
-         // Loop over electrons
-         //----------------------------------------------------
-         
-          for(idx=0;idx<entries-2;idx+=2)
-           {
-             
-             pad_number = (Int_t) v2(idx);
-             
-             if(pad_number == 0) continue; // skip electrons outside range
-             
-             Int_t pad_dist = pad_number-np;
-             Int_t abs_dist = TMath::Abs(pad_dist);
-             
-             if(abs_dist > 3) continue; // beyond signal range
-             
-             y=  v1(idx+1);
-             z = v1(idx+2);
-             
-             Float_t dist = y-(pad_number-pad_c)*pad_pitch_w;
-             
-             //----------------------------------------------
-             // Calculate the signal induced on a pad "np"
-             //----------------------------------------------
-             
-             if(pad_dist < 0) dist = -dist;
-             
-             switch((Int_t) abs_dist){
-             case 0 : pad_signal = P4(dist); // electron is on pad "np"
-                          break;
-             case 1 : pad_signal = P3(dist); // electron is 1 pad away
-               break;
-             case 2 : pad_signal = P2(dist); // electron is 2 pads away
-               break;
-             case 3 : pad_signal = P1(dist); // electron is 3 pads away
-             }
-             
-             //---------------------------------
-              //  Multiply by a gas gain
-             //---------------------------------
-             
-              pad_signal=pad_signal*v2(idx+1);
-             
-              flag = 1;
-             
-             
-             //-----------------------------------------------
-             //  Sample the pad signal in time
-             //-----------------------------------------------
-             
-             Float_t t_drift = (z_end-TMath::Abs(z))/v_drift; // drift time
-             
-             Float_t t_offset = t_drift-t_sample*(Int_t)(t_drift/t_sample);   
-             Int_t first_bucket = (Int_t) (t_drift/t_sample+1.); 
-             
-             for(Int_t bucket = 1;bucket<6;bucket++){
-               Float_t time = (bucket-1)*t_sample+t_offset;
-               Int_t time_idx = first_bucket+bucket-1;
-               Float_t ampl = pad_signal*TimeRes(time);
-               if (time_idx > MAXTPCTBK) break; //Y.Belikov
-               if (track_counter >=100) break;  //Y.Belikov
-
-               signal_tr[track_counter][time_idx] += ampl; // single track only
-               signal[time_idx-1] += ampl;  // fill a signal array for this pad
-               
-             } // end of time sampling
-             
-           } // end of loop over electrons for a current track
-         
-         //-----------------------------------------------
-         //  add the track number and update the counter
-         //  if it gave a nonzero contribution to the pad
-         //-----------------------------------------------
-         if(flag != 0 && track_counter < 100){
-          signal_tr[track_counter][0] = v1(0);
-          track_counter++;      // counter is looking at the NEXT track!
-         }
-         
-       } // end of loop over tracks
-      
-      //----------------------------------------------
-      //  Fill the Digits for this pad
-      //----------------------------------------------
-      
-      Int_t tracks[3];
-      Int_t digits[5];
-      
-      digits[0]=isec; // sector number
-      digits[1]=irow+1; // row number
-      digits[2]=np;   // pad number
-      
-      Float_t q;
-      
-      for(Int_t time = 0;time<MAXTPCTBK;time++){
-       digits[3] = time+1; // time bucket
-       
-       q = signal[time];
-       q = gRandom->Gaus(q,sigma_noise); // apply noise
-       
-       q *= (q_el*1.e15); // convert to fC
-       q *= chip_gain; // convert to mV   
-       q *= (adc_sat/dyn_range); // convert to ADC counts
-       
-       if(q < zero_sup) continue; // do not fill "zeros"
-       if(q > adc_sat) q = adc_sat;  // saturation
-       digits[4] = (Int_t) q;                   // ADC counts
-       
-       //--------------------------------------------------
-       //    "Real signal" or electronics noise
-       //--------------------------------------------------
-       
-       if(signal[time] > 0.){
-         
-         //-----------------------------------------------------
-         //  Create a list of tracks contributing to this digit
-         //  If the digit results from a noise, track number is 0
-         //-----------------------------------------------------
-         
-         CreateList(tracks,signal_tr,track_counter,time);
-       }
-       else {
-         for(Int_t ii=0;ii<3;ii++) tracks[ii]=0;
-       }
-       
-       AddDigit(tracks,digits);
-       
-       
-      } // end of digits for this pad
-      
-    } // end of loop over pads
-  
-  arr->Delete(); // delete objects in this array
-  
-  delete arr; // deletes the TObjArray itselves
-  
-}
-
 //_____________________________________________________________________________
 Int_t AliTPC::DistancetoPrimitive(Int_t , Int_t )
 {
@@ -514,12 +225,13 @@ Int_t AliTPC::DistancetoPrimitive(Int_t , Int_t )
 }
 
 //_____________________________________________________________________________
-const int MAX_CLUSTER=nrow_low+nrow_up; 
+//const int MAX_CLUSTER=nrow_low+nrow_up; 
+const int MAX_CLUSTER=200; 
 const int S_MAXSEC=24;
 const int L_MAXSEC=48;
 const int ROWS_TO_SKIP=21;
-const Float_t MAX_CHI2=15.;
-const Float_t THRESHOLD=8*zero_sup;
+const Float_t MAX_CHI2=12.;
+
 
 //_____________________________________________________________________________
 static Double_t SigmaY2(Double_t r, Double_t tgl, Double_t pt)
@@ -560,8 +272,9 @@ inline Double_t f1(Double_t x1,Double_t y1,   //C
                   (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
   Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
                   (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
+
   Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
-  
+
   return -xr*yr/sqrt(xr*xr+yr*yr); 
 }
 
@@ -579,6 +292,7 @@ inline Double_t f2(Double_t x1,Double_t y1,  //eta=C*x0
                   (y2-y1)*(y3*y3-y2*y2+x3*x3-x2*x2));
   Double_t b=0.5*((x2-x1)*(y3*y3-y2*y2+x3*x3-x2*x2)-
                   (x3-x2)*(y2*y2-y1*y1+x2*x2-x1*x1));
+
   Double_t xr=TMath::Abs(d/(d*x1-a)), yr=d/(d*y1-b);
   
   return -a/(d*y1-b)*xr/sqrt(xr*xr+yr*yr);
@@ -605,56 +319,58 @@ static int FindProlongation(AliTPCtrack& t, const AliTPCSector *sec,
   int try_again=ROWS_TO_SKIP;
   Double_t alpha=sec->GetAlpha();
   int ns=int(2*TMath::Pi()/alpha)+1;
+
   for (int nr=ri; nr>=rf; nr--) {
     Double_t x=sec[s].GetX(nr), ymax=sec[s].GetMaxY(nr);
-    if (!t.PropagateTo(x)) break;
-    
+    if (!t.PropagateTo(x)) return -1;
+
     const AliTPCcluster *cl=0;
     Double_t max_chi2=MAX_CHI2;
     const AliTPCRow& row=sec[s][nr];
     Double_t sy2=SigmaY2(t.GetX(),t.GetTgl(),t.GetPt());
     Double_t sz2=SigmaZ2(t.GetX(),t.GetTgl());
-    Double_t road=3.*sqrt(t.GetSigmaY2() + sy2), y=t.GetY(), z=t.GetZ();
-    
+    Double_t road=3.*sqrt(t.GetSigmaY2() + 4*sy2), y=t.GetY(), z=t.GetZ();
+
     if (road>30) {
       if (t>3) cerr<<t<<" AliTPCtrack warning: Too broad road !\n"; 
-      break;
+      return -1;
     }
-    
-    if (row) 
+
+    if (row) {
       for (int i=row.Find(y-road); i<row; i++) {
        AliTPCcluster* c=(AliTPCcluster*)(row[i]);
        if (c->fY > y+road) break;
        if (c->IsUsed()) continue;
-       if ((c->fZ - z)*(c->fZ - z) > 9.*(t.GetSigmaZ2() + sz2)) continue;
+       if ((c->fZ - z)*(c->fZ - z) > 9.*(t.GetSigmaZ2() + 4*sz2)) continue;
        Double_t chi2=t.GetPredictedChi2(c);
        if (chi2 > max_chi2) continue;
        max_chi2=chi2;
        cl=c;       
       }
+    }
     if (cl) {
       t.Update(cl,max_chi2);
       try_again=ROWS_TO_SKIP;
     } else {
-      if (try_again--) {
-       if (y > ymax) {
-         s = (s+1) % ns;
-         if (!t.Rotate(alpha)) break;
-       } else
-         if (y <-ymax) {
-           s = (s-1+ns) % ns;
-           if (!t.Rotate(-alpha)) break;
-         };
-       continue;
+      if (try_again==0) break;
+      if (y > ymax) {
+         s = (s+1) % ns;
+         if (!t.Rotate(alpha)) return -1;
+      } else if (y <-ymax) {
+           s = (s-1+ns) % ns;
+           if (!t.Rotate(-alpha)) return -1;
       }
-      break;
+      try_again--;
     }
   }
+
   return s;
 }
 
+
 //_____________________________________________________________________________
-static void MakeSeeds(TObjArray& seeds,const AliTPCSector* sec,int i1,int i2)
+static void MakeSeeds(TObjArray& seeds,const AliTPCSector* sec,int i1,int i2,
+const AliTPCParam *p)
 {
   //
   // Find seed for tracking
@@ -672,21 +388,21 @@ static void MakeSeeds(TObjArray& seeds,const AliTPCSector* sec,int i1,int i2)
       for (int js=0; js < nl+nm+nu; js++) {
        const AliTPCcluster *cl;
        Double_t cs,sn;
-       //int ks;
+       int ks;
        
        if (js<nl) {
-         //ks=(ns-1+max_sec)%max_sec;
+         ks=(ns-1+max_sec)%max_sec;
          const AliTPCRow& r2=sec[(ns-1+max_sec)%max_sec][i2];
          cl=r2[js];
          cs=cos(alpha); sn=sin(alpha);
        } else 
          if (js<nl+nm) {
-           //ks=ns;
+           ks=ns;
            const AliTPCRow& r2=sec[ns][i2];
            cl=r2[js-nl];
            cs=1; sn=0.;
          } else {
-           //ks=(ns+1)%max_sec;
+           ks=(ns+1)%max_sec;
            const AliTPCRow& r2=sec[(ns+1)%max_sec][i2];
            cl=r2[js-nl-nm];
            cs=cos(alpha); sn=-sin(alpha);
@@ -708,18 +424,11 @@ static void MakeSeeds(TObjArray& seeds,const AliTPCSector* sec,int i1,int i2)
        if (TMath::Abs(x(2)*x1-x(3)) >= 0.999) continue;
        
        if (TMath::Abs(x(4)) > 1.2) continue;
-       
+
        Double_t a=asin(x(3));
-       /*
-         Double_t tgl1=z1*x(2)/(a+asin(x(2)*x1-x(3)));
-         Double_t tgl2=z2*x(2)/(a+asin(x(2)*x2-x(3)));
-         Double_t ratio=2*(tgl1-tgl2)/(tgl1+tgl2);
-         if (TMath::Abs(ratio)>0.0170) continue; //or > 0.005
-       */
        Double_t zv=z1 - x(4)/x(2)*(a+asin(x(2)*x1-x(3)));
        if (TMath::Abs(zv)>33.) continue; 
-       
-       
+
        TMatrix X(6,6); X=0.; 
        X(0,0)=r1[is]->fSigmaY2; X(1,1)=r1[is]->fSigmaZ2;
        X(2,2)=cl->fSigmaY2;     X(3,3)=cl->fSigmaZ2;
@@ -741,12 +450,11 @@ static void MakeSeeds(TObjArray& seeds,const AliTPCSector* sec,int i1,int i2)
        
        TMatrix t(F,TMatrix::kMult,X);
        C.Mult(t,TMatrix(TMatrix::kTransposed,F));
-       
-       TrackSeed *track=new TrackSeed(*(r1[is]),x,C);
-       FindProlongation(*track,sec,ns,i1-1,i2);
-       int ii=(i1-i2)/2;
-       if (*track >= ii) {seeds.AddLast(track); continue;}
-       else delete track;
+
+       TrackSeed *track=new TrackSeed(*(r1[is]),x,C,p);
+       int rc=FindProlongation(*track,sec,ns,i1-1,i2);
+        if (rc<0 || *track<(i1-i2)/2) delete track;
+        else seeds.AddLast(track); 
       }
     }
   }
@@ -759,12 +467,22 @@ void AliTPC::Clusters2Tracks()
   // TPC Track finder from clusters.
   //
   if (!fClusters) return;
+
+  AliTPCParam *p=&fDigParam->GetParam();
+  Int_t nrow_low=p->GetNRowLow();
+  Int_t nrow_up=p->GetNRowUp();
+
   AliTPCSSector ssec[S_MAXSEC/2];
+  for (int i=0; i<S_MAXSEC/2; i++) ssec[i].SetUp(p);
+
   AliTPCLSector lsec[L_MAXSEC/2];
+  for (int j=0; j<L_MAXSEC/2; j++) lsec[j].SetUp(p);
+
   int ncl=fClusters->GetEntriesFast();
   while (ncl--) {
     AliTPCcluster *c=(AliTPCcluster*)fClusters->UncheckedAt(ncl);
-    int sec=int(c->fSector), row=int(c->fPadRow);
+
+    int sec=int(c->fSector)-1, row=int(c->fPadRow)-1;
     
     if (sec<24) {
       if (row<0 || row>nrow_low) {cerr<<"low !!!"<<row<<endl; continue;}
@@ -778,9 +496,9 @@ void AliTPC::Clusters2Tracks()
   
   
   TObjArray seeds(20000);
-  MakeSeeds(seeds,lsec,nrow_up-1,nrow_up-1-8);
-  MakeSeeds(seeds,lsec,nrow_up-1-4,nrow_up-1-4-8);
-  
+  MakeSeeds(seeds,lsec,nrow_up-1,nrow_up-1-8,p);
+  MakeSeeds(seeds,lsec,nrow_up-1-4,nrow_up-1-4-8,p);
+    
   seeds.Sort();
   
   int found=0;
@@ -795,14 +513,12 @@ void AliTPC::Clusters2Tracks()
     
     Double_t x=t.GetX();
     int nr;
-    if (x<pad_row_up[nrow_up-1-4-7]) nr=nrow_up-1-4-8;
-    else if (x<pad_row_up[nrow_up-1-7]) nr=nrow_up-1-8;
+    if (x<p->GetPadRowRadiiUp(nrow_up-1-4-7)) nr=nrow_up-1-4-8;
+    else if (x<p->GetPadRowRadiiUp(nrow_up-1-7)) nr=nrow_up-1-8;
     else {cerr<<x<<" =x !!!\n"; continue;}
-    
+
     int ls=FindProlongation(t,lsec,ns,nr-1);
-    
-    //   if (t < 25) continue;
-    
+    if (ls<0) continue;
     x=t.GetX(); alpha=lsec[ls].GetAlpha();          //
     Double_t phi=ls*alpha + atan(t.GetY()/x);       // Find S-sector
     int ss=int(0.5*(phi/alpha+1));                  //
@@ -810,7 +526,7 @@ void AliTPC::Clusters2Tracks()
     if (!t.Rotate(alpha)) continue;                 //
     ss %= (S_MAXSEC/2);                             //
     
-    ss=FindProlongation(t,ssec,ss,nrow_low-1);
+    if (FindProlongation(t,ssec,ss,nrow_low-1)<0) continue;
     if (t < 30) continue;
     
     AddTrack(t);
@@ -822,10 +538,13 @@ void AliTPC::Clusters2Tracks()
 //_____________________________________________________________________________
 void AliTPC::CreateMaterials()
 {
-  //
+  //-----------------------------------------------
   // Create Materials for for TPC
-  // Origin M.Kowalski
-  //
+  //-----------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
   
   AliMC* pMC = AliMC::GetMC();
 
@@ -847,7 +566,8 @@ void AliTPC::CreateMaterials()
   Float_t ag[2] = { 20.18 };
   Float_t zg[2] = { 10. };
   Float_t wg[2] = { .8,.2 };
-  Float_t dne   = 9e-4;        // --- Neon density in g/cm3 ---     
+  Float_t dne   = 9e-4;        // --- Neon density in g/cm3 ---
+  
   // --- Mylar (C5H4O2) --- 
   Float_t amy[3] = { 12.,1.,16. };
   Float_t zmy[3] = { 6.,1.,8. };
@@ -884,12 +604,9 @@ void AliTPC::CreateMaterials()
   
   char namate[21];
   pMC->Gfmate((*fIdmate)[7], namate, a, z, d, radl, absl, buf, nbuf);
-
   ag[1] = a;
   zg[1] = z;
   dg = dne * .9 + dc * .1;
-
-  //-------------------------------------
   
   // --  Create Ne/CO2 90/10 mixture 
   
@@ -930,8 +647,10 @@ struct PreCluster : public AliTPCcluster {
    int idx;
    int cut;
    int npeaks;
-   PreCluster() : AliTPCcluster() {cut=npeaks=0;}
+   PreCluster();
 };
+PreCluster::PreCluster() : AliTPCcluster() {cut=npeaks=0;}
+
 
 //_____________________________________________________________________________
 static void FindCluster(int i, int j, Bin bins[][MAXTPCTBK+2], PreCluster &c) 
@@ -940,8 +659,8 @@ static void FindCluster(int i, int j, Bin bins[][MAXTPCTBK+2], PreCluster &c)
   // Find clusters
   //
   Bin& b=bins[i][j];
-  int q=b.dig->fSignal;
-  
+  double q=double(b.dig->fSignal);
+
   if (q<0) { // digit is at the edge of the pad row
     q=-q;
     c.cut=1;
@@ -958,7 +677,7 @@ static void FindCluster(int i, int j, Bin bins[][MAXTPCTBK+2], PreCluster &c)
   c.fSigmaY2 += i*i*q;
   c.fSigmaZ2 += j*j*q;
   c.fQ += q;
-  
+
   b.dig = 0;  b.idx = c.idx;
   
   if (bins[i-1][j].dig) FindCluster(i-1,j,bins,c);
@@ -974,11 +693,15 @@ void AliTPC::Digits2Clusters()
   //
   // simple TPC cluster finder from digits.
   //
+  //
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
+  
   const Int_t MAX_PAD=200+2, MAX_BUCKET=MAXTPCTBK+2;
-  const Int_t Q_min=200;//75;
+  const Int_t Q_min=60;
+  const Int_t THRESHOLD=20;
   
-  TTree *t=gAlice->TreeD();
-  t->GetBranch("TPC")->SetAddress(&fDigits);
+  TTree *t=(TTree*)gDirectory->Get("TreeD0_Param1");
+  t->GetBranch("Digits")->SetAddress(&fDigits);
   Int_t sectors_by_rows=(Int_t)t->GetEntries();
   
   int ncls=0;
@@ -993,10 +716,10 @@ void AliTPC::Digits2Clusters()
     int npads;  int sign_z;
     if (nsec<25) {
       sign_z=(nsec<13) ? 1 : -1;
-      npads=npads_low[nrow-1];
+      npads=fTPCParam->GetNPadsLow(nrow-1);
     } else {
       sign_z=(nsec<49) ? 1 : -1;
-      npads=npads_up[nrow-1];
+      npads=fTPCParam->GetNPadsUp(nrow-1);
     }
     
     int ndig;
@@ -1009,30 +732,37 @@ void AliTPC::Digits2Clusters()
     
     int ncl=0;
     int i,j;
+    
     for (i=1; i<MAX_PAD-1; i++) {
       for (j=1; j<MAX_BUCKET-1; j++) {
        if (bins[i][j].dig == 0) continue;
        PreCluster c; c.summit=bins[i][j].dig; c.idx=ncls;
        FindCluster(i, j, bins, c);
-       //if (c.fQ <= Q_min) continue; //noise cluster
        c.fY /= c.fQ;
        c.fZ /= c.fQ;
-       c.fSigmaY2 = c.fSigmaY2/c.fQ - c.fY*c.fY + 1./12.;
-       c.fSigmaZ2 = c.fSigmaZ2/c.fQ - c.fZ*c.fZ + 1./12.;
-       c.fSigmaY2 *= pad_pitch_w*pad_pitch_w;
-       c.fSigmaZ2 *= z_end/MAXTPCTBK*z_end/MAXTPCTBK;
-       c.fSigmaY2 *= 0.022*8;
-       c.fSigmaZ2 *= 0.068*4;
-       c.fY = (c.fY - 0.5 - 0.5*npads)*pad_pitch_w;
-       c.fZ = z_end/MAXTPCTBK*c.fZ; 
-       c.fZ -= 3.*fwhm/2.35482*v_drift; // PASA delay 
+
+        double s2 = c.fSigmaY2/c.fQ - c.fY*c.fY;
+        c.fSigmaY2 = s2 + 1./12.;
+        c.fSigmaY2 *= fTPCParam->GetPadPitchWidth()*
+                      fTPCParam->GetPadPitchWidth();
+        if (s2 != 0.) c.fSigmaY2 *= 0.022*8*4;
+
+        s2 = c.fSigmaZ2/c.fQ - c.fZ*c.fZ;
+        c.fSigmaZ2 = s2 + 1./12.;
+        c.fSigmaZ2 *= fTPCParam->GetZWidth()*fTPCParam->GetZWidth();
+        if (s2 != 0.) c.fSigmaZ2 *= 0.068*4*4;
+
+       c.fY = (c.fY - 0.5 - 0.5*npads)*fTPCParam->GetPadPitchWidth();
+       c.fZ = fTPCParam->GetZWidth()*(c.fZ+1); 
+       c.fZ -= 3.*fTPCParam->GetZSigma(); // PASA delay 
        c.fZ = sign_z*(z_end - c.fZ);
-       c.fSector=nsec-1;
-       c.fPadRow=nrow-1;
+       //c.fZ += 0.023;
+       c.fSector=nsec;
+       c.fPadRow=nrow;
        c.fTracks[0]=c.summit->fTracks[0];
        c.fTracks[1]=c.summit->fTracks[1];
        c.fTracks[2]=c.summit->fTracks[2];
-       
+
        if (c.cut) {
          c.fSigmaY2 *= 25.;
          c.fSigmaZ2 *= 4.;
@@ -1044,7 +774,7 @@ void AliTPC::Digits2Clusters()
     
     for (ndig=0; ndig<ndigits; ndig++) {
       dig=(AliTPCdigit*)fDigits->UncheckedAt(ndig);
-      if (TMath::Abs(dig->fSignal) >= THRESHOLD/3
+      if (TMath::Abs(dig->fSignal) >= 0
        bins[dig->fPad][dig->fTime].dig=dig;
     }
     
@@ -1054,21 +784,28 @@ void AliTPC::Digits2Clusters()
        PreCluster c; c.summit=bins[i][j].dig; c.idx=ncls;
        FindCluster(i, j, bins, c);
        if (c.fQ <= Q_min) continue; //noise cluster
-       if (c.npeaks>1) continue;    //overlapped cluster
+        if (c.npeaks>1) continue;    //overlapped cluster
        c.fY /= c.fQ;
        c.fZ /= c.fQ;
-       c.fSigmaY2 = c.fSigmaY2/c.fQ - c.fY*c.fY + 1./12.;
-       c.fSigmaZ2 = c.fSigmaZ2/c.fQ - c.fZ*c.fZ + 1./12.;
-       c.fSigmaY2 *= pad_pitch_w*pad_pitch_w;
-       c.fSigmaZ2 *= z_end/MAXTPCTBK*z_end/MAXTPCTBK;
-       c.fSigmaY2 *= 0.022*4;
-       c.fSigmaZ2 *= 0.068*4;
-       c.fY = (c.fY - 0.5 - 0.5*npads)*pad_pitch_w;
-       c.fZ = z_end/MAXTPCTBK*c.fZ; 
-       c.fZ -= 3.*fwhm/2.35482*v_drift; // PASA delay 
+
+        double s2 = c.fSigmaY2/c.fQ - c.fY*c.fY;
+        c.fSigmaY2 = s2 + 1./12.;
+        c.fSigmaY2 *= fTPCParam->GetPadPitchWidth()*
+                      fTPCParam->GetPadPitchWidth();
+        if (s2 != 0.) c.fSigmaY2 *= 0.022*4*0.6*4;
+
+        s2 = c.fSigmaZ2/c.fQ - c.fZ*c.fZ;
+        c.fSigmaZ2 = s2 + 1./12.;
+        c.fSigmaZ2 *= fTPCParam->GetZWidth()*fTPCParam->GetZWidth();
+        if (s2 != 0.) c.fSigmaZ2 *= 0.068*4*0.4;
+
+       c.fY = (c.fY - 0.5 - 0.5*npads)*fTPCParam->GetPadPitchWidth();
+       c.fZ = fTPCParam->GetZWidth()*(c.fZ+1); 
+       c.fZ -= 3.*fTPCParam->GetZSigma(); // PASA delay 
        c.fZ = sign_z*(z_end - c.fZ);
-       c.fSector=nsec-1;
-       c.fPadRow=nrow-1;
+       //c.fZ += 0.023;
+       c.fSector=nsec;
+       c.fPadRow=nrow;
        c.fTracks[0]=c.summit->fTracks[0];
        c.fTracks[1]=c.summit->fTracks[1];
        c.fTracks[2]=c.summit->fTracks[2];
@@ -1096,38 +833,56 @@ void AliTPC::Digits2Clusters()
 //_____________________________________________________________________________
 void AliTPC::ElDiff(Float_t *xyz)
 {
-  //
+  //--------------------------------------------------
   // calculates the diffusion of a single electron
-  //
-  
+  //--------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
   Float_t driftl;
-  //
+  
   Float_t z0=xyz[2];
+
   driftl=z_end-TMath::Abs(xyz[2]);
+
   if(driftl<0.01) driftl=0.01;
+
+  // check the attachment
+
   driftl=TMath::Sqrt(driftl);
-  Float_t sig_t = driftl*diff_t;
-  Float_t sig_l = driftl*diff_l;
-  //
+
+  //  Float_t sig_t = driftl*diff_t;
+  //Float_t sig_l = driftl*diff_l;
+  Float_t sig_t = driftl*fTPCParam->GetDiffT();
+  Float_t sig_l = driftl*fTPCParam->GetDiffL();
   xyz[0]=gRandom->Gaus(xyz[0],sig_t);
   xyz[1]=gRandom->Gaus(xyz[1],sig_t);
   xyz[2]=gRandom->Gaus(xyz[2],sig_l);
-  //
+  
   if (TMath::Abs(xyz[2])>z_end){
-    xyz[2]=z_end*TMath::Sign(1.,(double) z0);
+    xyz[2]=TMath::Sign(z_end,z0);
   }
   if(xyz[2]*z0 < 0.){
-    xyz[2]=0.0001*TMath::Sign(1.,(double) z0);
+    Float_t eps = 0.0001;
+    xyz[2]=TMath::Sign(eps,z0);
   } 
 }
 
 //_____________________________________________________________________________
 void AliTPC::Hits2Clusters()
 {
-  //
+  //--------------------------------------------------------
   // TPC simple cluster generator from hits
   // obtained from the TPC Fast Simulator
-  //
+  // The point errors are taken from the parametrization
+  //--------------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
   Float_t sigma_rphi,sigma_z,cl_rphi,cl_z;
   //
   GParticle *particle; // pointer to a given particle
@@ -1137,7 +892,6 @@ void AliTPC::Hits2Clusters()
   Int_t ipart;
   Float_t xyz[5];
   Float_t pl,pt,tanth,rpad,ratio;
-  Float_t rot_angle;
   Float_t cph,sph;
   
   //---------------------------------------------------------------
@@ -1160,16 +914,8 @@ void AliTPC::Hits2Clusters()
   
   //
   for(Int_t isec=1;isec<fNsectors+1;isec++){
-    //
-    if(isec < 25){
-      rot_angle = (isec < 13) ? (isec-1)*alpha_low : (isec-13)*alpha_low;
-    }
-    else {
-      rot_angle = (isec < 49) ? (isec-25)*alpha_up : (isec-49)*alpha_up;
-    }
-    
-    cph=TMath::Cos(rot_angle);
-    sph=TMath::Sin(rot_angle);
+    //MI change
+    fTPCParam->AdjustAngles(isec,cph,sph);
     
     //------------------------------------------------------------
     // Loop over tracks
@@ -1227,21 +973,19 @@ void AliTPC::Hits2Clusters()
        Float_t xprim= tpcHit->fX*cph + tpcHit->fY*sph;
        Float_t yprim=-tpcHit->fX*sph + tpcHit->fY*cph;
        xyz[0]=gRandom->Gaus(yprim,TMath::Sqrt(sigma_rphi));   // y
+        Double_t alpha=(sector<25) ? alpha_low : alpha_up;
+       if (TMath::Abs(xyz[0]/xprim) > TMath::Tan(0.5*alpha)) xyz[0]=yprim;
        xyz[1]=gRandom->Gaus(tpcHit->fZ,TMath::Sqrt(sigma_z)); // z 
+        if (TMath::Abs(xyz[1]) > 250) xyz[1]=tpcHit->fZ;
        xyz[2]=tpcHit->fQ;                                     // q
        xyz[3]=sigma_rphi;                                     // fSigmaY2
        xyz[4]=sigma_z;                                        // fSigmaZ2
        
        //find row number
-       int row;
-       if (xprim > 0.5*(pad_row_up[0]+pad_row_low[nrow_low-1])) {
-          for (row=0; row<nrow_up; row++) if (xprim < pad_row_up[row]) break;
-       } else {
-          for (row=0; row<nrow_low; row++) if (xprim < pad_row_low[row]) break;
-       }
-       
+       //MI we must change
+       Int_t row = fTPCParam->GetPadRow(sector,xprim) ;        
        // and finally add the cluster
-       Int_t tracks[5]={tpcHit->fTrack+1, 0, 0, sector-1, row-1};
+       Int_t tracks[5]={tpcHit->fTrack, -1, -1, sector, row+1};
        AddCluster(xyz,tracks);
        
       } // end of loop over hits
@@ -1255,206 +999,967 @@ void AliTPC::Hits2Clusters()
   
 }
 
+
+void AliTPC::Hits2Digits()  
+{ 
+
+ //----------------------------------------------------
+  // Loop over all sectors (72 sectors)
+  // Sectors 1-24 are lower sectors, 1-12 z>0, 13-24 z<0
+  // Sectors 25-72 are upper sectors, 25-48 z>0, 49-72 z<0
+  //----
+  for(Int_t isec=1;isec<fNsectors+1;isec++)  Hits2DigitsSector(isec);
+}
+
+
 //_____________________________________________________________________________
-void AliTPC::Hits2Digits()
+void AliTPC::Hits2DigitsSector(Int_t isec)
 {
-  //
+  //-------------------------------------------------------------------
   // TPC conversion from hits to digits.
-  //
-  
-  Int_t i;
-  //
-  AliTPChit *tpcHit; // pointer to a sigle TPC hit
-  //
-  Float_t xyz[3];
-  Float_t rot_angle;
+  //------------------------------------------------------------------- 
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
   //-------------------------------------------------------
-  //  Get the access to the track
+  //  Get the access to the track hits
   //-------------------------------------------------------
-  TTree *TH = gAlice->TreeH();
+
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
+  TTree *TH = gAlice->TreeH(); // pointer to the hits tree
   Stat_t ntracks = TH->GetEntries();
-  
-  //----------------------------------------------------
-  // Loop over all sectors (72 sectors)
-  // Sectors 1-24 are lower sectors, 1-12 z>0, 13-24 z<0
-  // Sectors 25-72 are upper sectors, 25-48 z>0, 49-72 z<0
-  //----------------------------------------------------
-  
-  for(Int_t isec=1;isec<fNsectors+1;isec++){ 
+
+  if( ntracks > 0){
+
+  //------------------------------------------- 
+  //  Only if there are any tracks...
+  //-------------------------------------------
+
     
-    //
-    printf("*** Processing sector number %d ***\n",isec);
+    // TObjArrays for three neighouring pad-rows
+
+    TObjArray **rowTriplet = new TObjArray* [3]; 
     
-    if(isec < 25){
-      rot_angle = (isec < 13) ? (isec-1)*alpha_low : (isec-13)*alpha_low;
-    }
-    else {
-      rot_angle = (isec < 49) ? (isec-25)*alpha_up : (isec-49)*alpha_up;
+    // TObjArray-s for each pad-row
+
+    TObjArray **row;
+      
+    for (Int_t trip=0;trip<3;trip++){  
+      rowTriplet[trip]=new TObjArray;
     }
+
+
     
-    Int_t nrows = (isec<25) ? 23 : 52;
-    
-    
-    Float_t cph=TMath::Cos(rot_angle);
-    Float_t sph=TMath::Sin(rot_angle);
-    
-    
-    
-    //----------------------------------------------
-    // Create TObjArray-s, one for each row
-    //---------------------------------------------- 
-    
-    TObjArray **row = new TObjArray* [nrows];
-    for(i=0; i<nrows; i++){
-      row[i] = new TObjArray;
-    }
+      printf("*** Processing sector number %d ***\n",isec);
+
+      Int_t nrows =fTPCParam->GetNRow(isec);
+
+      row= new TObjArray* [nrows];
     
-    //----------------------------------------------
-    // Loop over tracks
-    //----------------------------------------------
-    for(Int_t track=0;track<ntracks;track++){  
-      ResetHits();
-      TH->GetEvent(track); 
-      
-      //------------------------------------------------
-      //  Get number of the TPC hits and a pointer
-      //  to the particles
-      //------------------------------------------------
-      Int_t nhits=fHits->GetEntriesFast();
-      if(nhits == 0) continue; 
-      //-----------------------------------------------
-      //  Create vectors for storing the track information,
-      //  one vector per track per row,
-      //  first element is a track number and then
-      //  there are (y,z) pairs * number of electrons
-      //----------------------------------------------
-      
-      TVector **tr = new TVector* [nrows];
-      Int_t *n_of_electrons= new int [nrows]; // electron counter 
-      for(i=0;i<nrows;i++){
-       tr[i] = new TVector(241); // 120 electrons initialy
-       n_of_electrons[i]=0;
-      } 
-      //-----------------------------------------------------
-      // Loop over hits
-      //------------------------------------------------------
-      for(Int_t hit=0;hit<nhits;hit++){
-       tpcHit=(AliTPChit*)fHits->UncheckedAt(hit);
-       Int_t sector=tpcHit->fSector; // sector number
-       if(sector != isec) continue; //terminate iteration
-       
-       xyz[0]=tpcHit->fX;
-       xyz[1]=tpcHit->fY;
-       xyz[2]=tpcHit->fZ;
-       Int_t QI = (Int_t) (tpcHit->fQ); // energy loss (number of electrons)
-       
-       //-----------------------------------------------
-       //  Rotate the electron cluster to sector 1,13,25,49
-       //-----------------------------------------------
-       Float_t xprim=xyz[0]*cph+xyz[1]*sph;
-       Float_t yprim=-xyz[0]*sph+xyz[1]*cph;
-       Float_t zprim=xyz[2]; 
-       
-       //-------------------------------------
-       // Loop over electrons
-       //-------------------------------------
-       for(Int_t nel=0;nel<QI;nel++){
-         xyz[0]=xprim;  //
-         xyz[1]=yprim;  // Keep the initial cluster position!
-         xyz[2]=zprim;  //
-         
-         ElDiff(xyz); // Appply the diffusion
-         
-         Float_t row_first; 
-         Int_t row_number;
-         row_first = (isec<25) ? pad_row_low[0] : pad_row_up[0];
-         
-         row_number=(Int_t) ((xyz[0]-row_first+0.5*pad_pitch_l)/pad_pitch_l);
-         
-         // Check if out of range
-         
-          if((xyz[0]-row_first+0.5*pad_pitch_l) < 0 
-            || row_number > (nrows-1)) continue;
-          
-         n_of_electrons[row_number]++;
-         
-         //
-         // Expand vector if necessary
-         //
+      MakeSector(isec,nrows,TH,ntracks,row);
+
+      //--------------------------------------------------------
+      //   Digitize this sector, row by row
+      //   row[i] is the pointer to the TObjArray of TVectors,
+      //   each one containing electrons accepted on this
+      //   row, assigned into tracks
+      //--------------------------------------------------------
+
+      Int_t i;
+
+      for (i=0;i<nrows;i++){
+
+       // Triplets for i = 0 and i=1 are identical!
+       // The same for i = nrows-1 and nrows!
+
+        if(i != 1 && i != nrows-1){
+          MakeTriplet(i,rowTriplet,row);
+        }
+
+           DigitizeRow(i,isec,rowTriplet);
+
+           fDigParam->Fill();
+
+            Int_t ndig=fDigParam->GetArray()->GetEntriesFast();
+
+            printf("*** Sector, row, digits %d %d %d ***\n",isec,i,ndig);
+
+           ResetDigits(); // reset digits for this row after storing them
+             
+       } // end of the sector digitization
+     
+       // delete the last triplet
+
+       for (i=0;i<3;i++) rowTriplet[i]->Delete();
+          
+       delete [] row; // delete the array of pointers to TObjArray-s
+        
+  } // ntracks >0
+} // end of Hits2Digits
+//_____________________________________________________________________________
+void AliTPC::MakeTriplet(Int_t row,
+                         TObjArray **rowTriplet, TObjArray **prow)
+{
+  //------------------------------------------------------------------
+  //  Makes the "triplet" of the neighbouring pad-row for the
+  //  digitization including the cross-talk between the pad-rows
+  //------------------------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
+  Float_t gasgain = fTPCParam->GetGasGain();
+  Int_t nTracks[3];
+
+  Int_t nElements,nElectrons;
+
+  TVector *pv;
+  TVector *tv;
+
+  //-------------------------------------------------------------------
+  // pv is an "old" track, i.e. label + triplets of (x,y,z) 
+  // for each electron
+  //
+  //-------------------------------------------------------------------
+
+
+  Int_t i1,i2;
+  Int_t nel,nt;
+
+  if(row == 0 || row == 1){
+
+  // create entire triplet for the first AND the second row
+
+    nTracks[0] = prow[0]->GetEntries();
+    nTracks[1] = prow[1]->GetEntries();
+    nTracks[2] = prow[2]->GetEntries();
+
+    for(i1=0;i1<3;i1++){
+      nt = nTracks[i1]; // number of tracks for this row
+
+      for(i2=0;i2<nt;i2++){
+        pv = (TVector*)prow[i1]->At(i2);
+        TVector &v1 = *pv;
+        nElements = pv->GetNrows(); 
+        nElectrons = (nElements-1)/3;
+
+        tv = new TVector(4*nElectrons+1); // create TVector for a modified track
+        TVector &v2 = *tv;
+        v2(0)=v1(0); //track label
+
+        for(nel=0;nel<nElectrons;nel++){        
+          Int_t idx1 = nel*3;
+          Int_t idx2 = nel*4;
+                 // Avalanche, including fluctuations
+          Int_t aval = (Int_t) (-gasgain*TMath::Log(gRandom->Rndm()));
+          v2(idx2+1)= v1(idx1+1);
+          v2(idx2+2)= v1(idx1+2);
+          v2(idx2+3)= v1(idx1+3);
+          v2(idx2+4)= (Float_t)aval; // in number of electrons!        
+       } // end of loop over electrons
+       //
+       //  Add this track to a row 
+       //
+
+        rowTriplet[i1]->Add(tv); 
+
+
+      } // end of loop over tracks for this row
+
+      prow[i1]->Delete(); // remove "old" tracks
+      delete prow[i1]; // delete  TObjArray for this row
+      prow[i1]=0; // set pointer to NULL
+
+    } // end of loop over row triplets
+
+
+  }
+  else{
+   
+    rowTriplet[0]->Delete(); // remove old lower row
+
+    nTracks[0]=rowTriplet[1]->GetEntries(); // previous middle row
+    nTracks[1]=rowTriplet[2]->GetEntries(); // previous upper row
+    nTracks[2]=prow[row+1]->GetEntries(); // next row
+    
+
+    //------------------------------------------- 
+    //  shift new tracks downwards
+    //-------------------------------------------
+
+    for(i1=0;i1<nTracks[0];i1++){
+      pv=(TVector*)rowTriplet[1]->At(i1);
+      rowTriplet[0]->Add(pv); 
+    }       
+
+    rowTriplet[1]->Clear(); // leave tracks on the heap!!!
+
+    for(i1=0;i1<nTracks[1];i1++){
+      pv=(TVector*)rowTriplet[2]->At(i1);
+      rowTriplet[1]->Add(pv);
+    }
+
+    rowTriplet[2]->Clear(); // leave tracks on the heap!!!
+
+    //---------------------------------------------
+    //  Create new upper row
+    //---------------------------------------------
+
+    
+
+    for(i1=0;i1<nTracks[2];i1++){
+        pv = (TVector*)prow[row+1]->At(i1);
+        TVector &v1 = *pv;
+        nElements = pv->GetNrows();
+        nElectrons = (nElements-1)/3;
+
+        tv = new TVector(4*nElectrons+1); // create TVector for a modified track
+        TVector &v2 = *tv;
+        v2(0)=v1(0); //track label
+
+        for(nel=0;nel<nElectrons;nel++){
+        
+          Int_t idx1 = nel*3;
+          Int_t idx2 = nel*4;
+         // Avalanche, including fluctuations
+          Int_t aval = (Int_t) 
+           (-gasgain*TMath::Log(gRandom->Rndm()));
+          
+          v2(idx2+1)= v1(idx1+1); 
+          v2(idx2+2)= v1(idx1+2);
+          v2(idx2+3)= v1(idx1+3);
+          v2(idx2+4)= (Float_t)aval; // in number of electrons!        
+       } // end of loop over electrons
+
+          rowTriplet[2]->Add(tv);
+     
+    } // end of loop over tracks
+         
+    prow[row+1]->Delete(); // delete tracks for this row
+    delete prow[row+1];  // delete TObjArray for this row
+    prow[row+1]=0; // set a pointer to NULL
+
+  }
+
+}  // end of MakeTriplet
+//_____________________________________________________________________________
+void AliTPC::ExB(Float_t *xyz)
+{
+  //------------------------------------------------
+  //  ExB at the wires and wire number calulation
+  //------------------------------------------------
+  
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+   AliTPCParam * fTPCParam = &(fDigParam->GetParam());
+
+   Float_t x1=xyz[0];
+   fTPCParam->GetWire(x1);        //calculate nearest wire position
+   Float_t dx=xyz[0]-x1;
+   xyz[1]+=dx*fTPCParam->GetOmegaTau();
+
+} // end of ExB
+//_____________________________________________________________________________
+void AliTPC::DigitizeRow(Int_t irow,Int_t isec,TObjArray **rowTriplet)
+{
+  //-----------------------------------------------------------
+  // Single row digitization, coupling from the neighbouring
+  // rows taken into account
+  //-----------------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
+  Float_t chipgain= fTPCParam->GetChipGain();
+  Float_t zerosup = fTPCParam->GetZeroSup();
+  Int_t nrows =fTPCParam->GetNRow(isec);
+  
+  Int_t nTracks[3];
+  Int_t n_of_pads[3];
+  Int_t IndexRange[4];
+  Int_t i1;
+  Int_t iFlag; 
+
+  //
+  // iFlag = 0 -> inner row, iFlag = 1 -> the middle one, iFlag = 2 -> the outer one
+  //
+
+  nTracks[0]=rowTriplet[0]->GetEntries(); // lower row
+  nTracks[1]=rowTriplet[1]->GetEntries(); // middle row
+  nTracks[2]=rowTriplet[2]->GetEntries(); // upper row
+
+    
+  if(irow == 0){
+    iFlag=0;
+    n_of_pads[0]=fTPCParam->GetNPads(isec,0);
+    n_of_pads[1]=fTPCParam->GetNPads(isec,1);
+  }
+  else if(irow == nrows-1){
+     iFlag=2;
+     n_of_pads[1]=fTPCParam->GetNPads(isec,irow-1);
+     n_of_pads[2]=fTPCParam->GetNPads(isec,irow);
+  }
+  else {
+    iFlag=1;
+    for(i1=0;i1<3;i1++){
+       n_of_pads[i1]=fTPCParam->GetNPads(isec,irow-1+i1);
+    }
+  }
+  //
+  //  Integrated signal for this row
+  //  and a single track signal
+  // 
+   
+  TMatrix *m1   = new TMatrix(1,n_of_pads[iFlag],1,MAXTPCTBK); // integrated
+  TMatrix *m2   = new TMatrix(1,n_of_pads[iFlag],1,MAXTPCTBK); // single
+
+  //
+
+  TMatrix &Total  = *m1;
+
+  //  Array of pointers to the label-signal list
+
+  Int_t NofDigits = n_of_pads[iFlag]*MAXTPCTBK; // number of digits for this row
+
+  Float_t  **pList = new Float_t* [NofDigits]; 
+
+  Int_t lp;
+
+  for(lp=0;lp<NofDigits;lp++)pList[lp]=0; // set all pointers to NULL
+
+  //
+  //  Straight signal and cross-talk, cross-talk is integrated over all
+  //  tracks and added to the signal at the very end
+  //
+   
+
+  for (i1=0;i1<nTracks[iFlag];i1++){
+
+    m2->Zero(); // clear single track signal matrix
+  
+    Float_t TrackLabel = 
+      GetSignal(rowTriplet[iFlag],i1,n_of_pads[iFlag],m2,m1,IndexRange); 
+
+    GetList(TrackLabel,n_of_pads[iFlag],m2,IndexRange,pList);
+
+  }
+
+  // 
+  //  Cross talk from the neighbouring pad-rows
+  //
+
+  TMatrix *m3 =  new TMatrix(1,n_of_pads[iFlag],1,MAXTPCTBK); // cross-talk
+
+  TMatrix &Cross = *m3;
+
+  if(iFlag == 0){
+
+    // cross-talk from the outer row only (first pad row)
+
+    GetCrossTalk(0,rowTriplet[1],nTracks[1],n_of_pads,m3);
+
+  }
+  else if(iFlag == 2){
+
+    // cross-talk from the inner row only (last pad row)
+
+    GetCrossTalk(2,rowTriplet[1],nTracks[1],n_of_pads,m3);
+
+  }
+  else{
+
+    // cross-talk from both inner and outer rows
+
+    GetCrossTalk(3,rowTriplet[0],nTracks[0],n_of_pads,m3); // inner
+    GetCrossTalk(4,rowTriplet[2],nTracks[2],n_of_pads,m3); //outer
+  }
+
+  Total += Cross; // add the cross-talk
+
+  //
+  //  Convert analog signal to ADC counts
+  //
+   
+  Int_t tracks[3];
+  Int_t digits[5];
+
+
+  for(Int_t ip=1;ip<n_of_pads[iFlag]+1;ip++){
+    for(Int_t it=1;it<MAXTPCTBK+1;it++){
+
+      Float_t q = Total(ip,it);
+
+      Int_t gi =(it-1)*n_of_pads[iFlag]+ip-1; // global index
+
+      q = gRandom->Gaus(q,fTPCParam->GetNoise()); // apply noise
+      q *= (q_el*1.e15); // convert to fC
+      q *= chipgain; // convert to mV   
+      q *= (adc_sat/dyn_range); // convert to ADC counts  
+
+      if(q <zerosup) continue; // do not fill zeros
+      if(q > adc_sat) q = adc_sat;  // saturation
+
+      //
+      //  "real" signal or electronic noise (list = -1)?
+      //    
+
+      for(Int_t j1=0;j1<3;j1++){
+        tracks[j1] = (pList[gi]) ?(Int_t)(*(pList[gi]+j1)) : -1;
+      }
+
+      digits[0]=isec;
+      digits[1]=irow+1;
+      digits[2]=ip;
+      digits[3]=it;
+      digits[4]= (Int_t)q;
+
+      //  Add this digit
+
+      AddDigit(tracks,digits);
+    
+    } // end of loop over time buckets
+  }  // end of lop over pads 
+
+  //
+  //  This row has been digitized, delete nonused stuff
+  //
+
+  for(lp=0;lp<NofDigits;lp++){
+    if(pList[lp]) delete [] pList[lp];
+  }
+  
+  delete [] pList;
+
+  delete m1;
+  delete m2;
+  delete m3;
+
+} // end of DigitizeRow
+//_____________________________________________________________________________
+Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr, Int_t np, TMatrix *m1, TMatrix *m2,
+                          Int_t *IndexRange)
+{
+
+  //---------------------------------------------------------------
+  //  Calculates 2-D signal (pad,time) for a single track,
+  //  returns a pointer to the signal matrix and the track label 
+  //  No digitization is performed at this level!!!
+  //---------------------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
+  TVector *tv;
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
+  AliTPCPRF2D * fPRF2D = &(fDigParam->GetPRF2D());
+  AliTPCRF1D  * fRF    = &(fDigParam->GetRF()); 
+  //to make the code faster we put parameters  to the stack
+
+  Float_t zwidth  = fTPCParam->GetZWidth();
+  Float_t zwidthm1  =1./fTPCParam->GetZWidth();
+
+  tv = (TVector*)p1->At(ntr); // pointer to a track
+  TVector &v = *tv;
+  
+  Float_t label = v(0);
+
+  Int_t CentralPad = (np+1)/2;
+  Int_t PadNumber;
+  Int_t nElectrons = (tv->GetNrows()-1)/4;
+  Float_t range=((np-1)/2 + 0.5)*fTPCParam->GetPadPitchWidth(); // pad range
+  range -= 0.5; // dead zone, 5mm from the edge, according to H.G. Fischer
+
+  Float_t IneffFactor = 0.5; // inefficiency in the gain close to the edge, as above
+
+
+  Float_t PadSignal[7]; // signal from a single electron
+
+  TMatrix &signal = *m1;
+  TMatrix &total = *m2;
+
+
+  IndexRange[0]=9999; // min pad
+  IndexRange[1]=-1; // max pad
+  IndexRange[2]=9999; //min time
+  IndexRange[3]=-1; // max time
+
+  //
+  //  Loop over all electrons
+  //
+
+  for(Int_t nel=0; nel<nElectrons; nel++){
+   Int_t idx=nel*4;
+   Float_t xwire = v(idx+1);
+   Float_t y = v(idx+2);
+   Float_t z = v(idx+3);
+
+
+   Float_t absy=TMath::Abs(y);
+   
+   if(absy < 0.5*fTPCParam->GetPadPitchWidth()){
+     PadNumber=CentralPad;
+   }
+   else if (absy < range){
+     PadNumber=(Int_t) ((absy-0.5*fTPCParam->GetPadPitchWidth())/fTPCParam->GetPadPitchWidth() +1.);
+     PadNumber=(Int_t) (TMath::Sign((Float_t)PadNumber, y)+CentralPad);
+   }
+   else continue; // electron out of pad-range , lost at the sector edge
+    
+   Float_t aval = (absy<range-0.5) ? v(idx+4):v(idx+4)*IneffFactor;
+   
+
+   Float_t dist = y - (Float_t)(PadNumber-CentralPad)*fTPCParam->GetPadPitchWidth();
+   for (Int_t i=0;i<7;i++)
+     PadSignal[i]=fPRF2D->GetPRF(dist+(i-3)*fTPCParam->GetPadPitchWidth(),xwire)*aval;
+
+   Int_t  LeftPad = TMath::Max(1,PadNumber-3);
+   Int_t  RightPad = TMath::Min(np,PadNumber+3);
+
+   Int_t pmin=LeftPad-PadNumber+3; // lower index of the pad_signal vector
+   Int_t pmax=RightPad-PadNumber+3; // upper index     
+   
+   Float_t z_drift = (z_end-z)*zwidthm1;
+   Float_t z_offset = z_drift-(Int_t)z_drift;
+  //distance to the centre of nearest time bin (in time bin units)
+   Int_t FirstBucket = (Int_t)z_drift+1; 
+
+
+   // loop over time bins (4 bins is enough - 3 sigma truncated Gaussian)
+   for (Int_t i2=0;i2<4;i2++){          
+     Int_t TrueTime = FirstBucket+i2; // current time bucket
+     Float_t dz   = (Float_t(i2)+z_offset)*zwidth; 
+     Float_t ampl = fRF->GetRF(dz); 
+     if( (TrueTime>MAXTPCTBK) ) break; // beyond the time range
+     
+     IndexRange[2]=TMath::Min(IndexRange[2],TrueTime); // min time
+     IndexRange[3]=TMath::Max(IndexRange[3],TrueTime); // max time
+
+     // loop over pads, from pmin to pmax
+     for(Int_t i3=pmin;i3<=pmax;i3++){
+       Int_t TruePad = LeftPad+i3-pmin;
+       IndexRange[0]=TMath::Min(IndexRange[0],TruePad); // min pad
+       IndexRange[1]=TMath::Max(IndexRange[1],TruePad); // max pad
+       signal(TruePad,TrueTime)+=(PadSignal[i3]*ampl); // not converted to charge!!!
+       total(TruePad,TrueTime)+=(PadSignal[i3]*ampl); // not converted to charge!!!
+     } // end of pads loop
+   }  // end of time loop
+  } // end of loop over electrons
+
+  return label; // returns track label when finished
+}
+
+//_____________________________________________________________________________
+void AliTPC::GetList(Float_t label,Int_t np,TMatrix *m,Int_t *IndexRange,
+                     Float_t **pList)
+{
+  //----------------------------------------------------------------------
+  //  Updates the list of tracks contributing to digits for a given row
+  //----------------------------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
+  TMatrix &signal = *m;
+
+  // lop over nonzero digits
+
+  for(Int_t it=IndexRange[2];it<IndexRange[3]+1;it++){
+    for(Int_t ip=IndexRange[0];ip<IndexRange[1]+1;ip++){
+
+
+        Int_t GlobalIndex = (it-1)*np+ip-1; // GlobalIndex starts from 0!
+        
+        if(!pList[GlobalIndex]){
+        
+          // 
+         // Create new list (6 elements - 3 signals and 3 labels),
+         // but only if the signal is > 0. 
+         //
+
+          if(signal(ip,it)>0.){
+
+          pList[GlobalIndex] = new Float_t [6];
+
+         // set list to -1 
+
+          *pList[GlobalIndex] = -1.;
+          *(pList[GlobalIndex]+1) = -1.;
+          *(pList[GlobalIndex]+2) = -1.;
+          *(pList[GlobalIndex]+3) = -1.;
+          *(pList[GlobalIndex]+4) = -1.;
+          *(pList[GlobalIndex]+5) = -1.;
+
+
+          *pList[GlobalIndex] = label;
+          *(pList[GlobalIndex]+3) = signal(ip,it);}
+        }
+        else{
+
+         // check the signal magnitude
+
+          Float_t highest = *(pList[GlobalIndex]+3);
+          Float_t middle = *(pList[GlobalIndex]+4);
+          Float_t lowest = *(pList[GlobalIndex]+5);
+
+         //
+         //  compare the new signal with already existing list
+         //
+
+          if(signal(ip,it)<lowest) continue; // neglect this track
+
+         //
+
+          if (signal(ip,it)>highest){
+            *(pList[GlobalIndex]+5) = middle;
+            *(pList[GlobalIndex]+4) = highest;
+            *(pList[GlobalIndex]+3) = signal(ip,it);
+
+            *(pList[GlobalIndex]+2) = *(pList[GlobalIndex]+1);
+            *(pList[GlobalIndex]+1) = *pList[GlobalIndex];
+            *pList[GlobalIndex] = label;
+         }
+          else if (signal(ip,it)>middle){
+            *(pList[GlobalIndex]+5) = middle;
+            *(pList[GlobalIndex]+4) = signal(ip,it);
+
+            *(pList[GlobalIndex]+2) = *(pList[GlobalIndex]+1);
+            *(pList[GlobalIndex]+1) = label;
+         }
+          else{
+            *(pList[GlobalIndex]+5) = signal(ip,it);
+            *(pList[GlobalIndex]+2) = label;
+         }
+        }
+
+    } // end of loop over pads
+  } // end of loop over time bins
+
+
+
+
+}//end of GetList
+//___________________________________________________________________
+void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
+                        Stat_t ntracks,TObjArray **row)
+{
+
+  //-----------------------------------------------------------------
+  // Prepares the sector digitization, creates the vectors of
+  // tracks for each row of this sector. The track vector
+  // contains the track label and the position of electrons.
+  //-----------------------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
+  Int_t i;
+  Float_t xyz[3]; 
+
+  AliTPChit *tpcHit; // pointer to a sigle TPC hit    
+  //----------------------------------------------
+  // Create TObjArray-s, one for each row,
+  // each TObjArray will store the TVectors
+  // of electrons, one TVector per each track.
+  //---------------------------------------------- 
+    
+  for(i=0; i<nrows; i++){
+    row[i] = new TObjArray;
+  }
+  Int_t *n_of_electrons = new Int_t [nrows]; // electron counter for each row
+  TVector **tr = new TVector* [nrows]; //pointers to the track vectors
+
+  //--------------------------------------------------------------------
+  //  Loop over tracks, the "track" contains the full history
+  //--------------------------------------------------------------------
+
+  Int_t previousTrack,currentTrack;
+  previousTrack = -1; // nothing to store so far!
+
+  for(Int_t track=0;track<ntracks;track++){
+
+    ResetHits();
+
+    TH->GetEvent(track); // get next track
+    Int_t nhits = fHits->GetEntriesFast(); // get number of hits for this track
+
+    if(nhits == 0) continue; // no hits in the TPC for this track
+
+    //--------------------------------------------------------------
+    //  Loop over hits
+    //--------------------------------------------------------------
+
+    for(Int_t hit=0;hit<nhits;hit++){
+
+      tpcHit = (AliTPChit*)fHits->UncheckedAt(hit); // get a pointer to a hit
+      
+      Int_t sector=tpcHit->fSector; // sector number
+      if(sector != isec) continue; //terminate iteration
+
+       currentTrack = tpcHit->fTrack; // track number
+        if(currentTrack != previousTrack){
+                          
+           // store already filled fTrack
+              
+          for(i=0;i<nrows;i++){
+             if(previousTrack != -1){
+              if(n_of_electrons[i]>0){
+                TVector &v = *tr[i];
+                v(0) = previousTrack;
+                 tr[i]->ResizeTo(3*n_of_electrons[i]+1); // shrink if necessary
+                row[i]->Add(tr[i]);                     
+              }
+               else{
+                 delete tr[i]; // delete empty TVector
+                 tr[i]=0;
+              }
+            }
+
+             n_of_electrons[i]=0;
+             tr[i] = new TVector(361); // TVectors for the next fTrack
+
+          } // end of loop over rows
+              
+           previousTrack=currentTrack; // update track label 
+       }
+          
+       Int_t QI = (Int_t) (tpcHit->fQ); // energy loss (number of electrons)
+
+       //---------------------------------------------------
+       //  Calculate the electron attachment probability
+       //---------------------------------------------------
+
+        Float_t time = 1.e6*(z_end-TMath::Abs(tpcHit->fZ))/fTPCParam->GetDriftV(); 
+       // in microseconds!     
+       Float_t AttProb = fTPCParam->GetAttCoef()*
+         fTPCParam->GetOxyCont()*time; //  fraction! 
+   
+       //-----------------------------------------------
+       //  Loop over electrons
+       //-----------------------------------------------
+
+        for(Int_t nel=0;nel<QI;nel++){
+          // skip if electron lost due to the attachment
+          if((gRandom->Rndm(0)) < AttProb) continue; // electron lost!
+         xyz[0]=tpcHit->fX;
+         xyz[1]=tpcHit->fY;
+         xyz[2]=tpcHit->fZ;
+         ElDiff(xyz); // Appply the diffusion
+         Int_t row_number;
+         fTPCParam->XYZtoCRXYZ(xyz,isec,row_number,3);
+
+         //transform position to local coordinates
+         //option 3 means that we calculate x position relative to 
+         //nearest pad row 
+
+         if ((row_number<0)||row_number>=fTPCParam->GetNRow(isec)) continue;
+         ExB(xyz); // ExB effect at the sense wires
+         n_of_electrons[row_number]++;   
+         //----------------------------------
+         // Expand vector if necessary
+         //----------------------------------
          if(n_of_electrons[row_number]>120){
            Int_t range = tr[row_number]->GetNrows();
-           if(n_of_electrons[row_number] > (range-1)/2){
-             tr[row_number]->ResizeTo(range+30); // Add 15 electrons
+           if(n_of_electrons[row_number] > (range-1)/3){
+             tr[row_number]->ResizeTo(range+150); // Add 50 electrons
            }
          }
          
-         //---------------------------------
-         //  E x B effect at the wires
-         //---------------------------------
-         Int_t nw;
-         nw=(nwires+1)/2;
-         Float_t xx,dx;
-         for (Int_t nwire=1;nwire<=nwires;nwire++){
-           xx=(nwire-nw)*ww_pitch+
-             ((isec<13) ? pad_row_low[row_number]:pad_row_up[row_number]);
-           dx=xx-xyz[0];
-           if(TMath::Abs(dx) < 0.5*ww_pitch) {
-             xyz[1]=dx*omega_tau+xyz[1];
-             break;
-           }
-         } // end of loop over the wires
-         
          TVector &v = *tr[row_number];
-         Int_t idx = 2*n_of_electrons[row_number]-1;
-         v(idx)=xyz[1];
-         v(idx+1)=xyz[2];
-       } // end of loop over electrons         
-      } // end of loop over hits  
-      
-      //
-      //  The track is finished 
-      //     
-      int trk=((AliTPChit*)fHits->UncheckedAt(0))->fTrack; //Y.Belikov
-      for(i=0;i<nrows;i++){
-       TVector &v = *tr[i];
-       if(n_of_electrons[i] >0) {
-         //        v(0)=(Float_t)(track+1); // track number
-          v(0)=(Float_t)(trk+1); // Y.Belikov 
-         tr[i]->ResizeTo(2*n_of_electrons[i]+1); // shrink if necessary
-         row[i]->Add(tr[i]); // add to the row-array
+         Int_t idx = 3*n_of_electrons[row_number]-2;
+
+         v(idx)=  xyz[0];   // X
+         v(idx+1)=xyz[1];   // Y (along the pad-row)
+          v(idx+2)=xyz[2];   // Z
+           
+       } // end of loop over electrons
+        
+      } // end of loop over hits
+    } // end of loop over tracks
+
+    //
+    //   store remaining track (the last one) if not empty
+    //
+
+     for(i=0;i<nrows;i++){
+       if(n_of_electrons[i]>0){
+          TVector &v = *tr[i];
+         v(0) = previousTrack;
+          tr[i]->ResizeTo(3*n_of_electrons[i]+1); // shrink if necessary
+         row[i]->Add(tr[i]);  
        }
        else{
-         delete tr[i]; // delete TVector if empty
-       }
-      }   
-      delete [] tr; // delete track pointers  
-      delete [] n_of_electrons; // delete n_of_electrons array     
-    } //end of loop over tracks 
-    //---------------------------------------------------
-    //  Digitize the sector data, row by row
-    //---------------------------------------------------  
-    
-    printf("*** Digitizing sector number %d ***\n",isec);
-    
-    for(i=0;i<nrows;i++){
-      
-      DigSignal(isec,i,row[i]); 
-      gAlice->TreeD()->Fill();      
-      int ndig=fDigits->GetEntriesFast();
-      printf("*** Sector, row, digits %d %d %d ***\n",isec,i+1,ndig);
-      
-      ResetDigits();
-      
-      row[i]->Delete(); // delete objects in this array
-      delete row[i]; // delete the TObjArray itselves
-      
-    } // end of digitization
-    
-    delete [] row; // delete vectors of pointers to sectors
-    
-  } //end of loop over sectors 
-  
-}
+          delete tr[i];
+          tr[i]=0;
+       }  
+      }  
+
+          delete [] tr;
+          delete [] n_of_electrons; 
+
+} // end of MakeSector
+//_____________________________________________________________________________
+void AliTPC::GetCrossTalk (Int_t iFlag,TObjArray *p,Int_t ntracks,Int_t *npads,
+                           TMatrix *m)
+{
+
+  //-------------------------------------------------------------
+  // Calculates the cross-talk from one row (inner or outer)
+  //-------------------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
+  //
+  // iFlag=2 & 3 --> cross-talk from the inner row
+  // iFlag=0 & 4 --> cross-talk from the outer row
+  //
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
+  AliTPCPRF2D * fPRF2D = &(fDigParam->GetPRF2D());
+  AliTPCRF1D  * fRF    = &(fDigParam->GetRF()); 
+  //to make code faster
+
+  Float_t zwidth  = fTPCParam->GetZWidth();
+  Float_t zwidthm1  =1/fTPCParam->GetZWidth();
+
+ Int_t PadNumber;
+ Float_t xwire;
+
+ Int_t nPadsSignal; // for this pads the signal is calculated
+ Float_t range;     // sense wire range
+ Int_t nPadsDiff;
+
+ Float_t IneffFactor=0.5; // gain inefficiency close to the edges
+
+ if(iFlag == 0){   
+   // 1-->0
+   nPadsSignal = npads[1];
+   range = ((npads[1]-1)/2 + 0.5)*fTPCParam->GetPadPitchWidth();  
+   nPadsDiff = (npads[1]-npads[0])/2;
+ }  
+ else if (iFlag == 2){
+   // 1-->2
+   nPadsSignal = npads[2];
+   range = ((npads[1]-1)/2 + 0.5)*fTPCParam->GetPadPitchWidth();
+   nPadsDiff = 0;
+ }
+ else if (iFlag == 3){
+   // 0-->1
+   nPadsSignal = npads[1];
+   range = ((npads[0]-1)/2 + 0.5)*fTPCParam->GetPadPitchWidth();
+   nPadsDiff = 0;
+ }
+ else{
+   // 2-->1
+   nPadsSignal = npads[2];
+   range = ((npads[2]-1)/2 + 0.5)*fTPCParam->GetPadPitchWidth();
+   nPadsDiff = (npads[2]-npads[1])/2;
+ }
+
+ range-=0.5; // dead zone close to the edges
+
+ TVector *tv; 
+ TMatrix &signal = *m;
+
+ Int_t CentralPad = (nPadsSignal+1)/2;
+ Float_t PadSignal[7]; // signal from a single electron
+ // Loop over tracks
+ for(Int_t nt=0;nt<ntracks;nt++){
+   tv=(TVector*)p->At(nt); // pointer to a track
+   TVector &v = *tv;
+   Int_t nElectrons = (tv->GetNrows()-1)/4;
+   // Loop over electrons
+   for(Int_t nel=0; nel<nElectrons; nel++){
+     Int_t idx=nel*4;
+     xwire=v(idx+1);
+     if (iFlag==0) xwire+=fTPCParam->GetPadPitchLength();
+     if (iFlag==2)  xwire-=fTPCParam->GetPadPitchLength();
+     if (iFlag==3)  xwire-=fTPCParam->GetPadPitchLength();
+     if (iFlag==4)  xwire+=fTPCParam->GetPadPitchLength();  
+   
+     //  electron acceptance for the cross-talk (only the closest wire)  
+
+     Float_t dxMax = fTPCParam->GetPadPitchLength()*0.5+fTPCParam->GetWWPitch();
+     if(TMath::Abs(xwire)>dxMax) continue;
+
+     Float_t y = v(idx+2);
+     Float_t z = v(idx+3);
+     Float_t absy=TMath::Abs(y);
+
+     if(absy < 0.5*fTPCParam->GetPadPitchWidth()){
+       PadNumber=CentralPad;
+     }
+     else if (absy < range){
+       PadNumber=(Int_t) ((absy-0.5*fTPCParam->GetPadPitchWidth())/fTPCParam->GetPadPitchWidth() +1.);
+       PadNumber=(Int_t) (TMath::Sign((Float_t)PadNumber, y)+CentralPad);
+     }
+     else continue; // electron out of sense wire range, lost at the sector edge
+
+     Float_t aval = (absy<range-0.5) ? v(idx+4):v(idx+4)*IneffFactor;
+
+     Float_t dist = y - (Float_t)(PadNumber-CentralPad)*fTPCParam->GetPadPitchWidth();
+       
+     for (Int_t i=0;i<7;i++)
+       PadSignal[i]=fPRF2D->GetPRF(dist+(3-i)*fTPCParam->GetPadPitchWidth(),xwire)*aval;
+
+     // real pad range
+
+     Int_t  LeftPad = TMath::Max(1,PadNumber-3);
+     Int_t  RightPad = TMath::Min(nPadsSignal,PadNumber+3);
+
+     Int_t pmin=LeftPad-PadNumber+3; // lower index of the pad_signal vector
+     Int_t pmax=RightPad-PadNumber+3; // upper index  
+
+
+     Float_t z_drift = (z_end-z)*zwidthm1;
+     Float_t z_offset = z_drift-(Int_t)z_drift;
+     //distance to the centre of nearest time bin (in time bin units)
+     Int_t FirstBucket = (Int_t)z_drift+1; 
+     // MI check it --time offset
+     for (Int_t i2=0;i2<4;i2++){     
+       Int_t TrueTime = FirstBucket+i2; // current time bucket
+       Float_t dz   = (Float_t(i2)+z_offset)*zwidth; 
+       Float_t ampl = fRF->GetRF(dz); 
+       if((TrueTime>MAXTPCTBK)) break; // beyond the time range
+
+
+       // loop over pads, from pmin to pmax
+
+       for(Int_t i3=pmin;i3<pmax+1;i3++){
+         Int_t TruePad = LeftPad+i3-pmin;
+
+         if(TruePad<nPadsDiff+1 || TruePad > nPadsSignal-nPadsDiff) continue;
+
+         TruePad -= nPadsDiff;
+         signal(TruePad,TrueTime)+=(PadSignal[i3]*ampl); // not converted to charge!
+
+       } // end of loop over pads
+     } // end of loop over time bins
+
+   } // end of loop over electrons 
+
+ } // end of loop over tracks
+
+} // end of GetCrossTalk
+
+
 
 //_____________________________________________________________________________
 void AliTPC::Init()
@@ -1509,7 +2014,8 @@ void AliTPC::ResetDigits()
   // reset clusters
   //
   fNdigits   = 0;
-  if (fDigits)   fDigits->Clear();
+  //  if (fDigits)   fDigits->Clear();
+  if (fDigParam->GetArray()!=0)  fDigParam->GetArray()->Clear();
   fNclusters = 0;
   if (fClusters) fClusters->Clear();
 }
@@ -1517,27 +2023,42 @@ void AliTPC::ResetDigits()
 //_____________________________________________________________________________
 void AliTPC::SetSecAL(Int_t sec)
 {
-  //
+  //---------------------------------------------------
   // Activate/deactivate selection for lower sectors
-  //
+  //---------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
   fSecAL = sec;
 }
 
 //_____________________________________________________________________________
 void AliTPC::SetSecAU(Int_t sec)
 {
-  //
+  //----------------------------------------------------
   // Activate/deactivate selection for upper sectors
-  //
+  //---------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
   fSecAU = sec;
 }
 
 //_____________________________________________________________________________
 void AliTPC::SetSecLows(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6)
 {
-  //
+  //----------------------------------------
   // Select active lower sectors
-  //
+  //----------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
   fSecLows[0] = s1;
   fSecLows[1] = s2;
   fSecLows[2] = s3;
@@ -1551,9 +2072,14 @@ void AliTPC::SetSecUps(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6,
                        Int_t s7, Int_t s8 ,Int_t s9 ,Int_t s10, 
                        Int_t s11 , Int_t s12)
 {
-  // 
+  //--------------------------------
   // Select active upper sectors
-  //
+  //--------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
   fSecUps[0] = s1;
   fSecUps[1] = s2;
   fSecUps[2] = s3;
@@ -1571,6 +2097,16 @@ void AliTPC::SetSecUps(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6,
 //_____________________________________________________________________________
 void AliTPC::SetSens(Int_t sens)
 {
+
+  //-------------------------------------------------------------
+  // Activates/deactivates the sensitive strips at the center of
+  // the pad row -- this is for the space-point resolution calculations
+  //-------------------------------------------------------------
+
+  //-----------------------------------------------------------------
+  // Origin: Marek Kowalski  IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
+  //-----------------------------------------------------------------
+
   fSens = sens;
 }
 
@@ -1619,24 +2155,37 @@ AliTPCcluster::AliTPCcluster(Float_t *hits, Int_t *lab)
 }
  
 //_____________________________________________________________________________
-void AliTPCcluster::GetXYZ(Double_t& x, Double_t& y, Double_t& z) const 
+void AliTPCcluster::GetXYZ(Float_t *x, const AliTPCParam *par) const 
 {
   //
-  // Returns centroid for of a simulated TPC cluster
+  // Transformation from local to global coordinate system
   //
-  Double_t alpha,xrow;
-  if (fSector<24) {
-    alpha=(fSector<12) ? fSector*alpha_low : (fSector-12)*alpha_low;
-    xrow=pad_row_low[fPadRow];
-  } else {
-    alpha=(fSector<48) ? (fSector-24)*alpha_up : (fSector-48)*alpha_up;
-    xrow=pad_row_up[fPadRow];
-  }
-  x=xrow*cos(alpha) - fY*sin(alpha);
-  y=xrow*sin(alpha) + fY*cos(alpha);
-  z=fZ;
+  x[0]=par->GetPadRowRadii(fSector,fPadRow-1);
+  x[1]=fY;
+  x[2]=fZ;
+  par->CRXYZtoXYZ(x,fSector,fPadRow-1,1);
 }
  
+//_____________________________________________________________________________
+Int_t AliTPCcluster::Compare(TObject * o)
+{
+  //
+  // compare two clusters according y coordinata
+  AliTPCcluster *cl= (AliTPCcluster *)o;
+  if (fY<cl->fY) return -1;
+  if (fY==cl->fY) return 0;
+  return 1;  
+}
+
+Bool_t AliTPCcluster::IsSortable() const
+{
+  //
+  //make AliTPCcluster sortabale
+  return kTRUE; 
+}
+
+
+
 ClassImp(AliTPCdigit)
  
 //_____________________________________________________________________________
@@ -1684,18 +2233,20 @@ AliTPCtrack::AliTPCtrack(Float_t *hits)
 }
 
 AliTPCtrack::AliTPCtrack(const AliTPCcluster& c,const TVector& xx,
-                        const TMatrix& CC):
+                        const TMatrix& CC, const AliTPCParam *p):
   x(xx),C(CC),clusters(MAX_CLUSTER)
 {
   //
   // Standard creator for a TPC reconstructed track object
   //
   chi2=0.;
-  int sec=c.fSector, row=c.fPadRow;
+  int sec=c.fSector-1, row=c.fPadRow-1;
+  ref=p->GetPadRowRadii(sec+1,row);
+
   if (sec<24) { 
-    fAlpha=(sec%12)*alpha_low; ref=pad_row_low[0] + row*pad_pitch_l;
+    fAlpha=(sec%12)*alpha_low;
   } else { 
-    fAlpha=(sec%24)*alpha_up;  ref=pad_row_up[0]  + row*pad_pitch_l;
+    fAlpha=(sec%24)*alpha_up;
   }
   clusters.AddLast((AliTPCcluster*)(&c));
 }
@@ -1741,14 +2292,14 @@ int AliTPCtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho,Double_t pm)
     if (*this>3) cerr<<*this<<" AliTPCtrack warning: Propagation failed !\n";
     return 0;
   }
-  
+
   Double_t x1=ref, x2=x1+0.5*(xk-x1), dx=x2-x1, y1=x(0), z1=x(1);
   Double_t c1=x(2)*x1 - x(3), r1=sqrt(1.- c1*c1);
   Double_t c2=x(2)*x2 - x(3), r2=sqrt(1.- c2*c2);
   
   x(0) += dx*(c1+c2)/(r1+r2);
   x(1) += dx*(c1+c2)/(c1*r2 + c2*r1)*x(4);
-  
+
   TMatrix F(5,5); F.UnitMatrix();
   Double_t rr=r1+r2, cc=c1+c2, xx=x1+x2;
   F(0,2)= dx*(rr*xx + cc*(c1*x1/r1+c2*x2/r2))/(rr*rr);
@@ -1791,6 +2342,7 @@ int AliTPCtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho,Double_t pm)
   Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2)) - beta2)*d*rho;
   if (x1 < x2) dE=-dE;
   x(2)*=(1.- sqrt(p2+pm*pm)/p2*dE);
+  //x(3)*=(1.- sqrt(p2+pm*pm)/p2*dE);
   
   x1=ref; x2=xk; y1=x(0); z1=x(1);
   c1=x(2)*x1 - x(3); r1=sqrt(1.- c1*c1);
@@ -1957,7 +2509,7 @@ int AliTPCtrack::GetLab() const
   //
   //
   //
-  int lab = 0;
+  int lab;
   struct {
     int lab;
     int max;
@@ -1967,7 +2519,7 @@ int AliTPCtrack::GetLab() const
   int num_of_clusters=clusters.GetEntriesFast();
   for (i=0; i<num_of_clusters; i++) {
     AliTPCcluster *c=(AliTPCcluster*)clusters.UncheckedAt(i);
-    lab=c->fTracks[0]; if (lab<0) lab=-lab;
+    lab=TMath::Abs(c->fTracks[0]);
     int j;
     for (j=0; j<MAX_CLUSTER; j++)
       if (s[j].lab==lab || s[j].max==0) break;
@@ -1978,7 +2530,12 @@ int AliTPCtrack::GetLab() const
   int max=0;
   for (i=0; i<num_of_clusters; i++) 
     if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
-  if (lab>0) lab--;
+
+  for (i=0; i<num_of_clusters; i++) {
+    AliTPCcluster *c=(AliTPCcluster*)clusters.UncheckedAt(i);
+    if (TMath::Abs(c->fTracks[1]) == lab ||
+        TMath::Abs(c->fTracks[2]) == lab ) max++;
+  }
   
   if (1.-float(max)/num_of_clusters > 0.10) return -lab;
   
@@ -1987,12 +2544,11 @@ int AliTPCtrack::GetLab() const
   max=0;
   for (i=1; i<=6; i++) {
     AliTPCcluster *c=(AliTPCcluster*)clusters.UncheckedAt(num_of_clusters-i);
-    if (lab != TMath::Abs(c->fTracks[0])-1
-       && lab != TMath::Abs(c->fTracks[1])-1
-       && lab != TMath::Abs(c->fTracks[2])-1
-       ) max++;
+    if (lab == TMath::Abs(c->fTracks[0]) ||
+        lab == TMath::Abs(c->fTracks[1]) ||
+        lab == TMath::Abs(c->fTracks[2])) max++;
   }
-  if (max>3) return -lab;
+  if (max<3) return -lab;
   
   return lab;
 }
@@ -2049,3 +2605,4 @@ int AliTPCRow::Find(Double_t y) const
   }
   return m;
 }
+
index 487673dc111c01aadac85f139df01b7ce1e4a5d8..a6f4d5333c39c618a4d6bab1182e6c8eebc8c198 100644 (file)
@@ -8,12 +8,18 @@
 #include "AliHit.h" 
 #include "AliDigit.h" 
 #include "AliTPCSecGeo.h" 
+#include "AliTPCParam.h"
 #include <TMatrix.h>
+#include <TTree.h>
+#include <TClonesArray.h>
 
 #define MAXTPCTBK 500
 
 class AliTPCcluster;
 class AliTPCtrack;
+class AliTPCParam;
+//MI changes
+class AliTPCD;
 
 class AliTPC : public AliDetector {
 protected:
@@ -29,7 +35,8 @@ protected:
   Int_t          *fDigitsIndex;     // Index for each sector in fDigits
   TClonesArray   *fClusters;        // List of clusters for all sectors
   TClonesArray   *fTracks;          // List of reconstructed tracks
-  
+  //MI changes
+  AliTPCD * fDigParam;              //detector parameters  
 public:
   AliTPC();
   AliTPC(const char *name, const char *title);
@@ -45,7 +52,9 @@ public:
   virtual void  CreateGeometry() {}
   virtual void  CreateMaterials();
   virtual void  Hits2Clusters();
-  virtual void  Hits2Digits();
+
+  virtual void  Hits2Digits();   //MI change
+  virtual void Hits2DigitsSector(Int_t isec);  //MI change
   virtual void  Init();
   virtual Int_t IsVersion() const =0;
   virtual void  Digits2Clusters();
@@ -64,72 +73,25 @@ public:
                           Int_t s7,Int_t s8,Int_t s9,Int_t s10, Int_t s11, Int_t s12);
   virtual void  SetSens(Int_t sens);
   virtual void  StepManager()=0;
-  virtual void  DrawModule() {}
-  
+  virtual void  DrawDetector() {}
+  AliTPCD*  GetDigParam() {return fDigParam;} //MI change8
+  void SetDigParam(AliTPCD* param) {fDigParam=param;}  //MI must think about it
 private:
   //
-  //  Private inline functions for AliTPC
-  //
-  inline Float_t P1(const Float_t x){
-#ifndef __CINT__
-    const
-#endif
-    Float_t y=x*x;
-    return(1.25e-3-8.0e-3*x+0.0274*y-0.0523*x*y); //electron is 3 pads away
-  }
-  //
-  inline Float_t P2(const Float_t x){
-#ifndef __CINT__
-    const
-#endif
-    Float_t y=x*x;
-
-    return(.0114-0.0726*x+0.2408*y-0.4421*x*y);    //electron is 2 pads away
-  }
-  //
-  inline Float_t P3(const Float_t x){
-#ifndef __CINT__
-    const
-#endif
-    Float_t y=x*x;
-
-    return(0.0959-0.5204*x+0.9272*y+0.2865*x*y);      //electron is 1 pad away
-  }
-  //
-  inline Float_t P4(const Float_t x){
-#ifndef __CINT__
-    const
-#endif
-      Float_t y=x*x; 
-    return(.2835-2.7*y+11.55*y*y); //electron is here
-  }
+  void ElDiff(Float_t *xyz);
+  void MakeTriplet(Int_t row,TObjArray **rowTriplet, 
+                   TObjArray **prow);
 
+  void ExB(Float_t *xyz);
+  void DigitizeRow(Int_t irow,Int_t isec,TObjArray **rowTriplet);
+  Float_t GetSignal(TObjArray *p1, Int_t ntr, Int_t np, TMatrix *m1, TMatrix *m2,
+                    Int_t *IndexRange);
+  void GetList (Float_t label,Int_t np,TMatrix *m,Int_t *IndexRange,
+                Float_t **pList);
+  void MakeSector(Int_t isec,Int_t nrows,TTree *TH,Stat_t ntracks,TObjArray **row);
+  void GetCrossTalk (Int_t iFlag,TObjArray *p,Int_t ntracks,Int_t *npads,
+                     TMatrix *m);
 
-  //
-  //  Time response, 3 sigma truncated Gaussian
-  //
-  inline Float_t TimeRes(const Float_t x) {
-#ifndef __CINT__
-    const 
-#endif
-      Float_t sigma = fwhm/2.354820045;
-#ifndef __CINT__
-    const
-#endif
-      Float_t trunc = 3.*sigma;
-    const Float_t norm = 0.4; // according to H-G. Fischer
-#ifndef __CINT__
-    const
-#endif
-      Float_t x1 = x-trunc;
-    return (TMath::Abs(x1)>trunc) ? 0 : norm*TMath::Exp(-0.5*x1*x1/sigma/sigma);
-  }
-  //
-  // Private prototypes for Alice TPC
-  //
-  void CreateList(Int_t *tracks,Float_t signal[][MAXTPCTBK+1],Int_t ntr,Int_t time);
-  void DigSignal(Int_t isec,Int_t irow,TObjArray *pointer);
-  void ElDiff(Float_t *xyz);
   
   ClassDef(AliTPC,2)  // Time Projection Chamber class
 };
@@ -157,8 +119,9 @@ public:
   virtual ~AliTPCcluster() {;}
   void Use() {fTracks[0]=-fTracks[0];}
   int IsUsed() const {return (fTracks[0]<0) ? 1 : 0;}
-  void GetXYZ(Double_t& x,Double_t& y,Double_t& z) const; //Get global x,y,z
-  
+  void GetXYZ(Float_t *x, const AliTPCParam *) const; //Get global x,y,z
+  Bool_t    IsSortable() const;
+  Int_t Compare(TObject *o) ;
   ClassDef(AliTPCcluster,1)  // Time Projection Chamber clusters
 };
 
@@ -201,7 +164,7 @@ public:
  
 //_____________________________________________________________________________
  
-const unsigned MAX_CLUSTER_PER_ROW=500;
+const unsigned MAX_CLUSTER_PER_ROW=1500;
 const Double_t FIELD=0.2;
 
 class AliTPCtrack : public TObject {
@@ -213,7 +176,8 @@ class AliTPCtrack : public TObject {
    Double_t chi2;            // total chi2 value for this track
 public:
    AliTPCtrack(Float_t *hits);
-   AliTPCtrack(const AliTPCcluster& c, const TVector& xx, const TMatrix& CC); 
+   AliTPCtrack(const AliTPCcluster& c, const TVector& xx, const TMatrix& CC,
+               const AliTPCParam *); 
    AliTPCtrack(const AliTPCtrack& t);
    int PropagateTo(Double_t x,
                     Double_t x0=28.94,Double_t rho=0.9e-3,Double_t pm=0.139);
@@ -252,8 +216,8 @@ public:
 
 class TrackSeed : public AliTPCtrack {
 public:
-   TrackSeed(const AliTPCcluster& c, const TVector& x, const TMatrix& C) :
-   AliTPCtrack(c,x,C) {}
+   TrackSeed(const AliTPCcluster& c, const TVector& x, const TMatrix& C,
+   const AliTPCParam *p) : AliTPCtrack(c,x,C,p) {}
    Bool_t IsSortable() const {return kTRUE;}
    Int_t Compare(TObject *o) {
       AliTPCtrack *t=(AliTPCtrack*)o;
@@ -277,13 +241,18 @@ public:
    int Find(Double_t y) const; 
 };
 
+
 class AliTPCSector {
+protected:
    unsigned num_of_rows; 
    AliTPCRow *row;
+   const AliTPCParam *param; 
 public:
-   AliTPCSector(int nl) { 
-      row = new AliTPCRow[nl]; num_of_rows=nl;
+   AliTPCSector() { 
+      row = 0; num_of_rows=0;
+      param=0;
    }
+   virtual void SetUp(AliTPCParam *p) {param=p;}
    virtual ~AliTPCSector() { delete[] row; }
    AliTPCRow& operator[](int i) const { return *(row+i); }
    virtual Double_t GetX(int l) const = 0;
@@ -293,21 +262,34 @@ public:
 
 class AliTPCSSector : public AliTPCSector {
 public:
-   AliTPCSSector(): AliTPCSector(nrow_low){}
+   AliTPCSSector(){}
    virtual ~AliTPCSSector() {}
-   Double_t GetX(int l) const { return pad_row_low[0] + (l+0.0)*pad_pitch_l; }
-   Double_t GetMaxY(int l) const { return GetX(l)*tan(0.5*alpha_low); }
+   virtual void SetUp(AliTPCParam *p) {
+      param=p;
+      num_of_rows=p->GetNRowLow();
+      row=new AliTPCRow[num_of_rows];
+   }
+   Double_t GetX(int l) const { return param->GetPadRowRadiiLow(l); }
    Double_t GetAlpha() const {return alpha_low;}
+   Double_t GetMaxY(int l) const { return GetX(l)*tan(0.5*GetAlpha()); }
 };
 
 class AliTPCLSector : public AliTPCSector {
 public:
-   AliTPCLSector(): AliTPCSector(nrow_up){}
+   AliTPCLSector(){}
    virtual ~AliTPCLSector() {}
-   Double_t GetX(int l) const { return pad_row_up[0] + (l+0.0)*pad_pitch_l; }
-   Double_t GetMaxY(int l) const { return GetX(l)*tan(0.5*alpha_up); }
+   virtual void SetUp(AliTPCParam *p) {
+      param=p;
+      num_of_rows=p->GetNRowUp();
+      row=new AliTPCRow[num_of_rows];
+   }
+   Double_t GetX(int l) const { return param->GetPadRowRadiiUp(l); }
    Double_t GetAlpha() const {return alpha_up;}
+   Double_t GetMaxY(int l) const { return GetX(l)*tan(0.5*GetAlpha()); }
 };
 
+
+
+
 #endif
 
diff --git a/TPC/AliTPCD.cxx b/TPC/AliTPCD.cxx
new file mode 100644 (file)
index 0000000..de34611
--- /dev/null
@@ -0,0 +1,139 @@
+//-----------------------------------------------------------------------------
+// 
+//  Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk
+//
+//  Implementation of class AliTPCD
+//
+//-----------------------------------------------------------------------------
+
+#include <TMath.h>
+#include "AliTPCParam.h"
+#include "AliTPCRF1D.h"
+#include "AliTPCPRF2D.h"
+#include "AliTPCD.h"
+#include "TClonesArray.h"
+#include "TClass.h"
+#include "TBranchClones.h"
+#include "TTree.h"   
+#include "TDirectory.h"
+
+
+
+// other include files follow here
+
+
+ClassImp(AliTPCD)
+  //_____________________________________________________________ 
+AliTPCD::AliTPCD(Text_t *  name,
+                AliTPCParam * param, AliTPCPRF2D* prf, AliTPCRF1D* prfz) 
+{
+  //construct new object's or accept objects sent to constructor
+  //AliTPCD handle sent object and is repsonsible for
+  //deleting it
+
+//Begin_Html
+/*
+<img src="gif/alitpcd.gif">
+*/
+//End_Html
+  SetName(name);
+  if ((param!=0) && 
+      ( (param->IsA()->InheritsFrom("AliTPCParam")==kTRUE ) ))
+    fParam=param; 
+  else
+    fParam= new AliTPCParam;
+  if ( (prf!=0) && (prf->IsA()->InheritsFrom("AliTPCPRF2D")==kTRUE) )
+    fPRF=prf;
+  else
+    fPRF =  new AliTPCPRF2D;
+  if ( (prfz!=0) && (prfz->IsA()->InheritsFrom("AliTPCRF1D")==kTRUE) )
+    fRF=prfz;
+  else
+    fRF =  new AliTPCRF1D(kTRUE);  
+  fDigits = new TClonesArray("AliTPCdigit",5000);
+  fpthis=this;
+}
+
+AliTPCD::~AliTPCD() 
+{
+  if (fParam!=0) fParam->Delete();
+  if (fPRF!=0) fPRF->Delete();
+  if (fRF!=0) fRF->Delete();
+  if (fDigits!=0) fDigits->Delete();
+}
+
+
+Bool_t  AliTPCD::SetTree(Int_t nevent, TDirectory *dir )
+{
+  char treeName[100];
+  // Get Hits Tree header from file
+  sprintf(treeName,"TreeD%d_%s",nevent,GetName());
+  fTreeD = (TTree*)dir->Get(treeName);
+  if (fTreeD == 0) return kFALSE;
+  //set Digit branch 
+  TBranch *b = fTreeD->GetBranch("Digits");
+  if (b==0) return kFALSE;
+  b->SetAddress(&fDigits);
+  return kTRUE;
+}
+
+
+Bool_t  AliTPCD::MakeTree(Int_t nevent)
+{
+  char treeName[100];
+  // Get Hits Tree header from file
+  sprintf(treeName,"TreeD%d_%s",nevent,GetName());
+  fTreeD =  new TTree(treeName,treeName);
+  if (fTreeD == 0) return kFALSE;
+  //set Digit branch 
+  TBranch *b = fTreeD->Branch("Digits",&fDigits,40000);
+  if (b==0) return kFALSE;
+  b->SetAddress(&fDigits);
+  return kTRUE;
+}
+  
+void AliTPCD::Fill()
+{ 
+  if (fTreeD!=0) fTreeD->Fill();    
+}
+
+
+
+
+
+void AliTPCD::Streamer(TBuffer &R__b)
+{
+ // Stream an object of class AliTPCD. 
+  if (R__b.IsReading()) {    
+    Version_t R__v = R__b.ReadVersion(); if (R__v) { }
+    TNamed::Streamer(R__b);  
+    if (fParam!=0) {
+      fParam->Delete();
+      fParam = new AliTPCParam;
+    }
+    if (fPRF!=0) {
+      fPRF->Delete();
+      fPRF = new AliTPCPRF2D;
+    }
+    if (fRF!=0) {
+      fRF->Delete();
+      fRF = new AliTPCRF1D;
+    }
+    if (fTreeD!=0) {
+      fRF->Delete();
+      fRF = new AliTPCRF1D;
+    }
+    R__b >>fParam;
+    R__b >>fPRF;
+    R__b >>fRF;    
+    SetTree();        
+  } else {
+    R__b.WriteVersion(AliTPCD::IsA());
+    TNamed::Streamer(R__b);     
+    R__b <<fParam;
+    R__b <<fPRF;
+    R__b <<fRF;     
+    if (fTreeD!=0) fTreeD->Write();         
+  } 
+}
diff --git a/TPC/AliTPCD.h b/TPC/AliTPCD.h
new file mode 100644 (file)
index 0000000..c4f410a
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef ALITPCD_H
+#define ALITPCD_H
+
+// include files and class forward declarations
+
+
+// Documentation
+/**
+  *   Object with the  TPC parameters 
+  *   
+  *
+  *
+  */
+#include "TNamed.h"
+#include "TTree.h"
+class AliTPCPRF2D;
+class AliTPCRF1D;
+class AliTPCParam;
+class TClonesArray;
+class TTree;
+class TDirectory;
+R__EXTERN TDirectory *  gDirectory;
+//class TBranch;
+
+class AliTPCD : public TNamed{
+
+public:
+  AliTPCD(
+         Text_t *  name ="DIGIT",
+         AliTPCParam *param=0, 
+         AliTPCPRF2D *prf=0, 
+         AliTPCRF1D *prfz=0);
+  ~AliTPCD();
+  
+public: 
+  AliTPCParam & GetParam() {return *fParam;}
+  //give us reference to the parameters
+  AliTPCPRF2D &  GetPRF2D() {return *fPRF;}
+  //give us reference to 2-dimensional pad response function object
+  //this is responsible for respnse in x and y dimension
+  AliTPCRF1D  &  GetRF() {return *fRF;}
+  //give us reference to 1 dimensionl response
+  //this is responsible for z-direction
+  TClonesArray * GetArray() {return fDigits;}
+  //return reference for digits array
+
+  TTree * GetTree() { return fTreeD;}
+  //return refeence to actual tree 
+  Bool_t  SetTree(Int_t nevent=0, TDirectory *dir = gDirectory);
+  //map tree from given directory
+  Bool_t  MakeTree(Int_t nevent=0);
+  //map tree from given directory
+   void Fill();
+protected:
+  
+public:
+  AliTPCParam * fParam;     //geometry and gas parameters object 
+  AliTPCPRF2D * fPRF;            //x and y pad response function object
+  AliTPCRF1D * fRF;             //z (time) response function object
+  TClonesArray *fDigits;    //aray of tpc Digits
+  TTree   *fTreeD;        //tree 
+private:
+  AliTPCD *fpthis;  //pointer to object
+  ClassDef(AliTPCD,2) 
+};
+
+
+#endif /* ALITPCD_H */
diff --git a/TPC/AliTPCDigitsDisplay.C b/TPC/AliTPCDigitsDisplay.C
new file mode 100644 (file)
index 0000000..a6e6455
--- /dev/null
@@ -0,0 +1,53 @@
+void AliTPCDigitsDisplay(int sec, int row,
+                 int max_t_chan=500, float min_t=0., float max_t=500.,
+                 int max_p_chan=200, float min_p=0., float max_p=200.)
+{
+// Dynamically link some shared libs
+   if (gClassTable->GetID("AliRun") < 0) {
+      gROOT->LoadMacro("loadlibs.C");
+      loadlibs();
+   } else {
+      delete gAlice;
+      gAlice=0;
+   }
+
+// Connect the Root Galice file containing Geometry, Kine and Hits
+   TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
+   if (f) f->Close();
+   f = new TFile("galice.root");
+
+   TClonesArray *fDigits=new TClonesArray("AliTPCdigit",10000);
+   TTree *t=(TTree*)f->Get("TreeD0_Param1");
+   t->GetBranch("Digits")->SetAddress(&fDigits);
+   Int_t sectors_by_rows=(Int_t)t->GetEntries();
+   for (Int_t n=0; n<sectors_by_rows; n++) {
+      if (!t->GetEvent(n)) continue;
+      AliTPCdigit *dig=(AliTPCdigit*)fDigits->UncheckedAt(0);
+
+      if (sec  < dig->fSector) break;
+      if (sec != dig->fSector) continue;
+      if (row != dig->fPadRow) continue;
+
+      char s[80];
+      sprintf(s,"Sector %d   Row %d\n",sec,row);
+      TH2F *h = new TH2F("h",s,max_t_chan,min_t,max_t,max_p_chan,min_p,max_p);
+      Int_t ndigits=fDigits->GetEntriesFast();
+      for (Int_t ndig=0; ndig<ndigits; ndig++) {
+         dig=(AliTPCdigit*)fDigits->UncheckedAt(ndig);
+         if (dig->fSignal < 0) continue; //cluster finder threshold
+         h->Fill(dig->fTime,dig->fPad,dig->fSignal);
+      }
+      h->SetMaximum(200);
+      gStyle->SetOptStat(0);
+      TCanvas *c1=new TCanvas("c1","TPC digits display",0,0,1110,680);
+      TPad *p1=new TPad("p1","",0,0,1,0.5);
+      p1->Draw();
+      TPad *p2=new TPad("p2","",0,0.5,1,1);
+      p2->Draw();
+      p2->cd();
+      h->Draw("lego");
+      p1->cd();
+      h->Draw("colz");
+   }
+}
+
diff --git a/TPC/AliTPCHits2Digits.C b/TPC/AliTPCHits2Digits.C
new file mode 100644 (file)
index 0000000..1358d97
--- /dev/null
@@ -0,0 +1,84 @@
+
+void AliTPCHits2Digits(const  char * name= "pokusD_")
+{
+  // Dynamically link some shared libs
+    if (gClassTable->GetID("AliRun") < 0) {
+     gROOT->LoadMacro("loadlibs.C");
+     loadlibs();
+   }
+  
+   //names of trees
+   const char * inFile = "galice.root";
+   //   const * char ident= "TreeD1par_";
+
+// Connect the Root Galice file containing Geometry, Kine and Hits
+   TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
+   if (file) file->Close();
+   file = new TFile(inFile,"UPDATE");
+// Get AliRun object from file or create it if not on file
+
+   if(gAlice){
+     delete gAlice;
+     gAlice=0;
+   }
+      if (!gAlice) {
+      gAlice = (AliRun*)file->Get("gAlice");
+      if (gAlice) printf("AliRun object found on file\n");
+      if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
+        }
+   gAlice->GetEvent(0);
+   AliTPC *TPC = (AliTPC*)gAlice->GetModule("TPC");      
+   TPC->Dump();
+   //adjust parameters
+  
+  AliTPCD *paramd = TPC->GetDigParam();
+  paramd->Dump();
+  paramd->SetName("Param1");  
+  paramd->MakeTree();
+  //set pointers to parameters
+  paramd->Dump();
+  AliTPCParam &param = paramd->GetParam();
+  AliTPCPRF2D &prf = paramd->GetPRF2D();
+  AliTPCRF1D  & rf  = paramd->GetRF();
+  
+  param.SetPadLength(2.05);
+  param.SetPadWidth(0.35);
+  param.SetPadPitchLength(2.05);
+  param.SetPadPitchWidth(0.35);
+  param.SetNWires(5);
+  param.SetZeroSup(5);
+  param.SetDiffT(0.022);
+  param.SetDiffL(0.022);
+  param.SetNoise(500);
+  param.SetGasGain(1.e4);
+  param.SetChipGain(24);      
+  param.Update();
+
+    //Set z (time) response function
+  rf.SetGauss(param.GetZSigma(),param.GetZWidth(),0.4);
+  rf.Update();
+  //Set two dimensional pad response function
+  TFile f("TPC/AliTPCprf2d.root");
+  //  prf.Read("prf_205035_Gati_062074_d03");
+  prf.Read("prf_205035_Gati_062074_d03");
+  f.Close();
+  
+  printf("**********Digit object dump start********************\n");
+  paramd->Dump();
+  printf("**********AliTPCParam**************************\n");
+  param.Dump();
+  printf("**********Time response function***************\n");
+  rf.Dump();
+  printf("**********Pad response function params*********\n");
+  prf.Dump();
+  printf("**********Digit object dump end********************\n");
+
+   TPC->Hits2DigitsSector(1);     
+         
+   file->cd();
+   TPC->GetDigParam()->Write();
+};
+
+
diff --git a/TPC/AliTPCPRF2D.cxx b/TPC/AliTPCPRF2D.cxx
new file mode 100644 (file)
index 0000000..6df2f6d
--- /dev/null
@@ -0,0 +1,734 @@
+///////////////////////////////////////////////////////////////////////////////
+//  AliTPCPRF2D -                                                                         //
+//  Pad response function object in two dimesions                            //
+//  This class contains the basic functions for the                          //
+//  calculation of PRF according generic charge distribution                 //
+//  In Update function object calculate table of response function           //
+//  in discrete x and y position                                             //
+// This table is used for interpolation od response function in any position //
+// (function GetPRF)                                                          //
+//                                                                           // 
+//  Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk          //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+#include "TMath.h"
+#include "AliTPCPRF2D.h"
+#include "TF2.h"
+#include <iostream.h>
+#include <string.h>
+#include "TCanvas.h"
+#include "TPad.h"
+#include "TStyle.h"
+#include "TH1.h"
+#include "TH2.h"
+#include "TPaveText.h"
+#include "TText.h"
+
+extern TStyle * gStyle;
+
+static const Float_t sqrt12=3.46;
+static const Int_t   NPRF = 100;
+
+
+static Double_t funGauss2D(Double_t *x, Double_t * par)
+{ 
+  return ( TMath::Exp(-(x[0]*x[0])/(2*par[0]*par[0]))*
+          TMath::Exp(-(x[1]*x[1])/(2*par[1]*par[1])));
+
+}
+
+static Double_t funCosh2D(Double_t *x, Double_t * par)
+{
+  return ( 1/(TMath::CosH(3.14159*x[0]/(2*par[0]))*
+          TMath::CosH(3.14159*x[1]/(2*par[1]))));
+}    
+
+static Double_t funGati2D(Double_t *x, Double_t * par)
+{
+  //par[1] = is equal to k3X
+  //par[0] is equal to pad wire distance
+  Float_t K3=par[1];
+  Float_t K3R=TMath::Sqrt(K3);
+  Float_t K2=(TMath::Pi()/2)*(1-K3R/2.);
+  Float_t K1=K2*K3R/(4*TMath::ATan(K3R));
+  Float_t l=x[0]/par[0];
+  Float_t tan2=TMath::TanH(K2*l);
+  tan2*=tan2;
+  Float_t res = K1*(1-tan2)/(1+K3*tan2);
+ //par[4] = is equal to k3Y
+  K3=par[4];
+  K3R=TMath::Sqrt(K3);
+  K2=(TMath::Pi()/2)*(1-K3R/2.);
+  K1=K2*K3R/(4*TMath::ATan(K3R));
+  l=x[1]/par[0];
+  tan2=TMath::TanH(K2*l);
+  tan2*=tan2;
+  res = res*K1*(1-tan2)/(1+K3*tan2);  
+  return res;  
+}   
+
+
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+
+ClassImp(AliTPCPRF2D)
+
+AliTPCPRF2D::AliTPCPRF2D()
+{
+  ffcharge = 0;
+  fNPRF =NPRF ;
+  fSigmaX = 0;
+
+  fGRF = 0;
+  fkNorm = 1;
+  forigsigmaY=0;
+  forigsigmaX=0;
+  fNdiv = 5;
+  //chewron default values   
+  SetPad(0.8,0.8);
+  SetChevron(0.2,0.0,1.0);
+  SetY(-0.2,0.2,2);
+  // SetGauss(0.22,0.22,1);  
+}
+
+AliTPCPRF2D::~AliTPCPRF2D()
+{
+  if (ffcharge!=0) delete [] ffcharge;
+  if (fGRF !=0 ) fGRF->Delete();
+}
+
+void AliTPCPRF2D::SetY(Float_t y1, Float_t y2, Int_t nYdiv)
+{
+  //
+  //set virtual line position
+  //first and last line and number of lines
+  fNYdiv = nYdiv;
+  if (ffcharge!=0) delete [] ffcharge;
+  ffcharge = new Float_t[fNPRF*fNYdiv];
+  fY1=y1;
+  fY2=y2;
+}
+
+void AliTPCPRF2D::SetPad(Float_t width, Float_t height)
+{
+  //set base chevron parameters
+ fHeightFull=height;
+ fWidth=width;
+}
+void AliTPCPRF2D::SetChevron(Float_t hstep, 
+                       Float_t shifty, 
+                       Float_t fac)
+{
+  //set shaping of chewron parameters
+  fHeightS=hstep;
+  fShiftY=shifty;
+  fK=fWidth*fac/hstep;
+}
+
+void AliTPCPRF2D::SetChParam(Float_t width, Float_t height,
+                 Float_t hstep, Float_t shifty, Float_t fac)
+{
+  SetPad(width,height);
+  SetChevron(hstep,shifty,fac);
+}
+
+
+Float_t AliTPCPRF2D::GetPRF(Float_t xin, Float_t yin, Bool_t inter)
+{
+  if (ffcharge==0) return 0;
+  //  Float_t y=Float_t(fNYdiv-1)*(yin-fY1)/(fY2-fY1);
+  //transform position to "wire position"
+  Float_t y=fDYtoWire*(yin-fY1);
+  if (fNYdiv == 1) y=fY1;
+  //normaly it find nearest line charge
+  if (inter ==kFALSE){   
+    Int_t i=Int_t(0.5+y);
+    if (y<0) i=Int_t(-0.5+y);
+    if ((i<0) || (i>=fNYdiv) ) return 0;
+    fcharge   = &(ffcharge[i*fNPRF]);
+    return GetPRFActiv(xin);
+  }
+  else{
+    //make interpolation from more fore lines
+    Int_t i= Int_t(y);
+    if ((i<0) || (i>=fNYdiv) ) return 0;
+    Float_t z0=0;
+    Float_t z1=0;
+    Float_t z2=0;
+    Float_t z3=0;
+    if (i>0) {
+      fcharge =&(ffcharge[(i-1)*fNPRF]);
+      z0 = GetPRFActiv(xin);
+    }
+    fcharge =&(ffcharge[i*fNPRF]);
+    z1=GetPRFActiv(xin);
+    if ((i+1)<fNYdiv){
+      fcharge =&(ffcharge[(i+1)*fNPRF]);
+      z2 = GetPRFActiv(xin);
+    }
+    if ((i+2)<fNYdiv){
+      fcharge =&(ffcharge[(i+2)*fNPRF]);
+      z3 = GetPRFActiv(xin);
+    }
+    Float_t a,b,c,d,K,L;
+    a=z1;
+    b=(z2-z0)/2.;
+    K=z2-a-b;
+    L=(z3-z1)/2.-b;
+    d=L-2*K;
+    c=K-d;
+    Float_t dy=y-Float_t(i);
+        Float_t res = a+b*dy+c*dy*dy+d*dy*dy*dy;  
+       //Float_t res = z1*(1-dy)+z2*dy;
+    return res;            
+  }        
+  return 0.;
+} 
+
+
+Float_t AliTPCPRF2D::GetPRFActiv(Float_t xin)
+{
+  //x xin DStep unit
+  //return splaine aproximaton 
+  Float_t x = (xin*fDStepM1)+fNPRF/2;
+  Int_t i = Int_t(x);
+  
+  if  ( (i>0) && ((i+2)<fNPRF)) {
+    Float_t a,b,c,d,K,L;
+    a = fcharge[i];
+    b = (fcharge[i+1]-fcharge[i-1])*0.5; 
+    K = fcharge[i+1]-a-b;
+    L = (fcharge[i+2]-fcharge[i])*0.5-b;
+    d=L-2.*K;
+    c=K-d;
+    Float_t dx=x-Float_t(i);
+    Float_t res = a+b*dx+c*dx*dx+d*dx*dx*dx;  
+    return res;
+  }
+  else return 0;
+}
+
+
+Float_t  AliTPCPRF2D::GetGRF(Float_t xin, Float_t yin)
+{  
+  if (fGRF != 0 ) 
+    return fkNorm*fGRF->Eval(xin,yin)/fInteg;
+      else
+    return 0.;
+}
+
+   
+void AliTPCPRF2D::SetParam( TF2 * GRF,  Float_t kNorm, 
+                      Float_t sigmaX, Float_t sigmaY)
+{
+   if (fGRF !=0 ) fGRF->Delete();
+   fGRF = GRF;
+   fkNorm = kNorm;
+   if (sigmaX ==0) sigmaX=(fWidth+fK*fHeightS)/sqrt12;
+   if (sigmaY ==0) sigmaY=(fWidth+fK*fHeightS)/sqrt12;
+   forigsigmaX=sigmaX; 
+   forigsigmaY=sigmaY; 
+   fDStep = TMath::Sqrt(sigmaX*sigmaX+fWidth*fWidth/6.)/10.; 
+   //   Update();   
+  sprintf(fType,"User");
+}
+  
+
+void AliTPCPRF2D::SetGauss(Float_t sigmaX, Float_t sigmaY,
+                     Float_t kNorm)
+{
+  fkNorm = kNorm;
+  if (fGRF !=0 ) fGRF->Delete();
+  fGRF = new TF2("fun",funGauss2D,-5.,5.,-5.,5.,4);
+  funParam[0]=sigmaX;
+  funParam[1]=sigmaY;  
+  funParam[2]=fK;
+  funParam[3]=fHeightS;    
+  forigsigmaX=sigmaX;
+  forigsigmaY=sigmaY;
+  fGRF->SetParameters(funParam);
+  fDStep = TMath::Sqrt(sigmaX*sigmaX+fWidth*fWidth/6.)/10.; 
+  //by default I set the step as one tenth of sigma
+  //Update();
+  sprintf(fType,"Gauss");
+}
+
+void AliTPCPRF2D::SetCosh(Float_t sigmaX, Float_t sigmaY,
+                    Float_t kNorm)
+{
+  fkNorm = kNorm;
+  if (fGRF !=0 ) fGRF->Delete();
+  fGRF = new TF2("fun",        funCosh2D,-5.,5.,-5.,5.,4);   
+  funParam[0]=sigmaX;
+  funParam[1]=sigmaY;
+  funParam[2]=fK;  
+  funParam[3]=fHeightS;
+  fGRF->SetParameters(funParam);
+  forigsigmaX=sigmaX;
+  forigsigmaY=sigmaY;
+  fDStep = TMath::Sqrt(sigmaX*sigmaX+fWidth*fWidth/6.)/10.; 
+  //by default I set the step as one tenth of sigma
+  //Update();
+  sprintf(fType,"Cosh");
+}
+
+void AliTPCPRF2D::SetGati(Float_t K3X, Float_t K3Y,
+                    Float_t padDistance,
+                    Float_t kNorm)
+{
+  fkNorm = kNorm;
+  if (fGRF !=0 ) fGRF->Delete();
+  fGRF = new TF2("fun",        funGati2D,-5.,5.,-5.,5.,5);  
+  fK3X=K3X;
+  fK3Y=K3Y;
+  fPadDistance=padDistance;
+  funParam[0]=padDistance;
+  funParam[1]=K3X;
+  funParam[2]=fK;  
+  funParam[3]=fHeightS;
+  funParam[4]=K3Y;
+  fGRF->SetParameters(funParam);
+  forigsigmaX=padDistance;
+  forigsigmaY=padDistance;
+  fDStep = TMath::Sqrt(padDistance*padDistance+fWidth*fWidth/6.)/10.; 
+  //by default I set the step as one tenth of sigma
+  //Update();
+  sprintf(fType,"Gati");
+}
+
+
+
+void AliTPCPRF2D::Update()
+{
+  for (Int_t i=0; i<fNYdiv; i++){
+    if (fNYdiv == 1) fActualY = fY1;
+    else
+      fActualY = fY1+Float_t(i)*(fY2-fY1)/Float_t(fNYdiv-1);
+    fcharge   = &(ffcharge[i*fNPRF]);
+    Update1();
+  }
+}
+
+
+
+void AliTPCPRF2D::Update1()
+{
+  //initialize to 0
+  
+
+  Int_t i;
+  Float_t x;
+  for (i =0; i<fNPRF;i++)  fcharge[i] = 0;
+  if ( fGRF == 0 ) return;
+  ////////////////////////////////////////////////////////
+  //I'm waiting for normal integral
+  //in this moment only sum
+  Float_t x2=  4*forigsigmaX;
+  Float_t y2=  4*forigsigmaY;
+  Float_t dx = forigsigmaX/Float_t(fNdiv*6);
+  Float_t dy = forigsigmaY/Float_t(fNdiv*6);  
+  fInteg  = 0;
+  for (x=0.;x<x2;x+=dx)
+    for (Float_t y=0;y<y2;y+=dy) fInteg+=fGRF->Eval(x,y)*dx*dy;
+  fInteg*=4;
+  /////////////////////////////////////////////////////
+      
+  
+  if ( fInteg == 0 ) fInteg = 1; 
+  
+    //integrate charge over pad for different distance of pad
+    for (i =0; i<fNPRF;i++)
+      {      //x in cm fWidth in cm
+       //calculate integral 
+       Float_t xch = fDStep * (Float_t)(i-fNPRF/2);
+       Float_t k=1;
+       fcharge[i]=0;
+       for (Float_t y=-fHeightFull/2.-fShiftY;
+            y<fHeightFull/2.;y+=fHeightS){
+         Float_t y2=TMath::Min((y+fHeightS),Float_t(fHeightFull/2.));
+         Float_t y1=TMath::Max((y),Float_t(-fHeightFull/2.));
+         Float_t x1;
+       
+         if (k>0) 
+           x1 = (y2-y1)*fK-(fWidth+fK*fHeightS)/2.;      
+         else
+           x1 =-(fWidth+fK*fHeightS)/2. ;        
+         Float_t x2=x1+fWidth;
+
+         if (y2>y1) {
+           
+            if ((x2-x1)*fNdiv<forigsigmaX) dx=(x2-x1);
+           else{
+             dx= forigsigmaX/Float_t(fNdiv);
+             dx = (x2-x1)/Float_t(Int_t(3+(x2-x1)/dx));          
+           }       
+           Float_t dy;
+           if ((y2-y1)*fNdiv<forigsigmaY) dy=(y2-y1);
+           else{             
+             dy= forigsigmaY/Float_t(fNdiv);
+             dy = (y2-y1)/Float_t(Int_t(3+(y2-y1)/dy));
+           }
+
+           for (x=x1;x<x2;x+=dx)
+             for (Float_t y=y1;y<y2;y+=dy){
+               if ( (y>(fActualY-(4.0*forigsigmaY))) &&
+                    (y<(fActualY+(4.0*forigsigmaY)))){
+                 Float_t xt=x-k*fK*(y-y1); 
+                 if ((TMath::Abs(xch-xt)<4*forigsigmaX)){
+                   
+                   Float_t z0=fGRF->Eval(xch-(xt+dx/2.),fActualY-(y+dy/2.));
+                   
+                   Float_t z1=fGRF->Eval(xch-(xt+dx/2.),fActualY-y);
+                   Float_t z2=fGRF->Eval(xch-xt,fActualY-(y+dy/2.));
+                   Float_t z3=fGRF->Eval(xch-(xt-dx/2.),fActualY-y);
+                   Float_t z4=fGRF->Eval(xch-xt,fActualY-(y-dy/2.));
+                   if (z0<0) z0=0;
+                   if (z1<0) z1=0;
+                   if (z2<0) z2=0;
+                   if (z3<0) z3=0;
+                   if (z4<0) z4=0;
+                   
+                   //        Float_t a=(z1-z3)/2;
+                   //        Float_t b=(z2-z4)/2;
+                   Float_t c= (z3+z1-2*z0)/2.;
+                   Float_t d= (z2+z4-2*z0)/2.;
+                   Float_t z= (z0+c/12.+d/12.);                                
+                   
+                   //Float_t z= fGRF->Eval(xch-xt,fActualY-y);
+                   if (z>0.)         fcharge[i]+=z*dx*dy/fInteg;             
+                 }
+               }
+             }
+         }
+         k*=-1;
+       }
+      };   
+  
+  fSigmaX = 0; 
+  Float_t sum =0;
+  Float_t mean=0;
+  for (x =-fNPRF*fDStep; x<fNPRF*fDStep;x+=fDStep)
+    {      //x in cm fWidth in cm
+      Float_t weight = GetPRFActiv(x);
+      fSigmaX+=x*x*weight; 
+      mean+=x*weight;
+      sum+=weight;
+    };  
+  if (sum>0){
+    mean/=sum;
+    fSigmaX = TMath::Sqrt(fSigmaX/sum-mean*mean);   
+  }
+  else fSigmaX=0; 
+  //calculate conversion coefitient to convert position to virtual wire
+  fDYtoWire=Float_t(fNYdiv-1)/(fY2-fY1);
+  fDStepM1=1/fDStep;
+}
+
+void AliTPCPRF2D::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class AliTPCPRF2D
+
+   if (R__b.IsReading()) {
+      Version_t R__v = R__b.ReadVersion(); if (R__v) { }
+      TObject::Streamer(R__b);     
+      //read chewron parameters
+      R__b >> fSigmaX;
+      R__b >> fHeightFull;
+      R__b >> fHeightS;
+      R__b >> fShiftY;
+      R__b >> fWidth;
+      R__b >> fK;
+      R__b >> fActualY;
+      //read charge parameters
+      R__b >> fType[0];
+      R__b >> fType[1];
+      R__b >> fType[2];
+      R__b >> fType[3];
+      R__b >> fType[4];
+      R__b >> forigsigmaX;
+      R__b >> forigsigmaY;
+      R__b >> fkNorm;
+      R__b >> fK3X;
+      R__b >> fK3Y;
+      R__b >> fPadDistance;
+      R__b >> fInteg;
+      
+      //read functions
+      if (fGRF!=0) { 
+       delete [] fGRF;  
+       fGRF=0;
+      }
+      if (strncmp(fType,"User",3)==0){
+       fGRF= new TF2;
+       R__b>>fGRF;   
+      }
+      if (strncmp(fType,"Gauss",3)==0) 
+       fGRF = new TF2("fun",funGauss2D,-5.,5.,-5.,5.,4);
+      if (strncmp(fType,"Cosh",3)==0) 
+       fGRF = new TF2("fun",funCosh2D,-5.,5.,-5.,5.,4);
+       if (strncmp(fType,"Gati",3)==0) 
+       fGRF = new TF2("fun",funGati2D,-5.,5.,-5.,5.,5);
+      
+      //read interpolation parameters
+      R__b >>fY1;
+      R__b >>fY2;
+      R__b >>fNYdiv;  
+      R__b >>fDStep;  
+      R__b >>fNPRF;
+      if (ffcharge!=0) delete [] ffcharge;
+      ffcharge = new Float_t[fNPRF*fNYdiv];
+      R__b.ReadFastArray(ffcharge,fNPRF*fNYdiv); 
+      R__b.ReadFastArray(funParam,5); 
+      if (fGRF!=0) fGRF->SetParameters(funParam);
+      //calculate conversion coefitient to convert position to virtual wire
+      fDYtoWire=Float_t(fNYdiv-1)/(fY2-fY1);
+      fDStepM1=1/fDStep;
+   } else {
+      R__b.WriteVersion(AliTPCPRF2D::IsA());
+      TObject::Streamer(R__b);      
+      //write chewron parameters
+      R__b << fSigmaX;
+      R__b << fHeightFull;
+      R__b << fHeightS;
+      R__b << fShiftY;
+      R__b << fWidth;
+      R__b << fK;
+      R__b << fActualY;
+      //write charge parameters
+      R__b << fType[0];
+      R__b << fType[1];
+      R__b << fType[2];
+      R__b << fType[3];
+      R__b << fType[4];
+
+      R__b << forigsigmaX;
+      R__b << forigsigmaY;
+      R__b << fkNorm;
+      R__b << fK3X;
+      R__b << fK3Y;
+      R__b << fPadDistance;  
+      R__b << fInteg;
+
+      if (strncmp(fType,"User",3)==0)  R__b <<fGRF;         
+      //write interpolation parameters
+      R__b <<fY1;
+      R__b <<fY2;
+      R__b <<fNYdiv;   
+      R__b <<fDStep;
+      R__b <<fNPRF;    
+      R__b.WriteFastArray(ffcharge,fNPRF*fNYdiv); 
+      R__b.WriteFastArray(funParam,5); 
+   }
+}
+
+
+
+
+void AliTPCPRF2D::DrawX(Float_t x1 ,Float_t x2,Float_t y, Bool_t inter)
+{ 
+  if (fGRF==0) return ;
+  const Int_t N=100;
+  char s[100];
+  TCanvas  * c1 = new TCanvas("canPRF","Pad response function",700,900);
+  c1->cd();
+  TPad * pad1 = new TPad("pad1PRF","",0.05,0.61,0.95,0.97,21);
+  pad1->Draw();
+  TPad * pad2 = new TPad("pad2PRF","",0.05,0.22,0.95,0.60,21);
+  pad2->Draw();
+
+  //  pad1->cd();  
+  //pad2->cd();
+  gStyle->SetOptFit(1);
+  gStyle->SetOptStat(0); 
+  sprintf(s,"PRF response function for chevron pad");  
+  TH1F * hPRFc = new TH1F("hPRFc",s,N+1,x1,x2);
+  Float_t x=x1;
+  Float_t y1;
+  //  Float_t y2;
+
+  for (Float_t i = 0;i<N+1;i++)
+    {
+      x+=(x2-x1)/Float_t(N);
+      y1 = GetPRF(x,y,inter);
+      hPRFc->Fill(x,y1);
+    };
+
+  pad1->cd();
+  fGRF->SetRange(x1,x1,x2,x2); 
+  fGRF->SetNpx(25);
+  fGRF->SetNpy(25); 
+  fGRF->Draw("lego2");
+  // hPRFo->Fit("gaus");
+  gStyle->SetOptStat(1); 
+  pad2->cd();
+  hPRFc->Fit("gaus");
+  c1->cd(); 
+  TPaveText * comment = new TPaveText(0.05,0.02,0.95,0.20,"NDC");
+  comment->SetTextAlign(12);
+  comment->SetFillColor(42);
+  TText *title = comment->AddText("Chevron pad parameters:");
+  title->SetTextSize(0.03);
+  sprintf(s,"Full height of pad:  %2.2f",fHeightFull);
+  comment->AddText(s);
+  sprintf(s,"Height of one chevron unit h:  %2.2f cm",2*fHeightS);
+  comment->AddText(s);
+  sprintf(s,"Width of one chevron unit  w:  %2.2f cm",fWidth);
+  comment->AddText(s);
+  sprintf(s,"Overlap factor:  %2.2f",fK*fHeightS/fWidth);
+  comment->AddText(s);
+  sprintf(s,"Y position:  %2.2f ",y);
+  comment->AddText(s);
+  sprintf(s,"Sigma x of original distribution: %2.2f ",forigsigmaX);
+  comment->AddText(s);  
+  sprintf(s,"Sigma y of original distribution: %2.2f ",forigsigmaY);
+  comment->AddText(s);    
+  sprintf(s,"Type of original distribution: %s ",fType);
+  comment->AddText(s); 
+  comment->Draw();
+}
+
+
+
+void AliTPCPRF2D::Draw(Float_t x1 ,Float_t x2,Float_t y1, Float_t y2, 
+                 Bool_t inter, Int_t Nx, Int_t Ny)
+{ 
+  char s[100];
+  if (fGRF==0) return ;
+  TCanvas  * c1 = new TCanvas("canPRF","Pad response function",700,900);
+  c1->cd();
+  TPad * pad1 = new TPad("pad1PRF","",0.05,0.61,0.95,0.97,21);
+  pad1->Draw();
+  TPad * pad2 = new TPad("pad2PRF","",0.05,0.22,0.95,0.60,21);
+  pad2->Draw();
+
+  //  pad1->cd();  
+  //pad2->cd();
+  gStyle->SetOptFit(1);
+  gStyle->SetOptStat(0); 
+  sprintf(s,"PRF response function for chevron pad");  
+  TH2F * hPRFc = new TH2F("hPRFc",s,Nx+1,x1,x2,Ny+1,y1,y2);
+  Float_t dx=(x2-x1)/Float_t(Nx);
+  Float_t dy=(y2-y1)/Float_t(Ny) ;
+  Float_t x,y,z;
+  //  Float_t y2;
+  for ( x = x1;x<=x2;x+=dx){
+    for(y = y1;y<=y2;y+=dy)
+      {
+       z = GetPRF(x,y,inter);
+       hPRFc->Fill(x,y,z);
+      };
+  }
+  pad1->cd();
+  fGRF->SetRange(x1,y1,x2,y2); 
+  fGRF->SetNpx(25);
+  fGRF->SetNpy(25); 
+  fGRF->Draw("lego2");
+  // hPRFo->Fit("gaus");
+  gStyle->SetOptStat(1); 
+  pad2->cd();
+  hPRFc->Draw("lego2");
+  c1->cd(); 
+  TPaveText * comment = new TPaveText(0.05,0.02,0.95,0.20,"NDC");
+  comment->SetTextAlign(12);
+  comment->SetFillColor(42);
+  TText *title = comment->AddText("Chevron pad parameters:");
+  title->SetTextSize(0.03);
+  sprintf(s,"Full height of pad:  %2.2f",fHeightFull);
+  comment->AddText(s);
+  sprintf(s,"Height of one chevron unit h:  %2.2f cm",2*fHeightS);
+  comment->AddText(s);
+  sprintf(s,"Width of one chevron unit  w:  %2.2f cm",fWidth);
+  comment->AddText(s);
+  sprintf(s,"Overlap factor:  %2.2f",fK*fHeightS/fWidth);
+  comment->AddText(s); 
+  sprintf(s,"Sigma x of original distribution: %2.2f ",forigsigmaX);
+  comment->AddText(s);  
+  sprintf(s,"Sigma y of original distribution: %2.2f ",forigsigmaY);
+  comment->AddText(s);    
+  sprintf(s,"Type of original distribution: %s ",fType);
+  comment->AddText(s); 
+  comment->Draw();
+}
+
+void AliTPCPRF2D::DrawDist(Float_t x1 ,Float_t x2,Float_t y1, Float_t y2, 
+                 Bool_t inter, Int_t Nx, Int_t Ny, Float_t thr)
+{ 
+  const Float_t minth=0.00001;
+  if (thr<minth) thr=minth;
+  char s[100];
+  if (fGRF==0) return ;
+  TCanvas  * c1 = new TCanvas("padDistortion","COG distortion",700,900);
+  c1->cd();
+  TPad * pad1 = new TPad("CHARGE","",0.05,0.61,0.95,0.97,21);
+  pad1->Draw();
+  TPad * pad2 = new TPad("dist","",0.05,0.22,0.95,0.60,21);
+  pad2->Draw();
+
+  //  pad1->cd();  
+  //pad2->cd();
+  gStyle->SetOptFit(1);
+  gStyle->SetOptStat(0); 
+  sprintf(s,"COG distortion (threshold=%2.2f)",thr);  
+  TH2F * hPRFDist = new TH2F("hDistortion",s,Nx+1,x1,x2,Ny+1,y1,y2);
+  Float_t dx=(x2-x1)/Float_t(Nx);
+  Float_t dy=(y2-y1)/Float_t(Ny) ;
+  Float_t x,y,z,ddx;
+  //  Float_t y2;
+  for ( x = x1;x<(x2+dx/2.);x+=dx)
+    for(y = y1;y<=(y2+dx/2.);y+=dy)
+      {
+       Float_t sumx=0;
+       Float_t sum=0;
+       for (Float_t padx=-fWidth;padx<(fWidth*1.1);padx+=fWidth)
+         {         
+           z = GetPRF(x-padx,y,inter);
+           if (z>thr){
+             sum+=z;
+             sumx+=z*padx;
+           }   
+         };    
+       if (sum>minth)  
+         {
+           ddx = (x-(sumx/sum));
+         }
+       else ddx=-1;
+       if (TMath::Abs(ddx)<10)         hPRFDist->Fill(x,y,ddx);
+      }
+  pad1->cd();
+  fGRF->SetRange(x1,y1,x2,y2); 
+  fGRF->SetNpx(25);
+  fGRF->SetNpy(25); 
+  fGRF->Draw("lego2");
+  // hPRFo->Fit("gaus");
+  //  gStyle->SetOptStat(1); 
+  pad2->cd();
+  hPRFDist->Draw("lego2");
+  
+  c1->cd(); 
+  TPaveText * comment = new TPaveText(0.05,0.02,0.95,0.20,"NDC");
+  comment->SetTextAlign(12);
+  comment->SetFillColor(42);
+  //  TText *title = comment->AddText("Distortion of COG method");
+  //  title->SetTextSize(0.03);
+  TText * title = comment->AddText("Chevron pad parameters:");
+  title->SetTextSize(0.03);
+  sprintf(s,"Full height of pad:  %2.2f",fHeightFull);
+  comment->AddText(s);
+  sprintf(s,"Height of one chevron unit h:  %2.2f cm",2*fHeightS);
+  comment->AddText(s);
+  sprintf(s,"Width of one chevron unit  w:  %2.2f cm",fWidth);
+  comment->AddText(s);
+  sprintf(s,"Overlap factor:  %2.2f",fK*fHeightS/fWidth);
+  comment->AddText(s); 
+  sprintf(s,"Sigma x of original distribution: %2.2f ",forigsigmaX);
+  comment->AddText(s);  
+  sprintf(s,"Sigma y of original distribution: %2.2f ",forigsigmaY);
+  comment->AddText(s);    
+  sprintf(s,"Type of original distribution: %s ",fType);
+  comment->AddText(s); 
+  comment->Draw();
+  
+}
+
diff --git a/TPC/AliTPCPRF2D.h b/TPC/AliTPCPRF2D.h
new file mode 100644 (file)
index 0000000..8982cdd
--- /dev/null
@@ -0,0 +1,105 @@
+#ifndef ALITPCPRF2D_H
+#define ALITPCPRF2D_H
+////////////////////////////////////////////////
+//  Manager class for AliTPCPRF2D                  //
+////////////////////////////////////////////////
+  
+
+// include files and class forward declarations
+//DSTEP in cm
+//NPRF in number of interpolation points
+
+
+#include "TObject.h"
+#include "TMath.h"
+class TF2;
+class TArrayF; 
+
+class AliTPCPRF2D : public TObject {
+public : 
+  AliTPCPRF2D();
+  ~AliTPCPRF2D();
+
+  Float_t GetGRF(Float_t xin, Float_t yin); 
+  //return generic response function  in xin
+  Float_t GetPRF(Float_t xin, Float_t yin, Bool_t inter=kFALSE); 
+  //return PRF in point xin,yin
+  void SetY(Float_t y1, Float_t y2, Int_t nYdiv) ;
+  void DrawX(Float_t x1, Float_t x2,Float_t y, Bool_t inter=kFALSE);  
+  //draw one dimensional response for
+  //fixed y
+  // void DrawY(Float_t y1, Float_t y2,Float_t x);
+  //draw one dimensional response for fixed x
+  void Draw(Float_t x1, Float_t x2, Float_t y1, Float_t y2,
+           Bool_t inter=kFALSE, Int_t Nx=20, Int_t Ny=20);
+  //draw two dimensional PRF
+
+  void DrawDist(Float_t x1, Float_t x2, Float_t y1, Float_t y2,
+               Bool_t inter=kFALSE, Int_t Nx=20, Int_t Ny=20, 
+               Float_t  thr=0);
+  //draw distortion of COG method
+  //we suppose threshold equal to thr
+   
+  void SetGauss(Float_t sigmaX,Float_t sigmaY , Float_t kNorm=1);
+  //adjust PRF with GAUSIAN as generic GRF 
+  //if  direct = kTRUE then it does't convolute distribution
+  void SetCosh(Float_t sigmaX,Float_t sigmaY , Float_t kNorm=1);
+  //adjust PRF with 1/Cosh  as generic GRF
+  void  SetGati(Float_t K3X, Float_t K3Y,
+                    Float_t padDistance,
+                    Float_t kNorm=1);
+  void SetParam(TF2 * GRF,Float_t kNorm, 
+               Float_t sigmaX=0, Float_t sigmaY=0);
+  void SetPad(Float_t width, Float_t height);
+  //set base chevron parameters
+  void SetChevron(Float_t hstep, Float_t shifty, Float_t fac);
+  //set chevron parameters   
+  void SetChParam(Float_t width, Float_t height,
+                 Float_t hstep, Float_t shifty, Float_t fac);
+  //set all geometrical parameters  
+  void SetNdiv(Int_t Ndiv){fNdiv=Ndiv;}
+  void Update();  
+protected:
+  void Update1();  
+  Float_t GetPRFActiv(Float_t xin); //return PRF in point xin and actual y
+  Float_t  * fcharge; // field with PRF 
+  Float_t fY1;
+  Float_t fY2;
+  Int_t fNYdiv;  
+  Float_t * ffcharge;  //pointer to array of arrays
+
+private: 
+  Double_t funParam[5];//parameters of used charge function
+  Int_t  fNPRF;      //number of interpolations point
+  Int_t  fNdiv;      //number of division to calculate integral
+  Float_t fDStep;    //element step for point 
+  Float_t fkNorm;     //normalisation factor of the charge integral
+  Float_t fInteg;     //integral of GRF on +- infinity
+  TF2 *  fGRF;        //charge distribution function
+
+  Float_t fK3X;
+  Float_t fK3Y;
+  Float_t fPadDistance;
+
+  Float_t  forigsigmaX;//sigma of original distribution;  
+  Float_t  forigsigmaY;//sigma of original distribution;  
+  Float_t fSigmaX;     //sigma of PAD response function
+  //calculated during update
+
+  //chewron parameters
+  Float_t fHeightFull;  //height of the full pad
+  Float_t fHeightS;     //height of the one step
+  Float_t fShiftY;  //shift of the step
+  Float_t fWidth;       //width of the pad
+  Float_t fK;           //k factor of the chewron
+  Float_t fActualY;          //in reality we calculate PRF only for 
+  //one fixed y
+  char  fType[5];  //charge type
+  //to make calculation faster we reduce  division
+  Float_t fDYtoWire;    //used to make PRF calculation faster in GetPRF
+  Float_t fDStepM1;     //used in GetPRFActiv
+  ClassDef(AliTPCPRF2D,1) 
+}; 
+
+#endif /* ALITPCPRF2D_H */
+  
diff --git a/TPC/AliTPCParam.cxx b/TPC/AliTPCParam.cxx
new file mode 100644 (file)
index 0000000..f111511
--- /dev/null
@@ -0,0 +1,503 @@
+///////////////////////////////////////////////////////////////////////
+//  Manager and of geomety  classes for set: TPC                     //
+//                                                                   //
+//  Origin:  Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk // 
+//                                                                   //  
+///////////////////////////////////////////////////////////////////////
+
+// MI change global variables for geometry 
+// declaration of the global static variable 
+// of AliTPCParam objects
+
+#include <iostream.h>
+#include <TMath.h>
+//#include <TObject.h>
+#include "AliTPCParam.h"
+//some old TPC parameters in AliTPCSecGeo.h
+#include "AliTPCSecGeo.h"
+
+
+ClassImp(AliTPCParam)
+
+// default values  
+
+const  Float_t kInnerRadiusLow = 89.45;
+const  Float_t kOuterRadiusLow = 143.725;
+const  Float_t kInnerRadiusUp  = 134.55;
+const  Float_t kOuterRadiusUp  = 248.275;
+
+const Float_t kPadPitchLength = 2.05;
+const Float_t kPadPitchWidth = 0.35;
+const Float_t kPadLength = 2.05;
+const Float_t kPadWidth = 0.35;
+//  Number of wires per pad and wire-wire pitch
+const Int_t knWires = 5;
+const  Float_t  kDiffT = 2.2e-2; 
+const  Float_t  kDiffL = 2.2e-2; 
+const  Float_t  kDriftV  =2.85e6;
+
+const  Float_t  kOmegaTau = 0.145;
+const  Float_t  kAttCoef = 250.;
+const  Float_t  kOxyCont = 5.e-6;
+
+
+
+const  Float_t  kChipGain = 24;
+const  Float_t  kGasGain = 1e4;
+const  Float_t  kTSample = 2.e-7; //TSAMPLE
+const  Float_t  kTFWHM   = 2.5e-7;  //fwhm of charge distribution
+const  Float_t  kNoise = 500;  //default noise = 1000 el 
+const  Int_t  kZeroSup=5;
+const  Float_t  kPadCoupling=0.5;
+// 
+const  Float_t  kEdgeSectorSpace = 5.26;
+
+
+
+
+//___________________________________________
+AliTPCParam::AliTPCParam()
+{   
+  //constructor set the default parameters
+  SetDefault();  
+}
+
+
+void AliTPCParam::CRXYZtoXYZ(Float_t *xyz,
+              const Int_t &sector, const Int_t & padrow, Int_t option) const  
+{  
+  //transform relative coordinates to absolute
+  Bool_t rel = ( (option&2)!=0);
+  Float_t row_first; 
+  row_first = (sector<25) ? fPadRowLow[0] : fPadRowUp[0]; 
+  if (rel==kTRUE)  //if we have 
+    {
+      xyz[0]+=row_first;
+      xyz[0]+=(Int_t) padrow*fPadPitchLength;
+    }  
+  if (sector<25) 
+    if ( sector>12)    xyz[2]*=-1.;
+  else 
+     if (sector>48)    xyz[2]*=-1;       
+  Float_t x1=xyz[0];
+  Float_t y1=xyz[1];
+  Float_t cos,sin;
+  AdjustAngles(sector,cos,sin);
+  xyz[0]=x1*cos - y1*sin;
+  xyz[1]=x1*sin + y1*cos;
+}
+
+void AliTPCParam::XYZtoCRXYZ(Float_t *xyz,
+                            Int_t &sector, Int_t & padrow, Int_t option)
+{
+   //transform global position to the position relative to the sector padrow
+  //if option=0  X calculate absolute            calculate sector
+  //if option=1  X           absolute            use input sector
+  //if option=2  X           relative to pad row calculate sector
+  //if option=3  X           relative            use input sector
+  //!!!!!!!!! WE start to calculate rows from row = 0
+  
+  Bool_t rel = ( (option&2)!=0);  
+  //option 0 and 2  means that we don't have information about sector
+  //we calculate sector
+  if ((option&1)==0){
+    Float_t angle;
+    Float_t r = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
+    if ((xyz[0]==0)&&(xyz[1]==0)) angle = 0;
+    else
+      {
+       angle =TMath::ASin(xyz[1]/r);
+       if   (xyz[0]<0)   angle=TMath::Pi()-angle;
+       if ( (xyz[0]>0) && (xyz[1]<0) ) angle=2*TMath::Pi()+angle;
+      }
+  //transform global position to the position relative to the sector padrow
+  //fistly calculate xyz[0] "polomer for lover sector
+    sector=Int_t(angle/alpha_low)+1;      
+    Float_t x1;
+    Float_t y1;
+    //firstly we suppose that we are in inner sector
+    Float_t cos,sin;
+    AdjustAngles(sector,cos,sin);
+
+    x1=xyz[0]*cos + xyz[1]*sin;
+    y1=-xyz[0]*sin + xyz[1]*cos;
+    if (x1>fOuterRadiusLow)
+      {
+       sector=Int_t(angle/alpha_up)+25;
+       AdjustAngles(sector,cos,sin);        
+       x1=xyz[0]*cos + xyz[1]*sin;
+       y1=-xyz[0]*sin + xyz[1]*cos;      
+       if (xyz[2]<0)   sector+=24;            
+      }
+    else   
+      if (xyz[2]<0) sector+=12;    
+    if (xyz[2]<0) xyz[2]=-xyz[2];  
+  if  (x1<fOuterRadiusLow)   
+    padrow =Int_t( (x1-fPadRowLow[0])/fPadPitchLength+0.5);
+  else
+    padrow = Int_t( (x1-fPadRowUp[0])/fPadPitchLength+0.5);
+  if (rel==kTRUE)
+      if (x1<fOuterRadiusLow)   x1-=padrow*fPadPitchLength+fPadRowLow[0];
+      else
+       x1-=padrow*fPadPitchLength+fPadRowUp[0];  
+   xyz[0]=x1;
+   xyz[1]=y1;    
+  }
+  else{
+    //if we have information about sector
+    Float_t cos,sin;
+    AdjustAngles(sector,cos,sin);   
+    Float_t x1;
+    Float_t y1;
+    //rotate to given sector
+    x1=xyz[0]*cos + xyz[1]*sin;
+    y1=-xyz[0]*sin + xyz[1]*cos; 
+    //calculate pad row number
+    if (sector<25) {
+      padrow =Int_t( (x1-fPadRowLow[0])/fPadPitchLength+1.5)-1;
+      if ( sector>12)  xyz[2]=-xyz[2];
+    }
+    else {
+      padrow =Int_t( (x1-fPadRowUp[0])/fPadPitchLength+1.5)-1;
+      if (sector>48)    xyz[2]=-xyz[2];      
+    }
+    //if we store relative position calculate position relative to pad row
+    if (rel==kTRUE){
+      if (sector<25)
+       x1-=padrow*fPadPitchLength+fPadRowLow[0];
+      else 
+       x1-=padrow*fPadPitchLength+fPadRowUp[0];
+    }      
+    xyz[0]=x1;
+    xyz[1]=y1;
+  }
+}
+
+void AliTPCParam::CRYZtoTimePad(const Float_t &y, const Float_t &z,
+                               Float_t &time, Float_t &pad,
+                               Int_t sector, Int_t padrow)
+{
+  //transform position in cm to position in time slices and pads
+  Float_t  nofpads = (sector < 25) ? fnPadsLow[padrow] : fnPadsUp[padrow];
+  Float_t padc=(nofpads+1)/2; // this is the "central" pad for a row
+  pad = y/(fPadPitchWidth)+padc;
+  time=(z_end-z)/(fDriftV*fTSample);  
+  //  cout<<y<<"  "<<z<<"   "<<time<<"    "<<pad<<"  "<<
+  //    sector<<"   "<<padrow<<"\n";   
+}
+void AliTPCParam::CRTimePadtoYZ(Float_t &y, Float_t &z,
+                               const Float_t &time, const Float_t &pad,
+                               Int_t sector, Int_t padrow)
+{
+  //transform position in time slices and pads  to cm 
+   Float_t  nofpads = (sector < 25) ? fnPadsLow[padrow] : fnPadsUp[padrow];
+   Float_t padc=(nofpads+1)/2; // this is the "central" pad for a row
+   y=(pad-padc)*fPadPitchWidth;
+   z=z_end-time*(fDriftV*fTSample);
+   //   cout<<y<<"  "<<z<<"   "<<time<<"    "<<pad<<"  "<<
+   //    sector<<"   "<<padrow<<"\n";  
+}
+
+Int_t AliTPCParam::GetWire(Float_t & x)
+{
+  //
+  //return wire number of pad for electron at relative position x
+  //to the center of the pad
+  //and adjust x to the wire position
+  //we suppose that if the wire number is even the center wire
+  //is at center of pad
+  //
+  Float_t xrel= x/fWWPitch;
+  if ((fnWires>>1)==0) xrel+=1;
+  else  xrel+=0.5;
+  Int_t nw=Int_t(xrel);
+  if (xrel<0) nw-=1;
+  
+  x=(nw*fWWPitch);
+  if ((fnWires>>1)==0) x-=fWWPitch/2.;
+  return nw;
+}
+
+Int_t AliTPCParam::GetIndex(Int_t sector, Int_t row)
+{
+  //
+  //give index of the given sector and pad row 
+  //no control if the sectors and rows  are reasonable !!!
+  //
+  if (sector<25) return (sector-1)*fnRowLow+row;
+  return (24*fnRowLow)+(sector-25)*fnRowUp+row;  
+}
+
+Bool_t   AliTPCParam::AdjustSectorRow(Int_t index, Int_t & sector, Int_t &row)
+{
+  //
+  //return sector and padrow for given index
+  //if index is reasonable return true else return false
+  //
+  if ( (index<0) || (index>fNtRows))  return kFALSE;
+  Int_t outindex = 24*fnRowLow;
+  if (index<outindex) {
+    sector = index/fnRowLow;
+    row    = index - sector*fnRowLow;
+    sector++;
+    return kTRUE;
+  }
+  index-= outindex;
+  sector = index/fnRowUp;
+  row    = index - sector*fnRowUp;
+  sector++;
+  return kTRUE;         
+} 
+
+
+
+Int_t AliTPCParam::GetPadRow(Int_t isec, Float_t  &x)
+{
+  //
+  //return the pad row for given x (transformed) 
+  //
+  Float_t row_first=GetPadRowRadii(isec,0);
+  Int_t row = Int_t(( x-row_first+1.5*fPadPitchLength)/fPadPitchLength)-1;
+  //Int_t will make from -0.5 0 but we want to make -1 so we add and after substract 1
+  x -=row* fPadPitchLength+row_first;
+  if (  (row<0)||(row>=GetNRow(isec))) return -1;
+  else return row;  
+}
+
+void AliTPCParam::SetDefault()
+{
+  //set default TPC param   
+  fbStatus = kFALSE;
+  //set radius parameters
+  fInnerRadiusLow = kInnerRadiusLow;
+  fOuterRadiusLow = kOuterRadiusLow;
+  fInnerRadiusUp  = kInnerRadiusUp;
+  fOuterRadiusUp  = kOuterRadiusUp; 
+  // set default pad size and shape
+  fPadPitchLength  = kPadPitchLength;
+  fPadPitchWidth   = kPadPitchWidth;
+  fPadLength  = kPadLength;
+  fPadWidth   = kPadWidth;   
+  //
+  fnWires = knWires;
+  fWWPitch= kPadPitchLength/Float_t(knWires);
+  fDiffT  = kDiffT;
+  fDiffL  = kDiffL;
+  fOmegaTau = kOmegaTau;
+  fOxyCont  = kOxyCont;
+  fAttCoef  = kAttCoef;
+  fNoise  = kNoise;
+  fChipGain = kChipGain;
+  fGasGain = kGasGain;
+  fZeroSup= kZeroSup;
+  fPadCoupling= kPadCoupling;
+  fTSample =kTSample;
+  fTSigma  =kTFWHM/2.35; 
+  fDriftV=kDriftV;
+  //calculate sin and cosine of rotations angle   
+  for (Int_t i=1; i<80; i++)
+    {
+      Float_t angle;
+      if(i < 25){
+       angle = (i < 13) ? (i-1)*alpha_low : (i-13)*alpha_low;
+      }
+      else {
+       angle = (i < 49) ? (i-25)*alpha_up : (i-49)*alpha_up;
+      }
+      fRotAngle[i]=TMath::Cos(angle);
+      fRotAngle[100+i]=TMath::Sin(angle);
+    }
+  fbStatus = Update();
+}
+
+void  AliTPCParam::AdjustAngles(Int_t isec, Float_t &cos, Float_t &sin) const
+{
+  //set cosinus and sinus of rotation angles for sector isec
+  cos=fRotAngle[isec];
+  sin=fRotAngle[100+isec];
+}
+          
+Bool_t AliTPCParam::Update()
+{
+  fbStatus = kFALSE;
+  Int_t i;
+  //recalculate and check some geometric parameters 
+  if (0.001>fPadPitchLength){
+    cout<<"ERROR !!! Small pad pitch length \n"<<flush;
+    return kFALSE;
+  }
+
+  if (fPadPitchLength<fPadLength) {
+    cout<<"ERROR !!! Pitch length  smaller then length of pad \n"<<flush;
+    return kFALSE;
+  } 
+
+  fnRowUp   = Int_t((0.01+fOuterRadiusUp-fOuterRadiusLow)/fPadPitchLength)+1; 
+  if ( kMaxRows<fnRowUp) fnRowUp = kMaxRows;
+  if (1>fnRowUp) return kFALSE;
+
+  fnRowLow   = Int_t((0.01+fInnerRadiusUp-fInnerRadiusLow)/fPadPitchLength)+1;
+  if ( kMaxRows<fnRowLow) fnRowUp = kMaxRows;
+  if (1>fnRowLow) return kFALSE;
+  // adjust upper sectors pad row positions and pad numbers
+  for (i = 0;i<fnRowUp;i++) 
+    {
+       Float_t x  = fOuterRadiusLow +fPadPitchLength*(Float_t)i;
+       Float_t y = (x-0.5*fPadPitchLength)*2.*tan(alpha_up/2)-kEdgeSectorSpace;
+       fPadRowUp[i] = x;
+       fnPadsUp[i] = (Int_t)(y/fPadPitchWidth) ;        
+       if ((fnPadsUp[i]%2) == 0) fnPadsUp[i]-=1;        
+    }
+  // adjust lower sectors pad row positions and pad numbers 
+  for (i = 0;i<fnRowLow;i++) 
+    {
+       Float_t x  = fInnerRadiusLow +fPadPitchLength*(Float_t)i;
+       Float_t y = (x-0.5*fPadPitchLength)*2.*tan(alpha_low/2)-kEdgeSectorSpace;
+       fPadRowLow[i] = x;
+       fnPadsLow[i] = (Int_t)(y/fPadPitchWidth) ;
+       if ((fnPadsLow[i]%2) == 0) fnPadsLow[i]-=1;        
+    }
+
+  //that variable are not writen to the file there are calculated
+  //
+  fWWPitch= fPadPitchLength/Float_t(fnWires);
+  fZWidth = fTSample*fDriftV;  
+  fNtRows = 24*fnRowLow+48*fnRowUp;
+
+  fbStatus = kTRUE;
+  return kTRUE;
+}
+
+
+
+Bool_t AliTPCParam::GetStatus()
+{
+  //get information about object consistency
+  return fbStatus;
+}
+
+Int_t AliTPCParam::GetNRowLow() const
+{
+  //get the number of pad rows in low sector
+  return fnRowLow;
+}
+Int_t AliTPCParam::GetNRowUp() const
+{
+  //get the number of pad rows in up sector
+  return fnRowUp;
+}
+Float_t AliTPCParam::GetPadRowRadiiLow(Int_t irow) const
+{
+  //get the pad row (irow) radii
+  if ( !(irow<0) && (irow<fnRowLow) ) 
+    return  fPadRowLow[irow];
+  else
+    return 0;
+}
+
+Float_t AliTPCParam::GetPadRowRadiiUp(Int_t irow) const
+{
+  //get the pad row (irow) radii
+ if ( !(irow<0) && (irow<fnRowUp) ) 
+    return  fPadRowUp[irow];
+  else
+    return 0;
+}
+
+Int_t AliTPCParam::GetNPadsLow(Int_t irow) const
+{
+  //get the number of pads in row irow
+  if ( !(irow<0) && (irow<fnRowLow) ) 
+    return  fnPadsLow[irow];
+  else
+    return 0;
+}
+
+
+Int_t AliTPCParam::GetNPadsUp(Int_t irow) const
+{
+  //get the number of pads in row irow
+  if ( !(irow<0) && (irow<fnRowUp) ) 
+    return  fnPadsUp[irow];
+  else
+    return 0;
+}
+
+
+void AliTPCParam::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class AliTPC.
+
+   if (R__b.IsReading()) {
+      Version_t R__v = R__b.ReadVersion(); if (R__v) { }
+      TObject::Streamer(R__b);
+      if (R__v < 2) return;
+      
+      R__b >> fInnerRadiusLow;
+      R__b >> fInnerRadiusUp;
+      R__b >> fOuterRadiusLow;
+      R__b >> fOuterRadiusUp;
+
+      R__b >> fPadPitchLength;
+      R__b >> fPadPitchWidth;
+      R__b >> fPadLength;
+      R__b >> fPadWidth;
+
+      R__b >> fnWires;
+      
+      R__b >>fDiffT;
+      R__b >>fDiffL;
+      R__b >>fGasGain;
+      R__b >>fDriftV;
+      R__b >>fOmegaTau;
+      R__b >>fOxyCont;
+      R__b >>fAttCoef;
+      
+
+      R__b >>fPadCoupling;
+      R__b >>fZeroSup;
+      R__b >>fNoise;
+      R__b >>fChipGain;
+      
+      R__b >>fTSample;
+      R__b >>fTSigma;     
+      //
+      fWWPitch= fPadPitchLength/Float_t(fnWires);
+      fZWidth = fTSample*fDriftV;  
+      fNtRows = 24*fnRowLow+48*fnRowUp;
+      Update();
+   } else {
+      R__b.WriteVersion(AliTPCParam::IsA());
+      TObject::Streamer(R__b);      
+      R__b << fInnerRadiusLow;
+      R__b << fInnerRadiusUp;
+      R__b << fOuterRadiusLow;
+      R__b << fOuterRadiusUp;
+
+      R__b << fPadPitchLength;
+      R__b << fPadPitchWidth;
+      R__b << fPadLength;
+      R__b << fPadWidth;
+
+      R__b << fnWires;
+      
+      R__b <<fDiffT;
+      R__b <<fDiffL;
+      R__b <<fGasGain;
+      R__b <<fDriftV;
+      R__b <<fOmegaTau;
+      R__b <<fOxyCont;
+      R__b <<fAttCoef;
+
+
+      R__b <<fPadCoupling;
+      R__b <<fZeroSup;
+      R__b <<fNoise;
+      R__b <<fChipGain;
+      
+      R__b <<fTSample;
+      R__b <<fTSigma;                              
+   }
+}
+
diff --git a/TPC/AliTPCParam.h b/TPC/AliTPCParam.h
new file mode 100644 (file)
index 0000000..eff1d8d
--- /dev/null
@@ -0,0 +1,191 @@
+#ifndef TPCParam_H
+#define TPCParam_H
+////////////////////////////////////////////////
+//  Manager class for TPC parameters          //
+////////////////////////////////////////////////
+#include"TObject.h"
+
+const Int_t kMaxRows=600;
+
+class AliTPCParam : public TObject {
+  //////////////////////////////////////////////////////
+  //////////////////////////////////////////////////////
+  //ALITPCParam object to be possible change 
+  //geometry and some other parameters of TPC   
+  //used by AliTPC and AliTPCSector  
+public:
+  AliTPCParam(); 
+  virtual ~AliTPCParam() {;}  //dummy destructor
+  
+  void XYZtoCRXYZ(Float_t *xyz, 
+                 Int_t &sector, Int_t &padrow, Int_t option=3);
+  //transform global position to the position relative to the sector padrow
+  //if option=0  X calculate absolute            calculate sector
+  //if option=1  X           absolute            use input sector
+  //if option=2  X           relative to pad row calculate sector
+  //if option=3  X           relative            use input sector
+
+  void CRXYZtoXYZ(Float_t *xyz,
+           const Int_t &sector, const Int_t & padrow, Int_t option=3) const;  
+  //transform relative position  to the gloabal position
+
+  void CRTimePadtoYZ(Float_t &y, Float_t &z, 
+                    const Float_t &time, const Float_t &pad,
+                    Int_t sector, Int_t padrow );
+  //transform position in digit  units (time slices and pads)  to "normal" 
+  //units (cm)   
+  void CRYZtoTimePad(const Float_t &y, const Float_t &z, 
+                    Float_t &time, Float_t &pad,
+                    Int_t sector, Int_t padrow);
+  //transform position in cm to position in digit unit  
+  Double_t GetLowMaxY(Int_t irow) const {return irow*0.;}
+  Double_t GetUpMaxY(Int_t irow) const {return irow*0;}
+  //additional geometrical function
+  Int_t GetPadRow(Int_t isec, Float_t &x);
+  //return pad row for given sector and position x
+  //if res=-1 it is out of sector
+  
+  Int_t GetWire(Float_t &x);      
+  Int_t GetIndex(Int_t sector, Int_t row);  //give index of the given sector and pad row 
+  Bool_t   AdjustSectorRow(Int_t index, Int_t & sector, Int_t &row); //return sector and padrow
+  //for given index
+  Int_t GetNRowsTotal(){return fNtRows;}  //get total nuber of rows
+  void SetDefault();          //set defaut TPCparam
+  Bool_t Update();            //recalculate and check geometric parameters 
+  Bool_t GetStatus();         //get information about object consistency  
+
+
+  void  AdjustAngles(Int_t isec, Float_t &cos, Float_t &sin) const;
+  //set cosinus and sinus of rotation angles for sector isec
+  Int_t GetNRowLow() const;   //get the number of pad rows in low sector
+  Int_t GetNRowUp() const;    //get the number of pad rows in up sector
+  Int_t GetNRow(Int_t isec) {return  ((isec<25) ?  fnRowLow:fnRowUp);}
+  //get the nuber of pad row in given sector
+  Float_t GetPadRowRadiiLow(Int_t irow) const; //get the pad row (irow) radii
+  Float_t GetPadRowRadiiUp(Int_t irow) const;  //get the pad row (irow) radii
+  Float_t GetPadRowRadii(Int_t isec,Int_t irow) const {
+    return ( (isec < 25) ?GetPadRowRadiiLow(irow):GetPadRowRadiiUp(irow));}
+    //retrun raii of the pad row irow in sector i
+  Int_t GetNPadsLow(Int_t irow) const;    //get the number of pads in row irow 
+  Int_t GetNPadsUp(Int_t irow) const;     //get the number of pads in row irow
+  Int_t GetNPads(Int_t isector,Int_t irow){
+     return ( (isector < 25) ?GetNPadsLow(irow) : GetNPadsUp(irow));}
+    //get the number of pads  in given sector and row
+  //  Int_t GetNPads(Int_t isector, Int_t irow) const;         
+   //get the number of pads in sector isector and row irow
+
+  void  SetInnerRadiusLow(Float_t InnerRadiusLow ) { fInnerRadiusLow=InnerRadiusLow;}
+  void  SetOuterRadiusLow(Float_t OuterRadiusLow ){  fOuterRadiusLow=OuterRadiusLow;} 
+  void  SetInnerRadiusUp(Float_t InnerRadiusUp){  fInnerRadiusUp= InnerRadiusUp;} 
+  void  SetOuterRadiusUp(Float_t OuterRadiusUp){  fOuterRadiusUp= OuterRadiusUp;} 
+
+  void  SetPadPitchLength(Float_t PadPitchLength){  fPadPitchLength=PadPitchLength;}
+  void  SetPadPitchWidth(Float_t PadPitchWidth){  fPadPitchWidth = PadPitchWidth;}
+  void  SetPadLength(Float_t PadLength){  fPadLength=PadLength;}
+  void  SetPadWidth(Float_t PadWidth) {  fPadWidth=PadWidth;}  
+  void  SetDiffT(Float_t DiffT){  fDiffT= DiffT;}
+  void  SetDiffL(Float_t DiffL){  fDiffL=DiffL;}
+  void  SetDriftV(Float_t DriftV){  fDriftV= DriftV;}
+  void  SetOmegaTau(Float_t OmegaTau){  fOmegaTau=OmegaTau;}
+  void  SetAttCoef(Float_t AttCoef){  fAttCoef=AttCoef;}
+  void  SetOxyCont(Float_t OxyCont){  fOxyCont=OxyCont;}
+
+  void  SetNoise(Float_t Noise ){  fNoise= Noise;}
+  void  SetChipGain(Float_t ChipGain){  fChipGain= ChipGain;}
+  void  SetGasGain(Float_t GasGain){  fGasGain=GasGain;}
+  void  SetTSample(Float_t TSample){  fTSample=TSample;}
+  void  SetTSigma(Float_t Sigma){  fTSigma=Sigma;}
+  void  SetPadCoupling(Float_t PadCoupling){  fPadCoupling=PadCoupling;}
+  void  SetNWires(Int_t nWires){  fnWires=nWires;}
+  void  SetWWPitch(Float_t WWPitch){  fWWPitch=WWPitch;}
+  void  SetZeroSup(Int_t ZeroSup){  fZeroSup=ZeroSup;}
+
+  Float_t  GetInnerRadiusLow(){return fInnerRadiusLow;}
+  Float_t  GetOuterRadiusLow(){return fOuterRadiusLow;} 
+  Float_t  GetInnerRadiusUp(){return fInnerRadiusUp;} 
+  Float_t  GetOuterRadiusUp(){return fOuterRadiusUp;} 
+
+  Float_t  GetPadPitchLength(){return fPadPitchLength;}
+  Float_t  GetPadPitchWidth(){return fPadPitchWidth;}
+  Float_t  GetPadLength(){return fPadLength;}
+  Float_t  GetPadWidth() {return fPadWidth;}  
+  Float_t  GetDiffT(){return fDiffT;}
+  Float_t  GetDiffL(){return fDiffL;}
+  Float_t  GetDriftV(){return fDriftV;}
+  Float_t  GetOmegaTau(){return fOmegaTau;}
+  Float_t  GetAttCoef(){return fAttCoef;}
+  Float_t  GetOxyCont(){return fOxyCont;}
+
+  Float_t  GetNoise(){return fNoise;}
+  Float_t  GetChipGain(){return fChipGain;}
+  Float_t  GetGasGain(){return fGasGain;}
+  Float_t  GetTSample(){return fTSample;}
+  Float_t  GetTSigma(){return fTSigma;}
+  Float_t  GetZWidth(){return fZWidth;}
+  Float_t  GetZSigma(){return fTSigma*fDriftV;}  
+  Float_t  GetPadCoupling(){return fPadCoupling;}
+  Int_t    GetNWires(){return fnWires;}
+  Float_t  GetWWPitch(){return fWWPitch;}
+  Int_t    GetZeroSup(){return fZeroSup;}
+
+
+private :
+  Bool_t fbStatus;  //indicates consistency of the data
+  //---------------------------------------------------------------------
+  //   ALICE TPC sector geometry
+  //--------------------------------------------------------------------
+  
+  Float_t fInnerRadiusLow;  // lower radius of inner sector
+  Float_t fOuterRadiusLow;  // lower radius of outer sector
+  Float_t fInnerRadiusUp;   // upper radius of inner  sector
+  Float_t fOuterRadiusUp;   // upper radius of outer  sector
+
+  Float_t   fPadPitchLength;    //pad pitch length
+  Float_t   fPadPitchWidth;     //pad pitch width
+  Float_t   fPadLength;         //pad  length
+  Float_t   fPadWidth;          //pad  width
+  
+  
+  Int_t fnRowLow;           //  number of pad rows per low sector 
+  Int_t fnRowUp;            //  number of pad rows per sector up 
+  Float_t  fPadRowLow[600]; // Lower sector, pad row radii
+  Float_t  fPadRowUp[600];  // Upper sector, pad row radii
+  Int_t    fnPadsLow[600];     // Lower sector, number of pads per row
+  Int_t    fnPadsUp[600];      //  Upper sector, number of pads per row
+  Float_t fRotAngle[200];      //  sin and cos of rotation angles for 
+                                 //  diferent sectors
+
+  Int_t fnWires;            //  Number of wires per pad
+  Float_t fWWPitch;         // pitch between wires   
+  //---------------------------------------------------------------------
+  //   ALICE TPC Gas Parameters
+  //--------------------------------------------------------------------
+  Float_t  fDiffT;          //tangencial diffusion constant
+  Float_t  fDiffL;          //longutudinal diffusion constant
+  Float_t  fGasGain;        //gas gain constant
+  Float_t  fDriftV;          //drift velocity constant
+  Float_t  fOmegaTau;       //omega tau ExB coeficient
+  Float_t  fAttCoef;        //attachment coefitients
+  Float_t  fOxyCont;        //oxygen content
+  //---------------------------------------------------------------------
+  //   ALICE TPC  Electronics Parameters
+  //--------------------------------------------------------------------
+  Float_t fPadCoupling;     //coupling factor ration of  anode signal 
+                            //and total pads signal  
+  Int_t fZeroSup;         //zero suppresion constant
+  Float_t fNoise;         //noise sigma constant
+  Float_t fChipGain;      //preamp shaper constant
+  Float_t fTSample; // sampling time
+  Float_t fZWidth;  //derived value calculated using TSample and driftw 
+  Float_t fTSigma;  // width of the Preamp/Shaper function
+  //--------------------------------------------------------
+  //
+  Int_t fNtRows;  //total number of rows in TPC  
+  ClassDef(AliTPCParam,2)  //parameter  object for set:TPC
+};
+
+
+
+
+
+#endif  
diff --git a/TPC/AliTPCRF1D.cxx b/TPC/AliTPCRF1D.cxx
new file mode 100644 (file)
index 0000000..9b284e8
--- /dev/null
@@ -0,0 +1,317 @@
+//-----------------------------------------------------------------------------
+//  $Header$
+//
+//
+//  Origin:   Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk
+//
+//  Declaration of class AliTPCRF1D
+//
+//-----------------------------------------------------------------------------
+#include "TMath.h"
+#include "AliTPCRF1D.h"
+#include "TF2.h"
+#include <iostream.h>
+#include "TCanvas.h"
+#include "TPad.h"
+#include "TStyle.h"
+#include "TH1.h"
+
+extern TStyle * gStyle;
+
+static Double_t funGauss(Double_t *x, Double_t * par)
+{
+  return TMath::Exp(-(x[0]*x[0])/(2*par[0]*par[0]));
+}
+
+static Double_t funCosh(Double_t *x, Double_t * par)
+{
+  return 1/TMath::CosH(3.14159*x[0]/(2*par[0]));  
+}    
+
+static Double_t funGati(Double_t *x, Double_t * par)
+{
+  //par[1] = is equal to k3
+  //par[0] is equal to pad wire distance
+  Float_t K3=par[1];
+  Float_t K3R=TMath::Sqrt(K3);
+  Float_t K2=(TMath::Pi()/2)*(1-K3R/2.);
+  Float_t K1=K2*K3R/(4*TMath::ATan(K3R));
+  Float_t l=x[0]/par[0];
+  Float_t tan2=TMath::TanH(K2*l);
+  tan2*=tan2;
+  Float_t res = K1*(1-tan2)/(1+K3*tan2);  
+  return res;  
+}    
+
+
+
+
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+
+AliTPCRF1D * gRF1D;
+ClassImp(AliTPCRF1D)
+
+
+AliTPCRF1D::AliTPCRF1D(Bool_t direct,Int_t np,Float_t step)
+{
+  fDirect=direct;
+  fNRF = np;
+  fcharge = new Float_t[fNRF];
+  fDSTEPM1=1./step;
+  fSigma = 0;
+  gRF1D = this;
+  fGRF = 0;
+  fkNorm = 0.5;
+  fpadWidth = 3.5;
+  forigsigma=0.;
+  fOffset = 0.;
+}
+
+
+AliTPCRF1D::~AliTPCRF1D()
+{
+  if (fcharge!=0) delete fcharge;
+  if (fGRF !=0 ) fGRF->Delete();
+}
+
+Float_t AliTPCRF1D::GetRF(Float_t xin)
+{
+  //x xin DSTEP unit
+  //return linear aproximation of RF
+  Float_t x = TMath::Abs((xin-fOffset)*fDSTEPM1)+fNRF/2;
+  Int_t i1=Int_t(x);
+  if (x<0) i1-=1;
+  Float_t res=0;
+  if (i1+1<fNRF)
+    res = fcharge[i1]*(Float_t(i1+1)-x)+fcharge[i1+1]*(x-Float_t(i1));    
+  return res;
+}
+
+Float_t  AliTPCRF1D::GetGRF(Float_t xin)
+{  
+  if (fGRF != 0 ) 
+    return fkNorm*fGRF->Eval(xin)/fInteg;
+      else
+    return 0.;
+}
+
+   
+void AliTPCRF1D::SetParam( TF1 * GRF,Float_t padwidth,
+                      Float_t kNorm, Float_t sigma)
+{
+   fpadWidth = padwidth;
+   fGRF = GRF;
+   fkNorm = kNorm;
+   if (sigma==0) sigma= fpadWidth/TMath::Sqrt(12.);
+   forigsigma=sigma;
+   fDSTEPM1 = 10/TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12); 
+   sprintf(fType,"User");
+   //   Update();   
+}
+  
+
+void AliTPCRF1D::SetGauss(Float_t sigma, Float_t padWidth,
+                     Float_t kNorm)
+{
+  // char s[120];
+  fpadWidth = padWidth;
+  fkNorm = kNorm;
+  if (fGRF !=0 ) fGRF->Delete();
+  fGRF = new TF1("fun",funGauss,-5,5,2);
+  funParam[0]=sigma;
+  forigsigma=sigma;
+  fGRF->SetParameters(funParam);
+   fDSTEPM1 = 10./TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12); 
+  //by default I set the step as one tenth of sigma
+   //  Update(); 
+  sprintf(fType,"Gauss");
+}
+
+void AliTPCRF1D::SetCosh(Float_t sigma, Float_t padWidth,
+                    Float_t kNorm)
+{
+  //  char s[120];
+  fpadWidth = padWidth;
+  fkNorm = kNorm;
+  if (fGRF !=0 ) fGRF->Delete();
+  fGRF = new TF1("fun",        funCosh, -5.,5.,2);   
+  funParam[0]=sigma;
+  fGRF->SetParameters(funParam);
+  forigsigma=sigma;
+  fDSTEPM1 = 10./TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12); 
+  //by default I set the step as one tenth of sigma
+  //  Update();
+  sprintf(fType,"Cosh");
+}
+
+void AliTPCRF1D::SetGati(Float_t K3, Float_t padDistance, Float_t padWidth,
+                    Float_t kNorm)
+{
+  //  char s[120];
+  fpadWidth = padWidth;
+  fkNorm = kNorm;
+  if (fGRF !=0 ) fGRF->Delete();
+  fGRF = new TF1("fun",        funGati, -5.,5.,2);   
+  funParam[0]=padDistance;
+  funParam[1]=K3;  
+  fGRF->SetParameters(funParam);
+  forigsigma=padDistance;
+  fDSTEPM1 = 10./TMath::Sqrt(padDistance*padDistance+fpadWidth*fpadWidth/12); 
+  //by default I set the step as one tenth of sigma
+  //  Update(); 
+  sprintf(fType,"Gati");
+}
+
+void AliTPCRF1D::Draw(Float_t x1,Float_t x2,Int_t N)
+{ 
+  char s[100];
+  TCanvas  * c1 = new TCanvas("canRF","Pad response function",700,900);
+  c1->cd();
+  TPad * pad1 = new TPad("pad1RF","",0.05,0.55,0.95,0.95,21);
+  pad1->Draw();
+  TPad * pad2 = new TPad("pad2RF","",0.05,0.05,0.95,0.45,21);
+  pad2->Draw();
+
+  sprintf(s,"RF response function for %1.2f cm pad width",
+         fpadWidth);  
+  pad1->cd();
+  TH1F * hRFo = new TH1F("hRFo","Original charge distribution",N+1,x1,x2);
+  pad2->cd();
+   gStyle->SetOptFit(1);
+   gStyle->SetOptStat(0); 
+  TH1F * hRFc = new TH1F("hRFc",s,N+1,x1,x2);
+  Float_t x=x1;
+  Float_t y1;
+  Float_t y2;
+
+  for (Float_t i = 0;i<N+1;i++)
+    {
+      x+=(x2-x1)/Float_t(N);
+      y1 = GetRF(x);
+      hRFc->Fill(x,y1);
+      y2 = GetGRF(x);
+      hRFo->Fill(x,y2);      
+    };
+  pad1->cd();
+  hRFo->Fit("gaus");
+  pad2->cd();
+  hRFc->Fit("gaus");
+}
+
+void AliTPCRF1D::Update()
+{
+  //initialize to 0
+  for (Int_t i =0; i<fNRF;i++)  fcharge[i] = 0;
+  if ( fGRF == 0 ) return;
+  fInteg  = fGRF->Integral(-5*forigsigma,5*forigsigma,funParam,0.00001);
+  if ( fInteg == 0 ) fInteg = 1; 
+  if (fDirect==kFALSE){
+  //integrate charge over pad for different distance of pad
+  for (Int_t i =0; i<fNRF;i++)
+    {      //x in cm fpadWidth in cm
+      Float_t x = (Float_t)(i-fNRF/2)/fDSTEPM1;
+      Float_t x1=TMath::Max(x-fpadWidth/2,-5*forigsigma);
+      Float_t x2=TMath::Min(x+fpadWidth/2,5*forigsigma);
+      fcharge[i] = 
+       fkNorm*fGRF->Integral(x1,x2,funParam,0.0001)/fInteg;
+    };   
+  }
+  else{
+    for (Int_t i =0; i<fNRF;i++)
+      {      //x in cm fpadWidth in cm
+       Float_t x = (Float_t)(i-fNRF/2)/fDSTEPM1;
+       fcharge[i] = fkNorm*fGRF->Eval(x);
+      };   
+  }  
+  fSigma = 0; 
+  Float_t sum =0;
+  Float_t mean=0;
+  for (Float_t  x =-fNRF/fDSTEPM1; x<fNRF/fDSTEPM1;x+=1/fDSTEPM1)
+    {      //x in cm fpadWidth in cm
+      Float_t weight = GetRF(x+fOffset);
+      fSigma+=x*x*weight; 
+      mean+=x*weight;
+      sum+=weight;
+    };  
+  if (sum>0){
+    mean/=sum;
+    fSigma = TMath::Sqrt(fSigma/sum-mean*mean);   
+  }
+  else fSigma=0; 
+}
+
+void AliTPCRF1D::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class AliTPC.
+
+   if (R__b.IsReading()) {
+      Version_t R__v = R__b.ReadVersion(); if (R__v) { }
+      TObject::Streamer(R__b);     
+      //read pad parameters
+      R__b >> fpadWidth;
+      //read charge parameters
+      R__b >> fType[0];
+      R__b >> fType[1];
+      R__b >> fType[2];
+      R__b >> fType[3];
+      R__b >> fType[4];
+      R__b >> forigsigma;
+      R__b >> fkNorm;
+      R__b >> fK3X;
+      R__b >> fPadDistance; 
+      R__b >> fInteg;
+      R__b >> fOffset;
+      //read functions
+      if (fGRF!=0) { 
+       delete fGRF;  
+       fGRF=0;
+      }
+      if (strncmp(fType,"User",3)==0){
+       fGRF= new TF1;
+       R__b>>fGRF;   
+      }
+      if (strncmp(fType,"Gauss",3)==0) 
+       fGRF = new TF1("fun",funGauss,-5.,5.,4);
+      if (strncmp(fType,"Cosh",3)==0) 
+       fGRF = new TF1("fun",funCosh,-5.,5.,4);
+      if (strncmp(fType,"Gati",3)==0) 
+       fGRF = new TF1("fun",funGati,-5.,5.,4);   
+      R__b >>fDSTEPM1;  
+      R__b >>fNRF;
+      R__b.ReadFastArray(fcharge,fNRF); 
+      R__b.ReadFastArray(funParam,5); 
+      if (fGRF!=0) fGRF->SetParameters(funParam);     
+
+   } else {
+      R__b.WriteVersion(AliTPCRF1D::IsA());
+      TObject::Streamer(R__b);   
+      //write pad width
+      R__b << fpadWidth;
+      //write charge parameters
+      R__b << fType[0];
+      R__b << fType[1];
+      R__b << fType[2];
+      R__b << fType[3];
+      R__b << fType[4];
+      R__b << forigsigma;
+      R__b << fkNorm;
+      R__b << fK3X;
+      R__b << fPadDistance;
+      R__b << fInteg;
+      R__b << fOffset;
+      //write interpolation parameters
+      if (strncmp(fType,"User",3)==0) R__b <<fGRF;   
+      R__b <<fDSTEPM1;
+      R__b <<fNRF;    
+      R__b.WriteFastArray(fcharge,fNRF); 
+      R__b.WriteFastArray(funParam,5); 
+       
+      
+
+   }
+}
diff --git a/TPC/AliTPCRF1D.h b/TPC/AliTPCRF1D.h
new file mode 100644 (file)
index 0000000..a22366c
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef AliTPCRF1D_H
+#define AliTPCRF1D_H
+////////////////////////////////////////////////
+//  Manager class for AliTPCRF1D                  //
+////////////////////////////////////////////////
+  
+
+// include files and class forward declarations
+//DSTEP in cm
+//NPRF in number of interpolation points
+const Int_t   NRF=100;
+const Float_t RFDSTEP=0.01;
+
+#include "TObject.h"
+#include "TMath.h"
+class TF1;
+
+
+class AliTPCRF1D : public TObject {
+public : 
+  AliTPCRF1D(Bool_t direct=kFALSE,Int_t np=NRF,Float_t step=RFDSTEP );
+  ~AliTPCRF1D();  
+  Float_t GetRF(Float_t xin); //return RF in point xin
+  Float_t GetGRF(Float_t xin); //return generic response function  in xin
+  void SetGauss(Float_t sigma,Float_t padWidth, Float_t kNorm);
+  //adjust RF with GAUSIAN as generic GRF 
+  //if  direct = kTRUE then it does't convolute distribution
+  void SetCosh(Float_t sigma,Float_t padWidth, Float_t kNorm);
+  void SetGati(Float_t K3, Float_t padDistance, Float_t padWidth,
+              Float_t kNorm);
+  //adjust RF with 1/Cosh  as generic GRF
+  void SetParam(TF1 * GRF,Float_t padwidth,Float_t kNorm, 
+               Float_t sigma=0);
+  //adjust RF with general function 
+  void SetOffset(Float_t xoff) {fOffset=xoff;}
+  //set offset value 
+  Float_t GetPadWidth(){ return fpadWidth;};       
+  //return  pad width 
+  Float_t  GetSigma(){return fSigma;}
+  //return estimated sigma of RF
+  void Draw(Float_t x1=-3 ,Float_t x2 =3.,Int_t N = 200);
+  //draw RF it don't delete histograms after drawing
+  /// it's on user !!!!
+  void Update();  
+private: 
+  Double_t funParam[5];//parameters of used charge function
+  Int_t  fNRF;      //number of interpolations point
+  Float_t fDSTEPM1;    //element step for point
+  Float_t* fcharge; // field with RF
+  Float_t  forigsigma;//sigma of original distribution;
+  Float_t fpadWidth;  //width of pad
+  Float_t fkNorm;     //normalisation factor of the charge integral
+  Float_t fInteg;     //integral of GRF on +- infinity
+  TF1 *  fGRF;        //charge distribution function
+  Float_t fSigma;     //sigma of PAD response function
+
+  Float_t fOffset;    //offset of response function (for time reponse we 
+  //have for expample shifted gauss)
+  //calculated during update
+  Bool_t fDirect;     //tell us if we use directly generalfunction
+  Float_t fK3X;  
+  Float_t fPadDistance; 
+  //charge type
+  char  fType[5];
+  ClassDef(AliTPCRF1D,2)
+}; 
+
+
+
+
+#endif /* AliTPCRF1D_H */
+  
index 51f890d200ca18e780b2e12cdb2a4f5fff9e9b68..b4fc3661c418c05f53cbc1fafb209f32709433d6 100644 (file)
@@ -1,69 +1,18 @@
 #ifndef TPCSecGeo_H
-#define TPCSecGeo_H
-/////////////////////////////////////////////////////////////////////////////
-//
-//---------------------------------------------------------------------
-//   ALICE TPC sector geometry
-//--------------------------------------------------------------------
-//
-const Float_t z_end = 250.; // position of the readout chamber
-//
-//   Lower sectors (numbers 1-12), opening angle in radians
-//
+
+
+//Some things from the old AliTPCSecGeo
+
+const Float_t z_end = 250.; 
 const Float_t alpha_low=0.523598775; // 30 degrees
-//
-//   Upper sectors (numbers 13-36), opening angle in radians
-//
 const Float_t alpha_up=0.261799387; //  15 degrees
-//
-// Pad size 2.05 x 0.35 cm
-//
-const Float_t pad_pitch_l=2.05;
-const Float_t pad_pitch_w=0.35;
-//
-//  number of pad rows per sector
-//
-const Int_t nrow_low = 23;
-const Int_t nrow_up = 52;
-//
-// Lower sector, pad row radii
-//
-const Float_t pad_row_low[23]={
-   89.445,   91.495,   93.545,   95.595,  97.645,  99.695,  101.745,  103.795,  
-  105.845,  107.895,  109.945,  111.995, 114.045, 116.095,  118.145,  120.195,  
-  122.245,  124.295,  126.345,  128.395, 130.445, 132.495,  134.545}; 
-//
-// Upper sector, pad row radii
-//
-const Float_t pad_row_up[52]={
-143.72,  145.77,  147.82,  149.87,  151.92,  153.97,  156.02, 158.07,  
-160.12,  162.17,  164.22,  166.27,  168.32,  170.37,  172.42, 174.47,  
-176.52,  178.57,  180.62,  182.67,  184.72,  186.77,  188.82, 190.87,  
-192.92,  194.97,  197.02,  199.07,  201.12,  203.17,  205.22, 207.27,  
-209.32,  211.37,  213.42,  215.47,  217.52,  219.57,  221.62, 223.67,  
-225.72,  227.77,  229.82,  231.87,  233.92,  235.97,  238.02, 240.07,  
-242.12,  244.17,  246.22,  248.27};
-//
-// Lower sector, number of pads per row
-//
-const Int_t npads_low[23]={
- 129,  133,  135,  139,  143,  145,  149,  151,  155,  157,  161,  165,
- 167,  171,  173,  177,  179,  183,  187,  189,  193,  195,  199};
-//
-//  Upper sector, number of pads per row
-//
-const Int_t npads_up[52]={
-  101,  103,  103,  105,  107,  109,  111,  111,  113,  115,  117,  117,
-  119,  121,  123,  123,  125,  127,  129,  131,  131,  133,  135,  137,
-  137,  139,  141,  143,  145,  145,  147,  149,  151,  151,  153,  155,
-  157,  157,  159,  161,  163,  165,  165,  167,  169,  171,  171,  173,
-  175,  177,  177,  179};
 
-//
-//  Number of wires per pad and wire-wire pitch
-//
-const Int_t nwires = 5;
-const Float_t ww_pitch = 0.41;
+
+
+
+const Float_t q_el = 1.602e-19; // elementary charge
+const Float_t adc_sat = 1023; // dynamic range (10 bits)
+const Float_t dyn_range = 2000.; // output dynamic range (mV)
 
 /////////////////////////////////////////////////////////////////////////////
 //
@@ -91,49 +40,6 @@ const Float_t bc_z=0.55938e-3;
 const Float_t cc_z=0.30428;
 //
 
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//---------------------------------------------------------------------
-//   ALICE TPC Gas Parameters
-//--------------------------------------------------------------------
-//
-//
-//   Diffusion constants
-//
-const Float_t diff_t=2.2e-2; 
-const Float_t diff_l=2.2e-2;  
-//
-//  Lorentz angle (omega_tau)
-//
-const Float_t omega_tau = 0.125;
-//
-//  Electron drift velocity
-//
-const Float_t v_drift=2.85e6;
-/////////////////////////////////////////////////////////////////////////////
-//
-//---------------------------------------------------------------------
-//   ALICE TPC  Electronics Parameters
-//--------------------------------------------------------------------
-//
-//
-
-const Float_t t_sample = 2.e-7; // sampling time
-const Float_t fwhm = 2.5e-7; // width of the Preamp/Shaper function
-
-//
-
-const Float_t gas_gain = 1.e4; // gas gain
-const Float_t q_el = 1.602e-19; // elementary charge
-
-//
-
-const Float_t adc_sat = 1023; // dynamic range (10 bits)
-const Float_t zero_sup = 5.; // zero suppression
-const Float_t sigma_noise = 500.; // electronics noise (no. of electrons)
-const Float_t chip_gain = 24.; // conversion gain (mV/fC)
-const Float_t dyn_range = 2000.; // output dynamic range (mV)
+#define TPCSecGeo_H
 
 #endif
diff --git a/TPC/AliTPCTestClustering.C b/TPC/AliTPCTestClustering.C
new file mode 100644 (file)
index 0000000..8011c1b
--- /dev/null
@@ -0,0 +1,77 @@
+void AliTPCTestClustering() {
+   const char *pname="Param1";
+   const char *tname="TreeD0_Param1";
+
+// Dynamically link some shared libs
+   if (gClassTable->GetID("AliRun") < 0) {
+      gROOT->LoadMacro("loadlibs.C");
+      loadlibs();
+   } else {
+      delete gAlice;
+      gAlice=0;
+   }
+
+// Connect the Root Galice file containing Geometry, Kine and Hits
+   TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
+   if (!file) file = new TFile("galice.root");
+
+// Get AliRun object from file or create it if not on file
+   if (!gAlice) {
+      gAlice = (AliRun*)file->Get("gAlice");
+      if (gAlice) printf("AliRun object found on file\n");
+      if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
+   }
+
+   gAlice->GetEvent(0);
+
+   AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
+   int ver=TPC->IsVersion(); 
+   cerr<<"TPC version "<<ver<<" has been found !\n";
+
+   AliTPCD *dig=(AliTPCD*)file->Get(pname);
+   if (dig!=0) TPC->SetDigParam(dig);
+   else cerr<<"Warning: default TPC parameters will be used !\n";
+
+   switch (ver) {
+   case 1:
+      cerr<<"Making clusters...\n";
+      TPC->Hits2Clusters();
+      break;
+   case 2:
+      cerr<<"Looking for clusters...\n";
+      TPC->Digits2Clusters();
+      break;
+   default:
+      cerr<<"Invalid TPC version !\n";
+      return;
+   }
+   TClonesArray *c=TPC->Clusters();
+   int n=c->GetEntriesFast();
+   cerr<<"Number of clusters "<<n<<"                            \n";
+
+   AliTPCParam *par=&TPC->GetDigParam()->GetParam();
+   Float_t x[3];
+   TPolyMarker3D *pm=new TPolyMarker3D(n);
+   for (int i=0; i<n; i++) {
+       AliTPCcluster *cl=(AliTPCcluster *)c->UncheckedAt(i);
+       cl->GetXYZ(x,par);
+       Double_t xx=x[0], yy=x[1], zz=x[2];
+       pm->SetPoint(i,xx,yy,zz);
+   }
+
+   c1=new TCanvas("c1", "Cluster display",0,0,660,740);
+   TView *v=new TView(1);
+   v->SetRange(-430,-560,-430,430,560,1710);
+
+   c1->Clear();
+   c1->SetFillColor(1);
+   c1->SetTheta(90.);
+   c1->SetPhi(0.);
+
+   pm->SetMarkerSize(1);
+   pm->SetMarkerColor(2);
+   pm->SetMarkerStyle(1);
+   pm->Draw();
+
+   gAlice->GetGeometry()->Draw("same");
+}
diff --git a/TPC/AliTPCTestTracking.C b/TPC/AliTPCTestTracking.C
new file mode 100644 (file)
index 0000000..7fe7450
--- /dev/null
@@ -0,0 +1,240 @@
+void AliTPCTestTracking() {
+   const char *pname="Param1";
+   const char *tname="TreeD0_Param1";
+
+// Dynamically link some shared libs
+   if (gClassTable->GetID("AliRun") < 0) {
+      gROOT->LoadMacro("loadlibs.C");
+      loadlibs();
+   } else {
+      delete gAlice;
+      gAlice=0;
+   }
+
+// Connect the Root Galice file containing Geometry, Kine and Hits
+   TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
+   if (!file) file = new TFile("galice.root");
+
+// Get AliRun object from file or create it if not on file
+   if (!gAlice) {
+      gAlice = (AliRun*)file->Get("gAlice");
+      if (gAlice) printf("AliRun object found on file\n");
+      if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
+   }
+
+   gAlice->GetEvent(0);
+
+   TClonesArray *particles=gAlice->Particles(); 
+   int np=particles->GetEntriesFast();
+
+   AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
+   int ver=TPC->IsVersion();
+   cerr<<"TPC version "<<ver<<" has been found !\n";
+
+   AliTPCD *digp= (AliTPCD*)file->Get(pname);
+   if (digp!=0) TPC->SetDigParam(digp);
+   else cerr<<"Warning: default TPC parameters will be used !\n";
+
+   int nrows=TPC->GetDigParam()->GetParam().GetNRowUp()-1;
+   switch (ver) {
+   case 1:
+      cerr<<"Making clusters...\n";
+      TPC->Hits2Clusters();
+      TClonesArray *clusters=TPC->Clusters();
+      if (!clusters) {cerr<<"No clusters found !\n"; return;}
+      int n=clusters->GetEntriesFast();
+      cerr<<"Number of clusters "<<n<<"                                  \n";
+      
+      cerr<<"Marking \"good\" tracks...                                  \n";
+      for (int i=0; i<n; i++) {
+          AliTPCcluster *c=(AliTPCcluster*)clusters->UncheckedAt(i);
+          int lab=c->fTracks[0];
+          if (lab<0) continue; //noise cluster
+          lab=TMath::Abs(lab);
+          int sector=c->fSector-1, row=c->fPadRow-1;
+          GParticle *p=(GParticle*)particles->UncheckedAt(lab);
+          int ks;
+          if (row==nrows)   {ks=p->GetKS()|0x1000; p->SetKS(ks);}
+          if (row==nrows-8) {ks=p->GetKS()|0x800; p->SetKS(ks);}
+          ks=p->GetKS()+1; p->SetKS(ks);
+      }
+      
+      break;
+   case 2:
+      cerr<<"Looking for clusters...\n";
+      TPC->Digits2Clusters();
+      TClonesArray *clusters=TPC->Clusters();
+      if (!clusters) {cerr<<"No clusters found !\n"; return;}
+      int n=clusters->GetEntriesFast();
+      cerr<<"Number of clusters "<<n<<"                                  \n";
+      
+      cerr<<"Marking \"good\" tracks...                                  \n";
+      TTree *TD=gDirectory->Get(tname);
+      TClonesArray *digits=TPC->Digits();
+      TD->GetBranch("Digits")->SetAddress(&digits);
+
+      int *count = new int[np];
+      int i;
+      for (i=0; i<np; i++) count[i]=0;
+      int sectors_by_rows=(int)TD->GetEntries();
+      for (i=0; i<sectors_by_rows; i++) {
+          if (!TD->GetEvent(i)) continue;
+          int sec, row;
+          int ndigits=digits->GetEntriesFast();
+          int j;
+          for (j=0; j<ndigits; j++) {
+              AliTPCdigit *dig = (AliTPCdigit*)digits->UncheckedAt(j);
+              int idx0=dig->fTracks[0];
+              int idx1=dig->fTracks[1];
+              int idx2=dig->fTracks[2];
+              sec=dig->fSector-1; row=dig->fPadRow-1;
+              if (idx0>=0 && dig->fSignal>0) count[idx0]+=1;
+              if (idx1>=0 && dig->fSignal>0) count[idx1]+=1;
+              if (idx2>=0 && dig->fSignal>0) count[idx2]+=1;
+          }
+          for (j=0; j<np; j++) {
+              GParticle *p=(GParticle*)particles->UncheckedAt(j);
+              if (count[j]>1) {
+                 int ks;
+                 if (row==nrows   ) {ks=p->GetKS()|0x1000; p->SetKS(ks);}
+                 if (row==nrows-8 ) {ks=p->GetKS()|0x800;  p->SetKS(ks);}
+                 ks=p->GetKS()+1; p->SetKS(ks);
+              }
+              count[j]=0;
+          }
+      }
+      delete[] count;
+      
+      break;
+   default:
+      cerr<<"Invalid TPC version !\n";
+      return;
+   }
+
+   cerr<<"Looking for tracks...\n";
+   TPC->Clusters2Tracks();
+   int nt=0;
+   TClonesArray *tracks=TPC->Tracks();
+   if (tracks) nt=tracks->GetEntriesFast();
+   cerr<<"Number of found tracks "<<nt<<endl;
+
+/////////////////////////////////////////////////////////////////////////
+   cerr<<"Doing comparison...\n";
+   TH1F *hp=new TH1F("hp","PHI resolution",50,-100.,100.); hp->SetFillColor(4); 
+   TH1F *hl=new TH1F("hl","LAMBDA resolution",50,-100,100); hl->SetFillColor(4);
+   TH1F *hpt=new TH1F("hpt","Relative Pt resolution",30,-10.,10.); 
+   hpt->SetFillColor(2); 
+   TH1F *hd=new TH1F("hd","Impact parameter distribution ",30,0,25); 
+   hd->SetFillColor(6);
+
+   TH1F *hgood=new TH1F("hgood","Good tracks",20,0,2);    
+   TH1F *hfound=new TH1F("hfound","Found tracks",20,0,2);
+   TH1F *hfake=new TH1F("hfake","Fake tracks",20,0,2);
+   TH1F *hg=new TH1F("hg","",20,0,2); //efficiency for good tracks
+   hg->SetLineColor(4); hg->SetLineWidth(2);
+   TH1F *hf=new TH1F("hf","Efficiency for fake tracks",20,0,2);
+   hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
+
+   for (int i=0; i<np; i++) {
+      GParticle *p = (GParticle*)particles->UncheckedAt(i);
+      if (p->GetParent()>=0) continue;  //secondary particle
+      if (p->GetKS()<0x1000+0x800+2+30) continue;
+      Double_t ptg=p->GetPT(),pxg=p->GetPx(),pyg=p->GetPy(),pzg=p->GetPz();
+      if (ptg<0.100) continue;
+      if (fabs(pzg/ptg)>0.999) continue;
+
+      //cout<<i<<endl;
+
+      hgood->Fill(ptg);
+      int found=0;
+      for (int j=0; j<nt; j++) {
+          AliTPCtrack *track=(AliTPCtrack*)tracks->UncheckedAt(j);
+          int lab=track->GetLab();
+         if (fabs(lab)!=i) continue;
+         //if (lab!=i) continue;
+          found=1;
+          Double_t xk=76.;
+
+          track->PropagateTo(xk);
+          xk-=0.11;
+          track->PropagateTo(xk,42.7,2.27); //C
+          xk-=2.6;
+          track->PropagateTo(xk,36.2,1.98e-3); //C02
+          xk-=0.051;
+          track->PropagateTo(xk,42.7,2.27); //C
+
+          xk-=0.4;
+          track->PropagateTo(xk,21.82,2.33); //ITS+beam_pipe+etc (approximately)
+
+          track->PropagateToVertex(); //comparison should be done at the vertex
+
+          if (lab==i) hfound->Fill(ptg);
+          else { hfake->Fill(ptg); cerr<<lab<<" fake\n";}
+          Double_t px,py,pz,pt=fabs(track->GetPt());track->GetPxPyPz(px,py,pz);
+          Double_t phig=TMath::ATan(pyg/pxg);
+          Double_t phi =TMath::ATan(py /px );
+          hp->Fill((phi - phig)*1000.);
+          Double_t lamg=TMath::ATan(pzg/ptg);
+          Double_t lam =TMath::ATan(pz /pt );
+          hl->Fill((lam - lamg)*1000.);
+          hpt->Fill((pt - ptg)/ptg*100.);
+          Double_t x,y,z; track->GetXYZ(x,y,z);
+          hd->Fill(sqrt(x*x + y*y + z*z)*10.);
+          break;
+      }
+      if (!found) cerr<<"Track number "<<i<<" was not found !\n";
+   }
+   Stat_t ngood =hgood->GetEntries(); cerr<<"Good tracks "<<ngood<<endl;
+   Stat_t nfound=hfound->GetEntries();
+   if (ngood!=0) 
+      cerr<<"Integral efficiency is about "<<nfound/ngood*100.<<" %\n";
+
+   gStyle->SetOptStat(111110);
+   gStyle->SetOptFit(1);
+
+   TCanvas *c1=new TCanvas("c1","",0,0,700,850);
+
+   TPad *p1=new TPad("p1","",0,0.3,.5,.6); p1->Draw();
+   p1->cd(); p1->SetFillColor(42); p1->SetFrameFillColor(10); 
+   hp->SetFillColor(4);  hp->SetXTitle("(mrad)"); hp->Fit("gaus"); c1->cd();
+
+   TPad *p2=new TPad("p2","",0.5,.3,1,.6); p2->Draw(); 
+   p2->cd(); p2->SetFillColor(42); p2->SetFrameFillColor(10);
+   hl->SetXTitle("(mrad)"); hl->Fit("gaus"); c1->cd();
+
+   TPad *p3=new TPad("p3","",0,0,0.5,0.3); p3->Draw();
+   p3->cd(); p3->SetFillColor(42); p3->SetFrameFillColor(10); 
+   hpt->SetXTitle("(%)"); hpt->Fit("gaus"); c1->cd();
+
+   TPad *p4=new TPad("p4","",0.5,0,1,0.3); p4->Draw();
+   p4->cd(); p4->SetFillColor(42); p4->SetFrameFillColor(10);
+   hd->SetXTitle("(mm)"); hd->Draw(); c1->cd();
+
+   TPad *p5=new TPad("p5","",0,0.6,1,1); p5->Draw(); p5->cd(); 
+   /*p5->SetTopMargin(0.25);*/ p5->SetFillColor(41); p5->SetFrameFillColor(10);
+   hfound->Sumw2(); hgood->Sumw2(); hfake->Sumw2();
+   hg->Divide(hfound,hgood,1,1.,"b");
+   hf->Divide(hfake,hgood,1,1.,"b");
+   hg->SetMaximum(1.4);
+   hg->SetYTitle("Tracking efficiency");
+   hg->SetXTitle("Pt (GeV/c)");
+   hg->Draw();
+
+   TLine *line1 = new TLine(0,1.0,2,1.0); line1->SetLineStyle(4);
+   line1->Draw("same");
+   TLine *line2 = new TLine(0,0.9,2,0.9); line2->SetLineStyle(4);
+   line2->Draw("same");
+
+   hf->SetFillColor(1);
+   hf->SetFillStyle(3013);
+   hf->SetLineColor(2);
+   hf->SetLineWidth(2);
+   hf->Draw("histsame");
+   TText *text = new TText(0.461176,0.248448,"Fake tracks");
+   text->SetTextSize(0.05);
+   text->Draw();
+   text = new TText(0.453919,1.11408,"Good tracks");
+   text->SetTextSize(0.05);
+   text->Draw();
+}
+
index fd89a61b8ed782acca7b11dded683ee4cc9a6d1b..dd279435810c5103647d7428076406159a7c1884 100644 (file)
@@ -528,7 +528,7 @@ void AliTPCv0::CreateMaterials()
 }
 
 //_____________________________________________________________________________
-void AliTPCv0::DrawModule()
+void AliTPCv0::DrawDetector()
 {
   //
   // Draw a shaded view of the Time Projection Chamber version 0
index 30d7b6478068ab54f2315b228346fa35d29d81d5..fb1f6f14cdc7c99185b7e567941de6f9cc39445c 100644 (file)
@@ -17,7 +17,7 @@ public:
   virtual void  Init();
   virtual Int_t IsVersion() const {return 0;}
   virtual void  StepManager();
-  virtual void  DrawModule();
+  virtual void  DrawDetector();
 
 protected:
   
index 97df11b33edac51568b4828dbd3ffb0f7a00cf04..e6d0c03ab9a8049baefe3e0864ded2112a0b881e 100644 (file)
@@ -24,6 +24,9 @@
 #include "AliMC.h"
 #include "AliConst.h"
 
+#include "AliTPCParam.h"
+#include "AliTPCD.h"
+
 ClassImp(AliTPCv1)
  
 //_____________________________________________________________________________
@@ -57,8 +60,11 @@ void AliTPCv1::CreateGeometry()
   AliMC* pMC = AliMC::GetMC();
 
   Int_t *idtmed = gAlice->Idtmed();
+
+
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
   
-  Float_t padl, tana, rlsl, wlsl, rssl, rlsu, wssl, wlsu,
+  Float_t tana, rlsl, wlsl, rssl, rlsu, wssl, wlsu,
     rssu, wssu, alpha, x, y, z, sec_thick;
   
   Float_t r1, r2, x1, z0, z1, x2, theta1, theta2, theta3, dm[21];
@@ -72,7 +78,7 @@ void AliTPCv1::CreateGeometry()
   Int_t ils;
   Float_t opl;
   Int_t iss;
-  Float_t thu, opu, dzz, phi1, phi2, phi3;
+  Float_t thu, opu, phi1, phi2, phi3;
   
   // ---------------------------------------------------- 
   //          FIELD CAGE WITH ENDCAPS - CARBON FIBER 
@@ -198,41 +204,39 @@ void AliTPCv1::CreateGeometry()
   pMC->Gsvolu("TLGA", "TRD1", idtmed[402], dm, 4);
   // ----------------------------------------------------- 
   //  thin sensitive strips (100 microns) placed at a center 
-  //  of each pad row (23 rows) in the "drift gas sector" 
+  //  of each pad row  in the "drift gas sector" 
   // ----------------------------------------------------- 
   pMC->Gsvolu("TSST", "TRD1", idtmed[403], dm, 0);
   
   dm[3] = .005;
-  padl  = 2.05;
-  z0    = (rssu - rssl) * .5;
-  dzz   = (rssu - rssl - padl * 22.) * .5;
-  z0    = -z0 + dzz;
-  
-  for (iss = 0; iss < 23; ++iss) {
-    r1    = rssl + dzz + iss * padl - dm[3];
+  z0    = rssl + (rssu - rssl) * .5;
+
+  for (iss = 0; iss < fTPCParam->GetNRowLow(); ++iss) {
+    r1    = fTPCParam->GetPadRowRadiiLow(iss);
     r2    = r1 + dm[3] * 2.;
-    dm[0] = r1 * thl - 1.1;
-    dm[1] = r2 * thl - 1.1;
-    zz    = z0 + iss * padl;
+    dm[0] = r1 * thl - 2.63;
+    dm[1] = r2 * thl - 2.63;
+
+    zz    = -z0 + r1+dm[3];
+
     pMC->Gsposp("TSST", iss+1, "TSGA", 0, 0, zz, 0, "ONLY", dm, 4);
   }
   // ----------------------------------------------------- 
   //  thin sensitive strips (100 microns) placed at a center 
-  //  of each pad row (52 rows) in the "drift gas sector" 
+  //  of each pad row  in the "drift gas sector" 
   // ----------------------------------------------------- 
   pMC->Gsvolu("TLST", "TRD1", idtmed[403], dm, 0);
+
+  z0   = rlsl+ (rlsu - rlsl) * .5;
   
-  padl = 2.05;
-  z0   = (rlsu - rlsl) * .5;
-  dzz  = (rlsu - rlsl - padl * 51.) * .5;
-  z0   = -z0 + dzz;
-  
-  for (ils = 0; ils < 52; ++ils) {
-    r1    = rlsl + dzz + ils * padl - dm[3];
+  for (ils = 0; ils < fTPCParam->GetNRowUp(); ++ils) {
+    r1    = fTPCParam->GetPadRowRadiiUp(ils);
     r2    = r1 + dm[3] * 2.;
-    dm[0] = r1 * thu - 1.1;
-    dm[1] = r2 * thu - 1.1;
-    zz    = z0 + ils * padl;
+    dm[0] = r1 * thu - 2.63;
+    dm[1] = r2 * thu - 2.63;
+
+    zz    = -z0 + r1 +dm[3];
+
     pMC->Gsposp("TLST", ils+1, "TLGA", 0, 0, zz, 0, "ONLY", dm, 4);
   }
   // ------------------------------------------------ 
@@ -626,7 +630,7 @@ void AliTPCv1::CreateGeometry()
 }
 
 //_____________________________________________________________________________
-void AliTPCv1::DrawModule()
+void AliTPCv1::DrawDetector()
 {
   //
   // Draw a shaded view of the Time Projection Chamber version 1
index f2cf5f0f9ed5820b009fa597c2e04afdd0af645f..344bccc53ba64c3c6834f15b0ecda0849959dc6f 100644 (file)
@@ -17,7 +17,7 @@ public:
   virtual void  Init();
   virtual Int_t IsVersion() const {return 1;}
   virtual void  StepManager();
-  virtual void  DrawModule();
+  virtual void  DrawDetector();
 
 protected:
   Int_t fIdSens1;    //First  sensitive volume identifier
index 7f5b59d420c6f812641fbf325184e2bb33f2668d..6a3a9d23992cb431628de2e80ecf7983e21b4b92 100644 (file)
@@ -22,6 +22,9 @@
 #include "AliConst.h"
 #include <stdlib.h>
 
+#include "AliTPCParam.h"
+#include "AliTPCD.h"
+
 ClassImp(AliTPCv2)
  
 //_____________________________________________________________________________
@@ -57,7 +60,9 @@ void AliTPCv2::CreateGeometry()
 
   Int_t *idtmed = gAlice->Idtmed();
 
-  Float_t padl, tana;
+  AliTPCParam * fTPCParam = &(fDigParam->GetParam());
+
+  Float_t tana;
   Int_t isll;
   Float_t rlsl, wlsl, rssl, rlsu, wssl, wlsu, rssu, wssu;
   Int_t i;
@@ -72,7 +77,7 @@ void AliTPCv2::CreateGeometry()
   Int_t idr;
   Float_t thl, opl;
   Int_t ils, iss;
-  Float_t thu, opu, dzz;
+  Float_t thu, opu;
   Int_t ifl1 = 0, ifl2 = 0;
   Float_t phi1, phi2, phi3;
   
@@ -91,6 +96,7 @@ void AliTPCv2::CreateGeometry()
 
   } else {
     printf("*** ALL LOWER SECTORS SELECTED ***\n");
+    ifl1 = 1;
   }
 
   if (fSecAU >= 0) {
@@ -105,6 +111,7 @@ void AliTPCv2::CreateGeometry()
     
   } else {
     printf("*** ALL UPPER SECTORS SELECTED ***\n");
+    ifl1 = 1;
   }
   
   if (ifl1 == 0 && ifl2 == 0) {
@@ -201,18 +208,18 @@ void AliTPCv2::CreateGeometry()
   if (fSens >= 0) {
     pMC->Gsvolu("TSST", "TRD1", idtmed[403], dm, 0);
     dm[3] = .005;
-    padl  = 2.05;
-    z0    = (rssu - rssl) * .5;
-    dzz   = (rssu - rssl - padl * 22.) * .5;
-    z0    = -z0 + dzz;
+  
+    z0    = rssl + (rssu - rssl) * .5;
     
-    for (iss = 1; iss <= 23; ++iss) {
-      r1    = rssl + dzz + (iss - 1) * padl - dm[3];
+    for (iss = 0; iss < fTPCParam->GetNRowLow(); ++iss) {
+      r1    = fTPCParam->GetPadRowRadiiLow(iss);
       r2    = r1 + dm[3] * 2.;
       dm[0] = r1 * thl - .01;
       dm[1] = r2 * thl - .01;
-      zz    = z0 + (iss - 1) * padl;
-      pMC->Gsposp("TSST", iss, "TSGA", 0, 0, zz, 0, "ONLY", dm, 4);
+      
+      zz    = -z0 + r1 +dm[3];
+
+      pMC->Gsposp("TSST", iss+1, "TSGA", 0, 0, zz, 0, "ONLY", dm, 4);
     }
     pMC->Gsord("TSGA", 3);
   }
@@ -240,18 +247,18 @@ void AliTPCv2::CreateGeometry()
     pMC->Gsvolu("TLST", "TRD1", idtmed[403], dm, 0);
     
     dm[3] = .005;
-    padl  = 2.05;
-    z0    = (rlsu - rlsl) * .5;
-    dzz   = (rlsu - rlsl - padl * 51.) * .5;
-    z0    = -z0 + dzz;
+
+    z0   = rlsl+ (rlsu - rlsl) * .5;
     
-    for (ils = 1; ils <= 52; ++ils) {
-      r1    = rlsl + dzz + (ils - 1) * padl - dm[3];
+    for (ils = 0; ils <fTPCParam->GetNRowUp(); ++ils) {
+      r1    = fTPCParam->GetPadRowRadiiUp(ils);
       r2    = r1 + dm[3] * 2.;
-      dm[0] = r1 * thu - 1.1;
-      dm[1] = r2 * thu - 1.1;
-      zz    = z0 + (ils - 1) * padl;
-      pMC->Gsposp("TLST", ils, "TLGA", 0, 0, zz, 0, "ONLY", dm, 4);
+      dm[0] = r1 * thu - 2.63;
+      dm[1] = r2 * thu - 2.63;
+
+      zz  = -z0 + r1 +dm[3]; 
+
+      pMC->Gsposp("TLST", ils+1, "TLGA", 0, 0, zz, 0, "ONLY", dm, 4);
     }
     pMC->Gsord("TLGA", 3);
   }
@@ -670,7 +677,7 @@ void AliTPCv2::CreateGeometry()
 }
  
 //_____________________________________________________________________________
-void AliTPCv2::DrawModule()
+void AliTPCv2::DrawDetector()
 {
   //
   // Draw a shaded view of the Time Projection Chamber version 1
index a0c4503a168c7329e4efa38d79e16953e64f7edb..85287bb5a0dbcd840ba837921a789ddf5b0f633f 100644 (file)
@@ -17,7 +17,7 @@ public:
   virtual void  Init();
   virtual Int_t IsVersion() const {return 2;}
   virtual void  StepManager();
-  virtual void  DrawModule();
+  virtual void  DrawDetector();
 
 protected:
   Int_t fIdSens1;    //First  sensitive volume identifier - lower sector
index f31fd2a998009224d94a085c0d80051f97e046d4..d9e700c34c864c5d6230ac8923dea0bfbd927e33 100644 (file)
  
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
-AliTPC.o: /soft/root/include/TMath.h /soft/root/include/Rtypes.h
-AliTPC.o: /soft/root/include/RConfig.h /usr/include/stdio.h
-AliTPC.o: /usr/local/include/g++/libio.h /usr/include/_G_config.h
-AliTPC.o: /usr/include/gnu/types.h /usr/include/features.h
-AliTPC.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
-AliTPC.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stddef.h
-AliTPC.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stdarg.h
-AliTPC.o: /usr/include/stdio_lim.h /soft/root/include/DllImport.h
-AliTPC.o: /soft/root/include/TRandom.h /soft/root/include/TNamed.h
-AliTPC.o: /soft/root/include/TObject.h /soft/root/include/Varargs.h
-AliTPC.o: /soft/root/include/TStorage.h /soft/root/include/TBuffer.h
-AliTPC.o: /usr/include/string.h /soft/root/include/Bytes.h
-AliTPC.o: /soft/root/include/TList.h /soft/root/include/TSeqCollection.h
-AliTPC.o: /soft/root/include/TCollection.h /soft/root/include/TIterator.h
-AliTPC.o: /soft/root/include/TString.h /soft/root/include/TRefCnt.h
-AliTPC.o: /soft/root/include/TVector.h /soft/root/include/TError.h
-AliTPC.o: /soft/root/include/TGeometry.h /soft/root/include/THashList.h
-AliTPC.o: /soft/root/include/TNode.h /soft/root/include/TShape.h
-AliTPC.o: /soft/root/include/TMaterial.h /soft/root/include/TAttFill.h
-AliTPC.o: /soft/root/include/Gtypes.h /soft/root/include/Htypes.h
-AliTPC.o: /soft/root/include/TAttLine.h /soft/root/include/X3DBuffer.h
-AliTPC.o: /soft/root/include/TPolyLine3D.h /soft/root/include/TRotMatrix.h
-AliTPC.o: /soft/root/include/TTUBS.h /soft/root/include/TTUBE.h
+AliTPC.o: /soft/root/include/TMath.h /soft/root/include/TRandom.h
+AliTPC.o: /soft/root/include/TVector.h /soft/root/include/TGeometry.h
+AliTPC.o: /soft/root/include/TNode.h /soft/root/include/TTUBS.h
 AliTPC.o: /soft/root/include/TObjectTable.h
-AliTPC.o: /hdb2/offline/pro/include/GParticle.h AliTPC.h
-AliTPC.o: /hdb2/offline/pro/include/AliDetector.h
-AliTPC.o: /hdb2/offline/pro/include/AliModule.h
-AliTPC.o: /soft/root/include/TClonesArray.h /soft/root/include/TObjArray.h
-AliTPC.o: /soft/root/include/TBrowser.h /soft/root/include/TBrowserImp.h
-AliTPC.o: /soft/root/include/TAttMarker.h /soft/root/include/TArrayI.h
-AliTPC.o: /soft/root/include/TArray.h /hdb2/offline/pro/include/AliHit.h
+AliTPC.o: /hdb2/offline/pro/include/GParticle.h /soft/root/include/TObject.h
+AliTPC.o: AliTPC.h /hdb2/offline/pro/include/AliDetector.h
+AliTPC.o: /hdb2/offline/pro/include/AliModule.h /soft/root/include/TNamed.h
+AliTPC.o: /soft/root/include/TClonesArray.h /soft/root/include/TBrowser.h
+AliTPC.o: /soft/root/include/TAttLine.h /soft/root/include/TAttMarker.h
+AliTPC.o: /soft/root/include/TArrayI.h /hdb2/offline/pro/include/AliHit.h
 AliTPC.o: /hdb2/offline/pro/include/AliDigit.h AliTPCSecGeo.h
-AliTPC.o: /soft/root/include/TMatrix.h /soft/root/include/TMatrixUtils.h
-AliTPC.o: /hdb2/offline/pro/include/AliRun.h /soft/root/include/TROOT.h
-AliTPC.o: /soft/root/include/TDirectory.h /soft/root/include/TDatime.h
+AliTPC.o: /soft/root/include/TMatrix.h /hdb2/offline/pro/include/AliRun.h
+AliTPC.o: /soft/root/include/TROOT.h /soft/root/include/TList.h
 AliTPC.o: /soft/root/include/TStopwatch.h /soft/root/include/TTree.h
-AliTPC.o: /soft/root/include/TBranch.h /soft/root/include/TStringLong.h
-AliTPC.o: /soft/root/include/TCut.h /hdb2/offline/pro/include/AliHeader.h
+AliTPC.o: /hdb2/offline/pro/include/AliHeader.h
 AliTPC.o: /hdb2/offline/pro/include/AliMagF.h
 AliTPC.o: /hdb2/offline/pro/include/AliMC.h
 AliTPC.o: /hdb2/offline/pro/include/AliGenerator.h
 AliTPC.o: /soft/root/include/TArrayF.h /soft/root/include/TGenerator.h
 AliTPC.o: /hdb2/offline/pro/include/AliLego.h /soft/root/include/TH2.h
-AliTPC.o: /soft/root/include/TH1.h /soft/root/include/TAxis.h
-AliTPC.o: /soft/root/include/TAttAxis.h /usr/local/include/g++/fstream.h
 AliTPC.o: /usr/local/include/g++/iostream.h
-AliTPC.o: /usr/local/include/g++/streambuf.h /soft/root/include/TLego.h
-AliTPC.o: /soft/root/include/TF1.h /soft/root/include/TFormula.h
-AliTPC.o: /soft/root/include/TMethodCall.h /soft/root/include/TGaxis.h
-AliTPC.o: /soft/root/include/TLine.h /soft/root/include/TAttText.h
-AliTPC.o: /soft/root/include/TArrayC.h /soft/root/include/TArrayS.h
-AliTPC.o: /soft/root/include/TArrayD.h
-AliTPCv0.o: /soft/root/include/TMath.h /soft/root/include/Rtypes.h
-AliTPCv0.o: /soft/root/include/RConfig.h /usr/include/stdio.h
-AliTPCv0.o: /usr/local/include/g++/libio.h /usr/include/_G_config.h
-AliTPCv0.o: /usr/include/gnu/types.h /usr/include/features.h
-AliTPCv0.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
-AliTPCv0.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stddef.h
-AliTPCv0.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stdarg.h
-AliTPCv0.o: /usr/include/stdio_lim.h /soft/root/include/DllImport.h
-AliTPCv0.o: /soft/root/include/TGeometry.h /soft/root/include/THashList.h
-AliTPCv0.o: /soft/root/include/TNode.h /soft/root/include/TShape.h
-AliTPCv0.o: /soft/root/include/TMaterial.h /soft/root/include/TAttFill.h
-AliTPCv0.o: /soft/root/include/Gtypes.h /soft/root/include/Htypes.h
-AliTPCv0.o: /soft/root/include/TAttLine.h /soft/root/include/X3DBuffer.h
-AliTPCv0.o: /soft/root/include/TPolyLine3D.h /soft/root/include/TString.h
-AliTPCv0.o: /usr/include/string.h /soft/root/include/TRefCnt.h
-AliTPCv0.o: /soft/root/include/TRotMatrix.h /soft/root/include/TTUBE.h
-AliTPCv0.o: AliTPCv0.h AliTPC.h /hdb2/offline/pro/include/AliDetector.h
+AliTPC.o: /usr/local/include/g++/streambuf.h /usr/local/include/g++/libio.h
+AliTPC.o: /usr/include/_G_config.h /usr/include/gnu/types.h
+AliTPC.o: /usr/include/features.h /usr/include/sys/cdefs.h
+AliTPC.o: /usr/include/gnu/stubs.h
+AliTPC.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stddef.h
+AliTPC.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stdarg.h
+AliTPC.o: /usr/local/include/g++/fstream.h
+AliTPCv0.o: /soft/root/include/TMath.h /soft/root/include/TGeometry.h
+AliTPCv0.o: /soft/root/include/TNode.h /soft/root/include/TTUBE.h AliTPCv0.h
+AliTPCv0.o: AliTPC.h /hdb2/offline/pro/include/AliDetector.h
 AliTPCv0.o: /hdb2/offline/pro/include/AliModule.h /soft/root/include/TNamed.h
-AliTPCv0.o: /soft/root/include/TObject.h /soft/root/include/Varargs.h
-AliTPCv0.o: /soft/root/include/TStorage.h /soft/root/include/TBuffer.h
-AliTPCv0.o: /soft/root/include/Bytes.h /soft/root/include/TList.h
-AliTPCv0.o: /soft/root/include/TSeqCollection.h
-AliTPCv0.o: /soft/root/include/TCollection.h /soft/root/include/TIterator.h
-AliTPCv0.o: /soft/root/include/TClonesArray.h /soft/root/include/TObjArray.h
-AliTPCv0.o: /soft/root/include/TBrowser.h /soft/root/include/TBrowserImp.h
-AliTPCv0.o: /soft/root/include/TAttMarker.h /soft/root/include/TArrayI.h
-AliTPCv0.o: /soft/root/include/TArray.h /hdb2/offline/pro/include/AliHit.h
-AliTPCv0.o: /hdb2/offline/pro/include/AliDigit.h AliTPCSecGeo.h
-AliTPCv0.o: /soft/root/include/TMatrix.h /soft/root/include/TMatrixUtils.h
+AliTPCv0.o: /soft/root/include/TClonesArray.h /soft/root/include/TBrowser.h
+AliTPCv0.o: /soft/root/include/TAttLine.h /soft/root/include/TAttMarker.h
+AliTPCv0.o: /soft/root/include/TArrayI.h /hdb2/offline/pro/include/AliHit.h
+AliTPCv0.o: /soft/root/include/TObject.h /hdb2/offline/pro/include/AliDigit.h
+AliTPCv0.o: AliTPCSecGeo.h /soft/root/include/TMatrix.h
 AliTPCv0.o: /hdb2/offline/pro/include/AliRun.h /soft/root/include/TROOT.h
-AliTPCv0.o: /soft/root/include/TDirectory.h /soft/root/include/TDatime.h
-AliTPCv0.o: /soft/root/include/TStopwatch.h /soft/root/include/TTree.h
-AliTPCv0.o: /soft/root/include/TBranch.h /soft/root/include/TStringLong.h
-AliTPCv0.o: /soft/root/include/TCut.h /hdb2/offline/pro/include/AliHeader.h
+AliTPCv0.o: /soft/root/include/TList.h /soft/root/include/TStopwatch.h
+AliTPCv0.o: /soft/root/include/TTree.h /hdb2/offline/pro/include/AliHeader.h
 AliTPCv0.o: /hdb2/offline/pro/include/AliMagF.h /soft/root/include/TVector.h
-AliTPCv0.o: /soft/root/include/TError.h /hdb2/offline/pro/include/AliMC.h
+AliTPCv0.o: /hdb2/offline/pro/include/AliMC.h
 AliTPCv0.o: /hdb2/offline/pro/include/AliGenerator.h
 AliTPCv0.o: /soft/root/include/TArrayF.h /soft/root/include/TGenerator.h
 AliTPCv0.o: /hdb2/offline/pro/include/AliLego.h /soft/root/include/TH2.h
-AliTPCv0.o: /soft/root/include/TH1.h /soft/root/include/TAxis.h
-AliTPCv0.o: /soft/root/include/TAttAxis.h /usr/local/include/g++/fstream.h
 AliTPCv0.o: /usr/local/include/g++/iostream.h
-AliTPCv0.o: /usr/local/include/g++/streambuf.h /soft/root/include/TLego.h
-AliTPCv0.o: /soft/root/include/TF1.h /soft/root/include/TFormula.h
-AliTPCv0.o: /soft/root/include/TMethodCall.h /soft/root/include/TGaxis.h
-AliTPCv0.o: /soft/root/include/TLine.h /soft/root/include/TAttText.h
-AliTPCv0.o: /soft/root/include/TArrayC.h /soft/root/include/TArrayS.h
-AliTPCv0.o: /soft/root/include/TArrayD.h /hdb2/offline/pro/include/AliConst.h
-AliTPCv1.o: /soft/root/include/TMath.h /soft/root/include/Rtypes.h
-AliTPCv1.o: /soft/root/include/RConfig.h /usr/include/stdio.h
-AliTPCv1.o: /usr/local/include/g++/libio.h /usr/include/_G_config.h
-AliTPCv1.o: /usr/include/gnu/types.h /usr/include/features.h
-AliTPCv1.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
-AliTPCv1.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stddef.h
-AliTPCv1.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stdarg.h
-AliTPCv1.o: /usr/include/stdio_lim.h /soft/root/include/DllImport.h
-AliTPCv1.o: /soft/root/include/TGeometry.h /soft/root/include/THashList.h
-AliTPCv1.o: /soft/root/include/TNode.h /soft/root/include/TShape.h
-AliTPCv1.o: /soft/root/include/TMaterial.h /soft/root/include/TAttFill.h
-AliTPCv1.o: /soft/root/include/Gtypes.h /soft/root/include/Htypes.h
-AliTPCv1.o: /soft/root/include/TAttLine.h /soft/root/include/X3DBuffer.h
-AliTPCv1.o: /soft/root/include/TPolyLine3D.h /soft/root/include/TString.h
-AliTPCv1.o: /usr/include/string.h /soft/root/include/TRefCnt.h
-AliTPCv1.o: /soft/root/include/TRotMatrix.h /soft/root/include/TBRIK.h
+AliTPCv0.o: /usr/local/include/g++/streambuf.h /usr/local/include/g++/libio.h
+AliTPCv0.o: /usr/include/_G_config.h /usr/include/gnu/types.h
+AliTPCv0.o: /usr/include/features.h /usr/include/sys/cdefs.h
+AliTPCv0.o: /usr/include/gnu/stubs.h
+AliTPCv0.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stddef.h
+AliTPCv0.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stdarg.h
+AliTPCv0.o: /usr/local/include/g++/fstream.h
+AliTPCv0.o: /hdb2/offline/pro/include/AliConst.h
+AliTPCv1.o: /soft/root/include/TMath.h /soft/root/include/TGeometry.h
+AliTPCv1.o: /soft/root/include/TNode.h /soft/root/include/TBRIK.h
 AliTPCv1.o: /soft/root/include/TTUBE.h AliTPCv1.h AliTPC.h
 AliTPCv1.o: /hdb2/offline/pro/include/AliDetector.h
 AliTPCv1.o: /hdb2/offline/pro/include/AliModule.h /soft/root/include/TNamed.h
-AliTPCv1.o: /soft/root/include/TObject.h /soft/root/include/Varargs.h
-AliTPCv1.o: /soft/root/include/TStorage.h /soft/root/include/TBuffer.h
-AliTPCv1.o: /soft/root/include/Bytes.h /soft/root/include/TList.h
-AliTPCv1.o: /soft/root/include/TSeqCollection.h
-AliTPCv1.o: /soft/root/include/TCollection.h /soft/root/include/TIterator.h
-AliTPCv1.o: /soft/root/include/TClonesArray.h /soft/root/include/TObjArray.h
-AliTPCv1.o: /soft/root/include/TBrowser.h /soft/root/include/TBrowserImp.h
-AliTPCv1.o: /soft/root/include/TAttMarker.h /soft/root/include/TArrayI.h
-AliTPCv1.o: /soft/root/include/TArray.h /hdb2/offline/pro/include/AliHit.h
-AliTPCv1.o: /hdb2/offline/pro/include/AliDigit.h AliTPCSecGeo.h
-AliTPCv1.o: /soft/root/include/TMatrix.h /soft/root/include/TMatrixUtils.h
+AliTPCv1.o: /soft/root/include/TClonesArray.h /soft/root/include/TBrowser.h
+AliTPCv1.o: /soft/root/include/TAttLine.h /soft/root/include/TAttMarker.h
+AliTPCv1.o: /soft/root/include/TArrayI.h /hdb2/offline/pro/include/AliHit.h
+AliTPCv1.o: /soft/root/include/TObject.h /hdb2/offline/pro/include/AliDigit.h
+AliTPCv1.o: AliTPCSecGeo.h /soft/root/include/TMatrix.h
 AliTPCv1.o: /hdb2/offline/pro/include/AliRun.h /soft/root/include/TROOT.h
-AliTPCv1.o: /soft/root/include/TDirectory.h /soft/root/include/TDatime.h
-AliTPCv1.o: /soft/root/include/TStopwatch.h /soft/root/include/TTree.h
-AliTPCv1.o: /soft/root/include/TBranch.h /soft/root/include/TStringLong.h
-AliTPCv1.o: /soft/root/include/TCut.h /hdb2/offline/pro/include/AliHeader.h
+AliTPCv1.o: /soft/root/include/TList.h /soft/root/include/TStopwatch.h
+AliTPCv1.o: /soft/root/include/TTree.h /hdb2/offline/pro/include/AliHeader.h
 AliTPCv1.o: /hdb2/offline/pro/include/AliMagF.h /soft/root/include/TVector.h
-AliTPCv1.o: /soft/root/include/TError.h /hdb2/offline/pro/include/AliMC.h
+AliTPCv1.o: /hdb2/offline/pro/include/AliMC.h
 AliTPCv1.o: /hdb2/offline/pro/include/AliGenerator.h
 AliTPCv1.o: /soft/root/include/TArrayF.h /soft/root/include/TGenerator.h
 AliTPCv1.o: /hdb2/offline/pro/include/AliLego.h /soft/root/include/TH2.h
-AliTPCv1.o: /soft/root/include/TH1.h /soft/root/include/TAxis.h
-AliTPCv1.o: /soft/root/include/TAttAxis.h /usr/local/include/g++/fstream.h
 AliTPCv1.o: /usr/local/include/g++/iostream.h
-AliTPCv1.o: /usr/local/include/g++/streambuf.h /soft/root/include/TLego.h
-AliTPCv1.o: /soft/root/include/TF1.h /soft/root/include/TFormula.h
-AliTPCv1.o: /soft/root/include/TMethodCall.h /soft/root/include/TGaxis.h
-AliTPCv1.o: /soft/root/include/TLine.h /soft/root/include/TAttText.h
-AliTPCv1.o: /soft/root/include/TArrayC.h /soft/root/include/TArrayS.h
-AliTPCv1.o: /soft/root/include/TArrayD.h /hdb2/offline/pro/include/AliConst.h
-AliTPCv2.o: /soft/root/include/TMath.h /soft/root/include/Rtypes.h
-AliTPCv2.o: /soft/root/include/RConfig.h /usr/include/stdio.h
-AliTPCv2.o: /usr/local/include/g++/libio.h /usr/include/_G_config.h
-AliTPCv2.o: /usr/include/gnu/types.h /usr/include/features.h
-AliTPCv2.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
-AliTPCv2.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stddef.h
-AliTPCv2.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stdarg.h
-AliTPCv2.o: /usr/include/stdio_lim.h /soft/root/include/DllImport.h
-AliTPCv2.o: /soft/root/include/TGeometry.h /soft/root/include/THashList.h
+AliTPCv1.o: /usr/local/include/g++/streambuf.h /usr/local/include/g++/libio.h
+AliTPCv1.o: /usr/include/_G_config.h /usr/include/gnu/types.h
+AliTPCv1.o: /usr/include/features.h /usr/include/sys/cdefs.h
+AliTPCv1.o: /usr/include/gnu/stubs.h
+AliTPCv1.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stddef.h
+AliTPCv1.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stdarg.h
+AliTPCv1.o: /usr/local/include/g++/fstream.h
+AliTPCv1.o: /hdb2/offline/pro/include/AliConst.h
+AliTPCv2.o: /soft/root/include/TMath.h /soft/root/include/TGeometry.h
 AliTPCv2.o: AliTPCv2.h AliTPC.h /hdb2/offline/pro/include/AliDetector.h
 AliTPCv2.o: /hdb2/offline/pro/include/AliModule.h /soft/root/include/TNamed.h
-AliTPCv2.o: /soft/root/include/TObject.h /soft/root/include/Varargs.h
-AliTPCv2.o: /soft/root/include/TStorage.h /soft/root/include/TBuffer.h
-AliTPCv2.o: /usr/include/string.h /soft/root/include/Bytes.h
-AliTPCv2.o: /soft/root/include/TList.h /soft/root/include/TSeqCollection.h
-AliTPCv2.o: /soft/root/include/TCollection.h /soft/root/include/TIterator.h
-AliTPCv2.o: /soft/root/include/TString.h /soft/root/include/TRefCnt.h
-AliTPCv2.o: /soft/root/include/TClonesArray.h /soft/root/include/TObjArray.h
-AliTPCv2.o: /soft/root/include/TBrowser.h /soft/root/include/TBrowserImp.h
+AliTPCv2.o: /soft/root/include/TClonesArray.h /soft/root/include/TBrowser.h
 AliTPCv2.o: /soft/root/include/TAttLine.h /soft/root/include/TAttMarker.h
-AliTPCv2.o: /soft/root/include/TArrayI.h /soft/root/include/TArray.h
-AliTPCv2.o: /hdb2/offline/pro/include/AliHit.h
-AliTPCv2.o: /hdb2/offline/pro/include/AliDigit.h AliTPCSecGeo.h
-AliTPCv2.o: /soft/root/include/TMatrix.h /soft/root/include/TMatrixUtils.h
+AliTPCv2.o: /soft/root/include/TArrayI.h /hdb2/offline/pro/include/AliHit.h
+AliTPCv2.o: /soft/root/include/TObject.h /hdb2/offline/pro/include/AliDigit.h
+AliTPCv2.o: AliTPCSecGeo.h /soft/root/include/TMatrix.h
 AliTPCv2.o: /hdb2/offline/pro/include/AliRun.h /soft/root/include/TROOT.h
-AliTPCv2.o: /soft/root/include/TDirectory.h /soft/root/include/TDatime.h
-AliTPCv2.o: /soft/root/include/TStopwatch.h /soft/root/include/TTree.h
-AliTPCv2.o: /soft/root/include/TBranch.h /soft/root/include/TStringLong.h
-AliTPCv2.o: /soft/root/include/TCut.h /hdb2/offline/pro/include/AliHeader.h
+AliTPCv2.o: /soft/root/include/TList.h /soft/root/include/TStopwatch.h
+AliTPCv2.o: /soft/root/include/TTree.h /hdb2/offline/pro/include/AliHeader.h
 AliTPCv2.o: /hdb2/offline/pro/include/AliMagF.h /soft/root/include/TVector.h
-AliTPCv2.o: /soft/root/include/TError.h /hdb2/offline/pro/include/AliMC.h
+AliTPCv2.o: /hdb2/offline/pro/include/AliMC.h
 AliTPCv2.o: /hdb2/offline/pro/include/AliGenerator.h
 AliTPCv2.o: /soft/root/include/TArrayF.h /soft/root/include/TGenerator.h
 AliTPCv2.o: /hdb2/offline/pro/include/AliLego.h /soft/root/include/TH2.h
-AliTPCv2.o: /soft/root/include/TH1.h /soft/root/include/TAxis.h
-AliTPCv2.o: /soft/root/include/TAttAxis.h /usr/local/include/g++/fstream.h
 AliTPCv2.o: /usr/local/include/g++/iostream.h
-AliTPCv2.o: /usr/local/include/g++/streambuf.h /soft/root/include/TLego.h
-AliTPCv2.o: /soft/root/include/TF1.h /soft/root/include/TFormula.h
-AliTPCv2.o: /soft/root/include/TMethodCall.h /soft/root/include/TGaxis.h
-AliTPCv2.o: /soft/root/include/TLine.h /soft/root/include/TAttText.h
-AliTPCv2.o: /soft/root/include/TArrayC.h /soft/root/include/TArrayS.h
-AliTPCv2.o: /soft/root/include/TArrayD.h /hdb2/offline/pro/include/AliConst.h
-AliTPCv2.o: /usr/include/stdlib.h /usr/include/sys/types.h
-AliTPCv2.o: /usr/include/time.h /usr/include/endian.h /usr/include/bytesex.h
+AliTPCv2.o: /usr/local/include/g++/streambuf.h /usr/local/include/g++/libio.h
+AliTPCv2.o: /usr/include/_G_config.h /usr/include/gnu/types.h
+AliTPCv2.o: /usr/include/features.h /usr/include/sys/cdefs.h
+AliTPCv2.o: /usr/include/gnu/stubs.h
+AliTPCv2.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stddef.h
+AliTPCv2.o: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include/stdarg.h
+AliTPCv2.o: /usr/local/include/g++/fstream.h
+AliTPCv2.o: /hdb2/offline/pro/include/AliConst.h /usr/include/stdlib.h
+AliTPCv2.o: /usr/include/sys/types.h /usr/include/time.h
+AliTPCv2.o: /usr/include/endian.h /usr/include/bytesex.h
 AliTPCv2.o: /usr/include/sys/select.h /usr/include/selectbits.h
 AliTPCv2.o: /usr/include/alloca.h
index ae12741f0d487fcf9715eb63bc5bc636f690dee2..799679ead9ab5895e34defb780a14c49e6d19c94 100644 (file)
@@ -9,7 +9,8 @@ PACKAGE = TPC
 
 # C++ sources
 
-SRCS          = AliTPC.cxx  AliTPCv0.cxx    AliTPCv1.cxx      AliTPCv2.cxx  
+SRCS          = AliTPC.cxx  AliTPCv0.cxx    AliTPCv1.cxx      AliTPCv2.cxx  \
+               AliTPCD.cxx AliTPCPRF2D.cxx AliTPCRF1D.cxx AliTPCParam.cxx
 
 # C++ Headers
 
@@ -46,7 +47,6 @@ FFLAGS      = $(FOPT)
 # Target
 
 SLIBRARY       = $(ALICE_ROOT)/lib/libTPC.$(SL)
-ALIBRARY       = $(ALICE_ROOT)/lib/libTPC.a
 
 default:       $(SLIBRARY)
 
index d67edf9bb105e6f1014038ff5ff8f1e86c8178ed..0f13a747435a7b7aa11ed3d7e4c54580014717b2 100644 (file)
 #pragma link C++ class  AliTPCcluster;
 #pragma link C++ class  AliTPCtrack;
 
+#pragma link C++ class  AliTPCParam-;
+#pragma link C++ class  AliTPCD-;
+#pragma link C++ class  AliTPCRF1D-;
+#pragma link C++ class  AliTPCPRF2D-;
+
+
+//Marian Ivanov  objects  - doesn't go to oficial version
+#pragma link C++ class AliArrayI; //MI change 18.5.1999 - maybe better to change it in Root
+#pragma link C++ class AliArrayS; //MI change 18.5.1999 - maybe better to change it in Root
+
+#pragma link C++ class AliSegment;
+#pragma link C++ class AliSegmentArray;
+#pragma link C++ class AliDigits;
+#pragma link C++ class AliSimDigits;
+
+#pragma link C++ class AliTPCDigitsH-;
+#pragma link C++ class AliClusterFinder-;
+#pragma link C++ class AliCluster;
+#pragma link C++ class THit;
+#pragma link C++ class THitPAngle;
+#pragma link C++ class AliTPCup-;
+#pragma link C++ class AliH2F;
+#pragma link C++ class AliTPCClustersRow;
+#pragma link C++ class AliTPCClustersArray;
+
+
 #endif