Adding facility to components to dump internal data blocks to file when corruption...
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 2 Aug 2008 23:56:14 +0000 (23:56 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 2 Aug 2008 23:56:14 +0000 (23:56 +0000)
Refactored code to move common command line options to AliHLTMUONProcessor base class.
Applying a bug fix with loading of libraries in command line utilities dHLTdumpraw and dHLTrootify. Also adding cdbpath and run number command line options.

26 files changed:
HLT/MUON/AliHLTMUONProcessor.cxx
HLT/MUON/AliHLTMUONProcessor.h
HLT/MUON/OfflineInterface/AliHLTMUONDigitPublisherComponent.cxx
HLT/MUON/OfflineInterface/AliHLTMUONDigitPublisherComponent.h
HLT/MUON/OfflineInterface/AliHLTMUONESDMaker.cxx
HLT/MUON/OfflineInterface/AliHLTMUONESDMaker.h
HLT/MUON/OfflineInterface/AliHLTMUONRecHitsSource.cxx
HLT/MUON/OfflineInterface/AliHLTMUONRecHitsSource.h
HLT/MUON/OfflineInterface/AliHLTMUONRootifierComponent.cxx
HLT/MUON/OfflineInterface/AliHLTMUONRootifierComponent.h
HLT/MUON/OfflineInterface/AliHLTMUONTriggerRecordsSource.cxx
HLT/MUON/OfflineInterface/AliHLTMUONTriggerRecordsSource.h
HLT/MUON/OnlineAnalysis/AliHLTMUONDecisionComponent.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONDecisionComponent.h
HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.h
HLT/MUON/OnlineAnalysis/AliHLTMUONMansoTrackerFSMComponent.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONMansoTrackerFSMComponent.h
HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructorComponent.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructorComponent.h
HLT/MUON/utils/AliHLTMUONDataCheckerComponent.cxx
HLT/MUON/utils/AliHLTMUONDataCheckerComponent.h
HLT/MUON/utils/AliHLTMUONEmptyEventFilterComponent.cxx
HLT/MUON/utils/AliHLTMUONEmptyEventFilterComponent.h
HLT/MUON/utils/dHLTdumpraw.cxx
HLT/MUON/utils/dHLTrootify.cxx

index 26dc919..3f6e869 100644 (file)
 #include "TMap.h"
 #include "TObjString.h"
 #include "TString.h"
+#include <string>
+#include <cstdlib>
+#include <fstream>
+
 
 ClassImp(AliHLTMUONProcessor)
 
 
+AliHLTMUONProcessor::AliHLTMUONProcessor() :
+       AliHLTProcessor(),
+       fWarnForUnexpecedBlock(false),
+       fDelaySetup(false),
+       fDumpDataOnError(false),
+       fDumpPath("./")
+{
+       /// Default constructor.
+}
+
+
+int AliHLTMUONProcessor::DoInit(int argc, const char** argv)
+{
+       /// Parses common dHLT component arguments.
+
+       // Set the default values for various arguments comming from the command line.
+       fDelaySetup = false;
+       fDumpDataOnError = false;
+       fDumpPath = "./";
+       const char* cdbPath = NULL;
+       Int_t run = -1;
+
+       for (int i = 0; i < argc; i++)
+       {
+               // Ignore the argument if the child class indicates to do so.
+               if (IgnoreArgument(argv[i])) continue;
+       
+               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." );
+                               return -EINVAL;
+                       }
+                       cdbPath = argv[i+1];
+                       i++;
+                       continue;
+               }
+       
+               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.");
+                               return -EINVAL;
+                       }
+                       
+                       char* cpErr = NULL;
+                       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 a positive integer value.", argv[i+1]
+                               );
+                               return -EINVAL;
+                       }
+                       
+                       i++;
+                       continue;
+               }
+               
+               if (strcmp(argv[i], "-delaysetup") == 0)
+               {
+                       fDelaySetup = true;
+                       continue;
+               }
+               
+               if (strcmp(argv[i], "-dumponerror") == 0)
+               {
+                       fDumpDataOnError = true;
+                       continue;
+               }
+               
+               if (strcmp(argv[i], "-dumppath") == 0)
+               {
+                       if (fDumpPath != NULL)
+                       {
+                               HLTWarning("The dump path was already specified. Will"
+                                       " replace previous value given by -dumppath."
+                               );
+                       }
+                       if (argc <= i+1)
+                       {
+                               HLTError("The dump path was not specified.");
+                               return -EINVAL;
+                       }
+                       fDumpPath = argv[i+1];
+                       i++;
+                       continue;
+               }
+       }
+       
+       if (cdbPath != NULL or run != -1)
+       {
+               int result = SetCDBPathAndRunNo(cdbPath, run);
+               if (result != 0)
+               {
+                       // Error messages already generated in SetCDBPathAndRunNo.
+                       return result;
+               }
+       }
+
+       return 0;
+}
+
+
+bool AliHLTMUONProcessor::ArgumentAlreadyHandled(int& i, const char* argi) const
+{
+       /// This method can be used by the derivind child class to check if a particular
+       /// argument in argv was already processed.
+
+       if (strcmp(argi, "-cdbpath") == 0)
+       {
+               if (IgnoreArgument(argi)) return false;
+               i++;
+               return true;
+       }
+
+       if (strcmp(argi, "-run") == 0)
+       {
+               if (IgnoreArgument(argi)) return false;
+               i++;
+               return true;
+       }
+       
+       if (strcmp(argi, "-delaysetup") == 0)
+       {
+               if (IgnoreArgument(argi)) return false;
+               return true;
+       }
+       
+       if (strcmp(argi, "-dumponerror") == 0)
+       {
+               if (IgnoreArgument(argi)) return false;
+               return true;
+       }
+       
+       if (strcmp(argi, "-dumppath") == 0)
+       {
+               if (IgnoreArgument(argi)) return false;
+               i++;
+               return true;
+       }
+
+       return false;
+}
+
+
 int AliHLTMUONProcessor::SetCDBPathAndRunNo(
                const char* cdbPath, Int_t run, bool useDefault
        ) const
@@ -467,3 +631,162 @@ int AliHLTMUONProcessor::LoadRecoParamsFromCDB(AliMUONRecoParam*& params) const
        return 0;
 }
 
