extending unit test: adding check for magnetic field setup from the external interface
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 Nov 2009 01:23:57 +0000 (01:23 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 Nov 2009 01:23:57 +0000 (01:23 +0000)
HLT/BASE/interface/test/AliHLTTest.h [new file with mode: 0644]
HLT/BASE/interface/test/AliHLTTestProcessor.cxx
HLT/BASE/interface/test/AliHLTTestProcessor.h
HLT/BASE/interface/test/Makefile.am
HLT/BASE/interface/test/testAliHLTExternalInterface.C

diff --git a/HLT/BASE/interface/test/AliHLTTest.h b/HLT/BASE/interface/test/AliHLTTest.h
new file mode 100644 (file)
index 0000000..7e3b198
--- /dev/null
@@ -0,0 +1,37 @@
+//-*- Mode: C++ -*-
+// $Id$
+
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+ *                  for The ALICE HLT Project.                            *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+/** @file   AliHLTTest.h
+    @author Matthias Richter
+    @date   
+    @brief  Abstract interface for the AliHLTTestProcessor test methods
+ */
+
+class AliHLTTest
+{
+public:
+  AliHLTTest() {};
+  virtual ~AliHLTTest() {};
+
+  virtual bool CheckRunNo(unsigned runNo) const = 0;
+  virtual bool CheckChainId(const char* chainId) const = 0;
+  virtual bool CheckDataType(const char* id, const char* origin) const = 0;
+  virtual bool CheckMagneticField(float bz) = 0;
+
+};
index c3ecbc6..347669a 100644 (file)
@@ -23,6 +23,8 @@
  */
 
 #include "AliHLTTestProcessor.h"
+#include "TMath.h"
+#include "AliTracker.h"
 
 AliHLTTestProcessor::AliHLTTestProcessor()
   : AliHLTProcessor()
@@ -63,6 +65,11 @@ int AliHLTTestProcessor::DoEvent( const AliHLTComponentEventData& /*evtData*/, A
     return -ENODEV;
   }
 
+  if (!CheckMagneticField(-5)) {
+    HLTError("initialization of magnetic field failed");
+    return -EFAULT;
+  }  
+
   HLTInfo("processing event");
   for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
         pBlock!=NULL; 
@@ -96,3 +103,10 @@ bool AliHLTTestProcessor::CheckDataType(const char* id, const char* origin) cons
   }
   return false;
 }
+
+bool AliHLTTestProcessor::CheckMagneticField(float bz)
+{
+  if (TMath::Abs(AliTracker::GetBz()-bz)<0.01) return true;
+  HLTError("mismatch in magnetic field: %f, expecting %f", AliTracker::GetBz(), bz);
+  return false;
+}
index 74bb069..1516bac 100644 (file)
@@ -25,8 +25,9 @@
 
 #include <vector>
 #include "AliHLTProcessor.h"
+#include "AliHLTTest.h"
 
-class AliHLTTestProcessor : public AliHLTProcessor
+class AliHLTTestProcessor : public AliHLTProcessor, public AliHLTTest
 {
 public:
   AliHLTTestProcessor();
@@ -47,6 +48,7 @@ public:
   bool CheckRunNo(unsigned runNo) const;
   bool CheckChainId(const char* chainId) const;
   bool CheckDataType(const char* id, const char* origin) const;
+  bool CheckMagneticField(float bz);
 
 private:
   int DoInit( int argc, const char** argv );
index a317260..8e681af 100644 (file)
@@ -3,7 +3,8 @@
 
 AM_CPPFLAGS                    = -I$(top_srcdir)/BASE \
                                  -I$(top_srcdir)/BASE/interface \
-                                 -DBASE_PATH=\"$(top_builddir)/BASE/interface/test/\"
+                                 -DBASE_PATH=\"$(top_builddir)/BASE/interface/test/\" \
+                                 -I$(ALICE_ROOT)/STEER
 
 EXTRA_DIST                     = 
 
@@ -22,7 +23,10 @@ testAliHLTExternalInterface_SOURCES  = testAliHLTExternalInterface.C \
 # Maybe an issue with the RTLD_NOW used in the dlopen from the
 # AliHLTComponentHandler
 testAliHLTExternalInterface_LDADD = $(top_builddir)/BASE/libHLTbase.la
-
+testAliHLTExternalInterface_LDFLAGS  = -L@ROOTLIBDIR@ \
+                                       @ROOTLIBS@ \
+                                       @ALIROOT_LDFLAGS@ \
+                                       @ALIROOT_LIBS@
 
 libAliHLTTest_la_SOURCES = AliHLTTestProcessor.cxx AliHLTTestAgent.cxx
 libAliHLTTest_la_LIBADD         =
index c71049e..996362c 100644 (file)
 
 #include "AliHLTDataTypes.h"
 #include "AliHLTExternalInterface.h"
+#include "AliHLTTest.h"
+#include "AliCDBManager.h"
+#include "AliCDBPath.h"
+#include "AliCDBId.h"
+#include "AliCDBMetaData.h"
+#include "AliCDBRunRange.h"
+#include "AliGRPObject.h"
 #include <cstring>
 #include <cstdlib>
 #include <dlfcn.h>
@@ -55,10 +62,44 @@ void* AllocMemory( void* param, unsigned long size )
   return new AliHLTUInt8_t[size];
 }
 
