]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFDigitizer.cxx
hopefully the last refinements for correct type conversion in miscalibration
[u/mrichter/AliRoot.git] / TOF / AliTOFDigitizer.cxx
index c937854cd065110a7fc90873c6d4b123612b552b..6701cb1fa454887ae90e98479c1934eb5aa132ab 100644 (file)
@@ -481,13 +481,15 @@ void AliTOFDigitizer::DecalibrateTOFSignal( AliTOFcalib *calib){
        par[j]=calChannel->GetSlewPar(j);
        if(par[j]!=0)misCalibPars=kTRUE;
       }
-      
+      AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
       // Now generate Realistic ToT distribution from TestBeam Data. 
       // Tot is in ns, assuming a Matching Window of 10 ns.
 
       Float_t simToT = 0;
       Float_t trix = 0;
       Float_t triy = 0;
+      Double_t timeCorr;
+      Double_t tToT;
       while (simToT <= triy){
        trix = gRandom->Rndm(i);
        triy = gRandom->Rndm(i);
@@ -497,35 +499,40 @@ void AliTOFDigitizer::DecalibrateTOFSignal( AliTOFcalib *calib){
        simToT=hToT->GetBinContent(binx);
       }
       // the generated ToT (ns)
-      Float_t tToT= trix; // to apply slewing we start from ns..
-      // transform TOF signal in ns, factor 1E-3 as bin width is in ps.
-      AliDebug(2,Form(" Initial Time (counts): %i: ",dig->GetTdc()));
-      Float_t time = ((dig->GetTdc())*AliTOFGeometry::TdcBinWidth()+32)*1.E-3; 
-      AliDebug(2,Form(" Time before miscalibration (ns) %f: ",time));
+      tToT= (Double_t) trix; // to apply slewing we start from ns..
+      // transform TOF signal in ns
+      AliDebug(2,Form(" The Initial Time (counts): %i: ",dig->GetTdc()));
+      AliDebug(2,Form(" Time before miscalibration (ps) %e: ",dig->GetTdc()*AliTOFGeometry::TdcBinWidth()));
       // add slewing effect
-      Float_t timeoffset=par[0] + tToT*(par[1] +tToT*(par[2] +tToT*(par[3] +tToT*(par[4] +tToT*par[5])))); 
-      Float_t timeSlewed = time+timeoffset;
-      AliDebug(2,Form(" Time after applying slewing (ns): %f: ",timeSlewed));
+      timeCorr=par[0] + tToT*(par[1] +tToT*(par[2] +tToT*(par[3] +tToT*(par[4] +tToT*par[5])))); 
+      AliDebug(2,Form(" The Time slewing (ns): %f: ",timeCorr));
       // add global time shift
-      timeSlewed = timeSlewed + timedelay;
-      AliDebug(2,Form(" Time after applying delay (ns): %f: ",timeSlewed));
-      Int_t tdc= (Int_t)((timeSlewed*1E3-32)/AliTOFGeometry::TdcBinWidth());
-      // Setting Decalibrated Time signal (TDC counts)    
-      dig->SetTdc(tdc);   
-      AliDebug(2,Form(" Final Time (counts): %i: ",dig->GetTdc()));
-      // Setting realistic ToT signal (TDC counts)   
+      timeCorr = timeCorr + timedelay;
+      AliDebug(2,Form(" The Time Slewing+ delay (ns): %f: ",timeCorr));
+      //convert to ps
+      timeCorr*=1E-3;
+      Double_t timeMis = (Double_t)(dig->GetTdc())*AliTOFGeometry::TdcBinWidth();
+      timeMis = timeMis+timeCorr;
+      AliDebug(2,Form(" The Miscalibrated time (ps): %e: ",timeMis));
+
+      // now update the digit info
+      Int_t tdcCorr= (Int_t)(timeMis/AliTOFGeometry::TdcBinWidth());
+      AliDebug(2,Form(" Final Time (counts): %i: ",tdcCorr));
       // Setting Decalibrated Time signal (TDC counts)    
-      Int_t tot=(Int_t)(trix/AliTOFGeometry::ToTBinWidth()*1.E3);//(factor 1E3 as input ToT is in ns)
+      dig->SetTdc(tdcCorr);   
+      // Setting realistic ToT signal (TDC counts) 
+      tToT*=1E3; //back to ps  
+      Int_t tot=(Int_t)(tToT/AliTOFGeometry::ToTBinWidth());//(factor 1E3 as input ToT is in ns)
       dig->SetToT(tot); 
-      AliDebug(2,Form(" Final Tot (counts): %i: ",dig->GetToT()));
-      if(tdc<0){
-       AliWarning (Form(" The bad Slewed Time(TDC counts)= %i ", tdc)); 
+      AliDebug(2,Form(" Final Time and ToT (counts): %i: ",dig->GetTdc(),dig->GetToT()));
+      if(tdcCorr<0){
+       AliWarning (Form(" The bad Slewed Time(TDC counts)= %i ", tdcCorr)); 
        AliWarning(Form(" The bad ToT (TDC counts)= %i ", tot)); 
       }
     }
     else{
     // For Data with no Miscalibration, set ToT signal == Adc
-      //    dig->SetToT(dig->GetAdc()/AliTOFGeometry::ToTBinWidth()*1.E3); 
       dig->SetToT((Int_t)(dig->GetAdc()/AliTOFGeometry::ToTBinWidth())); //remove the factor 10^3 just to have a reasonable ToT range for raw data simulation even in the case of non-realistic ToT distribution (n.b. fAdc is practically an arbitrary quantity, and ToT has no impact on the TOF reco for non-miscalibrated digits)
     }
   }