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