the same calibration for cosmic and pdc data
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 May 2009 07:37:54 +0000 (07:37 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 May 2009 07:37:54 +0000 (07:37 +0000)
T0/AliT0Calibrator.cxx
T0/AliT0Digitizer.cxx
T0/AliT0RawData.cxx
T0/AliT0Reconstructor.cxx

index 6cae77a..7337d3a 100644 (file)
@@ -49,35 +49,15 @@ ClassImp(AliT0Calibrator)
    param->Init();
   
   fChannelWidth = param->GetChannelWidth() ;  
-  Double_t *grY ; //= new grY[2500] ;
-  // Double_t *grX ;
-  Int_t index[25000];
-  Bool_t down=true;
   for (Int_t i=0; i<24; i++){
     fMaxValue[i]=0;
     fTimeDelayCFD[i] = Int_t (param->GetTimeDelayCFD(i));
-     
+    
     TGraph* fu = param ->GetWalk(i);
-     //    TGraph* fu  = param ->GetAmpLEDRec(i);
-       fWalk.AddAtAndExpand(fu,i);
-       
-  if(fu) {
-      Int_t np=fu->GetN();
-      if(np>0) {
-       grY = fu->GetY();
-       //      grX[i] = fu->GetX();
-       TMath::Sort(np, grY, index,down);
-       fMaxValue[i]=Int_t(grY[index[0]]);
-
-      }
-    }
-       
+    //    TGraph* fu  = param ->GetAmpLEDRec(i);
+    fWalk.AddAtAndExpand(fu,i);        
   }
-
-  //  delete [] grY;
-  //  delete [] grX;
   
-  //
 }
 //_____________________________________________________________________________
 
@@ -107,7 +87,6 @@ AliT0Calibrator &AliT0Calibrator::operator=(const AliT0Calibrator &r)
 }
 
 
-
 //____________________________________________________________________
 Int_t  AliT0Calibrator::WalkCorrection(Int_t ipmt, Int_t qt, Int_t time, TString option) 
 {
@@ -116,27 +95,15 @@ Int_t  AliT0Calibrator::WalkCorrection(Int_t ipmt, Int_t qt, Int_t time, TString
   Int_t walk=0;
 
   Int_t timeEq=0, timeWalk=0;  
-  //  TGraph* fu1 = param ->GetWalk(ipmt);
-  //   TGraph* fu1  = param ->GetAmpLEDRec(ipmt);
-   TGraph *fu1=(TGraph*) fWalk.At(ipmt);
-  if(fu1 && fu1->GetN()>0) {
+  TGraph *fu1=(TGraph*) fWalk.At(ipmt);
+  if(fu1 && fu1->GetN()>0) 
     walk=Int_t(fu1->Eval(Double_t(qt)));
-  }
-  if (option == "pdc") {
-    timeWalk = time + Int_t(fMaxValue[ipmt]-walk) ;
-    //    timeEq= timeWalk - fTimeDelayCFD[ipmt];
-    timeEq= timeWalk - fTimeDelayCFD[ipmt]; //for the same as cosmic
-     AliDebug(10,Form(" ipmt %i time before %i timeWalk %i ,  qt %i timeEq %i \n ",
-                ipmt, time,timeWalk, qt, timeEq ));
-  }
-  if (option == "cosmic") {
-    timeWalk = time + Int_t((fMaxValue[ipmt]-walk)) ;
-    if(walk <1  )  timeWalk = time  ;
-     timeEq= timeWalk - fTimeDelayCFD[ipmt];
-     AliDebug(10,Form(" ipmt %i time before %i timeWalk %i ,  qt %i timeEq %i \n ",
-                ipmt, time,timeWalk, qt, timeEq ));
-  }
+  
+  timeWalk = time + walk   ;
+  timeEq= timeWalk - fTimeDelayCFD[ipmt];
+  AliDebug(10,Form(" ipmt %i time before %i timeWalk %i , walk %i  qt %i timeEq %i \n ",
+                  ipmt, time,timeWalk, walk, qt, timeEq ));
+  
   return timeEq;
 }
 
index 6898eff..421fbae 100644 (file)
@@ -61,6 +61,7 @@ ClassImp(AliT0Digitizer)
                                     fADC0 (new TArrayI(24)),
                                     fSumMult(0),
                                     fAmpLED(0),
+                                     fAmpQTC(0),
                                     fParam(0)
 
 
@@ -81,6 +82,7 @@ AliT0Digitizer::AliT0Digitizer(AliRunDigitizer* manager)
    fADC0 (new TArrayI(24)),
    fSumMult(0),
    fAmpLED(0),
+   fAmpQTC(0),
    fParam(0)
 {
 // ctor which should be used
@@ -88,33 +90,37 @@ AliT0Digitizer::AliT0Digitizer(AliRunDigitizer* manager)
   AliDebug(1,"processed");
   fParam = AliT0Parameters::Instance();
   fParam->Init();
-  Int_t index[25000];
-  Bool_t down=true;
 
   for (Int_t i=0; i<24; i++){
-    TGraph* gr = fParam ->GetAmpLEDRec(i);
+    TGraph* gr = fParam ->GetAmpLED(i);
     Int_t np = gr->GetN();
     Double_t *x = gr->GetX();
     Double_t *y = gr->GetY();
-
+    
     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-1]; x1[ii]=x[np-ii-1];
+      y1[ii]=y[np-ii-1]; 
+      x1[ii]=x[np-ii-1];
     }
     
     TGraph *grInverse = new TGraph(np,y1,x1);
     fAmpLED.AddAtAndExpand(grInverse,i);
-
-     TGraph* grw = fParam ->GetWalk(i);
-      Int_t npw = grw->GetN();
-     Double_t *yw = grw->GetY();
-    TMath::Sort(npw, yw, index,down);
-    fMaxValue[i]=Int_t(yw[index[0]]);
   }
