+ digit = dynamic_cast<AliEMCALDigit*>( digits->At(digit2->GetId()) ) ;
+ if ( !digit ) continue;
+
+ // Put the embedded cell energy in same units as simulated sdigits -> transform to energy units
+ // and multiply to get a big int.
+ Float_t time2 = digit2->GetTime();
+ Float_t e2 = digit2->GetAmplitude();
+ CalibrateADCTime(e2,time2,digit2->GetId());
+ Float_t amp2 = fSDigitizer->Digitize(e2);
+
+ Float_t e0 = digit ->GetAmplitude();
+ if(e0>0.01)
+ AliDebug(1,Form("digit 1: Abs ID %d, amp %f, type %d, time %e; digit2: Abs ID %d, amp %f, type %d, time %e\n",
+ digit ->GetId(),digit ->GetAmplitude(), digit ->GetType(), digit->GetTime(),
+ digit2->GetId(),amp2, digit2->GetType(), time2 ));
+
+ // Sum amplitudes, change digit amplitude
+ digit->SetAmplitude( digit->GetAmplitude() + amp2);
+
+ // Rough assumption, assign time of the largest of the 2 digits,
+ // data or signal to the final digit.
+ if(amp2 > digit->GetAmplitude()) digit->SetTime(time2);
+
+ //Mark the new digit as embedded
+ digit->SetType(AliEMCALDigit::kEmbedded);
+
+ if(digit2->GetAmplitude()>0.01 && e0> 0.01 )
+ AliDebug(1,Form("Embedded digit: Abs ID %d, amp %f, type %d\n",
+ digit->GetId(), digit->GetAmplitude(), digit->GetType()));
+ }//loop digit 2
+ }//input loop
+ }//embed
+
+ //JLK is it better to call Clear() here?
+ delete sdigArray ; //We should not delete its contents
+
+ //------------------------------
+ //remove digits below thresholds
+ // until 10-02-2010 remove digits with energy smaller than fDigitThreshold 3*fPinNoise
+ // now, remove digits with Digitized ADC smaller than fDigitThreshold = 3,
+ // before merge in the same loop real data digits if available
+ Float_t energy = 0;
+ Float_t time = 0;
+ for(i = 0 ; i < nEMC ; i++)
+ {
+ digit = dynamic_cast<AliEMCALDigit*>( digits->At(i) ) ;
+ if ( !digit ) continue;
+
+ //Then get the energy in GeV units.
+ energy = fSDigitizer->Calibrate(digit->GetAmplitude()) ;
+
+ //Then digitize using the calibration constants of the ocdb
+ Float_t ampADC = energy;
+ DigitizeEnergyTime(ampADC, time, digit->GetId()) ;
+
+ if(ampADC < fDigitThreshold)
+ digits->RemoveAt(i) ;
+
+ } // digit loop
+
+ digits->Compress() ;
+
+ Int_t ndigits = digits->GetEntriesFast() ;
+
+ //---------------------------------------------------------------
+ //JLK 26-June-2008
+ //After we have done the summing and digitizing to create the
+ //digits, now we want to calibrate the resulting amplitude to match
+ //the dynamic range of our real data.
+ for (i = 0 ; i < ndigits ; i++)
+ {
+ digit = dynamic_cast<AliEMCALDigit *>( digits->At(i) ) ;
+ if( !digit ) continue ;
+
+ digit->SetIndexInList(i) ;
+
+ time = digit->GetTime();
+ digit->SetTime(time);
+
+ energy = fSDigitizer->Calibrate(digit->GetAmplitude()) ;
+
+ Float_t ampADC = energy;
+ DigitizeEnergyTime(ampADC, time, digit->GetId());
+
+ digit->SetAmplitude(ampADC) ;
+ // printf("digit amplitude set at end: i %d, amp %f\n",i,digit->GetAmplitude());
+ }//Digit loop