+ Int_t trgid;
+ if (geom->GetFastORIndexFromCellIndex(id , trgid))
+ {
+ AliDebug(1,Form("trigger digit id: %d from cell id: %d\n",trgid,id));
+
+ AliEMCALDigit* d = static_cast<AliEMCALDigit*>(digitsTMP->At(trgid));
+
+ if (!d)
+ {
+ new((*digitsTMP)[trgid]) AliEMCALDigit(*digit);
+ d = (AliEMCALDigit*)digitsTMP->At(trgid);
+ d->SetId(trgid);
+ }
+ else
+ {
+ *d = *d + *digit;
+ }
+ }
+ }
+
+ if (AliDebugLevel()) printf("Number of TRG digits: %d\n",digitsTMP->GetEntriesFast());
+
+ Int_t nSamples = geom->GetNTotalTRU();
+ Int_t *timeSamples = new Int_t[nSamples];
+
+ NextDigit = TIter(digitsTMP);
+ while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
+ {
+ if (digit)
+ {
+ Int_t id = digit->GetId();
+ Float_t time = 50.e-9;
+
+ Double_t depositedEnergy = 0.;
+ for (Int_t j = 1; j <= digit->GetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j);
+
+ if (AliDebugLevel()) printf("Deposited Energy: %f\n", depositedEnergy);
+
+ // FIXME: Check digit time!
+ if (depositedEnergy) {
+ depositedEnergy += gRandom->Gaus(0., .08);
+ DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
+
+ 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("");
+ }
+ }
+ }
+
+ delete [] timeSamples;
+
+ if (digits && digits->GetEntriesFast()) digits->Delete();
+}
+
+//____________________________________________________________________________
+void AliEMCALDigitizer::DigitalFastOR( Double_t time, Double_t dE, Int_t timeSamples[], Int_t nSamples )
+{
+ // parameters:
+ // id: 0..95
+ 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-
+ 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
+ signalF.SetParameter( 2, rise );
+
+ for (Int_t iTime=0; iTime<nSamples; iTime++)
+ {
+ // FIXME: add noise (probably not simply Gaussian) according to DA measurements
+ // probably plan an access to OCDB
+ 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;
+ }