]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RALICE/AliEvent.cxx
13-oct-2005 NvE TTask derived class IceCleanHits introduced to perform hit cleaning.
[u/mrichter/AliRoot.git] / RALICE / AliEvent.cxx
CommitLineData
d16062ac 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
4f368c8c 16// $Id: AliEvent.cxx,v 1.25 2004/10/20 10:49:44 nick Exp $
d16062ac 17
18///////////////////////////////////////////////////////////////////////////
19// Class AliEvent
20// Creation and investigation of an Alice physics event.
7849a8ab 21// An AliEvent can be constructed by adding AliTracks, Alivertices, AliJets
7a086578 22// and/or devices like AliCalorimeters or AliDevice (derived) objects.
23//
1c01b4f8 24// All objects which are derived from TObject can be regarded as a device.
7a086578 25// However, AliDevice (or derived) objects profit from additional hit
26// handling facilities.
27// A "hit" is a generic name indicating an AliSignal (or derived) object.
28// Note that AliEvent does NOT own hits; it only provides references to hits
29// obtained from the various devices.
30// This implies that hits should be owned by the devices themselves.
d16062ac 31//
32// The basic functionality of AliEvent is identical to the one of AliVertex.
35044448 33// So, an AliEvent may be used as the primary vertex with some additional
34// functionality compared to AliVertex.
d16062ac 35//
7849a8ab 36// To provide maximal flexibility to the user, the two modes of track/jet/vertex
37// storage as described in AliJet and AliVertex can be used.
1c01b4f8 38// In addition an identical structure is provided for the storage of devices like
39// AliCalorimeter objects, which can be selected by means of the memberfunction
40// SetDevCopy().
41//
42// a) SetDevCopy(0) (which is the default).
43// Only the pointers of the 'added' devices are stored.
44// This mode is typically used by making studies based on a fixed set
45// of devices which stays under user control or is kept on an external
7849a8ab 46// file/tree.
47// In this way the AliEvent just represents a 'logical structure' for the
48// physics analysis.
35044448 49//
50// Note :
1c01b4f8 51// Modifications made to the original devices also affect the device
7849a8ab 52// objects which are stored in the AliEvent.
35044448 53//
1c01b4f8 54// b) SetDevCopy(1).
55// Of every 'added' device a private copy will be made of which the pointer
7849a8ab 56// will be stored.
57// In this way the AliEvent represents an entity on its own and modifications
58// made to the original calorimeters do not affect the AliCalorimeter objects
59// which are stored in the AliEvent.
1c01b4f8 60// This mode will allow 'adding' many different devices into an AliEvent by
61// creating only one device instance in the main programme and using the
62// Reset() and parameter setting memberfunctions of the object representing the device.
63//
64// Note :
65// The copy is made using the Clone() memberfunction.
66// All devices (i.e. classes derived from TObject) have the default TObject::Clone()
67// memberfunction.
68// However, devices generally contain an internal (signal) data structure
69// which may include pointers to other objects. Therefore it is recommended to provide
70// for all devices a specific copy constructor and override the default Clone()
71// memberfunction using this copy constructor.
7a086578 72// Examples for this may be seen from AliCalorimeter, AliSignal and AliDevice.
7849a8ab 73//
8e8e6c7f 74// See also the documentation provided for the memberfunction SetOwner().
75//
7849a8ab 76// Coding example to make an event consisting of a primary vertex,
77// 2 secondary vertices and a calorimeter.
d16062ac 78// --------------------------------------------------------------
7849a8ab 79// vp contains the tracks 1,2,3 and 4 (primary vertex)
80// v1 contains the tracks 5,6 and 7 (sec. vertex)
81// v2 contains the jets 1 and 2 (sec. vertex)
82//
7849a8ab 83// AliEvent evt;
84//
85// Specify the event object as the repository of all objects
86// for the event building and physics analysis.
87//
1c01b4f8 88// evt.SetDevCopy(1);
7849a8ab 89// evt.SetTrackCopy(1);
90//
91// Fill the event structure with the basic objects
92//
b055c99d 93// AliCalorimeter emcal1;
94// AliCalorimeter emcal2;
35044448 95// ...
b055c99d 96// ... // code to fill the emcal1 and emcal2 calorimeter data
35044448 97// ...
98//
b055c99d 99// evt.AddDevice(emcal1);
100// evt.AddDevice(emcal2);
7849a8ab 101//
7a086578 102// // Assume AliTOF has been derived from AliDevice
103// AliTOF tof1;
104// AliTOF tof2;
105// ...
106// ... // code to fill the tof1 and tof2 data
107// ...
108//
109// evt.AddDevice(tof1);
110// evt.AddDevice(tof2);
111//
35044448 112// AliTrack* tx=new AliTrack();
7849a8ab 113// for (Int_t i=0; i<10; i++)
114// {
d16062ac 115// ...
116// ... // code to fill the track data
117// ...
7849a8ab 118// evt.AddTrack(tx);
119// tx->Reset();
120// }
121//
35044448 122// if (tx)
123// {
124// delete tx;
125// tx=0;
126// }
127//
7a086578 128// Order and investigate all the hits of all the TOF devices
129//
130// TObjArray* hits=evt.GetHits("AliTOF");
7b825f44 131// TObjArray* orderedtofs=evt.SortHits(hits);
132// Int_t nhits=0;
133// if (orderedtofs) nhits=orderedtofs->GetEntries();
7a086578 134// for (Int_t i=0; i<nhits; i++)
135// {
7b825f44 136// AliSignal* sx=(AliSignal*)orderedtofs->At(i);
b055c99d 137// if (sx) sx->Data();
138// }
139//
140// Order and investigate all the hits of all the calorimeter devices
141//
142// TObjArray* hits=evt.GetHits("AliCalorimeter");
7b825f44 143// TObjArray* orderedcals=evt.SortHits(hits);
144// Int_t nhits=0;
145// if (orderedcals) nhits=orderedcals->GetEntries();
b055c99d 146// for (Int_t i=0; i<nhits; i++)
147// {
7b825f44 148// AliSignal* sx=(AliSignal*)orderedcals->At(i);
7a086578 149// if (sx) sx->Data();
150// }
151//
7849a8ab 152// Build the event structure (vertices, jets, ...) for physics analysis
153// based on the basic objects from the event repository.
d16062ac 154//
155// AliJet j1,j2;
7849a8ab 156// for (Int_t i=0; i<evt.GetNtracks(); i++)
157// {
158// tx=evt.GetTrack(i);
d16062ac 159// ...
160// ... // code to fill the jet data
161// ...
7849a8ab 162// }
d16062ac 163//
7849a8ab 164// AliVertex vp;
35044448 165// tx=evt.GetTrack(1);
7849a8ab 166// vp.AddTrack(tx);
35044448 167// tx=evt.GetTrack(2);
7849a8ab 168// vp.AddTrack(tx);
35044448 169// tx=evt.GetTrack(3);
7849a8ab 170// vp.AddTrack(tx);
35044448 171// tx=evt.GetTrack(4);
7849a8ab 172// vp.AddTrack(tx);
d16062ac 173//
7849a8ab 174// Float_t rp[3]={2.4,0.1,-8.5};
175// vp.SetPosition(rp,"car");
d16062ac 176//
7849a8ab 177// AliVertex v1;
35044448 178// tx=evt.GetTrack(5);
7849a8ab 179// v1.AddTrack(tx);
35044448 180// tx=evt.GetTrack(6);
7849a8ab 181// v1.AddTrack(tx);
35044448 182// tx=evt.GetTrack(7);
7849a8ab 183// v1.AddTrack(tx);
d16062ac 184//
185// Float_t r1[3]={1.6,-3.2,5.7};
186// v1.SetPosition(r1,"car");
187//
d16062ac 188//
7849a8ab 189// AliVertex v2;
190// v2.SetJetCopy(1);
d16062ac 191// v2.AddJet(j1);
192// v2.AddJet(j2);
193//
194// Float_t r2[3]={6.2,4.8,1.3};
195// v2.SetPosition(r2,"car");
196//
7849a8ab 197// Specify the vertices v1 and v2 as secondary vertices of the primary
198//
199// vp.SetVertexCopy(1);
200// vp.AddVertex(v1);
201// vp.AddVertex(v2);
202//
203// Enter the physics structures into the event
204// evt.SetVertexCopy(1);
205// evt.AddVertex(vp,0);
206//
207// The jets j1 and j2 are already available via sec. vertex v2,
208// but can be made available also from the event itself if desired.
209// AliJet* jx;
210// jx=v2.GetJet(1);
211// evt.AddJet(jx,0);
212// jx=v2.GetJet(2);
213// evt.AddJet(jx,0);
214//
84bb7c66 215// evt.Data("sph");
d16062ac 216// v1.ListAll();
217// v2.List("cyl");
218//
219// Float_t etot=evt.GetEnergy();
220// Ali3Vector ptot=evt.Get3Momentum();
221// Float_t loc[3];
222// evt.GetPosition(loc,"sph");
223// AliPosition r=v1.GetPosition();
84bb7c66 224// r.Data();
d16062ac 225// Int_t nt=v2.GetNtracks();
226// AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
227//
d16062ac 228// evt.List();
229//
230// Int_t nv=evt.GetNvtx();
7849a8ab 231// AliVertex* vx=evt.GetVertex(1); // Access primary vertex
d16062ac 232// Float_t e=vx->GetEnergy();
233//
234// Float_t M=evt.GetInvmass();
235//
236// Reconstruct the event from scratch
237//
238// evt.Reset();
239// evt.SetNvmax(25); // Increase initial no. of sec. vertices
7849a8ab 240// ...
241// ... // code to create tracks etc...
242// ...
d16062ac 243//
244// Note : All quantities are in GeV, GeV/c or GeV/c**2
245//
246//--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
4f368c8c 247//- Modified: NvE $Date: 2004/10/20 10:49:44 $ UU-SAP Utrecht
d16062ac 248///////////////////////////////////////////////////////////////////////////
249
250#include "AliEvent.h"
c72198f1 251#include "Riostream.h"
d16062ac 252
253ClassImp(AliEvent) // Class implementation to enable ROOT I/O
254
3ea81e9c 255AliEvent::AliEvent() : AliVertex(),AliTimestamp()
d16062ac 256{
257// Default constructor.
258// All variables initialised to default values.
d16062ac 259 fRun=0;
260 fEvent=0;
4575fcea 261 fAproj=0;
262 fZproj=0;
263 fPnucProj=0;
da17f667 264 fIdProj=0;
4575fcea 265 fAtarg=0;
266 fZtarg=0;
267 fPnucTarg=0;
da17f667 268 fIdTarg=0;
1c01b4f8 269 fDevices=0;
270 fDevCopy=0;
7a086578 271 fHits=0;
965bd237 272 fOrdered=0;
273 fDisplay=0;
27e6d856 274 fDevs=0;
d16062ac 275}
276///////////////////////////////////////////////////////////////////////////
3ea81e9c 277AliEvent::AliEvent(Int_t n) : AliVertex(n),AliTimestamp()
d16062ac 278{
279// Create an event to hold initially a maximum of n tracks
280// All variables initialised to default values
c72198f1 281 if (n<=0)
282 {
283 cout << " *** This AliVertex initialisation was invoked via the AliEvent ctor." << endl;
284 }
d16062ac 285 fRun=0;
286 fEvent=0;
4575fcea 287 fAproj=0;
288 fZproj=0;
289 fPnucProj=0;
da17f667 290 fIdProj=0;
4575fcea 291 fAtarg=0;
292 fZtarg=0;
293 fPnucTarg=0;
da17f667 294 fIdTarg=0;
1c01b4f8 295 fDevices=0;
296 fDevCopy=0;
7a086578 297 fHits=0;
965bd237 298 fOrdered=0;
299 fDisplay=0;
27e6d856 300 fDevs=0;
d16062ac 301}
302///////////////////////////////////////////////////////////////////////////
303AliEvent::~AliEvent()
304{
305// Default destructor
1c01b4f8 306 if (fDevices)
7849a8ab 307 {
1c01b4f8 308 delete fDevices;
309 fDevices=0;
7849a8ab 310 }
7a086578 311 if (fHits)
312 {
313 delete fHits;
314 fHits=0;
315 }
965bd237 316 if (fOrdered)
317 {
318 delete fOrdered;
319 fOrdered=0;
320 }
321 if (fDisplay)
322 {
323 delete fDisplay;
324 fDisplay=0;
325 }
27e6d856 326 if (fDevs)
327 {
328 delete fDevs;
329 fDevs=0;
330 }
d16062ac 331}
332///////////////////////////////////////////////////////////////////////////
3ea81e9c 333AliEvent::AliEvent(const AliEvent& evt) : AliVertex(evt),AliTimestamp(evt)
c72198f1 334{
335// Copy constructor.
c72198f1 336 fRun=evt.fRun;
337 fEvent=evt.fEvent;
338 fAproj=evt.fAproj;
339 fZproj=evt.fZproj;
340 fPnucProj=evt.fPnucProj;
341 fIdProj=evt.fIdProj;
342 fAtarg=evt.fAtarg;
343 fZtarg=evt.fZtarg;
344 fPnucTarg=evt.fPnucTarg;
345 fIdTarg=evt.fIdTarg;
1c01b4f8 346 fDevCopy=evt.fDevCopy;
c72198f1 347
965bd237 348 fHits=0;
349 fOrdered=0;
350 fDisplay=0;
27e6d856 351 fDevs=0;
965bd237 352
1c01b4f8 353 fDevices=0;
354 Int_t ndevs=evt.GetNdevices();
355 if (ndevs)
c72198f1 356 {
1c01b4f8 357 fDevices=new TObjArray(ndevs);
358 if (fDevCopy) fDevices->SetOwner();
359 for (Int_t i=1; i<=ndevs; i++)
c72198f1 360 {
1c01b4f8 361 TObject* dev=evt.GetDevice(i);
362 if (dev)
c72198f1 363 {
1c01b4f8 364 if (fDevCopy)
c72198f1 365 {
1c01b4f8 366 fDevices->Add(dev->Clone());
c72198f1 367 }
368 else
369 {
1c01b4f8 370 fDevices->Add(dev);
c72198f1 371 }
372 }
373 }
374 }
375}
376///////////////////////////////////////////////////////////////////////////
d16062ac 377void AliEvent::Reset()
378{
379// Reset all variables to default values
380// The max. number of tracks is set to the initial value again
381// The max. number of vertices is set to the default value again
7b825f44 382// Note : The DevCopy mode is maintained as it was set by the user before.
c72198f1 383
384 AliVertex::Reset();
385
3ea81e9c 386 Set();
d16062ac 387 fRun=0;
388 fEvent=0;
4575fcea 389 fAproj=0;
390 fZproj=0;
391 fPnucProj=0;
da17f667 392 fIdProj=0;
4575fcea 393 fAtarg=0;
394 fZtarg=0;
395 fPnucTarg=0;
da17f667 396 fIdTarg=0;
d16062ac 397
1c01b4f8 398 if (fDevices)
7849a8ab 399 {
1c01b4f8 400 delete fDevices;
401 fDevices=0;
7849a8ab 402 }
7a086578 403 if (fHits)
404 {
405 delete fHits;
406 fHits=0;
407 }
965bd237 408 if (fOrdered)
409 {
410 delete fOrdered;
411 fOrdered=0;
412 }
413 if (fDisplay)
414 {
415 delete fDisplay;
416 fDisplay=0;
417 }
27e6d856 418 if (fDevs)
419 {
420 delete fDevs;
421 fDevs=0;
422 }
d16062ac 423}
424///////////////////////////////////////////////////////////////////////////
8e8e6c7f 425void AliEvent::SetOwner(Bool_t own)
426{
427// Set ownership of all added objects.
428// The default parameter is own=kTRUE.
429//
430// Invokation of this memberfunction also sets all the copy modes
431// (e.g. TrackCopy & co.) according to the value of own.
432//
433// This function (with own=kTRUE) is particularly useful when reading data
434// from a tree/file, since Reset() will then actually remove all the
435// added objects from memory irrespective of the copy mode settings
436// during the tree/file creation process. In this way it provides a nice way
437// of preventing possible memory leaks in the reading/analysis process.
438//
439// In addition this memberfunction can also be used as a shortcut to set all
440// copy modes in one go during a tree/file creation process.
441// However, in this case the user has to take care to only set/change the
442// ownership (and copy mode) for empty objects (e.g. newly created objects
443// or after invokation of the Reset() memberfunction) otherwise it will
444// very likely result in inconsistent destructor behaviour.
445
446 Int_t mode=1;
447 if (!own) mode=0;
1c01b4f8 448 if (fDevices) fDevices->SetOwner(own);
449 fDevCopy=mode;
8e8e6c7f 450
451 AliVertex::SetOwner(own);
452}
453///////////////////////////////////////////////////////////////////////////
387a745b 454void AliEvent::SetDayTime(TTimeStamp& stamp)
d16062ac 455{
387a745b 456// Set the date and time stamp for this event.
457// An exact copy of the entered date/time stamp will be saved with an
47dddbe4 458// accuracy of 1 nanosecond.
3ea81e9c 459//
460// Note : Since the introduction of the more versatile class AliTimestamp
461// and the fact that AliEvent has now been derived from it,
462// this memberfunction has become obsolete.
463// It is recommended to use the corresponding AliTimestamp
464// functionality directly for AliEvent instances.
465// This memberfunction is only kept for backward compatibility.
466
467 Set(stamp.GetDate(),stamp.GetTime(),0,kTRUE,0);
d16062ac 468}
469///////////////////////////////////////////////////////////////////////////
387a745b 470void AliEvent::SetDayTime(TDatime& stamp)
471{
472// Set the date and time stamp for this event.
473// The entered date/time will be interpreted as being the local date/time
474// and the accuracy is 1 second.
3ea81e9c 475//
387a745b 476// This function with the TDatime argument is mainly kept for backward
3ea81e9c 477// compatibility reasons.
478// It is recommended to use the corresponding AliTimestamp functionality
479// directly for AliEvent instances.
387a745b 480
3ea81e9c 481 Set(stamp.GetDate(),stamp.GetTime(),0,kFALSE,0);
387a745b 482}
483///////////////////////////////////////////////////////////////////////////
d16062ac 484void AliEvent::SetRunNumber(Int_t run)
485{
486// Set the run number for this event
487 fRun=run;
488}
489///////////////////////////////////////////////////////////////////////////
490void AliEvent::SetEventNumber(Int_t evt)
491{
492// Set the event number for this event
493 fEvent=evt;
494}
495///////////////////////////////////////////////////////////////////////////
261c0caf 496TTimeStamp AliEvent::GetDayTime() const
d16062ac 497{
498// Provide the date and time stamp for this event
3ea81e9c 499//
500// Note : Since the introduction of the more versatile class AliTimestamp
501// and the fact that AliEvent has now been derived from it,
502// this memberfunction has become obsolete.
503// It is recommended to use the corresponding AliTimestamp
504// functionality directly for AliEvent instances.
505// This memberfunction is only kept for backward compatibility.
506
507 return (TTimeStamp)(*this);
d16062ac 508}
509///////////////////////////////////////////////////////////////////////////
261c0caf 510Int_t AliEvent::GetRunNumber() const
d16062ac 511{
512// Provide the run number for this event
513 return fRun;
514}
515///////////////////////////////////////////////////////////////////////////
261c0caf 516Int_t AliEvent::GetEventNumber() const
d16062ac 517{
518// Provide the event number for this event
519 return fEvent;
520}
521///////////////////////////////////////////////////////////////////////////
da17f667 522void AliEvent::SetProjectile(Int_t a,Int_t z,Double_t pnuc,Int_t id)
4575fcea 523{
da17f667 524// Set the projectile A, Z, momentum per nucleon and user defined particle ID.
525// By default the particle ID is set to zero.
4575fcea 526 fAproj=a;
527 fZproj=z;
528 fPnucProj=pnuc;
da17f667 529 fIdProj=id;
4575fcea 530}
531///////////////////////////////////////////////////////////////////////////
261c0caf 532Int_t AliEvent::GetProjectileA() const
4575fcea 533{
534// Provide the projectile A value.
535 return fAproj;
536}
537///////////////////////////////////////////////////////////////////////////
261c0caf 538Int_t AliEvent::GetProjectileZ() const
4575fcea 539{
540// Provide the projectile Z value.
541 return fZproj;
542}
543///////////////////////////////////////////////////////////////////////////
261c0caf 544Double_t AliEvent::GetProjectilePnuc() const
4575fcea 545{
546// Provide the projectile momentum value per nucleon.
547 return fPnucProj;
548}
549///////////////////////////////////////////////////////////////////////////
261c0caf 550Int_t AliEvent::GetProjectileId() const
4575fcea 551{
da17f667 552// Provide the user defined particle ID of the projectile.
553 return fIdProj;
554}
555///////////////////////////////////////////////////////////////////////////
556void AliEvent::SetTarget(Int_t a,Int_t z,Double_t pnuc,Int_t id)
557{
558// Set the target A, Z, momentum per nucleon and user defined particle ID.
559// By default the particle ID is set to zero.
4575fcea 560 fAtarg=a;
561 fZtarg=z;
562 fPnucTarg=pnuc;
da17f667 563 fIdTarg=id;
4575fcea 564}
565///////////////////////////////////////////////////////////////////////////
261c0caf 566Int_t AliEvent::GetTargetA() const
4575fcea 567{
568// Provide the target A value.
569 return fAtarg;
570}
571///////////////////////////////////////////////////////////////////////////
261c0caf 572Int_t AliEvent::GetTargetZ() const
4575fcea 573{
574// Provide the target Z value.
575 return fZtarg;
576}
577///////////////////////////////////////////////////////////////////////////
261c0caf 578Double_t AliEvent::GetTargetPnuc() const
4575fcea 579{
580// Provide the target momentum value per nucleon.
581 return fPnucTarg;
582}
583///////////////////////////////////////////////////////////////////////////
261c0caf 584Int_t AliEvent::GetTargetId() const
da17f667 585{
586// Provide the user defined particle ID of the target.
587 return fIdTarg;
588}
589///////////////////////////////////////////////////////////////////////////
3ea81e9c 590void AliEvent::HeaderData()
d16062ac 591{
592// Provide event header information
47dddbe4 593 const char* name=GetName();
594 const char* title=GetTitle();
47dddbe4 595 cout << " *" << ClassName() << "::Data*";
596 if (strlen(name)) cout << " Name : " << GetName();
597 if (strlen(title)) cout << " Title : " << GetTitle();
598 cout << endl;
3ea81e9c 599 Date(1);
ea0b5b7f 600 cout << " Run : " << fRun << " Event : " << fEvent << endl;
601 ShowDevices(0);
602 ShowTracks(0);
d16062ac 603}
604///////////////////////////////////////////////////////////////////////////
84bb7c66 605void AliEvent::Data(TString f)
d16062ac 606{
607// Provide event information within the coordinate frame f
84bb7c66 608 HeaderData();
609 AliVertex::Data(f);
d16062ac 610}
611///////////////////////////////////////////////////////////////////////////
261c0caf 612Int_t AliEvent::GetNdevices() const
7849a8ab 613{
1c01b4f8 614// Provide the number of stored devices
615 Int_t ndevs=0;
616 if (fDevices) ndevs=fDevices->GetEntries();
617 return ndevs;
7849a8ab 618}
619///////////////////////////////////////////////////////////////////////////
1c01b4f8 620void AliEvent::AddDevice(TObject& d)
7849a8ab 621{
1c01b4f8 622// Add a device to the event.
623//
624// Note :
625// In case a private copy is made, this is performed via the Clone() memberfunction.
626// All devices (i.e. classes derived from TObject) have the default TObject::Clone()
627// memberfunction.
628// However, devices generally contain an internal (signal) data structure
629// which may include pointers to other objects. Therefore it is recommended to provide
630// for all devices a specific copy constructor and override the default Clone()
631// memberfunction using this copy constructor.
632// An example for this may be seen from AliCalorimeter.
633
634 if (!fDevices)
6516b62d 635 {
1c01b4f8 636 fDevices=new TObjArray();
637 if (fDevCopy) fDevices->SetOwner();
6516b62d 638 }
7849a8ab 639
1c01b4f8 640 // Add the device to this event
641 if (fDevCopy)
7849a8ab 642 {
1c01b4f8 643 fDevices->Add(d.Clone());
7849a8ab 644 }
645 else
646 {
1c01b4f8 647 fDevices->Add(&d);
7849a8ab 648 }
649}
650///////////////////////////////////////////////////////////////////////////
1c01b4f8 651void AliEvent::SetDevCopy(Int_t j)
7849a8ab 652{
1c01b4f8 653// (De)activate the creation of private copies of the added devices.
654// j=0 ==> No private copies are made; pointers of original devices are stored.
655// j=1 ==> Private copies of the devices are made and these pointers are stored.
656//
657//
658// Notes :
659// In case a private copy is made, this is performed via the Clone() memberfunction.
660// All devices (i.e. classes derived from TObject) have the default TObject::Clone()
661// memberfunction.
662// However, devices generally contain an internal (signal) data structure
663// which may include pointers to other objects. Therefore it is recommended to provide
664// for all devices a specific copy constructor and override the default Clone()
665// memberfunction using this copy constructor.
666// An example for this may be seen from AliCalorimeter.
667//
668// Once the storage contains pointer(s) to device(s) one cannot
669// change the DevCopy mode anymore.
670// To change the DevCopy mode for an existing AliEvent containing
671// devices one first has to invoke Reset().
672
673 if (!fDevices)
7849a8ab 674 {
675 if (j==0 || j==1)
676 {
1c01b4f8 677 fDevCopy=j;
7849a8ab 678 }
679 else
680 {
1c01b4f8 681 cout << " *" << ClassName() << "::SetDevCopy* Invalid argument : " << j << endl;
7849a8ab 682 }
683 }
684 else
685 {
1c01b4f8 686 cout << " *" << ClassName() << "::SetDevCopy* Storage already contained devices."
687 << " ==> DevCopy mode not changed." << endl;
7849a8ab 688 }
689}
690///////////////////////////////////////////////////////////////////////////
261c0caf 691Int_t AliEvent::GetDevCopy() const
7849a8ab 692{
1c01b4f8 693// Provide value of the DevCopy mode.
694// 0 ==> No private copies are made; pointers of original devices are stored.
695// 1 ==> Private copies of the devices are made and these pointers are stored.
696//
697// Note :
698// In case a private copy is made, this is performed via the Clone() memberfunction.
699// All devices (i.e. classes derived from TObject) have the default TObject::Clone()
700// memberfunction.
701// However, devices generally contain an internal (signal) data structure
702// which may include pointers to other objects. Therefore it is recommended to provide
703// for all devices a specific copy constructor and override the default Clone()
704// memberfunction using this copy constructor.
705// An example for this may be seen from AliCalorimeter.
706
707 return fDevCopy;
7849a8ab 708}
709///////////////////////////////////////////////////////////////////////////
261c0caf 710TObject* AliEvent::GetDevice(Int_t i) const
7849a8ab 711{
1c01b4f8 712// Return the i-th device of this event.
713// The first device corresponds to i=1.
714
715 if (!fDevices)
7849a8ab 716 {
7849a8ab 717 return 0;
718 }
719 else
720 {
1c01b4f8 721 Int_t ndevs=GetNdevices();
722 if (i<=0 || i>ndevs)
7849a8ab 723 {
1c01b4f8 724 cout << " *" << ClassName() << "::GetDevice* Invalid argument i : " << i
725 << " ndevs = " << ndevs << endl;
7849a8ab 726 return 0;
727 }
728 else
729 {
1c01b4f8 730 return fDevices->At(i-1);
7849a8ab 731 }
732 }
733}
734///////////////////////////////////////////////////////////////////////////
261c0caf 735TObject* AliEvent::GetDevice(TString name) const
7849a8ab 736{
1c01b4f8 737// Return the device with name tag "name"
738 if (!fDevices)
7849a8ab 739 {
7849a8ab 740 return 0;
741 }
742 else
743 {
7849a8ab 744 TString s;
1c01b4f8 745 Int_t ndevs=GetNdevices();
746 for (Int_t i=0; i<ndevs; i++)
7849a8ab 747 {
1c01b4f8 748 TObject* dev=fDevices->At(i);
749 if (dev)
35044448 750 {
1c01b4f8 751 s=dev->GetName();
752 if (s == name) return dev;
35044448 753 }
7849a8ab 754 }
755
756 return 0; // No matching name found
757 }
758}
759///////////////////////////////////////////////////////////////////////////
4f368c8c 760TObject* AliEvent::GetIdDevice(Int_t id) const
761{
762// Return the device with unique identifier "id".
763 if (!fDevices || id<0) return 0;
764
765 Int_t idx=0;
766 for (Int_t i=0; i<GetNdevices(); i++)
767 {
768 TObject* dev=fDevices->At(i);
769 if (dev)
770 {
771 idx=dev->GetUniqueID();
772 if (idx==id) return dev;
773 }
774 }
775 return 0; // No matching id found
776}
777///////////////////////////////////////////////////////////////////////////
ea0b5b7f 778void AliEvent::ShowDevices(Int_t mode) const
1ce8a857 779{
1c01b4f8 780// Provide an overview of the available devices.
ea0b5b7f 781// The argument mode determines the amount of information as follows :
782// mode = 0 ==> Only printout of the number of devices
783// 1 ==> Provide a listing with 1 line of info for each device
784//
785// The default is mode=1.
786//
1c01b4f8 787 Int_t ndevs=GetNdevices();
788 if (ndevs)
1ce8a857 789 {
ea0b5b7f 790 if (!mode)
1ce8a857 791 {
ea0b5b7f 792 cout << " There are " << ndevs << " devices available." << endl;
793 }
794 else
795 {
796 cout << " The following " << ndevs << " devices are available :" << endl;
797 for (Int_t i=1; i<=ndevs; i++)
1c01b4f8 798 {
ea0b5b7f 799 TObject* dev=GetDevice(i);
800 if (dev)
801 {
802 const char* name=dev->GetName();
803 cout << " Device number : " << i;
804 cout << " Class : " << dev->ClassName() << " Id : " << dev->GetUniqueID();
805 if (strlen(name)) cout << " Name : " << name;
806 if (dev->InheritsFrom("AliDevice")) cout << " Nhits : " << ((AliDevice*)dev)->GetNhits();
807 if (dev->InheritsFrom("AliSignal")) cout << " Nwaveforms : " << ((AliSignal*)dev)->GetNwaveforms();
808 cout << endl;
809 }
1c01b4f8 810 }
1ce8a857 811 }
812 }
813 else
814 {
1c01b4f8 815 cout << " No devices present for this event." << endl;
1ce8a857 816 }
817}
818///////////////////////////////////////////////////////////////////////////
27e6d856 819TObjArray* AliEvent::GetDevices(const char* classname)
820{
821// Provide the references to the various devices derived from the
822// specified class.
823 if (fDevs) fDevs->Clear();
824
825 Int_t ndev=GetNdevices();
826 for (Int_t idev=1; idev<=ndev; idev++)
827 {
828 TObject* obj=GetDevice(idev);
829 if (!obj) continue;
830
831 if (obj->InheritsFrom(classname))
832 {
833 if (!fDevs) fDevs=new TObjArray();
834 fDevs->Add(obj);
835 }
836 }
837 return fDevs;
838}
839///////////////////////////////////////////////////////////////////////////
7a086578 840Int_t AliEvent::GetNhits(const char* classname)
841{
842// Provide the number of hits registered to the specified device class.
843// The specified device class has to be derived from AliDevice.
844// It is possible to indicate with the argument "classname" a specific
845// device instead of a whole class of devices. However, in such a case
846// it is more efficient to use the GetDevice() memberfunction directly.
847 LoadHits(classname);
848 Int_t nhits=0;
849 if (fHits) nhits=fHits->GetEntries();
850 return nhits;
851}
852///////////////////////////////////////////////////////////////////////////
853TObjArray* AliEvent::GetHits(const char* classname)
854{
855// Provide the references to all the hits registered to the specified
856// device class.
857// The specified device class has to be derived from AliDevice.
858// It is possible to indicate with the argument "classname" a specific
859// device instead of a whole class of devices. However, in such a case
860// it is more efficient to use the GetDevice() memberfunction directly.
861 LoadHits(classname);
862 return fHits;
863}
864///////////////////////////////////////////////////////////////////////////
4f368c8c 865AliSignal* AliEvent::GetIdHit(Int_t id,const char* classname)
866{
867// Return the hit with unique identifier "id" for the specified device class.
868 if (id<0) return 0;
869
870 Int_t nhits=GetNhits(classname);
871 if (!nhits) return 0;
872
873 AliSignal* sx=0;
874 Int_t sid=0;
875 for (Int_t i=0; i<nhits; i++)
876 {
877 sx=(AliSignal*)fHits->At(i);
878 if (sx)
879 {
880 sid=sx->GetUniqueID();
881 if (id==sid) return sx;
882 }
883 }
884 return 0; // No matching id found
885}
886///////////////////////////////////////////////////////////////////////////
7a086578 887void AliEvent::LoadHits(const char* classname)
888{
889// Load the references to the various hits registered to the specified
890// device class.
891// The specified device class has to be derived from AliDevice.
892 if (fHits) fHits->Clear();
893
894 Int_t ndev=GetNdevices();
895 for (Int_t idev=1; idev<=ndev; idev++)
896 {
897 TObject* obj=GetDevice(idev);
898 if (!obj) continue;
899
900 if (obj->InheritsFrom(classname) && obj->InheritsFrom("AliDevice"))
901 {
902 AliDevice* dev=(AliDevice*)GetDevice(idev);
903 Int_t nhits=dev->GetNhits();
904 if (nhits)
905 {
906 if (!fHits) fHits=new TObjArray();
907 for (Int_t ih=1; ih<=nhits; ih++)
908 {
909 AliSignal* sx=dev->GetHit(ih);
910 if (sx) fHits->Add(sx);
911 }
912 }
913 }
914 }
915}
916///////////////////////////////////////////////////////////////////////////
27e6d856 917TObjArray* AliEvent::SortHits(const char* classname,Int_t idx,Int_t mode,Int_t mcal)
7a086578 918{
965bd237 919// Order the references to the various hits registered to the specified
920// device class. The ordered array is returned as a TObjArray.
7a086578 921// A "hit" represents an abstract object which is derived from AliSignal.
922// The user can specify the index of the signal slot to perform the sorting on.
923// By default the slotindex will be 1.
924// Via the "mode" argument the user can specify ordering in decreasing
925// order (mode=-1) or ordering in increasing order (mode=1).
926// The default is mode=-1.
927// Signals which were declared as "Dead" will be rejected.
27e6d856 928// The gain etc... corrected signals will be used in the ordering process as
929// specified by the "mcal" argument. The definition of this "mcal" parameter
930// corresponds to the signal correction mode described in the GetSignal
931// memberfunction of class AliSignal.
932// The default is mcal=1 (for backward compatibility reasons).
965bd237 933//
934// For more extended functionality see class AliDevice.
935
936 if (idx<=0 || abs(mode)!=1) return 0;
937
938 LoadHits(classname);
939
940 AliDevice dev;
27e6d856 941 TObjArray* ordered=dev.SortHits(idx,mode,fHits,mcal);
7b825f44 942
943 if (fHits)
7a086578 944 {
7b825f44 945 delete fHits;
946 fHits=0;
947 }
7b825f44 948 if (ordered) fHits=new TObjArray(*ordered);
949 return fHits;
7a086578 950}
951///////////////////////////////////////////////////////////////////////////
27e6d856 952TObjArray* AliEvent::SortHits(const char* classname,TString name,Int_t mode,Int_t mcal)
7a086578 953{
965bd237 954// Order the references to the various hits registered to the specified
955// device class. The ordered array is returned as a TObjArray.
7a086578 956// A "hit" represents an abstract object which is derived from AliSignal.
957// The user can specify the name of the signal slot to perform the sorting on.
958// In case no matching slotname is found, the signal will be skipped.
959// Via the "mode" argument the user can specify ordering in decreasing
960// order (mode=-1) or ordering in increasing order (mode=1).
961// The default is mode=-1.
962// Signals which were declared as "Dead" will be rejected.
27e6d856 963// The gain etc... corrected signals will be used in the ordering process as
964// specified by the "mcal" argument. The definition of this "mcal" parameter
965// corresponds to the signal correction mode described in the GetSignal
966// memberfunction of class AliSignal.
967// The default is mcal=1 (for backward compatibility reasons).
965bd237 968//
969// For more extended functionality see class AliDevice.
970
971 if (abs(mode)!=1) return 0;
972
973 LoadHits(classname);
974
975 AliDevice dev;
27e6d856 976 TObjArray* ordered=dev.SortHits(name,mode,fHits,mcal);
7b825f44 977
978 if (fHits)
7a086578 979 {
7b825f44 980 delete fHits;
981 fHits=0;
982 }
965bd237 983 if (ordered) fHits=new TObjArray(*ordered);
984 return fHits;
985}
986///////////////////////////////////////////////////////////////////////////
27e6d856 987void AliEvent::GetExtremes(const char* classname,Float_t& vmin,Float_t& vmax,Int_t idx,Int_t mode)
965bd237 988{
989// Provide the min. and max. signal values of the various hits registered
990// to the specified device class.
991// The input argument "idx" denotes the index of the signal slots to be investigated.
992// The default is idx=1;
993// Signals which were declared as "Dead" will be rejected.
27e6d856 994// The gain etc... corrected signals will be used in the process as specified
995// by the "mode" argument. The definition of this "mode" parameter corresponds to
996// the description provided in the GetSignal memberfunction of class AliSignal.
997// The default is mode=1 (for backward compatibility reasons).
965bd237 998//
999// For more extended functionality see class AliDevice.
1000
1001 if (idx<=0) return;
1002
1003 LoadHits(classname);
1004
1005 AliDevice dev;
27e6d856 1006 dev.GetExtremes(vmin,vmax,idx,fHits,mode);
965bd237 1007}
1008///////////////////////////////////////////////////////////////////////////
27e6d856 1009void AliEvent::GetExtremes(const char* classname,Float_t& vmin,Float_t& vmax,TString name,Int_t mode)
965bd237 1010{
1011// Provide the min. and max. signal values of the various hits registered
1012// to the specified device class.
1013// The input argument "name" denotes the name of the signal slots to be investigated.
1014// Signals which were declared as "Dead" will be rejected.
27e6d856 1015// The gain etc... corrected signals will be used in the process as specified
1016// by the "mode" argument. The definition of this "mode" parameter corresponds to
1017// the description provided in the GetSignal memberfunction of class AliSignal.
1018// The default is mode=1 (for backward compatibility reasons).
965bd237 1019//
1020// For more extended functionality see class AliDevice.
1021
1022 LoadHits(classname);
1023
1024 AliDevice dev;
27e6d856 1025 dev.GetExtremes(vmin,vmax,name,fHits,mode);
965bd237 1026}
1027///////////////////////////////////////////////////////////////////////////
27e6d856 1028void AliEvent::DisplayHits(const char* classname,Int_t idx,Float_t scale,Int_t dp,Int_t mode,Int_t mcol)
965bd237 1029{
1030// 3D color display of the various hits registered to the specified device class.
1031// The user can specify the index (default=1) of the signal slot to perform the display for.
1032// The marker size will indicate the absolute value of the signal (specified by the slotindex)
1033// as a percentage of the input argument "scale".
1034// In case scale<0 the maximum absolute signal value encountered in the hit array will be used
1035// to define the 100% scale. The default is scale=-1.
1036// In case dp=1 the owning device position will be used, otherwise the hit position will
1037// be used in the display. The default is dp=0.
27e6d856 1038// Via the "mcol" argument the user can specify the marker color (see TPolyMarker3D).
1039// The default is mcol=blue.
965bd237 1040// Signals which were declared as "Dead" will not be displayed.
1041// The gain etc... corrected signals will be used to determine the marker size.
27e6d856 1042// The gain correction is performed according to "mode" argument. The definition of this
1043// "mode" parameter corresponds to the description provided in the GetSignal
1044// memberfunction of class AliSignal.
1045// The default is mode=1 (for backward compatibility reasons).
965bd237 1046//
1047// For more extended functionality see class AliDevice.
1048//
1049// Note :
1050// ------
1051// Before any display activity, a TCanvas and a TView have to be initiated
1052// first by the user like for instance
1053//
1054// TCanvas* c1=new TCanvas("c1","c1");
1055// TView* view=new TView(1);
1056// view->SetRange(-1000,-1000,-1000,1000,1000,1000);
1057// view->ShowAxis();
1058
1059 if (idx<=0) return;
1060
1061 LoadHits(classname);
1062
1063 AliDevice* dev=new AliDevice();
27e6d856 1064 dev->DisplayHits(idx,scale,fHits,dp,mode,mcol);
965bd237 1065
1066 if (fDisplay)
1067 {
1068 delete fDisplay;
1069 fDisplay=0;
1070 }
1071 fDisplay=dev;
1072}
1073///////////////////////////////////////////////////////////////////////////
27e6d856 1074void AliEvent::DisplayHits(const char* classname,TString name,Float_t scale,Int_t dp,Int_t mode,Int_t mcol)
965bd237 1075{
1076// 3D color display of the various hits registered to the specified device class.
1077// The user can specify the name of the signal slot to perform the display for.
1078// The marker size will indicate the absolute value of the signal (specified by the slotname)
1079// as a percentage of the input argument "scale".
1080// In case scale<0 the maximum absolute signal value encountered in the hit array will be used
1081// to define the 100% scale. The default is scale=-1.
1082// In case dp=1 the owning device position will be used, otherwise the hit position will
1083// be used in the display. The default is dp=0.
1084// The marker size will indicate the percentage of the maximum encountered value
1085// of the absolute value of the name-specified input signal slots.
27e6d856 1086// Via the "mcol" argument the user can specify the marker color (see TPolyMarker3D).
1087// The default is mcol=blue.
965bd237 1088// Signals which were declared as "Dead" will not be displayed.
1089// The gain etc... corrected signals will be used to determine the marker size.
27e6d856 1090// The gain correction is performed according to "mode" argument. The definition of this
1091// "mode" parameter corresponds to the description provided in the GetSignal
1092// memberfunction of class AliSignal.
1093// The default is mode=1 (for backward compatibility reasons).
965bd237 1094//
1095// For more extended functionality see class AliDevice.
1096//
1097// Note :
1098// ------
1099// Before any display activity, a TCanvas and a TView have to be initiated
1100// first by the user like for instance
1101//
1102// TCanvas* c1=new TCanvas("c1","c1");
1103// TView* view=new TView(1);
1104// view->SetRange(-1000,-1000,-1000,1000,1000,1000);
1105// view->ShowAxis();
1106
1107 LoadHits(classname);
1108
1109 AliDevice* dev=new AliDevice();
27e6d856 1110 dev->DisplayHits(name,scale,fHits,dp,mode,mcol);
965bd237 1111
1112 if (fDisplay)
1113 {
1114 delete fDisplay;
1115 fDisplay=0;
1116 }
1117 fDisplay=dev;
1118}
1119///////////////////////////////////////////////////////////////////////////
27e6d856 1120TObjArray* AliEvent::SortDevices(const char* classname,TString name,Int_t mode,Int_t mcal)
965bd237 1121{
1122// Order the references to the various devices based on hit signals registered
1123// to the specified device class. The ordered array is returned as a TObjArray.
1124// A "hit" represents an abstract object which is derived from AliSignal.
1125// The user can specify the name of the signal slot to perform the sorting on.
1126// In case no matching slotname is found, the signal will be skipped.
1127// Via the "mode" argument the user can specify ordering in decreasing
1128// order (mode=-1) or ordering in increasing order (mode=1).
1129// The default is mode=-1.
1130// Signals which were declared as "Dead" will be rejected.
27e6d856 1131// The gain etc... corrected signals will be used in the ordering process as
1132// specified by the "mcal" argument. The definition of this "mcal" parameter
1133// corresponds to the signal correction mode described in the GetSignal
1134// memberfunction of class AliSignal.
1135// The default is mcal=1 (for backward compatibility reasons).
965bd237 1136//
1137
27e6d856 1138 TObjArray* ordered=SortHits(classname,name,mode,mcal);
965bd237 1139
1140 if (!ordered) return 0;
1141
27e6d856 1142 TObjArray* devs=SortDevices(ordered,"*",0,mcal);
965bd237 1143 return devs;
1144}
1145///////////////////////////////////////////////////////////////////////////
27e6d856 1146TObjArray* AliEvent::SortDevices(const char* classname,Int_t idx,Int_t mode,Int_t mcal)
965bd237 1147{
1148// Order the references to the various devices based on hit signals registered
1149// to the specified device class. The ordered array is returned as a TObjArray.
1150// A "hit" represents an abstract object which is derived from AliSignal.
1151// The user can specify the index of the signal slot to perform the sorting on.
1152// By default the slotindex will be 1.
1153// Via the "mode" argument the user can specify ordering in decreasing
1154// order (mode=-1) or ordering in increasing order (mode=1).
1155// The default is mode=-1.
1156// Signals which were declared as "Dead" will be rejected.
27e6d856 1157// The gain etc... corrected signals will be used in the ordering process as
1158// specified by the "mcal" argument. The definition of this "mcal" parameter
1159// corresponds to the signal correction mode described in the GetSignal
1160// memberfunction of class AliSignal.
1161// The default is mcal=1 (for backward compatibility reasons).
965bd237 1162//
1163
27e6d856 1164 TObjArray* ordered=SortHits(classname,idx,mode,mcal);
7b825f44 1165
965bd237 1166 if (!ordered) return 0;
7b825f44 1167
27e6d856 1168 TObjArray* devs=SortDevices(ordered,0,0,mcal);
965bd237 1169 return devs;
1170}
1171///////////////////////////////////////////////////////////////////////////
27e6d856 1172TObjArray* AliEvent::SortDevices(TObjArray* hits,TString name,Int_t mode,Int_t mcal)
965bd237 1173{
1174// Order the references to the various devices based on hit signals contained
1175// in the input array. The ordered array is returned as a TObjArray.
1176// A "hit" represents an abstract object which is derived from AliSignal.
1177// The user can specify the name of the signal slot to perform the sorting on.
1178// In case no matching slotname is found, the signal will be skipped.
1179// Via the "mode" argument the user can specify ordering in decreasing
1180// order (mode=-1), ordering in increasing order (mode=1) or no ordering (mode=0).
1181// The latter option provides a means to quickly obtain an ordered devices list
1182// when the hits in the array were already ordered by the user. In this case
1183// the input argument "name" is irrelevant.
1184// The default is mode=-1.
1185// Signals which were declared as "Dead" will be rejected.
27e6d856 1186// The gain etc... corrected signals will be used in the ordering process as
1187// specified by the "mcal" argument. The definition of this "mcal" parameter
1188// corresponds to the signal correction mode described in the GetSignal
1189// memberfunction of class AliSignal.
1190// The default is mcal=1 (for backward compatibility reasons).
965bd237 1191//
1192
1193 if (!hits) return 0;
1194
1195 TObjArray* ordered=hits;
7b825f44 1196 AliDevice dev;
27e6d856 1197 if (mode) ordered=dev.SortHits(name,mode,hits,mcal);
965bd237 1198
1199 if (!ordered) return 0;
1200
1201 if (fOrdered)
1202 {
1203 fOrdered->Clear();
1204 }
1205 else
1206 {
1207 fOrdered=new TObjArray();
1208 }
1209
1210 Int_t nhits=ordered->GetEntries();
1211 Int_t exist=0;
1212 for (Int_t ih=0; ih<nhits; ih++)
1213 {
1214 AliSignal* sx=(AliSignal*)ordered->At(ih);
1215 if (!sx) continue;
1216 AliDevice* dx=sx->GetDevice();
1217 exist=0;
1218 for (Int_t id=0; id<fOrdered->GetEntries(); id++)
1219 {
1220 AliDevice* odx=(AliDevice*)fOrdered->At(id);
1221 if (dx==odx)
1222 {
1223 exist=1;
1224 break;
1225 }
1226 }
1227 if (!exist) fOrdered->Add(dx);
1228 }
1229 return fOrdered;
1230}
1231///////////////////////////////////////////////////////////////////////////
27e6d856 1232TObjArray* AliEvent::SortDevices(TObjArray* hits,Int_t idx,Int_t mode,Int_t mcal)
965bd237 1233{
1234// Order the references to the various devices based on hit signals contained
1235// in the input array. The ordered array is returned as a TObjArray.
1236// A "hit" represents an abstract object which is derived from AliSignal.
1237// The user can specify the index of the signal slot to perform the sorting on.
1238// By default the slotindex will be 1.
1239// Via the "mode" argument the user can specify ordering in decreasing
1240// order (mode=-1), ordering in increasing order (mode=1) or no ordering (mode=0).
1241// The latter option provides a means to quickly obtain an ordered devices list
1242// when the hits in the array were already ordered by the user. In this case
1243// the input argument "idx" is irrelevant.
1244// The default is mode=-1.
1245// Signals which were declared as "Dead" will be rejected.
27e6d856 1246// The gain etc... corrected signals will be used in the ordering process as
1247// specified by the "mcal" argument. The definition of this "mcal" parameter
1248// corresponds to the signal correction mode described in the GetSignal
1249// memberfunction of class AliSignal.
1250// The default is mcal=1 (for backward compatibility reasons).
965bd237 1251//
1252
1253 if (!hits) return 0;
1254
1255 TObjArray* ordered=hits;
1256 AliDevice dev;
27e6d856 1257 if (mode) ordered=dev.SortHits(idx,mode,hits,mcal);
965bd237 1258
1259 if (!ordered) return 0;
1260
1261 if (fOrdered)
1262 {
1263 fOrdered->Clear();
1264 }
1265 else
1266 {
1267 fOrdered=new TObjArray();
1268 }
1269
1270 Int_t nhits=ordered->GetEntries();
1271 Int_t exist=0;
1272 for (Int_t ih=0; ih<nhits; ih++)
1273 {
1274 AliSignal* sx=(AliSignal*)ordered->At(ih);
1275 if (!sx) continue;
1276 AliDevice* dx=sx->GetDevice();
1277 exist=0;
1278 for (Int_t id=0; id<fOrdered->GetEntries(); id++)
1279 {
1280 AliDevice* odx=(AliDevice*)fOrdered->At(id);
1281 if (dx==odx)
1282 {
1283 exist=1;
1284 break;
1285 }
1286 }
1287 if (!exist) fOrdered->Add(dx);
1288 }
1289 return fOrdered;
7a086578 1290}
1291///////////////////////////////////////////////////////////////////////////
261c0caf 1292TObject* AliEvent::Clone(const char* name) const
5f25234b 1293{
1294// Make a deep copy of the current object and provide the pointer to the copy.
1295// This memberfunction enables automatic creation of new objects of the
1296// correct type depending on the object type, a feature which may be very useful
1297// for containers when adding objects in case the container owns the objects.
1298// This feature allows to store either AliEvent objects or objects derived from
1299// AliEvent via some generic AddEvent memberfunction, provided these derived
1300// classes also have a proper Clone memberfunction.
1301
1302 AliEvent* evt=new AliEvent(*this);
1303 if (name)
1304 {
1305 if (strlen(name)) evt->SetName(name);
1306 }
1307 return evt;
1308}
1309///////////////////////////////////////////////////////////////////////////
d16062ac 1310