-//____________________________________________________________________________
-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;
- }
-
- AliCaloRawStream 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. ;
-
- //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 readOk = 1;
- Int_t lowGain = 0;
- Int_t caloFlag = 0; // low, high gain, or TRU, or LED ref.
-
- while (readOk && in.GetModule() < 0)
- readOk = in.Next(); // Go to first digit
-
- while (readOk) {
-
- id = fGeom->GetAbsCellIdFromCellIndexes(in.GetModule(), in.GetRow(), in.GetColumn()) ;
- caloFlag = in.GetCaloFlag();
- lowGain = in.IsLowGain();
- Int_t maxTime = in.GetTime(); // timebins come in reverse order
- if (maxTime < 0 || maxTime >= GetRawFormatTimeBins()) {
- AliWarning(Form("Invalid time bin %d",maxTime));
- maxTime = GetRawFormatTimeBins();
- }
- gSig->Set(maxTime+1);
- // There is some kind of zero-suppression in the raw data,
- // so set up the TGraph in advance
- for (Int_t i=0; i < maxTime; i++) {
- gSig->SetPoint(i, i , 0);
- }
-
- Int_t iTime = 0;
- do {
- if (in.GetTime() >= gSig->GetN()) {
- AliWarning("Too many time bins");
- gSig->Set(in.GetTime());
- }
-
- gSig->SetPoint(in.GetTime(), in.GetTime(), in.GetSignal()) ;
-
- if (in.GetTime() > maxTime)
- maxTime = in.GetTime();
- iTime++;
- } while ((readOk = in.Next()) && !in.IsNewHWAddress());
-
- FitRaw(gSig, signalF, amp, time) ;
-
- if (caloFlag == 0 || caloFlag == 1) { // low gain or high gain
- if (amp > 0 && amp < 2000) { //check both high and low end of
- //result, 2000 is somewhat arbitrary - not nice with magic numbers in the code..
- AliDebug(2,Form("id %d lowGain %d amp %g", id, lowGain, amp));
-
- AddDigit(digitsArr, id, lowGain, (Int_t)amp, time);
- }
-
- }
-
- // Reset graph
- for (Int_t index = 0; index < gSig->GetN(); index++) {
- gSig->SetPoint(index, index, 0) ;
- }
- // Reset starting parameters for fit function
- signalF->SetParameters(10.,0.,fTau,fOrder,5.); //reset all defaults just to be safe