]>
Commit | Line | Data |
---|---|---|
4731a36c | 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 | |
9bed6a67 | 11 | /// @author Timur Pocheptsov, Matthias Richter |
4731a36c | 12 | /// @date 05.07.2010 |
13 | /// @brief Generic component for data collection in a TTree | |
14 | ||
9bed6a67 | 15 | #include <list> |
16 | ||
17 | #include <TString.h> | |
18 | ||
4731a36c | 19 | #include "AliHLTProcessor.h" |
20 | ||
21 | class TTree; | |
22 | class TH1; | |
a6b16ade | 23 | class TStopwatch; |
4731a36c | 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 { | |
9bed6a67 | 45 | private: |
46 | enum EDefaults { | |
47 | kMaxEntries = 1000, | |
23ef7d2b | 48 | kDefaultNBins = 200, |
9bed6a67 | 49 | kInterval = 5 |
50 | }; | |
51 | public: | |
52 | /// default constructor | |
4731a36c | 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 | |
9bed6a67 | 61 | virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier); |
4731a36c | 62 | |
9bed6a67 | 63 | protected: |
4731a36c | 64 | /// initialization, overloaded from AliHLTComponent |
9bed6a67 | 65 | int DoInit(int argc, const char** argv); |
66 | /// deinitialization, overloaded from AliHLTComponent | |
4731a36c | 67 | int DoDeinit(); |
68 | /// inherited from AliHLTProcessor, data processing | |
9bed6a67 | 69 | int DoEvent(const AliHLTComponentEventData& evtData, |
70 | AliHLTComponentTriggerData& trigData); | |
4731a36c | 71 | using AliHLTProcessor::DoEvent; |
9bed6a67 | 72 | |
73 | class AliHLTHistogramDefinition { | |
74 | public: | |
75 | AliHLTHistogramDefinition() | |
76 | : fName(), fSize(0), fExpr(), fCut(), fOpt() | |
77 | { | |
78 | } | |
79 | ||
80 | const TString& GetName()const{return fName;} | |
81 | void SetName(const TString& name){fName = name;} | |
82 | ||
83 | int GetSize()const{return fSize;} | |
84 | void SetSize(int size){fSize = size;} | |
85 | ||
86 | const TString& GetExpression()const{return fExpr;} | |
87 | void SetExpression(const TString& expr){fExpr = expr;} | |
88 | ||
89 | const TString& GetCut()const{return fCut;} | |
90 | void SetCut(const TString& cut){fCut = cut;} | |
91 | ||
92 | const TString& GetDrawOption()const{return fOpt;} | |
93 | void SetDrawOption(const TString& opt){fOpt = opt;} | |
94 | ||
95 | private: | |
96 | ||
97 | TString fName; | |
98 | int fSize; | |
99 | TString fExpr; | |
100 | TString fCut; | |
101 | TString fOpt; | |
102 | }; | |
103 | ||
104 | std::list<AliHLTHistogramDefinition> fDefinitions; | |
105 | typedef std::list<AliHLTHistogramDefinition>::iterator list_iterator; | |
106 | typedef std::list<AliHLTHistogramDefinition>::const_iterator list_const_iterator; | |
107 | ||
108 | ||
109 | private: | |
4731a36c | 110 | /// inherited from AliHLTComponent, scan argument |
111 | int ScanConfigurationArgument(int argc, const char** argv); | |
4731a36c | 112 | /// create the tree instance and all branches |
113 | virtual TTree* CreateTree(int argc, const char** argv) = 0; | |
4731a36c | 114 | /// process input blocks and fill tree |
9bed6a67 | 115 | virtual int FillTree(TTree* pTree, const AliHLTComponentEventData& evtData, |
116 | AliHLTComponentTriggerData& trigData ) = 0; | |
117 | /// dtOrigin for PushBack. | |
118 | virtual AliHLTComponentDataType GetOriginDataType()const = 0; | |
119 | /// spec for PushBack | |
120 | virtual AliHLTUInt32_t GetDataSpec()const = 0; | |
121 | /// default histogram definitions. | |
122 | virtual void FillHistogramDefinitions() = 0; | |
4731a36c | 123 | |
124 | /// create a histogram from the tree | |
9bed6a67 | 125 | TH1* CreateHistogram(const AliHLTHistogramDefinition& def); |
126 | /// parse arguments, containing histogram definition. | |
127 | int ParseHistogramDefinition(int argc, const char** argv, int pos, AliHLTHistogramDefinition& dst)const; | |
4731a36c | 128 | |
129 | /// the TTree | |
130 | TTree* fTree; //! the tree instance | |
131 | /// max entries | |
132 | int fMaxEntries; //! maximum number of entries in the circular tree | |
133 | /// publish interval in s | |
9bed6a67 | 134 | unsigned fPublishInterval; //! publish interval in s |
135 | /// time stamp - publish or not. | |
136 | unsigned fLastTime; //! last time the histogramms were published | |
137 | ||
a6b16ade | 138 | TStopwatch* fpEventTimer; //! stopwatch for event processing |
139 | TStopwatch* fpCycleTimer; //! stopwatch for event cycle | |
140 | AliHLTUInt32_t fMaxEventTime; //! allowed maximum processing time in usec | |
141 | AliHLTUInt32_t fNofEventsForce; //! number of events to ignore the processing time | |
142 | AliHLTUInt32_t fForcedEventsCount; //! event count for the forced events | |
143 | AliHLTUInt32_t fSkippedEventsCount; //! number of skipped events | |
144 | ||
145 | static const AliHLTUInt32_t fgkTimeScale; | |
146 | ||
9bed6a67 | 147 | /// copy constructor prohibited |
148 | AliHLTTTreeProcessor(const AliHLTTTreeProcessor&); | |
149 | /// assignment operator prohibited | |
150 | AliHLTTTreeProcessor& operator = (const AliHLTTTreeProcessor&); | |
4731a36c | 151 | |
152 | ClassDef(AliHLTTTreeProcessor, 0) | |
153 | }; | |
154 | #endif |