LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTCTPData.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 9 11.1 %
Date: 2016-06-14 17:26:59 Functions: 1 16 6.2 %

          Line data    Source code
       1             : //-*- Mode: C++ -*-
       2             : // $Id$
       3             : 
       4             : #ifndef ALIHLTCTPDATA_H
       5             : #define ALIHLTCTPDATA_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   AliHLTCTPData.h
      11             :     @author Matthias Richter
      12             :     @date   2009-08-20
      13             :     @brief  Container for CTP trigger classes and counters
      14             : */
      15             : 
      16             : #include "TNamed.h"
      17             : #include "TClonesArray.h"
      18             : #include "TArrayL64.h"
      19             : #include "AliHLTLogging.h"
      20             : #include "AliHLTDataTypes.h"
      21             : #include "AliHLTReadoutList.h"
      22             : #include <string>
      23             : 
      24             : /**
      25             :  * @class AliHLTCTPData
      26             :  * This is a container for the CTP trigger classes, the mapping to the bit
      27             :  * field, and counters.
      28             :  *
      29             :  * The class is initialized from CTP_TRIGGER_CLASSES part of the ECS parameters.
      30             :  * and stores internally a list of trigger classes holding the information on bit
      31             :  * position, class name and involved detectors. The general format og the parameter
      32             :  * is as follows:
      33             :  * <pre>
      34             :  * [bit position]:[Trigger class identifier string]:[detector-id-nr]-[detector-id-nr]-...,[bit position]:.....
      35             :  * </pre>
      36             :  *
      37             :  * The list of participating detectors is converted into an AliHLTReadoutList
      38             :  * object named after the trigger class name, and can be used as mask for the
      39             :  * readout list generated by a component.
      40             :  *
      41             :  * The object is also stored as part of the HLTGlobalTriggerDecision
      42             :  * @ingroup alihlt_trigger
      43             :  */
      44             : class AliHLTCTPData: public TNamed, public AliHLTLogging
      45             : {
      46             :  public:
      47             :   /// default constructor
      48             :   AliHLTCTPData();
      49             :   /// standard constructor including initialization from CTP_TRIGGER_CLASS
      50             :   AliHLTCTPData(const char* parameter);
      51             :   /// copy constructor
      52             :   AliHLTCTPData(const AliHLTCTPData&);
      53             :   ///assignment operator
      54             :   AliHLTCTPData& operator=(const AliHLTCTPData&);
      55             :   /// destructor
      56             :   virtual ~AliHLTCTPData();
      57             : 
      58             :   /// Add counters
      59             :   AliHLTCTPData& operator += (const AliHLTCTPData&);
      60             :   /// Add counters
      61             :   AliHLTCTPData operator + (const AliHLTCTPData&) const;
      62             : 
      63             :   /// Subtract counters
      64             :   AliHLTCTPData& operator -= (const AliHLTCTPData&);
      65             :   /// Subtract counters
      66             :   AliHLTCTPData operator - (const AliHLTCTPData&) const;
      67             : 
      68             :   /**
      69             :    * Init the class ids and mapping from the CTP_TRIGGER_CLASS parameter.
      70             :    * The general format of the parameter is as follows:
      71             :    */
      72             :   int InitCTPTriggerClasses(const char* ctpString);
      73             : 
      74             :   /// etract the active trigger mask from the trigger data
      75             :   static AliHLTTriggerMask_t ActiveTriggers(const AliHLTComponentTriggerData& trigData);
      76             : 
      77             :   /**
      78             :    * Evaluate an expression of trigger class ids with respect to the trigger mask.
      79             :    */
      80             :   bool EvaluateCTPTriggerClass(const char* expression, const AliHLTComponentTriggerData& trigData) const;
      81             : 
      82             :   /**
      83             :    * Evaluate an expression of trigger class ids with respect to the trigger mask.
      84             :    */
      85             :   bool EvaluateCTPTriggerClass(const char* expression, AliHLTTriggerMask_t triggerMask) const;
      86             : 
      87             :   /**
      88             :    * Evaluate an expression of trigger class ids with respect to the current trigger mask.
      89             :    */
      90             :   bool EvaluateCTPTriggerClass(const char* expression) const {
      91           0 :     return EvaluateCTPTriggerClass(expression, fTriggers);
      92             :   }
      93             : 
      94             :   /**
      95             :    * Reset all counters
      96             :    */
      97             :   void ResetCounters();
      98             : 
      99             :   /**
     100             :    * Get index of a trigger class in the tigger pattern
     101             :    */
     102             :   int Index(const char* name) const;
     103             : 
     104             :   /**
     105             :    * Check state of a trigger class.
     106             :    * If the class name is not part of the current trigger setup (i.e. ECS parameter
     107             :    * does not contain a trigger definition for this class name) the function
     108             :    * returns -1
     109             :    * @return -1 class name not initialized, 
     110             :    *          0 trigger not active
     111             :    *          1 trigger active
     112             :    */
     113             :   int CheckTrigger(const char* name) const;
     114             : 
     115             :   /** glob match name in trigger mask **/
     116             :   int MatchTriggerGlob(const char* glob) const;
     117             : 
     118             :   /** regex match in trigger mask **/
     119             :   int MatchTriggerRE(const char* re) const;
     120             : 
     121             :   /**
     122             :    * Increment counter for CTP trigger classes
     123             :    * @param classIds  comma separated list of class ids
     124             :    */
     125             :   void Increment(const char* classIds);
     126             : 
     127             :   /**
     128             :    * Increment counter for CTP trigger classes
     129             :    * @param triggerPattern  corresponds to the 100bit trigger mask in the CDH
     130             :    */
     131             :   void Increment(AliHLTTriggerMask_t triggerPattern);
     132             : 
     133             :   /**
     134             :    * Increment counter for a CTP trigger class
     135             :    * @param classIdx  index of the class in the 100bit trigger mask
     136             :    */
     137             :   void Increment(int classIdx);
     138             : 
     139             :   /**
     140             :    * Increment counters according to the trigger data struct.
     141             :    * First extract trigger pattern from the CDH and then
     142             :    * increment from the trigger pattern.
     143             :    */
     144             :   int Increment(AliHLTComponentTriggerData& trigData);
     145             : 
     146             :   /**
     147             :    * Return a readout list for the active trigger classes.
     148             :    * The list is an 'OR' of the active trugger classes.
     149             :    */
     150             :   AliHLTReadoutList ReadoutList(const AliHLTComponentTriggerData& trigData) const;
     151             : 
     152             :   /**
     153             :    * Return a readout list for the active trigger classes.
     154             :    * The list is an 'OR' of the active trugger classes.
     155             :    */
     156             :   AliHLTReadoutList ReadoutList(AliHLTTriggerMask_t triggerMask) const;
     157             : 
     158             :   /**
     159             :    * Return a readout list for the active trigger classes.
     160             :    * The list is an 'OR' of the active trugger classes.
     161             :    */
     162             :   AliHLTReadoutList ReadoutList() const {
     163           0 :     return ReadoutList(fTriggers);
     164             :   }
     165             : 
     166             :   /**
     167             :    * Inherited from TObject, this prints the contents of the trigger decision.
     168             :    */
     169             :   virtual void Print(Option_t* option = "") const;
     170             : 
     171             :   /**
     172             :    * this is for compatibility with ESD, fills 2 words with 50 bit trigger masks
     173             :   */
     174             :   void      GetTriggerMaskAll(ULong64_t& low,ULong64_t& high) const;
     175             : 
     176             :   /**
     177             :    * fills a string with the names of all active trigger classes
     178             :    * returns number of classes
     179             :    */
     180             :   int GetFiredTriggerClasses(std::string& string) const;
     181             : 
     182           0 :   AliHLTTriggerMask_t   Mask() const { return fMask; }
     183           0 :   AliHLTTriggerMask_t   Triggers() const { return fTriggers; }
     184           0 :   void                  SetTriggers(AliHLTTriggerMask_t triggers) { fTriggers=triggers; }
     185           0 :   void                  SetTriggers(AliHLTComponentTriggerData trigData) {SetTriggers(ActiveTriggers(trigData));}
     186           0 :   const TArrayL64&      Counters() const { return fCounters; }
     187             :   AliHLTUInt64_t        Counter(int index) const;
     188             :   AliHLTUInt64_t        Counter(const char* classId) const;
     189             :   const char*           Name(int index) const;
     190             :   
     191             :  protected:
     192             :  private:
     193             :   /// Helper                                                                          
     194             :   std::string TriggerMaskToString(AliHLTTriggerMask_t mask) const;
     195             : 
     196             :   /**
     197             :    * Add counters.
     198             :    * Base methods for operators.
     199             :    * @param src    instance to add
     200             :    * @param factor +1/-1 for addition/subtraction
     201             :    * @skipped      target to get the numner of not matching class names
     202             :    */
     203             :   int Add(const AliHLTCTPData& src, int factor, int &skipped);
     204             : 
     205             :   /**
     206             :    * Read the map of trigger class indexes
     207             :    * The map is used in the generation of the TFormula from the trigger
     208             :    * expression in order to handle similar class names correctly.
     209             :    * For names like 'base', 'baseA', 'baseB' the class with the longer name
     210             :    * has to be replaced first.
     211             :    */
     212             :   int ReadMap(vector<unsigned> &map) const;
     213             : 
     214           0 :   int ReadMap() {return ReadMap(fMap);}
     215             : 
     216             :   /** simple char-by-char glob string matching 
     217             :    * e.g. ***FOO matches BARFOO **/
     218             :   Bool_t Globncmp(const char* triggerName, const char* glob, int triggerNameSize, int globSize ) const;
     219             : 
     220             :   AliHLTTriggerMask_t fMask;      /// mask of initialized trigger classes
     221             :   AliHLTTriggerMask_t fTriggers;  /// current trigger
     222             :   TClonesArray        fClassIds;  /// array of trigger class ids
     223             :   TArrayL64           fCounters;  /// trigger class counters
     224             :   vector<unsigned>    fMap;     //! index map for trigger expression evaluation
     225             : 
     226         126 :   ClassDef(AliHLTCTPData, 3)
     227             : };
     228             : 
     229             : #endif

Generated by: LCOV version 1.11