-
-    //    delete [] x1;
-    //   delete [] y1;
+  for (Int_t i=0; i<24; i++){
+    TGraph* grq = fParam ->GetQTC(i);
+    Int_t npq = grq->GetN();
+    Double_t *xq = grq->GetX();
+    Double_t *yq = grq->GetY();
+    Double_t *x1q = new Double_t[npq];
+    Double_t *y1q = new Double_t[npq];
+    for (Int_t ii=1; ii<npq; ii++) {
+      y1q[ii]=yq[ii-1]; 
+      x1q[ii]=xq[ii-1];
+    }
+  TGraph *grInverseQTC = new TGraph(npq,y1q,x1q);
+  fAmpQTC.AddAtAndExpand(grInverseQTC,i);
+  }
 }
 
 //------------------------------------------------------------------------
@@ -168,7 +174,7 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
   Float_t sl, qt;
   Int_t  bestATDC=0;
   Int_t  bestCTDC=0;
-  Int_t qtCh=0;
+  Float_t qtCh=0;
   Float_t time[24], besttime[24], timeGaus[24] ;
   //Q->T-> coefficients !!!! should be asked!!!
   Float_t timeDelayCFD[24];
@@ -181,9 +187,11 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
   Float_t channelWidth = fParam->GetChannelWidth() ;  
   Float_t delayVertex = fParam->GetTimeDelayTVD();
    
+
   zdetC = TMath::Abs(fParam->GetZPosition("T0/C/PMT1"));
   zdetA  = TMath::Abs(fParam->GetZPosition("T0/A/PMT15"));
   
+  //  printf(" !!!!!Z det A = %f C = % f",zdetA,zdetC);
   AliT0hit  *startHit;
   TBranch *brHits=0;
   
@@ -249,7 +257,6 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
          Double_t e=startHit->Etot();
          volume = startHit->Volume();
          
