LCOV - code coverage report
Current view: top level - EMCAL/EMCALbase - AliEMCALPreprocessor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 345 2.0 %
Date: 2016-06-14 17:26:59 Functions: 7 24 29.2 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : ///////////////////////////////////////////////////////////////////////////////
      19             : // EMCAL Preprocessor class. It runs by Shuttle at the end of the run,
      20             : // calculates stuff to be posted in OCDB
      21             : //
      22             : // Author: Boris Polichtchouk, 4 October 2006
      23             : // Adapted for EMCAL by Gustavo Conesa Balbastre, October 2006
      24             : // Updated by David Silvermyr May 2008, based on TPC code
      25             : // Updated by Markus Fasel November 2015, adding DCAL STU
      26             : ///////////////////////////////////////////////////////////////////////////////
      27             : 
      28             : //Root
      29             : #include "TFile.h"
      30             : #include "TTree.h"
      31             : #include "TEnv.h"
      32             : #include "TParameter.h"
      33             : #include "TString.h"
      34             : 
      35             : #include <TTimeStamp.h>
      36             : 
      37             : //AliRoot
      38             : #include "AliShuttleInterface.h"
      39             : #include "AliEMCALPreprocessor.h"
      40             : #include "AliLog.h"
      41             : #include "AliDCSValue.h"
      42             : #include "AliCDBMetaData.h"
      43             : #include "AliEMCALTriggerTRUDCSConfig.h"
      44             : #include "AliEMCALTriggerSTUDCSConfig.h"
      45             : #include "AliEMCALTriggerDCSConfig.h"
      46             : #include "AliCaloCalibPedestal.h"
      47             : #include "AliCaloCalibSignal.h"
      48             : #include "AliEMCALSensorTempArray.h"
      49             : 
      50             : const Int_t kValCutTemp = 100;               // discard temperatures > 100 degrees
      51             : const Int_t kDiffCutTemp = 5;                // discard temperature differences > 5 degrees
      52          42 : const TString kPedestalRunType = "PEDESTAL";  // pedestal run identifier
      53          42 : const TString kPhysicsRunType = "PHYSICS";   // physics run identifier
      54          42 : const TString kStandAloneRunType = "STANDALONE_BC"; // standalone run identifier
      55          42 : const TString kAmandaTemp = "EMC_PT_%02d.Temperature"; // Amanda string for temperature entries
      56             : //const Double_t kFitFraction = 0.7;                 // Fraction of DCS sensor fits required 
      57             : const Double_t kFitFraction = -1.0;          // Don't require minimum number of fits during commissioning 
      58             : 
      59          42 : const TString kMetaResponsible = "David Silvermyr";
      60             : //legacy comments and return codes from TPC
      61          42 : const TString kMetaComment = "Preprocessor AliEMCAL data base entries.";
      62             : const int kReturnCodeNoInfo = 9;
      63             : const int kReturnCodeNoObject = 2;
      64             : const int kReturnCodeNoEntries = 1;
      65             : 
      66          42 : ClassImp(AliEMCALPreprocessor)
      67             : 
      68             : //_______________________________________________________________________________________
      69             : AliEMCALPreprocessor::AliEMCALPreprocessor() :
      70           0 : AliPreprocessor("EMC",0),
      71           0 : fConfEnv(0),
      72           0 : fTemp(0),
      73           0 : fConfigOK(kTRUE)
      74           0 : {
      75             :   //default constructor
      76           0 : }
      77             : 
      78             : //_______________________________________________________________________________________
      79             : AliEMCALPreprocessor::AliEMCALPreprocessor(AliShuttleInterface* shuttle):
      80           0 :       AliPreprocessor("EMC",shuttle),
      81           0 :       fConfEnv(0),
      82           0 :       fTemp(0),
      83           0 :       fConfigOK(kTRUE)
      84           0 : {
      85             :   // Constructor AddRunType(kPedestalRunType);
      86             : 
      87             :   // define run types to be processed
      88           0 :   AddRunType(kPedestalRunType);
      89           0 :   AddRunType(kPhysicsRunType);
      90           0 : }
      91             : 
      92             : //______________________________________________________________________________________________
      93             : AliEMCALPreprocessor::AliEMCALPreprocessor(const AliEMCALPreprocessor&  ) :
      94           0 :       AliPreprocessor("EMCAL",0),
      95           0 :       fConfEnv(0), fTemp(0), fConfigOK(kTRUE)
      96           0 : {
      97           0 :   Fatal("AliEMCALPreprocessor", "copy constructor not implemented");
      98           0 : }
      99             : 
     100             : // assignment operator; use copy ctor to make life easy.
     101             : //______________________________________________________________________________________________
     102             : AliEMCALPreprocessor& AliEMCALPreprocessor::operator = (const AliEMCALPreprocessor &source ) 
     103             : {
     104             :   // assignment operator; use copy ctor
     105           0 :   if (&source == this) return *this;
     106             : 
     107           0 :   new (this) AliEMCALPreprocessor(source);
     108           0 :   return *this;
     109           0 : }
     110             : 
     111             : //____________________________________________________________________________
     112             : AliEMCALPreprocessor::~AliEMCALPreprocessor()
     113           0 : {
     114             :   // destructor
     115           0 :   if (fTemp) delete fTemp;
     116           0 : }
     117             : 
     118             : //______________________________________________________________________________________________
     119             : void AliEMCALPreprocessor::Initialize(Int_t run, UInt_t startTime,
     120             :     UInt_t endTime)
     121             : {
     122             :   // Creates AliTestDataDCS object -- start maps half an hour beforre actual run start
     123           0 :   UInt_t startTimeLocal = startTime-1800;
     124           0 :   AliPreprocessor::Initialize(run, startTimeLocal, endTime);
     125             : 
     126           0 :   AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
     127             :       TTimeStamp((time_t)startTime,0).AsString(),
     128             :       TTimeStamp((time_t)endTime,0).AsString()));
     129             : 
     130             :   // Preprocessor configuration
     131           0 :   AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
     132           0 :   if (entry) fConfEnv = (TEnv*) entry->GetObject();
     133           0 :   if ( fConfEnv==0 ) {
     134           0 :     Log("AliEMCALPreprocessor: Preprocessor Config OCDB entry missing.\n");
     135           0 :     fConfigOK = kFALSE;
     136           0 :     return;
     137             :   }
     138             : 
     139             :   // Temperature sensors
     140             :   TTree *confTree = 0;
     141             : 
     142           0 :   TString tempConf = fConfEnv->GetValue("Temperature","ON");
     143           0 :   tempConf.ToUpper();
     144           0 :   if (tempConf != "OFF" ) {
     145           0 :     entry = GetFromOCDB("Config", "Temperature");
     146           0 :     if (entry) confTree = (TTree*) entry->GetObject();
     147           0 :     if ( confTree==0 ) {
     148           0 :       Log("AliEMCALPreprocessor: Temperature Config OCDB entry missing.\n");
     149           0 :       fConfigOK = kFALSE;
     150           0 :       return;
     151             :     }
     152           0 :     fTemp = new AliEMCALSensorTempArray(startTimeLocal, fEndTime, confTree, kAmandaTemp);
     153           0 :     fTemp->SetValCut(kValCutTemp);
     154           0 :     fTemp->SetDiffCut(kDiffCutTemp);
     155           0 :   }
     156             : 
     157           0 :   return;
     158           0 : }
     159             : 
     160             : //______________________________________________________________________________________________
     161             : UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
     162             : {
     163             :   // Fills data into EMCAL calibrations objects
     164             :   // Amanda servers provide information directly through dcsAliasMap
     165             : 
     166           0 :   if (!fConfigOK) return kReturnCodeNoInfo;
     167             :   UInt_t result = 0;
     168           0 :   TObjArray *resultArray = new TObjArray();
     169           0 :   TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
     170           0 :   errorHandling.ToUpper();
     171             :   TObject * status;
     172             : 
     173             :   UInt_t dcsResult=0;
     174           0 :   if (errorHandling == "OFF" ) {
     175           0 :     if (!dcsAliasMap) dcsResult = kReturnCodeNoEntries;
     176           0 :     else if (dcsAliasMap->GetEntries() == 0 ) dcsResult = kReturnCodeNoEntries;  
     177           0 :     status = new TParameter<int>("dcsResult",dcsResult);
     178           0 :     resultArray->Add(status);
     179             :   } 
     180             :   else {
     181           0 :     if (!dcsAliasMap) return kReturnCodeNoInfo;
     182           0 :     else if (dcsAliasMap->GetEntries() == 0 ) return kReturnCodeNoInfo;
     183             :   }
     184             : 
     185             : 
     186           0 :   TString runType = GetRunType();
     187             : 
     188             :   // Temperature sensors are processed by AliEMCALCalTemp
     189           0 :   TString tempConf = fConfEnv->GetValue("Temperature","ON");
     190           0 :   tempConf.ToUpper();
     191           0 :   if (tempConf != "OFF" && dcsAliasMap ) {
     192           0 :     UInt_t tempResult = MapTemperature(dcsAliasMap);
     193             :     result=tempResult;
     194           0 :     status = new TParameter<int>("tempResult",tempResult);
     195           0 :     resultArray->Add(status);
     196           0 :   }
     197             :   // Trigger configuration processing: only for Physics runs
     198           0 :   TString triggerConf = fConfEnv->GetValue("Trigger","ON");
     199           0 :   triggerConf.ToUpper();
     200           0 :   if( runType == kPhysicsRunType ) {
     201           0 :     if (triggerConf != "OFF" && dcsAliasMap ) {
     202           0 :       UInt_t triggerResult = MapTriggerConfig(dcsAliasMap);
     203           0 :       result+=triggerResult;
     204           0 :       status = new TParameter<int>("triggerResult",triggerResult);
     205           0 :       resultArray->Add(status);
     206           0 :     }
     207             :   }
     208             : 
     209             :   // Other calibration information will be retrieved through FXS files
     210             :   //  examples:
     211             :   //    TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
     212             :   //    const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
     213             :   //
     214             :   //    TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
     215             :   //    const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
     216             : 
     217             :   // PEDESTAL ENTRIES:
     218             : 
     219           0 :   if ( runType == kPedestalRunType ) {
     220             :     Int_t numSources = 1;
     221           0 :     Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ, AliShuttleInterface::kHLT} ;
     222           0 :     TString source = fConfEnv->GetValue("Pedestal","DAQ");
     223           0 :     source.ToUpper();
     224           0 :     if (source != "OFF" ) { 
     225           0 :       if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
     226           0 :       if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
     227           0 :       if (source == "HLTDAQ" ) {
     228             :         numSources=2;
     229           0 :         pedestalSource[0] = AliShuttleInterface::kHLT;
     230           0 :         pedestalSource[1] = AliShuttleInterface::kDAQ;
     231           0 :       }
     232           0 :       if (source == "DAQHLT" ) numSources=2;
     233             :       UInt_t pedestalResult=0;
     234           0 :       for (Int_t i=0; i<numSources; i++ ) {  
     235           0 :         pedestalResult = ExtractPedestals(pedestalSource[i]);
     236           0 :         if ( pedestalResult == 0 ) break;
     237             :       }
     238           0 :       result += pedestalResult;
     239           0 :       status = new TParameter<int>("pedestalResult",pedestalResult);
     240           0 :       resultArray->Add(status);
     241           0 :     }
     242           0 :   }
     243             : 
     244             :   // SIGNAL/LED ENTRIES:
     245           0 :   if( runType == kPhysicsRunType ) {
     246             :     Int_t numSources = 1;
     247           0 :     Int_t signalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
     248           0 :     TString source = fConfEnv->GetValue("Signal","DAQ");
     249           0 :     source.ToUpper();
     250           0 :     if ( source != "OFF") { 
     251           0 :       if ( source == "HLT") signalSource[0] = AliShuttleInterface::kHLT;
     252           0 :       if (!GetHLTStatus()) signalSource[0] = AliShuttleInterface::kDAQ;
     253           0 :       if (source == "HLTDAQ" ) {
     254             :         numSources=2;
     255           0 :         signalSource[0] = AliShuttleInterface::kHLT;
     256           0 :         signalSource[1] = AliShuttleInterface::kDAQ;
     257           0 :       }
     258           0 :       if (source == "DAQHLT" ) numSources=2;
     259             :       UInt_t signalResult=0;
     260           0 :       for (Int_t i=0; i<numSources; i++ ) {  
     261           0 :         signalResult = ExtractSignal(signalSource[i]);
     262           0 :         if ( signalResult == 0 ) break;
     263             :       }
     264           0 :       result += signalResult;
     265           0 :       status = new TParameter<int>("signalResult",signalResult);
     266           0 :       resultArray->Add(status);
     267           0 :     }
     268           0 :   }
     269             : 
     270             : 
     271             :   // overall status at the end
     272           0 :   if (errorHandling == "OFF" ) {
     273           0 :     AliCDBMetaData metaData;
     274           0 :     metaData.SetBeamPeriod(0);
     275           0 :     metaData.SetResponsible(kMetaResponsible);
     276           0 :     metaData.SetComment("Preprocessor AliEMCAL status.");
     277           0 :     Bool_t storeOK = Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
     278           0 :     resultArray->Delete();
     279             :     result = 0;
     280           0 :     if ( !storeOK )  result=1;
     281             :     return result;
     282           0 :   } 
     283             :   else { 
     284           0 :     return result;
     285             :   }
     286             : 
     287           0 : }
     288             : //______________________________________________________________________________________________
     289             : UInt_t AliEMCALPreprocessor::MapTemperature(TMap* dcsAliasMap)
     290             : { // extract DCS temperature maps. Perform fits to save space
     291             :   UInt_t result=0;
     292             : 
     293           0 :   TMap *map = fTemp->ExtractDCS(dcsAliasMap);
     294           0 :   if (map) {
     295           0 :     fTemp->MakeSplineFit(map);
     296           0 :     Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors(); 
     297           0 :     if (fitFraction > kFitFraction ) {
     298           0 :       AliInfo(Form("Temperature values extracted, fits performed.\n"));
     299           0 :     } 
     300             :     else { 
     301           0 :       Log ("Too few temperature maps fitted. \n");
     302             :       result = kReturnCodeNoInfo;
     303             :     }
     304           0 :   } 
     305             :   else {
     306           0 :     Log("No temperature map extracted. \n");
     307             :     result = kReturnCodeNoInfo;
     308             :   }
     309           0 :   delete map;
     310             :   // Now store the final CDB file
     311             : 
     312           0 :   if ( result == 0 ) { // some info was found
     313           0 :     AliCDBMetaData metaData;
     314           0 :     metaData.SetBeamPeriod(0);
     315           0 :     metaData.SetResponsible(kMetaResponsible);
     316           0 :     metaData.SetComment(kMetaComment);
     317             : 
     318           0 :     Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
     319           0 :     if ( !storeOK )  result=1;
     320           0 :     AliInfo(Form("Temperature info stored. result %d\n", result));
     321           0 :   }
     322             : 
     323           0 :   return result;
     324           0 : }
     325             : 
     326             : //______________________________________________________________________________________________
     327             : UInt_t AliEMCALPreprocessor::MapTriggerConfig(TMap* dcsAliasMap)
     328             : { // extract DCS trigger info
     329             : 
     330             :   const Int_t kNTRU = 46;
     331             : 
     332           0 :   AliInfo("Print DCS alias map content");
     333           0 :   dcsAliasMap->Print();
     334             : 
     335           0 :   AliInfo(Form("Get TRU info from DCS DPs.\n"));
     336             :   Int_t i, iTRU;
     337             :   const Int_t bufsize = 1000;
     338           0 :   char buf[bufsize];
     339             : 
     340             :   AliDCSValue *dcsVal;
     341             : 
     342             :   // overall object to hold STU and DCS config info
     343             :   // DS comment: for now only holds TRU info, i.e. only partially filled
     344             :   // (STU info only in raw data header; unfortunately not also picked up via DCS DPs)
     345           0 :   AliEMCALTriggerDCSConfig *trigConfig = new AliEMCALTriggerDCSConfig();
     346             :   // allocate space for TRU objects
     347           0 :   TClonesArray *truArr = new TClonesArray("AliEMCALTriggerTRUDCSConfig", kNTRU);
     348           0 :   for( iTRU = 0; iTRU < kNTRU; iTRU++){
     349           0 :     new((*truArr)[iTRU]) AliEMCALTriggerTRUDCSConfig();
     350             :   }
     351           0 :   trigConfig->SetTRUArr(truArr);
     352             : 
     353             :   // loop through all TRUs
     354           0 :   for( iTRU = 0; iTRU < kNTRU; iTRU++){
     355           0 :     AliInfo( Form("iTRU %d \n", iTRU) );
     356             : 
     357             :     // fill the objects
     358           0 :     AliEMCALTriggerTRUDCSConfig* truConfig = trigConfig->GetTRUDCSConfig(iTRU);
     359           0 :     if( ! truConfig ){
     360           0 :       AliWarning( Form("EMC TRU%02d config not retrieved!\n", iTRU ));
     361           0 :       continue;
     362             :     }
     363             : 
     364             :     // get last entries. fill the TRU object
     365           0 :     snprintf( buf, bufsize, "EMC_TRU%02d_L0ALGSEL", iTRU );
     366           0 :     if((dcsVal = ReadDCSValue(dcsAliasMap, buf))){
     367           0 :       AliInfo(Form("saving value: %d\n", dcsVal->GetUInt()));
     368           0 :       truConfig->SetL0SEL( dcsVal->GetUInt() );
     369           0 :     }
     370             : 
     371           0 :     snprintf( buf, bufsize, "EMC_TRU%02d_PEAKFINDER", iTRU );
     372           0 :     if((dcsVal = ReadDCSValue(dcsAliasMap, buf))){
     373           0 :       AliInfo(Form("saving value: %d\n", dcsVal->GetUInt()));
     374           0 :       truConfig->SetSELPF( dcsVal->GetUInt() );
     375           0 :     }
     376             : 
     377           0 :     snprintf( buf, bufsize, "EMC_TRU%02d_GLOBALTHRESH", iTRU );
     378           0 :     if((dcsVal = ReadDCSValue(dcsAliasMap, buf))){
     379           0 :       AliInfo(Form("saving value: %d\n", dcsVal->GetUInt()));
     380           0 :       truConfig->SetGTHRL0( dcsVal->GetUInt() );
     381           0 :     }
     382             : 
     383           0 :     snprintf( buf, bufsize, "EMC_TRU%02d_COSMTHRESH", iTRU );
     384           0 :     if((dcsVal = ReadDCSValue(dcsAliasMap, buf))){
     385           0 :       AliInfo(Form("saving value: %d\n", dcsVal->GetUInt()));
     386           0 :       truConfig->SetL0COSM( dcsVal->GetUInt() );
     387           0 :     }
     388             : 
     389           0 :     for( i = 0; i < 6; i++ ){
     390           0 :       snprintf( buf, bufsize, "EMC_TRU%02d_MASK%d", iTRU, i );
     391           0 :       if((dcsVal = ReadDCSValue(dcsAliasMap, buf))){
     392           0 :         AliInfo(Form("saving value: %d\n", dcsVal->GetUInt()));
     393           0 :         truConfig->SetMaskReg( dcsVal->GetUInt(), i );
     394           0 :       }
     395             :     }
     396             : 
     397           0 :   } // TRUs
     398           0 :   AliInfo(Form("TRU info retrieved.\n"));
     399             : 
     400             :   // STU
     401             :   AliEMCALTriggerSTUDCSConfig * stuConfig(NULL);
     402             :   TObjArray *dcsvalarray(NULL);
     403           0 :   const char *detectors[2] = {"EMC", "DMC"};
     404             :   Bool_t isEMCAL;
     405           0 :   for(const char **idet = detectors; idet < detectors + sizeof(detectors)/sizeof(const char *); idet++){
     406           0 :     Bool_t isEMCAL = !strcmp(*idet, "EMC");
     407           0 :     stuConfig = new AliEMCALTriggerSTUDCSConfig;
     408           0 :     for (i = 0; i < 3; i++) {
     409           0 :       for (int j = 0; j < 2; j++) {
     410           0 :         if((dcsVal = ReadDCSValue(dcsAliasMap, Form("%s_STU_G%c%d", *idet, i + 65, j)))){
     411           0 :           AliInfo(Form("saving value: %d\n", dcsVal->GetInt()));
     412           0 :           stuConfig->SetG(i, j, dcsVal->GetInt());
     413           0 :         }
     414           0 :         if((dcsVal = ReadDCSValue(dcsAliasMap, Form("%s_STU_J%c%d", *idet, i + 65, j)))){
     415           0 :           AliInfo(Form("saving value: %d\n", dcsVal->GetInt()));
     416           0 :           stuConfig->SetJ(i, j, dcsVal->GetInt());
     417           0 :         }
     418             :       }
     419             :     }
     420             : 
     421           0 :     if((dcsVal = ReadDCSValue(dcsAliasMap, Form("%s_STU_GETRAW", *idet)))){
     422           0 :       AliInfo(Form("saving value: %d\n", dcsVal->GetInt()));
     423           0 :       stuConfig->SetRawData(dcsVal->GetInt());
     424           0 :     }
     425           0 :     if((dcsVal = ReadDCSValue(dcsAliasMap, Form("%s_STU_REGION", *idet)))){
     426           0 :       AliInfo(Form("saving value: %d\n", dcsVal->GetInt()));
     427           0 :       stuConfig->SetRegion(dcsVal->GetInt());
     428           0 :     }
     429           0 :     if((dcsVal = ReadDCSValue(dcsAliasMap, Form("%s_STU_FWVERS", *idet)))){
     430           0 :       AliInfo(Form("saving value: %d\n", dcsVal->GetInt()));
     431           0 :       stuConfig->SetFw(dcsVal->GetInt());
     432           0 :     }
     433             : 
     434             :     AliDCSValue *errorcount(NULL);
     435           0 :     for(Int_t itru = 0; itru < 32; itru++){
     436             :       // TODO: Cross check - we might receive multiple data points
     437             :       // Currently a test procedure
     438           0 :       if(itru > 14 && !isEMCAL) continue;
     439             : 
     440           0 :       snprintf(buf, bufsize, "%s_STU_ERROR_COUNT_TRU%d", *idet, itru);
     441           0 :       AliInfo(Form("Reading %s", buf));
     442             : 
     443           0 :       TObjArray *dcsvals = (TObjArray *)dcsAliasMap->GetValue(buf);
     444           0 :       if(dcsvals){
     445           0 :         AliInfo(Form("Found %d objects in DCS values", dcsvals->GetEntries()));
     446           0 :         for(TIter eniter = TIter(dcsvals).Begin(); eniter != TIter::End(); ++eniter){
     447           0 :           errorcount = dynamic_cast<AliDCSValue *>(*eniter);
     448           0 :           stuConfig->SetTRUErrorCounts(itru, errorcount->GetTimeStamp(), errorcount->GetUInt());
     449           0 :           AliInfo(Form("Saving value %d", errorcount->GetUInt()));
     450             :         }
     451           0 :       } else {
     452           0 :         AliWarning(Form("%s not found in the DCS alias map", buf));
     453             :       }
     454           0 :     }
     455             : 
     456           0 :     if(!isEMCAL){
     457           0 :       for(Int_t iphos = 0; iphos < 4; iphos++) {
     458           0 :         if((dcsVal = ReadDCSValue(dcsAliasMap, Form("%s_STU_PHOS_scale%d", *idet, iphos)))){
     459           0 :           AliInfo(Form("saving value: %d\n", dcsVal->GetInt()));
     460           0 :           stuConfig->SetPHOSScale(iphos, dcsVal->GetInt());
     461           0 :         }
     462             :       }
     463           0 :     }
     464             : 
     465           0 :     trigConfig->SetSTUObj(stuConfig, isEMCAL);
     466             :   }
     467             : 
     468           0 :   AliInfo(Form("STU info retrieved."));
     469             : 
     470             : 
     471             :   // save the objects
     472           0 :   AliCDBMetaData metaData;
     473           0 :   metaData.SetBeamPeriod(0);
     474           0 :   metaData.SetResponsible(kMetaResponsible);
     475           0 :   metaData.SetComment(kMetaComment); 
     476             : 
     477             :   UInt_t result=0;
     478           0 :   Bool_t storeOK = Store("Calib", "Trigger", trigConfig, &metaData, 0, kFALSE);
     479           0 :   if ( !storeOK )  result=1;
     480           0 :   AliInfo(Form("TRU info stored. result %d\n", result));
     481             : 
     482             :   return result;
     483           0 : }
     484             : 
     485             : //______________________________________________________________________________________________
     486             : UInt_t AliEMCALPreprocessor::ExtractPedestals(Int_t sourceFXS)
     487             : {
     488             :   //  Read pedestal file from file exchange server
     489             :   //  Only store if new pedestal info is available
     490             :   //
     491             :   UInt_t result=0;
     492             : 
     493           0 :   AliCaloCalibPedestal *calibPed = new AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal);
     494           0 :   calibPed->Init();
     495             : 
     496           0 :   TList* list = GetFileSources(sourceFXS,"pedestals");
     497           0 :   if (list && list->GetEntries()>0) {
     498             : 
     499             :     //  loop through all files from LDCs
     500             : 
     501             :     int changes = 0;
     502             :     UInt_t index = 0;
     503           0 :     while (list->At(index)!=NULL) {
     504           0 :       TObjString* fileNameEntry = (TObjString*) list->At(index);
     505           0 :       if (fileNameEntry!=NULL) {
     506           0 :         TString fileName = GetFile(sourceFXS, "pedestals",
     507           0 :             fileNameEntry->GetString().Data());
     508           0 :         TFile *f = TFile::Open(fileName);
     509           0 :         if (!f) {
     510           0 :           Log ("Error opening pedestal file.");
     511             :           result = kReturnCodeNoObject;
     512           0 :           break;
     513             :         }
     514           0 :         AliCaloCalibPedestal *calPed;
     515           0 :         f->GetObject("emcCalibPedestal",calPed);
     516           0 :         if ( !calPed ) {
     517           0 :           Log ("No pedestal calibration object in file.");
     518             :           result = kReturnCodeNoObject;
     519           0 :           break;
     520             :         }
     521           0 :         if ( calPed->GetNEvents()>0 && calPed->GetNChanFills()>0 ) {
     522             :           // add info for the modules available in the present file
     523           0 :           Bool_t status = calibPed->AddInfo(calPed);
     524           0 :           if (status) { changes++; }
     525           0 :         }
     526             : 
     527           0 :         delete calPed; 
     528           0 :         f->Close();
     529           0 :       }
     530           0 :       index++;
     531           0 :     }  // while(list)
     532             : 
     533             :     //
     534             :     //  Store updated pedestal entry to OCDB
     535             :     //
     536           0 :     if (changes>0) {
     537           0 :       AliCDBMetaData metaData;
     538           0 :       metaData.SetBeamPeriod(0);
     539           0 :       metaData.SetResponsible(kMetaResponsible);
     540           0 :       metaData.SetComment(kMetaComment); 
     541             : 
     542           0 :       Bool_t storeOK = StoreReferenceData("Calib", "Pedestals", calibPed, &metaData);
     543           0 :       if ( !storeOK ) result++;
     544           0 :     }
     545           0 :   } 
     546             :   else {
     547           0 :     Log ("Error: no entries in input file list!");
     548             :     result = kReturnCodeNoEntries;
     549             :   }
     550             : 
     551           0 :   return result;
     552           0 : }
     553             : 
     554             : //______________________________________________________________________________________________
     555             : UInt_t AliEMCALPreprocessor::ExtractSignal(Int_t sourceFXS)
     556             : { //  Read signal file from file exchange server
     557             :   //  Only store if new signal info is available
     558             :   //
     559             :   UInt_t result=0;
     560           0 :   AliCaloCalibSignal *calibSig = new AliCaloCalibSignal(AliCaloCalibSignal::kEmCal); 
     561             : 
     562           0 :   TList* list = GetFileSources(sourceFXS,"signal");
     563           0 :   if (list && list->GetEntries()>0) {
     564             : 
     565             :     //  loop through all files from LDCs
     566             : 
     567             :     int changes = 0;
     568             :     UInt_t index = 0;
     569           0 :     while (list->At(index)!=NULL) {
     570           0 :       TObjString* fileNameEntry = (TObjString*) list->At(index);
     571           0 :       if (fileNameEntry!=NULL) {
     572           0 :         TString fileName = GetFile(sourceFXS, "signal",
     573           0 :             fileNameEntry->GetString().Data());
     574           0 :         TFile *f = TFile::Open(fileName);
     575           0 :         if (!f) {
     576           0 :           Log ("Error opening signal file.");
     577             :           result = kReturnCodeNoObject;
     578           0 :           break;
     579             :         }
     580           0 :         AliCaloCalibSignal *calSig;
     581           0 :         f->GetObject("emcCalibSignal",calSig);
     582           0 :         if ( !calSig ) {
     583           0 :           Log ("No signal calibration object in file.");
     584             :           result = kReturnCodeNoObject;
     585           0 :           break;
     586             :         }
     587           0 :         if ( calSig->GetNEvents()>0 ) {
     588             :           // add info for the modules available in the present file
     589           0 :           Bool_t status = calibSig->AddInfo(calSig);
     590           0 :           if (status) { changes++; }
     591           0 :         }
     592             : 
     593           0 :         delete calSig; 
     594           0 :         f->Close();
     595           0 :       }
     596           0 :       index++;
     597           0 :     }  // while(list)
     598             : 
     599             :     //
     600             :     //  Store updated signal entry to OCDB
     601             :     //
     602           0 :     if (changes>0) {
     603           0 :       AliCDBMetaData metaData;
     604           0 :       metaData.SetBeamPeriod(0);
     605           0 :       metaData.SetResponsible(kMetaResponsible);
     606           0 :       metaData.SetComment(kMetaComment); 
     607             : 
     608           0 :       Bool_t storeOK = Store("Calib", "LED", calibSig, &metaData, 0, kFALSE);
     609           0 :       if ( !storeOK ) result++;
     610           0 :     }
     611           0 :   } 
     612             :   else {
     613           0 :     Log ("Error: no entries in input file list!");
     614             :     result = kReturnCodeNoEntries;
     615             :   }
     616             : 
     617           0 :   return result;
     618           0 : }
     619             : 
     620             : AliDCSValue *AliEMCALPreprocessor::ReadDCSValue(const TMap *values, const char *valname){
     621             :   AliDCSValue *dcsVal(NULL);
     622           0 :   TObjArray * dcsvalarray = (TObjArray*)values->GetValue(valname);
     623           0 :   if (!dcsvalarray) {
     624           0 :     AliWarning(Form("%s alias not found!", valname));
     625           0 :     return NULL;
     626             :   } else {
     627           0 :     AliInfo(Form("%s has %d entries", valname, dcsvalarray->GetEntries()));
     628           0 :     if (dcsvalarray->GetEntries() > 0) {
     629           0 :       return (AliDCSValue*)dcsvalarray->At(dcsvalarray->GetEntries() - 1);
     630             :     } else {
     631           0 :       AliWarning(Form("%s has no entry!", valname));
     632           0 :       return NULL;
     633             :     }
     634             :   }
     635           0 : }

Generated by: LCOV version 1.11