+
+void AliHLTMUONProcessor::DumpBuffer(
+               const void* buffer, AliHLTUInt32_t size, const char* filename
+       ) const
+{
+       /// Dumps the data contained in a buffer to file as is.
+
+       using std::fstream;
+
+       fstream file(filename, fstream::out | fstream::trunc | fstream::binary);
+       if (file.good())
+       {
+               file.write(reinterpret_cast<const char*>(buffer), size);
+               if (file.fail())
+               {
+                       HLTError("Could not write data block to file %s during"
+                               " dumping operation!",
+                               filename
+                       );
+               }
+       }
+       else
+       {
+               HLTError("Could not open file %s for dumping data block!", filename);
+       }
+}
+
+
+void AliHLTMUONProcessor::DumpBlock(
+               const AliHLTComponentBlockData* block, const char* fileNamePrefix
+       ) const
+{
+       /// Dumps the data block and meta information to file.
+
+       std::string filename = fDumpPath;
+       filename += fileNamePrefix;
+       filename += "-blockmeta.bin";
+       DumpBuffer(block, sizeof(AliHLTComponentBlockData), filename.c_str());
+       filename = fDumpPath;
+       filename += fileNamePrefix;
+       filename += "-data.bin";
+       DumpBuffer(block->fPtr, block->fSize, filename.c_str());
+}
+
+
+void AliHLTMUONProcessor::DumpEvent(
+               const AliHLTComponentEventData& evtData,
+               const AliHLTComponentBlockData* blocks,
+               AliHLTComponentTriggerData& trigData,
+               AliHLTUInt8_t* outputPtr,
+               AliHLTUInt32_t& size,
+               AliHLTComponentBlockDataList& outputBlocks
+       ) const
+{
+       /// Dumps the event information to files in the dump path given by the
+       /// method DumpPath, which can be set by the command line argument -dumppath.
+
+       using std::fstream;
+       char strbuf[1024];
+
+       std::string filename = fDumpPath;
+       sprintf(strbuf, "dump_event-0x%16.16llX.log", evtData.fEventID);
+       filename += strbuf;
+       fstream logfile(filename.c_str(), fstream::out | fstream::trunc);
+       if (logfile.fail())
+       {
+               HLTError("Could not open log file '%s' for dump information.", filename.c_str());
+               return;
+       }
+
+       filename = fDumpPath;
+       sprintf(strbuf, "dump_event-0x%16.16llX-eventdata.bin", evtData.fEventID);
+       filename += strbuf;
+       logfile << "Dumping event data structure to file: " << filename << std::endl;
+       DumpBuffer(&evtData, sizeof(AliHLTComponentEventData), filename.c_str());
+
+       filename = fDumpPath;
+       sprintf(strbuf, "dump_event-0x%16.16llX-triggerdata.bin", evtData.fEventID);
+       filename += strbuf;
+       logfile << "Dumping trigger data structure to file: " << filename << std::endl;
+       DumpBuffer(&trigData, sizeof(AliHLTComponentTriggerData), filename.c_str());
+
+       for (unsigned int n = 0; n < evtData.fBlockCnt; n++)
+       {
+               sprintf(strbuf, "dump_event-0x%16.16llX-block-0x%8.8X", evtData.fEventID, n);
+               filename = strbuf;
+               sprintf(strbuf, "0x%8.8X", blocks[n].fSpecification);
+               logfile << "Found block with data type = " << DataType2Text(blocks[n].fDataType)
+                       << ", specification = " << strbuf << ". Dumping to file: "
+                       << filename << "-data.bin" << std::endl;
+               DumpBlock(&blocks[n], filename.c_str());
+       }
+
+       filename = fDumpPath;
+       sprintf(strbuf, "dump_event-0x%16.16llX-output-buffer.bin", evtData.fEventID);
+       filename += strbuf;
+       logfile << "Dumping output buffer to file: " << filename << std::endl;
+       DumpBuffer(outputPtr, size, filename.c_str());
+
+       for (size_t i = 0; i < outputBlocks.size(); i++)
+       {
+               sprintf(strbuf, "dump_event-0x%16.16llX-output-block-0x%8.8X", evtData.fEventID, int(i));
+               filename = strbuf;
+               sprintf(strbuf, "0x%8.8X", outputBlocks[i].fSpecification);
+               logfile << "Generated output data block with type = "
+                       << DataType2Text(outputBlocks[i].fDataType)
+                       << ", specification = " << strbuf << ". Dumping to file: "
+                       << filename << "-data.bin" << std::endl;
+               DumpBlock(&outputBlocks[i], filename.c_str());
+       }
+}
+
+
+void AliHLTMUONProcessor::DumpEvent(
+               const AliHLTComponentEventData& evtData,
+               AliHLTComponentTriggerData& trigData
+       ) const
+{
+       /// Dumps the event information to files in the dump path given by the
+       /// method DumpPath, which can be set by the command line argument -dumppath.
+
+       using std::fstream;
+       char strbuf[1024];
+
+       std::string filename = fDumpPath;
+       sprintf(strbuf, "dump_event-0x%16.16llX.log", evtData.fEventID);
+       filename += strbuf;
+       fstream logfile(filename.c_str(), fstream::out | fstream::trunc);
+       if (logfile.fail())
+       {
+               HLTError("Could not open log file '%s' for dump information.", filename.c_str());
+               return;
+       }
+
+       filename = fDumpPath;
+       sprintf(strbuf, "dump_event-0x%16.16llX-eventdata.bin", evtData.fEventID);
+       filename += strbuf;
+       logfile << "Dumping event data structure to file: " << filename << std::endl;
+       DumpBuffer(&evtData, sizeof(AliHLTComponentEventData), filename.c_str());
+
+       filename = fDumpPath;
+       sprintf(strbuf, "dump_event-0x%16.16llX-triggerdata.bin", evtData.fEventID);
+       filename += strbuf;
+       logfile << "Dumping trigger data structure to file: " << filename << std::endl;
+       DumpBuffer(&trigData, sizeof(AliHLTComponentTriggerData), filename.c_str());
+
+       for (int i = 0; i < GetNumberOfInputBlocks(); i++)
+       {
+               const AliHLTComponentBlockData* block = GetInputBlock(i);
+               sprintf(strbuf, "dump_event-0x%16.16llX-block-0x%8.8X", evtData.fEventID, i);
+               filename = strbuf;
+               sprintf(strbuf, "0x%8.8X", block->fSpecification);
+               logfile << "Found block with data type = " << DataType2Text(block->fDataType)
+                       << ", specification = " << strbuf << ". Dumping to file: "
+                       << filename << "-data.bin" << std::endl;
+               DumpBlock(block, filename.c_str());
+       }
+}
+
index 877012d..77b0a4d 100644 (file)
@@ -32,7 +32,7 @@ class AliHLTMUONProcessor : public AliHLTProcessor
 {
 public:
        /// Default constructor.
-       AliHLTMUONProcessor() : AliHLTProcessor() {}
+       AliHLTMUONProcessor();
        
        /// Default destructor.
        virtual ~AliHLTMUONProcessor() {}
@@ -40,6 +40,73 @@ public:
 protected:
 
        /**
+        * This method parses the common arguments for dHLT processing components
+        * and initialises the common internal state.
+        * Deriving classes can use the ArgumentAlreadyHandled method to check if
+        * the parent class has processed a particular argument. The following is
+        * an example of this:
+        *
+        * \code
+        * int DerivedClass::DoInit(int argc, const char** argv)
+        * {
+        *   int result = AliHLTMUONProcessor::DoInit(argc, argv);
+        *   if (result != 0) return result;
+        *   for (int i = 0; i < argc; i++)
+        *   {
+        *     if (ArgumentAlreadyHandled(i, argv[i])) continue;
+        *     // ... handle custom arguments here ...
+        *   }
+        * }
+        * \endcode
+        */
+       virtual int DoInit(int argc, const char** argv);
+
+       /**
+        * This method can be used by the derivind child class to check if a particular
+        * argument in argv was already processed.
+        * \note This assumes that the deriving class called the DoInit method of the
+        * parent class in its own DoInit method.
+        */
+       virtual bool ArgumentAlreadyHandled(int& i, const char* argi) const;
+       
+       /**
+        * This method returns the command line arguments that should not be parsed
+        * by this class. This method can be used by child classes that derive from
+        * AliHLTMUONProcessor, to indicate which arguments should not be handled by
+        * the AliHLTMUONProcessor::DoInit method. Default return value is false.
+        */
+       virtual bool IgnoreArgument(const char* /*arg*/) const { return false; }
+       
+       /**
+        * Returns true if the component was told to delay initialisation from
+        * CDB until the first start of run event. This gets set by the -delaysetup
+        * flag which is processed in AliHLTMUONProcessor::DoInit.
+        */
+       bool DelaySetup() const { return fDelaySetup; }
+
+       /**
+        * This method should be called when a derived component has handled a
+        * delayed setup requested on the command line with -delaysetup and indicated
+        * by the flag returned by the DelaySetup method.
+        */
+       void DoneDelayedSetup() { fDelaySetup = false; }
+       
+       /**
+        * Returns true if the component has the flag set indicating to dump raw
+        * data when an error occurs. The DumpEvent method should be used by the
+        * deriving components to actually dump data at the appropriate point.
+        * \note This facility is intended for debugging.
+        */
+       bool DumpDataOnError() const { return fDumpDataOnError; }
+
+       /**
+        * Returns the path where the dump files will be written to by the Dump*
+        * methods. Defaults to the current working directory.
+        * \note This facility is intended for debugging.
+        */
+       const char* DumpPath() const { return fDumpPath; }
+
+       /**
         * Method to check the block structure and log appropriate error messages.
         * If a problem is found with the data block then an appropriate HLT error
         * message is logged and the method returns false.
@@ -272,6 +339,44 @@ protected:
         */
        int LoadRecoParamsFromCDB(AliMUONRecoParam*& params) const;
 
+       /**
+        * Dumps the data contained in a buffer to file as is.
+        */
+       void DumpBuffer(
+                       const void* buffer, AliHLTUInt32_t size,
+                       const char* filename
+               ) const;
+
+       /**
+        * Dumps the data block to file.
+        */
+       void DumpBlock(
+                       const AliHLTComponentBlockData* block,
+                       const char* fileNamePrefix
+               ) const;
+       
+       /**
+        * Dumps the event information to files in the dump path given by the
+        * method DumpPath, which can be set by the command line argument -dumppath.
+        */
+       void DumpEvent(
+                       const AliHLTComponentEventData& evtData,
+                       const AliHLTComponentBlockData* blocks,
+                       AliHLTComponentTriggerData& trigData,
+                       AliHLTUInt8_t* outputPtr,
+                       AliHLTUInt32_t& size,
+                       AliHLTComponentBlockDataList& outputBlocks
+               ) const;
+       
+       /**
+        * Dumps the event information to files in the dump path given by the
+        * method DumpPath, which can be set by the command line argument -dumppath.
+        */
+       void DumpEvent(
+                       const AliHLTComponentEventData& evtData,
+                       AliHLTComponentTriggerData& trigData
+               ) const;
+
 private:
 
        // Do not allow copying of this class.
@@ -279,6 +384,11 @@ private:
        AliHLTMUONProcessor(const AliHLTMUONProcessor& /*obj*/);
        /// Not implemented.
        AliHLTMUONProcessor& operator = (const AliHLTMUONProcessor& /*obj*/);
+
+       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.
+       bool fDumpDataOnError; ///< Flag indicating if we should dump data when an error occurs in the reconstruction class.
+       const char* fDumpPath; ///< This is the path prefix to use to dump event data too when an error occurs.
        
        ClassDef(AliHLTMUONProcessor, 0)  // Abstract base class for dHLT specific components.
 };
index 12b5cf0..b643461 100644 (file)
@@ -596,7 +596,7 @@ int AliHLTMUONDigitPublisherComponent::GetEvent(
                AliHLTComponentTriggerData& /*trigData*/,
                AliHLTUInt8_t* outputPtr,
                AliHLTUInt32_t& size,
-               vector<AliHLTComponentBlockData>& outputBlocks
+               AliHLTComponentBlockDataList& outputBlocks
        )
 {
        /// Inherited from AliHLTOfflineDataSource.
index fb7dc1b..cdfcd6f 100644 (file)
@@ -102,7 +102,7 @@ protected:
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr,
                        AliHLTUInt32_t& size,
-                       vector<AliHLTComponentBlockData>& outputBlocks
+                       AliHLTComponentBlockDataList& outputBlocks
                );
        
        using AliHLTOfflineDataSource::GetEvent;
index 78f85e2..388a530 100644 (file)
@@ -63,18 +63,41 @@ AliHLTMUONESDMaker::~AliHLTMUONESDMaker()
 }
 
 
