+ Log("Processing FEE");
+
+ Bool_t updateOCDB = kFALSE;
+ AliTOFFEEReader feeReader;
+
+ TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels);
+
+ /* load current TOF FEE config from DCS FXS, parse,
+ * fill current FEE histogram and set FEE status */
+
+ const char * nameFile = GetFile(kDCS,"TofFeeLightMap","");
+ AliInfo(Form("nameFile = %s",nameFile));
+ if (nameFile == NULL) {
+ return 15;
+ }
+ feeReader.LoadFEElightConfig(nameFile);
+ Int_t parseFee = feeReader.ParseFEElightConfig();
+ AliDebug(2,Form("%i enabled channels found in FEElight configuration",parseFee));
+ /* load stored TOF FEE from OCDB and compare it with current FEE.
+ * if stored FEE is different from current FEE set update flag.
+ * if there is no stored FEE in OCDB set update flag */
+
+ fMatchingWindow = new Int_t[fNChannels];
+
+ AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Status");
+ if (!cdbEntry) {
+ /* no CDB entry found. set update flag */
+ Log(" ************ WARNING ************");
+ Log("No CDB Status entry found, creating a new one!");
+ Log(" *********************************");
+ fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
+ updateOCDB = kTRUE;
+ }
+ else {
+ if (cdbEntry) cdbEntry->SetOwner(kFALSE);
+ /* CDB entry OK. loop over channels */
+ fStatus = (AliTOFChannelOnlineStatusArray*) cdbEntry->GetObject();
+ delete cdbEntry;
+ cdbEntry = 0x0;
+ }
+ for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){
+ //AliDebug(2,Form("********** channel %i",iChannel));
+ /* compare current FEE channel status with stored one
+ * if different set update flag and break loop */
+ //AliDebug(2,Form( " channel %i status before FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
+ fMatchingWindow[iChannel] = feeReader.GetMatchingWindow(iChannel);
+ if (feeReader.IsChannelEnabled(iChannel)) {
+ hCurrentFEE.SetBinContent(iChannel + 1, 1);
+ if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){
+ updateOCDB = kTRUE;
+ fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk);
+ AliDebug(3,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
+ }
+ }
+ else {
+ if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){
+ updateOCDB = kTRUE;
+ fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad);
+ AliDebug(3,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
+ }
+ }
+ }
+
+
+ /* check whether we don't have to store reference data.
+ * in this case we return without errors. */
+ if (fStoreRefData) {
+ /* store reference data */
+ AliCDBMetaData metaDataHisto;
+ metaDataHisto.SetBeamPeriod(0);
+ metaDataHisto.SetResponsible("Roberto Preghenella");
+ metaDataHisto.SetComment("This preprocessor stores the FEE Ref data of the current run.");
+ AliInfo("Storing FEE reference data");
+ /* store FEE reference data */
+ if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) {
+ /* failed */
+ Log("problems while storing FEE reference data");
+ if (fStatus){
+ delete fStatus;
+ fStatus = 0;
+ }
+ return 18; /* error return code for problems while storing FEE reference data */
+ }
+ }
+
+ /* check whether we don't need to update OCDB.
+ * in this case we can return without errors and
+ * the current FEE is stored in the fStatus object. */
+ if (!updateOCDB) {
+ AliInfo("TOF FEE config has not changed. Do not overwrite stored file.");
+ return 0; /* return ok */
+ }
+
+ TString runType = GetRunType();
+ if (runType != "PHYSICS") {
+ AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType()));
+ return 0; /* return ok */
+ }
+
+ /* update the OCDB with the current FEE since even
+ * a little difference has been detected. */
+
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Roberto Preghenella");
+ metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE data.");
+ AliInfo("Storing Status data from current run after FEE parsing");
+ /* store FEE data */
+ if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) {
+ /* failed */
+ Log("problems while storing FEE data object");
+ if (fStatus){
+ delete fStatus;
+ fStatus = 0;
+ }
+ return 17; /* return error code for problems while storing FEE data */
+ }
+
+ /* everything fine. return */
+
+ if (fStatus){
+ delete fStatus;
+ fStatus = 0;
+ }