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