Access to the number of associated clusters (M.Ivanov)
[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
4bb13277 16// $Id: AliEvent.cxx,v 1.18 2004/01/12 08:23:22 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
1c01b4f8 22// and/or devices like AliCalorimeters.
23// All objects which are derived from TObject can be regarded as a device.
d16062ac 24//
25// The basic functionality of AliEvent is identical to the one of AliVertex.
35044448 26// So, an AliEvent may be used as the primary vertex with some additional
27// functionality compared to AliVertex.
d16062ac 28//
7849a8ab 29// To provide maximal flexibility to the user, the two modes of track/jet/vertex
30// storage as described in AliJet and AliVertex can be used.
1c01b4f8 31// In addition an identical structure is provided for the storage of devices like
32// AliCalorimeter objects, which can be selected by means of the memberfunction
33// SetDevCopy().
34//
35// a) SetDevCopy(0) (which is the default).
36// Only the pointers of the 'added' devices are stored.
37// This mode is typically used by making studies based on a fixed set
38// of devices which stays under user control or is kept on an external
7849a8ab 39// file/tree.
40// In this way the AliEvent just represents a 'logical structure' for the
41// physics analysis.
35044448 42//
43// Note :
1c01b4f8 44// Modifications made to the original devices also affect the device
7849a8ab 45// objects which are stored in the AliEvent.
35044448 46//
1c01b4f8 47// b) SetDevCopy(1).
48// Of every 'added' device a private copy will be made of which the pointer
7849a8ab 49// will be stored.
50// In this way the AliEvent represents an entity on its own and modifications
51// made to the original calorimeters do not affect the AliCalorimeter objects
52// which are stored in the AliEvent.
1c01b4f8 53// This mode will allow 'adding' many different devices into an AliEvent by
54// creating only one device instance in the main programme and using the
55// Reset() and parameter setting memberfunctions of the object representing the device.
56//
57// Note :
58// The copy is made using the Clone() memberfunction.
59// All devices (i.e. classes derived from TObject) have the default TObject::Clone()
60// memberfunction.
61// However, devices generally contain an internal (signal) data structure
62// which may include pointers to other objects. Therefore it is recommended to provide
63// for all devices a specific copy constructor and override the default Clone()
64// memberfunction using this copy constructor.
65// An example for this may be seen from AliCalorimeter.
7849a8ab 66//
8e8e6c7f 67// See also the documentation provided for the memberfunction SetOwner().
68//
7849a8ab 69// Coding example to make an event consisting of a primary vertex,
70// 2 secondary vertices and a calorimeter.
d16062ac 71// --------------------------------------------------------------
7849a8ab 72// vp contains the tracks 1,2,3 and 4 (primary vertex)
73// v1 contains the tracks 5,6 and 7 (sec. vertex)
74// v2 contains the jets 1 and 2 (sec. vertex)
75//
7849a8ab 76// AliEvent evt;
77//
78// Specify the event object as the repository of all objects
79// for the event building and physics analysis.
80//
1c01b4f8 81// evt.SetDevCopy(1);
7849a8ab 82// evt.SetTrackCopy(1);
83//
84// Fill the event structure with the basic objects
85//
35044448 86// AliCalorimeter emcal;
87// ...
88// ... // code to fill the calorimeter data
89// ...
90//
1c01b4f8 91// evt.AddDevice(emcal);
7849a8ab 92//
35044448 93// AliTrack* tx=new AliTrack();
7849a8ab 94// for (Int_t i=0; i<10; i++)
95// {
d16062ac 96// ...
97// ... // code to fill the track data
98// ...
7849a8ab 99// evt.AddTrack(tx);
100// tx->Reset();
101// }
102//
35044448 103// if (tx)
104// {
105// delete tx;
106// tx=0;
107// }
108//
7849a8ab 109// Build the event structure (vertices, jets, ...) for physics analysis
110// based on the basic objects from the event repository.
d16062ac 111//
112// AliJet j1,j2;
7849a8ab 113// for (Int_t i=0; i<evt.GetNtracks(); i++)
114// {
115// tx=evt.GetTrack(i);
d16062ac 116// ...
117// ... // code to fill the jet data
118// ...
7849a8ab 119// }
d16062ac 120//
7849a8ab 121// AliVertex vp;
35044448 122// tx=evt.GetTrack(1);
7849a8ab 123// vp.AddTrack(tx);
35044448 124// tx=evt.GetTrack(2);
7849a8ab 125// vp.AddTrack(tx);
35044448 126// tx=evt.GetTrack(3);
7849a8ab 127// vp.AddTrack(tx);
35044448 128// tx=evt.GetTrack(4);
7849a8ab 129// vp.AddTrack(tx);
d16062ac 130//
7849a8ab 131// Float_t rp[3]={2.4,0.1,-8.5};
132// vp.SetPosition(rp,"car");
d16062ac 133//
7849a8ab 134// AliVertex v1;
35044448 135// tx=evt.GetTrack(5);
7849a8ab 136// v1.AddTrack(tx);
35044448 137// tx=evt.GetTrack(6);
7849a8ab 138// v1.AddTrack(tx);
35044448 139// tx=evt.GetTrack(7);
7849a8ab 140// v1.AddTrack(tx);
d16062ac 141//
142// Float_t r1[3]={1.6,-3.2,5.7};
143// v1.SetPosition(r1,"car");
144//
d16062ac 145//
7849a8ab 146// AliVertex v2;
147// v2.SetJetCopy(1);
d16062ac 148// v2.AddJet(j1);
149// v2.AddJet(j2);
150//
151// Float_t r2[3]={6.2,4.8,1.3};
152// v2.SetPosition(r2,"car");
153//
7849a8ab 154// Specify the vertices v1 and v2 as secondary vertices of the primary
155//
156// vp.SetVertexCopy(1);
157// vp.AddVertex(v1);
158// vp.AddVertex(v2);
159//
160// Enter the physics structures into the event
161// evt.SetVertexCopy(1);
162// evt.AddVertex(vp,0);
163//
164// The jets j1 and j2 are already available via sec. vertex v2,
165// but can be made available also from the event itself if desired.
166// AliJet* jx;
167// jx=v2.GetJet(1);
168// evt.AddJet(jx,0);
169// jx=v2.GetJet(2);
170// evt.AddJet(jx,0);
171//
84bb7c66 172// evt.Data("sph");
d16062ac 173// v1.ListAll();
174// v2.List("cyl");
175//
176// Float_t etot=evt.GetEnergy();
177// Ali3Vector ptot=evt.Get3Momentum();
178// Float_t loc[3];
179// evt.GetPosition(loc,"sph");
180// AliPosition r=v1.GetPosition();
84bb7c66 181// r.Data();
d16062ac 182// Int_t nt=v2.GetNtracks();
183// AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
184//
d16062ac 185// evt.List();
186//
187// Int_t nv=evt.GetNvtx();
7849a8ab 188// AliVertex* vx=evt.GetVertex(1); // Access primary vertex
d16062ac 189// Float_t e=vx->GetEnergy();
190//
191// Float_t M=evt.GetInvmass();
192//
193// Reconstruct the event from scratch
194//
195// evt.Reset();
196// evt.SetNvmax(25); // Increase initial no. of sec. vertices
7849a8ab 197// ...
198// ... // code to create tracks etc...
199// ...
d16062ac 200//
201// Note : All quantities are in GeV, GeV/c or GeV/c**2
202//
203//--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
4bb13277 204//- Modified: NvE $Date: 2004/01/12 08:23:22 $ UU-SAP Utrecht
d16062ac 205///////////////////////////////////////////////////////////////////////////
206
207#include "AliEvent.h"
c72198f1 208#include "Riostream.h"
d16062ac 209
210ClassImp(AliEvent) // Class implementation to enable ROOT I/O
211
c72198f1 212AliEvent::AliEvent() : AliVertex()
d16062ac 213{
214// Default constructor.
215// All variables initialised to default values.
4bb13277 216 fDaytime.Set();
d16062ac 217 fRun=0;
218 fEvent=0;
4575fcea 219 fAproj=0;
220 fZproj=0;
221 fPnucProj=0;
da17f667 222 fIdProj=0;
4575fcea 223 fAtarg=0;
224 fZtarg=0;
225 fPnucTarg=0;
da17f667 226 fIdTarg=0;
1c01b4f8 227 fDevices=0;
228 fDevCopy=0;
d16062ac 229}
230///////////////////////////////////////////////////////////////////////////
c72198f1 231AliEvent::AliEvent(Int_t n) : AliVertex(n)
d16062ac 232{
233// Create an event to hold initially a maximum of n tracks
234// All variables initialised to default values
c72198f1 235 if (n<=0)
236 {
237 cout << " *** This AliVertex initialisation was invoked via the AliEvent ctor." << endl;
238 }
4bb13277 239 fDaytime.Set();
d16062ac 240 fRun=0;
241 fEvent=0;
4575fcea 242 fAproj=0;
243 fZproj=0;
244 fPnucProj=0;
da17f667 245 fIdProj=0;
4575fcea 246 fAtarg=0;
247 fZtarg=0;
248 fPnucTarg=0;
da17f667 249 fIdTarg=0;
1c01b4f8 250 fDevices=0;
251 fDevCopy=0;
d16062ac 252}
253///////////////////////////////////////////////////////////////////////////
254AliEvent::~AliEvent()
255{
256// Default destructor
1c01b4f8 257 if (fDevices)
7849a8ab 258 {
1c01b4f8 259 delete fDevices;
260 fDevices=0;
7849a8ab 261 }
d16062ac 262}
263///////////////////////////////////////////////////////////////////////////
c72198f1 264AliEvent::AliEvent(AliEvent& evt) : AliVertex(evt)
265{
266// Copy constructor.
267 fDaytime=evt.fDaytime;
268 fRun=evt.fRun;
269 fEvent=evt.fEvent;
270 fAproj=evt.fAproj;
271 fZproj=evt.fZproj;
272 fPnucProj=evt.fPnucProj;
273 fIdProj=evt.fIdProj;
274 fAtarg=evt.fAtarg;
275 fZtarg=evt.fZtarg;
276 fPnucTarg=evt.fPnucTarg;
277 fIdTarg=evt.fIdTarg;
1c01b4f8 278 fDevCopy=evt.fDevCopy;
c72198f1 279
1c01b4f8 280 fDevices=0;
281 Int_t ndevs=evt.GetNdevices();
282 if (ndevs)
c72198f1 283 {
1c01b4f8 284 fDevices=new TObjArray(ndevs);
285 if (fDevCopy) fDevices->SetOwner();
286 for (Int_t i=1; i<=ndevs; i++)
c72198f1 287 {
1c01b4f8 288 TObject* dev=evt.GetDevice(i);
289 if (dev)
c72198f1 290 {
1c01b4f8 291 if (fDevCopy)
c72198f1 292 {
1c01b4f8 293 fDevices->Add(dev->Clone());
c72198f1 294 }
295 else
296 {
1c01b4f8 297 fDevices->Add(dev);
c72198f1 298 }
299 }
300 }
301 }
302}
303///////////////////////////////////////////////////////////////////////////
d16062ac 304void AliEvent::Reset()
305{
306// Reset all variables to default values
307// The max. number of tracks is set to the initial value again
308// The max. number of vertices is set to the default value again
8e8e6c7f 309// Note : The CalCopy mode is maintained as it was set by the user before.
c72198f1 310
311 AliVertex::Reset();
312
4bb13277 313 fDaytime.Set();
d16062ac 314 fRun=0;
315 fEvent=0;
4575fcea 316 fAproj=0;
317 fZproj=0;
318 fPnucProj=0;
da17f667 319 fIdProj=0;
4575fcea 320 fAtarg=0;
321 fZtarg=0;
322 fPnucTarg=0;
da17f667 323 fIdTarg=0;
d16062ac 324
1c01b4f8 325 if (fDevices)
7849a8ab 326 {
1c01b4f8 327 delete fDevices;
328 fDevices=0;
7849a8ab 329 }
d16062ac 330}
331///////////////////////////////////////////////////////////////////////////
8e8e6c7f 332void AliEvent::SetOwner(Bool_t own)
333{
334// Set ownership of all added objects.
335// The default parameter is own=kTRUE.
336//
337// Invokation of this memberfunction also sets all the copy modes
338// (e.g. TrackCopy & co.) according to the value of own.
339//
340// This function (with own=kTRUE) is particularly useful when reading data
341// from a tree/file, since Reset() will then actually remove all the
342// added objects from memory irrespective of the copy mode settings
343// during the tree/file creation process. In this way it provides a nice way
344// of preventing possible memory leaks in the reading/analysis process.
345//
346// In addition this memberfunction can also be used as a shortcut to set all
347// copy modes in one go during a tree/file creation process.
348// However, in this case the user has to take care to only set/change the
349// ownership (and copy mode) for empty objects (e.g. newly created objects
350// or after invokation of the Reset() memberfunction) otherwise it will
351// very likely result in inconsistent destructor behaviour.
352
353 Int_t mode=1;
354 if (!own) mode=0;
1c01b4f8 355 if (fDevices) fDevices->SetOwner(own);
356 fDevCopy=mode;
8e8e6c7f 357
358 AliVertex::SetOwner(own);
359}
360///////////////////////////////////////////////////////////////////////////
387a745b 361void AliEvent::SetDayTime(TTimeStamp& stamp)
d16062ac 362{
387a745b 363// Set the date and time stamp for this event.
364// An exact copy of the entered date/time stamp will be saved with an
47dddbe4 365// accuracy of 1 nanosecond.
d16062ac 366 fDaytime=stamp;
367}
368///////////////////////////////////////////////////////////////////////////
387a745b 369void AliEvent::SetDayTime(TDatime& stamp)
370{
371// Set the date and time stamp for this event.
372// The entered date/time will be interpreted as being the local date/time
373// and the accuracy is 1 second.
374// This function with the TDatime argument is mainly kept for backward
375// compatibility reasons. It is recommended to use the corresponding
376// function with the TTimeStamp argument.
377
4bb13277 378 fDaytime.Set(stamp.GetDate(),stamp.GetTime(),0,kFALSE,0);
387a745b 379}
380///////////////////////////////////////////////////////////////////////////
d16062ac 381void AliEvent::SetRunNumber(Int_t run)
382{
383// Set the run number for this event
384 fRun=run;
385}
386///////////////////////////////////////////////////////////////////////////
387void AliEvent::SetEventNumber(Int_t evt)
388{
389// Set the event number for this event
390 fEvent=evt;
391}
392///////////////////////////////////////////////////////////////////////////
387a745b 393TTimeStamp AliEvent::GetDayTime()
d16062ac 394{
395// Provide the date and time stamp for this event
396 return fDaytime;
397}
398///////////////////////////////////////////////////////////////////////////
399Int_t AliEvent::GetRunNumber()
400{
401// Provide the run number for this event
402 return fRun;
403}
404///////////////////////////////////////////////////////////////////////////
405Int_t AliEvent::GetEventNumber()
406{
407// Provide the event number for this event
408 return fEvent;
409}
410///////////////////////////////////////////////////////////////////////////
da17f667 411void AliEvent::SetProjectile(Int_t a,Int_t z,Double_t pnuc,Int_t id)
4575fcea 412{
da17f667 413// Set the projectile A, Z, momentum per nucleon and user defined particle ID.
414// By default the particle ID is set to zero.
4575fcea 415 fAproj=a;
416 fZproj=z;
417 fPnucProj=pnuc;
da17f667 418 fIdProj=id;
4575fcea 419}
420///////////////////////////////////////////////////////////////////////////
421Int_t AliEvent::GetProjectileA()
422{
423// Provide the projectile A value.
424 return fAproj;
425}
426///////////////////////////////////////////////////////////////////////////
427Int_t AliEvent::GetProjectileZ()
428{
429// Provide the projectile Z value.
430 return fZproj;
431}
432///////////////////////////////////////////////////////////////////////////
433Double_t AliEvent::GetProjectilePnuc()
434{
435// Provide the projectile momentum value per nucleon.
436 return fPnucProj;
437}
438///////////////////////////////////////////////////////////////////////////
da17f667 439Int_t AliEvent::GetProjectileId()
4575fcea 440{
da17f667 441// Provide the user defined particle ID of the projectile.
442 return fIdProj;
443}
444///////////////////////////////////////////////////////////////////////////
445void AliEvent::SetTarget(Int_t a,Int_t z,Double_t pnuc,Int_t id)
446{
447// Set the target A, Z, momentum per nucleon and user defined particle ID.
448// By default the particle ID is set to zero.
4575fcea 449 fAtarg=a;
450 fZtarg=z;
451 fPnucTarg=pnuc;
da17f667 452 fIdTarg=id;
4575fcea 453}
454///////////////////////////////////////////////////////////////////////////
455Int_t AliEvent::GetTargetA()
456{
457// Provide the target A value.
458 return fAtarg;
459}
460///////////////////////////////////////////////////////////////////////////
461Int_t AliEvent::GetTargetZ()
462{
463// Provide the target Z value.
464 return fZtarg;
465}
466///////////////////////////////////////////////////////////////////////////
467Double_t AliEvent::GetTargetPnuc()
468{
469// Provide the target momentum value per nucleon.
470 return fPnucTarg;
471}
472///////////////////////////////////////////////////////////////////////////
da17f667 473Int_t AliEvent::GetTargetId()
474{
475// Provide the user defined particle ID of the target.
476 return fIdTarg;
477}
478///////////////////////////////////////////////////////////////////////////
84bb7c66 479void AliEvent::HeaderData()
d16062ac 480{
481// Provide event header information
47dddbe4 482 const char* name=GetName();
483 const char* title=GetTitle();
484 Int_t ndevs=GetNdevices();
485 cout << " *" << ClassName() << "::Data*";
486 if (strlen(name)) cout << " Name : " << GetName();
487 if (strlen(title)) cout << " Title : " << GetTitle();
488 cout << endl;
387a745b 489 cout << " " << fDaytime.AsString() << endl;
47dddbe4 490 cout << " Run : " << fRun << " Event : " << fEvent
491 << " Number of devices : " << ndevs << endl;
d16062ac 492
47dddbe4 493 if (ndevs) ShowDevices();
d16062ac 494}
495///////////////////////////////////////////////////////////////////////////
84bb7c66 496void AliEvent::Data(TString f)
d16062ac 497{
498// Provide event information within the coordinate frame f
84bb7c66 499 HeaderData();
500 AliVertex::Data(f);
d16062ac 501}
502///////////////////////////////////////////////////////////////////////////
1c01b4f8 503Int_t AliEvent::GetNdevices()
7849a8ab 504{
1c01b4f8 505// Provide the number of stored devices
506 Int_t ndevs=0;
507 if (fDevices) ndevs=fDevices->GetEntries();
508 return ndevs;
7849a8ab 509}
510///////////////////////////////////////////////////////////////////////////
1c01b4f8 511void AliEvent::AddDevice(TObject& d)
7849a8ab 512{
1c01b4f8 513// Add a device to the event.
514//
515// Note :
516// In case a private copy is made, this is performed via the Clone() memberfunction.
517// All devices (i.e. classes derived from TObject) have the default TObject::Clone()
518// memberfunction.
519// However, devices generally contain an internal (signal) data structure
520// which may include pointers to other objects. Therefore it is recommended to provide
521// for all devices a specific copy constructor and override the default Clone()
522// memberfunction using this copy constructor.
523// An example for this may be seen from AliCalorimeter.
524
525 if (!fDevices)
6516b62d 526 {
1c01b4f8 527 fDevices=new TObjArray();
528 if (fDevCopy) fDevices->SetOwner();
6516b62d 529 }
7849a8ab 530
1c01b4f8 531 // Add the device to this event
532 if (fDevCopy)
7849a8ab 533 {
1c01b4f8 534 fDevices->Add(d.Clone());
7849a8ab 535 }
536 else
537 {
1c01b4f8 538 fDevices->Add(&d);
7849a8ab 539 }
540}
541///////////////////////////////////////////////////////////////////////////
1c01b4f8 542void AliEvent::SetDevCopy(Int_t j)
7849a8ab 543{
1c01b4f8 544// (De)activate the creation of private copies of the added devices.
545// j=0 ==> No private copies are made; pointers of original devices are stored.
546// j=1 ==> Private copies of the devices are made and these pointers are stored.
547//
548//
549// Notes :
550// In case a private copy is made, this is performed via the Clone() memberfunction.
551// All devices (i.e. classes derived from TObject) have the default TObject::Clone()
552// memberfunction.
553// However, devices generally contain an internal (signal) data structure
554// which may include pointers to other objects. Therefore it is recommended to provide
555// for all devices a specific copy constructor and override the default Clone()
556// memberfunction using this copy constructor.
557// An example for this may be seen from AliCalorimeter.
558//
559// Once the storage contains pointer(s) to device(s) one cannot
560// change the DevCopy mode anymore.
561// To change the DevCopy mode for an existing AliEvent containing
562// devices one first has to invoke Reset().
563
564 if (!fDevices)
7849a8ab 565 {
566 if (j==0 || j==1)
567 {
1c01b4f8 568 fDevCopy=j;
7849a8ab 569 }
570 else
571 {
1c01b4f8 572 cout << " *" << ClassName() << "::SetDevCopy* Invalid argument : " << j << endl;
7849a8ab 573 }
574 }
575 else
576 {
1c01b4f8 577 cout << " *" << ClassName() << "::SetDevCopy* Storage already contained devices."
578 << " ==> DevCopy mode not changed." << endl;
7849a8ab 579 }
580}
581///////////////////////////////////////////////////////////////////////////
1c01b4f8 582Int_t AliEvent::GetDevCopy()
7849a8ab 583{
1c01b4f8 584// Provide value of the DevCopy mode.
585// 0 ==> No private copies are made; pointers of original devices are stored.
586// 1 ==> Private copies of the devices are made and these pointers are stored.
587//
588// Note :
589// In case a private copy is made, this is performed via the Clone() memberfunction.
590// All devices (i.e. classes derived from TObject) have the default TObject::Clone()
591// memberfunction.
592// However, devices generally contain an internal (signal) data structure
593// which may include pointers to other objects. Therefore it is recommended to provide
594// for all devices a specific copy constructor and override the default Clone()
595// memberfunction using this copy constructor.
596// An example for this may be seen from AliCalorimeter.
597
598 return fDevCopy;
7849a8ab 599}
600///////////////////////////////////////////////////////////////////////////
1c01b4f8 601TObject* AliEvent::GetDevice(Int_t i)
7849a8ab 602{
1c01b4f8 603// Return the i-th device of this event.
604// The first device corresponds to i=1.
605
606 if (!fDevices)
7849a8ab 607 {
7849a8ab 608 return 0;
609 }
610 else
611 {
1c01b4f8 612 Int_t ndevs=GetNdevices();
613 if (i<=0 || i>ndevs)
7849a8ab 614 {
1c01b4f8 615 cout << " *" << ClassName() << "::GetDevice* Invalid argument i : " << i
616 << " ndevs = " << ndevs << endl;
7849a8ab 617 return 0;
618 }
619 else
620 {
1c01b4f8 621 return fDevices->At(i-1);
7849a8ab 622 }
623 }
624}
625///////////////////////////////////////////////////////////////////////////
1c01b4f8 626TObject* AliEvent::GetDevice(TString name)
7849a8ab 627{
1c01b4f8 628// Return the device with name tag "name"
629 if (!fDevices)
7849a8ab 630 {
7849a8ab 631 return 0;
632 }
633 else
634 {
7849a8ab 635 TString s;
1c01b4f8 636 Int_t ndevs=GetNdevices();
637 for (Int_t i=0; i<ndevs; i++)
7849a8ab 638 {
1c01b4f8 639 TObject* dev=fDevices->At(i);
640 if (dev)
35044448 641 {
1c01b4f8 642 s=dev->GetName();
643 if (s == name) return dev;
35044448 644 }
7849a8ab 645 }
646
647 return 0; // No matching name found
648 }
649}
650///////////////////////////////////////////////////////////////////////////
1c01b4f8 651void AliEvent::ShowDevices()
1ce8a857 652{
1c01b4f8 653// Provide an overview of the available devices.
654 Int_t ndevs=GetNdevices();
655 if (ndevs)
1ce8a857 656 {
1c01b4f8 657 cout << " The following " << ndevs << " devices are available :" << endl;
658 for (Int_t i=1; i<=ndevs; i++)
1ce8a857 659 {
1c01b4f8 660 TObject* dev=GetDevice(i);
661 if (dev)
662 {
663 cout << " Device number : " << i
664 << " Class : " << dev->ClassName()
665 << " Name : " << dev->GetName() << endl;
666 }
1ce8a857 667 }
668 }
669 else
670 {
1c01b4f8 671 cout << " No devices present for this event." << endl;
1ce8a857 672 }
673}
674///////////////////////////////////////////////////////////////////////////
8e8eae84 675TObject* AliEvent::Clone(const char* name)
5f25234b 676{
677// Make a deep copy of the current object and provide the pointer to the copy.
678// This memberfunction enables automatic creation of new objects of the
679// correct type depending on the object type, a feature which may be very useful
680// for containers when adding objects in case the container owns the objects.
681// This feature allows to store either AliEvent objects or objects derived from
682// AliEvent via some generic AddEvent memberfunction, provided these derived
683// classes also have a proper Clone memberfunction.
684
685 AliEvent* evt=new AliEvent(*this);
686 if (name)
687 {
688 if (strlen(name)) evt->SetName(name);
689 }
690 return evt;
691}
692///////////////////////////////////////////////////////////////////////////
d16062ac 693