-         //      if(e>0 && RegisterPhotoE(numpmt,e)) {
          if(e>0 ) {
            countE[numpmt]++;
            besttime[numpmt] = startHit->Time();
@@ -293,31 +300,32 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
          // phe -> mV 0.3; 1MIP ->500phe -> ln (amp (mV)) = 5;
          // max 200ns, HIJING  mean 50000phe -> 15000mv -> ln = 15 (s zapasom)
          // channel 25ps
-         qt= 50.*al/ph2Mip;  // 50mv/Mip amp in mV 
+         qt= al/ph2Mip;  // 50mv/Mip amp in mV 
          //  fill TDC
          timeDelayCFD[i] = fParam->GetTimeDelayCFD(i);
          trCFD = Int_t (timeGaus[i]/channelWidth + timeDelayCFD[i]); 
+
          TGraph* gr = ((TGraph*)fAmpLED.At(i));
          sl = gr->Eval(qt);
 
-         trLED = Int_t(( timeGaus[i] + 1000*sl )/channelWidth);
-         qtCh=Int_t (1000.*TMath::Log(qt) / channelWidth);
+         TGraph* gr1 = ((TGraph*)fAmpQTC.At(i));
+         qtCh = gr1->Eval(qt);
          fADC0->AddAt(0,i);
          fADC->AddAt(qtCh,i);
-         ftimeLED->AddAt(trLED,i); 
          //      sumMult += Int_t ((al*gain[i]/ph2Mip)*50) ;
-         sumMult += Int_t (qt/sumMultCoeff)  ;
+         sumMult += Int_t (qtCh/sumMultCoeff)  ;
         
          // put slewing 
          TGraph *fu=(TGraph*) fParam ->GetWalk(i) ;
          Float_t slew=fu->Eval(Float_t(qtCh));
 
          //      trCFD=trCFD-Int_t(fMaxValue[i]-slew);
-         trCFD = trCFD-Int_t(fMaxValue[i]-slew) + 2000; //for the same channel as cosmic
+         trCFD = trCFD - slew; //for the same channel as cosmic
          ftimeCFD->AddAt(Int_t (trCFD),i);
+         trLED = Int_t(trCFD  + sl );
+         ftimeLED->AddAt(trLED,i); 
          AliDebug(10,Form("  pmt %i : time in ns %f time in channels %i  LEd %i  ",  i, timeGaus[i],trCFD, trLED ));
-         AliDebug(10,Form(" qt in mV %f qt in ns %f qt in channels %i   ",qt, 
-                          TMath::Log(qt), qtCh));
+         AliDebug(10,Form(" qt in MIP %f led-cfd in  %f qt in channels %f   ",qt, sl, qtCh));
 
        }
       } //pmt loop
@@ -337,7 +345,6 @@ void AliT0Digitizer::Exec(Option_t* /*option*/)
                        /channelWidth);
        meanTime=Int_t (((besttimeC+besttimeA)/2. )/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))
index 8f28303..5198958 100644 (file)
@@ -184,26 +184,37 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits)
   Int_t timeC = fDigits->BestTimeA();
   
   
