4 #ifndef ALIHLTGLOBALHISTOCOMPONENT_H
5 #define ALIHLTGLOBALHISTOCOMPONENT_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 *
10 /// @file AliHLTGlobalHistoComponent.h
11 /// @author Matthias Richter
13 /// @brief A histogramming component for global ESD properties based
14 /// on the AliHLTTTreeProcessor
16 #include "AliHLTTTreeProcessor.h"
17 #include "TObjString.h"
18 #include "TObjArray.h"
24 * @class AliHLTGlobalHistoComponent
26 * <h2>General properties:</h2>
28 * Component ID: \b GlobalHisto <br>
29 * Library: \b libAliHLTGlobal.so <br>
30 * Input Data Types: ::kAliHLTAnyDataType <br>
31 * Output Data Types: none <br>
33 * <h2>Mandatory arguments:</h2>
34 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
36 * <h2>Optional arguments:</h2>
37 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
39 * <h2>Configuration:</h2>
40 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
41 * Configuration by component arguments.
43 * <h2>Default CDB entries:</h2>
44 * The component loads no CDB entries.
46 * <h2>Performance:</h2>
47 * The component does not process any event data.
49 * <h2>Memory consumption:</h2>
50 * The component does not process any event data.
52 * <h2>Output size:</h2>
53 * Depending on the mode.
55 * @ingroup alihlt_util_components
57 class AliHLTGlobalHistoComponent : public AliHLTTTreeProcessor
60 /// standard constructor
61 AliHLTGlobalHistoComponent();
63 virtual ~AliHLTGlobalHistoComponent();
65 /// inherited from AliHLTComponent: return id of the component.
66 virtual const char* GetComponentID() {return "GlobalHisto";};
67 /// inherited from AliHLTComponent: input data types
68 virtual void GetInputDataTypes(AliHLTComponentDataTypeList&);
71 /// interface function, see AliHLTComponent for description
72 AliHLTComponentDataType GetOutputDataType();
75 /// inherited from AliHLTComponent: spawn function, create an instance.
76 virtual AliHLTComponent* Spawn() {return new AliHLTGlobalHistoComponent;}
78 void FillHistogramDefinitions();
80 /// @class AliHLTGlobalHistoVariables
81 /// container for the tree branch variables
83 class AliHLTGlobalHistoVariables {
85 AliHLTGlobalHistoVariables() : fCapacity(0), fArrays(), fCount(), fKeys() {}
86 AliHLTGlobalHistoVariables(const AliHLTGlobalHistoVariables& src) : fCapacity(0), fArrays(), fCount(), fKeys() {}
87 ~AliHLTGlobalHistoVariables() {Reset();}
90 int Init(int capacity, const char* names)
94 TString initializer(names);
95 TObjArray* pTokens=initializer.Tokenize(" ");
98 int entries=pTokens->GetEntriesFast();
99 fArrays.resize(entries);
100 fCount.resize(entries);
101 for (int i=0; i<entries; i++) {
102 fKeys[pTokens->At(i)->GetName()]=i;
103 fArrays[i]=new T[fCapacity];
107 if (fArrays.size()!=fCount.size() ||
108 fArrays.size()!=fKeys.size()) {
116 /// capacity for every key
117 int Capacity() const {return fCapacity;}
118 /// number of variables
119 int Variables() const {return fArrays.size();}
121 /// fill variable at index
122 int Fill(unsigned index, T value)
124 if (index>=fArrays.size() || index>=fCount.size()) return -ENOENT;
125 if (fCount[index]>=fCapacity) return -ENOSPC;
127 (fArrays[index])[fCount[index]++]=value;
128 return fCount[index];
131 /// fill variable at key
132 int Fill(const char* key, T value)
134 int index=FindKey(key);
135 if (index<0) return -ENOENT;
136 return Fill(index, value);
140 T* GetArray(const char* key)
142 int index=FindKey(key); if (index<0) return NULL;
143 if ((unsigned)index>=fArrays.size()) return NULL;
144 return fArrays[index];
147 /// get the key of an array
148 const char* GetKey(int index) const
150 for (map<string, int>::const_iterator element=fKeys.begin(); element!=fKeys.end(); element++) {
151 if (element->second==index) return element->first.c_str();
156 /// reset and cleanup arrays
159 for (unsigned i=0; i<fArrays.size(); i++) {delete fArrays[i];}
160 fArrays.clear(); fCount.clear(); fKeys.clear();
164 /// reset the fill counts
167 for (vector<int>::iterator element=fCount.begin(); element!=fCount.end(); element++) *element=0;
171 char GetType() const {AliHLTGlobalHistoVariablesType type(T&); return type.GetType();}
174 int FindKey(const char* key) const
176 map<string, int>::const_iterator element=fKeys.find(key);
177 if (element==fKeys.end()) return -ENOENT;
178 return element->second;
181 /// internal helper class to get the type of the template
182 class AliHLTGlobalHistoVariablesType {
184 AliHLTGlobalHistoVariablesType(float&) : fType('f') {}
185 AliHLTGlobalHistoVariablesType(int&) : fType('i') {}
186 char GetType() const {return fType;}
191 /// capacity of all arrays
193 /// pointers of arrays
194 vector<T*> fArrays; //!
195 /// fill count for arrays
196 vector<int> fCount; //!
198 map<string,int> fKeys; //!
202 /// inherited from AliHLTTTreeProcessor: create the tree instance and all branches
203 TTree* CreateTree(int argc, const char** argv);
204 /// inherited from AliHLTTTreeProcessor: process input blocks and fill tree
205 int FillTree(TTree* pTree, const AliHLTComponentEventData& evtData,
206 AliHLTComponentTriggerData& trigData );
207 /// dtOrigin for PushBack.
208 AliHLTComponentDataType GetOriginDataType() const;
209 /// spec for PushBack
210 AliHLTUInt32_t GetDataSpec() const {return 0;}
212 int ResetVariables();
215 /// copy constructor prohibited
216 AliHLTGlobalHistoComponent(const AliHLTGlobalHistoComponent&);
217 /// assignment operator prohibited
218 AliHLTGlobalHistoComponent& operator=(const AliHLTGlobalHistoComponent&);
220 /// the event number, tree filling variable
222 /// track count, tree filling variable
224 /// V0 count, tree filling variable
226 /// UPC pair count (=1), tree filling variable
227 int fNofUPCpairs; //!
228 /// contributors count, tree filling variable
229 int fNofContributors; //!
230 /// x coordinate of vertex
232 /// y coordinate of vertex
234 /// z coordinate of vertex
236 /// vertex status, found or not
237 bool fVertexStatus; //!
239 /// filling arrays for track parameters
240 AliHLTGlobalHistoVariables<float> fTrackVariables; //!
241 AliHLTGlobalHistoVariables<int> fTrackVariablesInt; //!
243 /// filling arrays for V0 parameters
244 AliHLTGlobalHistoVariables<float> fV0Variables; //!
246 /// filling arrays for UPC parameters
247 AliHLTGlobalHistoVariables<float> fUPCVariables; //!
250 Double_t fGammaCuts[8]; // cuts for gammas
251 Double_t fKsCuts[8]; // cuts for Ks
252 Double_t fLambdaCuts[8]; // cuts for Lambdas
253 Double_t fAPCuts[8]; // cuts for Armenteros-Podolanski plot
255 Int_t fNEvents; // n of processed events
256 Int_t fNGammas; // n found total
257 Int_t fNKShorts; // n found total
258 Int_t fNLambdas; // n found total
259 Int_t fNPi0s; // n found total
261 ClassDef(AliHLTGlobalHistoComponent, 0) // HLT Global Histogram component