]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliHLTGlobalVertexerHistoComponent.cxx
New method PrepareToRead to be able of using the container without the runloader
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalVertexerHistoComponent.cxx
CommitLineData
de0257eb 1//**************************************************************************
2//* This file is property of and copyright by the ALICE HLT Project *
3//* ALICE Experiment at CERN, All rights reserved. *
4//* *
5//* Primary Authors: Timur.Pocheptsov@cern.ch *
6//* for The ALICE HLT Project. *
7//* *
8//* Permission to use, copy, modify and distribute this software and its *
9//* documentation strictly for non-commercial purposes is hereby granted *
10//* without fee, provided that the above copyright notice appears in all *
11//* copies and that both the copyright notice and this permission notice *
12//* appear in the supporting documentation. The authors make no claims *
13//* about the suitability of this software for any purpose. It is *
14//* provided "as is" without express or implied warranty. *
15//**************************************************************************
16
17/** @file AliHLTGlobalVertexerComponent.h
18 @author Timur Pocheptsov
19 @brief Component for monitor primary vertex
20*/
21
22#include "AliESDVertex.h"
23#include "AliESDEvent.h"
24
25#include "AliHLTGlobalVertexerHistoComponent.h"
26
27ClassImp(AliHLTGlobalVertexerHistoComponent)
28
29AliHLTGlobalVertexerHistoComponent::AliHLTGlobalVertexerHistoComponent()
30 :
ac0d701f 31 fRefreshPeriod(1000),
32 fFillSecond(0),
33 fFillSecondSPD(0)
de0257eb 34{
35 //Default ctor.
ac0d701f 36 for( int i=0; i<2; i++ ){
37 fPrimaryXY[i].SetName("primVertexXY");
38 fPrimaryXY[i].SetTitle("HLT: Primary vertex distribution in XY");
39 fPrimaryXY[i].SetMarkerStyle(8);
40 fPrimaryXY[i].SetMarkerSize(0.4);
41 fPrimaryXY[i].SetYTitle("Y [cm]");
42 fPrimaryXY[i].SetXTitle("X [cm]");
43 //fPrimaryXY[i].SetStats(0);
44 //fPrimaryXY[i].SetBit(TH1::kCanRebin);
45
46 fPrimaryX[i].SetName("primVertexX");
47 fPrimaryX[i].SetTitle("HLT: Primary vertex distribution in X");
48 fPrimaryX[i].SetMarkerStyle(8);
49 fPrimaryX[i].SetMarkerSize(0.4);
50 fPrimaryX[i].SetXTitle("X [cm]");
51 //fPrimaryX[i].SetStats(0);
52 //fPrimaryX[i].SetBit(TH1::kCanRebin);
53
54 fPrimaryY[i].SetName("primVertexY");
55 fPrimaryY[i].SetTitle("HLT: Primary vertex distribution in Y");
56 fPrimaryY[i].SetMarkerStyle(8);
57 fPrimaryY[i].SetMarkerSize(0.4);
58 fPrimaryY[i].SetXTitle("Y [cm]");
59 //fPrimaryY[i].SetStats(0);
60 //fPrimaryX[i].SetBit(TH1::kCanRebin);
61
62 fPrimaryZ[i].SetName("primVertexZ");
63 fPrimaryZ[i].SetTitle("HLT: Primary vertex distribution in Z");
64 fPrimaryZ[i].SetMarkerStyle(8);
65 fPrimaryZ[i].SetMarkerSize(0.4);
66 fPrimaryZ[i].SetXTitle("Z [cm]");
67 //fPrimaryZ[i].SetStats(0);
68 //fPrimaryX[i].SetBit(TH1::kCanRebin);
69
70
71 fSPDVertexXY[i].SetName("spdVertexXY");
72 fSPDVertexXY[i].SetTitle("HLT: SPD vertex distribution in XY");
73 fSPDVertexXY[i].SetMarkerStyle(8);
74 fSPDVertexXY[i].SetMarkerSize(0.4);
75 fSPDVertexXY[i].SetYTitle("Y [cm]");
76 fSPDVertexXY[i].SetXTitle("X [cm]");
77 fSPDVertexXY[i].SetStats(0);
78 //fSPDVertexXY[i].SetBit(TH1::kCanRebin);
79
80 fSPDVertexX[i].SetName("spdVertexX");
81 fSPDVertexX[i].SetTitle("HLT: SPD vertex distribution in X");
82 fSPDVertexX[i].SetMarkerStyle(8);
83 fSPDVertexX[i].SetMarkerSize(0.4);
84 fSPDVertexX[i].SetXTitle("X [cm]");
85 //fSPDVertexX[i].SetStats(0);
86 //fSPDVertexX[i].SetBit(TH1::kCanRebin);
87
88 fSPDVertexY[i].SetName("spdVertexY");
89 fSPDVertexY[i].SetTitle("HLT: SPD vertex distribution in Y");
90 fSPDVertexY[i].SetMarkerStyle(8);
91 fSPDVertexY[i].SetMarkerSize(0.4);
92 fSPDVertexY[i].SetXTitle("Y [cm]");
93 //fSPDVertexY[i].SetStats(0);
94 //fSPDVertexY[i].SetBit(TH1::kCanRebin);
95
96 fSPDVertexZ[i].SetName("spdVertexZ");
97 fSPDVertexZ[i].SetTitle("HLT: SPD vertex distribution in Z");
98 fSPDVertexZ[i].SetMarkerStyle(8);
99 fSPDVertexZ[i].SetMarkerSize(0.4);
100 fSPDVertexZ[i].SetXTitle("Z [cm]");
101 //fSPDVertexZ[i].SetStats(0);
102 //fSPDVertexZ[i].SetBit(TH1::kCanRebin);
103 }
de0257eb 104}
105
106const char* AliHLTGlobalVertexerHistoComponent::GetComponentID()
107{
108 //Unique component id.
109 return "GlobalVertexerHisto";
110}
111
112void AliHLTGlobalVertexerHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
113{
114 //
115 list.clear();
116 list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut);
117 list.push_back(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS );
118}
119
120
d2831d6a 121
de0257eb 122AliHLTComponentDataType AliHLTGlobalVertexerHistoComponent::GetOutputDataType()
123{
d2831d6a 124 // see header file for class documentation
125 return kAliHLTMultipleDataType;
de0257eb 126}
127
d2831d6a 128int AliHLTGlobalVertexerHistoComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
129
130{
131 // see header file for class documentation
132 tgtList.clear();
133 tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginOut);
134 tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginITSSPD);
135 return tgtList.size();
136}
137
138
de0257eb 139void AliHLTGlobalVertexerHistoComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
140{
141 //8000 is a temporary number. Find the way to
142 //estimate 3 serialized TH2F.
143 constBase = GetOutputDataSize();
144 inputMultiplier = 1.;
145}
146
147AliHLTComponent* AliHLTGlobalVertexerHistoComponent::Spawn()
148{
149 //Should be const, I think, but it's not.
150 return new AliHLTGlobalVertexerHistoComponent;
151}
152
ac0d701f 153void AliHLTGlobalVertexerHistoComponent::SetDefaultConfiguration()
154{
155 // Set default configuration for the CA tracker component
156 // Some parameters can be later overwritten from the OCDB
157
158 fRefreshPeriod = 1000;
159}
160
161int AliHLTGlobalVertexerHistoComponent::ReadConfigurationString( const char* arguments )
162{
163 // Set configuration parameters for the CA tracker component from the string
164
165 int iResult = 0;
166 if ( !arguments ) return iResult;
167
168 TString allArgs = arguments;
169 TString argument;
170 int bMissingParam = 0;
171
172 TObjArray* pTokens = allArgs.Tokenize( " " );
173
174 int nArgs = pTokens ? pTokens->GetEntries() : 0;
175
176 for ( int i = 0; i < nArgs; i++ ) {
177 argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
178 if ( argument.IsNull() ) continue;
179
180 if ( argument.CompareTo( "-refresh" ) == 0 ) {
181 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
182 fRefreshPeriod = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
183 HLTInfo( "N events for refresh of the run vertex is set to: %d", fRefreshPeriod );
184 continue;
185 }
186
187
188 HLTError( "Unknown option \"%s\"", argument.Data() );
189 iResult = -EINVAL;
190 }
191 delete pTokens;
192
193 if ( bMissingParam ) {
194 HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
195 iResult = -EINVAL;
196 }
197
198 return iResult;
199}
200
201
202int AliHLTGlobalVertexerHistoComponent::DoInit(int argc, const char** argv)
de0257eb 203{
204 //Clear all bin contents and statistics.
de0257eb 205
ac0d701f 206 SetDefaultConfiguration();
207
208
209 TString arguments = "";
210 for ( int i = 0; i < argc; i++ ) {
211 if ( !arguments.IsNull() ) arguments += " ";
212 arguments += argv[i];
213 }
214
215 int ret = ReadConfigurationString( arguments.Data() );
216 for( int i=0; i<2; i++ ){
217 fPrimaryXY[i].Reset();
218 fPrimaryX[i].Reset();
219 fPrimaryY[i].Reset();
220 fPrimaryZ[i].Reset();
221 fSPDVertexXY[i].Reset();
222 fSPDVertexX[i].Reset();
223 fSPDVertexY[i].Reset();
224 fSPDVertexZ[i].Reset();
225 //Set bin numbers and axis ranges[i].
226 fPrimaryXY[i].SetBins(1000, -1., 1., 1000, -1., 1.);
227 fPrimaryX[i].SetBins( 1000, -1., 1.);
228 fPrimaryY[i].SetBins( 1000, -1., 1.);
229 fPrimaryZ[i].SetBins( 1000, -30., 30.);
230 fSPDVertexXY[i].SetBins(1000, -1., 1., 1000, -1., 1.);
231 fSPDVertexX[i].SetBins(1000, -1., 1.);
232 fSPDVertexY[i].SetBins(1000, -1., 1.);
233 fSPDVertexZ[i].SetBins(1000, -30., 30.);
234 }
235 fFillSecond = 0;
236 fFillSecondSPD = 0;
237
238 return ret;
de0257eb 239}
240
241int AliHLTGlobalVertexerHistoComponent::DoDeinit()
242{
243 //Nothing to delete or "do de init" yet.
244 return 0;
245}
246
247int AliHLTGlobalVertexerHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
248 const AliHLTComponentBlockData* /*blocks*/,
249 AliHLTComponentTriggerData& /*trigData*/,
250 AliHLTUInt8_t* /*outputPtr*/,
251 AliHLTUInt32_t& size,
252 AliHLTComponentBlockDataList& /*outputBlocks*/)
253{
254 //Fill histogramms.
255 if (GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR))
256 return 0;
257
258 if (GetOutputDataSize() > size) {
259 Logging(kHLTLogFatal, "HLT::AliHLTGlobalVertexerHistoComponent::DoEvent", "Too much data",
260 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
261 GetOutputDataSize(), size);
262 return -ENOSPC;
263 }
264
ac0d701f 265 if( fRefreshPeriod>0 ){
266 if( fPrimaryXY[0].GetEntries()+1>=fRefreshPeriod/2 ) fFillSecond = 1;
267 if( fSPDVertexXY[0].GetEntries()+1>=fRefreshPeriod/2 ) fFillSecondSPD = 1;
268 }
de0257eb 269
ac0d701f 270 int iResult = 0;
271
de0257eb 272 bool wasITS = 0;
273 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
274 if( AliESDVertex *vertex = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) ) ){
c3c8af48 275 if( vertex && vertex->GetNContributors() >= 5 ){
ac0d701f 276 for( int i=0; i<=fFillSecondSPD; i++ ){
277 if( fRefreshPeriod>0 && fSPDVertexXY[i].GetEntries()>=fRefreshPeriod ){
278 fSPDVertexXY[i].Reset();
279 fSPDVertexX[i].Reset();
280 fSPDVertexY[i].Reset();
281 fSPDVertexZ[i].Reset();
282 }
283 fSPDVertexXY[i].Fill(vertex->GetX(), vertex->GetY());
284 fSPDVertexX[i].Fill(vertex->GetX() );
285 fSPDVertexY[i].Fill(vertex->GetY() );
286 fSPDVertexZ[i].Fill(vertex->GetZ() );
287 }
de0257eb 288 wasITS = 1;
289 }
290 } else {
291 HLTError("ITS SPD vertex object is corrupted");
292 iResult = -EINVAL;
293 }
294 }
295
296 for (const TObject* iter = GetFirstInputObject(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut); iter; iter = GetNextInputObject() ) {
297 if (AliESDEvent* event = dynamic_cast<AliESDEvent*>((TObject*)iter)) {
298 event->GetStdContent();
299 const AliESDVertex* vertex = event->GetPrimaryVertexTracks();
c3c8af48 300 if (vertex && vertex->GetNContributors() >= 5) {
ac0d701f 301 for( int i=0; i<=fFillSecond; i++ ){
302 if( fRefreshPeriod>0 && fPrimaryXY[i].GetEntries()>=fRefreshPeriod ){
303 fPrimaryXY[i].Reset();
304 fPrimaryX[i].Reset();
305 fPrimaryY[i].Reset();
306 fPrimaryZ[i].Reset();
307 }
308 fPrimaryXY[i].Fill(vertex->GetX(), vertex->GetY());
309 fPrimaryX[i].Fill(vertex->GetX());
310 fPrimaryY[i].Fill(vertex->GetY());
311 fPrimaryZ[i].Fill(vertex->GetZ());
312 }
de0257eb 313 }
314 if( !wasITS ){
315 vertex = event->GetPrimaryVertexSPD();
316 if( vertex && vertex->GetNContributors() >= 3 ){
ac0d701f 317 for( int i=0; i<=fFillSecondSPD; i++ ){
318 if( fRefreshPeriod>0 && fSPDVertexXY[i].GetEntries()>=fRefreshPeriod ){
319 fSPDVertexXY[i].Reset();
320 fSPDVertexX[i].Reset();
321 fSPDVertexY[i].Reset();
322 fSPDVertexZ[i].Reset();
323 }
324 fSPDVertexXY[i].Fill(vertex->GetX(), vertex->GetY());
325 fSPDVertexX[i].Fill(vertex->GetX() );
326 fSPDVertexY[i].Fill(vertex->GetY() );
327 fSPDVertexZ[i].Fill(vertex->GetZ() );
328 }
de0257eb 329 }
330 }
331 } else {
332 HLTError("ESD event object is corrupted");
333 iResult = -EINVAL;
334 }
335 }
ac0d701f 336
337 int i = ( fPrimaryXY[1].GetEntries() > fPrimaryXY[0].GetEntries() );
338
339 PushBack(&fPrimaryXY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0);
340 PushBack(&fPrimaryZ[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0);
341 PushBack(&fPrimaryX[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0);
342 PushBack(&fPrimaryY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0);
343
344 i = ( fSPDVertexXY[1].GetEntries() > fSPDVertexXY[0].GetEntries() );
345
346 //cout<<"bla NEntr = "<<fPrimaryXY[0].GetEntries()<<" / "<<fPrimaryXY[1].GetEntries()<<endl;
347 //cout<<"bla NEntr SPD = "<<fSPDVertexXY[0].GetEntries()<<" / "<<fSPDVertexXY[1].GetEntries()<<endl;
348
349 PushBack(&fSPDVertexXY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
350 PushBack(&fSPDVertexZ[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
351 PushBack(&fSPDVertexX[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
352 PushBack(&fSPDVertexY[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
de0257eb 353
354 return iResult;
355}
356
357int AliHLTGlobalVertexerHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
358{
359 //Do nothing at the moment, but at least log (base class version).
360 return AliHLTComponent::Reconfigure(cdbEntry, chainId);
361}
362
363unsigned long AliHLTGlobalVertexerHistoComponent::GetOutputDataSize()const
364{
365 //8000 is a temporary number. Find the way to
366 //estimate serialized TH2F.
367 return 20000;
368}