]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALDigitizer.cxx
Various fixes
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALDigitizer.cxx
index f0eca4c281be360b3809a7f7eabb5333bb9e0fc2..e76339029f0a511b3df04ade2817d989369236dd 100644 (file)
@@ -487,7 +487,7 @@ void AliEMCALDigitizer::Digitize(Int_t event)
           
        // add the noise now, no need for embedded events with real data
        if(!embed)
-         energy += TMath::Abs(gRandom->Gaus(0., fPinNoise)) ;
+         energy += gRandom->Gaus(0., fPinNoise) ;
           
 
        // JLK 26-June-2008
@@ -641,7 +641,7 @@ void AliEMCALDigitizer::DigitizeEnergyTime(Float_t & energy, Float_t & time, con
     fADCpedestalEC     = fCalibData->GetADCpedestal     (iSupMod,ieta,iphi);
     fADCchannelEC      = fCalibData->GetADCchannel      (iSupMod,ieta,iphi);
     fADCchannelECDecal = fCalibData->GetADCchannelDecal (iSupMod,ieta,iphi);
-    fTimeChannel       = fCalibData->GetTimeChannel     (iSupMod,ieta,iphi);
+    fTimeChannel       = fCalibData->GetTimeChannel     (iSupMod,ieta,iphi,0); // Assign bunch crossing number equal to 0 (has simulation different bunch crossings?)
     fTimeChannelDecal  = fCalibData->GetTimeChannelDecal(iSupMod,ieta,iphi);      
   }
   
@@ -653,6 +653,38 @@ void AliEMCALDigitizer::DigitizeEnergyTime(Float_t & energy, Float_t & time, con
     energy =  fNADCEC ; 
 }
 
+//_____________________________________________________________________
+void AliEMCALDigitizer::Decalibrate(AliEMCALDigit *digit)
+{ 
+       // Load Geometry
+       const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
+       
+       if (!geom) {
+               AliFatal("Did not get geometry from EMCALLoader");
+               return;
+       }
+       
+       Int_t absId   = digit->GetId();
+       Int_t iSupMod = -1;
+       Int_t nModule = -1;
+       Int_t nIphi   = -1;
+       Int_t nIeta   = -1;
+       Int_t iphi    = -1;
+       Int_t ieta    = -1;
+       
+       Bool_t bCell = geom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
+       
+       if (!bCell) Error("DigitizeEnergyTime","Wrong cell id number : absId %i ", absId) ;
+       geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
+       
+       if (fCalibData) {
+               fADCchannelEC = fCalibData->GetADCchannel(iSupMod,ieta,iphi);
+               float factor = 1./(fADCchannelEC/0.0162);
+               
+               *digit = *digit * factor;
+       }
+}
+
 //_____________________________________________________________________
 void AliEMCALDigitizer::CalibrateADCTime(Float_t & adc, Float_t & time, const Int_t absId)
 { 
@@ -686,7 +718,7 @@ void AliEMCALDigitizer::CalibrateADCTime(Float_t & adc, Float_t & time, const In
   if(fCalibData) {
     fADCpedestalEC = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
     fADCchannelEC  = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
-    fTimeChannel   = fCalibData->GetTimeChannel(iSupMod,ieta,iphi);
+    fTimeChannel   = fCalibData->GetTimeChannel(iSupMod,ieta,iphi,0);// Assign bunch crossing number equal to 0 (has simulation different bunch crossings?)
   }
   
   adc   = adc * fADCchannelEC - fADCpedestalEC;
@@ -825,11 +857,17 @@ void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* dig
       // build FOR from simulated digits
       // and xfer to the corresponding TRU input (mapping)
       
-      TClonesArray* digits = emcalLoader->Digits();
-      
+         TClonesArray* sdigits = emcalLoader->SDigits();
+               
+         TClonesArray *digits = (TClonesArray*)sdigits->Clone();
+               
+         AliDebug(999,Form("=== %d SDigits to trigger digits ===",digits->GetEntriesFast()));
+               
       TIter NextDigit(digits);
       while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
       {
+           Decalibrate(digit);   
+                 
         Int_t id = digit->GetId();
         
         Int_t trgid;
@@ -853,7 +891,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 *timeSamples = new Int_t[nSamples];
       
@@ -863,7 +901,7 @@ void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* dig
         if (digit)
         {
           Int_t     id = digit->GetId();
-          Float_t time = digit->GetTime();
+          Float_t time = 50.e-9;
           
           Double_t depositedEnergy = 0.;
           for (Int_t j = 1; j <= digit->GetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j);
@@ -873,6 +911,8 @@ void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* dig
           // FIXME: Check digit time!
           if (depositedEnergy)
           {
+                       depositedEnergy += gRandom->Gaus(0., .08);
+                         
             DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
             
             for (Int_t j=0;j<nSamples;j++) 
@@ -881,11 +921,15 @@ void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* dig
             }
             
             new((*digitsTRG)[digitsTRG->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
+                         
+                       if (AliDebugLevel()) ((AliEMCALRawDigit*)digitsTRG->At(digitsTRG->GetEntriesFast() - 1))->Print("");
           }
         }
       }
       
       delete [] timeSamples;
+               
+         if (digits && digits->GetEntriesFast()) digits->Delete();
     }// AliEMCAL exists
     else AliFatal("Could not get AliEMCAL");
   }// loader exists
@@ -899,14 +943,15 @@ void AliEMCALDigitizer::DigitalFastOR( Double_t time, Double_t dE, Int_t timeSam
        // id: 0..95
        const Int_t    reso = 11;      // 11-bit resolution ADC
        const Double_t vFSR = 1;       // Full scale input voltage range
-       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;     // 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-
-       const Double_t rise = 40e-9;   // rise time (10-90%) of the FastOR signal before shaping
+       const Double_t rise = 50e-9;   // rise time (10-90%) of the FastOR signal before shaping
        
        const Double_t kTimeBinWidth = 25E-9; // sampling frequency (40MHz)
        
        Double_t vV = 1000. * dE * dNe * vA; // GeV 2 MeV
-       
+               
        TF1 signalF("signal", AnalogFastORFunction, 0, nSamples * kTimeBinWidth, 3);
        signalF.SetParameter( 0,   vV ); 
        signalF.SetParameter( 1, time ); // FIXME: when does the signal arrive? Might account for cable lengths