+int CreateGRP() {
+  AliCDBManager* man = AliCDBManager::Instance();
+  if (!man) {
+    cerr << "can not get AliCDBManager" << endl;
+    return -1;
+  }
+  TString storage;
+  man->SetDefaultStorage("local://$PWD");
+
+  // generate GRP object
+  AliGRPObject* grpObj=new AliGRPObject;
+  float cmsEnergy=14000;
+  grpObj->SetBeamEnergy(cmsEnergy/0.120); // LHC convention
+  grpObj->SetBeamType("p-p");
+  grpObj->SetLHCLuminosity(0,(AliGRPObject::Stats)0);
+  grpObj->SetBeamIntensity(0,(AliGRPObject::Stats)0);
+  grpObj->SetL3Current(30000,(AliGRPObject::Stats)0);
+  grpObj->SetDipoleCurrent(0,(AliGRPObject::Stats)0);  
+  grpObj->SetL3Polarity(1);  
+  grpObj->SetDipolePolarity(0);
+  grpObj->SetPolarityConventionLHC();                    // LHC convention +/+ current -> -/- field main components
+
+  // write object to OCDB
+  AliCDBPath cdbPath("GRP/GRP/Data");
+  AliCDBId cdbId(cdbPath, 0, AliCDBRunRange::Infinity());
+  AliCDBMetaData cdbMetaData;
+  cdbMetaData.SetResponsible("ALICE HLT");
+  cdbMetaData.SetComment("Automatically produced GRP entry (AliHLTSimulation) for the magnetic field initialization of HLT components");
+  man->Put(grpObj, cdbId, &cdbMetaData);
+  return 0;
+}
+
 int main(int /*argc*/, const char** /*argv*/)
 {
   int iResult=0;
 
+  if ((iResult=CreateGRP()) < 0) return iResult;
+
   string libraryPath=gBasePath;
   libraryPath+="/";
   libraryPath+=ALIHLTANALYSIS_INTERFACE_LIBRARY;
@@ -219,6 +260,7 @@ int main(int /*argc*/, const char** /*argv*/)
 
   // Matthias 2009-05-29: here the check whether the setup is really
   // working needs to be implemented, postponing it for the moment
+//   AliHLTTest* pCheck=reinterpret_cast<AliHLTTest*>(handle);
 //   if (!pCheck->CheckRunNo(0xbeef)) {
 //     cerr << "error: propagation of run number failed " << hex << gRunNo << " vs. 0xbeef" << endl;
 //     return -1;
@@ -228,6 +270,10 @@ int main(int /*argc*/, const char** /*argv*/)
 //   if (!pCheck->CheckChainId("test")) {
 //     cerr << "propagation of chain id failed: '" << gChainId << "' vs. test" << endl;
 //     return -1;
+//   }
+//   if (!pCheck->CheckMagneticField(-5)) {
+//     cerr << "initialization of magnetic field failed" << endl;
+//     return -1;
 //   }
 
   AliHLTExtFctProcessEvent fctProcessEvent=(AliHLTExtFctProcessEvent)fctGetSystemCall("int AliHLTAnalysisProcessEvent(AliHLTComponentHandle,const AliHLTComponentEventData*,const AliHLTComponentBlockData*,AliHLTComponentTriggerData*,AliHLTUInt8_t*,AliHLTUInt32_t*,AliHLTUInt32_t*,AliHLTComponentBlockData**,AliHLTComponentEventDoneData**)");