bug fixed
[u/mrichter/AliRoot.git] / T0 / AliT0Digitizer.cxx
index 4e4369c..1a27aec 100644 (file)
@@ -95,7 +95,7 @@ AliT0Digitizer::AliT0Digitizer(AliRunDigitizer* manager)
     Double_t *x1 = new Double_t[np];
     Double_t *y1 = new Double_t[np];
     for (Int_t ii=0; ii<np; ii++) {
-      y1[ii]=y[np-ii]; x1[ii]=x[np-ii];
+      y1[ii]=y[np-ii-1]; x1[ii]=x[np-ii-1];
     }
     
     TGraph *grInverse = new TGraph(np,y1,x1);
@@ -160,12 +160,13 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
   Int_t threshold =50; //photoelectrons
   Float_t zdetA, zdetC;
   Int_t sumMultCoeff = 100;
+  Int_t refpoint=0;
   TH1F *hr;
 
 
   
   Int_t ph2Mip = fParam->GetPh2Mip();     
-  Int_t channelWidth = fParam->GetChannelWidth() ;  
+  Float_t channelWidth = fParam->GetChannelWidth() ;  
   Float_t delayVertex = fParam->GetTimeDelayTVD();
    
   zdetC = TMath::Abs(fParam->GetZPosition("T0/C/PMT1"));
@@ -256,9 +257,9 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
        if(timeGaus[ipmt]<besttimeC){
          besttimeC=timeGaus[ipmt]; //timeC
          pmtBestC=ipmt;}
-     }
+      }
     }
-     for ( Int_t ipmt=12; ipmt<24; ipmt++){
+    for ( Int_t ipmt=12; ipmt<24; ipmt++){
       if(countE[ipmt] > threshold) {
        timeGaus[ipmt]=gRandom->Gaus(time[ipmt],25); 
        if(timeGaus[ipmt]<besttimeA) {
@@ -266,25 +267,10 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
          pmtBestA=ipmt;}
       }        
     }
-   //folding with alignmentz position distribution  
-    if( besttimeC > 10000. && besttimeC <15000)
-      bestCTDC=Int_t ((besttimeC+timeDelayCFD[pmtBestC])
-                        /channelWidth);
-    if( besttimeA > 10000. && besttimeA <15000)
-      bestATDC=Int_t ((besttimeA+timeDelayCFD[pmtBestA])
-                       /channelWidth);
 
-    if (bestATDC < 99999 && bestCTDC < 99999)
-      {
-       timeDiff=Int_t (((besttimeC-besttimeA)+1000*delayVertex)
-                       /channelWidth);
-       meanTime=Int_t (((besttimeC+timeDelayCFD[pmtBestC]+
-                         besttimeA+timeDelayCFD[pmtBestA])/2.)
-                       /channelWidth);
-      }
-       AliDebug(10,Form(" time A& C %i %i  time diff && mean time in channels %i %i",bestATDC,bestCTDC, timeDiff, meanTime));
-         timeDelayCFD[0] = fParam->GetTimeDelayCFD(0);
+    timeDelayCFD[0] = fParam->GetTimeDelayCFD(0);
+    Int_t meanTimeDelay=200;
+
     for (Int_t i=0; i<24; i++)
       {
                Float_t  al = countE[i]; 
@@ -302,7 +288,7 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
          sl = gr->Eval(qt);
 
          trLED = Int_t(( timeGaus[i] + 1000*sl )/channelWidth);
-         qtCh=Int_t (1000.*TMath::Log(qt)) / channelWidth;
+         qtCh=Int_t (1000.*TMath::Log(qt) / channelWidth);
          fADC0->AddAt(0,i);
          fADC->AddAt(qtCh,i);
          ftimeLED->AddAt(trLED,i); 
@@ -324,6 +310,23 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
        }
       } //pmt loop
 
+    //folding with alignmentz position distribution  
+    if( besttimeC > 10000. && besttimeC <15000)
+      bestCTDC=Int_t ((besttimeC+timeDelayCFD[pmtBestC])
+                        /channelWidth);
+    if( besttimeA > 10000. && besttimeA <15000)
+      bestATDC=Int_t ((besttimeA+timeDelayCFD[pmtBestA])
+                       /channelWidth);
+
+    if (bestATDC < 99999 && bestCTDC < 99999)
+      {
+       timeDiff=Int_t (((besttimeC-besttimeA)+1000*delayVertex)
+                       /channelWidth);
+       meanTime=Int_t (((besttimeC+besttimeA)/2. + meanTimeDelay)/channelWidth);
+      }
+       AliDebug(10,Form(" time A& C %i %i  time diff && mean time in channels %i %i",bestATDC,bestCTDC, timeDiff, meanTime));
+
     if (sumMult > threshold){
       fSumMult =  Int_t (1000.* TMath::Log(Double_t(sumMult) / Double_t(sumMultCoeff))
                         /channelWidth);
@@ -331,10 +334,11 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
                      sumMult, fSumMult, fSumMult*channelWidth));
     }
 
-      fT0->AddDigit(bestATDC,bestCTDC,meanTime,timeDiff,fSumMult,
+    fT0->AddDigit(bestATDC,bestCTDC,meanTime,timeDiff,fSumMult, refpoint,
                       ftimeCFD,fADC0,ftimeLED,fADC);
      
-      AliDebug(10,Form(" Digits wrote bestATDC %i bestCTDC %i  meanTime %i  timeDiff %i fSumMult %i ", bestATDC,bestCTDC,meanTime,timeDiff,fSumMult ));
+    
+      AliDebug(10,Form(" Digits wrote refpoint %i bestATDC %i bestCTDC %i  meanTime %i  timeDiff %i fSumMult %i ",refpoint ,bestATDC,bestCTDC,meanTime,timeDiff,fSumMult ));
     pOutStartLoader->UnloadHits();
   } //input streams loop