LCOV - code coverage report
Current view: top level - HLT/rec - AliHLTEsdManagerImplementation.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 2 50.0 %
Date: 2016-06-14 17:26:59 Functions: 1 6 16.7 %

          Line data    Source code
       1             : //-*- Mode: C++ -*-
       2             : // $Id$
       3             : 
       4             : #ifndef ALIHLTESDMANAGERIMPLEMENTATION_H
       5             : #define ALIHLTESDMANAGERIMPLEMENTATION_H
       6             : //* This file is property of and copyright by the ALICE                    * 
       7             : //* ALICE Experiment at CERN, All rights reserved.                         *
       8             : //* See cxx source for full Copyright notice                               *
       9             : 
      10             : /// @file   AliHLTEsdManagerImplementation.h
      11             : /// @author Matthias Richter
      12             : /// @date   
      13             : /// @brief  Implementation of the AliHLTEsdManager
      14             : ///         This is an implementation of the abstract interface AliHLTEsdManager
      15             : 
      16             : #include "AliHLTEsdManager.h"
      17             : #include "AliESDEvent.h"
      18             : #include "TString.h"
      19             : #include <vector>
      20             : 
      21             : class TTree;
      22             : class TFile;
      23             : 
      24             : /**
      25             :  * @class AliHLTEsdManagerImplementation
      26             :  * Implementation of the AliHLTEsdManager.
      27             :  *
      28             :  * For the sake of library (in)dependencies, the concrete implementation of
      29             :  * the AliHLTEsdManager is separated from the libHLTbase class as this would
      30             :  * introduce dependencies to AliRoot libraries. See AliHLTEsdManager for
      31             :  * usage.
      32             :  *
      33             :  * @ingroup alihlt_aliroot_reconstruction
      34             :  */
      35             : class AliHLTEsdManagerImplementation : public AliHLTEsdManager {
      36             :  public:
      37             :   /** constructor */
      38             :   AliHLTEsdManagerImplementation();
      39             :   /** destructor */
      40             :   virtual ~AliHLTEsdManagerImplementation();
      41             : 
      42             :   /**
      43             :    * Inherited from base class, see AliHLTEsdManager::SetOption() for
      44             :    * documentation.
      45             :    */
      46             :   virtual int SetOption(const char* option);
      47             : 
      48             :   /**
      49             :    * Convert data buffer to ESD.
      50             :    * The buffer is supposed to describe a streamed AliESDEvent object.
      51             :    * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root,
      52             :    * where 'det' is derived from the data type origin. Each time the function is invoked
      53             :    * a new event is created. Dummy events are added if the previous events did not contain
      54             :    *
      55             :    * @param [in] pBuffer  the data buffer
      56             :    * @param [in] size     data buffer size
      57             :    * @param [in] dt       data type of the block
      58             :    * @param [out] tgtesd   optional target
      59             :    * @param [in] eventno  optional event no
      60             :    */
      61             :   int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt,
      62             :                AliESDEvent* tgtesd=NULL, int eventno=-1);
      63             : 
      64             :   /**
      65             :    * Merge content of source ESD into the target ESD.
      66             :    * Merging is done on the level of objects in the ESD and for the
      67             :    * moment it's only implemented for the TClonesArrays. In that case it's
      68             :    * easy to detect whether the object is empty or not.
      69             :    *
      70             :    * \b Note: The function can not match entries of the same type, like e.g.
      71             :    * tracks from the 'Tracks' member.
      72             :    */
      73             :   int Merge(AliESDEvent* pTgt, AliESDEvent* pSrc) const;
      74             : 
      75             :   /**
      76             :    * Align all ESD to the same number of events.
      77             :    * The function adds empty events to all ESD files if their event number
      78             :    * does not match the specified one.
      79             :    * @param eventno     the desired event no
      80             :    * @return neg. error code if failed
      81             :    */
      82             :   int PadESDs(int eventno);
      83             : 
      84             :   /**
      85             :    * Set the target directory for the ESD files.
      86             :    */
      87             :   void SetDirectory(const char* directory);
      88             : 
      89             :   /**
      90             :    * Get the list of the internally created files.
      91             :    * Returns a blank separated list of the file names.
      92             :    */
      93             :   TString GetFileNames(AliHLTComponentDataType dt=kAliHLTAnyDataType) const;
      94             : 
      95             :   /**
      96             :    * Embed an ESD into a TTree object.
      97             :    * The tree object needs to be deleted by the caller.
      98             :    */
      99             :   static TTree* EmbedIntoTree(AliESDEvent* pESD, const char* name="esdTree", const char* title="Tree with HLT ESD objects");
     100             : 
     101             :   class AliHLTESDEventHelper : public AliESDEvent {
     102             :   public:
     103             :     static bool IsStdContent(const char* key);
     104             :   };
     105             : 
     106             :   int CheckClassConditions() const;
     107             : 
     108             :   TObject* CreateEsdEvent(bool bCreateStdContent=false) const;
     109             : 
     110             :   int DestroyEsdEvent(TObject* pESDInstance) const;
     111             : 
     112             :   int AddObject(TObject* pESDInstance, const TObject* pObject, const char* branchname) const;
     113             : 
     114             :   int ResetEsdEvent(TObject* pESDInstance) const;
     115             : 
     116             :  protected:
     117             : 
     118             :  private:
     119             :   /** copy constructor prohibited */
     120             :   AliHLTEsdManagerImplementation(const AliHLTEsdManagerImplementation&);
     121             :   /** assignment operator prohibited */
     122             :   AliHLTEsdManagerImplementation& operator=(const AliHLTEsdManagerImplementation&);
     123             : 
     124             :   class AliHLTEsdListEntry : public AliHLTLogging {
     125             :   public:
     126             :     /** constructor */
     127             :     AliHLTEsdListEntry(AliHLTComponentDataType dt);
     128             :     /** destructor */
     129             :     ~AliHLTEsdListEntry();
     130             : 
     131             :     /**
     132             :      * Write the ESD to the corresponding file.
     133             :      * The tree is first synchronized with the eventno and additional empty
     134             :      * events might be inserted if there was a gap. Since we are writing
     135             :      * several files in parallel, we have to make sure that those files contain
     136             :      * the same number of events.
     137             :      * @param pESD        ESD to write
     138             :      * @param eventno     optional event no for tree synchronization
     139             :      */
     140             :     int WriteESD(const AliESDEvent* pESD, int eventno=-1);
     141             : 
     142             :     /**
     143             :      * Set the target directory for the ESD file.
     144             :      */
     145             :     void SetDirectory(const char* directory);
     146             : 
     147             :     /**
     148             :      * Set the tree name
     149             :      */
     150           0 :     void SetTreeName(const char* treename) {fTreeName=treename;}
     151             : 
     152             :     /**
     153             :      * Get name of the ESD file.
     154             :      */
     155             :     const char* GetFileName() const;
     156             : 
     157             :     /**
     158             :      * Get the object name prefix generated from the data origin
     159             :      * The prefix is added to the names of the ESD objects when copied to the
     160             :      * master ESD.
     161             :      */
     162             :     const char* GetPrefix();
     163             : 
     164             :     bool operator==(AliHLTComponentDataType dt) const;
     165             : 
     166             :   private:
     167             :     /** copy constructor prohibited */
     168             :     AliHLTEsdListEntry(const AliHLTEsdListEntry& src);
     169             :     /** assignment operator prohibited */
     170             :     AliHLTEsdListEntry& operator=(const AliHLTEsdListEntry& src);
     171             : 
     172             :     /** root file name */
     173             :     TString fName; //!transient
     174             :     /** target directory */
     175             :     TString fDirectory; //!transient
     176             :     /** data type of the corresponding block */
     177             :     AliHLTComponentDataType fDt; //!transient
     178             :     /** the root file for this esd */
     179             :     TFile* fpFile; //!transient
     180             :     /** the tree for this esd */
     181             :     TTree* fpTree; //!transient
     182             :     /** the esd to fill into the tree */
     183             :     AliESDEvent* fpEsd; //!transient
     184             :     /** Prefix for generated ESD objects in the master ESD */
     185             :     TString fPrefix; //!transient
     186             :     /** name of the tree to be created */
     187             :     TString fTreeName; //!transient
     188             :   };
     189             : 
     190             :   typedef vector<AliHLTEsdListEntry*> AliHLTEsdPList;
     191             : 
     192             :   /**
     193             :    * Find list entry for given data type
     194             :    */
     195             :   AliHLTEsdListEntry* Find(AliHLTComponentDataType dt) const;
     196             : 
     197             :   /** the list of the ESDs */
     198             :   AliHLTEsdPList fESDs; //!transient
     199             : 
     200             :   /** target directory */
     201             :   TString fDirectory; //!transient
     202             :   /** target directory */
     203             :   TString fTreeName; //!transient
     204             :   /** write local files */
     205             :   bool fWriteLocal; //!transient
     206             : 
     207           6 :   ClassDef(AliHLTEsdManagerImplementation, 3)
     208             : };
     209             : 
     210             : #endif

Generated by: LCOV version 1.11