+bool AliHLTMUONESDMaker::IgnoreArgument(const char* arg) const
+{
+       /// Return true if the argument is one of -cdbpath -run or -delaysetup
+       /// to prevent the parent class from parsing these arguments in DoInit.
+       
+       if (strcmp(arg, "-cdbpath") == 0 or strcmp(arg, "-run") != 0 or
+           strcmp(arg, "-delaysetup") != 0)
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+}
+
+
 int AliHLTMUONESDMaker::DoInit(int argc, const char** argv)
 {
        /// Inherited from AliHLTComponent.
        /// Parses the command line parameters and initialises the component.
        
        HLTInfo("Initialising dHLT ESD maker component.");
+
+       // Inherit the parents functionality.
+       int result = AliHLTMUONProcessor::DoInit(argc, argv);
+       if (result != 0) return result;
        
        fWarnForUnexpecedBlock = false;
        fMakeMinimalESD = false;
        
        for (int i = 0; i < argc; i++)
        {
+               if (ArgumentAlreadyHandled(i, argv[i])) continue;
+
                if (strcmp(argv[i], "-make_minimal_esd") == 0)
                {
                        fMakeMinimalESD = true;
@@ -121,9 +144,7 @@ AliHLTComponentDataType AliHLTMUONESDMaker::GetOutputDataType()
 }
 
 
-void AliHLTMUONESDMaker::GetInputDataTypes(
-               vector<AliHLTComponentDataType>& list
-       )
+void AliHLTMUONESDMaker::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
        /// Inherited from AliHLTProcessor.
        /// Returns the list of expected input data types.
@@ -154,8 +175,8 @@ AliHLTComponent* AliHLTMUONESDMaker::Spawn()
 
 
 int AliHLTMUONESDMaker::DoEvent(
-               const AliHLTComponentEventData& /*evtData*/,
-               AliHLTComponentTriggerData& /*trigData*/
+               const AliHLTComponentEventData& evtData,
+               AliHLTComponentTriggerData& trigData
        )
 {
        /// Inherited from AliHLTProcessor. Processes the new event data.
@@ -197,7 +218,11 @@ int AliHLTMUONESDMaker::DoEvent(
                {
                        specification |= block->fSpecification;
                        AliHLTMUONTriggerRecordsBlockReader inblock(block->fPtr, block->fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, trigData);
+                               continue;
+                       }
                        
                        for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
                        {
@@ -231,7 +256,11 @@ int AliHLTMUONESDMaker::DoEvent(
        {
                specification |= block->fSpecification;
                AliHLTMUONMansoTracksBlockReader inblock(block->fPtr, block->fSize);
-               if (not BlockStructureOk(inblock)) continue;
+               if (not BlockStructureOk(inblock))
+               {
+                       if (DumpDataOnError()) DumpEvent(evtData, trigData);
+                       continue;
+               }
                
                for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
                {
index c46c735..79efbc8 100644 (file)
@@ -47,7 +47,7 @@ public:
        
        virtual const char* GetComponentID();
 
-       virtual void GetInputDataTypes(vector<AliHLTComponentDataType>& list);
+       virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
        virtual AliHLTComponentDataType GetOutputDataType();
        virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
 
@@ -58,6 +58,7 @@ protected:
        virtual int DoInit(int argc, const char** argv);
        virtual int DoDeinit();
        virtual int DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
+       virtual bool IgnoreArgument(const char* arg) const;
        using AliHLTProcessor::DoEvent;
        
 private:
index 594cfd4..c3fd2e0 100644 (file)
@@ -380,7 +380,7 @@ int AliHLTMUONRecHitsSource::GetEvent(
                AliHLTComponentTriggerData& /*trigData*/,
                AliHLTUInt8_t* outputPtr, 
                AliHLTUInt32_t& size,
-               vector<AliHLTComponentBlockData>& outputBlocks
+               AliHLTComponentBlockDataList& outputBlocks
        )
 {
        ///
index c509a16..c43b228 100644 (file)
@@ -85,7 +85,7 @@ protected:
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr, 
                        AliHLTUInt32_t& size,
-                       vector<AliHLTComponentBlockData>& outputBlocks
+                       AliHLTComponentBlockDataList& outputBlocks
                );
        
        using AliHLTOfflineDataSource::GetEvent;
index bd6943e..a052301 100644 (file)
@@ -55,6 +55,23 @@ AliHLTMUONRootifierComponent::~AliHLTMUONRootifierComponent()
 }
 
 
+bool AliHLTMUONRootifierComponent::IgnoreArgument(const char* arg) const
+{
+       /// Return true if the argument is one of -cdbpath -run or -delaysetup
+       /// to prevent the parent class from parsing these arguments in DoInit.
+       
+       if (strcmp(arg, "-cdbpath") == 0 or strcmp(arg, "-run") != 0 or
+           strcmp(arg, "-delaysetup") != 0)
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+}
+
+
 int AliHLTMUONRootifierComponent::DoInit(int argc, const char** argv)
 {
        ///
@@ -63,11 +80,17 @@ int AliHLTMUONRootifierComponent::DoInit(int argc, const char** argv)
        ///
        
        HLTInfo("Initialising dHLT rootifier component.");
+
+       // Inherit the parents functionality.
+       int result = AliHLTMUONProcessor::DoInit(argc, argv);
+       if (result != 0) return result;
        
        fWarnForUnexpecedBlock = false;
        
        for (int i = 0; i < argc; i++)
        {
+               if (ArgumentAlreadyHandled(i, argv[i])) continue;
+
                if (strcmp(argv[i], "-warn_on_unexpected_block") == 0)
                {
                        fWarnForUnexpecedBlock = true;
@@ -121,9 +144,7 @@ int AliHLTMUONRootifierComponent::GetOutputDataTypes(AliHLTComponentDataTypeList
 }
 
 
-void AliHLTMUONRootifierComponent::GetInputDataTypes(
-               vector<AliHLTComponentDataType>& list
-       )
+void AliHLTMUONRootifierComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
        ///
        /// Inherited from AliHLTProcessor. Returns the list of expected input data types.
@@ -158,7 +179,7 @@ AliHLTComponent* AliHLTMUONRootifierComponent::Spawn()
 
 int AliHLTMUONRootifierComponent::DoEvent(
                const AliHLTComponentEventData& evtData,
-               AliHLTComponentTriggerData& /*trigData*/
+               AliHLTComponentTriggerData& trigData
        )
 {
        ///
@@ -183,7 +204,11 @@ int AliHLTMUONRootifierComponent::DoEvent(
                {
                        specification |= block->fSpecification;
                        AliHLTMUONRecHitsBlockReader inblock(block->fPtr, block->fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, trigData);
+                               continue;
+                       }
                        
                        // Decode the source DDL from the specification bits.
                        Int_t sourceDDL = -1;
@@ -223,7 +248,11 @@ int AliHLTMUONRootifierComponent::DoEvent(
                {
                        specification |= block->fSpecification;
                        AliHLTMUONTriggerRecordsBlockReader inblock(block->fPtr, block->fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, trigData);
+                               continue;
+                       }
                        
                        // Decode the source DDL from the specification bits.
                        Int_t sourceDDL = -1;
@@ -301,7 +330,11 @@ int AliHLTMUONRootifierComponent::DoEvent(
        {
                specification |= block->fSpecification;
                AliHLTMUONMansoTracksBlockReader inblock(block->fPtr, block->fSize);
-               if (not BlockStructureOk(inblock)) continue;
+               if (not BlockStructureOk(inblock))
+               {
+                       if (DumpDataOnError()) DumpEvent(evtData, trigData);
+                       continue;
+               }
                
                for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
                {
@@ -411,7 +444,11 @@ int AliHLTMUONRootifierComponent::DoEvent(
                decisionBlockFound = true;
                specification |= block->fSpecification;
                AliHLTMUONSinglesDecisionBlockReader inblock(block->fPtr, block->fSize);
-               if (not BlockStructureOk(inblock)) continue;
+               if (not BlockStructureOk(inblock))
+               {
+                       if (DumpDataOnError()) DumpEvent(evtData, trigData);
+                       continue;
+               }
                
                numLowPt += inblock.BlockHeader().fNlowPt;
                numHighPt += inblock.BlockHeader().fNhighPt;
@@ -472,7 +509,11 @@ int AliHLTMUONRootifierComponent::DoEvent(
                decisionBlockFound = true;
                specification |= block->fSpecification;
                AliHLTMUONPairsDecisionBlockReader inblock(block->fPtr, block->fSize);
-               if (not BlockStructureOk(inblock)) continue;
+               if (not BlockStructureOk(inblock))
+               {
+                       if (DumpDataOnError()) DumpEvent(evtData, trigData);
+                       continue;
+               }
                
                numUnlikeAnyPt += inblock.BlockHeader().fNunlikeAnyPt;
                numUnlikeLowPt += inblock.BlockHeader().fNunlikeLowPt;
index c50e7d1..6bca3dc 100644 (file)
@@ -27,7 +27,7 @@ public:
        
        virtual const char* GetComponentID();
 
-       virtual void GetInputDataTypes(vector<AliHLTComponentDataType>& list);
+       virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
        virtual AliHLTComponentDataType GetOutputDataType();
        virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
        virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
@@ -39,6 +39,7 @@ protected:
        virtual int DoInit(int argc, const char** argv);
        virtual int DoDeinit();
        virtual int DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
+       virtual bool IgnoreArgument(const char* arg) const;
        using AliHLTProcessor::DoEvent;
        
 private:
index 8fe8f3a..72cc71c 100644 (file)
@@ -392,7 +392,7 @@ int AliHLTMUONTriggerRecordsSource::GetEvent(
                AliHLTComponentTriggerData& /*trigData*/,
                AliHLTUInt8_t* outputPtr, 
                AliHLTUInt32_t& size,
-               vector<AliHLTComponentBlockData>& outputBlocks
+               AliHLTComponentBlockDataList& outputBlocks
        )
 {
        ///
index d3d09bf..2d92063 100644 (file)
@@ -85,7 +85,7 @@ protected:
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr, 
                        AliHLTUInt32_t& size,
-                       vector<AliHLTComponentBlockData>& outputBlocks
+                       AliHLTComponentBlockDataList& outputBlocks
                );
        
        using AliHLTOfflineDataSource::GetEvent;
index ba4e915..a892b68 100644 (file)
@@ -58,7 +58,6 @@ AliHLTMUONDecisionComponent::AliHLTMUONDecisionComponent() :
        fLowMassCut(2.5),  // 2.7 GeV/c^2 cut
        fHighMassCut(7.),  // 8 GeV/c^2 cut
        fWarnForUnexpecedBlock(false),
-       fDelaySetup(false),
        fLowPtCutSet(false),
        fHighPtCutSet(false),
        fLowMassCutSet(false),
@@ -93,9 +92,7 @@ const char* AliHLTMUONDecisionComponent::GetComponentID()
 }
 
 
-void AliHLTMUONDecisionComponent::GetInputDataTypes(
-               vector<AliHLTComponentDataType>& list
-       )
+void AliHLTMUONDecisionComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
        ///
        /// Inherited from AliHLTProcessor. Returns the list of expected input data types.
@@ -159,8 +156,11 @@ int AliHLTMUONDecisionComponent::DoInit(int argc, const char** argv)
        
        HLTInfo("Initialising dHLT trigger decision component.");
        
+       // Inherit the parents functionality.
+       int result = AliHLTMUONProcessor::DoInit(argc, argv);
+       if (result != 0) return result;
+
        fWarnForUnexpecedBlock = false;
-       fDelaySetup = false;
        fLowPtCutSet = false;
        fHighPtCutSet = false;
        fLowMassCutSet = false;
@@ -168,65 +168,10 @@ int AliHLTMUONDecisionComponent::DoInit(int argc, const char** argv)
        fFillSinglesDetail = true;
        fFillPairsDetail = true;
        
-       const char* cdbPath = NULL;
-       Int_t run = -1;
-       
        for (int i = 0; i < argc; i++)
        {
-               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." );
-                               return -EINVAL;
-                       }
-                       cdbPath = argv[i+1];
-                       i++;
-                       continue;
-               }
-       
-               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." );
-                               return -EINVAL;
-                       }
-                       
-                       char* cpErr = NULL;
-                       run = Int_t( strtoul(argv[i+1], &cpErr, 0) );
-                       if (cpErr == NULL or *cpErr != '\0')
-                       {
-                               HLTError("Cannot convert '%s' to a valid run number."
-                                       " Expected a positive integer value.", argv[i+1]
-                               );
-                               return -EINVAL;
-                       }
-                       
-                       i++;
-                       continue;
-               }
-               
-               if (strcmp( argv[i], "-delaysetup" ) == 0)
-               {
-                       fDelaySetup = true;
-                       continue;
-               }
-               
+               if (ArgumentAlreadyHandled(i, argv[i])) continue;
+
                if (strcmp( argv[i], "-lowptcut" ) == 0)
                {
                        if (fLowPtCutSet)
@@ -365,13 +310,7 @@ int AliHLTMUONDecisionComponent::DoInit(int argc, const char** argv)
                return -EINVAL;
        }
        
-       if (cdbPath != NULL or run != -1)
-       {
-               int result = SetCDBPathAndRunNo(cdbPath, run);
-               if (result != 0) return result;
-       }
-       
-       if (not fDelaySetup)
+       if (not DelaySetup())
        {
                // Read cut parameters from CDB if they were not specified on the command line.
                if (not fLowPtCutSet or not fHighPtCutSet or not fLowMassCutSet or not fHighMassCutSet)
@@ -455,10 +394,10 @@ int AliHLTMUONDecisionComponent::ReadPreprocessorValues(const char* modules)
 int AliHLTMUONDecisionComponent::DoEvent(
                const AliHLTComponentEventData& evtData,
                const AliHLTComponentBlockData* blocks,
-               AliHLTComponentTriggerData& /*trigData*/,
+               AliHLTComponentTriggerData& trigData,
                AliHLTUInt8_t* outputPtr,
                AliHLTUInt32_t& size,
-               std::vector<AliHLTComponentBlockData>& outputBlocks
+               AliHLTComponentBlockDataList& outputBlocks
        )
 {
        ///
@@ -467,7 +406,7 @@ int AliHLTMUONDecisionComponent::DoEvent(
        
        // Initialise the cut parameters from CDB if we were requested to
        // initialise only when the first event was received.
-       if (fDelaySetup)
+       if (DelaySetup())
        {
                // Load the cut paramters from CDB if they have not been given
                // on the command line.
@@ -481,7 +420,7 @@ int AliHLTMUONDecisionComponent::DoEvent(
                        if (result != 0) return result;
                }
                
-               fDelaySetup = false;
+               DoneDelayedSetup();
        }
        
        AliHLTUInt32_t specification = 0;  // Contains the output data block spec bits.
@@ -503,13 +442,18 @@ int AliHLTMUONDecisionComponent::DoEvent(
                        specification |= blocks[n].fSpecification;
                        
                        AliHLTMUONMansoTracksBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+                               continue;
+                       }
                        
                        for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++)
                        {
                                int result = AddTrack(&inblock[i]);
                                if (result != 0)
                                {
+                                       if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
                                        size = 0; // Important to tell framework that nothing was generated.
                                        return result;
                                }
@@ -543,6 +487,7 @@ int AliHLTMUONDecisionComponent::DoEvent(
                        " %d bytes for the singles output data block.",
                        size, sizeof(AliHLTMUONSinglesDecisionBlockWriter::HeaderType)
                );
+               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
                size = 0; // Important to tell framework that nothing was generated.
                return -ENOBUFS;
        }
@@ -557,6 +502,7 @@ int AliHLTMUONDecisionComponent::DoEvent(
                        " %d bytes for the singles output data block.",
                        size, bytesneeded
                );
+               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
                size = 0; // Important to tell framework that nothing was generated.
                return -ENOBUFS;
        }
@@ -576,6 +522,7 @@ int AliHLTMUONDecisionComponent::DoEvent(
                        size,
                        sizeof(AliHLTMUONPairsDecisionBlockWriter::HeaderType) + singlesBlock.BytesUsed()
                );
+               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
                size = 0; // Important to tell framework that nothing was generated.
                return -ENOBUFS;
        }
@@ -591,6 +538,7 @@ int AliHLTMUONDecisionComponent::DoEvent(
                        " %d bytes for the pairs output data block.",
                        size, bytesneeded
                );
+               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
                size = 0; // Important to tell framework that nothing was generated.
                return -ENOBUFS;
        }
index b6eb602..82cb8fd 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "AliHLTMUONProcessor.h"
 #include "AliHLTMUONDataTypes.h"
-#include <vector>
 
 #if __GNUC__ && __GNUC__ < 3
 #define std
@@ -75,7 +74,7 @@ protected:
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr,
                        AliHLTUInt32_t& size,
-                       std::vector<AliHLTComponentBlockData>& outputBlocks
+                       AliHLTComponentBlockDataList& outputBlocks
                );
        
        using AliHLTProcessor::DoEvent;
@@ -116,7 +115,6 @@ private:
        AliHLTFloat32_t fLowMassCut;  /// The low invariant mass cut value to apply to tracks. [GeV/c^2]
        AliHLTFloat32_t fHighMassCut;  /// The high invariant mass cut value to apply to tracks. [GeV/c^2]
        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.
        bool fLowPtCutSet; ///< Indicates if the low pT cut parameter was set on the command line.
        bool fHighPtCutSet; ///< Indicates if the high pT cut parameter was set on the command line.
        bool fLowMassCutSet; ///< Indicates if the low invariant mass cut parameter was set on the command line.
index e63f371..54254f2 100644 (file)
@@ -76,8 +76,7 @@ AliHLTMUONHitReconstructorComponent::AliHLTMUONHitReconstructorComponent() :
        fLutSize(0),
        fLut(NULL),
        fIdToEntry(),
-       fWarnForUnexpecedBlock(false),
-       fDelaySetup(false)
+       fWarnForUnexpecedBlock(false)
 {
        ///
        /// Default constructor.
@@ -111,7 +110,7 @@ const char* AliHLTMUONHitReconstructorComponent::GetComponentID()
 }
 
 
-void AliHLTMUONHitReconstructorComponent::GetInputDataTypes( std::vector<AliHLTComponentDataType>& list)
+void AliHLTMUONHitReconstructorComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
        ///
        /// Inherited from AliHLTProcessor. Returns the list of expected input data types.
@@ -132,7 +131,7 @@ AliHLTComponentDataType AliHLTMUONHitReconstructorComponent::GetOutputDataType()
 }
 
 
-void AliHLTMUONHitReconstructorComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+void AliHLTMUONHitReconstructorComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
 {
        ///
        /// Inherited from AliHLTComponent. Returns an estimate of the expected output data size.
@@ -161,37 +160,34 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
        ///
 
        HLTInfo("Initialising dHLT hit reconstruction component.");
+
+       // Inherit the parents functionality.
+       int result = AliHLTMUONProcessor::DoInit(argc, argv);
+       if (result != 0) return result;
        
        // Must make sure that fHitRec and fLut is deleted if it is still
        // allocated for whatever reason.
        FreeMemory();
        
-       try
-       {
-               fHitRec = new AliHLTMUONHitReconstructor();
-       }
-       catch (const std::bad_alloc&)
-       {
-               HLTError("Could not allocate more memory for the hit reconstructor component.");
-               return -ENOMEM;
-       }
-       
        // Initialise fields with default values then parse the command line.
        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++)
        {
-               HLTDebug("argv[%d] == %s", i, argv[i]);
+               // To keep the legacy behaviour we need to have the following check
+               // for -cdbpath here, before ArgumentAlreadyHandled.
+               if (strcmp(argv[i], "-cdbpath") == 0)
+               {
+                       useCDB = true;
+               }
+
+               if (ArgumentAlreadyHandled(i, argv[i])) continue;
                
                if (strcmp( argv[i], "-ddl" ) == 0)
                {
@@ -205,7 +201,6 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                        if (argc <= i+1)
                        {
                                HLTError("The DDL number was not specified. Must be in the range [13..20].");
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -214,13 +209,11 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                        if (cpErr == NULL or *cpErr != '\0')
                        {
                                HLTError("Cannot convert '%s' to DDL a number.", argv[i+1] );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        if (num < 13 or 20 < num)
                        {
                                HLTError("The DDL number must be in the range [13..20].");
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        fDDL = num - 1;  // convert to range [12..19]
@@ -241,7 +234,6 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                        if ( argc <= i+1 )
                        {
                                HLTError("DDL equipment ID number not specified. It must be in the range [2572..2579]" );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                
@@ -250,14 +242,12 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                        if (cpErr == NULL or *cpErr != '\0')
                        {
                                HLTError("Cannot convert '%s' to a DDL equipment ID Number.", argv[i+1]);
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        fDDL = AliHLTMUONUtils::EquipIdToDDLNumber(num); // Convert to DDL number in the range 0..21
                        if (fDDL < 12 or 19 < fDDL)
                        {
                                HLTError("The DDL equipment ID number must be in the range [2572..2579].");
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -277,7 +267,6 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                        if (argc <= i+1)
                        {
                                HLTError("The lookup table filename was not specified.");
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        lutFileName = argv[i+1];
@@ -291,58 +280,6 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                        continue;
                } // -cdb argument
                
-               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." );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
-                               return -EINVAL;
-                       }
-                       cdbPath = argv[i+1];
-                       useCDB = true;
-                       i++;
-                       continue;
-               } // -cdb argument
-       
-               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." );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
-                               return -EINVAL;
-                       }
-                       
-                       char* cpErr = NULL;
-                       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 a positive integer value.", argv[i+1]
-                               );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
-                               return -EINVAL;
-                       }
-                       
-                       i++;
-                       continue;
-               } // -run argument
-       
                if (strcmp( argv[i], "-dccut" ) == 0)
                {
                        if (dccut != -1)
@@ -355,7 +292,6 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                        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;
                        }
                        
@@ -366,7 +302,6 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                                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;
                        }
                        
@@ -374,12 +309,6 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                        continue;
                }
                
-               if (strcmp( argv[i], "-delaysetup" ) == 0)
-               {
-                       fDelaySetup = true;
-                       continue;
-               }
-               
                if (strcmp( argv[i], "-warn_on_unexpected_block" ) == 0)
                {
                        fWarnForUnexpecedBlock = true;
@@ -393,11 +322,20 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
                }
        
                HLTError("Unknown option '%s'", argv[i]);
-               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                return -EINVAL;
        
        } // for loop
        
+       try
+       {
+               fHitRec = new AliHLTMUONHitReconstructor();
+       }
+       catch (const std::bad_alloc&)
+       {
+               HLTError("Could not allocate more memory for the hit reconstructor component.");
+               return -ENOMEM;
+       }
+       
        if (dccut != -1 and useCDB)
        {
                HLTWarning("The -cdb or -cdbpath parameter was specified, which indicates that"
@@ -417,25 +355,14 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
        
        if (lutFileName == NULL) useCDB = true;
        
-       if (fDDL == -1 and not fDelaySetup)
+       if (fDDL == -1 and not DelaySetup())
        {
                HLTWarning("DDL number not specified. Cannot check if incomming data is valid.");
        }
        
-       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)
        {
-               if (not fDelaySetup)
+               if (not DelaySetup())
                {
                        HLTInfo("Loading lookup table information from CDB for DDL %d (ID = %d).",
                                fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
@@ -465,7 +392,7 @@ int AliHLTMUONHitReconstructorComponent::DoInit(int argc, const char** argv)
        
        if (dccut == -1)
        {
-               if (not fDelaySetup)
+               if (not DelaySetup())
                {
                        HLTInfo("Loading DC cut parameters from CDB for DDL %d (ID = %d).",
                                fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
@@ -582,19 +509,19 @@ int AliHLTMUONHitReconstructorComponent::ReadPreprocessorValues(const char* modu
 int AliHLTMUONHitReconstructorComponent::DoEvent(
                const AliHLTComponentEventData& evtData,
                const AliHLTComponentBlockData* blocks,
-               AliHLTComponentTriggerData& /*trigData*/,
+               AliHLTComponentTriggerData& trigData,
                AliHLTUInt8_t* outputPtr,
                AliHLTUInt32_t& size,
-               std::vector<AliHLTComponentBlockData>& outputBlocks
+               AliHLTComponentBlockDataList& outputBlocks
        )
 {
        ///
        /// 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)
+       if (DelaySetup())
        {
                // Use the specification given by the first data block if we
                // have not been given a DDL number on the command line.
@@ -651,7 +578,7 @@ int AliHLTMUONHitReconstructorComponent::DoEvent(
                        if (result != 0) return result;
                }
                
-               fDelaySetup = false;
+               DoneDelayedSetup();
        }
        
        if (fLut == NULL)
@@ -733,6 +660,7 @@ int AliHLTMUONHitReconstructorComponent::DoEvent(
                if (not fHitRec->Run(buffer, ddlRawDataSize, block.GetArray(), nofHit))
                {
                        HLTError("Error while processing the hit reconstruction algorithm.");
+                       if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
                        size = totalSize; // Must tell the framework how much buffer space was used.
                        return -EIO;
                }
index 87329b1..0a90a82 100644 (file)
@@ -124,9 +124,9 @@ public:
        // These functions are required for the registration process
 
        virtual const char* GetComponentID();
-       virtual void GetInputDataTypes(std::vector<AliHLTComponentDataType>& list);
+       virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
        virtual AliHLTComponentDataType GetOutputDataType();
-       virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+       virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
        virtual AliHLTComponent* Spawn();
        
        /**
@@ -160,7 +160,7 @@ protected:
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr,
                        AliHLTUInt32_t& size,
-                       std::vector<AliHLTComponentBlockData>& outputBlocks
+                       AliHLTComponentBlockDataList& outputBlocks
                );
        
        using AliHLTProcessor::DoEvent;
@@ -184,7 +184,6 @@ 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 3cbcdfe..fa70206 100644 (file)
@@ -48,7 +48,6 @@ AliHLTMUONMansoTrackerFSMComponent::AliHLTMUONMansoTrackerFSMComponent() :
        fBlock(NULL),
        fRecHitBlockArraySize(0),
        fWarnForUnexpecedBlock(false),
-       fDelaySetup(false),
        fCanLoadZmiddle(true),
        fCanLoadBL(true)
 {
@@ -93,7 +92,7 @@ const char* AliHLTMUONMansoTrackerFSMComponent::GetComponentID()
 
 
 void AliHLTMUONMansoTrackerFSMComponent::GetInputDataTypes(
-               vector<AliHLTComponentDataType>& list
+               AliHLTComponentDataTypeList& list
        )
 {
        ///
@@ -148,27 +147,16 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
        
        HLTInfo("Initialising dHLT manso tracker FSM component.");
        
+       // Inherit the parents functionality.
+       int result = AliHLTMUONProcessor::DoInit(argc, argv);
+       if (result != 0) return result;
+
        // Just in case for whatever reason we still have some of the internal
        // object allocated previously still hanging around delete them now.
        FreeMemory();
        
-       try
-       {
-               fTracker = new AliHLTMUONMansoTrackerFSM();
-       }
-       catch (const std::bad_alloc&)
-       {
-               HLTError("Could not allocate more memory for the tracker component.");
-               return -ENOMEM;
-       }
-       fTracker->SetCallback(this);
-       
        fWarnForUnexpecedBlock = false;
-       fDelaySetup = false;
        ResetCanLoadFlags();
-       
-       const char* cdbPath = NULL;
-       Int_t run = -1;
        double zmiddle = 0;
        double bfieldintegral = 0;
        double roiA[4] = {0, 0, 0, 0};
@@ -177,57 +165,8 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
        
        for (int i = 0; i < argc; i++)
        {
-               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." );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
-                               return -EINVAL;
-                       }
-                       cdbPath = argv[i+1];
-                       i++;
-                       continue;
-               }
-       
-               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." );
-                               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')
-                       {
-                               HLTError("Cannot convert '%s' to a valid run number."
-                                       " Expected a positive integer value.", argv[i+1]
-                               );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
-                               return -EINVAL;
-                       }
-                       
-                       i++;
-                       continue;
-               }
-       
+               if (ArgumentAlreadyHandled(i, argv[i])) continue;
+
                if (strcmp( argv[i], "-zmiddle" ) == 0)
                {
                        if (not fCanLoadZmiddle)
@@ -240,7 +179,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                        if ( argc <= i+1 )
                        {
                                HLTError("The Z coordinate for the middle of the dipole was not specified." );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -251,7 +189,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                                HLTError("Cannot convert '%s' to a valid floating point number.",
                                        argv[i+1]
                                );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -272,7 +209,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                        if ( argc <= i+1 )
                        {
                                HLTError("The magnetic field integral was not specified." );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -283,7 +219,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                                HLTError("Cannot convert '%s' to a valid floating point number.",
                                        argv[i+1]
                                );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -316,7 +251,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                        if ( argc <= i+1 )
                        {
                                HLTError("The region of interest parameter was not specified." );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -327,7 +261,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                                HLTError("Cannot convert '%s' to a valid floating point number.",
                                        argv[i+1]
                                );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -360,7 +293,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                        if ( argc <= i+1 )
                        {
                                HLTError("The region of interest parameter was not specified." );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -371,7 +303,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                                HLTError("Cannot convert '%s' to a valid floating point number.",
                                        argv[i+1]
                                );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -412,7 +343,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                        if ( argc <= i+1 )
                        {
                                HLTError("The region of interest parameter was not specified." );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -423,7 +353,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                                HLTError("Cannot convert '%s' to a valid floating point number.",
                                        argv[i+1]
                                );
-                               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                                return -EINVAL;
                        }
                        
@@ -432,12 +361,6 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                        continue;
                }
                
-               if (strcmp( argv[i], "-delaysetup" ) == 0)
-               {
-                       fDelaySetup = true;
-                       continue;
-               }
-               
                if (strcmp(argv[i], "-warn_on_unexpected_block") == 0)
                {
                        fWarnForUnexpecedBlock = true;
@@ -445,20 +368,19 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
                }
 
                HLTError("Unknown option '%s'.", argv[i]);
-               FreeMemory(); // Make sure we cleanup to avoid partial initialisation.
                return -EINVAL;
        }
        
-       if (cdbPath != NULL or run != -1)
+       try
        {
-               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;
-               }
+               fTracker = new AliHLTMUONMansoTrackerFSM();
+       }
+       catch (const std::bad_alloc&)
+       {
+               HLTError("Could not allocate more memory for the tracker component.");
+               return -ENOMEM;
        }
+       fTracker->SetCallback(this);
        
        // Set all the parameters that were found on the command line.
        if (not fCanLoadZmiddle) AliHLTMUONCalculations::Zf(zmiddle);
@@ -478,7 +400,7 @@ int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv)
        if (not fCanLoadZ[4]) fTracker->SetZ11(chamberZ[4]);
        if (not fCanLoadZ[5]) fTracker->SetZ13(chamberZ[5]);
        
-       if (not fDelaySetup)
+       if (not DelaySetup())
        {
                if (AtLeastOneCanLoadFlagsIsSet())
                {
@@ -748,10 +670,10 @@ int AliHLTMUONMansoTrackerFSMComponent::DoDeinit()
 int AliHLTMUONMansoTrackerFSMComponent::DoEvent(
                const AliHLTComponentEventData& evtData,
                const AliHLTComponentBlockData* blocks,
-               AliHLTComponentTriggerData& /*trigData*/,
+               AliHLTComponentTriggerData& trigData,
                AliHLTUInt8_t* outputPtr,
                AliHLTUInt32_t& size,
-               std::vector<AliHLTComponentBlockData>& outputBlocks
+               AliHLTComponentBlockDataList& outputBlocks
        )
 {
        ///
@@ -760,7 +682,7 @@ int AliHLTMUONMansoTrackerFSMComponent::DoEvent(
        
        // Initialise the configuration parameters from CDB if we were
        // requested to initialise only when the first event was received.
-       if (fDelaySetup)
+       if (DelaySetup())
        {
                // Load the configuration paramters from CDB if they have not
                // been given on the command line.
@@ -771,7 +693,7 @@ int AliHLTMUONMansoTrackerFSMComponent::DoEvent(
                        if (result != 0) return result;
                }
                
-               fDelaySetup = false;
+               DoneDelayedSetup();
                ResetCanLoadFlags();  // From this point read all parameters from CDB.
        }
        
@@ -809,6 +731,7 @@ int AliHLTMUONMansoTrackerFSMComponent::DoEvent(
                        {
                                fRecHitBlock[i] = NULL;
                        }
+                       if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
                        return -ENOMEM;
                }
                // Only set the arrays' size once we have successfully allocated the memory for the arrays.
@@ -831,6 +754,7 @@ int AliHLTMUONMansoTrackerFSMComponent::DoEvent(
                        "The buffer is only %d bytes in size. We need a minimum of %d bytes.",
                        size, sizeof(AliHLTMUONMansoTracksBlockWriter::HeaderType)
                );
+               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
                size = 0; // Important to tell framework that nothing was generated.
                return -ENOBUFS;
        }
@@ -849,7 +773,11 @@ int AliHLTMUONMansoTrackerFSMComponent::DoEvent(
                        specification |= blocks[n].fSpecification;
                        
                        AliHLTMUONRecHitsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+                               continue;
+                       }
                        
                        if (inblock.Nentries() != 0)
                                AddRecHits(blocks[n].fSpecification, inblock.GetArray(), inblock.Nentries());
@@ -885,7 +813,11 @@ int AliHLTMUONMansoTrackerFSMComponent::DoEvent(
                        continue;
                
                AliHLTMUONTriggerRecordsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
-               if (not BlockStructureOk(inblock)) continue;
+               if (not BlockStructureOk(inblock))
+               {
+                       if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+                       continue;
+               }
                
                DebugTrace("Processing a trigger block with "
                        << inblock.Nentries() << " entries."
index b150d25..d3a3473 100644 (file)
@@ -31,7 +31,6 @@
 #include "AliHLTMUONProcessor.h"
 #include "AliHLTMUONDataTypes.h"
 #include "AliHLTMUONMansoTrackerFSMCallback.h"
-#include <vector>
 
 #if __GNUC__ && __GNUC__ < 3
 #define std
@@ -59,7 +58,7 @@ public:
        // Public functions to implement the AliHLTProcessor interface.
        // These functions are required for the registration process.
        virtual const char* GetComponentID();
-       virtual void GetInputDataTypes(std::vector<AliHLTComponentDataType>& list);
+       virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
        virtual AliHLTComponentDataType GetOutputDataType();
        virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
        virtual AliHLTComponent* Spawn();
@@ -90,7 +89,7 @@ protected:
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr,
                        AliHLTUInt32_t& size,
-                       std::vector<AliHLTComponentBlockData>& outputBlocks
+                       AliHLTComponentBlockDataList& outputBlocks
                );
        
        using AliHLTProcessor::DoEvent;
@@ -169,9 +168,7 @@ private:
        // The allocated memory is: 4 * fRecHitBlockArraySize * sizeof(AliRecHitBlockInfo).
        AliRecHitBlockInfo* fRecHitBlock[4];  //! Arrays of rec hit block data.
 
-       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.
-       
+       bool fWarnForUnexpecedBlock;  ///< Flag indicating if we should log a warning if we got a block of an unexpected type.  
        bool fCanLoadZmiddle;  ///< Indicates if the zmiddle parameter can be loaded from CDB.
        bool fCanLoadBL;  ///< Indicates if the bfieldintegral parameter can be loaded from CDB.
        bool fCanLoadA[4];  ///< Indicates if the roi_paramA_chamber[7..10] parameter can be loaded from CDB.
index 19b4346..4442377 100644 (file)
@@ -62,7 +62,6 @@ AliHLTMUONTriggerReconstructorComponent::AliHLTMUONTriggerReconstructorComponent
        fWarnForUnexpecedBlock(false),
        fStopOnOverflow(false),
        fUseCrateId(true),
-       fDelaySetup(false),
        fZmiddleSpecified(false),
        fBLSpecified(false),
        fLutInitialised(false)
@@ -93,7 +92,7 @@ const char* AliHLTMUONTriggerReconstructorComponent::GetComponentID()
 }
 
 
-void AliHLTMUONTriggerReconstructorComponent::GetInputDataTypes( std::vector<AliHLTComponentDataType>& list)
+void AliHLTMUONTriggerReconstructorComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
        ///
        /// Inherited from AliHLTProcessor. Returns the list of expected input data types.
@@ -144,10 +143,12 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
        /// Parses the command line parameters and initialises the component.
        ///
        
-       // perform initialization.
-       
        HLTInfo("Initialising dHLT trigger reconstructor component.");
        
+       // Inherit the parents functionality.
+       int result = AliHLTMUONProcessor::DoInit(argc, argv);
+       if (result != 0) return result;
+       
        // Make sure to cleanup fTrigRec if it is still there for some reason.
        if (fTrigRec != NULL)
        {
@@ -155,28 +156,15 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                fTrigRec = NULL;
        }
        
-       try
-       {
-               fTrigRec = new AliHLTMUONTriggerReconstructor();
-       }
-       catch (const std::bad_alloc&)
-       {
-               HLTError("Could not allocate more memory for the trigger reconstructor component.");
-               return -ENOMEM;
-       }
-       
        fDDL = -1;
        fWarnForUnexpecedBlock = false;
        fStopOnOverflow = false;
        fUseCrateId = true;
-       fDelaySetup = false;
        fZmiddleSpecified = false;
        fBLSpecified = false;
        fLutInitialised = false;
        
        const char* lutFileName = NULL;
-       const char* cdbPath = NULL;
-       Int_t run = -1;
        bool useCDB = false;
        bool suppressPartialTrigs = true;
        bool tryRecover = false;
@@ -186,6 +174,15 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
        
        for (int i = 0; i < argc; i++)
        {
+               // To keep the legacy behaviour we need to have the following check
+               // for -cdbpath here, before ArgumentAlreadyHandled.
+               if (strcmp(argv[i], "-cdbpath") == 0)
+               {
+                       useCDB = true;
+               }
+
+               if (ArgumentAlreadyHandled(i, argv[i])) continue;
+
                if (strcmp( argv[i], "-lut" ) == 0)
                {
                        if (lutFileName != NULL)
@@ -198,9 +195,6 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        if ( argc <= i+1 )
                        {
                                HLTError("The lookup table filename was not specified." );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
                                return -EINVAL;
                        }
                        
@@ -221,10 +215,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        
                        if ( argc <= i+1 )
                        {
-                               HLTError("DDL number not specified. It must be in the range [21..22]" );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
+                               HLTError("DDL number not specified. It must be in the range [21..22]");
                                return -EINVAL;
                        }
                
@@ -233,17 +224,11 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        if (cpErr == NULL or *cpErr != '\0')
                        {
                                HLTError("Cannot convert '%s' to a DDL Number.", argv[i+1]);
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
                                return -EINVAL;
                        }
                        if (num < 21 or 22 < num)
                        {
                                HLTError("The DDL number must be in the range [21..22].");
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
                                return -EINVAL;
                        }
                        fDDL = num - 1; // Convert to DDL number in the range 0..21
@@ -263,10 +248,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        
                        if ( argc <= i+1 )
                        {
-                               HLTError("DDL equipment ID number not specified. It must be in the range [2816..2817]" );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
+                               HLTError("DDL equipment ID number not specified. It must be in the range [2816..2817]");
                                return -EINVAL;
                        }
                
@@ -275,18 +257,12 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        if (cpErr == NULL or *cpErr != '\0')
                        {
                                HLTError("Cannot convert '%s' to a DDL equipment ID Number.", argv[i+1]);
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
                                return -EINVAL;
                        }
                        fDDL = AliHLTMUONUtils::EquipIdToDDLNumber(num); // Convert to DDL number in the range 0..21
                        if (fDDL < 20 or 21 < fDDL)
                        {
                                HLTError("The DDL equipment ID number must be in the range [2816..2817].");
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
                                return -EINVAL;
                        }
                        
@@ -299,64 +275,6 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        useCDB = true;
                        continue;
                }
-               
-               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." );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
-                               return -EINVAL;
-                       }
-                       cdbPath = argv[i+1];
-                       useCDB = true;
-                       i++;
-                       continue;
-               }
-       
-               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." );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
-                               return -EINVAL;
-                       }
-                       
-                       char* cpErr = NULL;
-                       run = Int_t( strtoul(argv[i+1], &cpErr, 0) );
-                       if (cpErr == NULL or *cpErr != '\0')
-                       {
-                               HLTError("Cannot convert '%s' to a valid run number."
-                                       " Expected a positive integer value.", argv[i+1]
-                               );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
-                               return -EINVAL;
-                       }
-                       
-                       i++;
-                       continue;
-               }
        
                if (strcmp( argv[i], "-zmiddle" ) == 0)
                {
@@ -369,10 +287,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        
                        if ( argc <= i+1 )
                        {
-                               HLTError("The Z coordinate for the middle of the dipole was not specified." );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
+                               HLTError("The Z coordinate for the middle of the dipole was not specified.");
                                return -EINVAL;
                        }
                        
@@ -383,9 +298,6 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                                HLTError("Cannot convert '%s' to a valid floating point number.",
                                        argv[i+1]
                                );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
                                return -EINVAL;
                        }
                        
@@ -406,9 +318,6 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        if ( argc <= i+1 )
                        {
                                HLTError("The magnetic field integral was not specified." );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
                                return -EINVAL;
                        }
                        
@@ -419,9 +328,6 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                                HLTError("Cannot convert '%s' to a valid floating point number.",
                                        argv[i+1]
                                );
-                               // Make sure to delete fTrigRec to avoid partial initialisation.
-                               delete fTrigRec;
-                               fTrigRec = NULL;
                                return -EINVAL;
                        }
                        
@@ -430,12 +336,6 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        continue;
                }
                
-               if (strcmp( argv[i], "-delaysetup" ) == 0)
-               {
-                       fDelaySetup = true;
-                       continue;
-               }
-               
                if (strcmp( argv[i], "-warn_on_unexpected_block" ) == 0)
                {
                        fWarnForUnexpecedBlock = true;
@@ -478,14 +378,21 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
                        continue;
                }
                
-               HLTError("Unknown option '%s'.", argv[i] );
-               // Make sure to delete fTrigRec to avoid partial initialisation.
-               delete fTrigRec;
-               fTrigRec = NULL;
+               HLTError("Unknown option '%s'.", argv[i]);
                return -EINVAL;
                
        } // for loop
        
+       try
+       {
+               fTrigRec = new AliHLTMUONTriggerReconstructor();
+       }
+       catch (const std::bad_alloc&)
+       {
+               HLTError("Could not allocate more memory for the trigger reconstructor component.");
+               return -ENOMEM;
+       }
+       
        if (fZmiddleSpecified and useCDB)
        {
                HLTWarning("The -cdb or -cdbpath parameter was specified, which indicates that"
@@ -513,26 +420,14 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
        
        if (lutFileName == NULL) useCDB = true;
        
-       if (fDDL == -1 and not fDelaySetup)
+       if (fDDL == -1 and not DelaySetup())
        {
                HLTWarning("DDL number not specified. Cannot check if incomming data is valid.");
        }
        
-       if (cdbPath != NULL or run != -1)
-       {
-               int result = SetCDBPathAndRunNo(cdbPath, run);
-               if (result != 0)
-               {
-                       // Error messages already generated in SetCDBPathAndRunNo.
-                       delete fTrigRec; // Make sure to delete fTrigRec to avoid partial initialisation.
-                       fTrigRec = NULL;
-                       return result;
-               }
-       }
-       
        if (useCDB)
        {
-               if (not fDelaySetup)
+               if (not DelaySetup())
                {
                        HLTInfo("Loading lookup table information from CDB for DDL %d (ID = %d).",
                                fDDL+1, AliHLTMUONUtils::DDLNumberToEquipId(fDDL)
@@ -565,7 +460,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
        if (fZmiddleSpecified) AliHLTMUONCalculations::Zf(zmiddle);
        if (fBLSpecified) AliHLTMUONCalculations::QBL(bfieldintegral);
        
-       if (not fDelaySetup)
+       if (not DelaySetup())
        {
                if (not fZmiddleSpecified or not fBLSpecified)
                {
@@ -621,10 +516,10 @@ int AliHLTMUONTriggerReconstructorComponent::DoDeinit()
 int AliHLTMUONTriggerReconstructorComponent::DoEvent(
                const AliHLTComponentEventData& evtData,
                const AliHLTComponentBlockData* blocks,
-               AliHLTComponentTriggerData& /*trigData*/,
+               AliHLTComponentTriggerData& trigData,
                AliHLTUInt8_t* outputPtr,
                AliHLTUInt32_t& size,
-               std::vector<AliHLTComponentBlockData>& outputBlocks
+               AliHLTComponentBlockDataList& outputBlocks
        )
 {
        ///
@@ -633,7 +528,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoEvent(
        
        // Initialise the LUT and configuration parameters from CDB if we were
        // requested to initialise only when the first event was received.
-       if (fDelaySetup)
+       if (DelaySetup())
        {
                // Use the specification given by the first data block if we
                // have not been given a DDL number on the command line.
@@ -690,7 +585,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoEvent(
                        if (result != 0) return result;
                }
                
-               fDelaySetup = false;
+               DoneDelayedSetup();
        }
        
        // Process an event
@@ -780,6 +675,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoEvent(
                if (not runOk)
                {
                        HLTError("Error while processing the trigger DDL reconstruction algorithm.");
+                       if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
                        if (not fTrigRec->OverflowedOutputBuffer()
                            or (fTrigRec->OverflowedOutputBuffer() and fStopOnOverflow)
                           )
index b1dc058..d24b218 100644 (file)
@@ -36,7 +36,7 @@ public:
        // These functions are required for the registration process
 
        virtual const char* GetComponentID();
-       virtual void GetInputDataTypes( std::vector<AliHLTComponentDataType>& list);
+       virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
        virtual AliHLTComponentDataType GetOutputDataType();
        virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
        virtual AliHLTComponent* Spawn();
@@ -75,7 +75,7 @@ protected:
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr,
                        AliHLTUInt32_t& size,
-                       std::vector<AliHLTComponentBlockData>& outputBlocks
+                       AliHLTComponentBlockDataList& outputBlocks
                );
        
        using AliHLTProcessor::DoEvent;
@@ -109,7 +109,6 @@ private:
        bool fWarnForUnexpecedBlock;  ///< Flag indicating if we should log a warning if we got a block of an unexpected type.
        bool fStopOnOverflow;  ///< Flag indicating if we should fail in the DoEvent method if the output buffer was overflowed.
        bool fUseCrateId;  ///< Flag to indicate if the crate ID as found in the regional header structures should be used or not.
-       bool fDelaySetup;  ///< Indicates if the component should delay loading and initialising from the CDB to the start of run event.
        bool fZmiddleSpecified;  ///< Indicates if the zmiddle parameter was specified on the command line.
        bool fBLSpecified;  ///< Indicates if the bfieldintegral parameter was specified on the command line.
        bool fLutInitialised;  ///< Flag to indicate if the LUT was loaded yet or not.
index 2337129..e494902 100644 (file)
@@ -115,7 +115,7 @@ const char* AliHLTMUONDataCheckerComponent::GetComponentID()
 }
 
 
-void AliHLTMUONDataCheckerComponent::GetInputDataTypes( std::vector<AliHLTComponentDataType>& list)
+void AliHLTMUONDataCheckerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
        /// Inherited from AliHLTProcessor. Returns the list of expected input data types.
        /// At the moment this list is "any data type" since it is not known before
@@ -163,6 +163,10 @@ int AliHLTMUONDataCheckerComponent::DoInit(int argc, const char** argv)
        /// Parses the command line parameters and initialises the component.
        
        HLTInfo("Initialising dHLT data checker component.");
+       
+       // Inherit the parents functionality.
+       int result = AliHLTMUONProcessor::DoInit(argc, argv);
+       if (result != 0) return result;
 
        // Initialise flags with default values.
        fIgnoreType = false;
@@ -175,6 +179,8 @@ int AliHLTMUONDataCheckerComponent::DoInit(int argc, const char** argv)
 
        for (int i = 0; i < argc; i++)
        {
+               if (ArgumentAlreadyHandled(i, argv[i])) continue;
+
                if (strcmp(argv[i], "-ignoretype") == 0)
                {
                        fIgnoreType = true;
@@ -238,10 +244,10 @@ int AliHLTMUONDataCheckerComponent::DoDeinit()
 int AliHLTMUONDataCheckerComponent::DoEvent(
                const AliHLTComponentEventData& evtData,
                const AliHLTComponentBlockData* blocks,
-               AliHLTComponentTriggerData& /*trigData*/,
+               AliHLTComponentTriggerData& trigData,
                AliHLTUInt8_t* /*outputPtr*/,
                AliHLTUInt32_t& size,
-               std::vector<AliHLTComponentBlockData>& outputBlocks
+               AliHLTComponentBlockDataList& outputBlocks
        )
 {
        /// Inherited from AliHLTProcessor. Processes the new event data.
@@ -495,6 +501,8 @@ int AliHLTMUONDataCheckerComponent::DoEvent(
        // Finally we set the total size of output memory we consumed, which is
        // zero since we just copied the input descriptors to output if anything.
        size = 0;
+
+       if (dataProblems and DumpDataOnError()) DumpEvent(evtData, trigData);
        
        if (fReturnError)
        {
index ae7abc8..aaa38ba 100644 (file)
@@ -80,9 +80,9 @@ public:
        // These functions are required for the component registration process.
 
        virtual const char* GetComponentID();
-       virtual void GetInputDataTypes(std::vector<AliHLTComponentDataType>& list);
+       virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
        virtual AliHLTComponentDataType GetOutputDataType();
-       virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+       virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
        virtual AliHLTComponent* Spawn();
        
 protected:
@@ -99,7 +99,7 @@ protected:
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr, 
                        AliHLTUInt32_t& size,
-                       std::vector<AliHLTComponentBlockData>& outputBlocks
+                       AliHLTComponentBlockDataList& outputBlocks
                );
        
        using AliHLTProcessor::DoEvent;
index 7b8205d..3e57ca6 100644 (file)
@@ -65,7 +65,7 @@ const char* AliHLTMUONEmptyEventFilterComponent::GetComponentID()
 }
 
 
-void AliHLTMUONEmptyEventFilterComponent::GetInputDataTypes( std::vector<AliHLTComponentDataType>& list)
+void AliHLTMUONEmptyEventFilterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
        ///
        /// Inherited from AliHLTProcessor. Returns the list of expected input data types.
@@ -112,6 +112,23 @@ AliHLTComponent* AliHLTMUONEmptyEventFilterComponent::Spawn()
 }
 
 
+bool AliHLTMUONEmptyEventFilterComponent::IgnoreArgument(const char* arg) const
+{
+       /// Return true if the argument is one of -cdbpath -run or -delaysetup
+       /// to prevent the parent class from parsing these arguments in DoInit.
+       
+       if (strcmp(arg, "-cdbpath") == 0 or strcmp(arg, "-run") != 0 or
+           strcmp(arg, "-delaysetup") != 0)
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+}
+
+
 int AliHLTMUONEmptyEventFilterComponent::DoInit(int argc, const char** argv)
 {
        ///
@@ -119,10 +136,18 @@ int AliHLTMUONEmptyEventFilterComponent::DoInit(int argc, const char** argv)
        /// Parses the command line parameters and initialises the component.
        ///
 
+       HLTInfo("Initialising dHLT event filter component.");
+       
+       // Inherit the parents functionality.
+       int result = AliHLTMUONProcessor::DoInit(argc, argv);
+       if (result != 0) return result;
+
        fSendOnEmpty = false;  // Set to the default value.
 
        for (int i = 0; i < argc; i++)
        {
+               if (ArgumentAlreadyHandled(i, argv[i])) continue;
+               
                if (strcmp(argv[i], "-sendempty") == 0)
                {
                        fSendOnEmpty = true;
@@ -143,6 +168,8 @@ int AliHLTMUONEmptyEventFilterComponent::DoDeinit()
        ///
        /// Inherited from AliHLTComponent. Performs a cleanup of the component.
        ///
+       
+       HLTInfo("Deinitialising dHLT event filter component.");
   
        return 0;
 }
@@ -151,10 +178,10 @@ int AliHLTMUONEmptyEventFilterComponent::DoDeinit()
 int AliHLTMUONEmptyEventFilterComponent::DoEvent(
                const AliHLTComponentEventData& evtData,
                const AliHLTComponentBlockData* blocks,
-               AliHLTComponentTriggerData& /*trigData*/,
-               AliHLTUInt8_t* /*outputPtr*/,
+               AliHLTComponentTriggerData& trigData,
+               AliHLTUInt8_t* outputPtr,
                AliHLTUInt32_t& size,
-               std::vector<AliHLTComponentBlockData>& outputBlocks
+               AliHLTComponentBlockDataList& outputBlocks
        )
 {
        /// Inherited from AliHLTProcessor. Processes the new event data.
@@ -182,31 +209,51 @@ int AliHLTMUONEmptyEventFilterComponent::DoEvent(
                if (blocks[n].fDataType == AliHLTMUONConstants::TriggerRecordsBlockDataType())
                {
                        AliHLTMUONTriggerRecordsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+                               continue;
+                       }
                        if (inblock.Nentries() != 0) emptyEvent = false;
                }
                else if (blocks[n].fDataType == AliHLTMUONConstants::RecHitsBlockDataType())
                {
                        AliHLTMUONRecHitsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+                               continue;
+                       }
                        if (inblock.Nentries() != 0) emptyEvent = false;
                }
                else if (blocks[n].fDataType == AliHLTMUONConstants::MansoTracksBlockDataType())
                {
                        AliHLTMUONMansoTracksBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+                               continue;
+                       }
                        if (inblock.Nentries() != 0) emptyEvent = false;
                }
                else if (blocks[n].fDataType == AliHLTMUONConstants::SinglesDecisionBlockDataType())
                {
                        AliHLTMUONSinglesDecisionBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+                               continue;
+                       }
                        if (inblock.Nentries() != 0) emptyEvent = false;
                }
                else if (blocks[n].fDataType == AliHLTMUONConstants::PairsDecisionBlockDataType())
                {
                        AliHLTMUONPairsDecisionBlockReader inblock(blocks[n].fPtr, blocks[n].fSize);
-                       if (not BlockStructureOk(inblock)) continue;
+                       if (not BlockStructureOk(inblock))
+                       {
+                               if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+                               continue;
+                       }
                        if (inblock.Nentries() != 0) emptyEvent = false;
                }
        }
index a5222f1..937f66a 100644 (file)
@@ -52,9 +52,9 @@ public:
        // These functions are required for the registration process.
 
        virtual const char* GetComponentID();
-       virtual void GetInputDataTypes(std::vector<AliHLTComponentDataType>& list);
+       virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
        virtual AliHLTComponentDataType GetOutputDataType();
-       virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+       virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
        virtual AliHLTComponent* Spawn();
        
 protected:
@@ -71,8 +71,9 @@ protected:
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr, 
                        AliHLTUInt32_t& size,
-                       std::vector<AliHLTComponentBlockData>& outputBlocks
+                       AliHLTComponentBlockDataList& outputBlocks
                );
+       virtual bool IgnoreArgument(const char* arg) const;
        
        using AliHLTProcessor::DoEvent;
        
index 55520ee..2f21d1f 100644 (file)
@@ -2376,6 +2376,13 @@ const char* TryDecodeDataSpec(const char* filename)
        return NULL;
 }
 
+namespace
+{
+       // CDB path and run number to use.
+       const char* gCDBPath = "local://$ALICE_ROOT";
+       Int_t gRunNumber = 0;
+}
+
 /**
  * Performs basic data integrity checks of the data block using the
  * AliHLTMUONDataCheckerComponent.
@@ -2404,18 +2411,14 @@ int CheckDataIntegrity(
                sys.SetGlobalLoggingLevel(AliHLTComponentLogSeverity(level));
        }
        
-       // Check if required libraries are there and load them if not.
-       if (gClassTable->GetID("AliHLTAgentUtil") < 0)
-       {
-               sys.LoadComponentLibraries("libAliHLTUtil.so");
-       }
-       if (gClassTable->GetID("AliHLTMUONAgent") < 0)
-       {
-               sys.LoadComponentLibraries("libAliHLTMUON.so");
-       }
+       sys.LoadComponentLibraries("libAliHLTUtil.so");
+       sys.LoadComponentLibraries("libAliHLTMUON.so");
        
        // Setup the component parameter lists and then the components.
-       TString dcparams = "-return_error -warn_on_unexpected_block -no_global_check";
+       TString dcparams = "-return_error -warn_on_unexpected_block -no_global_check -cdbpath ";
+       dcparams += gCDBPath;
+       dcparams += " -run ";
+       dcparams += gRunNumber;
        TString fpparams = "-datatype '";
        fpparams += TypeToString(type);
        fpparams += "' 'MUON'";
@@ -2549,7 +2552,8 @@ void PrintUsage(bool asError = true)
 {
        std::ostream& os = asError ? cerr : cout;
        os << "Usage: dHLTdumpraw [-help|-h] [-continue|-c] [-type|-t <typename>] [-check|-k]" << endl;
-       os << "         [-debug|-d] [-dataspec|-s <number>] <filename> [<filename> ...]" << endl;
+       os << "         [-debug|-d] [-dataspec|-s <number>] [-cdbpath|-p <url>] [-run|-r <number>]" << endl;
+       os << "         <filename> [<filename> ...]" << endl;
        os << "Where <filename> is the name of a file containing a raw data block." << endl;
        os << "Options:" << endl;
        os << " -help | -h" << endl;
@@ -2584,6 +2588,10 @@ void PrintUsage(bool asError = true)
        os << " -dataspec | -s <number>" << endl;
        os << "       When specified, then <number> is used as the data specification for the" << endl;
        os << "       data file that follows. This option is only useful with the -check|-k option." << endl;
+       os << " -cdbpath | -p <url>" << endl;
+       os << "       The path to the CDB to use when running with the -check | -k option." << endl;
+       os << " -run | -r <number>" << endl;
+       os << "       The run number to use when running with the -check | -k option." << endl;
 }
 
 /**
@@ -2621,6 +2629,8 @@ int ParseCommandLine(
        checkData = false;
        int currentType = kUnknownDataBlock;
        const char* currentDataSpec = NULL;
+       bool pathSet = false;
+       bool runSet = false;
 
        // Parse the command line.
        for (int i = 1; i < argc; i++)
@@ -2701,6 +2711,50 @@ int ParseCommandLine(
                        }
                        currentDataSpec = argv[i];
                }
+               else if (strcmp(argv[i], "-cdbpath") == 0 or strcmp(argv[i], "-p") == 0)
+               {
+                       if (pathSet)
+                       {
+                               cerr << "WARNING: Already used -cdbpath|-p with '" << gCDBPath
+                                       << "' before. Will override it with the last value specified with -cdbpath|-p."
+                                       << endl;
+                       }
+                       if (++i >= argc)
+                       {
+                               cerr << "ERROR: Missing the URL for the CDB path." << endl << endl;
+                               PrintUsage();
+                               return CMDLINE_ERROR;
+                       }
+                       gCDBPath = argv[i];
+                       pathSet = true;
+               }
+               else if (strcmp(argv[i], "-run") == 0 or strcmp(argv[i], "-r") == 0)
+               {
+                       if (runSet)
+                       {
+                               cerr << "WARNING: Already used -run|-r with " << gRunNumber
+                                       << " before. Will override it with the last value specified with -run|-r."
+                                       << endl;
+                       }
+                       if (++i >= argc)
+                       {
+                               cerr << "ERROR: Missing the run number." << endl << endl;
+                               PrintUsage();
+                               return CMDLINE_ERROR;
+                       }
+                       
+                       char* cpErr = NULL;
+                       Int_t run = Int_t( strtol(argv[i], &cpErr, 0) );
+                       if (cpErr == NULL or *cpErr != '\0' or run < 0)
+                       {
+                               cerr << "ERROR: Cannot convert '" << argv[i] << "' to a valid run number."
+                                       " Expected a positive integer value." << endl;
+                               return CMDLINE_ERROR;
+                       }
+
+                       gRunNumber = run;
+                       runSet = true;
+               }
                else
                {
                        assert( numOfFiles < argc );
index 35c4c8c..ad8ee22 100644 (file)
@@ -50,6 +50,12 @@ using std::endl;
 #define FATAL_ERROR 4
 #define HLTSYSTEM_ERROR 5
 
+namespace
+{
+       // CDB path and run number to use.
+       const char* gCDBPath = "local://$ALICE_ROOT";
+       Int_t gRunNumber = 0;
+}
 
 /**
  * Uses AliHLTSystem and the AliHLTMUONRootifierComponent to convert the files
@@ -84,15 +90,8 @@ int RootifyFiles(
                sys.SetGlobalLoggingLevel(kHLTLogAll);
        }
        
-       // Check if required libraries are there and load them if not.
-       if (gClassTable->GetID("AliHLTAgentUtil") < 0)
-       {
-               sys.LoadComponentLibraries("libAliHLTUtil.so");
-       }
-       if (gClassTable->GetID("AliHLTMUONAgent") < 0)
-       {
-               sys.LoadComponentLibraries("libAliHLTMUON.so");
-       }
+       sys.LoadComponentLibraries("libAliHLTUtil.so");
+       sys.LoadComponentLibraries("libAliHLTMUON.so");
        
        TString sources = "";
        typedef AliHLTConfiguration* PAliHLTConfiguration;
@@ -146,9 +145,13 @@ int RootifyFiles(
        // Setup the component for data integrity checking.
        if (checkData)
        {
+               TString dcparams = "-warn_on_unexpected_block -ignorespec -cdbpath ";
+               dcparams += gCDBPath;
+               dcparams += " -run ";
+               dcparams += gRunNumber;
                AliHLTConfiguration checker(
                                "checker", AliHLTMUONConstants::DataCheckerComponentId(),
-                               sources, "-warn_on_unexpected_block -ignorespec"
+                               sources, dcparams
                        );
                sources = "checker";
        }
@@ -238,7 +241,8 @@ void PrintUsage(bool asError = true)
 {
        std::ostream& os = asError ? cerr : cout;
        os << "Usage: dHLTrootify [-help|-h] [-outfile|-o <output_file>] [-type|-t <typename>]" << endl;
-       os << "         [-debug|-d] [-check|-c] <filename> [<filename> ...]" << endl;
+       os << "         [-debug|-d] [-check|-c] [-cdbpath|-p <url>] [-run|-r <number>]" << endl;
+       os << "         <filename> [<filename> ...]" << endl;
        os << "Where <filename> is the name of a file containing a raw data block." << endl;
        os << "Options:" << endl;
        os << " -help | -h" << endl;
@@ -267,6 +271,10 @@ void PrintUsage(bool asError = true)
        os << "       If specified then data integrity checks are performed on the raw data." << endl;
        os << "       Warnings and errors are printed as problems are found with the data, but" << endl;
        os << "       the data will still be converted into ROOT objects as best as possible." << endl;
+       os << " -cdbpath | -p <url>" << endl;
+       os << "       The path to the CDB to use when running with the -check | -k option." << endl;
+       os << " -run | -r <number>" << endl;
+       os << "       The run number to use when running with the -check | -k option." << endl;
 }
 
 /**
@@ -299,6 +307,8 @@ int ParseCommandLine(
        outputFile = NULL;
        maxLogging = false;
        checkData = false;
+       bool pathSet = false;
+       bool runSet = false;
        AliHLTMUONDataBlockType currentType = kUnknownDataBlock;
 
        // Parse the command line.
@@ -311,6 +321,12 @@ int ParseCommandLine(
                }
                else if (strcmp(argv[i], "-outfile") == 0 or strcmp(argv[i], "-o") == 0)
                {
+                       if (outputFile != NULL)
+                       {
+                               cerr << "WARNING: Already used -outfile|-o with " << outputFile
+                                       << " before. Will override it with the last value specified with -outfile|-o."
+                                       << endl;
+                       }
                        if (++i >= argc)
                        {
                                cerr << "ERROR: Missing an output filename." << endl << endl;
@@ -353,6 +369,50 @@ int ParseCommandLine(
                {
                        checkData = true;
                }
+               else if (strcmp(argv[i], "-cdbpath") == 0 or strcmp(argv[i], "-p") == 0)
+               {
+                       if (pathSet)
+                       {
+                               cerr << "WARNING: Already used -cdbpath|-p with '" << gCDBPath
+                                       << "' before. Will override it with the last value specified with -cdbpath|-p."
+                                       << endl;
+                       }
+                       if (++i >= argc)
+                       {
+                               cerr << "ERROR: Missing the URL for the CDB path." << endl << endl;
+                               PrintUsage();
+                               return CMDLINE_ERROR;
+                       }
+                       gCDBPath = argv[i];
+                       pathSet = true;
+               }
+               else if (strcmp(argv[i], "-run") == 0 or strcmp(argv[i], "-r") == 0)
+               {
+                       if (runSet)
+                       {
+                               cerr << "WARNING: Already used -run|-r with " << gRunNumber
+                                       << " before. Will override it with the last value specified with -run|-r."
+                                       << endl;
+                       }
+                       if (++i >= argc)
+                       {
+                               cerr << "ERROR: Missing the run number." << endl << endl;
+                               PrintUsage();
+                               return CMDLINE_ERROR;
+                       }
+                       
+                       char* cpErr = NULL;
+                       Int_t run = Int_t( strtol(argv[i], &cpErr, 0) );
+                       if (cpErr == NULL or *cpErr != '\0' or run < 0)
+                       {
+                               cerr << "ERROR: Cannot convert '" << argv[i] << "' to a valid run number."
+                                       " Expected a positive integer value." << endl;
+                               return CMDLINE_ERROR;
+                       }
+
+                       gRunNumber = run;
+                       runSet = true;
+               }
                else
                {
                        assert( numOfFiles < argc );