LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTTTreeProcessor.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 18 5.6 %
Date: 2016-06-14 17:26:59 Functions: 1 24 4.2 %

          Line data    Source code
       1             : //-*- Mode: C++ -*-
       2             : // $Id$
       3             : 
       4             : #ifndef ALIHLTTTREEPROCESSOR_H
       5             : #define ALIHLTTTREEPROCESSOR_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   AliHLTTTreeProcessor.h
      11             : /// @author Timur Pocheptsov, Matthias Richter
      12             : /// @date   05.07.2010
      13             : /// @brief  Generic component for data collection in a TTree
      14             : 
      15             : #include <list>
      16             : 
      17             : #include <TString.h>
      18             : 
      19             : #include "AliHLTProcessor.h"
      20             : 
      21             : class TTree;
      22             : class TH1;
      23             : class TStopwatch;
      24             : 
      25             : /**
      26             :  * @class AliHLTTTreeProcessor
      27             :  * Generic component for data collection in a TTree, or as a special case
      28             :  * in a TNtuple (which is a tree with only float branches). Child components
      29             :  * implement the creation and filling of the tree, which is dependent on the
      30             :  * data itself.
      31             :  *
      32             :  * Child components have to implement the basic component property methods
      33             :  * like GetComponentID(), GetInputDataTypes(), and Spawn(). Default
      34             :  * implementations of GetOutputDataSize() and GetOutputDataType() are already
      35             :  * provided by the base class.
      36             :  * 
      37             :  * The base class keeps a circular TTree of a specific event count. Histograms
      38             :  * are periodically generated by applying a table of selections and cuts. The
      39             :  * table can be configured and changed at run-time and the data sample in the
      40             :  * tree can be reset.
      41             :  *
      42             :  * @ingroup alihlt_base
      43             :  */
      44             : class AliHLTTTreeProcessor : public AliHLTProcessor {
      45             : private:
      46             :   enum EDefaults {
      47             :     kMaxEntries = 1000,
      48             :     kDefaultNBins = 200,
      49             :     kInterval = 5
      50             :   };
      51             : public:
      52             :   /// default constructor
      53             :   AliHLTTTreeProcessor();
      54             :   /// destructor
      55             :   virtual ~AliHLTTTreeProcessor();
      56             : 
      57             :   /// inherited from AliHLTComponent, get the output data type
      58             :   virtual AliHLTComponentDataType GetOutputDataType();
      59             : 
      60             :   /// inherited from AliHLTComponent, get the output data size estimator
      61             :   virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
      62             : 
      63             : protected:
      64             :   /// initialization, overloaded from AliHLTComponent
      65             :   int DoInit(int argc, const char** argv);
      66             :   /// deinitialization, overloaded from AliHLTComponent
      67             :   int DoDeinit();
      68             :   /// inherited from AliHLTProcessor, data processing
      69             :   int DoEvent(const AliHLTComponentEventData& evtData,
      70             :               AliHLTComponentTriggerData& trigData);
      71             :   using AliHLTProcessor::DoEvent;
      72             :   /// inherited from AliHLTComponent, scan argument
      73             :   virtual int ScanConfigurationArgument(int argc, const char** argv);
      74             : 
      75           0 :   class AliHLTHistogramDefinition {
      76             :   public:
      77             :     AliHLTHistogramDefinition()
      78           0 :       : fName(), fSize(0), fExpr(), fTitle(), fCut(), fOpt()
      79           0 :     {
      80           0 :     }
      81             : 
      82           0 :         const TString& GetName()const{return fName;}
      83           0 :         void SetName(const TString& name){fName = name;}
      84             : 
      85           0 :         int GetSize()const{return fSize;}
      86           0 :         void SetSize(int size){fSize = size;}
      87             : 
      88           0 :         const TString& GetExpression()const{return fExpr;}
      89           0 :         void SetExpression(const TString& expr){fExpr = expr;}
      90             : 
      91           0 :         const TString& GetTitle()const{return fTitle;}
      92           0 :         void SetTitle(const TString& title){fTitle = title;}
      93             : 
      94           0 :         const TString& GetCut()const{return fCut;}
      95           0 :         void SetCut(const TString& cut){fCut = cut;}
      96             : 
      97           0 :         const TString& GetDrawOption()const{return fOpt;}
      98           0 :         void SetDrawOption(const TString& opt){fOpt = opt;}
      99             : 
     100             :   private:
     101             : 
     102             :     TString fName;
     103             :     int     fSize;
     104             :     TString fExpr;
     105             :     TString fTitle;
     106             :     TString fCut;
     107             :     TString fOpt;
     108             :   };
     109             : 
     110             :   std::list<AliHLTHistogramDefinition> fDefinitions;
     111             :   typedef std::list<AliHLTHistogramDefinition>::iterator list_iterator;
     112             :   typedef std::list<AliHLTHistogramDefinition>::const_iterator list_const_iterator;
     113             : 
     114             : private:
     115             :   /// create the tree instance and all branches
     116             :   virtual TTree* CreateTree(int argc, const char** argv) = 0;
     117             :   /// process input blocks and fill tree
     118             :   virtual int FillTree(TTree* pTree, const AliHLTComponentEventData& evtData, 
     119             :                        AliHLTComponentTriggerData& trigData ) = 0;
     120             :   /// dtOrigin for PushBack.
     121             :   virtual AliHLTComponentDataType GetOriginDataType()const = 0;
     122             :   /// spec for PushBack
     123           0 :   virtual AliHLTUInt32_t GetDataSpec()const {return fUniqueId;}
     124             :   /// default histogram definitions.
     125             :   virtual void FillHistogramDefinitions() = 0;
     126             : 
     127             :   /// create a histogram from the tree
     128             :   TH1* CreateHistogram(const AliHLTHistogramDefinition& def);
     129             :   /// parse arguments, containing histogram definition.
     130             :   int ParseHistogramDefinition(int argc, const char** argv, int pos, AliHLTHistogramDefinition& dst)const;
     131             : 
     132             :   /// the TTree
     133             :   TTree* fTree; //! the tree instance
     134             :   /// max entries
     135             :   int fMaxEntries; //! maximum number of entries in the circular tree
     136             :   /// publish interval in s
     137             :   unsigned fPublishInterval; //! publish interval in s
     138             :   /// time stamp - publish or not.
     139             :   unsigned fLastTime; //! last time the histogramms were published
     140             : 
     141             :   TStopwatch* fpEventTimer; //! stopwatch for event processing
     142             :   TStopwatch* fpCycleTimer; //! stopwatch for event cycle
     143             :   AliHLTUInt32_t fMaxMemory; //! maximum memory consumption allowed for the process
     144             :   AliHLTUInt32_t fMaxEventTime; //! allowed maximum processing time in usec
     145             :   AliHLTUInt32_t fNofEventsForce; //! number of events to ignore the processing time
     146             :   AliHLTUInt32_t fForcedEventsCount; //! event count for the forced events
     147             :   AliHLTUInt32_t fSkippedEventsCount; //! number of skipped events
     148             :   AliHLTUInt32_t fNewEventsCount; //! number of new events since last publishing
     149             :   AliHLTUInt32_t fUniqueId; //! a unique id for this process used to identify the output of multiple processes
     150             :   AliHLTUInt32_t fIgnoreCycleTime; //! ignore cycle time for n seconds
     151             :   float          fCycleTimeFactor; //! weight for the cycle time
     152             : 
     153             :   static const AliHLTUInt32_t fgkTimeScale;
     154             : 
     155             :   /// copy constructor prohibited
     156             :   AliHLTTTreeProcessor(const AliHLTTTreeProcessor&);
     157             :   /// assignment operator prohibited
     158             :   AliHLTTTreeProcessor& operator = (const AliHLTTTreeProcessor&);
     159             : 
     160         126 :   ClassDef(AliHLTTTreeProcessor, 0)
     161             : };
     162             : #endif

Generated by: LCOV version 1.11