Fixed memory leak
[u/mrichter/AliRoot.git] / MUON / AliMUONHVSubprocessor.cxx
index 471b994..116d2e7 100644 (file)
@@ -13,7 +13,9 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/// $Id$
+// $Id$
+
+//-----------------------------------------------------------------------------
 /// \class AliMUONHVSubprocessor
 ///
 /// A subprocessor to read HV values for one run
 /// from the MUON TRK, and dumps this copy into the CDB
 ///
 /// \author Laurent Aphecetche, Subatech
+//-----------------------------------------------------------------------------
 
 #include "AliMUONHVSubprocessor.h"
-#include "AliMUONHVNamer.h"
 #include "AliMUONPreprocessor.h"
 
 #include "AliMpDEIterator.h"
 #include "AliMpDEManager.h"
+#include "AliMpDCSNamer.h"
 
 #include "AliCDBMetaData.h"
 #include "AliLog.h"
@@ -42,10 +45,10 @@ ClassImp(AliMUONHVSubprocessor)
 /// \endcond
 
 //_____________________________________________________________________________
-AliMUONHVSubprocessor::AliMUONHVSubprocessor(AliMUONPreprocessor* master)
+AliMUONHVSubprocessor::AliMUONHVSubprocessor(AliMUONPreprocessor* master, Bool_t includeHVcurrents)
 : AliMUONVSubprocessor(master,
                        "HV",
-                       "Get MUON Tracker HV values from DCS")
+                       "Get MUON Tracker HV values from DCS"), fIncludeHVCurrents(includeHVcurrents)
 {
   /// ctor
 }
@@ -65,7 +68,7 @@ AliMUONHVSubprocessor::Process(TMap* dcsAliasMap)
   TMap hv;
   hv.SetOwner(kTRUE);
   
-  AliMUONHVNamer hvNamer;
+  AliMpDCSNamer hvNamer("TRACKER");
 
   AliMpDEIterator deIt;
 
@@ -82,21 +85,28 @@ AliMUONHVSubprocessor::Process(TMap* dcsAliasMap)
     
     switch ( AliMpDEManager::GetStationType(detElemId) )
     {
-      case AliMp::kStation1:
-      case AliMp::kStation2:
+      case AliMp::kStation12:
       {
         for ( int i = 0; i <3; ++i)
         {
-          aliases.Add(new TObjString(hvNamer.DCSHVChannelName(detElemId,i)));
+          aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,i)));
+          if ( fIncludeHVCurrents )
+          {
+            aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,i,AliMpDCSNamer::kDCSI)));
+          }
         }
       }
       break;
       case AliMp::kStation345:
       {
-        aliases.Add(new TObjString(hvNamer.DCSHVChannelName(detElemId)));
+        aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId)));
+        if ( fIncludeHVCurrents )
+        {
+          aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,0,AliMpDCSNamer::kDCSI)));
+        }
         for ( int i = 0; i < hvNamer.NumberOfPCBs(detElemId); ++i)
         {
-          aliases.Add(new TObjString(hvNamer.DCSHVSwitchName(detElemId,i)));
+          aliases.Add(new TObjString(hvNamer.DCSSwitchAliasName(detElemId,i)));
         }
       }
       break;
@@ -113,31 +123,64 @@ AliMUONHVSubprocessor::Process(TMap* dcsAliasMap)
   Int_t aliasNotFound(0);
   Int_t valueNotFound(0);
   
+  TObjArray temporaryOut; // due to a bug in PVSS some iMon aliases cause problem
+  // we remove them for the moment.
+  temporaryOut.SetOwner(kTRUE);
+  
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber06Left/Slat10.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber06Left/Slat11.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber06Left/Slat12.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber07Left/Slat10.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber07Left/Slat11.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber07Left/Slat12.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber08Left/Slat10.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber08Left/Slat11.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber08Left/Slat12.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber09Left/Slat10.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber09Left/Slat11.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber09Left/Slat12.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber06Right/Slat10.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber06Right/Slat11.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber06Right/Slat12.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber07Right/Slat10.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber07Right/Slat11.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber07Right/Slat12.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber08Right/Slat10.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber08Right/Slat11.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber08Right/Slat12.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber09Right/Slat10.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber09Right/Slat11.actual.iMon"));
+  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber09Right/Slat12.actual.iMon"));
+  
   while ( ( alias = static_cast<TObjString*>(next()) ) ) 
   {
     TString aliasName(alias->String());
+    
+    if ( temporaryOut.FindObject(alias->String().Data() ) )
+    {
+      // skip problematic aliases
+      continue;
+    }
+    
     TPair* hvPair = static_cast<TPair*>(dcsAliasMap->FindObject(aliasName.Data()));
     if (!hvPair)
     {
       ++aliasNotFound;
-//      Master()->Log(Form("WARNING Did not find expected alias (%s)",aliasName.Data()));
     }
     else
     {
-      TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
+      kNoAliases = kFALSE;
+      TObjArray* values = static_cast<TObjArray*>(hvPair->Value()->Clone());
       if (!values)
       {
         ++valueNotFound;
-//        Master()->Log(Form("WARNING Could not get values for alias (%s)",aliasName.Data()));
       }
       else
       {
-        //FIXME : should insure here that values are only the ones within run
-        //limits (startTime<timestamp<endTime)
+        RemoveValuesOutsideRun(values);
         hv.Add(new TObjString(aliasName.Data()),values);
       }
     }
-    kNoAliases = kFALSE;
   }
   
   if ( kNoAliases ) 
@@ -165,8 +208,8 @@ AliMUONHVSubprocessor::Process(TMap* dcsAliasMap)
   
   Bool_t validToInfinity(kFALSE);
   
-  UInt_t result = Master()->Store("Calib","HV",&hv,&metaData,0,validToInfinity);
+  Bool_t result = Master()->Store("Calib","HV",&hv,&metaData,0,validToInfinity);
   
-  return result;
+  return ( result != kTRUE); // return 0 if everything is ok
 }