-  TArrayI  *allData = new TArrayI(110);
-  Int_t i=0;
-  allData->AddAt(0,0);
-  for (i=1; i<25; i++) {
-    allData->AddAt(fTimeLED->At(i-1),i);
-    allData->AddAt(fTimeCFD->At(i-1),i+24);
-    allData->AddAt(fADC0->At(i-1),i+56);
-    allData->AddAt(fADC1->At(i-1),i+80);
-
+  //  TArrayI  *allData = new TArrayI(110);
+  Int_t allData[110][1];
+  for (Int_t i=0; i<110; i++) allData[i][0] = 0;
+
+  allData[0][0]=0;
+  for (Int_t i=1; i<13; i++) {
+    allData[i][0]    = fTimeCFD->At(i-1);
+    allData[i+12][0] = fTimeLED->At(i-1);
+    allData[i+56][0] = fTimeCFD->At(i-1+12);
+    allData[i+68][0] = fTimeLED->At(i-1+12);
+  }
+  
+  for (Int_t iii=0; iii<12; iii++) {
+    allData[2*iii+25][0] = fADC1->At(iii);
+    allData[2*iii+26][0] = fADC0->At(iii);
   }
-  allData->AddAt(meantime,49);
-  allData->AddAt(timediff,50);
-  allData->AddAt(timeA,51);
-  allData->AddAt(timeC,52);
-  allData->AddAt(mult0,53);
-  allData->AddAt(mult1,54);
-  allData->AddAt(mult0,55);
-  allData->AddAt(mult1,56);
-
-    cout.setf( ios_base::hex, ios_base::basefield );
+  for (Int_t ii=12; ii<24; ii++) {
+    allData[2*ii+57][0] = fADC1->At(ii);
+    allData[2*ii+58][0] = fADC0->At(ii);
+  }
+  
+  allData[49][0] = meantime;
+  allData[50][0] = timediff;
+  allData[51][0] = timeA;
+  allData[52][0] = timeC;
+  allData[53][0] = mult0;
+  allData[54][0] = mult1;
+  allData[55][0] = mult0;
+  allData[56][0] = mult1;
+
+  //    cout.setf( ios_base::hex, ios_base::basefield );
   //space for DRM header
   fIndex += 6;
 
@@ -228,7 +239,7 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits)
   AliT0LookUpKey * lookkey  = new AliT0LookUpKey();
   AliT0LookUpValue * lookvalue ;//= new AliT0LookUpValue(trm,tdc,chain,channel);
   for (Int_t det = 0; det < 105; det++) {
-    time = allData->At(det);
+    time = allData[det][0];
     if (time >0 && time !=99999) {
       lookkey->SetKey(det);
       lookvalue = (AliT0LookUpValue*) fLookUp.GetValue((TObject*)lookkey);     
@@ -236,7 +247,7 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits)
        {
          isData++;
          itrm= lookvalue->GetTRM();
-         if (det >56 &&inside ==0)  {
+         if (det >56 &&inside == 0)  {
            WriteChainDataTrailer(1); // 1st chain trailer
            fIndex++;
            WriteChainDataHeader(2, 1);
@@ -247,7 +258,7 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits)
          iTDC = lookvalue->GetTDC();
          channel = lookvalue->GetChannel();
          FillTime(channel,  iTDC,  time);
-         AliDebug(1,Form("  itrm %i ,  chain %i , iTDC %i, channel %i",itrm,chain,iTDC,channel));
+         AliDebug(1,Form("look %i  itrm %i ,  chain %i , iTDC %i, channel %i time %i", det,itrm,chain,iTDC,channel, time));
        }
       else
        {
@@ -277,8 +288,6 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits)
     
     WriteDRMDataHeader();
     
-    delete allData;
-    
 }
 
 //_____________________________________________________________________________
index 3f74358..55647e9 100644 (file)
@@ -113,22 +113,20 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   // T0 digits reconstruction
   // T0RecPoint writing 
   
-   
+  
   TArrayI * timeCFD = new TArrayI(24); 
   TArrayI * timeLED = new TArrayI(24); 
   TArrayI * chargeQT0 = new TArrayI(24); 
   TArrayI * chargeQT1 = new TArrayI(24); 
 
-
-  //  Int_t mV2Mip = param->GetmV2Mip();     
-  //mV2Mip = param->GetmV2Mip();     
   Float_t channelWidth = fParam->GetChannelWidth() ;  
   Float_t meanVertex = fParam->GetMeanVertex();
   
   AliDebug(1,Form("Start DIGITS reconstruction "));
   
 
- TBranch *brDigits=digitsTree->GetBranch("T0");
+  TBranch *brDigits=digitsTree->GetBranch("T0");
   AliT0digit *fDigits = new AliT0digit() ;
   if (brDigits) {
     brDigits->SetAddress(&fDigits);
@@ -153,7 +151,7 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   Int_t pmtBestC=99999;
   Float_t timeDiff=999999, meanTime=0;
   
-  Int_t mv2MIP = fParam-> GetmV2Mip();     
+  //  Int_t mv2MIP = fParam-> GetmV2Mip();     
 
 
   AliT0RecPoint* frecpoints= new AliT0RecPoint ();
@@ -162,28 +160,25 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   Float_t time[24], adc[24];
   for (Int_t ipmt=0; ipmt<24; ipmt++) {
     if(timeCFD->At(ipmt)>0 ){
-      Double_t qt0 = Double_t(chargeQT0->At(ipmt));
-      Double_t qt1 = Double_t(chargeQT1->At(ipmt));
-      if((qt1-qt0)>0)  adc[ipmt] = Int_t (TMath::Exp( Double_t (channelWidth*(qt1-qt0)/1000)));
-
-      time[ipmt] = fCalib-> WalkCorrection( ipmt, Int_t(qt1) , timeCFD->At(ipmt), "pdc" ) ;
-     
-      //LED
-      Float_t ampLED;    //LED
-      Double_t sl = (timeLED->At(ipmt) - time[ipmt])*channelWidth;
-      if( adc[ipmt]/Float_t(mv2MIP) < 20) 
-       {
-         Double_t qt=((TGraph*)fAmpLEDrec.At(ipmt))->Eval(sl/1000.);
-         ampLED = qt/Float_t(mv2MIP);
-         AliDebug(1,Form(" ipmt %i QTC %f ch QTC in MIP %f, time in chann %f (led-cfd) %f in MIPs %f",
-                         ipmt, adc[ipmt], adc[ipmt]/Float_t(mv2MIP), time[ipmt],sl,ampLED ));
-       }
+     if(( chargeQT1->At(ipmt) - chargeQT0->At(ipmt))>0)  
+       adc[ipmt] = chargeQT1->At(ipmt) - chargeQT0->At(ipmt);
       else
-       { AliDebug(1,Form(" amplitude %f MIPs on PMT %i, write QTC in both ", (adc[ipmt]/Float_t(mv2MIP)), ipmt));
-         ampLED=adc[ipmt]/Float_t(mv2MIP);}
-      frecpoints->SetTime(ipmt,time[ipmt]);
-      frecpoints->SetAmp(ipmt,adc[ipmt]/Float_t(mv2MIP));
-      frecpoints->SetAmpLED(ipmt,ampLED);
+       adc[ipmt] = 0;
+      
+      time[ipmt] = fCalib-> WalkCorrection( ipmt, adc[ipmt], Float_t( timeCFD->At(ipmt))) ;
+            
+      Double_t sl = Double_t(timeLED->At(ipmt) - timeCFD->At(ipmt));
+      //    time[ipmt] = fCalib-> WalkCorrection( ipmt, Int_t(sl), timeCFD[ipmt],"cosmic" ) ;
+      AliDebug(10,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ",
+                      ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl)));
+      Double_t ampMip =((TGraph*)fAmpLED.At(ipmt))->Eval(sl);
+      Double_t qtMip = ((TGraph*)fQTC.At(ipmt))->Eval(adc[ipmt]);
+      AliDebug(10,Form("  Amlitude in MIPS LED %f ,  QTC %f in channels %i\n ",ampMip,qtMip, adc[ipmt]));
+      
+      frecpoints->SetTime(ipmt, Float_t(time[ipmt]) );
+      frecpoints->SetAmp(ipmt, Float_t( ampMip)); //for cosmic &pp beam 
+      frecpoints->SetAmpLED(ipmt, Float_t(qtMip));
+      
     }
     else {
       time[ipmt] = 0;
@@ -208,19 +203,19 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   }
   if(besttimeA !=999999)  frecpoints->SetTimeBestA(Int_t(besttimeA));
   if( besttimeC != 999999 ) frecpoints->SetTimeBestC(Int_t(besttimeC));
-  AliDebug(1,Form(" besttimeA %f ch,  besttimeC %f ch",besttimeA, besttimeC));
+  AliDebug(10,Form(" besttimeA %f ch,  besttimeC %f ch",besttimeA, besttimeC));
   Float_t c = 0.0299792; // cm/ps
   Float_t vertex = 0;
   if(besttimeA !=999999 && besttimeC != 999999 ){
     timeDiff = (besttimeC - besttimeA)*channelWidth;
-    meanTime = (Float_t((besttimeA + besttimeC -4000)/2) * channelWidth); 
+    meanTime = Float_t((besttimeA + besttimeC)/2);// * channelWidth); 
     //    meanTime = (meanT0 - (besttimeA + besttimeC)/2) * channelWidth;
-    vertex = meanVertex - c*(timeDiff)/2. + (fdZonA - fdZonC)/2; 
+    vertex = meanVertex - c*(timeDiff)/2.;// + (fdZonA - fdZonC)/2; 
     frecpoints->SetVertex(vertex);
     frecpoints->SetMeanTime(Int_t(meanTime));
     //online mean
-    frecpoints->SetOnlineMean(Int_t(onlineMean * channelWidth));
-    AliDebug(1,Form("  timeDiff %f ps,  meanTime %f ps, vertex %f cm online mean %i ps",timeDiff, meanTime,vertex, Int_t(onlineMean * channelWidth )));
+    frecpoints->SetOnlineMean(Int_t(onlineMean));
+    AliDebug(10,Form("  timeDiff %f ps,  meanTime %f ps, vertex %f cm online mean %i ps",timeDiff, meanTime,vertex, Int_t(onlineMean)));
     
   }
   
@@ -245,7 +240,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   
   Int_t timeCFD[24], timeLED[24], chargeQT0[24], chargeQT1[24];
   TString option = GetOption(); 
-  AliDebug(10,Form("Option: %s\n", option.Data()));
+  AliDebug(1,Form("Option: %s\n", option.Data()));
    
    
   for (Int_t i0=0; i0<105; i0++)
@@ -259,9 +254,9 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   Int_t pmtBestC=99999;
   Float_t timeDiff=9999999, meanTime=0;
   Double_t qt=0;
-  Int_t mv2MIP = fParam-> GetmV2Mip();     
+  //  Int_t mv2MIP = fParam-> GetmV2Mip();     
   Float_t meanVertex = fParam->GetMeanVertex();
-
+  printf("meanVertex %f \n",meanVertex);
   //  UInt_t type =rawReader->GetType();        
   
   AliT0RecPoint* frecpoints= new AliT0RecPoint ();
@@ -285,19 +280,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
       Float_t channelWidth = fParam->GetChannelWidth() ;  
       
       //       Int_t meanT0 = fParam->GetMeanT0();
-      if(option == "pdc"){
-       for (Int_t in=0; in<24; in++)  
-         {
-           
-           timeLED[in] = allData[in+1][0] ;
-           timeCFD[in] = allData[in+25][0] ;
-           chargeQT1[in] = allData[in+57][0] ;
-            chargeQT0[in] = allData[in+81][0] ;
-         }
-       }
-      
-      if(option == "cosmic"  ) //&& type == 7 )
-       {
+       
          
          for (Int_t in=0; in<12; in++)  
            {
@@ -305,21 +288,24 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
              timeCFD[in+12] = allData[in+56+1][0] ;
              timeLED[in] = allData[in+12+1][0] ;
              timeLED[in+12] = allData[in+68+1][0] ;
+             AliDebug(10, Form(" readed i %i cfdC %i cfdA %i ledC %i ledA%i ",
+                               in, timeCFD[in],timeCFD[in+12],timeLED[in], 
+                               timeLED[in+12]));   
            }
          
          for (Int_t in=0; in<12;  in++)
            {
-             chargeQT1[in]=allData[2*in+25][0];
-             chargeQT0[in]=allData[2*in+26][0];
+             chargeQT0[in]=allData[2*in+25][0];
+             chargeQT1[in]=allData[2*in+26][0];
            }
          
           for (Int_t in=12; in<24;  in++)
             {
-              chargeQT1[in]=allData[2*in+57][0];
-              chargeQT0[in]=allData[2*in+58][0];
+              chargeQT0[in]=allData[2*in+57][0];
+              chargeQT1[in]=allData[2*in+58][0];
             }
           
-        } //cosmic with physics event
+          //    } //cosmic with physics event
        for (Int_t in=0; in<24; in++)  
         AliDebug(10, Form(" readed Raw %i %i %i %i %i",
                           in, timeLED[in],timeCFD[in],chargeQT0[in],chargeQT1[in]));
@@ -329,52 +315,26 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
        for (Int_t ipmt=0; ipmt<24; ipmt++) {
         if(timeCFD[ipmt]>0 && timeLED[ipmt]>0){
           //for simulated data
-          if(option == "pdc"){
-            Double_t qt0 = Double_t(chargeQT0[ipmt]);
-            Double_t qt1 = Double_t(chargeQT1[ipmt]);
-            if((qt1-qt0)>0)  adc[ipmt] = Int_t(TMath::Exp( Double_t (channelWidth*(qt1-qt0)/1000.)));
-            time[ipmt] = fCalib-> WalkCorrection( ipmt,Int_t(qt1) , timeCFD[ipmt], "pdc" ) ;
-            Double_t sl = (timeLED[ipmt] - time[ipmt])*channelWidth;
-            //pp collison
-            if( adc[ipmt]/Float_t(mv2MIP) < 20) 
-              {
-                if(fAmpLEDrec.At(ipmt)) 
-                  qt=((TGraph*)fAmpLEDrec.At(ipmt))->Eval(sl/1000.);
-              }
-            else //PbPb
-              { AliDebug(1,Form(" amplitude %f MIPs on PMT %i, write QTC in both ", (adc[ipmt]/Float_t(mv2MIP)), ipmt));
-                qt=adc[ipmt]/Float_t(mv2MIP);}
-            
-            frecpoints->SetTime(ipmt,time[ipmt]);
-            frecpoints->SetAmp(ipmt,adc[ipmt]/Float_t(mv2MIP));
-            frecpoints->SetAmpLED(ipmt,qt/Float_t(mv2MIP));
-            AliDebug(10,Form(" QTC %f mv,  time in chann %f ampLED %f",adc[ipmt] ,time[ipmt], qt));
-            AliDebug(10,Form("  Amlitude in MIPS LED %f ,  QTC %f \n ", adc[ipmt]/Float_t(mv2MIP),qt/Float_t(mv2MIP)));
-          }
+            //for physics  data
+          if(( chargeQT1[ipmt] - chargeQT0[ipmt])>0)  
+            adc[ipmt] = chargeQT1[ipmt] - chargeQT0[ipmt];
+          else
+            adc[ipmt] = 0;
           
+          time[ipmt] = fCalib-> WalkCorrection( ipmt, adc[ipmt], timeCFD[ipmt],"cosmic" ) ;
           
-            //for physics  data
-          if(option == "cosmic") // && type == 7)
-            {
-            if(( chargeQT1[ipmt] - chargeQT0[ipmt])>0)  
-              adc[ipmt] = chargeQT1[ipmt] - chargeQT0[ipmt];
-            else
-              adc[ipmt] = 0;
-            //      time[ipmt] = fCalib-> WalkCorrection( ipmt, adc[ipmt], timeCFD[ipmt],"cosmic" ) ;
+          Double_t sl = timeLED[ipmt] - timeCFD[ipmt];
+            //    time[ipmt] = fCalib-> WalkCorrection( ipmt, Int_t(sl), timeCFD[ipmt],"cosmic" ) ;
+          AliDebug(10,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ",
+                           ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl)));
+          Double_t ampMip =( (TGraph*)fAmpLED.At(ipmt))->Eval(sl);
+          Double_t qtMip = ((TGraph*)fQTC.At(ipmt))->Eval(adc[ipmt]);
+          AliDebug(10,Form("  Amlitude in MIPS LED %f ; QTC %f;  in channels %i\n ",ampMip,qtMip, adc[ipmt]));
             
-            Double_t sl = timeLED[ipmt] - timeCFD[ipmt];
-            time[ipmt] = fCalib-> WalkCorrection( ipmt, Int_t(sl), timeCFD[ipmt],"cosmic" ) ;
-            AliDebug(10,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ",
-                             ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl)));
-            Double_t ampMip =( (TGraph*)fAmpLED.At(ipmt))->Eval(sl);
-            Double_t qtMip = ((TGraph*)fQTC.At(ipmt))->Eval(adc[ipmt]);
-            AliDebug(10,Form("  Amlitude in MIPS LED %f ,  QTC %f \n ",ampMip,qtMip));
+          frecpoints->SetTime(ipmt, Float_t(time[ipmt]) );
+          frecpoints->SetAmp(ipmt, Float_t( ampMip)); //for cosmic &pp beam 
+          frecpoints->SetAmpLED(ipmt, Float_t(qtMip));
             
