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

          Line data    Source code
       1             : // -*- Mode: C++ -*-
       2             : // $Id$
       3             : 
       4             : #ifndef ALIHLTROOTSCHEMAEVOLUTIONCOMPONENT_H
       5             : #define ALIHLTROOTSCHEMAEVOLUTIONCOMPONENT_H
       6             : //* This file is property of and copyright by the                          * 
       7             : //* ALICE Experiment at CERN, All rights reserved.                         *
       8             : //* See cxx source for full Copyright notice                               *
       9             : 
      10             : /// @file   AliHLTRootSchemaEvolutionComponent.h
      11             : /// @author Matthias Richter
      12             : /// @date   2009-10-18
      13             : /// @brief  Handler component for ROOT schema evolution of streamed objects
      14             : ///
      15             : 
      16             : #include "AliHLTCalibrationProcessor.h"
      17             : #include "TString.h"
      18             : #include <vector>
      19             : 
      20             : class TObjArray;
      21             : class TObject;
      22             : class TStopwatch;
      23             : class AliHLTMessage;
      24             : 
      25             : using std::vector;
      26             : 
      27             : /**
      28             :  * @class AliHLTRootSchemaEvolutionComponent
      29             :  * Collects streamer info for all input objects and produces the corresponding
      30             :  * calibration object for reconstruction of HLT. The component runs with a
      31             :  * configurable rate constraint and skips the processing of known data blocks
      32             :  * for the sake of performance. New data blocks are always processed and added
      33             :  * to the list.
      34             :  *
      35             :  * <h2>General properties:</h2>
      36             :  *
      37             :  * Component ID: \b ROOTSchemaEvolutionComponent                        <br>
      38             :  * Library: \b libAliHLTUtil.so                                         <br>
      39             :  * Input Data Types: ::kAliHLTAnyDataType                               <br>
      40             :  * Output Data Types: none                                              <br>
      41             :  *
      42             :  * <h2>Mandatory arguments:</h2>
      43             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      44             :  *      
      45             :  * <h2>Optional arguments:</h2>
      46             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      47             :  * \li -fxs<=[n,off]> <br>
      48             :  *      push streamer info to FXS, fetched by Shuttle and store in the entry
      49             :  *      HLT/Calib/StreamerInfo                                          <br>
      50             :  *      if a scalar greather then 0 is specified the calibration object is
      51             :  *      pushed during the event processing with the specified scale down<br>
      52             :  *      always pushed on EOR, default on
      53             :  * \li -hltout<=[all,first,eor,off]> <br>
      54             :  *      push streamer info to output, the streamer info is stored in the
      55             :  *      events in all, the first, and/or the EOR.
      56             :  * \li -file=filename <br>
      57             :  *      write to file at EOR
      58             :  * \li -rate=hz <br>
      59             :  *      required processing rate in Hz, default 2000Hz
      60             :  *
      61             :  * <h2>Configuration:</h2>
      62             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      63             :  * Configuration by component arguments.
      64             :  *
      65             :  * <h2>Default CDB entries:</h2>
      66             :  * The component loads no CDB entries.
      67             :  *
      68             :  * <h2>Performance:</h2>
      69             :  * TODO: update performance requirements for unpacking ESDs and creating the
      70             :  * streamer info
      71             :  *
      72             :  * <h2>Memory consumption:</h2>
      73             :  * The component does not process any event data.
      74             :  *
      75             :  * <h2>Output size:</h2>
      76             :  * Depending on the mode.
      77             :  *
      78             :  * @ingroup alihlt_util_components
      79             :  */
      80             : class AliHLTRootSchemaEvolutionComponent : public AliHLTCalibrationProcessor
      81             : {
      82             :  public:
      83             :   /// standard constructor
      84             :   AliHLTRootSchemaEvolutionComponent();
      85             :   /// destructor
      86             :   virtual ~AliHLTRootSchemaEvolutionComponent();
      87             : 
      88             :   /// inherited from AliHLTComponent: return id of the component.
      89         660 :   virtual const char* GetComponentID() {return "ROOTSchemaEvolutionComponent";};
      90             :   /// inherited from AliHLTComponent: input data types
      91             :   virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
      92             :   /// inherited from AliHLTComponent: output data types
      93             :   virtual AliHLTComponentDataType GetOutputDataType();
      94             :   /// inherited from AliHLTComponent: output data size
      95             :   virtual void GetOutputDataSize(unsigned long&, double&);
      96             : 
      97             :   /// inherited from AliHLTComponent: spawn function, create an instance.
      98           0 :   virtual AliHLTComponent* Spawn() {return new AliHLTRootSchemaEvolutionComponent;}
      99             : 
     100             :   enum {
     101             :     /// push streamer info to the HLTOUT for the first event
     102             :     kHLTOUTatFirstEvent   = 0x1,
     103             :     /// push streamer info to the HLTOUT for all events
     104             :     kHLTOUTatAllEvents    = 0x2,
     105             :     /// push streamer info to the HLTOUT at EOR, this has no relevance
     106             :     /// for reconstruction as it is too late and just in one raw file,
     107             :     /// but it allows archival at the end of the run
     108             :     kHLTOUTatEOR          = 0x4,
     109             :     /// push streamer info to FXS
     110             :     kFXS                  = 0x100,
     111             :   };
     112             : 
     113             :   /// Update the array of known streamer infos from a list of infos
     114             :   /// Checks whether the provided infos are already there in the present version
     115             :   /// and adds if it is a new info. 
     116             :   int UpdateStreamerInfos(const TObjArray* list, TObjArray* infos) const;
     117             : 
     118             :   class AliHLTDataBlockItem
     119             :   {
     120             :   public:
     121             :     AliHLTDataBlockItem(AliHLTComponentDataType dt=kAliHLTVoidDataType,
     122             :                         AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
     123             :     ~AliHLTDataBlockItem();
     124             : 
     125             :     /// extract data block to root object, and update performance parameters
     126             :     /// object needs to be deleted externally
     127             :     TObject* Extract(const AliHLTComponentBlockData* bd);
     128             : 
     129             :     /// stream object and update performance parameters
     130             :     int Stream(const TObject* obj, AliHLTMessage& msg);
     131             : 
     132           0 :     bool IsObject() const {return fIsObject;}
     133             :     bool operator==(const AliHLTDataBlockItem& i) const {return fDt==i.fDt && fSpecification==i.fSpecification;}
     134           0 :     bool operator==(AliHLTComponentDataType dt) const {return fDt==dt;}
     135           0 :     bool operator==(AliHLTUInt32_t spec) const {return fSpecification==spec;}
     136           0 :     operator const AliHLTComponentDataType&() const {return fDt;}
     137           0 :     AliHLTUInt32_t GetSpecification() const {return fSpecification;}
     138             :     
     139             :     /// average extraction time in usec
     140           0 :     AliHLTUInt32_t GetExtractionTime() const {return fNofExtractions>0?fExtractionTimeUsec/fNofExtractions:0;}
     141             :     /// average streaming time in usec
     142           0 :     AliHLTUInt32_t GetStreamingTime() const {return fNofStreamings>0?fStreamingTimeUsec/fNofStreamings:0;}
     143             :     /// average total time in usec
     144           0 :     AliHLTUInt32_t GetTotalTime() const {return GetExtractionTime() + GetStreamingTime();}
     145             : 
     146             :     /// print status
     147             :     void Print(const char* option) const;
     148             : 
     149             :   private:
     150             :     /// data type of the block
     151             :     AliHLTComponentDataType fDt; //! transient
     152             :     /// specification of the block
     153             :     AliHLTUInt32_t fSpecification; //! transient
     154             :     /// flag for TObject
     155             :     bool fIsObject; //! transient
     156             : 
     157             :     /// number of extractions
     158             :     AliHLTUInt32_t fNofExtractions; //! transient
     159             :     /// object extraction time in usec
     160             :     AliHLTUInt32_t fExtractionTimeUsec; //! transient
     161             :     /// timestamp of last extraction in usec
     162             :     AliHLTUInt32_t fLastExtraction; //! transient
     163             :     /// number of streamings
     164             :     AliHLTUInt32_t fNofStreamings; //! transient
     165             :     /// object streaming time in usec
     166             :     AliHLTUInt32_t fStreamingTimeUsec; //! transient
     167             :     /// timestamp of last streaming in usec
     168             :     AliHLTUInt32_t fLastStreaming; // !transient
     169             :   };
     170             : 
     171             :   /// find item in the list
     172             :   AliHLTDataBlockItem* FindItem(AliHLTComponentDataType dt,
     173             :                                 AliHLTUInt32_t spec);
     174             : 
     175             :  protected:
     176             :   /// inherited from AliHLTCalibrationProcessor: custom initialization
     177             :   int InitCalibration();
     178             :   /// inherited from AliHLTCalibrationProcessor: custom argument scan
     179             :   /// the AliHLTCalibrationProcessor so far does not use the base class
     180             :   /// methods for argument scan.
     181             :   int ScanArgument( int argc, const char** argv ) {
     182           0 :     int result=ScanConfigurationArgument(argc, argv); return result>0?result-1:result;
     183             :   }
     184             :   /// inherited from AliHLTCalibrationProcessor: cleanup
     185             :   int DeinitCalibration();
     186             : 
     187             :   /// inherited from AliHLTCalibrationProcessor processing
     188             :   virtual int ProcessCalibration( const AliHLTComponentEventData& evtData,
     189             :                                   AliHLTComponentTriggerData& trigData );
     190             :   
     191             :   using AliHLTCalibrationProcessor::ProcessCalibration;
     192             : 
     193             :   /// inherited from AliHLTCalibrationProcessor processing
     194             :   int ShipDataToFXS( const AliHLTComponentEventData& evtData,
     195             :                      AliHLTComponentTriggerData& trigData);
     196             : 
     197             :   using AliHLTCalibrationProcessor::ShipDataToFXS;
     198             : 
     199             :   /**
     200             :    * Inherited from AliHLTComponent
     201             :    * Scan one argument and adjacent parameters.
     202             :    * @return number of scanned parameters, neg. error code if failed
     203             :    */
     204             :   virtual int ScanConfigurationArgument(int argc, const char** argv);
     205             : 
     206           0 :   void SetBits(AliHLTUInt32_t b) {fPropertyFlags|=b;}
     207           0 :   void ClearBits(AliHLTUInt32_t b) {fPropertyFlags&=~b;}
     208           0 :   bool TestBits(AliHLTUInt32_t b) const {return (fPropertyFlags&b) != 0;}
     209             :   int WriteToFile(const char* filename, const TObjArray* infos) const;
     210             : 
     211             : private:
     212             :   /** copy constructor prohibited */
     213             :   AliHLTRootSchemaEvolutionComponent(const AliHLTRootSchemaEvolutionComponent&);
     214             :   /** assignment operator prohibited */
     215             :   AliHLTRootSchemaEvolutionComponent& operator=(const AliHLTRootSchemaEvolutionComponent&);
     216             : 
     217             :   vector<AliHLTDataBlockItem> fList; //! list of block properties
     218             : 
     219             :   AliHLTUInt32_t fPropertyFlags; //! property flags
     220             : 
     221             :   TObjArray* fpStreamerInfos; //! array of streamer infos
     222             :   TStopwatch* fpEventTimer; //! stopwatch for event processing
     223             :   TStopwatch* fpCycleTimer; //! stopwatch for event cycle
     224             :   AliHLTUInt32_t fMaxEventTime; //! required maximum processing time in usec
     225             : 
     226             :   AliHLTUInt32_t fFXSPrescaler; //! prescalar for the publishing to FXS
     227             : 
     228             :   TString fFileName; //! file name for dump at EOR
     229             : 
     230             :   static const char* fgkConfigurationObject; //! configuration object
     231             :   static const AliHLTUInt32_t fgkTimeScale; //! timescale base
     232             : 
     233           8 :   ClassDef(AliHLTRootSchemaEvolutionComponent, 0) // ROOT schema evolution component
     234             : };
     235             : #endif

Generated by: LCOV version 1.11