Fixes for the trunk: compilation on Lion (Yves)
[u/mrichter/AliRoot.git] / VZERO / AliVZERODigitizer.cxx
index 798911e..4abae07 100644 (file)
@@ -41,7 +41,7 @@
 #include "AliRunLoader.h"
 #include "AliLoader.h"
 #include "AliGRPObject.h"
-#include "AliRunDigitizer.h"
+#include "AliDigitizationInput.h"
 #include "AliCDBManager.h"
 #include "AliCDBStorage.h"
 #include "AliCDBEntry.h"
@@ -94,8 +94,8 @@ ClassImp(AliVZERODigitizer)
 }
            
 //____________________________________________________________________________ 
-  AliVZERODigitizer::AliVZERODigitizer(AliRunDigitizer* manager)
-                    :AliDigitizer(manager),
+  AliVZERODigitizer::AliVZERODigitizer(AliDigitizationInput* digInput)
+                    :AliDigitizer(digInput),
                     fCalibData(GetCalibData()),
                      fPhotoCathodeEfficiency(0.18),
                     fNdigits(0),
@@ -198,13 +198,18 @@ Bool_t AliVZERODigitizer::Init()
     fNBinsLT[i] = TMath::Nint(((Float_t)(fCalibData->GetMatchWindow(board)+1)*25.0)/
                              fCalibData->GetTimeResolution(board));
     fBinSize[i] = fCalibData->GetTimeResolution(board);
-    fHptdcOffset[i] = (((Float_t)fCalibData->GetTriggerCountOffset(board)-
-                       (Float_t)fCalibData->GetRollOver(board))*25.0+
+    fHptdcOffset[i] = (((Float_t)fCalibData->GetRollOver(board)-
+                       (Float_t)fCalibData->GetTriggerCountOffset(board))*25.0+
                       fCalibData->GetTimeOffset(i)-
                       l1Delay-
                       phase->GetMeanPhase()+
                       delays->GetBinContent(i+1)+
                       kV0Offset);
+    fClockOffset[i] = (((Float_t)fCalibData->GetRollOver(board)-
+                       (Float_t)fCalibData->GetTriggerCountOffset(board))*25.0+
+                      fCalibData->GetTimeOffset(i)-
+                      l1Delay+
+                      kV0Offset);
 
     fTime[i] = new Float_t[fNBins[i]];
     memset(fTime[i],0,fNBins[i]*sizeof(Float_t));
@@ -214,12 +219,12 @@ Bool_t AliVZERODigitizer::Init()
 }
 
 //____________________________________________________________________________
-void AliVZERODigitizer::Exec(Option_t* /*option*/) 
+void AliVZERODigitizer::Digitize(Option_t* /*option*/) 
 {   
   // Creates digits from hits
   fNdigits = 0;  
 
-  if (fVZERO && !fManager) {
+  if (fVZERO && !fDigInput) {
     AliLoader *loader = fVZERO->GetLoader();
     if (!loader) {
       AliError("Can not get VZERO Loader via AliVZERO object!");
@@ -239,10 +244,10 @@ void AliVZERODigitizer::Exec(Option_t* /*option*/)
       }
     }
   }
-  else if (fManager) {
+  else if (fDigInput) {
       ReadSDigits();
       DigitizeSDigits();
-      AliRunLoader *currentLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+      AliRunLoader *currentLoader = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
       AliLoader *loader = currentLoader->GetLoader("VZEROLoader");
       if (!loader) { 
        AliError("Cannot get VZERO Loader via RunDigitizer!");
@@ -449,7 +454,7 @@ void AliVZERODigitizer::DigitizeSDigits()
   Float_t maximum = 0.9*fSignalShape->GetMaximum(0,200); // Not exact, one needs to do this on the convoluted
   Float_t integral2 = fSignalShape->Integral(0,200); // function. Anyway the effect is small <10% on the 2.5 ADC thr
   for (Int_t ipmt = 0; ipmt < 64; ++ipmt) {
-    Float_t thr = fCalibData->GetDiscriThr(ipmt)*kChargePerADC*maximum*fBinSize[ipmt]/integral2;
+    Float_t thr = fCalibData->GetCalibDiscriThr(ipmt,kFALSE)*kChargePerADC*maximum*fBinSize[ipmt]/integral2;
     Bool_t ltFound = kFALSE, ttFound = kFALSE;
     for (Int_t iBin = 0; iBin < fNBins[ipmt]; ++iBin) {
       Float_t t = fBinSize[ipmt]*Float_t(iBin);
@@ -467,11 +472,12 @@ void AliVZERODigitizer::DigitizeSDigits()
          }
        }
       }
-      Float_t tadc = t - kClockOffset - fCalibData->GetTimeOffset(ipmt);
+      Float_t tadc = t - fClockOffset[ipmt];
       Int_t clock = kNClocks/2 - Int_t(tadc/25.0);
       if (clock >= 0 && clock < kNClocks)
        fAdc[ipmt][clock] += fTime[ipmt][iBin]/kChargePerADC;
     }
+    AliDebug(1,Form("Channel %d Offset %f Time %f",ipmt,fClockOffset[ipmt],fLeadingTime[ipmt]));
     Int_t board = AliVZEROCalibData::GetBoardNumber(ipmt);
     if (ltFound && ttFound) {
       fTimeWidth[ipmt] = fCalibData->GetWidthResolution(board)*
@@ -487,6 +493,7 @@ void AliVZERODigitizer::DigitizeSDigits()
   for (Int_t j=0; j<64; ++j){
     for (Int_t iClock = 0; iClock < kNClocks; ++iClock) {
       Int_t integrator = (iClock + fEvenOrOdd) % 2;
+      AliDebug(1,Form("ADC %d %d %f",j,iClock,fAdc[j][iClock]));
       fAdc[j][iClock]  += gRandom->Gaus(fAdcPedestal[j][integrator], fAdcSigma[j][integrator]);
     }
   }
@@ -556,11 +563,11 @@ void AliVZERODigitizer::ReadSDigits()
   }
 
   // Loop over input files
-  Int_t nFiles= fManager->GetNinputs();
+  Int_t nFiles= fDigInput->GetNinputs();
   for (Int_t inputFile = 0; inputFile < nFiles; inputFile++) {
     // Get the current loader 
     AliRunLoader* currentLoader = 
-      AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
+      AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(inputFile));
 
     AliLoader *loader = currentLoader->GetLoader("VZEROLoader");
     loader->LoadSDigits("READ");
@@ -568,7 +575,7 @@ void AliVZERODigitizer::ReadSDigits()
     // Get the tree of summable digits
     TTree* sdigitsTree = loader->TreeS();
     if (!sdigitsTree)  {
-      AliError("No sdigit tree from manager");
+      AliError("No sdigit tree from digInput");
       continue;
     }