-            frecpoints->SetTime(ipmt, Float_t(time[ipmt]) );
-            frecpoints->SetAmp(ipmt, Float_t( ampMip)); //for cosmic &pp beam 
-            frecpoints->SetAmpLED(ipmt, Float_t(qtMip));
-          } //if physic data end
-          
         }
         else {
           time[ipmt] = 0;
@@ -399,25 +359,19 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
        }
        if(besttimeA !=9999999)  frecpoints->SetTimeBestA(Int_t(besttimeA));
        if( besttimeC != 9999999 ) frecpoints->SetTimeBestC(Int_t(besttimeC));
-       AliDebug(1,Form(" besttimeA %f ps,  besttimeC %f ps",besttimeA, besttimeC));
-       Float_t c = 0.0299792; // cm/ps
+       AliDebug(5,Form(" pmtA %i besttimeA %f ps, pmtC %i besttimeC %f ps",
+                      pmtBestA,besttimeA, pmtBestC,  besttimeC));
+       Float_t c = 0.0299792458; // cm/ps
        Float_t vertex = 99999;
        if(besttimeA <9999999 && besttimeC < 9999999 ){
         timeDiff = ( besttimeC - besttimeA) *channelWidth;
-        if(option == "pdc"){ 
-          //      meanTime = (besttimeA + besttimeC)/2 * channelWidth; 
-          meanTime = (besttimeA + besttimeC-4000.)/2 * channelWidth; 
-          onlineMean = Int_t (onlineMean * channelWidth);
-        }
-        if(option == "cosmic") {
-          meanTime =  Float_t((besttimeA + besttimeC)/2);  
-          onlineMean = onlineMean ;
-        }
-        vertex =  meanVertex -c*(timeDiff)/2.; //+ (fdZonA - fdZonC)/2; 
+        meanTime =  Float_t((besttimeA + besttimeC)/2.);  
+        onlineMean = onlineMean ;
+        vertex =  meanVertex - c*(timeDiff)/2.; //+ (fdZonA - fdZonC)/2; 
         frecpoints->SetVertex(vertex);
         frecpoints->SetMeanTime(Int_t(meanTime));
         frecpoints->SetOnlineMean(Int_t(onlineMean));
-        AliDebug(1,Form("  timeDiff %f ps,  meanTime %f ps, vertex %f cm online mean %i ",timeDiff, meanTime,vertex, onlineMean));
+        AliDebug(5,Form("  timeDiff %f ps,  meanTime %f ps, vertex %f cm meanVertex %f online mean %i ",timeDiff, meanTime,vertex,meanVertex, onlineMean));
         
        }
     } // if (else )raw data