]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
f531a546 | 16 | // $Id$ |
4c039060 | 17 | |
959fbac5 | 18 | /////////////////////////////////////////////////////////////////////////// |
19 | // Class AliSignal | |
dafe31a2 | 20 | // Generic handling of (extrapolated) detector signals. |
959fbac5 | 21 | // |
b721efb7 | 22 | // The user can decide to store either calibrated or uncalibrated signals. |
23 | // Via the specification of a gain and offset or/and an explicit | |
24 | // (de)calibration function both calibrated and uncalibrated signals | |
25 | // can always be obtained. For details see the documentation of the | |
26 | // memberfunction GetSignal() and the class AliAttrib. | |
27 | // The explicit specification of a (de)calibration function offers the | |
28 | // maximum flexibility and also allows automatic indication whether | |
29 | // calibrated or uncalibrated data has been stored. | |
30 | // The latter can be achieved by only specifying a calibration function | |
31 | // (and no de-calibration function) in case uncalibrated data is stored, | |
32 | // whereas in case of stored calibrated data the user should only | |
33 | // provide a de-calibration function (and no calibration function). | |
34 | // | |
959fbac5 | 35 | // Note : |
36 | // ------ | |
37 | // Signal positions (r) and reference frames (f) are specified via | |
38 | // SetPosition(r,f) under the following conventions : | |
39 | // | |
40 | // f="car" ==> r is Cartesian (x,y,z) | |
41 | // f="sph" ==> r is Spherical (r,theta,phi) | |
42 | // f="cyl" ==> r is Cylindrical (rho,phi,z) | |
43 | // | |
44 | // The same holds for SetPositionErrors(). | |
45 | // | |
46 | // All angles are in radians. | |
47 | // | |
48 | // Example : | |
49 | // --------- | |
50 | // | |
51 | // AliSignal s; | |
7a5c405b | 52 | // s.SetName("Start counter"); |
959fbac5 | 53 | // Float_t pos[3]={-1,25,7}; |
54 | // Float_t err[3]={0.03,0.7,0.18}; | |
55 | // Float_t signal=120.8; | |
56 | // Float_t error=1.73; | |
1fbffa23 | 57 | // Float_t offset=-12.78; |
58 | // Float_t gain=250; | |
959fbac5 | 59 | // s.SetPosition(pos,"car"); |
60 | // s.SetPositionErrors(err,"car"); | |
61 | // s.SetSignal(signal); | |
62 | // s.SetSignalError(error); | |
1fbffa23 | 63 | // s.SetOffset(offset); |
64 | // s.SetGain(gain); | |
959fbac5 | 65 | // Float_t loc[3],dr[3],sigma; |
66 | // s.GetPosition(loc,"sph"); | |
67 | // s.GetPositionErrors(dr,"sph"); | |
68 | // Float_t adc=s.GetSignal(); | |
69 | // Float_t sigma=s.GetSignalError(); | |
70 | // | |
c72198f1 | 71 | // AliSignal q; // In the example below a signal contains the |
959fbac5 | 72 | // // following data : timing, ADC and dE/dx |
965bd237 | 73 | // q.SetNameTitle("Hybrid","Test for multiple signal data"); |
959fbac5 | 74 | // q.SetPosition(pos,"car"); |
75 | // q.SetPositionErrors(err,"car"); | |
7a5c405b | 76 | // signal=82.5; // e.g. signal time in ns |
959fbac5 | 77 | // error=2.01; |
1fbffa23 | 78 | // offset=0.003; |
b721efb7 | 79 | // q.SetSlotName("TOF",1); |
959fbac5 | 80 | // q.SetSignal(signal,1); |
81 | // q.SetSignalError(error,1); | |
1fbffa23 | 82 | // q.SetOffset(offset,1); |
959fbac5 | 83 | // signal=268.1; // e.g. ADC value of signal |
84 | // error=3.75; | |
1fbffa23 | 85 | // gain=120.78; |
b721efb7 | 86 | // offset=1.5732; |
965bd237 | 87 | // // Addressing via name specification instead of index |
b721efb7 | 88 | // q.SetSlotName("ADC",2); |
965bd237 | 89 | // q.SetSignal(signal,"ADC"); |
90 | // q.SetSignalError(error,"ADC"); | |
91 | // q.SetGain(gain,"ADC"); | |
b721efb7 | 92 | // q.SetOffset(offset,"ADC"); |
959fbac5 | 93 | // signal=23.7; // e.g. corresponding dE/dx value |
94 | // error=0.48; | |
b721efb7 | 95 | // TF1 f=("calib","[0]*pow(x,2)+[1]"); // dE/dx calib. function |
96 | // f.SetParameter(0,3.285); | |
97 | // f.SetParameter(1,-18.67); | |
98 | // q.SetSlotName("dE/dx",3); | |
99 | // q.SetCalFunction(&f,"dE/dx"); | |
100 | // q.SetSignal(signal,"dE/dx"); | |
101 | // q.SetSignalError(error,"dE/dx"); | |
102 | // | |
103 | // // Signal retrieval with various (de)calibration modes | |
104 | // Float_t tof=q.GetSignal("TOF"); | |
105 | // Float_t adc=q.GetSignal("ADC",1); | |
106 | // Float_t dedx=q.GetSignal("dE/dx",3); | |
965bd237 | 107 | // |
959fbac5 | 108 | //--- Author: Nick van Eijndhoven 23-jan-1999 UU-SAP Utrecht |
f531a546 | 109 | //- Modified: NvE $Date$ UU-SAP Utrecht |
959fbac5 | 110 | /////////////////////////////////////////////////////////////////////////// |
111 | ||
d88f97cc | 112 | #include "AliSignal.h" |
5f25234b | 113 | #include "AliTrack.h" |
c72198f1 | 114 | #include "Riostream.h" |
d88f97cc | 115 | |
116 | ClassImp(AliSignal) // Class implementation to enable ROOT I/O | |
117 | ||
1c01b4f8 | 118 | AliSignal::AliSignal() : TNamed(),AliPosition(),AliAttrib() |
d88f97cc | 119 | { |
959fbac5 | 120 | // Creation of an AliSignal object and initialisation of parameters. |
1fbffa23 | 121 | // Several signal values (with errors) can be stored in different slots. |
fdadc78a | 122 | // If needed, the storage for values (and errors) will be expanded automatically |
123 | // when entering values and/or errors. | |
1fbffa23 | 124 | fSignals=0; |
125 | fDsignals=0; | |
5ae71069 | 126 | fSigflags=0; |
1fbffa23 | 127 | fWaveforms=0; |
5f25234b | 128 | fLinks=0; |
965bd237 | 129 | fDevice=0; |
d0120ca2 | 130 | fTracks=0; |
d88f97cc | 131 | } |
132 | /////////////////////////////////////////////////////////////////////////// | |
133 | AliSignal::~AliSignal() | |
134 | { | |
135 | // Destructor to delete dynamically allocated memory | |
1fbffa23 | 136 | if (fSignals) |
959fbac5 | 137 | { |
1fbffa23 | 138 | delete fSignals; |
139 | fSignals=0; | |
959fbac5 | 140 | } |
1fbffa23 | 141 | if (fDsignals) |
959fbac5 | 142 | { |
1fbffa23 | 143 | delete fDsignals; |
144 | fDsignals=0; | |
959fbac5 | 145 | } |
5ae71069 | 146 | if (fSigflags) |
147 | { | |
148 | delete fSigflags; | |
149 | fSigflags=0; | |
150 | } | |
1fbffa23 | 151 | if (fWaveforms) |
c72198f1 | 152 | { |
1fbffa23 | 153 | delete fWaveforms; |
154 | fWaveforms=0; | |
c72198f1 | 155 | } |
5f25234b | 156 | if (fLinks) |
d0120ca2 | 157 | { |
158 | delete fLinks; | |
159 | fLinks=0; | |
160 | } | |
161 | if (fTracks) | |
5f25234b | 162 | { |
ea0b5b7f | 163 | // Remove this signal from all related tracks |
d0120ca2 | 164 | for (Int_t i=1; i<=GetNtracks(); i++) |
ea0b5b7f | 165 | { |
d0120ca2 | 166 | AliTrack* tx=GetTrack(i); |
167 | if (tx) tx->RemoveSignal(*this,0); | |
ea0b5b7f | 168 | } |
d0120ca2 | 169 | delete fTracks; |
170 | fTracks=0; | |
5f25234b | 171 | } |
d88f97cc | 172 | } |
173 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 174 | AliSignal::AliSignal(const AliSignal& s) : TNamed(s),AliPosition(s),AliAttrib(s) |
8e8e6c7f | 175 | { |
176 | // Copy constructor | |
1fbffa23 | 177 | fSignals=0; |
178 | fDsignals=0; | |
5ae71069 | 179 | fSigflags=0; |
1fbffa23 | 180 | fWaveforms=0; |
5f25234b | 181 | fLinks=0; |
d0120ca2 | 182 | fTracks=0; |
8e8e6c7f | 183 | |
965bd237 | 184 | // Don't copy the owning device pointer for the copy |
185 | fDevice=0; | |
186 | ||
1fbffa23 | 187 | Int_t n=s.GetNvalues(); |
188 | Double_t val; | |
189 | for (Int_t i=1; i<=n; i++) | |
8e8e6c7f | 190 | { |
5ae71069 | 191 | if (s.GetSignalFlag(i)) |
192 | { | |
193 | val=s.GetSignal(i); | |
194 | SetSignal(val,i); | |
195 | } | |
fdadc78a | 196 | } |
197 | ||
1fbffa23 | 198 | n=s.GetNerrors(); |
199 | for (Int_t j=1; j<=n; j++) | |
fdadc78a | 200 | { |
08225085 | 201 | if (s.GetErrorFlag(j)) |
5ae71069 | 202 | { |
203 | val=s.GetSignalError(j); | |
204 | SetSignalError(val,j); | |
205 | } | |
c72198f1 | 206 | } |
207 | ||
1fbffa23 | 208 | n=s.GetNwaveforms(); |
209 | for (Int_t k=1; k<=n; k++) | |
210 | { | |
211 | TH1F* hist=s.GetWaveform(k); | |
212 | if (hist) SetWaveform(hist,k); | |
213 | } | |
5f25234b | 214 | |
d0a8ef71 | 215 | TArrayI slotarr; |
216 | TArrayI posarr; | |
217 | TObject* dum=0; | |
218 | n=s.GetIndices(dum,slotarr,posarr); | |
219 | Int_t slot,pos; | |
220 | for (Int_t idx=0; idx<n; idx++) | |
5f25234b | 221 | { |
d0a8ef71 | 222 | slot=slotarr.At(idx); |
223 | pos=posarr.At(idx); | |
224 | TObject* obj=s.GetLink(slot,pos); | |
225 | if (obj) SetLink(obj,slot,pos); | |
5f25234b | 226 | } |
d0120ca2 | 227 | |
228 | Int_t ntk=s.GetNtracks(); | |
229 | if (ntk) | |
230 | { | |
231 | fTracks=new TObjArray(ntk); | |
232 | for (Int_t it=1; it<=ntk; it++) | |
233 | { | |
234 | AliTrack* tx=s.GetTrack(it); | |
235 | fTracks->Add(tx); | |
236 | } | |
237 | } | |
8e8e6c7f | 238 | } |
239 | /////////////////////////////////////////////////////////////////////////// | |
fdadc78a | 240 | void AliSignal::Reset(Int_t mode) |
d88f97cc | 241 | { |
959fbac5 | 242 | // Reset all signal and position values and errors to 0. |
fdadc78a | 243 | // |
244 | // mode = 0 Reset position and all signal values and their errors to 0. | |
1fbffa23 | 245 | // The waveform histograms are reset, but the calibration |
246 | // constants (i.e. gains and offsets) are kept. | |
fdadc78a | 247 | // 1 Reset position and delete the signal and error storage arrays. |
1fbffa23 | 248 | // Also the waveform histograms, gains and offset arrays are deleted. |
fdadc78a | 249 | // |
250 | // The default when invoking Reset() corresponds to mode=0. | |
251 | // | |
d0a8ef71 | 252 | // Note : In all cases the storage of the various links will be reset. |
4f368c8c | 253 | // The UniqueID, name and title will NOT be reset. |
254 | // In case the user wants to reset these attributes, this has to | |
255 | // be done explicitly via the SET facilities. | |
5f25234b | 256 | // |
fdadc78a | 257 | // The usage of mode=0 allows to re-use the allocated memory for new |
258 | // signal (and error) values. This behaviour is preferable (i.e. faster) | |
1fbffa23 | 259 | // in case the various signals always contain the same number of values |
260 | // and have the same calibration constants. | |
fdadc78a | 261 | // The usage of mode=1 is slower, but allows a more efficient memory |
262 | // occupation (and smaller output file size) in case the different | |
263 | // signals have a variable number of values. | |
264 | // | |
1fbffa23 | 265 | // For more specific actions see ResetPosition(), ResetSignals(), |
d0a8ef71 | 266 | // DeleteSignals(), ResetGain(), ResetOffset(), ResetLink(), ResetWaveform(), |
267 | // DeleteWaveform() and DeleteCalibrations(). | |
c72198f1 | 268 | // |
959fbac5 | 269 | |
fdadc78a | 270 | if (mode<0 || mode>1) |
959fbac5 | 271 | { |
fdadc78a | 272 | cout << " *AliSignal::Reset* Invalid argument mode = " << mode << endl; |
273 | cout << " Default mode=0 will be used." << endl; | |
274 | mode=0; | |
275 | } | |
276 | ||
277 | ResetPosition(); | |
278 | if (!mode) | |
279 | { | |
280 | ResetSignals(); | |
281 | } | |
282 | else | |
283 | { | |
284 | DeleteSignals(); | |
1fbffa23 | 285 | DeleteCalibrations(); |
959fbac5 | 286 | } |
5f25234b | 287 | |
d0a8ef71 | 288 | if (fLinks) fLinks->Reset(); |
965bd237 | 289 | fDevice=0; |
d0120ca2 | 290 | |
291 | if (fTracks) | |
292 | { | |
293 | delete fTracks; | |
294 | fTracks=0; | |
295 | } | |
959fbac5 | 296 | } |
297 | /////////////////////////////////////////////////////////////////////////// | |
fdadc78a | 298 | void AliSignal::ResetSignals(Int_t mode) |
959fbac5 | 299 | { |
fdadc78a | 300 | // Reset various signal data according to user selection. |
301 | // | |
302 | // mode = 0 Reset all signal values and their errors to 0. | |
303 | // 1 Reset only signal values | |
304 | // 2 Reset only signal errors | |
305 | // | |
306 | // The default when invoking ResetSignals() corresponds to mode=0. | |
c72198f1 | 307 | // |
1fbffa23 | 308 | // Irrespective of the mode, the waveform histograms are reset. |
959fbac5 | 309 | |
fdadc78a | 310 | if (mode<0 || mode>2) |
311 | { | |
312 | cout << " *AliSignal::ResetSignals* Invalid argument mode = " << mode << endl; | |
313 | cout << " Default mode=0 will be used." << endl; | |
314 | mode=0; | |
315 | } | |
316 | ||
5ae71069 | 317 | Int_t sflag=0; |
318 | Int_t eflag=0; | |
319 | ||
1fbffa23 | 320 | if (fSignals && (mode==0 || mode==1)) |
959fbac5 | 321 | { |
5ae71069 | 322 | for (Int_t i=1; i<=fSignals->GetSize(); i++) |
dafe31a2 | 323 | { |
5ae71069 | 324 | fSignals->AddAt(0,i-1); |
325 | eflag=GetErrorFlag(i); | |
326 | SetSigFlags(0,eflag,i); | |
fdadc78a | 327 | } |
328 | } | |
329 | ||
1fbffa23 | 330 | if (fDsignals && (mode==0 || mode==2)) |
fdadc78a | 331 | { |
5ae71069 | 332 | for (Int_t j=1; j<=fDsignals->GetSize(); j++) |
fdadc78a | 333 | { |
5ae71069 | 334 | fDsignals->AddAt(0,j-1); |
335 | sflag=GetSignalFlag(j); | |
336 | SetSigFlags(sflag,0,j); | |
dafe31a2 | 337 | } |
959fbac5 | 338 | } |
c72198f1 | 339 | |
1fbffa23 | 340 | ResetWaveform(0); |
d88f97cc | 341 | } |
342 | /////////////////////////////////////////////////////////////////////////// | |
fdadc78a | 343 | void AliSignal::DeleteSignals(Int_t mode) |
344 | { | |
345 | // Delete storage arrays of various signal data according to user selection. | |
346 | // | |
347 | // mode = 0 Delete arrays of both signal values and their errors. | |
348 | // 1 Delete only signal values array | |
349 | // 2 Delete only signal errors array | |
350 | // | |
351 | // The default when invoking DeleteSignals() corresponds to mode=0. | |
c72198f1 | 352 | // |
1fbffa23 | 353 | // Irrespective of the mode, the waveform histograms are deleted. |
fdadc78a | 354 | |
355 | if (mode<0 || mode>2) | |
356 | { | |
357 | cout << " *AliSignal::DeleteSignals* Invalid argument mode = " << mode << endl; | |
358 | cout << " Default mode=0 will be used." << endl; | |
359 | mode=0; | |
360 | } | |
361 | ||
1fbffa23 | 362 | if (fSignals && (mode==0 || mode==1)) |
fdadc78a | 363 | { |
1fbffa23 | 364 | delete fSignals; |
365 | fSignals=0; | |
fdadc78a | 366 | } |
367 | ||
1fbffa23 | 368 | if (fDsignals && (mode==0 || mode==2)) |
fdadc78a | 369 | { |
1fbffa23 | 370 | delete fDsignals; |
371 | fDsignals=0; | |
fdadc78a | 372 | } |
c72198f1 | 373 | |
5ae71069 | 374 | Int_t sflag=0; |
375 | Int_t eflag=0; | |
376 | ||
377 | if (mode==0) | |
378 | { | |
379 | delete fSigflags; | |
380 | fSigflags=0; | |
381 | } | |
382 | else if (mode==1) | |
383 | { | |
384 | for (Int_t i=1; i<=fSigflags->GetSize(); i++) | |
385 | { | |
386 | eflag=GetErrorFlag(i); | |
387 | SetSigFlags(0,eflag,i); | |
388 | } | |
389 | } | |
390 | else if (mode==2) | |
391 | { | |
392 | for (Int_t j=1; j<=fSigflags->GetSize(); j++) | |
393 | { | |
394 | sflag=GetSignalFlag(j); | |
395 | SetSigFlags(sflag,0,j); | |
396 | } | |
397 | } | |
398 | ||
1fbffa23 | 399 | DeleteWaveform(0); |
fdadc78a | 400 | } |
401 | /////////////////////////////////////////////////////////////////////////// | |
959fbac5 | 402 | void AliSignal::SetSignal(Double_t sig,Int_t j) |
d88f97cc | 403 | { |
2cb7369d | 404 | // Store signal value for the j-th (default j=1) slot. |
1fbffa23 | 405 | // Note : The first signal slot is at j=1. |
dafe31a2 | 406 | // In case the value of the index j exceeds the maximum number of reserved |
fdadc78a | 407 | // slots for signal values, the number of reserved slots for the |
408 | // signal values is increased automatically. | |
959fbac5 | 409 | |
1fbffa23 | 410 | if (!fSignals) |
959fbac5 | 411 | { |
1fbffa23 | 412 | fSignals=new TArrayF(j); |
fdadc78a | 413 | ResetSignals(1); |
959fbac5 | 414 | } |
dafe31a2 | 415 | |
1fbffa23 | 416 | Int_t size=fSignals->GetSize(); |
dafe31a2 | 417 | |
418 | if (j>size) | |
959fbac5 | 419 | { |
1fbffa23 | 420 | fSignals->Set(j); |
959fbac5 | 421 | } |
dafe31a2 | 422 | |
1fbffa23 | 423 | fSignals->AddAt(float(sig),j-1); |
5ae71069 | 424 | |
425 | Int_t eflag=GetErrorFlag(j); | |
426 | SetSigFlags(1,eflag,j); | |
d88f97cc | 427 | } |
428 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 429 | void AliSignal::SetSignal(Double_t sig,TString name) |
430 | { | |
431 | // Store signal value for the name-specified slot. | |
432 | // | |
433 | // This procedure involves a slot-index search based on the specified name | |
434 | // at each invokation. This may become slow in case many slots have been | |
435 | // defined and/or when this procedure is invoked many times. | |
436 | // In such cases it is preferable to use indexed addressing in the user code | |
437 | // either directly or via a few invokations of GetSlotIndex(). | |
438 | ||
439 | Int_t j=GetSlotIndex(name); | |
440 | if (j>0) SetSignal(sig,j); | |
441 | } | |
442 | /////////////////////////////////////////////////////////////////////////// | |
959fbac5 | 443 | void AliSignal::AddSignal(Double_t sig,Int_t j) |
444 | { | |
2cb7369d | 445 | // Add value to the signal of the j-th (default j=1) slot. |
1fbffa23 | 446 | // Note : The first signal slot is at j=1. |
dafe31a2 | 447 | // In case the value of the index j exceeds the maximum number of reserved |
fdadc78a | 448 | // slots for signal values, the number of reserved slots for the |
449 | // signal values is increased automatically. | |
959fbac5 | 450 | |
1fbffa23 | 451 | if (!fSignals) |
959fbac5 | 452 | { |
1fbffa23 | 453 | fSignals=new TArrayF(j); |
fdadc78a | 454 | ResetSignals(1); |
959fbac5 | 455 | } |
dafe31a2 | 456 | |
1fbffa23 | 457 | Int_t size=fSignals->GetSize(); |
dafe31a2 | 458 | |
459 | if (j>size) | |
959fbac5 | 460 | { |
1fbffa23 | 461 | fSignals->Set(j); |
959fbac5 | 462 | } |
dafe31a2 | 463 | |
1fbffa23 | 464 | Float_t sum=(fSignals->At(j-1))+sig; |
465 | fSignals->AddAt(sum,j-1); | |
5ae71069 | 466 | |
467 | Int_t eflag=GetErrorFlag(j); | |
468 | SetSigFlags(1,eflag,j); | |
959fbac5 | 469 | } |
470 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 471 | void AliSignal::AddSignal(Double_t sig,TString name) |
472 | { | |
473 | // Add value to the signal of the name-specified slot. | |
474 | // | |
475 | // This procedure involves a slot-index search based on the specified name | |
476 | // at each invokation. This may become slow in case many slots have been | |
477 | // defined and/or when this procedure is invoked many times. | |
478 | // In such cases it is preferable to use indexed addressing in the user code | |
479 | // either directly or via a few invokations of GetSlotIndex(). | |
480 | ||
481 | Int_t j=GetSlotIndex(name); | |
482 | if (j>0) AddSignal(sig,j); | |
483 | } | |
484 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 485 | Float_t AliSignal::GetSignal(Int_t j,Int_t mode) const |
959fbac5 | 486 | { |
2cb7369d | 487 | // Provide signal value of the j-th (default j=1) slot. |
1fbffa23 | 488 | // Note : The first signal slot is at j=1. |
b721efb7 | 489 | // In case no signal is present or the input argument "j" or "mode" is invalid, |
490 | // the value 0 is returned. | |
491 | // The parameter "mode" allows for automatic (de)calibration of the signal | |
492 | // (e.g. gain etc... correction or via explicit (de)calibration functions). | |
1fbffa23 | 493 | // |
494 | // mode = 0 : Just the j-th signal is returned. | |
495 | // 1 : The j-th signal is corrected for the gain, offset, dead flag etc... | |
b721efb7 | 496 | // In case the j-th slot was marked dead, 0 is returned. |
1fbffa23 | 497 | // In case the gain value was not set, gain=1 will be assumed. |
498 | // In case the gain value was 0, a signal value of 0 is returned. | |
499 | // In case the offset value was not set, offset=0 will be assumed. | |
b721efb7 | 500 | // 2 : Same as mode=1 but gain, offset dead flag etc... are taken from |
501 | // the AliDevice which owns this AliSignal object. | |
64c21700 | 502 | // The corresponding AliDevice slot is obtained via matching of |
503 | // the slotnames. In case this fails, the slotindex "j" of the | |
504 | // input argument will be used. | |
b721efb7 | 505 | // In case this AliSignal object has no parent AliDevice, just |
506 | // the j-th signal is returned (like with mode=0). | |
507 | // 3 : The j-th signal is corrected using the corresponding calibration | |
508 | // function. | |
1fbffa23 | 509 | // In case the j-th slot was marked dead, 0 is returned. |
b721efb7 | 510 | // In case no calibration function is present, just the j-th signal |
511 | // is returned (like with mode=0). | |
216d1d91 | 512 | // 4 : Same as mode=3 but the calibration function and dead flag are |
513 | // taken from the AliDevice which owns this AliSignal object. | |
64c21700 | 514 | // The corresponding AliDevice slot is obtained via matching of |
515 | // the slotnames. In case this fails, the slotindex "j" of the | |
516 | // input argument will be used. | |
b721efb7 | 517 | // 5 : Same as mode=2 but in case no parent AliDevice is present |
518 | // an automatic switch to mode=1 will be made. | |
519 | // 6 : Same as mode=4 but in case no parent AliDevice is present | |
520 | // an automatic switch to mode=3 will be made. | |
64c21700 | 521 | // 7 : Same as mode=3 but in case no calibration function is present |
522 | // an automatic switch to mode=4 will be made. | |
216d1d91 | 523 | // 8 : Same as mode=7 but also the corresponding dead flag of the |
524 | // parent device (if any) will be checked. | |
525 | // If either the dead flag of the requested signal slot of this | |
526 | // AliSignal object or the corresponding parent device slot is | |
527 | // set, 0 is returned. | |
b721efb7 | 528 | // |
529 | // <0 : The corresponding de-correction or de-calibration is performed | |
1fbffa23 | 530 | // |
531 | // The corrected signal (sigc) is determined as follows : | |
532 | // | |
533 | // sigc=(signal/gain)-offset | |
534 | // | |
b721efb7 | 535 | // The de-corrected signal is determined as follows : |
536 | // | |
537 | // signal=(sigc+offset)*gain | |
538 | // | |
1fbffa23 | 539 | // The default is mode=0. |
540 | ||
216d1d91 | 541 | if (abs(mode)>8) return 0; |
b721efb7 | 542 | |
64c21700 | 543 | Int_t jcal=j; |
fdadc78a | 544 | Float_t sig=0; |
1fbffa23 | 545 | Float_t gain=1; |
546 | Float_t offset=0; | |
b721efb7 | 547 | |
216d1d91 | 548 | // Get the corresponding slot index (and dead flag) of the parent device |
549 | Int_t pj=0; | |
550 | Int_t pdead=0; | |
551 | AliSignal* parent=(AliSignal*)GetDevice(); | |
552 | if ((abs(mode)==2 || abs(mode)>=4) && parent) | |
553 | { | |
554 | TString name=GetSlotName(j); | |
555 | if (strlen(name.Data())) pj=parent->GetSlotIndex(name); | |
556 | if (abs(mode)==8 && pj) pdead=parent->GetDeadValue(pj); | |
557 | } | |
558 | if (mode==8) mode=7; | |
559 | if (mode==-8) mode=-7; | |
560 | ||
b721efb7 | 561 | AliSignal* sx=(AliSignal*)this; |
64c21700 | 562 | |
563 | TF1* f=0; | |
564 | if (mode==7) | |
565 | { | |
566 | f=sx->GetCalFunction(jcal); | |
567 | if (f) | |
568 | { | |
569 | mode=3; | |
570 | } | |
571 | else | |
572 | { | |
573 | mode=4; | |
574 | } | |
575 | } | |
576 | if (mode==-7) | |
577 | { | |
578 | f=sx->GetDecalFunction(jcal); | |
579 | if (f) | |
580 | { | |
581 | mode=-3; | |
582 | } | |
583 | else | |
584 | { | |
585 | mode=-4; | |
586 | } | |
587 | } | |
588 | ||
589 | if (abs(mode)==2 || abs(mode)>=4) | |
590 | { | |
591 | sx=(AliSignal*)GetDevice(); | |
216d1d91 | 592 | if (pj) jcal=pj; |
64c21700 | 593 | } |
b721efb7 | 594 | if (!sx && abs(mode)>=5) sx=(AliSignal*)this; |
595 | if (mode==5) mode=2; | |
596 | if (mode==-5) mode=-2; | |
597 | if (mode==6) mode=3; | |
598 | if (mode==-6) mode=-3; | |
599 | ||
1fbffa23 | 600 | if (fSignals) |
959fbac5 | 601 | { |
1fbffa23 | 602 | if (j>0 && j<=(fSignals->GetSize())) |
fdadc78a | 603 | { |
1fbffa23 | 604 | sig=fSignals->At(j-1); |
605 | ||
b721efb7 | 606 | if (mode==0 || !sx) return sig; |
1fbffa23 | 607 | |
b721efb7 | 608 | // Check for the dead flag setting |
216d1d91 | 609 | if (sx->GetDeadValue(jcal) || pdead) return 0; |
1fbffa23 | 610 | |
b721efb7 | 611 | // (De)correct the signal for the gain and offset |
612 | if (abs(mode)==1 || abs(mode)==2) | |
1fbffa23 | 613 | { |
64c21700 | 614 | if (sx->GetGainFlag(jcal)) gain=sx->GetGain(jcal); |
615 | if (sx->GetOffsetFlag(jcal)) offset=sx->GetOffset(jcal); | |
b721efb7 | 616 | |
617 | if (fabs(gain)>0.) | |
618 | { | |
619 | if (mode>0) sig=(sig/gain)-offset; // Gain and offset correction | |
620 | if (mode<0) sig=(sig+offset)*gain; // Gain and offset de-correction | |
621 | } | |
622 | else | |
623 | { | |
624 | sig=0; | |
625 | } | |
626 | return sig; | |
1fbffa23 | 627 | } |
b721efb7 | 628 | |
629 | // (De)calibrate the signal with the corresponding (de)calibration function | |
630 | if (abs(mode)==3 || abs(mode)==4) | |
1fbffa23 | 631 | { |
64c21700 | 632 | f=sx->GetCalFunction(jcal); |
633 | if (mode<0) f=sx->GetDecalFunction(jcal); | |
b721efb7 | 634 | if (f) sig=f->Eval(sig); |
635 | return sig; | |
1fbffa23 | 636 | } |
fdadc78a | 637 | } |
638 | else | |
639 | { | |
640 | cout << " *AliSignal::GetSignal* Index j = " << j << " invalid." << endl; | |
641 | } | |
959fbac5 | 642 | } |
fdadc78a | 643 | return sig; |
959fbac5 | 644 | } |
645 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 646 | Float_t AliSignal::GetSignal(TString name,Int_t mode) const |
647 | { | |
648 | // Provide signal value of the name-specified slot. | |
649 | // In case no signal is present, 0 is returned. | |
64c21700 | 650 | // The parameter "mode" allows for automatic (de)calibration of the signal |
651 | // (e.g. gain etc... correction or via explicit (de)calibration functions). | |
652 | // For further details about the (de)calibration modes, please refer to the | |
653 | // corresponding slot-index based memberfunction. | |
2cb7369d | 654 | // |
655 | // The default is mode=0. | |
656 | // | |
657 | // This procedure involves a slot-index search based on the specified name | |
658 | // at each invokation. This may become slow in case many slots have been | |
659 | // defined and/or when this procedure is invoked many times. | |
660 | // In such cases it is preferable to use indexed addressing in the user code | |
661 | // either directly or via a few invokations of GetSlotIndex(). | |
662 | ||
663 | Int_t j=GetSlotIndex(name); | |
664 | Float_t val=0; | |
665 | if (j>0) val=GetSignal(j,mode); | |
666 | return val; | |
667 | } | |
668 | /////////////////////////////////////////////////////////////////////////// | |
959fbac5 | 669 | void AliSignal::SetSignalError(Double_t dsig,Int_t j) |
670 | { | |
2cb7369d | 671 | // Store error on the signal for the j-th (default j=1) slot. |
1fbffa23 | 672 | // Note : The first signal slot is at j=1. |
dafe31a2 | 673 | // In case the value of the index j exceeds the maximum number of reserved |
fdadc78a | 674 | // slots for signal error values, the number of reserved slots for the |
675 | // signal errors is increased automatically. | |
959fbac5 | 676 | |
1fbffa23 | 677 | if (!fDsignals) |
959fbac5 | 678 | { |
1fbffa23 | 679 | fDsignals=new TArrayF(j); |
fdadc78a | 680 | ResetSignals(2); |
959fbac5 | 681 | } |
dafe31a2 | 682 | |
1fbffa23 | 683 | Int_t size=fDsignals->GetSize(); |
dafe31a2 | 684 | |
685 | if (j>size) | |
959fbac5 | 686 | { |
1fbffa23 | 687 | fDsignals->Set(j); |
959fbac5 | 688 | } |
dafe31a2 | 689 | |
1fbffa23 | 690 | fDsignals->AddAt(float(dsig),j-1); |
5ae71069 | 691 | |
692 | Int_t sflag=GetSignalFlag(j); | |
693 | SetSigFlags(sflag,1,j); | |
959fbac5 | 694 | } |
695 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 696 | void AliSignal::SetSignalError(Double_t dsig,TString name) |
697 | { | |
698 | // Store error on the signal for the name-specified slot. | |
699 | // | |
700 | // This procedure involves a slot-index search based on the specified name | |
701 | // at each invokation. This may become slow in case many slots have been | |
702 | // defined and/or when this procedure is invoked many times. | |
703 | // In such cases it is preferable to use indexed addressing in the user code | |
704 | // either directly or via a few invokations of GetSlotIndex(). | |
705 | ||
706 | Int_t j=GetSlotIndex(name); | |
707 | if (j>0) SetSignalError(dsig,j); | |
708 | } | |
709 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 710 | Float_t AliSignal::GetSignalError(Int_t j) const |
959fbac5 | 711 | { |
2cb7369d | 712 | // Provide error on the signal of the j-th (default j=1) slot. |
1fbffa23 | 713 | // Note : The first signal slot is at j=1. |
fdadc78a | 714 | // In case no signal is present or the argument j is invalid, 0 is returned. |
715 | Float_t err=0; | |
1fbffa23 | 716 | if (fDsignals) |
959fbac5 | 717 | { |
1fbffa23 | 718 | if (j>0 && j<=(fDsignals->GetSize())) |
fdadc78a | 719 | { |
1fbffa23 | 720 | err=fDsignals->At(j-1); |
fdadc78a | 721 | } |
722 | else | |
723 | { | |
724 | cout << " *AliSignal::GetSignalError* Index j = " << j << " invalid." << endl; | |
725 | } | |
959fbac5 | 726 | } |
fdadc78a | 727 | return err; |
959fbac5 | 728 | } |
729 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 730 | Float_t AliSignal::GetSignalError(TString name) const |
731 | { | |
732 | // Provide error on the signal of the name-specified slot. | |
733 | // | |
734 | // This procedure involves a slot-index search based on the specified name | |
735 | // at each invokation. This may become slow in case many slots have been | |
736 | // defined and/or when this procedure is invoked many times. | |
737 | // In such cases it is preferable to use indexed addressing in the user code | |
738 | // either directly or via a few invokations of GetSlotIndex(). | |
739 | ||
740 | Int_t j=GetSlotIndex(name); | |
741 | Float_t val=0; | |
742 | if (j>0) val=GetSignalError(j); | |
743 | return val; | |
744 | } | |
745 | /////////////////////////////////////////////////////////////////////////// | |
1f241680 | 746 | void AliSignal::Data(TString f,TString u) const |
1c01b4f8 | 747 | { |
748 | // Provide all signal information within the coordinate frame f. | |
1f241680 | 749 | // |
750 | // The string argument "u" allows to choose between different angular units | |
751 | // in case e.g. a spherical frame is selected. | |
752 | // u = "rad" : angles provided in radians | |
753 | // "deg" : angles provided in degrees | |
754 | // | |
755 | // The defaults are f="car" and u="rad". | |
1c01b4f8 | 756 | |
5f25234b | 757 | const char* name=GetName(); |
758 | const char* title=GetTitle(); | |
759 | ||
f67e2651 | 760 | cout << " *" << ClassName() << "::Data* Id : " << GetUniqueID(); |
5f25234b | 761 | if (strlen(name)) cout << " Name : " << name; |
762 | if (strlen(title)) cout << " Title : " << title; | |
763 | cout << endl; | |
d0a8ef71 | 764 | cout << " Position"; |
1f241680 | 765 | AliPosition::Data(f,u); |
965bd237 | 766 | if (fDevice) |
767 | { | |
768 | const char* devname=fDevice->GetName(); | |
769 | const char* devtitle=fDevice->GetTitle(); | |
f67e2651 | 770 | cout << " Owned by device : " << fDevice->ClassName() |
771 | << " Id : " << fDevice->GetUniqueID(); | |
965bd237 | 772 | if (strlen(devname)) cout << " Name : " << devname; |
773 | if (strlen(devtitle)) cout << " Title : " << devtitle; | |
774 | cout << endl; | |
775 | } | |
1c01b4f8 | 776 | |
6a8254a0 | 777 | // Provide an overview of the stored waveforms |
778 | ListWaveform(-1); | |
779 | ||
d0120ca2 | 780 | // Provide an overview of the associated tracks |
781 | ListTrack(-1); | |
782 | ||
6a8254a0 | 783 | // Provide an overview of all the data and attribute slots |
1c01b4f8 | 784 | List(-1); |
785 | } | |
786 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 787 | void AliSignal::List(Int_t j) const |
959fbac5 | 788 | { |
1c01b4f8 | 789 | // Provide signal information for the j-th slot. |
1fbffa23 | 790 | // The first slot is at j=1. |
791 | // In case j=0 (default) the data of all slots will be listed. | |
1c01b4f8 | 792 | // In case j=-1 the data of all slots will be listed, but the header |
793 | // information will be suppressed. | |
1fbffa23 | 794 | |
1c01b4f8 | 795 | if (j<-1) |
1fbffa23 | 796 | { |
1c01b4f8 | 797 | cout << " *AliSignal::List* Invalid argument j = " << j << endl; |
1fbffa23 | 798 | return; |
799 | } | |
800 | ||
5f25234b | 801 | if (j != -1) |
802 | { | |
803 | const char* name=GetName(); | |
804 | const char* title=GetTitle(); | |
805 | ||
6a8254a0 | 806 | cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID(); |
5f25234b | 807 | if (strlen(name)) cout << " Name : " << name; |
808 | if (strlen(title)) cout << " Title : " << title; | |
809 | cout << endl; | |
6a8254a0 | 810 | if (fDevice) |
811 | { | |
812 | const char* devname=fDevice->GetName(); | |
813 | const char* devtitle=fDevice->GetTitle(); | |
814 | cout << " Owned by device : " << fDevice->ClassName(); | |
815 | if (strlen(devname)) cout << " Name : " << devname; | |
816 | if (strlen(devtitle)) cout << " Title : " << devtitle; | |
817 | cout << endl; | |
818 | } | |
5f25234b | 819 | } |
fdadc78a | 820 | |
5ae71069 | 821 | Int_t n=GetNslots(); |
d0a8ef71 | 822 | Int_t nlinkslots=0; |
d0120ca2 | 823 | if (GetNlinks()) nlinkslots=fLinks->GetMaxColumn(); |
d0a8ef71 | 824 | if (nlinkslots>n) n=nlinkslots; |
b721efb7 | 825 | |
5f25234b | 826 | TObject* obj=0; |
d0a8ef71 | 827 | Int_t nrefs=0; |
828 | TArrayI posarr; | |
829 | Int_t pos; | |
fdadc78a | 830 | |
1c01b4f8 | 831 | if (j<=0) |
959fbac5 | 832 | { |
1fbffa23 | 833 | for (Int_t i=1; i<=n; i++) |
959fbac5 | 834 | { |
d0a8ef71 | 835 | obj=0; |
836 | nrefs=GetIndices(obj,i,posarr); | |
5ae71069 | 837 | |
838 | if (GetSignalFlag(i) || GetErrorFlag(i) || GetCalFunction(i) || GetDecalFunction(i) || GetCalWord(i) || nrefs) | |
5f25234b | 839 | { |
5ae71069 | 840 | cout << " Slot : " << i; |
841 | if (GetSignalFlag(i)) cout << " Signal value : " << GetSignal(i); | |
842 | if (GetErrorFlag(i)) cout << " error : " << GetSignalError(i); | |
843 | AliAttrib::List(i); | |
844 | cout << endl; | |
845 | ||
846 | for (Int_t k=0; k<nrefs; k++) | |
03b59bc9 | 847 | { |
5ae71069 | 848 | pos=posarr.At(k); |
849 | obj=GetLink(i,pos); | |
850 | if (obj) | |
d0a8ef71 | 851 | { |
5ae71069 | 852 | cout << " Link at position " << pos << " to : " << obj->ClassName(); |
853 | if (obj->InheritsFrom("TNamed")) | |
854 | { | |
855 | const char* lname=obj->GetName(); | |
856 | const char* ltitle=obj->GetTitle(); | |
857 | if (strlen(lname)) cout << " Name : " << lname; | |
858 | if (strlen(ltitle)) cout << " Title : " << ltitle; | |
859 | } | |
860 | cout << endl; | |
d0a8ef71 | 861 | } |
03b59bc9 | 862 | } |
5f25234b | 863 | } |
1fbffa23 | 864 | } |
865 | } | |
866 | else | |
867 | { | |
868 | if (j<=n) | |
869 | { | |
d0a8ef71 | 870 | obj=0; |
871 | nrefs=GetIndices(obj,j,posarr); | |
5ae71069 | 872 | |
873 | if (GetSignalFlag(j) || GetErrorFlag(j) || GetCalFunction(j) || GetDecalFunction(j) || GetCalWord(j) || nrefs) | |
5f25234b | 874 | { |
5ae71069 | 875 | cout << " Slot : " << j; |
876 | if (GetSignalFlag(j)) cout << " Signal value : " << GetSignal(j); | |
877 | if (GetErrorFlag(j)) cout << " error : " << GetSignalError(j); | |
878 | AliAttrib::List(j); | |
879 | cout << endl; | |
880 | ||
881 | for (Int_t kj=0; kj<nrefs; kj++) | |
03b59bc9 | 882 | { |
5ae71069 | 883 | pos=posarr.At(kj); |
884 | obj=GetLink(j,pos); | |
885 | if (obj) | |
d0a8ef71 | 886 | { |
5ae71069 | 887 | cout << " Link at position " << pos << " to : " << obj->ClassName(); |
888 | if (obj->InheritsFrom("TNamed")) | |
889 | { | |
890 | const char* lnamej=obj->GetName(); | |
891 | const char* ltitlej=obj->GetTitle(); | |
892 | if (strlen(lnamej)) cout << " Name : " << lnamej; | |
893 | if (strlen(ltitlej)) cout << " Title : " << ltitlej; | |
894 | } | |
895 | cout << endl; | |
d0a8ef71 | 896 | } |
03b59bc9 | 897 | } |
5f25234b | 898 | } |
959fbac5 | 899 | } |
900 | } | |
901 | } | |
902 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 903 | void AliSignal::List(TString name) const |
904 | { | |
905 | // Provide signal information for the name-specified slot. | |
906 | // | |
907 | // This procedure involves a slot-index search based on the specified name | |
908 | // at each invokation. This may become slow in case many slots have been | |
909 | // defined and/or when this procedure is invoked many times. | |
910 | // In such cases it is preferable to use indexed addressing in the user code | |
911 | // either directly or via a few invokations of GetSlotIndex(). | |
912 | ||
913 | Int_t j=GetSlotIndex(name); | |
914 | if (j>0) List(j); | |
915 | } | |
916 | /////////////////////////////////////////////////////////////////////////// | |
6a8254a0 | 917 | void AliSignal::ListWaveform(Int_t j) const |
918 | { | |
919 | // Provide information for the j-th waveform. | |
920 | // The first waveform is at j=1. | |
921 | // In case j=0 (default) the info of all waveforms will be listed. | |
922 | // In case j=-1 the info of all waveforms will be listed, but the header | |
923 | // information will be suppressed. | |
924 | ||
925 | if (j<-1) | |
926 | { | |
927 | cout << " *AliSignal::ListWaveform* Invalid argument j = " << j << endl; | |
928 | return; | |
929 | } | |
930 | ||
931 | if (j != -1) | |
932 | { | |
933 | const char* name=GetName(); | |
934 | const char* title=GetTitle(); | |
935 | ||
936 | cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID(); | |
937 | if (strlen(name)) cout << " Name : " << name; | |
938 | if (strlen(title)) cout << " Title : " << title; | |
939 | cout << endl; | |
940 | if (fDevice) | |
941 | { | |
942 | const char* devname=fDevice->GetName(); | |
943 | const char* devtitle=fDevice->GetTitle(); | |
944 | cout << " Owned by device : " << fDevice->ClassName(); | |
945 | if (strlen(devname)) cout << " Name : " << devname; | |
946 | if (strlen(devtitle)) cout << " Title : " << devtitle; | |
947 | cout << endl; | |
948 | } | |
949 | } | |
950 | ||
951 | Int_t n=GetNwaveforms(); | |
952 | TObject* obj=0; | |
953 | ||
954 | if (j<=0) | |
955 | { | |
956 | for (Int_t i=1; i<=n; i++) | |
957 | { | |
958 | obj=GetWaveform(i); | |
959 | if (obj) | |
960 | { | |
961 | const char* wfname=obj->GetName(); | |
962 | const char* wftitle=obj->GetTitle(); | |
963 | cout << " Waveform " << i << " : " << obj->ClassName(); | |
964 | if (strlen(wfname)) cout << " Name : " << wfname; | |
965 | if (strlen(wftitle)) cout << " Title : " << wftitle; | |
966 | cout << endl; | |
967 | } | |
968 | } | |
969 | } | |
970 | else | |
971 | { | |
972 | if (j<=n) | |
973 | { | |
974 | obj=GetWaveform(j); | |
975 | if (obj) | |
976 | { | |
977 | const char* wfnamej=obj->GetName(); | |
978 | const char* wftitlej=obj->GetTitle(); | |
979 | cout << " Waveform " << j << " : " << obj->ClassName(); | |
980 | if (strlen(wfnamej)) cout << " Name : " << wfnamej; | |
981 | if (strlen(wftitlej)) cout << " Title : " << wftitlej; | |
982 | cout << endl; | |
983 | } | |
984 | } | |
985 | } | |
986 | } | |
987 | /////////////////////////////////////////////////////////////////////////// | |
d0120ca2 | 988 | void AliSignal::ListTrack(Int_t j) const |
989 | { | |
990 | // Provide information for the j-th associated track. | |
991 | // The first associated track is at j=1. | |
992 | // In case j=0 (default) the info of all associated tracks will be listed. | |
993 | // In case j=-1 the info of all tracks will be listed, but the header | |
994 | // information will be suppressed. | |
995 | ||
996 | if (j<-1) | |
997 | { | |
998 | cout << " *AliSignal::ListTrack* Invalid argument j = " << j << endl; | |
999 | return; | |
1000 | } | |
1001 | ||
1002 | if (j != -1) | |
1003 | { | |
1004 | const char* name=GetName(); | |
1005 | const char* title=GetTitle(); | |
1006 | ||
1007 | cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID(); | |
1008 | if (strlen(name)) cout << " Name : " << name; | |
1009 | if (strlen(title)) cout << " Title : " << title; | |
1010 | cout << endl; | |
1011 | if (fDevice) | |
1012 | { | |
1013 | const char* devname=fDevice->GetName(); | |
1014 | const char* devtitle=fDevice->GetTitle(); | |
1015 | cout << " Owned by device : " << fDevice->ClassName(); | |
1016 | if (strlen(devname)) cout << " Name : " << devname; | |
1017 | if (strlen(devtitle)) cout << " Title : " << devtitle; | |
1018 | cout << endl; | |
1019 | } | |
1020 | } | |
1021 | ||
1022 | Int_t n=GetNtracks(); | |
1023 | AliTrack* tx=0; | |
1024 | ||
1025 | if (j<=0) | |
1026 | { | |
1027 | for (Int_t i=1; i<=n; i++) | |
1028 | { | |
1029 | tx=GetTrack(i); | |
1030 | if (tx) | |
1031 | { | |
1032 | const char* txname=tx->GetName(); | |
1033 | const char* txtitle=tx->GetTitle(); | |
1034 | cout << " Track " << i << " : " << tx->ClassName() << " Id : " << tx->GetId(); | |
1035 | if (strlen(txname)) cout << " Name : " << txname; | |
1036 | if (strlen(txtitle)) cout << " Title : " << txtitle; | |
1037 | cout << endl; | |
1038 | } | |
1039 | } | |
1040 | } | |
1041 | else | |
1042 | { | |
1043 | if (j<=n) | |
1044 | { | |
1045 | tx=GetTrack(j); | |
1046 | if (tx) | |
1047 | { | |
1048 | const char* txnamej=tx->GetName(); | |
1049 | const char* txtitlej=tx->GetTitle(); | |
1050 | cout << " Track " << j << " : " << tx->ClassName() << " Id : " << tx->GetId(); | |
1051 | if (strlen(txnamej)) cout << " Name : " << txnamej; | |
1052 | if (strlen(txtitlej)) cout << " Title : " << txtitlej; | |
1053 | cout << endl; | |
1054 | } | |
1055 | } | |
1056 | } | |
1057 | } | |
1058 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1059 | Int_t AliSignal::GetNvalues() const |
8e8e6c7f | 1060 | { |
1061 | // Provide the number of values for this signal. | |
5ae71069 | 1062 | |
1063 | if (!fSignals) return 0; | |
1064 | ||
dafe31a2 | 1065 | Int_t n=0; |
5ae71069 | 1066 | for (Int_t i=1; i<=fSigflags->GetSize(); i++) |
1067 | { | |
1068 | if (GetSignalFlag(i)) n=i; | |
1069 | } | |
1070 | ||
fdadc78a | 1071 | return n; |
1072 | } | |
1073 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1074 | Int_t AliSignal::GetNerrors() const |
fdadc78a | 1075 | { |
1076 | // Provide the number specified errors on the values for this signal. | |
5ae71069 | 1077 | |
1078 | if (!fDsignals) return 0; | |
1079 | ||
fdadc78a | 1080 | Int_t n=0; |
5ae71069 | 1081 | for (Int_t i=1; i<=fSigflags->GetSize(); i++) |
1082 | { | |
1083 | if (GetErrorFlag(i)) n=i; | |
1084 | } | |
1085 | ||
1086 | return n; | |
1087 | } | |
1088 | /////////////////////////////////////////////////////////////////////////// | |
1089 | void AliSignal::SetSigFlags(Int_t is,Int_t ie,Int_t j) | |
1090 | { | |
1091 | // Store signal and/or error value flags of the j-th (default j=1) slot. | |
1092 | // Note : The first slot is at j=1. | |
1093 | // In case the value of the index j exceeds the maximum number of reserved | |
1094 | // slots for the flags, the number of reserved slots for the flags is | |
1095 | // increased automatically. | |
1096 | // The value stored is : 10*signalflag + errorflag. | |
1097 | ||
1098 | if (j<1) | |
1099 | { | |
1100 | cout << " *AliSignal::SetSigFlags* Invalid argument j = " << j << endl; | |
1101 | return; | |
1102 | } | |
1103 | ||
1104 | if (!fSigflags) | |
1105 | { | |
1106 | fSigflags=new TArrayI(j); | |
1107 | } | |
1108 | ||
1109 | Int_t size=fSigflags->GetSize(); | |
1110 | ||
1111 | if (j>size) | |
1112 | { | |
1113 | fSigflags->Set(j); | |
1114 | } | |
1115 | ||
1116 | Int_t word=10*is+ie; | |
1117 | ||
1118 | fSigflags->AddAt(word,j-1); | |
1119 | } | |
1120 | /////////////////////////////////////////////////////////////////////////// | |
1121 | Int_t AliSignal::GetSignalFlag(Int_t j) const | |
1122 | { | |
1123 | // Provide signal value flag of the j-th (default j=1) slot. | |
1124 | // | |
1125 | // flag = 1 : Signal value was set | |
1126 | // 0 : Signal value was not set | |
1127 | // | |
1128 | // Note : The first attribute slot is at j=1. | |
1129 | // In case j is invalid, 0 is returned. | |
1130 | ||
1131 | if (j<1) | |
1132 | { | |
1133 | cout << " *AliSignal::GetSignalFlag* Invalid argument j = " << j << endl; | |
1134 | return 0; | |
1135 | } | |
1136 | Int_t flag=0; | |
1137 | if (fSigflags) | |
1138 | { | |
1139 | if (j>0 && j<=(fSigflags->GetSize())) | |
1140 | { | |
1141 | Int_t word=fSigflags->At(j-1); | |
1142 | flag=word/10; | |
1143 | } | |
1144 | } | |
1145 | return flag; | |
1146 | } | |
1147 | /////////////////////////////////////////////////////////////////////////// | |
1148 | Int_t AliSignal::GetSignalFlag(TString name) const | |
1149 | { | |
1150 | // Provide signal value flag of the name-specified slot. | |
1151 | // | |
1152 | // flag = 1 : Signal value was set | |
1153 | // 0 : Signal value was not set | |
1154 | // | |
1155 | // | |
1156 | // This procedure involves a slot-index search based on the specified name | |
1157 | // at each invokation. This may become slow in case many slots have been | |
1158 | // defined and/or when this procedure is invoked many times. | |
1159 | // In such cases it is preferable to use indexed addressing in the user code | |
1160 | // either directly or via a few invokations of GetSlotIndex(). | |
1161 | ||
1162 | Int_t j=GetSlotIndex(name); | |
1163 | Int_t flag=0; | |
1164 | if (j>0) flag=GetSignalFlag(j); | |
1165 | return flag; | |
1166 | } | |
1167 | /////////////////////////////////////////////////////////////////////////// | |
1168 | Int_t AliSignal::GetErrorFlag(Int_t j) const | |
1169 | { | |
1170 | // Provide error value flag of the j-th (default j=1) slot. | |
1171 | // | |
1172 | // flag = 1 : Error value was set | |
1173 | // 0 : Error value was not set | |
1174 | // | |
1175 | // Note : The first attribute slot is at j=1. | |
1176 | // In case j is invalid, 0 is returned. | |
1177 | ||
1178 | if (j<1) | |
1179 | { | |
1180 | cout << " *AliSignal::GetErrorFlag* Invalid argument j = " << j << endl; | |
1181 | return 0; | |
1182 | } | |
1183 | Int_t flag=0; | |
1184 | if (fSigflags) | |
1185 | { | |
1186 | if (j>0 && j<=(fSigflags->GetSize())) | |
1187 | { | |
1188 | Int_t word=fSigflags->At(j-1); | |
1189 | flag=word%10; | |
1190 | } | |
1191 | } | |
1192 | return flag; | |
1193 | } | |
1194 | /////////////////////////////////////////////////////////////////////////// | |
1195 | Int_t AliSignal::GetErrorFlag(TString name) const | |
1196 | { | |
1197 | // Provide error value flag of the name-specified slot. | |
1198 | // | |
1199 | // flag = 1 : Error value was set | |
1200 | // 0 : Error value was not set | |
1201 | // | |
1202 | // | |
1203 | // This procedure involves a slot-index search based on the specified name | |
1204 | // at each invokation. This may become slow in case many slots have been | |
1205 | // defined and/or when this procedure is invoked many times. | |
1206 | // In such cases it is preferable to use indexed addressing in the user code | |
1207 | // either directly or via a few invokations of GetSlotIndex(). | |
1208 | ||
1209 | Int_t j=GetSlotIndex(name); | |
1210 | Int_t flag=0; | |
1211 | if (j>0) flag=GetErrorFlag(j); | |
1212 | return flag; | |
1213 | } | |
1214 | /////////////////////////////////////////////////////////////////////////// | |
1215 | Int_t AliSignal::GetNslots() const | |
1216 | { | |
1217 | // Provide the number of existing slots. | |
1218 | ||
1219 | Int_t n=AliAttrib::GetNslots(); | |
1220 | ||
1221 | if (!fSigflags) return n; | |
1222 | ||
1223 | Int_t nflags=0; | |
1224 | for (Int_t i=0; i<fSigflags->GetSize(); i++) | |
1225 | { | |
1226 | if (fSigflags->At(i)) nflags=i+1; | |
1227 | } | |
1228 | ||
1229 | if (n<nflags) n=nflags; | |
1230 | ||
dafe31a2 | 1231 | return n; |
8e8e6c7f | 1232 | } |
1233 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1234 | Int_t AliSignal::GetNwaveforms() const |
c72198f1 | 1235 | { |
a80c27d9 | 1236 | // Provide the number of specified waveforms for this signal. |
1237 | // Actually the return value is the highest index of the stored waveforms. | |
1238 | // This allows an index dependent meaning of waveform info (e.g. waveforms | |
1239 | // with various gain values). | |
1240 | // So, when all waveforms are stored in consequetive positions (e.g. 1,2,3), | |
1241 | // this memberfunction returns 3, being both the highest filled position | |
1242 | // and the actual number of waveforms. | |
1243 | // In case only waveforms are stored at positions 1,2,5,7 this memberfunction | |
1244 | // returns a value 7 whereas only 4 actual waveforms are present. | |
1245 | // This implies that when looping over the various waveform slots, one | |
1246 | // always has to check whether the returned pointer value is non-zero | |
1247 | // (which is a good practice anyhow). | |
1248 | Int_t n=-1; | |
1249 | if (fWaveforms) n=fWaveforms->GetLast(); | |
1250 | return (n+1); | |
c72198f1 | 1251 | } |
1252 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1253 | TH1F* AliSignal::GetWaveform(Int_t j) const |
c72198f1 | 1254 | { |
6a8254a0 | 1255 | // Provide pointer to the j-th waveform histogram. |
1fbffa23 | 1256 | TH1F* waveform=0; |
1257 | if (j <= GetNwaveforms()) waveform=(TH1F*)fWaveforms->At(j-1); | |
1258 | return waveform; | |
1259 | } | |
1260 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1261 | TH1F* AliSignal::GetWaveform(TString name) const |
1262 | { | |
6a8254a0 | 1263 | // Provide pointer to the waveform histogram with the specified name. |
1264 | // In case no match is found, zero is returned. | |
1265 | Int_t n=GetNwaveforms(); | |
1266 | TString str; | |
1267 | for (Int_t i=1; i<=n; i++) | |
1268 | { | |
1269 | TH1F* waveform=GetWaveform(i); | |
1270 | if (waveform) | |
1271 | { | |
1272 | str=waveform->GetName(); | |
1273 | if (str == name) return waveform; | |
1274 | } | |
1275 | } | |
1276 | return 0; // No match found | |
1277 | } | |
1278 | /////////////////////////////////////////////////////////////////////////// | |
1279 | Int_t AliSignal::GetWaveformIndex(TString name) const | |
1280 | { | |
1281 | // Provide index to the waveform histogram with the specified name. | |
1282 | // In case no match is found, zero is returned. | |
1283 | Int_t n=GetNwaveforms(); | |
1284 | TString str; | |
1285 | for (Int_t i=1; i<=n; i++) | |
1286 | { | |
1287 | TH1F* waveform=GetWaveform(i); | |
1288 | if (waveform) | |
1289 | { | |
1290 | str=waveform->GetName(); | |
1291 | if (str == name) return i; | |
1292 | } | |
1293 | } | |
1294 | return 0; // No match found | |
2cb7369d | 1295 | } |
1296 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 1297 | void AliSignal::SetWaveform(TH1F* waveform,Int_t j) |
1298 | { | |
6a8254a0 | 1299 | // Set the 1D waveform histogram for the j-th waveform. |
1fbffa23 | 1300 | // |
1301 | // Notes : | |
6a8254a0 | 1302 | // The first waveform position at j=1. |
1fbffa23 | 1303 | // j=1 is the default value. |
1304 | // | |
1305 | // In case the value of the index j exceeds the maximum number of reserved | |
6a8254a0 | 1306 | // positions for the waveforms, the number of reserved positions for the waveforms |
1fbffa23 | 1307 | // is increased automatically. |
c72198f1 | 1308 | // |
1fbffa23 | 1309 | // In case the histo pointer argument has the same value as the current waveform |
c72198f1 | 1310 | // histogram pointer value, no action is taken since the user has already |
1311 | // modified the actual histogram. | |
1312 | // | |
1fbffa23 | 1313 | // In case the histo pointer argument is zero, the current waveform histogram |
c72198f1 | 1314 | // is deleted and the pointer set to zero. |
1315 | // | |
1316 | // In all other cases the current waveform histogram is deleted and a new | |
1317 | // copy of the input histogram is created which becomes the current waveform | |
1318 | // histogram. | |
1319 | ||
6a8254a0 | 1320 | if (j<1) return; |
1321 | ||
1fbffa23 | 1322 | if (!fWaveforms) |
1323 | { | |
1324 | fWaveforms=new TObjArray(j); | |
1325 | fWaveforms->SetOwner(); | |
1326 | } | |
1327 | ||
1328 | if (j > fWaveforms->GetSize()) fWaveforms->Expand(j); | |
1329 | ||
1330 | TH1F* hcur=(TH1F*)fWaveforms->At(j-1); | |
1331 | if (waveform != hcur) | |
c72198f1 | 1332 | { |
1fbffa23 | 1333 | if (hcur) |
c72198f1 | 1334 | { |
1fbffa23 | 1335 | fWaveforms->Remove(hcur); |
1336 | delete hcur; | |
1337 | hcur=0; | |
1338 | } | |
1339 | if (waveform) | |
1340 | { | |
1341 | hcur=new TH1F(*waveform); | |
1342 | fWaveforms->AddAt(hcur,j-1); | |
c72198f1 | 1343 | } |
c72198f1 | 1344 | } |
1345 | } | |
1346 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 1347 | void AliSignal::ResetWaveform(Int_t j) |
1348 | { | |
6a8254a0 | 1349 | // Reset the histogram of the j-th (default j=1) waveform. |
1fbffa23 | 1350 | // This memberfunction invokes TH1F::Reset() for the corresponding waveform(s). |
1351 | // To actually delete the histograms from memory, use DeleteWaveform(). | |
6a8254a0 | 1352 | // Notes : The first position is at j=1. |
1fbffa23 | 1353 | // j=0 ==> All waveforms will be reset. |
1354 | ||
1355 | if (!fWaveforms) return; | |
1356 | ||
1357 | Int_t size=fWaveforms->GetSize(); | |
1358 | ||
1359 | if ((j>=0) && (j<=size)) | |
1360 | { | |
1361 | if (j) | |
1362 | { | |
1363 | TH1F* hwave=(TH1F*)fWaveforms->At(j-1); | |
1364 | if (hwave) hwave->Reset(); | |
1365 | } | |
1366 | else | |
1367 | { | |
1368 | for (Int_t i=0; i<size; i++) | |
1369 | { | |
1370 | TH1F* hwave=(TH1F*)fWaveforms->At(i); | |
1371 | if (hwave) hwave->Reset(); | |
1372 | } | |
1373 | } | |
1374 | } | |
1375 | else | |
1376 | { | |
1377 | cout << " *AliSignal::ResetWaveform* Index j = " << j << " invalid." << endl; | |
1378 | return; | |
1379 | } | |
1380 | } | |
1381 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1382 | void AliSignal::ResetWaveform(TString name) |
1383 | { | |
6a8254a0 | 1384 | // Reset the waveform with the specified name. |
1385 | Int_t j=GetWaveformIndex(name); | |
2cb7369d | 1386 | if (j>0) ResetWaveform(j); |
1387 | } | |
1388 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 1389 | void AliSignal::DeleteWaveform(Int_t j) |
1390 | { | |
6a8254a0 | 1391 | // Delete the histogram of the j-th (default j=1) waveform. |
1392 | // Notes : The first position is at j=1. | |
1fbffa23 | 1393 | // j=0 ==> All waveforms will be deleted. |
1394 | ||
1395 | if (!fWaveforms) return; | |
1396 | ||
1397 | Int_t size=fWaveforms->GetSize(); | |
1398 | ||
1399 | if ((j>=0) && (j<=size)) | |
1400 | { | |
1401 | if (j) | |
1402 | { | |
1403 | TH1F* hwave=(TH1F*)fWaveforms->At(j-1); | |
1404 | if (hwave) | |
1405 | { | |
1406 | fWaveforms->Remove(hwave); | |
1407 | delete hwave; | |
1408 | } | |
1409 | } | |
1410 | else | |
1411 | { | |
1412 | delete fWaveforms; | |
1413 | fWaveforms=0; | |
1414 | } | |
1415 | } | |
1416 | else | |
1417 | { | |
1418 | cout << " *AliSignal::DeleteWaveform* Index j = " << j << " invalid." << endl; | |
1419 | return; | |
1420 | } | |
1421 | } | |
1422 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1423 | void AliSignal::DeleteWaveform(TString name) |
1424 | { | |
6a8254a0 | 1425 | // Delete the waveform with the specified name. |
1426 | Int_t j=GetWaveformIndex(name); | |
2cb7369d | 1427 | if (j>0) DeleteWaveform(j); |
1428 | } | |
1429 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1430 | Int_t AliSignal::GetNlinks(TObject* obj,Int_t j) const |
5f25234b | 1431 | { |
d0a8ef71 | 1432 | // Provide the number of links to the specified object for the j-th slot. |
1433 | // If j=0 (default) all slots will be scanned for the specified object. | |
1434 | // If obj=0 (default) all encountered objects for the specified slot will be counted. | |
1435 | // So, invokation of the default GetNlinks() will return the total number of | |
1436 | // all references to all sorts of stored objects. | |
1437 | if (j<0) | |
1438 | { | |
1439 | cout << " *AliSignal::GetNlinks* Index j = " << j << " invalid." << endl; | |
1440 | return 0; | |
1441 | } | |
1442 | ||
d0120ca2 | 1443 | if (!fLinks) return 0; |
1444 | ||
5f25234b | 1445 | Int_t n=0; |
d0a8ef71 | 1446 | if (!j) |
1447 | { | |
d0120ca2 | 1448 | n=fLinks->GetNrefs(obj); |
d0a8ef71 | 1449 | } |
1450 | else | |
1451 | { | |
1452 | TArrayI posarr; | |
1453 | n=GetIndices(obj,j,posarr); | |
1454 | } | |
5f25234b | 1455 | return n; |
1456 | } | |
1457 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1458 | Int_t AliSignal::GetNlinks(TObject* obj,TString name) const |
1459 | { | |
1460 | // Provide the number of links to the specified object for the name-spec. slot. | |
1461 | // If obj=0 all encountered objects for the specified slot will be counted. | |
1462 | // | |
1463 | // This procedure involves a slot-index search based on the specified name | |
1464 | // at each invokation. This may become slow in case many slots have been | |
1465 | // defined and/or when this procedure is invoked many times. | |
1466 | // In such cases it is preferable to use indexed addressing in the user code | |
1467 | // either directly or via a few invokations of GetSlotIndex(). | |
1468 | ||
1469 | Int_t j=GetSlotIndex(name); | |
1470 | Int_t n=0; | |
1471 | if (j>0) n=GetNlinks(obj,j); | |
1472 | return n; | |
1473 | } | |
1474 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1475 | TObject* AliSignal::GetLink(Int_t j,Int_t k) const |
5f25234b | 1476 | { |
d0a8ef71 | 1477 | // Provide pointer of the object linked to the j-th slot at position k. |
1478 | ||
5f25234b | 1479 | TObject* obj=0; |
d0a8ef71 | 1480 | // Note : In the internal storage matrix slots=columns positions=rows |
1481 | if (fLinks) obj=fLinks->GetObject(k,j); | |
5f25234b | 1482 | return obj; |
1483 | } | |
1484 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1485 | TObject* AliSignal::GetLink(TString name,Int_t k) const |
1486 | { | |
1487 | // Provide pointer of the object linked to the name-spec. slot at position k. | |
1488 | // | |
1489 | // This procedure involves a slot-index search based on the specified name | |
1490 | // at each invokation. This may become slow in case many slots have been | |
1491 | // defined and/or when this procedure is invoked many times. | |
1492 | // In such cases it is preferable to use indexed addressing in the user code | |
1493 | // either directly or via a few invokations of GetSlotIndex(). | |
1494 | ||
1495 | Int_t j=GetSlotIndex(name); | |
1496 | TObject* obj=0; | |
1497 | if (j>0) obj=GetLink(j,k); | |
1498 | return obj; | |
1499 | } | |
1500 | /////////////////////////////////////////////////////////////////////////// | |
d0a8ef71 | 1501 | void AliSignal::SetLink(TObject* obj,Int_t j,Int_t k) |
5f25234b | 1502 | { |
d0a8ef71 | 1503 | // Introduce a link (=pointer) to an object for the j-th slot at position k. |
5f25234b | 1504 | // Only the pointer values are stored for (backward) reference, meaning |
1505 | // that the objects of which the pointers are stored are NOT owned | |
1506 | // by the AliSignal object. | |
1507 | // | |
1508 | // Notes : | |
d0a8ef71 | 1509 | // The first slot is at j=1 and the first position is at k=1. |
1510 | // j=1 and k=1 are the default values. | |
5f25234b | 1511 | // |
d0a8ef71 | 1512 | // If needed, the storage area for the links is increased automatically. |
5f25234b | 1513 | // |
1514 | // In case the pointer argument is zero, indeed a value of zero will be | |
d0a8ef71 | 1515 | // stored at the specified position (k) for the specified slot (j). |
5f25234b | 1516 | // |
1517 | // In principle any object derived from TObject can be referred to by this | |
1518 | // mechanism. | |
1519 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1520 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1521 | // is related (see AliTrack::AddSignal). | |
1522 | // Therefore, in case the input argument "obj" points to an AliTrack (or derived) | |
1523 | // object, the current signal is automatically related to this AliTrack | |
1524 | // (or derived) object. | |
d0120ca2 | 1525 | // Also a global link to this AliTrack (or derived) object will be stored |
1526 | // via the AddTrack() facility. | |
1527 | // | |
1528 | // IMPORTANT NOTE : | |
1529 | // ---------------- | |
1530 | // In case one just wants to relate the current AliSignal to a certain AliTrack | |
1531 | // without a specific signal slot association, it is much more efficient | |
1532 | // (both memory and CPU wise) to use the memberfunction AddTrack() instead. | |
5f25234b | 1533 | // |
1534 | // Please also have a look at the docs of the memberfunction ResetLink() | |
1535 | // to prevent the situation of stored pointers to non-existent object. | |
1536 | ||
d0a8ef71 | 1537 | if (!fLinks && obj) fLinks=new AliObjMatrix(); |
5f25234b | 1538 | |
d0a8ef71 | 1539 | if (!fLinks) return; |
5f25234b | 1540 | |
d0a8ef71 | 1541 | // Note : In the internal storage matrix slots=columns positions=rows |
1542 | fLinks->EnterObject(k,j,obj); | |
1543 | if (obj) | |
5f25234b | 1544 | { |
d0a8ef71 | 1545 | if (obj->InheritsFrom("AliTrack")) |
5f25234b | 1546 | { |
d0a8ef71 | 1547 | AliTrack* t=(AliTrack*)obj; |
d0120ca2 | 1548 | AddTrack(*t,1); |
5f25234b | 1549 | } |
1550 | } | |
1551 | } | |
1552 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1553 | void AliSignal::SetLink(TObject* obj,TString name,Int_t k) |
1554 | { | |
1555 | // Introduce a link (=pointer) to an object for the name-spec. slot at position k. | |
1556 | // Only the pointer values are stored for (backward) reference, meaning | |
1557 | // that the objects of which the pointers are stored are NOT owned | |
1558 | // by the AliSignal object. | |
1559 | // | |
1560 | // This procedure involves a slot-index search based on the specified name | |
1561 | // at each invokation. This may become slow in case many slots have been | |
1562 | // defined and/or when this procedure is invoked many times. | |
1563 | // In such cases it is preferable to use indexed addressing in the user code | |
1564 | // either directly or via a few invokations of GetSlotIndex(). | |
d0120ca2 | 1565 | // |
1566 | // In case the pointer argument is zero, indeed a value of zero will be | |
1567 | // stored at the specified position (k) for the specified slotname. | |
1568 | // | |
1569 | // In principle any object derived from TObject can be referred to by this | |
1570 | // mechanism. | |
1571 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1572 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1573 | // is related (see AliTrack::AddSignal). | |
1574 | // Therefore, in case the input argument "obj" points to an AliTrack (or derived) | |
1575 | // object, the current signal is automatically related to this AliTrack | |
1576 | // (or derived) object. | |
1577 | // Also a global link to this AliTrack (or derived) object will be stored | |
1578 | // via the AddTrack() facility. | |
1579 | // | |
1580 | // IMPORTANT NOTE : | |
1581 | // ---------------- | |
1582 | // In case one just wants to relate the current AliSignal to a certain AliTrack | |
1583 | // without a specific signal slot association, it is much more efficient | |
1584 | // (both memory and CPU wise) to use the memberfunction AddTrack() instead. | |
1585 | // | |
1586 | // Please also have a look at the docs of the memberfunction ResetLink() | |
1587 | // to prevent the situation of stored pointers to non-existent object. | |
2cb7369d | 1588 | |
1589 | Int_t j=GetSlotIndex(name); | |
1590 | if (j>0) SetLink(obj,j,k); | |
1591 | } | |
1592 | /////////////////////////////////////////////////////////////////////////// | |
d0a8ef71 | 1593 | void AliSignal::AddLink(TObject* obj,Int_t j) |
1594 | { | |
1595 | // Introduce a link (=pointer) to an object for the j-th slot at the first | |
1596 | // free position. | |
1597 | // Only the pointer values are stored for (backward) reference, meaning | |
1598 | // that the objects of which the pointers are stored are NOT owned | |
1599 | // by the AliSignal object. | |
1600 | // | |
1601 | // Notes : | |
1602 | // The first slot is at j=1 and the first position is at k=1. | |
1603 | // j=1 is the default value. | |
1604 | // | |
1605 | // If needed, the storage area for the links is increased automatically. | |
1606 | // | |
1607 | // In case the pointer argument is zero, no link will be added. | |
1608 | // | |
1609 | // In principle any object derived from TObject can be referred to by this | |
1610 | // mechanism. | |
1611 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1612 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1613 | // is related (see AliTrack::AddSignal). | |
1614 | // Therefore, in case the input argument "obj" points to an AliTrack (or derived) | |
1615 | // object, the current signal is automatically related to this AliTrack | |
1616 | // (or derived) object. | |
d0120ca2 | 1617 | // Also a global link to this AliTrack (or derived) object will be stored |
1618 | // via the AddTrack() facility. | |
1619 | // | |
1620 | // IMPORTANT NOTE : | |
1621 | // ---------------- | |
1622 | // In case one just wants to relate the current AliSignal to a certain AliTrack | |
1623 | // without a specific signal slot association, it is much more efficient | |
1624 | // (both memory and CPU wise) to use the memberfunction AddTrack() instead. | |
d0a8ef71 | 1625 | // |
1626 | // Please also have a look at the docs of the memberfunction ResetLink() | |
1627 | // to prevent the situation of stored pointers to non-existent object. | |
1628 | ||
1629 | if (!obj || j<=0) return; | |
1630 | ||
1631 | if (!fLinks) fLinks=new AliObjMatrix(); | |
1632 | ||
1633 | TObject* dum=0; | |
1634 | Int_t n=GetNlinks(dum,j); | |
1635 | Int_t pos=1; | |
1636 | for (Int_t k=1; k<=n; k++) | |
1637 | { | |
1638 | dum=GetLink(j,k); | |
1639 | if (!dum) break; | |
1640 | pos++; | |
1641 | } | |
1642 | ||
1643 | SetLink(obj,j,pos); | |
1644 | } | |
1645 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1646 | void AliSignal::AddLink(TObject* obj,TString name) |
1647 | { | |
1648 | // Introduce a link (=pointer) to an object for the name-spec slot at the first | |
1649 | // free position. | |
1650 | // Only the pointer values are stored for (backward) reference, meaning | |
1651 | // that the objects of which the pointers are stored are NOT owned | |
1652 | // by the AliSignal object. | |
1653 | // | |
1654 | // This procedure involves a slot-index search based on the specified name | |
1655 | // at each invokation. This may become slow in case many slots have been | |
1656 | // defined and/or when this procedure is invoked many times. | |
1657 | // In such cases it is preferable to use indexed addressing in the user code | |
1658 | // either directly or via a few invokations of GetSlotIndex(). | |
d0120ca2 | 1659 | // |
1660 | // In case the pointer argument is zero, indeed a value of zero will be | |
1661 | // stored at the first free position of the specified slotname. | |
1662 | // | |
1663 | // In principle any object derived from TObject can be referred to by this | |
1664 | // mechanism. | |
1665 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1666 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1667 | // is related (see AliTrack::AddSignal). | |
1668 | // Therefore, in case the input argument "obj" points to an AliTrack (or derived) | |
1669 | // object, the current signal is automatically related to this AliTrack | |
1670 | // (or derived) object. | |
1671 | // Also a global link to this AliTrack (or derived) object will be stored | |
1672 | // via the AddTrack() facility. | |
1673 | // | |
1674 | // IMPORTANT NOTE : | |
1675 | // ---------------- | |
1676 | // In case one just wants to relate the current AliSignal to a certain AliTrack | |
1677 | // without a specific signal slot association, it is much more efficient | |
1678 | // (both memory and CPU wise) to use the memberfunction AddTrack() instead. | |
1679 | // | |
1680 | // Please also have a look at the docs of the memberfunction ResetLink() | |
1681 | // to prevent the situation of stored pointers to non-existent object. | |
2cb7369d | 1682 | |
1683 | Int_t j=GetSlotIndex(name); | |
1684 | if (j>0) AddLink(obj,j); | |
1685 | } | |
1686 | /////////////////////////////////////////////////////////////////////////// | |
d0a8ef71 | 1687 | void AliSignal::ResetLink(Int_t j,Int_t k) |
5f25234b | 1688 | { |
d0a8ef71 | 1689 | // Reset the link of the j-th slot at position k. |
1690 | // | |
1691 | // Notes : | |
1692 | // The first slot is at j=1 and the first position is at k=1. | |
1693 | // j=1 and k=1 are the default values. | |
1694 | // | |
1695 | // This memberfunction is intended to reset only 1 specified link location. | |
1696 | // For extended functionality, please refer to the memberfuction ResetLinks(). | |
5f25234b | 1697 | // |
1698 | // In general the user should take care of properly clearing the corresponding | |
1699 | // pointer here when the referred object is deleted. | |
1700 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1701 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1702 | // is related (see AliTrack::AddSignal). | |
1703 | // As such, the AliTrack destructor already takes care of clearing the corresponding | |
1704 | // links from the various AliSignal slots for all the AliSignal objects that were | |
1705 | // related to that AliTrack. | |
1706 | // So, in case the link introduced via SetLink() is the pointer of an AliTrack object, | |
1707 | // the user doesn't have to worry about clearing the corresponding AliTrack link from | |
1708 | // the AliSignal object when the corresponding AliTrack object is deleted. | |
1709 | ||
d0a8ef71 | 1710 | // Note : In the internal storage matrix slots=columns positions=rows |
1711 | if (fLinks) fLinks->RemoveObject(k,j); | |
5f25234b | 1712 | } |
1713 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1714 | void AliSignal::ResetLink(TString name,Int_t k) |
1715 | { | |
1716 | // Reset the link of the name-specified slot at position k. | |
1717 | // | |
1718 | // This memberfunction is intended to reset only 1 specified link location. | |
1719 | // For extended functionality, please refer to the memberfuction ResetLinks(). | |
1720 | // | |
1721 | // This procedure involves a slot-index search based on the specified name | |
1722 | // at each invokation. This may become slow in case many slots have been | |
1723 | // defined and/or when this procedure is invoked many times. | |
1724 | // In such cases it is preferable to use indexed addressing in the user code | |
1725 | // either directly or via a few invokations of GetSlotIndex(). | |
1726 | ||
1727 | Int_t j=GetSlotIndex(name); | |
1728 | if (j>0) ResetLink(j,k); | |
1729 | } | |
1730 | /////////////////////////////////////////////////////////////////////////// | |
d0a8ef71 | 1731 | void AliSignal::ResetLinks(TObject* obj,Int_t j,Int_t k) |
5f25234b | 1732 | { |
d0120ca2 | 1733 | // Reset single or multiple slot link(s) according to user specified selections. |
1734 | // | |
1735 | // IMPORTANT NOTE : | |
1736 | // ---------------- | |
1737 | // This facility only acts on the slot related links. | |
1738 | // The global track reference list will not be affected. | |
1739 | // To remove all references to AliTrack (or derived) objects, please | |
1740 | // use the RemoveTrack() of RemoveTracks() memberfunctions. | |
d0a8ef71 | 1741 | // |
1742 | // A link is only reset if the stored reference matches the argument "obj". | |
1743 | // In case obj=0 no check on the matching of the stored reference is performed | |
1744 | // and the stored link is always reset in accordance with the other | |
1745 | // selection criteria. | |
1746 | // | |
1747 | // In case the slot argument "j" is specified, only the links from that | |
1748 | // specified slot will be deleted. | |
1749 | // In case j=0 (default) no checking on the slot index is performed. | |
1750 | // | |
1751 | // In case the position argument "k" is specified, only the links from that | |
1752 | // specified position will be deleted. | |
1753 | // In case k=0 (default) no checking on the position index is performed. | |
1754 | // | |
1755 | // So, invokation of ResetLinks(obj) will remove all references to the | |
1756 | // object "obj" from the total AliSignal, whereas ResetLinks(obj,j) | |
1757 | // will remove all references to the object "obj" only from slot "j". | |
1758 | // | |
1759 | // Notes : | |
1760 | // ------- | |
1761 | // The first slot is indicated as j=1, whereas the first position is at k=1. | |
1762 | // | |
1763 | // Invokation of ResetLinks(0,row,col) is equivalent to invoking the | |
1764 | // memberfunction ResetLink(row,col). | |
1765 | // Invoking the latter directly is slightly faster. | |
1766 | // | |
1767 | // Invokation of ResetLinks(0) will reset all stored references in this AliSignal. | |
5f25234b | 1768 | // |
1769 | // In general the user should take care of properly clearing the corresponding | |
1770 | // pointer here when the referred object is deleted. | |
1771 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1772 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1773 | // is related (see AliTrack::AddSignal). | |
1774 | // As such, the AliTrack destructor already takes care of clearing the corresponding | |
1775 | // links from the various AliSignal slots for all the AliSignal objects that were | |
1776 | // related to that AliTrack. | |
1777 | // So, in case the link introduced via SetLink() is the pointer of an AliTrack object, | |
1778 | // the user doesn't have to worry about clearing the corresponding AliTrack link from | |
1779 | // the AliSignal object when the corresponding AliTrack object is deleted. | |
1780 | ||
d0a8ef71 | 1781 | if (!fLinks) return; |
5f25234b | 1782 | |
d0a8ef71 | 1783 | if (!obj && !j && !k) |
5f25234b | 1784 | { |
d0a8ef71 | 1785 | fLinks->Reset(); |
5f25234b | 1786 | } |
d0a8ef71 | 1787 | else |
1788 | { | |
1789 | // Note : In the internal storage matrix slots=columns positions=rows | |
1790 | fLinks->RemoveObjects(obj,k,j); | |
1791 | } | |
1792 | } | |
1793 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1794 | void AliSignal::ResetLinks(TObject* obj,TString name,Int_t k) |
1795 | { | |
d0120ca2 | 1796 | // Reset single or multiple slot link(s) according to user specified selections. |
1797 | // | |
1798 | // IMPORTANT NOTE : | |
1799 | // ---------------- | |
1800 | // This facility only acts on the slot related links. | |
1801 | // The global track reference list will not be affected. | |
1802 | // To remove all references to AliTrack (or derived) objects, please | |
1803 | // use the RemoveTrack() of RemoveTracks() memberfunctions. | |
2cb7369d | 1804 | // |
1805 | // A link is only reset if the stored reference matches the argument "obj". | |
1806 | // In case obj=0 no check on the matching of the stored reference is performed | |
1807 | // and the stored link is always reset in accordance with the other | |
1808 | // selection criteria. | |
1809 | // | |
1810 | // In case the position argument "k" is specified, only the links from that | |
1811 | // specified position will be deleted. | |
1812 | // In case k=0 (default) no checking on the position index is performed. | |
1813 | // | |
1814 | // This procedure involves a slot-index search based on the specified name | |
1815 | // at each invokation. This may become slow in case many slots have been | |
1816 | // defined and/or when this procedure is invoked many times. | |
1817 | // In such cases it is preferable to use indexed addressing in the user code | |
1818 | // either directly or via a few invokations of GetSlotIndex(). | |
d0120ca2 | 1819 | // |
1820 | // In general the user should take care of properly clearing the corresponding | |
1821 | // pointer here when the referred object is deleted. | |
1822 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1823 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1824 | // is related (see AliTrack::AddSignal). | |
1825 | // As such, the AliTrack destructor already takes care of clearing the corresponding | |
1826 | // links from the various AliSignal slots for all the AliSignal objects that were | |
1827 | // related to that AliTrack. | |
1828 | // So, in case the link introduced via SetLink() is the pointer of an AliTrack object, | |
1829 | // the user doesn't have to worry about clearing the corresponding AliTrack link from | |
1830 | // the AliSignal object when the corresponding AliTrack object is deleted. | |
2cb7369d | 1831 | |
1832 | Int_t j=GetSlotIndex(name); | |
1833 | if (j>0) ResetLinks(obj,j,k); | |
1834 | } | |
1835 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1836 | Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,TArrayI& ks) const |
d0a8ef71 | 1837 | { |
1838 | // Provide the slot and position indices of all the storage locations | |
1839 | // of the specified object. | |
1840 | // The slot (j) and pos. (k) indices are returned in the two separate TArrayI arrays | |
1841 | // from which the (j,k) pairs can be obtained from the corresponding | |
1842 | // array indices like (j,k)=(js.At(i),ks.At(i)). | |
1843 | // The integer return argument represents the number of (j,k) pairs which | |
1844 | // were encountered for the specified object. | |
1845 | // | |
1846 | // If obj=0 no object selection is performed and all (j,k) indices | |
1847 | // of the stored references for all objects are returned. | |
1848 | // | |
1849 | // Notes : | |
1850 | // ------- | |
1851 | // As usual the convention is that slot and position numbering starts at 1. | |
1852 | // | |
1853 | // This memberfunction always resets the two TArrayI arrays at the start. | |
1854 | // | |
1855 | // This memberfunction can only be used to obtain the (j,k) indices | |
1856 | // of the object as stored via the SetLink() or AddLink() memberfunction. | |
1857 | // This means that in case the user has entered a TObjArray as object | |
1858 | // (to increase the dimension of the resulting structure), the (j,k) | |
1859 | // indices of that TObjArray are obtained and NOT the indices of the | |
1860 | // actual objects contained in that TObjArray structure. | |
1861 | // | |
1862 | Int_t nrefs=0; | |
1863 | js.Reset(); | |
1864 | ks.Reset(); | |
1865 | // Note : In the internal storage matrix slots=columns positions=rows | |
1866 | if (fLinks) nrefs=fLinks->GetIndices(obj,ks,js); | |
1867 | return nrefs; | |
1868 | } | |
1869 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1870 | Int_t AliSignal::GetIndices(TObject* obj,Int_t j,TArrayI& ks) const |
d0a8ef71 | 1871 | { |
1872 | // Provide the position indices of all the storage locations of the | |
1873 | // specified object in the j-th slot of this AliSignal. | |
1874 | // The position indices are returned in the TArrayI array. | |
1875 | // The integer return argument represents the number of storage locations which | |
1876 | // were encountered for the specified object in the j-th slot. | |
1877 | // | |
1878 | // If obj=0 no object selection is performed and all position indices | |
1879 | // of the stored references for all objects of the j-th slot are returned. | |
1880 | // | |
1881 | // If j=0 all slots will be scanned and all position indices matching the | |
1882 | // object selection are returned. | |
1883 | // Note that in this case multiple appearances of the same position index | |
1884 | // will only be recorded once in the returned TArrayI array. | |
1885 | // | |
1886 | // Notes : | |
1887 | // ------- | |
1888 | // As usual the convention is that slot and position numbering starts at 1. | |
1889 | // | |
1890 | // This memberfunction always resets the TArrayI array at the start. | |
1891 | // | |
1892 | // This memberfunction can only be used to obtain the position indices | |
1893 | // of the object as stored via the SetLink() or AddLink() memberfunction. | |
1894 | // This means that in case the user has entered a TObjArray as object | |
1895 | // (to increase the dimension of the resulting structure), the position | |
1896 | // indices of that TObjArray are obtained and NOT the indices of the | |
1897 | // actual objects contained in that TObjArray structure. | |
1898 | // | |
1899 | Int_t nrefs=0; | |
1900 | ks.Reset(); | |
1901 | // Note : In the internal storage matrix slots=columns positions=rows | |
1902 | if (fLinks) nrefs=fLinks->GetIndices(obj,ks,j); | |
1903 | return nrefs; | |
1904 | } | |
1905 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1906 | Int_t AliSignal::GetIndices(TObject* obj,TString name,TArrayI& ks) const |
1907 | { | |
1908 | // Provide the position indices of all the storage locations of the | |
1909 | // specified object in the name-specified slot of this AliSignal. | |
1910 | // The position indices are returned in the TArrayI array. | |
1911 | // The integer return argument represents the number of storage locations which | |
1912 | // were encountered for the specified object in the j-th slot. | |
1913 | // | |
1914 | // If obj=0 no object selection is performed and all position indices | |
1915 | // of the stored references for all objects of the j-th slot are returned. | |
1916 | // | |
1917 | // This procedure involves a slot-index search based on the specified name | |
1918 | // at each invokation. This may become slow in case many slots have been | |
1919 | // defined and/or when this procedure is invoked many times. | |
1920 | // In such cases it is preferable to use indexed addressing in the user code | |
1921 | // either directly or via a few invokations of GetSlotIndex(). | |
1922 | ||
1923 | Int_t j=GetSlotIndex(name); | |
1924 | Int_t n=0; | |
1925 | if (j>0) n=GetIndices(obj,j,ks); | |
1926 | return n; | |
1927 | } | |
1928 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1929 | Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,Int_t k) const |
d0a8ef71 | 1930 | { |
1931 | // Provide the slot indices of all the storage locations of the | |
1932 | // specified object for the k-th position in this AliSignal. | |
1933 | // The slot indices are returned in the TArrayI array. | |
1934 | // The integer return argument represents the number of storage locations which | |
1935 | // were encountered for the specified object in the k-th position. | |
1936 | // | |
1937 | // If obj=0 no object selection is performed and all slot indices | |
1938 | // of the stored references for all objects in the k-th position are returned. | |
1939 | // | |
1940 | // If k=0 all positions will be scanned and all slot indices matching the | |
1941 | // object selection are returned. | |
1942 | // Note that in this case multiple appearances of the same slot index | |
1943 | // will only be recorded once in the returned TArrayI array. | |
1944 | // | |
1945 | // Notes : | |
1946 | // ------- | |
1947 | // As usual the convention is that slot and position numbering starts at 1. | |
1948 | // | |
1949 | // This memberfunction always resets the TArrayI array at the start. | |
1950 | // | |
1951 | // This memberfunction can only be used to obtain the slot indices | |
1952 | // of the object as stored via the SetLink() or AddLink() memberfunction. | |
1953 | // This means that in case the user has entered a TObjArray as object | |
1954 | // (to increase the dimension of the resulting structure), the slot | |
1955 | // indices of that TObjArray are obtained and NOT the indices of the | |
1956 | // actual objects contained in that TObjArray structure. | |
1957 | // | |
1958 | Int_t nrefs=0; | |
1959 | js.Reset(); | |
1960 | // Note : In the internal storage matrix slots=columns positions=rows | |
1961 | if (fLinks) nrefs=fLinks->GetIndices(obj,k,js); | |
1962 | return nrefs; | |
1963 | } | |
1964 | /////////////////////////////////////////////////////////////////////////// | |
1965 | void AliSignal::SetSwapMode(Int_t swap) | |
1966 | { | |
1967 | // Set swapmode flag for the internal link storage. | |
1968 | // In case for the stored links the maximum slot number differs considerably | |
1969 | // from the maximum position number, it might be more efficient | |
1970 | // (w.r.t. memory usage and/or output file size) to internally store the | |
1971 | // link reference matrix with the rows and colums swapped. | |
1972 | // This swapping is only related with the internal storage and as such | |
1973 | // is completely hidden for the user. | |
1974 | // At invokation of this memberfunction the default argument is swap=1. | |
1975 | // | |
1976 | // Note : The swap mode can only be set as long as no links are | |
1977 | // stored in the AliSignal (i.e. a new instance of AliSignal | |
1978 | // or after invokation of the Reset() or ResetLinks() function). | |
1979 | ||
1980 | if (!fLinks) fLinks=new AliObjMatrix(); | |
1981 | fLinks->SetSwapMode(swap); | |
1982 | } | |
1983 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1984 | Int_t AliSignal::GetSwapMode() const |
d0a8ef71 | 1985 | { |
1986 | // Provide swapmode flag of the link storage. | |
1987 | Int_t swap=0; | |
1988 | if (fLinks) swap=fLinks->GetSwapMode(); | |
1989 | return swap; | |
5f25234b | 1990 | } |
1991 | /////////////////////////////////////////////////////////////////////////// | |
965bd237 | 1992 | void AliSignal::SetDevice(TObject* dev) |
1993 | { | |
1994 | // Store the pointer to the device which owns this AliSignal object. | |
1995 | // This memberfunction is meant for internal use in AliDevice. | |
1996 | fDevice=dev; | |
1997 | } | |
1998 | /////////////////////////////////////////////////////////////////////////// | |
1999 | AliDevice* AliSignal::GetDevice() const | |
2000 | { | |
2001 | // Provide the pointer to the device which owns this AliSignal object. | |
2002 | return (AliDevice*)fDevice; | |
2003 | } | |
2004 | /////////////////////////////////////////////////////////////////////////// | |
d0120ca2 | 2005 | void AliSignal::AddTrack(AliTrack& t,Int_t mode) |
2006 | { | |
2007 | // Relate an AliTrack object to this signal. | |
2008 | // Only the pointer values are stored for (backward) reference, meaning | |
2009 | // that the tracks of which the pointers are stored are NOT owned | |
2010 | // by the AliSignal object. | |
2011 | // | |
2012 | // mode = 0 : Only the reference to the specified track is stored in | |
2013 | // the current signal, without storing the (backward) reference | |
2014 | // to this signal into the AliTrack structure. | |
2015 | // 1 : The (backward) reference to the current signal is also automatically | |
2016 | // stored into the AliTrack (or derived) object specified in the | |
2017 | // input argument. | |
2018 | // | |
2019 | // The default is mode=1. | |
2020 | ||
2021 | if (!fTracks) fTracks=new TObjArray(1); | |
2022 | ||
2023 | // Check if this track is already stored for this signal | |
2024 | Int_t ntk=GetNtracks(); | |
2025 | for (Int_t i=0; i<ntk; i++) | |
2026 | { | |
2027 | if (&t==fTracks->At(i)) return; | |
2028 | } | |
2029 | ||
2030 | fTracks->Add(&t); | |
2031 | if (mode==1) t.AddSignal(*this,0); | |
2032 | } | |
2033 | /////////////////////////////////////////////////////////////////////////// | |
2034 | void AliSignal::RemoveTrack(AliTrack& t,Int_t mode) | |
2035 | { | |
2036 | // Remove related AliTrack object from this signal. | |
2037 | // Also all references (if any) to this track in the slot links area | |
2038 | // are removed. | |
2039 | // | |
2040 | // mode = 0 : All references to the specified track are removed from | |
2041 | // the current signal, without removing the (backward) reference | |
2042 | // to this signal from the AliTrack structure. | |
2043 | // 1 : The (backward) reference to the current signal is also automatically | |
2044 | // removed from the AliTrack (or derived) object specified in the | |
2045 | // input argument. | |
2046 | // | |
2047 | // The default is mode=1. | |
2048 | ||
2049 | if (fTracks) | |
2050 | { | |
2051 | AliTrack* test=(AliTrack*)fTracks->Remove(&t); | |
2052 | if (test) fTracks->Compress(); | |
2053 | } | |
2054 | ||
2055 | ResetLinks(&t); | |
2056 | ||
2057 | if (mode==1) t.RemoveSignal(*this,0); | |
2058 | } | |
2059 | /////////////////////////////////////////////////////////////////////////// | |
2060 | void AliSignal::RemoveTracks(Int_t mode) | |
2061 | { | |
2062 | // Remove all related AliTrack objects from this signal. | |
2063 | // Also all references (if any) to the related tracks in the slot links area | |
2064 | // are removed. | |
2065 | // | |
2066 | // mode = 0 : All track references are removed from the current signal, | |
2067 | // without removing the (backward) references to this signal from | |
2068 | // the corresponding AliTrack objects. | |
2069 | // 1 : The (backward) references to the current signal are also automatically | |
2070 | // removed from the corresponding AliTrack (or derived) objects. | |
2071 | // | |
2072 | // The default is mode=1. | |
2073 | ||
2074 | if (!fTracks) return; | |
2075 | ||
2076 | Int_t ntk=GetNtracks(); | |
2077 | for (Int_t i=0; i<ntk; i++) | |
2078 | { | |
2079 | AliTrack* tx=(AliTrack*)fTracks->At(i); | |
2080 | if (tx) | |
2081 | { | |
2082 | ResetLinks(tx); | |
2083 | if (mode==1) tx->RemoveSignal(*this,0); | |
2084 | } | |
2085 | } | |
2086 | ||
2087 | delete fTracks; | |
2088 | fTracks=0; | |
2089 | } | |
2090 | /////////////////////////////////////////////////////////////////////////// | |
2091 | Int_t AliSignal::GetNtracks(AliTrack* t) const | |
2092 | { | |
2093 | // Provide the number of related AliTracks. | |
2094 | // In case an AliTrack pointer is specified as input argument, | |
2095 | // the number returned will be the number of occurrences (i.e. 0 or 1) | |
2096 | // for that specified track. | |
2097 | // By default t=0, which implies that just the number of all associated | |
2098 | // tracks will be returned. | |
2099 | ||
2100 | if (!fTracks) return 0; | |
2101 | ||
2102 | Int_t ntk=fTracks->GetEntries(); | |
2103 | ||
2104 | if (!t) return ntk; | |
2105 | ||
2106 | for (Int_t i=0; i<ntk; i++) | |
2107 | { | |
2108 | AliTrack* tx=(AliTrack*)fTracks->At(i); | |
2109 | if (tx==t) return 1; | |
2110 | } | |
2111 | ||
2112 | return 0; | |
2113 | } | |
2114 | /////////////////////////////////////////////////////////////////////////// | |
2115 | AliTrack* AliSignal::GetTrack(Int_t j) const | |
2116 | { | |
2117 | // Provide the related AliTrack number j. | |
2118 | // Note : j=1 denotes the first track. | |
2119 | ||
2120 | if (!fTracks) return 0; | |
2121 | ||
2122 | if ((j >= 1) && (j <= GetNtracks())) | |
2123 | { | |
2124 | return (AliTrack*)fTracks->At(j-1); | |
2125 | } | |
2126 | else | |
2127 | { | |
2128 | cout << " *AliSignal* track number : " << j << " out of range." | |
2129 | << " Ntk = " << GetNtracks() << endl; | |
2130 | return 0; | |
2131 | } | |
2132 | } | |
2133 | /////////////////////////////////////////////////////////////////////////// | |
2134 | AliTrack* AliSignal::GetIdTrack(Int_t id) const | |
2135 | { | |
2136 | // Return the track with user identifier "id" of this signal | |
2137 | if (!fTracks) return 0; | |
2138 | ||
2139 | AliTrack* tx=0; | |
2140 | for (Int_t i=0; i<GetNtracks(); i++) | |
2141 | { | |
2142 | tx=(AliTrack*)fTracks->At(i); | |
2143 | if (id == tx->GetId()) return tx; | |
2144 | } | |
2145 | return 0; // No matching id found | |
2146 | } | |
2147 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 2148 | TObject* AliSignal::Clone(const char* name) const |
c72198f1 | 2149 | { |
1c01b4f8 | 2150 | // Make a deep copy of the current object and provide the pointer to the copy. |
c72198f1 | 2151 | // This memberfunction enables automatic creation of new objects of the |
1c01b4f8 | 2152 | // correct type depending on the object type, a feature which may be very useful |
c72198f1 | 2153 | // for containers when adding objects in case the container owns the objects. |
2154 | // This feature allows e.g. AliTrack to store either AliSignal objects or | |
2155 | // objects derived from AliSignal via the AddSignal memberfunction, provided | |
1c01b4f8 | 2156 | // these derived classes also have a proper Clone memberfunction. |
c72198f1 | 2157 | |
1c01b4f8 | 2158 | AliSignal* sig=new AliSignal(*this); |
2159 | if (name) | |
2160 | { | |
2161 | if (strlen(name)) sig->SetName(name); | |
2162 | } | |
c72198f1 | 2163 | return sig; |
2164 | } | |
2165 | /////////////////////////////////////////////////////////////////////////// |