-//____________________________________________________________________________
-void AliEMCALRawUtils::Raw2Digits(AliRawReader* reader,TClonesArray *digitsArr)
-{
- // convert raw data of the current event to digits
-
- digitsArr->Clear();
-
- if (!digitsArr) {
- Error("Raw2Digits", "no digits found !");
- return;
- }
- if (!reader) {
- Error("Raw2Digits", "no raw reader found !");
- return;
- }
-
- AliCaloRawStreamV3 in(reader,"EMCAL",fMapping);
- // Select EMCAL DDL's;
- reader->Select("EMCAL");
-
- //Updated fitting routine from 2007 beam test takes into account
- //possibility of two peaks in data and selects first one for fitting
- //Also sets some of the starting parameters based on the shape of the
- //given raw signal being fit
-
- TF1 * signalF = new TF1("signal", RawResponseFunction, 0, GetRawFormatTimeBins(), 5);
- signalF->SetParameters(10.,0.,fTau,fOrder,5.); //set all defaults once, just to be safe
- signalF->SetParNames("amp","t0","tau","N","ped");
- signalF->SetParameter(2,fTau); // tau in units of time bin
- signalF->SetParLimits(2,2,-1);
- signalF->SetParameter(3,fOrder); // order
- signalF->SetParLimits(3,2,-1);
-
- Int_t id = -1;
- Float_t time = 0. ;
- Float_t amp = 0. ;
- Int_t i = 0;
- Int_t startBin = 0;
-
- //Graph to hold data we will fit (should be converted to an array
- //later to speed up processing
- TGraph * gSig = new TGraph(GetRawFormatTimeBins());
-
- Int_t lowGain = 0;
- Int_t caloFlag = 0; // low, high gain, or TRU, or LED ref.
-
- // start loop over input stream
- while (in.NextDDL()) {
- while (in.NextChannel()) {
-
- //Check if the signal is high or low gain and then do the fit,
- //if it is from TRU do not fit
- caloFlag = in.GetCaloFlag();
- if (caloFlag != 0 && caloFlag != 1) continue;
-
- // There can be zero-suppression in the raw data,
- // so set up the TGraph in advance
- for (i=0; i < GetRawFormatTimeBins(); i++) {
- gSig->SetPoint(i, i , 0);
- }
-
- Int_t maxTime = 0;
- Int_t min = 0x3ff; // init to 10-bit max
- Int_t max = 0; // init to 10-bit min
- int nsamples = 0;
- while (in.NextBunch()) {
- const UShort_t *sig = in.GetSignals();
- startBin = in.GetStartTimeBin();
-
- if (((UInt_t) maxTime) < in.GetStartTimeBin()) {
- maxTime = in.GetStartTimeBin(); // timebins come in reverse order
- }
-
- if (maxTime < 0 || maxTime >= GetRawFormatTimeBins()) {
- AliWarning(Form("Invalid time bin %d",maxTime));
- maxTime = GetRawFormatTimeBins();
- }
- nsamples += in.GetBunchLength();
- for (i = 0; i < in.GetBunchLength(); i++) {
- time = startBin--;
- gSig->SetPoint(time, time, (Double_t) sig[i]) ;
- if (max < sig[i]) max= sig[i];
- if (min > sig[i]) min = sig[i];
- }
- } // loop over bunches
-
- if (nsamples > 0) { // this check is needed for when we have zero-supp. on, but not sparse readout
-
- id = fGeom->GetAbsCellIdFromCellIndexes(in.GetModule(), in.GetRow(), in.GetColumn()) ;
- lowGain = in.IsLowGain();