MCH HV subprocessor (Laurent)
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Feb 2007 17:15:48 +0000 (17:15 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Feb 2007 17:15:48 +0000 (17:15 +0000)
MUON/AliMUONHVSubprocessor.cxx [new file with mode: 0644]
MUON/AliMUONHVSubprocessor.h [new file with mode: 0644]

diff --git a/MUON/AliMUONHVSubprocessor.cxx b/MUON/AliMUONHVSubprocessor.cxx
new file mode 100644 (file)
index 0000000..c9e5fc2
--- /dev/null
@@ -0,0 +1,157 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+/// $Id$
+/// \class AliMUONHVSubprocessor
+///
+/// A subprocessor to read HV values for one run
+///
+/// It simply creates a copy of the dcsAliasMap w/o information
+/// 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 "AliCDBMetaData.h"
+#include "AliLog.h"
+
+#include "Riostream.h"
+#include "TMap.h"
+#include "TObjString.h"
+
+/// \cond CLASSIMP
+ClassImp(AliMUONHVSubprocessor)
+/// \endcond
+
+//_____________________________________________________________________________
+AliMUONHVSubprocessor::AliMUONHVSubprocessor(AliMUONPreprocessor* master)
+: AliMUONVSubprocessor(master,
+                       "HV",
+                       "Get MUON Tracker HV values from DCS")
+{
+  /// ctor
+}
+
+//_____________________________________________________________________________
+AliMUONHVSubprocessor::~AliMUONHVSubprocessor()
+{
+  /// dtor
+}
+
+//_____________________________________________________________________________
+void 
+AliMUONHVSubprocessor::Initialize(Int_t run, 
+                                  UInt_t startTime, UInt_t endTime)
+{
+  /// Initialisation for a given run
+  AliDebug(1,Form("run %d startTime %ld endtime %ld",run,startTime,endTime));
+}
+
+//_____________________________________________________________________________
+UInt_t
+AliMUONHVSubprocessor::Process(TMap* dcsAliasMap)
+{
+  /// Make another alias map from dcsAliasMap, considering only MUON TRK aliases.
+
+  TMap hv;
+  hv.SetOwner(kTRUE);
+  
+  AliMUONHVNamer hvNamer;
+
+  AliMpDEIterator deIt;
+
+  deIt.First();
+  
+  TObjArray aliases;
+  aliases.SetOwner(kTRUE);
+  
+  // we first generate a list of expected MCH DCS aliases we'll then look for
+  
+  while ( !deIt.IsDone() )
+  {
+    Int_t detElemId = deIt.CurrentDEId();
+    
+    switch ( AliMpDEManager::GetStationType(detElemId) )
+    {
+      case AliMp::kStation1:
+      case AliMp::kStation2:
+      {
+        for ( int i = 0; i <3; ++i)
+        {
+          aliases.Add(new TObjString(hvNamer.DCSHVChannelName(detElemId,i)));
+        }
+      }
+      break;
+      case AliMp::kStation345:
+      {
+        aliases.Add(new TObjString(hvNamer.DCSHVChannelName(detElemId)));
+        for ( int i = 0; i < hvNamer.NumberOfPCBs(detElemId); ++i)
+        {
+          aliases.Add(new TObjString(hvNamer.DCSHVSwitchName(detElemId,i)));
+        }
+      }
+      break;
+      default:
+        break;
+    };
+
+    deIt.Next();
+  }
+
+  TIter next(&aliases);
+  TObjString* alias;
+  
+  while ( ( alias = static_cast<TObjString*>(next()) ) ) 
+  {
+    TString aliasName(alias->String());
+    TPair* hvPair = static_cast<TPair*>(dcsAliasMap->FindObject(aliasName.Data()));
+    if (!hvPair)
+    {
+      AliError(Form("Did not find expected alias (%s)",aliasName.Data()));
+    }
+    else
+    {
+      TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
+      if (!values)
+      {
+        AliError(Form("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)
+        hv.Add(new TObjString(aliasName.Data()),values);
+      }
+    }
+  }
+  
+  AliCDBMetaData metaData;
+  metaData.SetBeamPeriod(0);
+  metaData.SetResponsible("MUON TRK");
+  metaData.SetComment("Computed by AliMUONHVSubprocessor $Id$");
+  
+  Bool_t validToInfinity(kFALSE);
+  
+  UInt_t result = Master()->Store("Calib","HV",&hv,&metaData,0,validToInfinity);
+  
+  return result;
+}
+
diff --git a/MUON/AliMUONHVSubprocessor.h b/MUON/AliMUONHVSubprocessor.h
new file mode 100644 (file)
index 0000000..29b2e3d
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef ALIMUONHVSUBPROCESSOR_H
+#define ALIMUONHVSUBPROCESSOR_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+/// \ingroup shuttle
+/// \class AliMUONHVSubprocessor
+/// \brief A subprocessor to read HV values for one run
+/// \author Laurent Aphecetche
+
+#ifndef ALIMUONVSUBPROCESSOR_H
+#  include "AliMUONVSubprocessor.h"
+#endif
+
+class AliMUONHVSubprocessor : public AliMUONVSubprocessor
+{
+public:
+  AliMUONHVSubprocessor(AliMUONPreprocessor* master);
+  virtual ~AliMUONHVSubprocessor();
+  
+  virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
+  virtual UInt_t Process(TMap* dcsAliasMap);
+
+private:
+  AliMUONHVSubprocessor(const AliMUONHVSubprocessor&);
+  AliMUONHVSubprocessor& operator=(const AliMUONHVSubprocessor&);
+  
+  ClassDef(AliMUONHVSubprocessor,1) // Shuttle Subprocessor for MUON TRK HV
+};
+
+#endif