+ // Fits the raw signal time distribution
+
+ const Int_t kNoiseThreshold = 0 ;
+ Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
+ Double_t signal = 0., signalmax = 0. ;
+ time = 0. ;
+ energy = 0. ;
+
+ // Create a shaper pulse object which contains all the shaper parameters
+ AliPHOSPulseGenerator pulse;
+
+ if (lowGainFlag) {
+ timezero1 = timezero2 = signalmax = timemax = 0. ;
+ signalF->FixParameter(0, pulse.GetRawFormatLowCharge()) ;
+ signalF->FixParameter(1, pulse.GetRawFormatLowGain()) ;
+ Int_t index ;
+ for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
+ gLowGain->GetPoint(index, time, signal) ;
+ if (signal > kNoiseThreshold && timezero1 == 0.)
+ timezero1 = time ;
+ if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
+ timezero2 = time ;
+ if (signal > signalmax) {
+ signalmax = signal ;
+ timemax = time ;
+ }
+ }
+ signalmax /=
+ pulse.RawResponseFunctionMax(pulse.GetRawFormatLowCharge(),
+ pulse.GetRawFormatLowGain()) ;
+ if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
+ signalF->SetParameter(2, signalmax) ;
+ signalF->SetParameter(3, timezero1) ;
+ gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ;
+ energy = signalF->GetParameter(2) ;
+ time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
+ }
+ } else {
+ timezero1 = timezero2 = signalmax = timemax = 0. ;
+ signalF->FixParameter(0, pulse.GetRawFormatHighCharge()) ;
+ signalF->FixParameter(1, pulse.GetRawFormatHighGain()) ;
+ Int_t index ;
+ for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
+ gHighGain->GetPoint(index, time, signal) ;
+ if (signal > kNoiseThreshold && timezero1 == 0.)
+ timezero1 = time ;
+ if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
+ timezero2 = time ;
+ if (signal > signalmax) {
+ signalmax = signal ;
+ timemax = time ;
+ }
+ }
+ signalmax /= pulse.RawResponseFunctionMax(pulse.GetRawFormatHighCharge(),
+ pulse.GetRawFormatHighGain()) ;;
+ if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
+ signalF->SetParameter(2, signalmax) ;
+ signalF->SetParameter(3, timezero1) ;
+ gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ;
+ energy = signalF->GetParameter(2) ;
+ time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
+ }
+ }
+ if (time == 0) energy = 0 ;
+}
+
+//____________________________________________________________________________
+Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
+{
+ // Convert energy into digitized amplitude for a cell relId
+ // It is a user responsilibity to open CDB and set
+ // AliPHOSCalibData object by the following operators:
+ //
+ // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
+ // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
+ // ->Get(path_to_calibdata,run_number);
+ // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
+ // gime->SetCalibData(clb);
+
+ if (CalibData() == 0)
+ Warning("CalibrateRaw","Calibration DB is not initiated!");
+
+ Int_t module = relId[0];
+ Int_t column = relId[3];
+ Int_t row = relId[2];
+
+ Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
+ Float_t pedestal = 0.005; // Emc pedestals
+
+ if(CalibData()) {
+ gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
+ pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
+ }