]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALPreprocessor.cxx
add getter for the array with digits and initialization inside, just for analysis...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALPreprocessor.cxx
index a035ee957769c66ad37c587c2c94bccce8779451..1396c43fe077de8502ee6fee329c96404f885115 100644 (file)
 #include "AliShuttleInterface.h"
 #include "AliEMCALPreprocessor.h"
 #include "AliLog.h"
+#include "AliDCSValue.h"
 #include "AliCDBMetaData.h"
+#include "AliEMCALTriggerTRUDCSConfig.h"
+#include "AliEMCALTriggerDCSConfig.h"
 #include "AliCaloCalibPedestal.h"
 #include "AliCaloCalibSignal.h"
 #include "AliEMCALSensorTempArray.h"
@@ -57,6 +60,8 @@ const int kReturnCodeNoInfo = 9;
 const int kReturnCodeNoObject = 2;
 const int kReturnCodeNoEntries = 1;
 
+const int kNTRU = 32; // From 2012; 10 + 2/3 SuperModules (SM) * 3 TRU per SM
+
 ClassImp(AliEMCALPreprocessor)
   
 //_______________________________________________________________________________________
@@ -81,7 +86,6 @@ AliEMCALPreprocessor::AliEMCALPreprocessor(AliShuttleInterface* shuttle):
   // define run types to be processed
   AddRunType(kPedestalRunType);
   AddRunType(kPhysicsRunType);
-  AddRunType(kStandAloneRunType);
 }
 
 //______________________________________________________________________________________________
@@ -168,26 +172,38 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
   UInt_t dcsResult=0;
   if (errorHandling == "OFF" ) {
     if (!dcsAliasMap) dcsResult = kReturnCodeNoEntries;
-    if (dcsAliasMap->GetEntries() == 0 ) dcsResult = kReturnCodeNoEntries;  
+    else if (dcsAliasMap->GetEntries() == 0 ) dcsResult = kReturnCodeNoEntries;  
     status = new TParameter<int>("dcsResult",dcsResult);
     resultArray->Add(status);
   } 
   else {
     if (!dcsAliasMap) return kReturnCodeNoInfo;
-    if (dcsAliasMap->GetEntries() == 0 ) 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" ) {
+  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:
@@ -199,7 +215,7 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
   
   // PEDESTAL ENTRIES:
   
-  if (runType == kPedestalRunType || runType == kStandAloneRunType) {
+  if ( runType == kPedestalRunType ) {
     Int_t numSources = 1;
     Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ, AliShuttleInterface::kHLT} ;
     TString source = fConfEnv->GetValue("Pedestal","DAQ");
@@ -208,15 +224,15 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
       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;
+        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;
+        pedestalResult = ExtractPedestals(pedestalSource[i]);
+        if ( pedestalResult == 0 ) break;
       }
       result += pedestalResult;
       status = new TParameter<int>("pedestalResult",pedestalResult);
@@ -225,8 +241,7 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
   }
   
   // SIGNAL/LED ENTRIES:
-  
-  if( runType == kStandAloneRunType ) {
+  if( runType == kPhysicsRunType ) {
     Int_t numSources = 1;
     Int_t signalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
     TString source = fConfEnv->GetValue("Signal","DAQ");
@@ -235,15 +250,15 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
       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;
+        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;
+        signalResult = ExtractSignal(signalSource[i]);
+        if ( signalResult == 0 ) break;
       }
       result += signalResult;
       status = new TParameter<int>("signalResult",signalResult);
@@ -258,9 +273,11 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
     metaData.SetBeamPeriod(0);
     metaData.SetResponsible(kMetaResponsible);
     metaData.SetComment("Preprocessor AliEMCAL status.");
-    Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
+    Bool_t storeOK = Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
     resultArray->Delete();
-    return 0;
+    result = 0;
+    if ( !storeOK )  result=1;
+    return result;
   } 
   else { 
     return result;
@@ -269,8 +286,7 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
 }
 //______________________________________________________________________________________________
 UInt_t AliEMCALPreprocessor::MapTemperature(TMap* dcsAliasMap)
