]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Refactoring code to pull common functionality for loading CDB configuration entries...
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 18 Jul 2008 13:38:48 +0000 (13:38 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 18 Jul 2008 13:38:48 +0000 (13:38 +0000)
Fixed bug in treatment of run number in AliHLTMUONHitReconstructor.
Adding functionality to AliHLTMUONHitReconstructor for loading of DC cut parameter form CDB or command line. Also added a delaysetup option to delay loading of CDB entries to the Start-of-Run event.

12 files changed:
HLT/ConfigMUON/HitReconstructor/Run0_999999999_v0_s0.root [new file with mode: 0644]
HLT/MUON/AliHLTMUONProcessor.cxx
HLT/MUON/AliHLTMUONProcessor.h
HLT/MUON/OnlineAnalysis/AliHLTMUONDecisionComponent.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructor.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructor.h
HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.h
HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructor.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructorComponent.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructorComponent.h
HLT/MUON/macros/CreateDefaultCDBEntries.C

diff --git a/HLT/ConfigMUON/HitReconstructor/Run0_999999999_v0_s0.root b/HLT/ConfigMUON/HitReconstructor/Run0_999999999_v0_s0.root
new file mode 100644 (file)
index 0000000..5177baf
Binary files /dev/null and b/HLT/ConfigMUON/HitReconstructor/Run0_999999999_v0_s0.root differ
index 0ac023dca592829f5e802037bfbd8b30c282d8cc..cc65cf941923ea6a61ff6e0a60d078281d7baac3 100644 (file)
 #include "AliHLTMUONProcessor.h"
 #include "AliCDBManager.h"
 #include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
 #include "AliMpCDB.h"
 #include "AliMpDDLStore.h"
 #include "AliMpDEStore.h"
+#include "TMap.h"
+#include "TObjString.h"
+#include "TString.h"
 
 ClassImp(AliHLTMUONProcessor)
 
 
-int AliHLTMUONProcessor::FetchMappingStores(
+int AliHLTMUONProcessor::SetCDBPathAndRunNo(
                const char* cdbPath, Int_t run, bool useDefault
        ) const
 {
-       /// Fetches the DDL and detector element store objects for MUON mapping.
+       /// Sets the CDB path and run number to read from.
        /// \param cdbPath  The CDB path to use. If set to NULL and the path has
        ///      not been set in the CDB manager then the default path
        ///      "local://$ALICE_ROOT" is used if the 'useDefault' flag is also true.
        /// \param run  The run number to use. If set to -1 and the run number has
        ///      not been set in the CDB manager then a value of zero is used if
        ///      the 'useDefault' flag is also true.
-       /// \param useDefault  If set to true then a default CDB path and run number
+       /// \param useDefault  If set to true then a default CDB path and/or run number
        ///      is used if they have not been set and 'cdbPath' == NULL or
-       ///      'run' == NULL.
-       /// \return Zero if the object could be loaded. Otherwise an error code is
-       ///      returned, which is compatible with the HLT framework.
-       /// \note AliMpDDLStore::Instance() and AliMpDEStore::Instance() must be used
-       ///      to fetch the objects after this method returns a code equal to zero.
-       
-       Bool_t warn = kFALSE;
-       
-       // Check if the objects are already loaded. If they are then exit early,
-       // otherwise we need to try load the objects.
-       if (AliMpDDLStore::Instance(warn) != NULL and AliMpDEStore::Instance(warn) != NULL)
-               return 0;
+       ///      'run' == -1.
+       /// \return Zero if the object could be loaded. Otherwise an error code,
+       ///      compatible with the HLT framework, is returned.
        
        const char* defaultPath = "local://$ALICE_ROOT";
        Int_t defaultRun = 0;
@@ -73,27 +68,13 @@ int AliHLTMUONProcessor::FetchMappingStores(
        }
        
        // Setup the CDB path.
-       const char* cdbPathUsed = "unknown (not set)";
        if (cdbPath != NULL)
        {
                cdbManager->SetDefaultStorage(cdbPath);
-               cdbPathUsed = cdbPath;
        }
-       else
+       else if (not cdbManager->IsDefaultStorageSet() and useDefault)
        {
-               AliCDBStorage* store = cdbManager->GetDefaultStorage();
-               if (store == NULL)
-               {
-                       if (useDefault)
-                       {
-                               cdbManager->SetDefaultStorage(defaultPath);
-                               cdbPathUsed = defaultPath;
-                       }
-               }
-               else
-               {
-                       cdbPathUsed = store->GetURI().Data();
-               }
+               cdbManager->SetDefaultStorage(defaultPath);
        }
        
        // Now setup the run number.
@@ -105,6 +86,37 @@ int AliHLTMUONProcessor::FetchMappingStores(
        {
                if (useDefault) cdbManager->SetRun(defaultRun);
        }
+       
+       return 0;
+}
+
+
+int AliHLTMUONProcessor::FetchMappingStores() const
+{
+       /// Fetches the DDL and detector element store objects for MUON mapping.
+       /// \return Zero if the objects could be loaded. Otherwise an error code,
+       ///      which is compatible with the HLT framework, is returned.
+       /// \note AliMpDDLStore::Instance() and AliMpDEStore::Instance() must be used
+       ///      to fetch the objects after this method returns a code equal to zero.
+       
+       Bool_t warn = kFALSE;
+       
+       // Check if the objects are already loaded. If they are then exit early,
+       // otherwise we need to try load the objects.
+       if (AliMpDDLStore::Instance(warn) != NULL and AliMpDEStore::Instance(warn) != NULL)
+               return 0;
+       
+       AliCDBManager* cdbManager = AliCDBManager::Instance();
+       if (cdbManager == NULL)
+       {
+               HLTError("CDB manager instance does not exist.");
+               return -EIO;
+       }
+       
+       const char* cdbPathUsed = "unknown (not set)";
+       AliCDBStorage* store = cdbManager->GetDefaultStorage();
+       if (store != NULL) cdbPathUsed = store->GetURI().Data();
+       
        Int_t runUsed = cdbManager->GetRun();
        
        // Now we can try load the DDL and DE store objects.
@@ -126,3 +138,266 @@ int AliHLTMUONProcessor::FetchMappingStores(
        return 0;
 }
 
+
+int AliHLTMUONProcessor::FetchTMapFromCDB(const char* pathToEntry, TMap*& map) const
+{
+       /// Fetches a TMap object from the CDB.
+       /// [in] \param pathToEntry  The relative path to the entry in the CDB to fetch.
+       /// [out] \param map  This will be filled with the TMap object found if
+       ///      a successful status code is returned. Otherwise it will be unchanged.
+       /// \return Zero if the object could be found. Otherwise an error code,
+       ///      which is compatible with the HLT framework, is returned.
+       
+       assert(AliCDBManager::Instance() != NULL);
+       
+       AliCDBEntry* entry = AliCDBManager::Instance()->Get(pathToEntry);
+       if (entry == NULL)
+       {
+               HLTError("Could not get the CDB entry for \"%s\".", pathToEntry);
+               return -EIO;
+       }
+       
+       TObject* obj = entry->GetObject();
+       if (obj == NULL)
+       {
+               HLTError("Configuration object for \"%s\" is missing.", pathToEntry);
+               return -ENOENT;
+       }
+       
+       if (obj->IsA() != TMap::Class())
+       {
+               HLTError("Wrong type for configuration object in \"%s\". Found a %s but we need a TMap.",
+                       pathToEntry, obj->ClassName()
+               );
+               return -EPROTO;
+       }
+       map = dynamic_cast<TMap*>(obj);
+       
+       return 0;
+}
+
+
+int AliHLTMUONProcessor::GetValueFromTMap(
+               TMap* map, const char* paramName, TString& value,
+               const char* pathToEntry, const char* prettyName
+       ) const
+{
+       /// Tries to find the string value associated with a certain parameter in a TMap.
+       /// [in] \param map  The TMap object to search in.
+       /// [in] \param paramName  The name of the parameter to search for.
+       /// [out] \param value  Will be filled with the object found.
+       /// [in] \param pathToEntry  The relative path to the entry in the CDB.
+       ///      Used when printing error messages. If set to NULL then a string of
+       ///      "(unknown)" is used. (default is NULL).
+       /// [in] \param prettyName  Should be the name of the parameter which will
+       ///      be used when printing error messages. If this is set to NULL then
+       ///      the paramName will be used instead (default is NULL).
+       /// \return Zero if the object could be found. Otherwise an error code,
+       ///      which is compatible with the HLT framework, is returned.
+       
+       if (pathToEntry == NULL) pathToEntry = "(unknown)";
+       if (prettyName == NULL) prettyName = paramName;
+       
+       TPair* pair = static_cast<TPair*>(map->FindObject(paramName));
+       if (pair == NULL)
+       {
+               HLTError("Configuration object for \"%s\" does not contain the %s value.",
+                       pathToEntry, prettyName
+               );
+               return -ENOENT;
+       }
+       TObject* valueObj = pair->Value();
+       if (valueObj->IsA() != TObjString::Class())
+       {
+               HLTError("The %s parameter found in configuration object \"%s\""
+                       " is not a TObjString. Found an object of type %s instead.",
+                       prettyName, pathToEntry, valueObj->ClassName()
+               );
+               return -EPROTO;
+       }
+       value = dynamic_cast<TObjString*>(valueObj)->GetString();
+       
+       return 0;
+}
+
+
+int AliHLTMUONProcessor::GetIntFromTMap(
+               TMap* map, const char* paramName, Int_t& value,
+               const char* pathToEntry, const char* prettyName
+       ) const
+{
+       /// Tries to find a certain parameter in the TMap object and convert it to
+       /// an integer value.
+       /// [in] \param map  The TMap object to search in.
+       /// [in] \param paramName  The name of the parameter to search for.
+       /// [out] \param value  Will be filled with the integer value for the parameter,
+       ///       if it was found and it was an integer value.
+       /// [in] \param pathToEntry  The relative path to the entry in the CDB.
+       ///      Used when printing error messages. If set to NULL then a string of
+       ///      "(unknown)" is used. (default is NULL).
+       /// [in] \param prettyName  Should be the name of the parameter which will
+       ///      be used when printing error messages. If this is set to NULL then
+       ///      the paramName will be used instead (default is NULL).
+       /// \return Zero if the object could be found and is valid. Otherwise an
+       ///       error code, which is compatible with the HLT framework, is returned.
+       
+       if (pathToEntry == NULL) pathToEntry = "(unknown)";
+       if (prettyName == NULL) prettyName = paramName;
+       
+       TString valueStr;
+       int result = GetValueFromTMap(map, paramName, valueStr, prettyName);
+       if (result != 0) return result;
+       
+       if (not valueStr.IsDigit())
+       {
+               HLTError("The %s parameter found in configuration object \"%s\""
+                       "is not a valid integer number string; found \"%s\".",
+                       prettyName, pathToEntry, valueStr.Data()
+               );
+               return -EPROTO;
+       }
+       value = valueStr.Atoi();
+       
+       return 0;
+}
+
+
+int AliHLTMUONProcessor::GetPositiveIntFromTMap(
+               TMap* map, const char* paramName, Int_t& value,
+               const char* pathToEntry, const char* prettyName
+       ) const
+{
+       /// Tries to find a certain parameter in the TMap object and convert it to
+       /// a positive integer value.
+       /// [in] \param map  The TMap object to search in.
+       /// [in] \param paramName  The name of the parameter to search for.
+       /// [out] \param value  Will be filled with the integer value for the parameter,
+       ///       if it was found and it was a positive integer value.
+       /// [in] \param pathToEntry  The relative path to the entry in the CDB.
+       ///      Used when printing error messages. If set to NULL then a string of
+       ///      "(unknown)" is used. (default is NULL).
+       /// [in] \param prettyName  Should be the name of the parameter which will
+       ///      be used when printing error messages. If this is set to NULL then
+       ///      the paramName will be used instead (default is NULL).
+       /// \return Zero if the object could be found and is valid. Otherwise an
+       ///       error code, which is compatible with the HLT framework, is returned.
+       
+       if (pathToEntry == NULL) pathToEntry = "(unknown)";
+       if (prettyName == NULL) prettyName = paramName;
+       
+       TString valueStr;
+       int result = GetValueFromTMap(map, paramName, valueStr, prettyName);
+       if (result != 0) return result;
+       
+       if (not valueStr.IsDigit())
+       {
+               HLTError("The %s parameter found in configuration object \"%s\""
+                       "is not a valid integer number string; found \"%s\".",
+                       prettyName, pathToEntry, valueStr.Data()
+               );
+               return -EPROTO;
+       }
+       Int_t val = valueStr.Atoi();
+       if (val < 0)
+       {
+               HLTError("The %s parameter found in configuration object \"%s\""
+                       "is not a positive integer number; found \"%d\".",
+                       prettyName, pathToEntry, val
+               );
+               return -EPROTO;
+       }
+       value = val;
+       
+       return 0;
+}
+
+
+int AliHLTMUONProcessor::GetFloatFromTMap(
+               TMap* map, const char* paramName, Double_t& value,
+               const char* pathToEntry, const char* prettyName
+       ) const
+{
+       /// Tries to find a certain parameter in the TMap object and convert it to
+       /// an floating point value.
+       /// [in] \param map  The TMap object to search in.
+       /// [in] \param paramName  The name of the parameter to search for.
+       /// [out] \param value  Will be filled with the floating point value for the
+       ///       parameter, if it was found and it was a floating point value.
+       /// [in] \param pathToEntry  The relative path to the entry in the CDB.
+       ///      Used when printing error messages. If set to NULL then a string of
+       ///      "(unknown)" is used. (default is NULL).
+       /// [in] \param prettyName  Should be the name of the parameter which will
+       ///      be used when printing error messages. If this is set to NULL then
+       ///      the paramName will be used instead (default is NULL).
+       /// \return Zero if the object could be found and is valid. Otherwise an
+       ///       error code, which is compatible with the HLT framework, is returned.
+       
+       if (pathToEntry == NULL) pathToEntry = "(unknown)";
+       if (prettyName == NULL) prettyName = paramName;
+       
+       TString valueStr;
+       int result = GetValueFromTMap(map, paramName, valueStr, prettyName);
+       if (result != 0) return result;
+       
+       if (not valueStr.IsFloat())
+       {
+               HLTError("The %s parameter found in configuration object \"%s\""
+                       "is not a valid floating point number string; found \"%s\".",
+                       prettyName, pathToEntry, valueStr.Data()
+               );
+               return -EPROTO;
+       }
+       value = valueStr.Atof();
+       
+       return 0;
+}
+
+
+int AliHLTMUONProcessor::GetPositiveFloatFromTMap(
+               TMap* map, const char* paramName, Double_t& value,
+               const char* pathToEntry, const char* prettyName
+       ) const
+{
+       /// Tries to find a certain parameter in the TMap object and convert it to
+       /// an positive floating point value.
+       /// [in] \param map  The TMap object to search in.
+       /// [in] \param paramName  The name of the parameter to search for.
+       /// [out] \param value  Will be filled with the floating point value for the
+       ///       parameter, if it was found and it was a positive floating point value.
+       /// [in] \param pathToEntry  The relative path to the entry in the CDB.
+       ///      Used when printing error messages. If set to NULL then a string of
+       ///      "(unknown)" is used. (default is NULL).
+       /// [in] \param prettyName  Should be the name of the parameter which will
+       ///      be used when printing error messages. If this is set to NULL then
+       ///      the paramName will be used instead (default is NULL).
+       /// \return Zero if the object could be found and is valid. Otherwise an
+       ///       error code, which is compatible with the HLT framework, is returned.
+       
+       if (pathToEntry == NULL) pathToEntry = "(unknown)";
+       if (prettyName == NULL) prettyName = paramName;
+       
+       TString valueStr;
+       int result = GetValueFromTMap(map, paramName, valueStr, prettyName);
+       if (result != 0) return result;
+       
+       if (not valueStr.IsFloat())
+       {
+               HLTError("The %s parameter found in configuration object \"%s\""
+                       "is not a valid floating point number string; found \"%s\".",
+                       prettyName, pathToEntry, valueStr.Data()
+               );
+               return -EPROTO;
+       }
+       Double_t val = valueStr.Atof();
+       if (val < 0)
+       {
+               HLTError("The %s parameter found in configuration object \"%s\""
+                       "is not a positive floating point number; found \"%d\".",
+                       prettyName, pathToEntry, val
+               );
+               return -EPROTO;
+       }
+       value = val;
+       
+       return 0;
+}
index a5546eb827ca559b6266d74f08e718371b929722..422ec28db4ea5dd9fef27d34e319f034a72ee756 100644 (file)
@@ -17,6 +17,8 @@
 #include "AliHLTMUONDataBlockReader.h"
 #include "AliHLTMUONUtils.h"
 
+class TMap;
+
 /**
  * @class AliHLTMUONProcessor
  * This component class is an abstract base class for dHLT components.
@@ -135,24 +137,128 @@ protected:
        }
        
        /**
-        * Fetches the DDL and detector element store objects for MUON mapping.
+        * Sets the CDB path and run number to read from.
         * \param cdbPath  The CDB path to use. If set to NULL and the path has
         *      not been set in the CDB manager then the default path
         *      "local://$ALICE_ROOT" is used if the 'useDefault' flag is also true.
         * \param run  The run number to use. If set to -1 and the run number has
         *      not been set in the CDB manager then a value of zero is used if
         *      the 'useDefault' flag is also true.
-        * \param useDefault  If set to true then a default CDB path and run number
+        * \param useDefault  If set to true then a default CDB path and/or run number
         *      is used if they have not been set and 'cdbPath' == NULL or
-        *      'run' == NULL.
-        * \return Zero if the object could be loaded. Otherwise an error code is
-        *      returned, which is compatible with the HLT framework.
+        *      'run' == -1. (false by default).
+        * \return Zero if the object could be loaded. Otherwise an error code,
+        *      compatible with the HLT framework, is returned.
+        */
+       int SetCDBPathAndRunNo(
+                       const char* cdbPath, Int_t run, bool useDefault = false
+               ) const;
+       
+       /**
+        * Fetches the DDL and detector element store objects for MUON mapping.
+        * \return Zero if the objects could be loaded. Otherwise an error code,
+        *      which is compatible with the HLT framework, is returned.
         * \note AliMpDDLStore::Instance() and AliMpDEStore::Instance() must be used
         *      to fetch the objects after this method returns a code equal to zero.
         */
-       int FetchMappingStores(
-                       const char* cdbPath = NULL, Int_t run = -1,
-                       bool useDefault = true
+       int FetchMappingStores() const;
+       
+       /**
+        * Fetches a TMap object from the CDB.
+        * [in] \param pathToEntry  The relative path to the entry in the CDB to fetch.
+        * [out] \param map  This will be filled with the TMap object found if
+        *      a successful status code is returned. Otherwise it will be unchanged.
+        * \return Zero if the object could be found. Otherwise an error code,
+        *      which is compatible with the HLT framework, is returned.
+        */
+       int FetchTMapFromCDB(const char* pathToEntry, TMap*& map) const;
+       
+       /**
+        * Tries to find the string value associated with a certain parameter in a TMap.
+        * [in] \param map  The TMap object to search in.
+        * [in] \param paramName  The name of the parameter to search for.
+        * [out] \param value  Will be filled with the object found.
+        * [in] \param prettyName  Should be the name of the parameter which will
+        *      be used when printing error messages. If this is set to NULL then
+        *      the paramName will be used instead (default is NULL).
+        * \return Zero if the object could be found. Otherwise an error code,
+        *      which is compatible with the HLT framework, is returned.
+        */
+       int GetValueFromTMap(
+                       TMap* map, const char* paramName, TString& value,
+                       const char* pathToEntry = NULL, const char* prettyName = NULL
+               ) const;
+       
+       /**
+        * Tries to find a certain parameter in the TMap object and convert it to
+        * an integer value.
+        * [in] \param map  The TMap object to search in.
+        * [in] \param paramName  The name of the parameter to search for.
+        * [out] \param value  Will be filled with the integer value for the parameter,
+        *       if it was found and it was an integer value.
+        * [in] \param prettyName  Should be the name of the parameter which will
+        *      be used when printing error messages. If this is set to NULL then
+        *      the paramName will be used instead (default is NULL).
+        * \return Zero if the object could be found and is valid. Otherwise an
+        *       error code, which is compatible with the HLT framework, is returned.
+        */
+       int GetIntFromTMap(
+                       TMap* map, const char* paramName, Int_t& value,
+                       const char* pathToEntry = NULL, const char* prettyName = NULL
+               ) const;
+       
+       /**
+        * Tries to find a certain parameter in the TMap object and convert it to
+        * a positive integer value.
+        * [in] \param map  The TMap object to search in.
+        * [in] \param paramName  The name of the parameter to search for.
+        * [out] \param value  Will be filled with the integer value for the parameter,
+        *       if it was found and it was a positive integer value.
+        * [in] \param prettyName  Should be the name of the parameter which will
+        *      be used when printing error messages. If this is set to NULL then
+        *      the paramName will be used instead (default is NULL).
+        * \return Zero if the object could be found and is valid. Otherwise an
+        *       error code, which is compatible with the HLT framework, is returned.
+        */
+       int GetPositiveIntFromTMap(
+                       TMap* map, const char* paramName, Int_t& value,
+                       const char* pathToEntry = NULL, const char* prettyName = NULL
+               ) const;
+       
+       /**
+        * Tries to find a certain parameter in the TMap object and convert it to
+        * an floating point value.
+        * [in] \param map  The TMap object to search in.
+        * [in] \param paramName  The name of the parameter to search for.
+        * [out] \param value  Will be filled with the floating point value for the
+        *       parameter, if it was found and it was a floating point value.
+        * [in] \param prettyName  Should be the name of the parameter which will
+        *      be used when printing error messages. If this is set to NULL then
+        *      the paramName will be used instead (default is NULL).
+        * \return Zero if the object could be found and is valid. Otherwise an
+        *       error code, which is compatible with the HLT framework, is returned.
+        */
+       int GetFloatFromTMap(
+                       TMap* map, const char* paramName, Double_t& value,
+                       const char* pathToEntry = NULL, const char* prettyName = NULL
+               ) const;
+       
+       /**
+        * Tries to find a certain parameter in the TMap object and convert it to
+        * an positive floating point value.
+        * [in] \param map  The TMap object to search in.
+        * [in] \param paramName  The name of the parameter to search for.
+        * [out] \param value  Will be filled with the floating point value for the
+        *       parameter, if it was found and it was a positive floating point value.
+        * [in] \param prettyName  Should be the name of the parameter which will
+        *      be used when printing error messages. If this is set to NULL then
+        *      the paramName will be used instead (default is NULL).
+        * \return Zero if the object could be found and is valid. Otherwise an
+        *       error code, which is compatible with the HLT framework, is returned.
+        */
+       int GetPositiveFloatFromTMap(
+                       TMap* map, const char* paramName, Double_t& value,
+                       const char* pathToEntry = NULL, const char* prettyName = NULL
                ) const;
        
 private:
index aee12a43e38d8085cb099260dc7cd0612a649131..a9ee2717a8cda18416b319cc987fc2bb5bb7b98a 100644 (file)
@@ -162,6 +162,13 @@ int AliHLTMUONDecisionComponent::DoInit(int argc, const char** argv)
        {
                if (strcmp( argv[i], "-lowptcut" ) == 0)
                {
+                       if (lowPtCutSet)
+                       {
+                               HLTWarning("Low pT cut parameter was already specified."
+                                       " Will replace previous value given by -lowptcut."
+                               );
+                       }
+                       
                        if (argc <= i+1)
                        {
                                HLTError("The value for the low pT cut was not specified.");
@@ -184,6 +191,13 @@ int AliHLTMUONDecisionComponent::DoInit(int argc, const char** argv)
                
                if (strcmp( argv[i], "-highptcut" ) == 0)
                {
+                       if (lowPtCutSet)
+                       {
+                               HLTWarning("High pT cut parameter was already specified."
+                                       " Will replace previous value given by -highptcut."
+                               );
+                       }
+                       
                        if (argc <= i+1)
                        {
                                HLTError("The value for the high pT cut was not specified.");
@@ -206,6 +220,13 @@ int AliHLTMUONDecisionComponent::DoInit(int argc, const char** argv)
                
                if (strcmp( argv[i], "-lowmasscut" ) == 0)
                {
+                       if (lowPtCutSet)
+                       {
+                               HLTWarning("Low invariant mass cut parameter was already specified."
+                                       " Will replace previous value given by -lowmasscut."
+                               );
+                       }
+                       
                        if (argc <= i+1)
                        {
                                HLTError("The value for the low invariant mass cut was not specified.");
@@ -228,6 +249,13 @@ int AliHLTMUONDecisionComponent::DoInit(int argc, const char** argv)
                
                if (strcmp( argv[i], "-highmasscut" ) == 0)
                {
+                       if (lowPtCutSet)
+                       {
+                               HLTWarning("High invariant mass cut parameter was already specified."
+                                       " Will replace previous value given by -highmasscut."
+                               );
+                       }
+                       
                        if (argc <= i+1)
                        {
                                HLTError("The value for the high invariant mass cut was not specified.");
@@ -472,6 +500,7 @@ int AliHLTMUONDecisionComponent::ReadConfigFromCDB(
        )
 {
        /// Reads the cut parameters from the CDB.
+       /// \param path Indicates the partial (or relative) path to the CDB entry.
        
        assert(AliCDBManager::Instance() != NULL);
        
@@ -479,151 +508,40 @@ int AliHLTMUONDecisionComponent::ReadConfigFromCDB(
        if (path != NULL)
                pathToEntry = path;
        
-       AliCDBEntry* entry = AliCDBManager::Instance()->Get(pathToEntry);
-       if (entry == NULL)
-       {
-               HLTError("Could not get the CDB entry for \"%s\".", pathToEntry);
-               return -EIO;
-       }
-       
-       TObject* obj = entry->GetObject();
-       if (obj == NULL)
-       {
-               HLTError("Configuration object for \"%s\" is missing.", pathToEntry);
-               return -ENOENT;
-       }
-       
-       if (obj->IsA() != TMap::Class())
-       {
-               HLTError("Wrong type for configuration object in \"%s\". Found a %s but we need a TMap.",
-                       pathToEntry, obj->ClassName()
-               );
-               return -EPROTO;
-       }
-       TMap* map = dynamic_cast<TMap*>(obj);
+       TMap* map = NULL;
+       int result = FetchTMapFromCDB(pathToEntry, map);
+       if (result != 0) return result;
        
        if (setLowPtCut)
        {
-               TPair* pair = static_cast<TPair*>(map->FindObject("lowptcut"));
-               if (pair == NULL)
-               {
-                       HLTError("Configuration object for \"%s\" does not contain the low pT cut value.",
-                               pathToEntry
-                       );
-                       return -ENOENT;
-               }
-               TObject* valueObj = pair->Value();
-               if (valueObj->IsA() != TObjString::Class())
-               {
-                       HLTError("The low pT cut parameter found in configuration object \"%s\""
-                               " is not a TObjString. Found an object of type %s instead.",
-                               pathToEntry, valueObj->ClassName()
-                       );
-                       return -EPROTO;
-               }
-               TString value = dynamic_cast<TObjString*>(valueObj)->GetString();
-               if (not value.IsFloat())
-               {
-                       HLTError("The low pT cut parameter found in configuration object \"%s\""
-                               "is not a floating point string; found \"%s\".",
-                               pathToEntry, value.Data()
-                       );
-                       return -EPROTO;
-               }
-               fLowPtCut = (AliHLTFloat32_t) value.Atof();
+               Double_t value = 0;
+               result = GetFloatFromTMap(map, "lowptcut", value, pathToEntry, "low pT cut");
+               if (result != 0) return result;
+               fLowPtCut = (AliHLTFloat32_t) value;
        }
        
        if (setHighPtCut)
        {
-               TPair* pair = static_cast<TPair*>(map->FindObject("highptcut"));
-               if (pair == NULL)
-               {
-                       HLTError("Configuration object for \"%s\" does not contain the high pT cut value.",
-                               pathToEntry
-                       );
-                       return -ENOENT;
-               }
-               TObject* valueObj = pair->Value();
-               if (valueObj->IsA() != TObjString::Class())
-               {
-                       HLTError("The high pT cut parameter found in configuration object \"%s\""
-                               " is not a TObjString. Found an object of type %s instead.",
-                               pathToEntry, valueObj->ClassName()
-                       );
-                       return -EPROTO;
-               }
-               TString value = dynamic_cast<TObjString*>(valueObj)->GetString();
-               if (not value.IsFloat())
-               {
-                       HLTError("The high pT cut parameter found in configuration object \"%s\""
-                               "is not a floating point string; found \"%s\".",
-                               pathToEntry, value.Data()
-                       );
-                       return -EPROTO;
-               }
-               fHighPtCut = (AliHLTFloat32_t) value.Atof();
+               Double_t value = 0;
+               result = GetFloatFromTMap(map, "highptcut", value, pathToEntry, "high pT cut");
+               if (result != 0) return result;
+               fHighPtCut = (AliHLTFloat32_t) value;
        }
        
        if (setLowMassCut)
        {
-               TPair* pair = static_cast<TPair*>(map->FindObject("lowmasscut"));
-               if (pair == NULL)
-               {
-                       HLTError("Configuration object for \"%s\" does not contain the low invariant mass cut value.",
-                               pathToEntry
-                       );
-                       return -ENOENT;
-               }
-               TObject* valueObj = pair->Value();
-               if (valueObj->IsA() != TObjString::Class())
-               {
-                       HLTError("The low invariant mass cut parameter found in configuration object \"%s\""
-                               " is not a TObjString. Found an object of type %s instead.",
-                               pathToEntry, valueObj->ClassName()
-                       );
-                       return -EPROTO;
-               }
-               TString value = dynamic_cast<TObjString*>(valueObj)->GetString();
-               if (not value.IsFloat())
-               {
-                       HLTError("The low invariant mass cut parameter found in configuration object \"%s\""
-                               "is not a floating point string; found \"%s\".",
-                               pathToEntry, value.Data()
-                       );
-                       return -EPROTO;
-               }
-               fLowMassCut = (AliHLTFloat32_t) value.Atof();
+               Double_t value = 0;
+               result = GetFloatFromTMap(map, "lowmasscut", value, pathToEntry, "low invariant mass cut");
+               if (result != 0) return result;
+               fLowMassCut = (AliHLTFloat32_t) value;
        }
        
        if (setHighMassCut)
        {
-               TPair* pair = static_cast<TPair*>(map->FindObject("highmasscut"));
-               if (pair == NULL)
-               {
-                       HLTError("Configuration object for \"%s\" does not contain the high invariant mass cut value.",
-                               pathToEntry
-                       );
-                       return -ENOENT;
-               }
-               TObject* valueObj = pair->Value();
-               if (valueObj->IsA() != TObjString::Class())
-               {
-                       HLTError("The high invariant mass cut parameter found in configuration object \"%s\""
-                               " is not a TObjString. Found an object of type %s instead.",
-                               pathToEntry, valueObj->ClassName()
-                       );
-                       return -EPROTO;
-               }
-               TString value = dynamic_cast<TObjString*>(valueObj)->GetString();
-               if (not value.IsFloat())
-               {
-                       HLTError("The high invariant mass cut parameter found in configuration object \"%s\""
-                               "is not a floating point string; found \"%s\".",
-                               pathToEntry, value.Data()
-                       );
-                       return -EPROTO;
-               }
-               fHighMassCut = (AliHLTFloat32_t) value.Atof();
+               Double_t value = 0;
+               result = GetFloatFromTMap(map, "highmasscut", value, pathToEntry, "high invariant mass cut");
+               if (result != 0) return result;
+               fHighMassCut = (AliHLTFloat32_t) value;
        }
        
        return 0;
index 544ae22160422485132b2eb328418763c4a44a5e..d7bfcb61c8069d14b176c64596e281e61f3646d9 100644 (file)
@@ -53,7 +53,7 @@ AliHLTMUONHitReconstructor::AliHLTMUONHitReconstructor() :
        fkBlockHeaderSize(8),
        fkDspHeaderSize(8),
        fkBuspatchHeaderSize(4),
-       fDCCut(0),
+       fDCCut(-1),
        fPadData(NULL),
        fLookUpTableData(NULL),
        fRecPoints(NULL),
@@ -736,7 +736,7 @@ void AliHLTMUONHitReconstructor::Clear()
 AliHLTMUONHitReconstructor::AliHLTMUONRawDecoder::AliHLTMUONRawDecoder() :
        fBufferStart(NULL),
        fBusPatchId(0),
-       fDCCut(0),
+       fDCCut(-1),
        fPadData(NULL),
        fLookUpTableData(NULL),
        fNofFiredDetElem(NULL),
index 37f79c9bb7495dd57636e7f0a65620f5c217338b..801bef76b9fb2bdf4dd7bb6d87207b1ce8c36a08 100644 (file)
@@ -54,6 +54,7 @@ public:
                );
        
        void SetDCCut(AliHLTInt32_t dcCut) { fDCCut = dcCut; }
+       AliHLTInt32_t GetDCCut() const { return fDCCut; }
        
        bool Run(
                        const AliHLTUInt32_t* rawData,
index 2fb1f00c72c606ee6d7c8cec0d819bde82088381..05cfed80efd396d154c0089cbdfd5708466622f6 100644 (file)
@@ -1,22 +1,27 @@
 /**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project        * 
+ * This file is property of and copyright by the ALICE HLT Project        *
  * All rights reserved.                                                   *
  *                                                                        *
  * Primary Authors:                                                       *
  *   Indranil Das <indra.das@saha.ac.in>                                  *
+ *   Artur Szostak <artursz@iafrica.com>                                  *
  *                                                                        *
  * 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          * 
+ * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
 /* $Id$ */
 
 ///
+///  @file   AliHLTMUONHitReconstructorComponent.cxx
+///  @author Indranil Das <indra.das@saha.ac.in> | <indra.ehep@gmail.com>, Artur Szostak <artursz@iafrica.com>
+///  @date   28 May 2007
+///  @brief  Implementation of the hit Reconstruction processing component.
 ///
 ///  The HitRec Component is designed to deal the rawdata inputfiles to findout the 
 ///  the reconstructed hits. The output is send to the output block for further 
 #include <cassert>
 #include <fstream>
 
-//STEER 
+#include "TMap.h"
+
+//STEER
 #include "AliCDBManager.h"
-#include "AliCDBStorage.h"
 #include "AliGeomManager.h"
 
 //MUON
@@ -70,7 +76,8 @@ AliHLTMUONHitReconstructorComponent::AliHLTMUONHitReconstructorComponent() :
        fLutSize(0),
        fLut(NULL),
        fIdToEntry(),
-       fWarnForUnexpecedBlock(false)
+       fWarnForUnexpecedBlock(false),
+       fDelaySetup(false)
 {
        ///
        /// Default constructor.
@@ -173,12 +180,14 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
        fDDL = -1;
        fIdToEntry.clear();
        fWarnForUnexpecedBlock = false;
+       fDelaySetup = false;
        
        const char* lutFileName = NULL;
        const char* cdbPath = NULL;
        Int_t run = -1;
        bool useCDB = false;
        bool tryRecover = false;
+       AliHLTInt32_t dccut = -1;
        
        for (int i = 0; i < argc; i++)
        {
@@ -186,6 +195,13 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                
                if (strcmp( argv[i], "-ddl" ) == 0)
                {
+                       if (fDDL != -1)
+                       {
+                               HLTWarning("DDL number was already specified."
+                                       " Will replace previous value given by -ddl or -ddlid."
+                               );
+                       }
+                       
                        if (argc <= i+1)
                        {
                                HLTError("The DDL number was not specified. Must be in the range [13..20].");
@@ -215,6 +231,13 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                
                if (strcmp( argv[i], "-ddlid" ) == 0)
                {
+                       if (fDDL != -1)
+                       {
+                               HLTWarning("DDL number was already specified."
+                                       " Will replace previous value given by -ddl or -ddlid."
+                               );
+                       }
+                       
                        if ( argc <= i+1 )
                        {
                                HLTError("DDL equipment ID number not specified. It must be in the range [2572..2579]" );
@@ -244,6 +267,13 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                
                if (strcmp( argv[i], "-lut" ) == 0)
                {
+                       if (lutFileName != NULL)
+                       {
+                               HLTWarning("LUT path was already specified."
+                                       " Will replace previous value given by -lut."
+                               );
+                       }
+                       
                        if (argc <= i+1)
                        {
                                HLTError("The lookup table filename was not specified.");
@@ -263,6 +293,13 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                
                if (strcmp( argv[i], "-cdbpath" ) == 0)
                {
+                       if (cdbPath != NULL)
+                       {
+                               HLTWarning("CDB path was already specified."
+                                       " Will replace previous value given by -cdbpath."
+                               );
+                       }
+                       
                        if ( argc <= i+1 )
                        {
                                HLTError("The CDB path was not specified." );
@@ -277,19 +314,26 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
        
                if (strcmp( argv[i], "-run" ) == 0)
                {
+                       if (run != -1)
+                       {
+                               HLTWarning("Run number was already specified."
+                                       " Will replace previous value given by -run."
+                               );
+                       }
+                       
                        if ( argc <= i+1 )
                        {
-                               HLTError("The RUN number was not specified." );
+                               HLTError("The run number was not specified." );
                                FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
                        char* cpErr = NULL;
-                       run = Int_t( strtoul(argv[i+1], &cpErr, 0) );
-                       if (cpErr == NULL or *cpErr != '\0')
+                       run = Int_t( strtol(argv[i+1], &cpErr, 0) );
+                       if (cpErr == NULL or *cpErr != '\0' or run < 0)
                        {
                                HLTError("Cannot convert '%s' to a valid run number."
-                                       " Expected an integer value.", argv[i+1]
+                                       " Expected a positive integer value.", argv[i+1]
                                );
                                FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
@@ -298,6 +342,43 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                        i++;
                        continue;
                } // -run argument
+       
+               if (strcmp( argv[i], "-dccut" ) == 0)
+               {
+                       if (dccut != -1)
+                       {
+                               HLTWarning("DC cut parameter was already specified."
+                                       " Will replace previous value given by -dccut."
+                               );
+                       }
+                       
+                       if ( argc <= i+1 )
+                       {
+                               HLTError("No DC cut value was specified. It should be a positive integer value." );
+                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+                               return -EINVAL;
+                       }
+                       
+                       char* cpErr = NULL;
+                       dccut = AliHLTInt32_t( strtol(argv[i+1], &cpErr, 0) );
+                       if (cpErr == NULL or *cpErr != '\0' or dccut < 0)
+                       {
+                               HLTError("Cannot convert '%s' to a valid DC cut value."
+                                       " Expected a positive integer value.", argv[i+1]
+                               );
+                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+                               return -EINVAL;
+                       }
+                       
+                       i++;
+                       continue;
+               }
+               
+               if (strcmp( argv[i], "-delaysetup" ) == 0)
+               {
+                       fDelaySetup = true;
+                       continue;
+               }
                
                if (strcmp( argv[i], "-warn_on_unexpected_block" ) == 0)
                {
@@ -319,34 +400,83 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
        
        if (lutFileName == NULL) useCDB = true;
        
-       if (fDDL == -1)
+       if (fDDL == -1 and not fDelaySetup)
        {
                HLTWarning("DDL number not specified. Cannot check if incomming data is valid.");
        }
        
-       int result = 0;
+       if (cdbPath != NULL or run != -1)
+       {
+               int result = SetCDBPathAndRunNo(cdbPath, run);
+               if (result != 0)
+               {
+                       // Error messages already generated in SetCDBPathAndRunNo.
+                       FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+                       return result;
+               }
+       }
+       
        if (useCDB)
        {
-               HLTInfo("Loading lookup table information from CDB for DDL %d (ID = %d).",
-                       fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
-               );
-               if (fDDL == -1)
-                       HLTWarning("DDL number not specified. The lookup table loaded from CDB will be empty!");
-               result = ReadCDB(cdbPath, run);
+               if (not fDelaySetup)
+               {
+                       HLTInfo("Loading lookup table information from CDB for DDL %d (ID = %d).",
+                               fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
+                       );
+                       int result = ReadLutFromCDB();
+                       if (result != 0)
+                       {
+                               // Error messages already generated in ReadLutFromCDB.
+                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+                               return result;
+                       }
+                       fHitRec->SetLookUpTable(fLut, &fIdToEntry);
+               }
        }
        else
        {
                HLTInfo("Loading lookup table information from file %s.", lutFileName);
-               result = ReadLookUpTable(lutFileName);
+               int result = ReadLookUpTable(lutFileName);
+               if (result != 0)
+               {
+                       // Error messages already generated in ReadLookUpTable.
+                       FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+                       return result;
+               }
+               fHitRec->SetLookUpTable(fLut, &fIdToEntry);
        }
-       if (result != 0)
+       
+       if (dccut == -1)
        {
-               // Error messages already generated in ReadCDB or ReadLookUpTable.
-               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
-               return result;
+               if (not fDelaySetup)
+               {
+                       HLTInfo("Loading DC cut parameters from CDB for DDL %d (ID = %d).",
+                               fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
+                       );
+                       int result = ReadDCCutFromCDB();
+                       if (result != 0)
+                       {
+                               // Error messages already generated in ReadDCCutFromCDB.
+                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
+                               return result;
+                       }
+                       HLTDebug("Using DC cut parameter of %d ADC channels.", fHitRec->GetDCCut());
+               }
+       }
+       else
+       {
+               if (useCDB)
+               {
+                       HLTWarning("The -cdb or -cdbpath parameter was specified, which indicates that"
+                               " this component should read from the CDB, but then the -dccut value"
+                               " was also used. Will override the value from CDB with the command"
+                               " line DC cut parameter given.");
+               }
+               
+               fHitRec->SetDCCut(dccut);
+               HLTDebug("Using DC cut parameter of %d ADC channels.", fHitRec->GetDCCut());
        }
        
-       fHitRec->SetLookUpTable(fLut, &fIdToEntry);
        fHitRec->TryRecover(tryRecover);
        
        return 0;
@@ -365,6 +495,76 @@ int AliHLTMUONHitReconstructorComponent::DoDeinit()
 }
 
 
+int AliHLTMUONHitReconstructorComponent::Reconfigure(
+               const char* cdbEntry, const char* componentId
+       )
+{
+       /// Inherited from AliHLTComponent. This method will reload CDB configuration
+       /// entries for this component from the CDB.
+       /// \param cdbEntry If this is NULL then it is assumed that all CDB entries should
+       ///      be reloaded. Otherwise a particular value for 'cdbEntry' will trigger
+       ///      reloading of the LUT if the path contains 'MUON/' and reloading of the DC
+       ///      cut parameter from the given path in all other cases.
+       /// \param componentId  Must be set to the same value as what GetComponentID()
+       ///      returns for this component for this method to have any effect.
+       
+       if (strcmp(componentId, GetComponentID()) == 0)
+       {
+               HLTInfo("Reading new configuration entries from CDB.");
+               
+               int result = 0;
+               bool startsWithMUON = TString(cdbEntry).Index("MUON/", 5, 0, TString::kExact) == 0;
+               if (cdbEntry == NULL or startsWithMUON)
+               {
+                       // First clear the current LUT data and then load in the new values.
+                       if (fLut != NULL)
+                       {
+                               delete [] fLut;
+                               fLut = NULL;
+                               fLutSize = 0;
+                       }
+                       
+                       fIdToEntry.clear();
+               
+                       result = ReadLutFromCDB();
+                       if (result != 0) return result;
+               }
+               
+               if (cdbEntry == NULL or not startsWithMUON)
+               {
+                       result = ReadDCCutFromCDB(cdbEntry);
+                       if (result != 0) return result;
+                       HLTDebug("Using DC cut parameter of %d ADC channels.", fHitRec->GetDCCut());
+               }
+       }
+       
+       return 0;
+}
+
+
+int AliHLTMUONHitReconstructorComponent::ReadPreprocessorValues(const char* modules)
+{
+       /// Inherited from AliHLTComponent. 
+       /// Updates the configuration of this component if either HLT or MUON have
+       /// been specified in the 'modules' list.
+
+       TString mods = modules;
+       if (mods.Contains("ALL") or (mods.Contains("HLT") and mods.Contains("MUON")))
+       {
+               return Reconfigure(NULL, GetComponentID());
+       }
+       if (mods.Contains("HLT"))
+       {
+               return Reconfigure(AliHLTMUONConstants::HitReconstructorCDBPath(), GetComponentID());
+       }
+       if (mods.Contains("MUON"))
+       {
+               return Reconfigure("MUON/*", GetComponentID());
+       }
+       return 0;
+}
+
+
 int AliHLTMUONHitReconstructorComponent::DoEvent(
                const AliHLTComponentEventData& evtData,
                const AliHLTComponentBlockData* blocks,
@@ -378,6 +578,68 @@ int AliHLTMUONHitReconstructorComponent::DoEvent(
        /// Inherited from AliHLTProcessor. Processes the new event data.
        ///
        
+       // Initialise the LUT and DC cut parameter from CDB if we were requested
+       // to initialise only when the first event was received.
+       if (fDelaySetup)
+       {
+               // Use the specification given by the first data block if we
+               // have not been given a DDL number on the command line.
+               if (fDDL == -1)
+               {
+                       if (evtData.fBlockCnt <= 0)
+                       {
+                               HLTError("The initialisation from CDB of the component has"
+                                       " been delayed to the first received event. However,"
+                                       " no data blocks have been found in the first event."
+                               );
+                               return -ENOENT;
+                       }
+                       
+                       fDDL = AliHLTMUONUtils::SpecToDDLNumber(blocks[0].fSpecification);
+                       
+                       if (fDDL == -1)
+                       {
+                               HLTError("Received a data block with a specification (0x%8.8X)"
+                                       " indicating multiple DDL data sources, but we must only"
+                                       " receive data from one tracking station DDL.",
+                                       blocks[0].fSpecification
+                               );
+                               return -EPROTO;
+                       }
+               }
+               
+               // Check that the LUT was not already loaded in DoInit.
+               if (fLut == NULL)
+               {
+                       HLTInfo("Loading lookup table information from CDB for DDL %d (ID = %d).",
+                               fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
+                       );
+                       int result = ReadLutFromCDB();
+                       if (result != 0) return result;
+                       
+                       fHitRec->SetLookUpTable(fLut, &fIdToEntry);
+               }
+               
+               // Check that the DC cut was not already loaded in DoInit.
+               if (fHitRec->GetDCCut() == -1)
+               {
+                       HLTInfo("Loading DC cut parameters from CDB for DDL %d (ID = %d).",
+                               fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
+                       );
+                       int result = ReadDCCutFromCDB();
+                       if (result != 0) return result;
+                       HLTDebug("Using DC cut parameter of %d ADC channels.", fHitRec->GetDCCut());
+               }
+               
+               fDelaySetup = false;
+       }
+       
+       if (fLut == NULL)
+       {
+               HLTFatal("Lookup table not loaded! Cannot continue processing data.");
+               return -ENOENT;
+       }
+       
        // Process an event
        unsigned long totalSize = 0; // Amount of memory currently consumed in bytes.
 
@@ -612,9 +874,12 @@ int AliHLTMUONHitReconstructorComponent::ReadLookUpTable(const char* lutFileName
 }
 
 
-int AliHLTMUONHitReconstructorComponent::ReadCDB(const char* cdbPath, Int_t run)
+int AliHLTMUONHitReconstructorComponent::ReadLutFromCDB()
 {
        /// Reads LUT from CDB.
+       /// To override the default CDB path and / or run number the
+       /// SetCDBPathAndRunNo(cdbPath, run) method should be called before this
+       /// method.
 
        assert( fLut == NULL );
        assert( fLutSize == 0 );
@@ -630,7 +895,7 @@ int AliHLTMUONHitReconstructorComponent::ReadCDB(const char* cdbPath, Int_t run)
        AliHLTMUONHitRecoLutRow lut;
        AliHLTUInt32_t iEntry = 0;
        
-       int result = FetchMappingStores(cdbPath, run);
+       int result = FetchMappingStores();
        // Error message already generated in FetchMappingStores.
        if (result != 0) return result;
        AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
@@ -654,7 +919,7 @@ int AliHLTMUONHitReconstructorComponent::ReadCDB(const char* cdbPath, Int_t run)
                return -ENOENT;
        }
        
-       AliMUONCalibrationData calibData(run);
+       AliMUONCalibrationData calibData(AliCDBManager::Instance()->GetRun());
        
        Int_t chamberId;
        
@@ -798,6 +1063,29 @@ int AliHLTMUONHitReconstructorComponent::ReadCDB(const char* cdbPath, Int_t run)
 }
 
 
+int AliHLTMUONHitReconstructorComponent::ReadDCCutFromCDB(const char* path)
+{
+       /// Reads the DC cut parameter from the CDB.
+
+       const char* pathToEntry = AliHLTMUONConstants::HitReconstructorCDBPath();
+       if (path != NULL)
+               pathToEntry = path;
+       
+       TMap* map = NULL;
+       int result = FetchTMapFromCDB(pathToEntry, map);
+       if (result != 0) return result;
+       
+       Int_t value = 0;
+       result = GetPositiveIntFromTMap(map, "dccut", value, pathToEntry, "DC cut");
+       if (result != 0) return result;
+       
+       assert(fHitRec != NULL);
+       fHitRec->SetDCCut(value);
+       
+       return 0;
+}
+
+
 bool AliHLTMUONHitReconstructorComponent::GenerateLookupTable(
                AliHLTInt32_t ddl, const char* filename,
                const char* cdbPath, Int_t run
@@ -821,7 +1109,8 @@ bool AliHLTMUONHitReconstructorComponent::GenerateLookupTable(
        }
        
        comp.fDDL = ddl;
-       if (comp.ReadCDB(cdbPath, run) != 0) return false;
+       if (comp.SetCDBPathAndRunNo(cdbPath, run) != 0) return false;
+       if (comp.ReadLutFromCDB() != 0) return false;
        
        char str[1024*4];
        std::fstream file(filename, std::ios::out);
@@ -841,7 +1130,7 @@ bool AliHLTMUONHitReconstructorComponent::GenerateLookupTable(
                AliHLTInt32_t idManuChannel = id->first;
                AliHLTInt32_t row = id->second;
                
-               assert( row < comp.fLutSize );
+               assert( AliHLTUInt32_t(row) < comp.fLutSize );
                
                sprintf(str, "%d\t%d\t%d\t%d\t%.15e\t%.15e\t%.15e\t%.15e\t%d\t%.15e\t%.15e\t%.15e\t%.15e\t%d\t%d",
                        idManuChannel, comp.fLut[row].fDetElemId, comp.fLut[row].fIX,
index 82cbbdc4a52aa55c7342256f0780a9047e14b6fd..4a496797e610397c95e6f3d0496275524fa94ab2 100644 (file)
@@ -8,7 +8,7 @@
 
 ///
 ///  @file   AliHLTMUONHitReconstructorComponent.h
-///  @author Indranil Das <indra.das@saha.ac.in> | <indra.ehep@gmail.com>
+///  @author Indranil Das <indra.das@saha.ac.in> | <indra.ehep@gmail.com>, Artur Szostak <artursz@iafrica.com>
 ///  @date   28 May 2007
 ///  @brief  Hit Reconstruction processing component for the dimuon HLT.
 ///
@@ -26,6 +26,93 @@ extern "C" struct AliHLTMUONHitRecoLutRow;
 /**
  * @class AliHLTMUONHitReconstructorComponent
  * @brief A processing component for the dHLT tracker DDL reconstruction.
+ *
+ * This is the hit reconstruction component which forms part of the online dHLT
+ * reconstruction algorithm. It processes the raw DDL data from a dimuon spectrometer
+ * tracker station, applies simple 3 pad cluster finding and then a centre of gravity
+ * calculation to reconstruct the hit coordinate.
+ *
+ * <h2>General properties:</h2>
+ *
+ * Component ID: \b MUONHitReconstructor <br>
+ * Library: \b libAliHLTMUON.so  <br>
+ * Input Data Types: ('DDL_RAW ', 'MUON') <br>
+ * Output Data Types: ('RECHITS ', 'MUON') <br>
+ *
+ * <h2>Mandatory arguments:</h2>
+ * \li -ddl <i>number</i> <br>
+ *      This indicates the DDL from which the component is expect to receive data
+ *      and for which it should load the appropriate electronics mapping lookup
+ *      table.
+ *      The <i>number</i> should be in the range [13..20], following local dimuon
+ *      spectrometer DDL numbering. If either the -ddlid, -lut or -delaysetup
+ *      arguments are used, then -ddl becomes optional. <br>
+ * \li -ddlid <i>number</i> <br>
+ *      This indicates the DDL by equipment ID, from which the component is expect
+ *      to receive data and for which it should load the appropriate electronics
+ *      mapping lookup table.
+ *      The <i>number</i> should be in the range [2572..2579].
+ *      If either the -ddl, -lut or -delaysetup arguments are used, then -ddlid
+ *      becomes optional. <br>
+ * \li -delaysetup <br>
+ *      Specifying this option causes the component to initialise the lookup table
+ *      and DC cut parameters from CDB only after receiving the first event to
+ *      process in DoEvent.
+ *      If -ddl or -ddlid were not used, then the DDL number will be taken from
+ *      the first block's specification during runtime from the first
+ *      event (Start-of-Run event).
+ *      Using the -lut or -dccut arguments will override loading from CDB for a
+ *      delayed setup. <br>
+ *
+ * <h2>Optional arguments:</h2>
+ * \li -lut <i>filename</i> <br>
+ *      A pree-built lookup table for the electronics mapping and calibration
+ *      information can be loaded with this argument. The file should have been
+ *      generated with the GenerateLookupTable method. The location of the file
+ *      is given by the parameter <i>filename</i> <br>
+ * \li -cdb <br>
+ *      Indicates that the component should load from CDB. This option is implicit
+ *      if the -cdbpath is given. It will also override the -lut option.<br>
+ * \li -cdbpath <i>path</i> <br>
+ *      Specifies the CDB path to use, given by <i>path</i>. This option will override
+ *      the CDB path automatically set by the HLT framework. <br>
+ * \li -run <i>number</i> <br>
+ *      Specifies the run number to use, given by <i>number</i>. This option will
+ *      override the current run number automatically set by the HLT framework. <br>
+ * \li -dccut <i>number</i> <br>
+ *      Used to override the DC cut parameter in the CDB with the value given by
+ *      <i>number</i>. <br>
+ * \li -warn_on_unexpected_block <br>
+ *      This will cause the component to generate warnings when it receives data block
+ *      types it does not know how to handle. Without this option the component only
+ *      generates debug messages when they are compiled in. <br>
+ * \li -tryrecover <br>
+ *      This is a special option to the raw data decoder to turn on logic which will
+ *      try and recover from corrupt raw DDL data. This is off by default. <br>
+ *
+ * <h2>Standard configuration:</h2>
+ * This component should normally be configured with either of the two sets of
+ * options in the XML configuration. <br>
+ * \li -delaysetup <br>
+ * \li -ddlid ${DDL_ID} <br>
+ *
+ * <h2>Default CDB entries:</h2>
+ * The component loads electronics mapping and calibration information from the MUON
+ * subdirectory in the CDB, MUON/Calib and MUON/Align.
+ * The DC cut parameter is stored in a TMap under HLT/ConfigMUON/HitReconstructor
+ * with a default value of 50 ADC channels.
+ *
+ * <h2>Performance:</h2>
+ * Can achieve about 2kHz processing rate for nominal event sizes containing
+ * 150 tracks per event.
+ *
+ * <h2>Memory consumption:</h2>
+ * The lookup table requires about 3.5 MBytes of memory.
+ *
+ * <h2>Output size:</h2>
+ * Output size is about 10% of incoming raw input data for nominal p+p events.
+ *
+ * @ingroup alihlt_dimuon_component
  */
 class AliHLTMUONHitReconstructorComponent : public AliHLTMUONProcessor
 {
@@ -64,6 +151,8 @@ protected:
        // capabilities of the component.
 
        virtual int DoInit(int argc, const char** argv);
+       virtual int Reconfigure(const char* cdbEntry, const char* componentId);
+       virtual int ReadPreprocessorValues(const char* modules);
        virtual int DoDeinit();
        virtual int DoEvent(
                        const AliHLTComponentEventData& evtData,
@@ -86,7 +175,8 @@ private:
        
        void FreeMemory();
        int ReadLookUpTable(const char* lutpath);
-       int ReadCDB(const char* cdbpath, Int_t run);
+       int ReadLutFromCDB();
+       int ReadDCCutFromCDB(const char* path = NULL);
        
        AliHLTMUONHitReconstructor* fHitRec;  ///< Internal class instance implementing the hit reconstruction algorithm.
        AliHLTInt32_t fDDL;  ///< DDL number in the range [12..19]. Set to -1 for invalid/unspecified value.
@@ -94,6 +184,7 @@ private:
        AliHLTMUONHitRecoLutRow* fLut;  ///< The lookup table used by the hit reconstruction algorithm (Owned by this component however).
        IdManuChannelToEntry fIdToEntry; ///< id to line mapping.
        bool fWarnForUnexpecedBlock;  ///< Flag indicating if we should log a warning if we got a block of an unexpected type.
+       bool fDelaySetup;  ///< Indicates if the component should delay loading and initialising from the CDB to the start of run event.
        
        ClassDef(AliHLTMUONHitReconstructorComponent, 0) // Hit reconstructor component for dHLT tracker DDL raw data.
 };
index c49fb741a0b2343349ddd4f7eca9714d02b9d99d..654787e53e0155e3776e9430fdc70a1be6a95773 100644 (file)
@@ -692,7 +692,7 @@ void AliHLTMUONTriggerReconstructor::AliDecoderHandler::OnLocalStructV2(
        ///    a new raw data buffer.
        /// \param localStruct  This is a pointer to the local L0 trigger structure data.
 
-       assert(iloc >= 0 and iloc < 16);
+       assert(iloc < 16);
        assert(localStruct != NULL);
        assert(fOutputTrigRecs != NULL);
        
index fba0d6907dba633881f0e8e99d011748144a9436..52de671bc3b5cfb8a4f91a18dda41511a0e1abe1 100644 (file)
@@ -287,7 +287,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                {
                        if ( argc <= i+1 )
                        {
-                               HLTError("The RUN number was not specified." );
+                               HLTError("The run number was not specified." );
                                // Make sure to delete fTrigRec to avoid partial initialisation.
                                delete fTrigRec;
                                fTrigRec = NULL;
@@ -299,7 +299,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        if (cpErr == NULL or *cpErr != '\0')
                        {
                                HLTError("Cannot convert '%s' to a valid run number."
-                                       " Expected an integer value.", argv[i+1]
+                                       " Expected a positive integer value.", argv[i+1]
                                );
                                // Make sure to delete fTrigRec to avoid partial initialisation.
                                delete fTrigRec;
@@ -363,23 +363,28 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
        }
        
        int result = 0;
-       if (useCDB)
+       if (cdbPath != NULL or run != -1)
+       {
+               result = SetCDBPathAndRunNo(cdbPath, run);
+       }
+       
+       if (result == 0 and useCDB)
        {
                HLTInfo("Loading lookup table information from CDB for DDL %d (ID = %d).",
                        fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
                );
                if (fDDL == -1)
                        HLTWarning("DDL number not specified. The lookup table loaded from CDB will be empty!");
-               result = ReadCDB(cdbPath, run);
+               result = ReadLutFromCDB();
        }
-       else
+       else if (result == 0)
        {
                HLTInfo("Loading lookup table information from file %s.", lutFileName);
                result = ReadLookUpTable(lutFileName);
        }
        if (result != 0)
        {
-               // Error messages already generated in ReadCDB or ReadLookUpTable.
+               // Error messages already generated in ReadLutFromCDB or ReadLookUpTable.
                
                // Make sure to delete fTrigRec to avoid partial initialisation.
                delete fTrigRec;
@@ -591,14 +596,15 @@ int AliHLTMUONTriggerReconstructorComponent::ReadLookUpTable(const char* lutpath
 }
 
 
-int AliHLTMUONTriggerReconstructorComponent::ReadCDB(const char* cdbPath, Int_t run)
+int AliHLTMUONTriggerReconstructorComponent::ReadLutFromCDB()
 {
        /// Loads the lookup table containing channel and geometrical position
        /// information about trigger strips from CDB.
-       /// \param cdbPath  This specifies the CDB path to use to load from.
-       ///                 Can be set to NULL meaning the default storage is used.
-       /// \param run  Specifies the run number to use. If set to -1 then the
-       ///             default / current run number set for the CDB is used.
+       ///
+       /// \note To override the default CDB path and / or run number the
+       /// SetCDBPathAndRunNo(cdbPath, run) method should be called before this
+       /// method.
+       ///
        /// \return 0 on success and non zero codes for errors.
 
        if (fDDL == -1)
@@ -607,7 +613,7 @@ int AliHLTMUONTriggerReconstructorComponent::ReadCDB(const char* cdbPath, Int_t
                return -EINVAL;
        }
 
-       int result = FetchMappingStores(cdbPath, run);
+       int result = FetchMappingStores();
        // Error message already generated in FetchMappingStores.
        if (result != 0) return result;
        AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
index c4c40e398a52ec44d0191a24e4b5fe35cf40072c..8f8365e66627acd30228b8d24bd13390d0945958 100644 (file)
@@ -85,7 +85,7 @@ private:
        AliHLTMUONTriggerReconstructorComponent& operator = (const AliHLTMUONTriggerReconstructorComponent& /*obj*/);
 
        int ReadLookUpTable(const char* lutpath);
-       int ReadCDB(const char* cdbPath, Int_t run);
+       int ReadLutFromCDB();
        
        AliHLTMUONTriggerReconstructor* fTrigRec; ///< The trigger reconstructor class implementing the algorithm.
        AliHLTInt32_t fDDL;   ///< The DDL number in the range 20..21 from which to expect input. Set to -1 for invalid/unspecified value.
index e767a0338b23d588066068a33a93f827664c5858..c9f2a83210e5f73a343a87ff63cb950326cc1fe0 100644 (file)
@@ -72,18 +72,35 @@ void CreateDefaultCDBEntries(const char* cdbPath = "local://$ALICE_ROOT")
        Int_t firstRun = 0;
        Int_t lastRun = AliCDBRunRange::Infinity();
        
+       const char* path = NULL;
+       AliCDBMetaData* metaData = NULL;
+       TMap* params = NULL;
+       AliCDBId id;
+       
+       // Create and store the configuration parameters for the hit reconstructor.
+       params = new TMap;
+       params->SetOwner(kTRUE);
+       params->Add(new TObjString("dccut"), new TObjString("50"));
+       
+       path = AliHLTMUONConstants::HitReconstructorCDBPath();
+       id = AliCDBId(path, firstRun, lastRun, verison);
+       metaData = new AliCDBMetaData();
+       metaData->SetResponsible("dimuon HLT");
+       metaData->SetComment("Hit reconstructor DC cut parameter for dimuon HLT.");
+       storage->Put(params, id, metaData);
+       
        // Create and store the configuration parameters for the trigger decision cuts.
-       TMap* cuts = new TMap;
-       cuts->SetOwner(kTRUE);
-       cuts->Add(new TObjString("lowptcut"), new TObjString("1"));
-       cuts->Add(new TObjString("highptcut"), new TObjString("2"));
-       cuts->Add(new TObjString("lowmasscut"), new TObjString("2.5"));
-       cuts->Add(new TObjString("highmasscut"), new TObjString("7"));
+       params = new TMap;
+       params->SetOwner(kTRUE);
+       params->Add(new TObjString("lowptcut"), new TObjString("1"));
+       params->Add(new TObjString("highptcut"), new TObjString("2"));
+       params->Add(new TObjString("lowmasscut"), new TObjString("2.5"));
+       params->Add(new TObjString("highmasscut"), new TObjString("7"));
        
-       const char* path = AliHLTMUONConstants::DecisionComponentCDBPath();
-       AliCDBId id(path, firstRun, lastRun, verison);
-       AliCDBMetaData* metaData = new AliCDBMetaData();
+       path = AliHLTMUONConstants::DecisionComponentCDBPath();
+       id = AliCDBId(path, firstRun, lastRun, verison);
+       metaData = new AliCDBMetaData();
        metaData->SetResponsible("dimuon HLT");
        metaData->SetComment("Trigger decision cuts for dimuon HLT.");
-       storage->Put(cuts, id, metaData);
+       storage->Put(params, id, metaData);
 }