+ TString tempConf = fConfEnv->GetValue("Temperature","ON");
+ tempConf.ToUpper();
+ if (tempConf != "OFF" ) {
+ entry = GetFromOCDB("Config", "Temperature");
+ if (entry) confTree = (TTree*) entry->GetObject();
+ if ( confTree==0 ) {
+ Log("AliEMCALPreprocessor: Temperature Config OCDB entry missing.\n");
+ fConfigOK = kFALSE;
+ return;
+ }
+ fTemp = new AliEMCALSensorTempArray(startTimeLocal, fEndTime, confTree, kAmandaTemp);
+ fTemp->SetValCut(kValCutTemp);
+ fTemp->SetDiffCut(kDiffCutTemp);
+ }
+
+ return;
+}
+
+//______________________________________________________________________________________________
+UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
+{
+ // Fills data into EMCAL calibrations objects
+ // Amanda servers provide information directly through dcsAliasMap
+
+ if (!fConfigOK) return kReturnCodeNoInfo;
+ UInt_t result = 0;
+ TObjArray *resultArray = new TObjArray();
+ TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
+ errorHandling.ToUpper();
+ TObject * status;
+
+ UInt_t dcsResult=0;
+ if (errorHandling == "OFF" ) {
+ if (!dcsAliasMap) dcsResult = kReturnCodeNoEntries;
+ else if (dcsAliasMap->GetEntries() == 0 ) dcsResult = kReturnCodeNoEntries;
+ status = new TParameter<int>("dcsResult",dcsResult);
+ resultArray->Add(status);
+ }
+ else {
+ if (!dcsAliasMap) return kReturnCodeNoInfo;
+ else if (dcsAliasMap->GetEntries() == 0 ) return kReturnCodeNoInfo;
+ }
+
+
+ TString runType = GetRunType();
+
+ // Temperature sensors are processed by AliEMCALCalTemp
+ TString tempConf = fConfEnv->GetValue("Temperature","ON");
+ tempConf.ToUpper();
+ if (tempConf != "OFF" && dcsAliasMap ) {
+ UInt_t tempResult = MapTemperature(dcsAliasMap);
+ result=tempResult;
+ status = new TParameter<int>("tempResult",tempResult);
+ resultArray->Add(status);
+ }
+ // Trigger configuration processing: only for Physics runs
+ TString triggerConf = fConfEnv->GetValue("Trigger","ON");
+ triggerConf.ToUpper();
+ if( runType == kPhysicsRunType ) {
+ if (triggerConf != "OFF" && dcsAliasMap ) {
+ UInt_t triggerResult = MapTriggerConfig(dcsAliasMap);
+ result+=triggerResult;
+ status = new TParameter<int>("triggerResult",triggerResult);
+ resultArray->Add(status);
+ }
+ }
+
+ // Other calibration information will be retrieved through FXS files
+ // examples:
+ // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
+ // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
+ //
+ // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
+ // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
+
+ // PEDESTAL ENTRIES:
+
+ if ( runType == kPedestalRunType ) {
+ Int_t numSources = 1;
+ Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ, AliShuttleInterface::kHLT} ;
+ TString source = fConfEnv->GetValue("Pedestal","DAQ");
+ source.ToUpper();
+ if (source != "OFF" ) {
+ if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
+ if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
+ if (source == "HLTDAQ" ) {
+ numSources=2;
+ pedestalSource[0] = AliShuttleInterface::kHLT;
+ pedestalSource[1] = AliShuttleInterface::kDAQ;
+ }
+ if (source == "DAQHLT" ) numSources=2;
+ UInt_t pedestalResult=0;
+ for (Int_t i=0; i<numSources; i++ ) {
+ pedestalResult = ExtractPedestals(pedestalSource[i]);
+ if ( pedestalResult == 0 ) break;
+ }
+ result += pedestalResult;
+ status = new TParameter<int>("pedestalResult",pedestalResult);
+ resultArray->Add(status);
+ }
+ }
+
+ // SIGNAL/LED ENTRIES:
+ if( runType == kPhysicsRunType ) {
+ Int_t numSources = 1;
+ Int_t signalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
+ TString source = fConfEnv->GetValue("Signal","DAQ");
+ source.ToUpper();
+ if ( source != "OFF") {
+ if ( source == "HLT") signalSource[0] = AliShuttleInterface::kHLT;
+ if (!GetHLTStatus()) signalSource[0] = AliShuttleInterface::kDAQ;
+ if (source == "HLTDAQ" ) {
+ numSources=2;
+ signalSource[0] = AliShuttleInterface::kHLT;
+ signalSource[1] = AliShuttleInterface::kDAQ;
+ }
+ if (source == "DAQHLT" ) numSources=2;
+ UInt_t signalResult=0;
+ for (Int_t i=0; i<numSources; i++ ) {
+ signalResult = ExtractSignal(signalSource[i]);
+ if ( signalResult == 0 ) break;
+ }
+ result += signalResult;
+ status = new TParameter<int>("signalResult",signalResult);
+ resultArray->Add(status);
+ }
+ }
+
+
+ // overall status at the end
+ if (errorHandling == "OFF" ) {
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible(kMetaResponsible);
+ metaData.SetComment("Preprocessor AliEMCAL status.");
+ Bool_t storeOK = Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
+ resultArray->Delete();
+ result = 0;
+ if ( !storeOK ) result=1;
+ return result;
+ }
+ else {
+ return result;
+ }
+
+}
+//______________________________________________________________________________________________
+UInt_t AliEMCALPreprocessor::MapTemperature(TMap* dcsAliasMap)
+{ // extract DCS temperature maps. Perform fits to save space
+ UInt_t result=0;
+
+ TMap *map = fTemp->ExtractDCS(dcsAliasMap);
+ if (map) {
+ fTemp->MakeSplineFit(map);
+ Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors();
+ if (fitFraction > kFitFraction ) {
+ AliInfo(Form("Temperature values extracted, fits performed.\n"));
+ }
+ else {
+ Log ("Too few temperature maps fitted. \n");
+ result = kReturnCodeNoInfo;
+ }
+ }
+ else {
+ Log("No temperature map extracted. \n");
+ result = kReturnCodeNoInfo;
+ }
+ delete map;
+ // Now store the final CDB file
+
+ if ( result == 0 ) { // some info was found
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible(kMetaResponsible);
+ metaData.SetComment(kMetaComment);
+
+ Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
+ if ( !storeOK ) result=1;
+ AliInfo(Form("Temperature info stored. result %d\n", result));
+ }
+
+ return result;
+}
+
+//______________________________________________________________________________________________
+UInt_t AliEMCALPreprocessor::MapTriggerConfig(TMap* dcsAliasMap)
+{ // extract DCS trigger info