-{
-  // extract DCS temperature maps. Perform fits to save space
+{ // extract DCS temperature maps. Perform fits to save space
   UInt_t result=0;
 
   TMap *map = fTemp->ExtractDCS(dcsAliasMap);
@@ -300,21 +316,171 @@ UInt_t AliEMCALPreprocessor::MapTemperature(TMap* dcsAliasMap)
     
     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
+  AliInfo(Form("Get TRU info from DCS DPs.\n"));
+  Int_t i, iTRU;
+  const Int_t bufsize = 1000;
+  char buf[bufsize];
+
+  AliDCSValue *dcsVal;
+  TObjArray *arrL0ALGSEL, *arrPEAKFINDER, *arrGLOBALTHRESH, *arrCOSMTHRESH;
+  TObjArray *arrMASK[6];
+
+  // overall object to hold STU and DCS config info
+  // DS comment: for now only holds TRU info, i.e. only partially filled
+  // (STU info only in raw data header; unfortunately not also picked up via DCS DPs)
+  AliEMCALTriggerDCSConfig *trigConfig = new AliEMCALTriggerDCSConfig();
+  // allocate space for TRU objects
+  TClonesArray *truArr = new TClonesArray("AliEMCALTriggerTRUDCSConfig", kNTRU);
+  for( iTRU = 0; iTRU < kNTRU; iTRU++){
+    new((*truArr)[iTRU]) AliEMCALTriggerTRUDCSConfig();
+  }
+  trigConfig->SetTRUArr(truArr);
+
+  // loop through all TRUs
+  bool debug = true; // debug flag for AliInfo printouts for each TRU
+  for( iTRU = 0; iTRU < kNTRU; iTRU++){
+    if (debug) AliInfo( Form("iTRU %d \n", iTRU) );
+    // get the shuttled values
+    snprintf( buf, bufsize, "EMC_TRU%02d_L0ALGSEL", iTRU );
+    arrL0ALGSEL = (TObjArray*) dcsAliasMap->GetValue( buf );
+    snprintf( buf, bufsize, "EMC_TRU%02d_PEAKFINDER", iTRU );
+    arrPEAKFINDER = (TObjArray*) dcsAliasMap->GetValue( buf );
+    snprintf( buf, bufsize, "EMC_TRU%02d_GLOBALTHRESH", iTRU );
+    arrGLOBALTHRESH = (TObjArray*) dcsAliasMap->GetValue( buf );
+    snprintf( buf, bufsize, "EMC_TRU%02d_COSMTHRESH", iTRU );
+    arrCOSMTHRESH = (TObjArray*) dcsAliasMap->GetValue( buf );
+    
+    for( i = 0; i < 6; i++ ){
+      snprintf( buf, bufsize, "EMC_TRU%02d_MASK%d", iTRU, i );
+      arrMASK[i] = (TObjArray*) dcsAliasMap->GetValue( buf );
+    }
+    
+    // fill the objects
+    AliEMCALTriggerTRUDCSConfig* truConfig = trigConfig->GetTRUDCSConfig(iTRU);
+    if( ! truConfig ){
+      AliWarning( Form("EMC TRU%02d config not retrieved!\n", iTRU ));
+      continue;
+    }
+
+    // get last entries. fill the TRU object
+    if( ! arrL0ALGSEL ){
+      AliWarning( Form("EMC_TRU%02d_L0ALGSEL alias not found!\n", iTRU ));
+    }
+    else{
+      if (debug) AliInfo( Form("arrL0ALGSEL has %d entries \n", arrL0ALGSEL->GetEntries()) );
+      if ( arrL0ALGSEL->GetEntries() > 0 ) {
+       dcsVal = (AliDCSValue *) arrL0ALGSEL->At( arrL0ALGSEL->GetEntries() - 1 );
+       if (dcsVal) {
+               truConfig->SetL0SEL( dcsVal->GetUInt() );
+    if (debug) AliInfo( Form("saving value: %u\n", dcsVal->GetUInt()) );
+       }
+      }
+      else
+      AliWarning( Form("EMC_TRU%02d_L0ALGSEL has no entries!\n", iTRU ));
+    }
+
+    if( ! arrPEAKFINDER ){
+      AliWarning( Form("EMC_TRU%02d_PEAKFINDER alias not found!\n", iTRU ));
+    }
+    else{
+      if (debug) AliInfo( Form("arrPEAKFINDER has %d entries \n", arrPEAKFINDER->GetEntries()) );
+      if ( arrPEAKFINDER->GetEntries() > 0 ) {
+       dcsVal = (AliDCSValue *) arrPEAKFINDER->At( arrPEAKFINDER->GetEntries() - 1 );
+       if (dcsVal){
+               truConfig->SetSELPF( dcsVal->GetUInt() );
+    if (debug) AliInfo( Form("saving value: %u\n", dcsVal->GetUInt()) );
+       }
+      }
+      else
+      AliWarning( Form("EMC_TRU%02d_PEAKFINDER has no entries!\n", iTRU ));
+    }
+
+    if( ! arrGLOBALTHRESH ){
+      AliWarning( Form("EMC_TRU%02d_GLOBALTHRESH alias not found!\n", iTRU ));
+    }
+    else{
+      if (debug) AliInfo( Form("arrGLOBALTHRESH has %d entries \n", arrGLOBALTHRESH->GetEntries()) );
+      if ( arrGLOBALTHRESH->GetEntries() > 0 ) {
+       dcsVal = (AliDCSValue *) arrGLOBALTHRESH->At( arrGLOBALTHRESH->GetEntries() - 1 );
+       if (dcsVal){
+               truConfig->SetGTHRL0( dcsVal->GetUInt() );
+    if (debug) AliInfo( Form("saving value: %u\n", dcsVal->GetUInt()) );
+       }
+      }
+      else
+      AliWarning( Form("EMC_TRU%02d_GLOBALTHRESH has no entries!\n", iTRU ));
+    }
+
+    if( ! arrCOSMTHRESH ){
+      AliWarning( Form("EMC_TRU%02d_COSMTHRESH alias not found!\n", iTRU ));
+    }
+    else{
+      if (debug) AliInfo( Form("arrCOSMTHRESH has %d entries \n", arrCOSMTHRESH->GetEntries()) );
+      if ( arrCOSMTHRESH->GetEntries() > 0 ) {
+       dcsVal = (AliDCSValue *) arrCOSMTHRESH->At( arrCOSMTHRESH->GetEntries() - 1 );
+       if (dcsVal){
+               truConfig->SetL0COSM( dcsVal->GetUInt() );
+    if (debug) AliInfo( Form("saving value: %u\n", dcsVal->GetUInt()) );
+       }
+      }
+      else
+      AliWarning( Form("EMC_TRU%02d_COSMTHRESH has no entries!\n", iTRU ));
+    }
+    
+    for( i = 0; i < 6; i++ ){
+      if( ! arrMASK[i] ){
+       AliWarning( Form("EMC_TRU%02d_MASK%d alias not found!\n", iTRU, i ));
+      }
+      else{
+       if (debug) AliInfo( Form("arrMASK[%d] has %d entries \n", i, arrMASK[i]->GetEntries()) );
+       if ( arrMASK[i]->GetEntries() > 0 ) {
+         dcsVal = (AliDCSValue *) arrMASK[i]->At( arrMASK[i]->GetEntries() - 1 );
+         if (dcsVal){
+                       truConfig->SetMaskReg( dcsVal->GetUInt(), i );
+    if (debug) AliInfo( Form("saving value: %u\n", dcsVal->GetUInt()) );
+       }
+       }
+      else
+      AliWarning( Form("EMC_TRU%02d_MASK%d has no entries!\n", iTRU, i ));
+      }
+    }
+    
+  } // TRUs
+  AliInfo(Form("TRU info retrieved.\n"));
+  // save the objects
+  AliCDBMetaData metaData;
+  metaData.SetBeamPeriod(0);
+  metaData.SetResponsible(kMetaResponsible);
+  metaData.SetComment(kMetaComment); 
+      
+  UInt_t result=0;
+  Bool_t storeOK = Store("Calib", "Trigger", trigConfig, &metaData, 0, kFALSE);
+  if ( !storeOK )  result=1;
+  AliInfo(Form("TRU info stored. result %d\n", result));
+
+  return result;
+}
+
 //______________________________________________________________________________________________
 UInt_t AliEMCALPreprocessor::ExtractPedestals(Int_t sourceFXS)
 {
-  UInt_t result=0;
-  //
   //  Read pedestal file from file exchange server
   //  Only store if new pedestal info is available
   //
+  UInt_t result=0;
+
   AliCaloCalibPedestal *calibPed = new AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal);
-  
+  calibPed->Init();
+
   TList* list = GetFileSources(sourceFXS,"pedestals");
   if (list && list->GetEntries()>0) {
     
@@ -375,12 +541,10 @@ UInt_t AliEMCALPreprocessor::ExtractPedestals(Int_t sourceFXS)
 
 //______________________________________________________________________________________________
 UInt_t AliEMCALPreprocessor::ExtractSignal(Int_t sourceFXS)
-{
-  UInt_t result=0;
-  //
-  //  Read signal file from file exchange server
+{ //  Read signal file from file exchange server
   //  Only store if new signal info is available
   //
+  UInt_t result=0;
   AliCaloCalibSignal *calibSig = new AliCaloCalibSignal(AliCaloCalibSignal::kEmCal); 
   
   TList* list = GetFileSources(sourceFXS,"signal");