+ // Print EMC and CPV calibration containers
+ // Input: option="ped" to print pedestals
+ // option="gain" to print calibration coefficients
+ if (fCalibDataEmc) fCalibDataEmc->Print(option);
+ if (fCalibDataCpv) fCalibDataCpv->Print(option);
+}
+
+//________________________________________________________________
+void AliPHOSCalibData::CreateNew()
+{
+ // Create new EMC and CPV calibration containers with ideal coefficients
+
+ if(fCalibDataEmc) delete fCalibDataEmc;
+ fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
+
+ if(fCalibDataCpv) delete fCalibDataCpv;
+ fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV");
+
+ if(fEmcBadChannelsMap) delete fEmcBadChannelsMap;
+ fEmcBadChannelsMap = new AliPHOSEmcBadChannelsMap();
+
+}
+
+//________________________________________________________________
+Bool_t AliPHOSCalibData::WriteEmc(Int_t firstRun, Int_t lastRun, AliCDBMetaData *md)
+{
+ // Write EMC calibration container to CDB
+
+ if(!fCalibDataEmc) return kFALSE;
+
+ AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS/*");
+ if(!storage)
+ storage = AliCDBManager::Instance()->GetDefaultStorage();
+
+ if(storage) {
+ AliCDBId id(fEmcDataPath.Data(),firstRun,lastRun);
+ storage->Put(fCalibDataEmc,id, md);
+ return kTRUE;
+ }
+ else
+ return kFALSE;
+
+}
+
+//________________________________________________________________
+Bool_t AliPHOSCalibData::WriteCpv(Int_t firstRun, Int_t lastRun, AliCDBMetaData *md)
+{
+ // Write CPV calibration container to CDB
+
+ if(!fCalibDataCpv) return kFALSE;
+
+ AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS/*");
+ if(!storage)
+ storage = AliCDBManager::Instance()->GetDefaultStorage();
+
+ if(storage) {
+ AliCDBId id(fCpvDataPath.Data(),firstRun,lastRun);
+ storage->Put(fCalibDataCpv,id, md);
+ return kTRUE;
+ }
+ else
+ return kFALSE;
+
+}
+
+
+//________________________________________________________________
+Bool_t AliPHOSCalibData::WriteEmcBadChannelsMap(Int_t firstRun,Int_t lastRun,AliCDBMetaData *md)
+{
+ //Write EMC bad channels map into CDB.
+
+ if(!fEmcBadChannelsMap) return kFALSE;
+
+ AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS/*");
+ if(!storage)
+ storage = AliCDBManager::Instance()->GetDefaultStorage();
+
+ if(storage) {
+ AliCDBId id(fEmcBadChannelsMapPath.Data(),firstRun,lastRun);
+ storage->Put(fEmcBadChannelsMap,id, md);
+ return kTRUE;
+ }
+ else
+ return kFALSE;
+}
+
+//________________________________________________________________
+Float_t AliPHOSCalibData::GetADCchannelEmc(Int_t module, Int_t column, Int_t row) const
+{
+ // Return EMC calibration coefficient
+ // for channel defined by (module,column,row)
+ // module, column,raw should follow the internal PHOS convention:
+ // module 1:5, column 1:56, row 1:64
+ // if CBD instance exists, the value is taken from CDB.
+ // Otherwise it is an ideal one
+
+ if(fCalibDataEmc)
+ return fCalibDataEmc->GetADCchannelEmc(module,column,row);
+ else
+ return 1.0; // default width of one EMC ADC channel in GeV
+}
+
+//________________________________________________________________
+void AliPHOSCalibData::SetADCchannelEmc(Int_t module, Int_t column, Int_t row, Float_t value)
+{
+ // Set EMC calibration coefficient for (module,column,row)
+
+ if(!fCalibDataEmc)
+ fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
+
+ fCalibDataEmc->SetADCchannelEmc(module,column,row,value);
+}
+
+//________________________________________________________________
+Float_t AliPHOSCalibData::GetADCpedestalEmc(Int_t module, Int_t column, Int_t row) const
+{
+ // Return EMC pedestal for channel defined by (module,column,row)
+ // module, column,raw should follow the internal PHOS convention:
+ // module 1:5, column 1:56, row 1:64
+ // if CBD instance exists, the value is taken from CDB.
+ // Otherwise it is an ideal one
+
+ if(fCalibDataEmc)
+ return fCalibDataEmc->GetADCpedestalEmc(module,column,row);
+ else
+ return 0.0; // default EMC ADC pedestal
+}
+
+//________________________________________________________________
+void AliPHOSCalibData::SetADCpedestalEmc(Int_t module, Int_t column, Int_t row, Float_t value)
+{
+ // Set EMC pedestal for (module,column,row)
+
+ if(!fCalibDataEmc)
+ fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
+
+ fCalibDataEmc->SetADCpedestalEmc(module,column,row,value);
+}
+
+//________________________________________________________________
+Float_t AliPHOSCalibData::GetHighLowRatioEmc(Int_t module, Int_t column, Int_t row) const
+{
+ // Return EMC calibration coefficient
+ // for channel defined by (module,column,row)
+ // module, column,raw should follow the internal PHOS convention:
+ // module 1:5, column 1:56, row 1:64
+ // if CBD instance exists, the value is taken from CDB.
+ // Otherwise it is an ideal one
+
+ if(fCalibDataEmc)
+ return fCalibDataEmc->GetHighLowRatioEmc(module,column,row);
+ else
+ return 1.0; // default width of one EMC ADC channel in GeV
+}
+
+//________________________________________________________________
+void AliPHOSCalibData::SetHighLowRatioEmc(Int_t module, Int_t column, Int_t row, Float_t value)
+{
+ // Set EMC calibration coefficient for (module,column,row)
+
+ if(!fCalibDataEmc)
+ fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
+
+ fCalibDataEmc->SetHighLowRatioEmc(module,column,row,value);
+}
+
+//________________________________________________________________
+Float_t AliPHOSCalibData::GetTimeShiftEmc(Int_t module, Int_t column, Int_t row) const
+{
+ // Return EMC calibration coefficient
+ // for channel defined by (module,column,row)
+ // module, column,raw should follow the internal PHOS convention:
+ // module 1:5, column 1:56, row 1:64
+ // if CBD instance exists, the value is taken from CDB.
+ // Otherwise it is an ideal one
+
+ if(fCalibDataEmc)
+ return fCalibDataEmc->GetTimeShiftEmc(module,column,row);
+ else
+ return 0.0; // by default no offset
+}
+//________________________________________________________________
+Float_t AliPHOSCalibData::GetLGTimeShiftEmc(Int_t module, Int_t column, Int_t row) const
+{
+ // Return EMC calibration coefficient
+ // for channel defined by (module,column,row)
+ // module, column,raw should follow the internal PHOS convention:
+ // module 1:5, column 1:56, row 1:64
+ // if CBD instance exists, the value is taken from CDB.
+ // Otherwise it is an ideal one
+
+ if(fCalibDataEmc)
+ return fCalibDataEmc->GetLGTimeShiftEmc(module,column,row);
+ else
+ return 0.0; // no offset by default
+}
+
+//________________________________________________________________
+void AliPHOSCalibData::SetLGTimeShiftEmc(Int_t module, Int_t column, Int_t row, Float_t value)
+{
+ // Set EMC calibration coefficient for (module,column,row)
+
+ if(!fCalibDataEmc)
+ fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
+
+ fCalibDataEmc->SetLGTimeShiftEmc(module,column,row,value);
+}
+//________________________________________________________________
+void AliPHOSCalibData::SetTimeShiftEmc(Int_t module, Int_t column, Int_t row, Float_t value)
+{
+ // Set EMC calibration coefficient for (module,column,row)
+
+ if(!fCalibDataEmc)
+ fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
+
+ fCalibDataEmc->SetTimeShiftEmc(module,column,row,value);
+}
+//________________________________________________________________
+Float_t AliPHOSCalibData::GetSampleTimeStep() const
+{
+ //Get conversion coeff. from sample time step to seconds.
+ //Negative value means that it is not used in reconstruction
+ //but only in simulation of raw.
+ if(fCalibDataEmc)
+ return fCalibDataEmc->GetSampleTimeStep();
+ else
+ return 0.0; // default width of one EMC ADC channel in GeV
+}
+//________________________________________________________________
+void AliPHOSCalibData::SetSampleTimeStep(Float_t step)
+{
+ //Set conversion coeff. from sample time step to seconds.
+ //Negative value means that it is not used in reconstruction
+ //but only in simulation of raw.
+ if(!fCalibDataEmc)
+ fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
+
+ fCalibDataEmc->SetSampleTimeStep(step) ;
+}
+//________________________________________________________________
+Int_t AliPHOSCalibData::GetAltroOffsetEmc(Int_t module, Int_t column, Int_t row) const
+{
+ // Return ALTRO pedestal coefficient
+ // for channel defined by (module,column,row)
+ // module, column,raw should follow the internal PHOS convention:
+ // module 1:5, column 1:56, row 1:64
+ // if CBD instance exists, the value is taken from CDB.
+ // Otherwise it is an ideal one
+
+ if(fCalibDataEmc)
+ return fCalibDataEmc->GetAltroOffsetEmc(module,column,row);
+ else
+ return 0; // default width of one EMC ADC channel in GeV
+}
+
+//________________________________________________________________
+void AliPHOSCalibData::SetAltroOffsetEmc(Int_t module, Int_t column, Int_t row, Int_t value)
+{
+ // Set altro offset for (module,column,row)
+
+ if(!fCalibDataEmc)
+ fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
+
+ fCalibDataEmc->SetAltroOffsetEmc(module,column,row,value);
+}
+
+
+//________________________________________________________________
+Float_t AliPHOSCalibData::GetADCchannelCpv(Int_t module, Int_t column, Int_t row) const
+{
+ // Return CPV calibration coefficient
+ // for channel defined by (module,column,row)
+ // module, column,raw should follow the internal CPV convention:
+ // module 1:5, column 1:56, row 1:128
+ // if CBD instance exists, the value is taken from CDB.
+ // Otherwise it is an ideal one
+
+ if(fCalibDataCpv)
+ return fCalibDataCpv->GetADCchannelCpv(module,column,row);
+ else
+ return 0.0012; // default width of one ADC channel in CPV arbitrary units
+}
+
+//________________________________________________________________
+Float_t AliPHOSCalibData::GetADCpedestalCpv(Int_t module, Int_t column, Int_t row) const
+{
+ // Return CPV pedestal
+ // for channel defined by (module,column,row)
+ // module, column,raw should follow the internal CPV convention:
+ // module 1:5, column 1:56, row 1:128
+ // if CBD instance exists, the value is taken from CDB.
+ // Otherwise it is an ideal one
+
+ if(fCalibDataCpv)
+ return fCalibDataCpv->GetADCpedestalCpv(module,column,row);
+ else
+ return 0.012; // default CPV ADC pedestal
+}
+
+//________________________________________________________________
+void AliPHOSCalibData::SetADCchannelCpv(Int_t module, Int_t column, Int_t row, Float_t value)
+{
+ // Set CPV calibration coefficient for (module,column,row)
+
+ if(!fCalibDataCpv)
+ fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV");
+
+ fCalibDataCpv->SetADCchannelCpv(module,column,row,value);
+}
+
+//________________________________________________________________
+void AliPHOSCalibData::SetADCpedestalCpv(Int_t module, Int_t column, Int_t row, Float_t value)
+{
+ // Set CPV pedestal for (module,column,row)
+
+ if(!fCalibDataCpv)
+ fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV");
+
+ fCalibDataCpv->SetADCpedestalCpv(module,column,row,value);
+}
+
+//________________________________________________________________
+void AliPHOSCalibData::RandomEmc(Float_t ccMin, Float_t ccMax)
+{
+ // Create decalibrated EMC with calibration coefficients and pedestals
+ // randomly distributed within hard-coded limits
+ // Default spread of calibration parameters is Cmax/Cmin = 4, (Cmax-Cmin)/2 = 1
+
+ if(fCalibDataEmc) delete fCalibDataEmc;
+ fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC");
+
+ TRandom rn;
+ rn.SetSeed(0); //the seed is set to the current machine clock
+
+ Float_t adcChannelEmc,adcPedestalEmc;
+
+ for(Int_t module=1; module<6; module++) {
+ for(Int_t column=1; column<57; column++) {
+ for(Int_t row=1; row<65; row++) {
+ adcChannelEmc =rn.Uniform(ccMin,ccMax);
+ adcPedestalEmc=rn.Uniform(0.0,0.0); // 0 spread of pedestals
+ fCalibDataEmc->SetADCchannelEmc(module,column,row,adcChannelEmc);
+ fCalibDataEmc->SetADCpedestalEmc(module,column,row,adcPedestalEmc);