]>
Commit | Line | Data |
---|---|---|
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 | ||
29 | ClassImp(AliHLTGlobalVertexerHistoComponent) | |
30 | ||
31 | AliHLTGlobalVertexerHistoComponent::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 | ||
109 | const char* AliHLTGlobalVertexerHistoComponent::GetComponentID() | |
110 | { | |
111 | //Unique component id. | |
112 | return "GlobalVertexerHisto"; | |
113 | } | |
114 | ||
115 | void AliHLTGlobalVertexerHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
116 | { | |
117 | // | |
118 | list.clear(); | |
119 | list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut); | |
120 | list.push_back(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS ); | |
121 | } | |
122 | ||
123 | ||
d2831d6a | 124 | |
de0257eb | 125 | AliHLTComponentDataType AliHLTGlobalVertexerHistoComponent::GetOutputDataType() |
126 | { | |
d2831d6a | 127 | // see header file for class documentation |
128 | return kAliHLTMultipleDataType; | |
de0257eb | 129 | } |
130 | ||
d2831d6a | 131 | int AliHLTGlobalVertexerHistoComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) |
132 | ||
133 | { | |
134 | // see header file for class documentation | |
135 | tgtList.clear(); | |
136 | tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginOut); | |
137 | tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginITSSPD); | |
138 | return tgtList.size(); | |
139 | } | |
140 | ||
141 | ||
de0257eb | 142 | void AliHLTGlobalVertexerHistoComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) |
143 | { | |
144 | //8000 is a temporary number. Find the way to | |
145 | //estimate 3 serialized TH2F. | |
146 | constBase = GetOutputDataSize(); | |
147 | inputMultiplier = 1.; | |
148 | } | |
149 | ||
150 | AliHLTComponent* AliHLTGlobalVertexerHistoComponent::Spawn() | |
151 | { | |
152 | //Should be const, I think, but it's not. | |
153 | return new AliHLTGlobalVertexerHistoComponent; | |
154 | } | |
155 | ||
ac0d701f | 156 | void AliHLTGlobalVertexerHistoComponent::SetDefaultConfiguration() |
157 | { | |
158 | // Set default configuration for the CA tracker component | |
159 | // Some parameters can be later overwritten from the OCDB | |
160 | ||
161 | fRefreshPeriod = 1000; | |
162 | } | |
163 | ||
164 | int AliHLTGlobalVertexerHistoComponent::ReadConfigurationString( const char* arguments ) | |
165 | { | |
166 | // Set configuration parameters for the CA tracker component from the string | |
167 | ||
168 | int iResult = 0; | |
169 | if ( !arguments ) return iResult; | |
170 | ||
171 | TString allArgs = arguments; | |
172 | TString argument; | |
173 | int bMissingParam = 0; | |
174 | ||
175 | TObjArray* pTokens = allArgs.Tokenize( " " ); | |
176 | ||
177 | int nArgs = pTokens ? pTokens->GetEntries() : 0; | |
178 | ||
179 | for ( int i = 0; i < nArgs; i++ ) { | |
180 | argument = ( ( TObjString* )pTokens->At( i ) )->GetString(); | |
181 | if ( argument.IsNull() ) continue; | |
182 | ||
183 | if ( argument.CompareTo( "-refresh" ) == 0 ) { | |
184 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
185 | fRefreshPeriod = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi(); | |
186 | HLTInfo( "N events for refresh of the run vertex is set to: %d", fRefreshPeriod ); | |
187 | continue; | |
188 | } | |
189 | ||
190 | ||
191 | HLTError( "Unknown option \"%s\"", argument.Data() ); | |
192 | iResult = -EINVAL; | |
193 | } | |
194 | delete pTokens; | |
195 | ||
196 | if ( bMissingParam ) { | |
197 | HLTError( "Specifier missed for parameter \"%s\"", argument.Data() ); | |
198 | iResult = -EINVAL; | |
199 | } | |
200 | ||
201 | return iResult; | |
202 | } | |
203 | ||
204 | ||
205 | int AliHLTGlobalVertexerHistoComponent::DoInit(int argc, const char** argv) | |
de0257eb | 206 | { |
207 | //Clear all bin contents and statistics. | |
de0257eb | 208 | |
ac0d701f | 209 | SetDefaultConfiguration(); |
210 | ||
211 | ||
212 | TString arguments = ""; | |
213 | for ( int i = 0; i < argc; i++ ) { | |
214 | if ( !arguments.IsNull() ) arguments += " "; | |
215 | arguments += argv[i]; | |
216 | } | |
217 | ||
218 | int ret = ReadConfigurationString( arguments.Data() ); | |
219 | for( int i=0; i<2; i++ ){ | |
220 | fPrimaryXY[i].Reset(); | |
221 | fPrimaryX[i].Reset(); | |
222 | fPrimaryY[i].Reset(); | |
223 | fPrimaryZ[i].Reset(); | |
224 | fSPDVertexXY[i].Reset(); | |
225 | fSPDVertexX[i].Reset(); | |
226 | fSPDVertexY[i].Reset(); | |
227 | fSPDVertexZ[i].Reset(); | |
228 | //Set bin numbers and axis ranges[i]. | |
229 | fPrimaryXY[i].SetBins(1000, -1., 1., 1000, -1., 1.); | |
230 | fPrimaryX[i].SetBins( 1000, -1., 1.); | |
231 | fPrimaryY[i].SetBins( 1000, -1., 1.); | |
232 | fPrimaryZ[i].SetBins( 1000, -30., 30.); | |
233 | fSPDVertexXY[i].SetBins(1000, -1., 1., 1000, -1., 1.); | |
234 | fSPDVertexX[i].SetBins(1000, -1., 1.); | |
235 | fSPDVertexY[i].SetBins(1000, -1., 1.); | |
236 | fSPDVertexZ[i].SetBins(1000, -30., 30.); | |
237 | } | |
238 | fFillSecond = 0; | |
239 | fFillSecondSPD = 0; | |
e419c1ae | 240 | fUID = 0; |
ac0d701f | 241 | return ret; |
de0257eb | 242 | } |
243 | ||
244 | int AliHLTGlobalVertexerHistoComponent::DoDeinit() | |
245 | { | |
246 | //Nothing to delete or "do de init" yet. | |
e419c1ae | 247 | fUID = 0; |
de0257eb | 248 | return 0; |
249 | } | |
250 | ||
e419c1ae | 251 | int AliHLTGlobalVertexerHistoComponent::DoEvent(const AliHLTComponentEventData& evtData, |
de0257eb | 252 | const AliHLTComponentBlockData* /*blocks*/, |
253 | AliHLTComponentTriggerData& /*trigData*/, | |
254 | AliHLTUInt8_t* /*outputPtr*/, | |
255 | AliHLTUInt32_t& size, | |
256 | AliHLTComponentBlockDataList& /*outputBlocks*/) | |
257 | { | |
258 | //Fill histogramms. | |
259 | if (GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) | |
260 | return 0; | |
261 | ||
e419c1ae | 262 | if( fUID == 0 ){ |
263 | TTimeStamp t; | |
264 | fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID; | |
265 | //cout<<"\nSet id to "<<fUID<<endl; | |
266 | } | |
267 | ||
de0257eb | 268 | if (GetOutputDataSize() > size) { |
269 | Logging(kHLTLogFatal, "HLT::AliHLTGlobalVertexerHistoComponent::DoEvent", "Too much data", | |
270 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", | |
271 | GetOutputDataSize(), size); | |
272 | return -ENOSPC; | |
273 | } | |
274 | ||
ac0d701f | 275 | if( fRefreshPeriod>0 ){ |
276 | if( fPrimaryXY[0].GetEntries()+1>=fRefreshPeriod/2 ) fFillSecond = 1; | |
277 | if( fSPDVertexXY[0].GetEntries()+1>=fRefreshPeriod/2 ) fFillSecondSPD = 1; | |
278 | } | |
de0257eb | 279 | |
ac0d701f | 280 | int iResult = 0; |
281 | ||
de0257eb | 282 | bool wasITS = 0; |
283 | for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) { | |
284 | if( AliESDVertex *vertex = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) ) ){ | |
c3c8af48 | 285 | if( vertex && vertex->GetNContributors() >= 5 ){ |
ac0d701f | 286 | for( int i=0; i<=fFillSecondSPD; i++ ){ |
287 | if( fRefreshPeriod>0 && fSPDVertexXY[i].GetEntries()>=fRefreshPeriod ){ | |
288 | fSPDVertexXY[i].Reset(); | |
289 | fSPDVertexX[i].Reset(); | |
290 | fSPDVertexY[i].Reset(); | |
291 | fSPDVertexZ[i].Reset(); | |
292 | } | |
293 | fSPDVertexXY[i].Fill(vertex->GetX(), vertex->GetY()); | |
294 | fSPDVertexX[i].Fill(vertex->GetX() ); | |
295 | fSPDVertexY[i].Fill(vertex->GetY() ); | |
296 | fSPDVertexZ[i].Fill(vertex->GetZ() ); | |
297 | } | |
de0257eb | 298 | wasITS = 1; |
299 | } | |
300 | } else { | |
301 | HLTError("ITS SPD vertex object is corrupted"); | |
302 | iResult = -EINVAL; | |
303 | } | |
304 | } | |
305 | ||
306 | for (const TObject* iter = GetFirstInputObject(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut); iter; iter = GetNextInputObject() ) { | |
307 | if (AliESDEvent* event = dynamic_cast<AliESDEvent*>((TObject*)iter)) { | |
308 | event->GetStdContent(); | |
309 | const AliESDVertex* vertex = event->GetPrimaryVertexTracks(); | |
c3c8af48 | 310 | if (vertex && vertex->GetNContributors() >= 5) { |
ac0d701f | 311 | for( int i=0; i<=fFillSecond; i++ ){ |
312 | if( fRefreshPeriod>0 && fPrimaryXY[i].GetEntries()>=fRefreshPeriod ){ | |
313 | fPrimaryXY[i].Reset(); | |
314 | fPrimaryX[i].Reset(); | |
315 | fPrimaryY[i].Reset(); | |
316 | fPrimaryZ[i].Reset(); | |
317 | } | |
318 | fPrimaryXY[i].Fill(vertex->GetX(), vertex->GetY()); | |
319 | fPrimaryX[i].Fill(vertex->GetX()); | |
320 | fPrimaryY[i].Fill(vertex->GetY()); | |
321 | fPrimaryZ[i].Fill(vertex->GetZ()); | |
322 | } | |
de0257eb | 323 | } |
324 | if( !wasITS ){ | |
325 | vertex = event->GetPrimaryVertexSPD(); | |
326 | if( vertex && vertex->GetNContributors() >= 3 ){ | |
ac0d701f | 327 | for( int i=0; i<=fFillSecondSPD; i++ ){ |
328 | if( fRefreshPeriod>0 && fSPDVertexXY[i].GetEntries()>=fRefreshPeriod ){ | |
329 | fSPDVertexXY[i].Reset(); | |
330 | fSPDVertexX[i].Reset(); | |
331 | fSPDVertexY[i].Reset(); | |
332 | fSPDVertexZ[i].Reset(); | |
333 | } | |
334 | fSPDVertexXY[i].Fill(vertex->GetX(), vertex->GetY()); | |
335 | fSPDVertexX[i].Fill(vertex->GetX() ); | |
336 | fSPDVertexY[i].Fill(vertex->GetY() ); | |
337 | fSPDVertexZ[i].Fill(vertex->GetZ() ); | |
338 | } | |
de0257eb | 339 | } |
340 | } | |
341 | } else { | |
342 | HLTError("ESD event object is corrupted"); | |
343 | iResult = -EINVAL; | |
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 | ||
367 | int 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 | ||
373 | unsigned long AliHLTGlobalVertexerHistoComponent::GetOutputDataSize()const | |
374 | { | |
375 | //8000 is a temporary number. Find the way to | |
376 | //estimate serialized TH2F. | |
377 | return 20000; | |
378 | } |