LCOV - code coverage report
Current view: top level - HLT/BASE/util - AliHLTCompStatCollector.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 11 18.2 %
Date: 2016-06-14 17:26:59 Functions: 2 15 13.3 %

          Line data    Source code
       1             : // -*- Mode: C++ -*-
       2             : // $Id$
       3             : 
       4             : #ifndef ALIHLTCOMPSTATCOLLECTOR_H
       5             : #define ALIHLTCOMPSTATCOLLECTOR_H
       6             : //* This file is property of and copyright by the ALICE HLT Project        * 
       7             : //* ALICE Experiment at CERN, All rights reserved.                         *
       8             : //* See cxx source for full Copyright notice                               *
       9             : 
      10             : /// @file   AliHLTCompStatCollector.h
      11             : /// @author Matthias Richter
      12             : /// @date   
      13             : /// @brief  Collector component for the component statistics information.
      14             : ///
      15             : 
      16             : #include "AliHLTProcessor.h"
      17             : #include <ctime>
      18             : #include <map>
      19             : 
      20             : class TStopwatch;
      21             : class TH1F;
      22             : class TH2F;
      23             : class TH2C;
      24             : class TTree;
      25             : class TFolder;
      26             : class TFile;
      27             : 
      28             : /**
      29             :  * @class AliHLTCompStatCollector
      30             :  * Collector component for the statistics entries produced by the
      31             :  * AliHLTComponent base class.
      32             :  *
      33             :  * <h2>General properties:</h2>
      34             :  * This components collects all data blocks of types
      35             :  * ::kAliHLTDataTypeComponentStatistics and ::kAliHLTDataTypeComponentTable
      36             :  * which can be produced by the AliHLTComponent base class for every component
      37             :  * and event. Component statistics entries are data blocks of
      38             :  * ::AliHLTComponentStatistics arrays containing a couple of informations
      39             :  * about each component. The information is extracted and stored into a
      40             :  * TTree. The component table entries (AliHLTComponentTable structs) are sent
      41             :  * on SOR and EOR events and are arranged in a TFolder hierarchy.
      42             :  *
      43             :  * The objects are published or/and saved according to the setup. An
      44             :  * event modulo marameter can be used to publish every nth event, a period
      45             :  * argument to publish every nth second. The objects can be optionally saved
      46             :  * directly to file and the publishing can be suppressed. The objects are
      47             :  * published/saved at the EOR event.
      48             :  *
      49             :  * Component ID: \b StatisticsCollector                                 <br>
      50             :  * Library: \b libAliHLTUtil.so                                         <br>
      51             :  * Input Data Types: ::kAliHLTDataTypeComponentStatistics                 <br>
      52             :  * Output Data Types: ::kAliHLTDataTypeHistogram, ::kAliHLTDataTypeTNtuple  <br>
      53             :  *
      54             :  * <h2>Mandatory arguments:</h2>
      55             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      56             :  *
      57             :  * <h2>Optional arguments:</h2>
      58             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      59             :  * \li -file     <i> filename   </i> <br>
      60             :  *      name of root file
      61             :  * \li -publish     <i> 0/1   </i> <br>
      62             :  *      enable/disable publishing to HLT output, default is on
      63             :  * \li -period     <i> n   </i> <br>
      64             :  *      publish/save every n-th second
      65             :  * \li -modulo     <i> n   </i> <br>
      66             :  *      publish/save every n-th event
      67             :  *
      68             :  * <h2>Configuration:</h2>
      69             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      70             :  * Configuration by component arguments.
      71             :  *
      72             :  * <h2>Default CDB entries:</h2>
      73             :  * The component loads no CDB entries.
      74             :  *
      75             :  * <h2>Performance:</h2>
      76             :  *
      77             :  * <h2>Memory consumption:</h2>
      78             :  *
      79             :  * <h2>Output size:</h2>
      80             :  *
      81             :  * @ingroup alihlt_util_components
      82             :  */
      83             : class AliHLTCompStatCollector : public AliHLTProcessor
      84             : {
      85             :  public:
      86             :   /** standard constructor */
      87             :   AliHLTCompStatCollector();
      88             :   /** destructor */
      89             :   virtual ~AliHLTCompStatCollector();
      90             : 
      91         588 :   const char* GetComponentID() {return "StatisticsCollector";};
      92           0 :   AliHLTComponent* Spawn() {return new AliHLTCompStatCollector;}
      93             :   void GetInputDataTypes( vector<AliHLTComponentDataType>& );
      94             :   AliHLTComponentDataType GetOutputDataType();
      95             :   int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
      96             :   void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
      97             : 
      98             :   /**
      99             :    * 
     100             :    */
     101             :   class AliHLTCompStatInstance {
     102             :   public:
     103             :     AliHLTCompStatInstance();
     104             :     AliHLTCompStatInstance(AliHLTUInt32_t CRCId,
     105             :                            const char* chainId,
     106             :                            const char* componentId,
     107             :                            const char* componentParam,
     108             :                            const vector<AliHLTUInt32_t>& parents,
     109             :                            const int level=-1,
     110             :                            const int tag=-1);
     111             :     AliHLTCompStatInstance(AliHLTUInt32_t CRCId,
     112             :                            const string& chainId,
     113             :                            const string& componentId,
     114             :                            const string& componentParam,
     115             :                            const vector<AliHLTUInt32_t>& parents,
     116             :                            const int level=-1,
     117             :                            const int tag=-1);
     118             :     AliHLTCompStatInstance(const AliHLTCompStatInstance& src);
     119             :     AliHLTCompStatInstance& operator=(const AliHLTCompStatInstance& src);
     120             : 
     121             :     ~AliHLTCompStatInstance();
     122             : 
     123           0 :     AliHLTUInt32_t GetCRCId() const {return fCRCId;}
     124             :     const string&  GetChainId() const {return fChainId;}
     125           0 :     const string&  GetComponentId() const {return fComponentId;}
     126             :     const string&  GetComponentParam() const {return fComponentParam;}
     127             :     const vector<AliHLTUInt32_t>& GetParents() const {return fParents;}
     128           0 :     int GetLevel() const {return fLevel;}
     129             :     int GetTag() const {return fTag;}
     130           0 :     int SetTag(int tag) {fTag=tag; return fTag;}
     131           0 :     bool IsProcessed() const {return fProcessed;}
     132           0 :     void MarkProcessed() {fProcessed=true;}
     133           0 :     void ResetProcessed() {fProcessed=false;}
     134             : 
     135             :     void Print(const char* option="") const;
     136             :     string Description(const char* option="") const;
     137             : 
     138             :     bool operator==(const AliHLTCompStatInstance &b) const;
     139           0 :     bool operator!=(const AliHLTCompStatInstance &b) const {return !(*this==b);}
     140             : 
     141             :     /// helper function for sort, like operator<
     142             :     static bool SortByLevelAndComponentId(const AliHLTCompStatInstance &a,
     143             :                                           const AliHLTCompStatInstance &b);
     144             : 
     145             :   private:
     146             :     AliHLTUInt32_t fCRCId;           /// CRC id of this entry
     147             :     string fChainId;                 /// chain id string
     148             :     string fComponentId;             /// component id string
     149             :     string fComponentParam;          /// component arguments
     150             :     vector<AliHLTUInt32_t> fParents; /// list of parent chain ids
     151             :     int fLevel;                      /// level in the reconstruction chain
     152             :     int fTag;                        /// tag for recording
     153             :     bool fProcessed;                 /// marks instance as processed
     154             :   };
     155             : 
     156             :   void Print(const char* option) const;
     157             : 
     158             :  protected:
     159             :   int DoInit( int argc, const char** argv );
     160             :   int DoDeinit();
     161             :   int DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
     162             :   
     163             :   using AliHLTProcessor::DoEvent;
     164             : 
     165             :   /** mode definition */
     166             :   enum {
     167             :     /** publish objects according to the given period */
     168             :     kPublishObjects = 0x1,
     169             : 
     170             :     /** save objects according to the given period */
     171             :     kSaveObjects = 0x2
     172             :   };
     173             : 
     174             :  private:
     175             :   /** not a valid copy constructor, defined according to effective C++ style */
     176             :   AliHLTCompStatCollector(const AliHLTCompStatCollector&);
     177             :   /** not a valid assignment op, but defined according to effective C++ style */
     178             :   AliHLTCompStatCollector& operator=(const AliHLTCompStatCollector&);
     179             : 
     180             :   /**
     181             :    * Reset all filling variables and lists.
     182             :    */
     183             :   void ResetFillingVariables();
     184             : 
     185             :   /**
     186             :    * Fill the lists from the component statistics block.
     187             :    */
     188             :   int FillVariablesSorted(void* ptr, int size, AliHLTUInt32_t eventType);
     189             : 
     190             :   /** allocate the statistics tree and the branch arrays */
     191             :   int AllocateStatTree(AliHLTUInt32_t size);
     192             : 
     193             :   /** delete all internal objects */
     194             :   void ClearAll();
     195             :   /** clear the statistics tree and the branch arrays */
     196             :   void ClearStatTree();
     197             : 
     198             :   /**
     199             :    * Remove entries from the parent list if they occur further down in the
     200             :    * hierarchy.
     201             :    */
     202             :   int RemoveRecurrence(TFolder* pRoot) const;
     203             : 
     204             :   /**
     205             :    * Check event modulo and time period.
     206             :    * If the result is true, the internal counter and time backup is
     207             :    * updated enabled
     208             :    * @param bUpdate   update internal backups if condition was true
     209             :    * @return true if period has excceded
     210             :    */
     211             :   bool CheckPeriod(bool bUpdate=true);
     212             : 
     213             :   /** event cycle timer */
     214             :   TStopwatch* fpTimer; //!transient
     215             : 
     216             :   /** top folder */
     217             :   TFolder* fpFolder; //!transient
     218             :   /** map between crc id and instance description */
     219             :   map<AliHLTUInt32_t, AliHLTCompStatInstance> fInstances;
     220             : 
     221             :   /** statistics tree */
     222             :   TTree* fpStatTree; //!transient
     223             : 
     224             :   /** branch filling variable */
     225             :   Float_t fCycleTime; //!transient
     226             :   /** branch filling variable */
     227             :   Int_t fNofSets; //!transient
     228             :   /** array size */
     229             :   UInt_t fArraySize; //!transient
     230             :   /** current position */
     231             :   UInt_t fPosition; //!transient
     232             :   /** branch filling variable */
     233             :   UInt_t* fpLevelArray; //!transient
     234             :   /** branch filling variable */
     235             :   UInt_t* fpSpecArray; //!transient
     236             :   /** branch filling variable */
     237             :   UInt_t* fpBlockNoArray; //!transient
     238             :   /** branch filling variable */
     239             :   UInt_t* fpIdArray; //!transient
     240             :   /** branch filling variable */
     241             :   UInt_t* fpTimeArray; //!transient
     242             :   /** branch filling variable */
     243             :   UInt_t* fpCTimeArray; //!transient
     244             :   /** branch filling variable */
     245             :   UInt_t* fpInputBlockCountArray; //!transient
     246             :   /** branch filling variable */
     247             :   UInt_t* fpTotalInputSizeArray; //!transient
     248             :   /** branch filling variable */
     249             :   UInt_t* fpNormalizedInputSizeArray; //!transient
     250             :   /** branch filling variable */
     251             :   UInt_t* fpOutputBlockCountArray; //!transient
     252             :   /** branch filling variable */
     253             :   UInt_t* fpTotalOutputSizeArray; //!transient
     254             :   /** branch filling variable */
     255             :   UInt_t* fpInputOutputRatioArray; //!transient
     256             :   /** branch filling variable */
     257             :   UInt_t* fpNormalizedInputOutputRatioArray; //!transient
     258             :   /** branch filling variable */
     259             :   UInt_t* fpComponentCycleTimeArray; //!transient
     260             :   /** branch filling variable */
     261             :   UInt_t* fpEventTypeArray; //!transient
     262             :   /** branch filling variable */
     263             :   UInt_t* fpEventCountArray; //!transient
     264             : 
     265             :   /** const base of GetOutputSize, updated on error in DoEvent */
     266             :   int fSizeEstimator; //! transient
     267             : 
     268             :   /** mode flags */
     269             :   unsigned int fMode; //! transient
     270             : 
     271             :   /** file name to store the objects */
     272             :   string fFileName; //! transient
     273             : 
     274             :   /** root file to save objects */
     275             :   TFile* fFile; // !transient
     276             : 
     277             :   /** last time, objects have been published or saved */
     278             :   time_t fLastTime; //! transient
     279             : 
     280             :   /** period in seconds to save/publish objects */
     281             :   unsigned int fPeriod; //! transient
     282             : 
     283             :   /** event modulo to save/publish onjects */
     284             :   unsigned int fEventModulo; //! transient
     285             : 
     286           8 :   ClassDef(AliHLTCompStatCollector, 0)
     287             : };
     288             : #endif

Generated by: LCOV version 1.11