]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALPreprocessor.cxx
Coding rule violations corrected.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALPreprocessor.cxx
index 081ce1400c0c1d4af06817a988e09836a273bbb1..013b88093e00c0444f728e69a822e895ea1cc7f3 100644 (file)
@@ -193,14 +193,16 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
     status = new TParameter<int>("tempResult",tempResult);
     resultArray->Add(status);
   }
-  // Trigger configuration processing
+  // Trigger configuration processing: only for Physics runs
   TString triggerConf = fConfEnv->GetValue("Trigger","ON");
   triggerConf.ToUpper();
-  if (triggerConf != "OFF" && dcsAliasMap ) {
-    UInt_t triggerResult = MapTriggerConfig(dcsAliasMap);
-    result=triggerResult;
-    status = new TParameter<int>("triggerResult",triggerResult);
-    resultArray->Add(status);
+  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
@@ -314,6 +316,7 @@ 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;
@@ -322,8 +325,10 @@ UInt_t AliEMCALPreprocessor::MapTemperature(TMap* dcsAliasMap)
 //______________________________________________________________________________________________
 UInt_t AliEMCALPreprocessor::MapTriggerConfig(TMap* dcsAliasMap)
 { // extract DCS trigger info
+  AliInfo(Form("Get TRU info from DCS DPs.\n"));
   Int_t i, iTRU;
-  char buf[100];
+  const Int_t bufsize = 1000;
+  char buf[bufsize];
 
   AliDCSValue *dcsVal;
   TObjArray *arrL0ALGSEL, *arrPEAKFINDER, *arrGLOBALTHRESH, *arrCOSMTHRESH;
@@ -333,78 +338,136 @@ UInt_t AliEMCALPreprocessor::MapTriggerConfig(TMap* dcsAliasMap)
   // 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
-    sprintf( buf, "EMC_TRU%02d_L0ALGSEL", iTRU );
+    snprintf( buf, bufsize, "EMC_TRU%02d_L0ALGSEL", iTRU );
     arrL0ALGSEL = (TObjArray*) dcsAliasMap->GetValue( buf );
-    sprintf( buf, "EMC_TRU%02d_PEAKFINDER", iTRU );
+    snprintf( buf, bufsize, "EMC_TRU%02d_PEAKFINDER", iTRU );
     arrPEAKFINDER = (TObjArray*) dcsAliasMap->GetValue( buf );
-    sprintf( buf, "EMC_TRU%02d_GLOBALTHRESH", iTRU );
+    snprintf( buf, bufsize, "EMC_TRU%02d_GLOBALTHRESH", iTRU );
     arrGLOBALTHRESH = (TObjArray*) dcsAliasMap->GetValue( buf );
-    sprintf( buf, "EMC_TRU%02d_COSMTHRESH", iTRU );
+    snprintf( buf, bufsize, "EMC_TRU%02d_COSMTHRESH", iTRU );
     arrCOSMTHRESH = (TObjArray*) dcsAliasMap->GetValue( buf );
     
     for( i = 0; i < 6; i++ ){
-      sprintf( buf, "EMC_TRU%02d_MASK%d", iTRU, 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 DCS TRU%02d L0ALGSEL alias not found!\n", iTRU ));
+      AliWarning( Form("EMC_TRU%02d_L0ALGSEL alias not found!\n", iTRU ));
     }
     else{
-      dcsVal = (AliDCSValue *) arrL0ALGSEL->At( arrL0ALGSEL->GetEntries() - 1 );
-      truConfig->SetL0SEL( dcsVal->GetUInt() );
+      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 DCS TRU%02d PEAKFINDER alias not found!\n", iTRU ));
+      AliWarning( Form("EMC_TRU%02d_PEAKFINDER alias not found!\n", iTRU ));
     }
     else{
-      dcsVal = (AliDCSValue *) arrPEAKFINDER->At( arrPEAKFINDER->GetEntries() - 1 );
-      truConfig->SetSELPF( dcsVal->GetUInt() );
+      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 DCS TRU%02d GLOBALTHRESH alias not found!\n", iTRU ));
+      AliWarning( Form("EMC_TRU%02d_GLOBALTHRESH alias not found!\n", iTRU ));
     }
     else{
-      dcsVal = (AliDCSValue *) arrGLOBALTHRESH->At( arrGLOBALTHRESH->GetEntries() - 1 );
-      truConfig->SetGTHRL0( dcsVal->GetUInt() );
+      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 DCS TRU%02d COSMTHRESH alias not found!\n", iTRU ));
+      AliWarning( Form("EMC_TRU%02d_COSMTHRESH alias not found!\n", iTRU ));
     }
     else{
-      dcsVal = (AliDCSValue *) arrCOSMTHRESH->At( arrCOSMTHRESH->GetEntries() - 1 );
-      truConfig->SetL0COSM( dcsVal->GetUInt() );
+      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 DCS TRU%02d MASK%d alias not found!\n", iTRU, i ));
+       AliWarning( Form("EMC_TRU%02d_MASK%d alias not found!\n", iTRU, i ));
       }
       else{
-       dcsVal = (AliDCSValue *) arrMASK[i]->At( arrMASK[i]->GetEntries() - 1 );
-       truConfig->SetMaskReg( dcsVal->GetUInt(), i );
+       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); 
       
-  Bool_t retCode = Store("Calib", "LED", trigConfig, &metaData, 0, kFALSE);
-  return retCode;
+  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;
 }
 
 //______________________________________________________________________________________________