Fix digit amplitude sign bit
authorguernane <guernane@lpsc.in2p3.fr>
Tue, 21 Jan 2014 17:43:57 +0000 (18:43 +0100)
committerguernane <guernane@lpsc.in2p3.fr>
Tue, 21 Jan 2014 17:49:10 +0000 (18:49 +0100)
EMCAL/AliEMCALDigitizer.cxx
EMCAL/AliEMCALRawDigit.cxx
EMCAL/AliEMCALTriggerBoard.cxx

index 3cc2392..553d8a2 100644 (file)
@@ -892,7 +892,7 @@ void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* dig
       
       if (AliDebugLevel()) printf("Number of TRG digits: %d\n",digitsTMP->GetEntriesFast());
                
-      Int_t    nSamples = 32;
+      Int_t     nSamples = 32;
       Int_t *timeSamples = new Int_t[nSamples];
       
       NextDigit = TIter(digitsTMP);
@@ -909,20 +909,18 @@ void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* dig
           if (AliDebugLevel()) printf("Deposited Energy: %f\n", depositedEnergy);
           
           // FIXME: Check digit time!
-          if (depositedEnergy)
-          {
-                       depositedEnergy += gRandom->Gaus(0., .08);
-                         
+          if (depositedEnergy) {
+            depositedEnergy += gRandom->Gaus(0., .08);
             DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
             
-            for (Int_t j=0;j<nSamples;j++) 
-            {
-              timeSamples[j] = ((j << 12) & 0xFF000) | (timeSamples[j] & 0xFFF);
+            for (Int_t j=0;j<nSamples;j++) {
+              if (AliDebugLevel()) printf("timeSamples[%d]: %d\n",j,timeSamples[j]);
+              timeSamples[j] = ((j << 16) | (timeSamples[j] & 0xFFFF));
             }
             
             new((*digitsTRG)[digitsTRG->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
-                         
-                       if (AliDebugLevel()) ((AliEMCALRawDigit*)digitsTRG->At(digitsTRG->GetEntriesFast() - 1))->Print("");
+
+            if (AliDebugLevel()) ((AliEMCALRawDigit*)digitsTRG->At(digitsTRG->GetEntriesFast() - 1))->Print("");
           }
         }
       }
@@ -937,8 +935,8 @@ void AliEMCALDigitizer::DigitalFastOR( Double_t time, Double_t dE, Int_t timeSam
 {
        // parameters:  
        // id: 0..95
-       const Int_t    reso = 11;      // 11-bit resolution ADC
-       const Double_t vFSR = 1;       // Full scale input voltage range
+       const Int_t    reso = 12;      // 11-bit resolution ADC
+       const Double_t vFSR = 2.;      // Full scale input voltage range 2V (p-p)
 //     const Double_t dNe  = 125;     // signal of the APD per MeV of energy deposit in a tower: 125 photo-e-/MeV @ M=30
        const Double_t dNe  = 125/1.3; // F-ALTRO max V. FEE: factor 4 
        const Double_t vA   = .136e-6; // CSP output range: 0.136uV/e-
@@ -957,8 +955,14 @@ void AliEMCALDigitizer::DigitalFastOR( Double_t time, Double_t dE, Int_t timeSam
        {
                // FIXME: add noise (probably not simply Gaussian) according to DA measurements
                // probably plan an access to OCDB
-               
-               timeSamples[iTime] = int((TMath::Power(2, reso) / vFSR) * signalF.Eval(iTime * kTimeBinWidth) + 0.5);
+    Double_t sig = signalF.Eval(iTime * kTimeBinWidth);
+    if (TMath::Abs(sig) > vFSR/2.) {
+      AliError("Signal overflow!");
+      timeSamples[iTime] = (1 << reso) - 1;
+    } else {
+      AliDebug(999,Form("iTime: %d sig: %f\n",iTime,sig));
+      timeSamples[iTime] = ((1 << reso) / vFSR) * sig + 0.5;
+    }
        }
 }
 
index 307489a..a602298 100644 (file)
@@ -76,8 +76,8 @@ Bool_t AliEMCALRawDigit::GetTimeSample(const Int_t iSample, Int_t& timeBin, Int_
   
        if (iSample > fNSamples || iSample < 0) return kFALSE;
        
-       amp     =  fSamples[iSample] & 0xFFF;
-       timeBin = (fSamples[iSample] >> 12) & 0xFF;
+  amp     = (Short_t)(fSamples[iSample] & 0xFFFF);
+  timeBin = (Short_t)(fSamples[iSample] >> 16 );
 
        return kTRUE;
 }
index 5da2bce..7bbf405 100644 (file)
@@ -130,17 +130,19 @@ void AliEMCALTriggerBoard::SlidingWindow(Int_t thres)
        for (int i = 0; i <= int(fRegionSize->X() - fPatchSize->X() * fSubRegionSize->X()); i += int(fSubRegionSize->X())) {
                for (int j = 0; j <= int(fRegionSize->Y() - fPatchSize->Y() * fSubRegionSize->Y()); j += int(fSubRegionSize->Y())) {
                        //
+                       AliDebug(999, Form("--- Current window at (%2d,%2d) ---",i,j));
                        int sum = 0;
                        
                        for (int k = 0; k < int(fPatchSize->X() * fSubRegionSize->X()); k++) {
                                for (int l = 0; l < int(fPatchSize->Y() * fSubRegionSize->Y()); l++) {
                                        //
-                                       sum += fRegion[i + k][j + l];
+                                       sum += fRegion[i + k][j + l]; 
+                                       AliDebug(999, Form("Adding fRegion[%2d + %2d][%2d + %2d]: %d and sum is %d",i,k,j,l,fRegion[i + k][j + l],sum));
                                }
                        }
                        
                        if (sum > thres) {
-                               AliDebug(999, Form("Adding new patch at (%2d,%2d)", i, j));
+                         AliDebug(999, Form("Adding new patch at (%2d,%2d) w/ amplitude %d", i, j, sum));
                                new((*fPatches)[fPatches->GetEntriesFast()]) AliEMCALTriggerPatch(i, j, sum);
                        }
                }