1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // $Id: AliEvent.cxx,v 1.25 2004/10/20 10:49:44 nick Exp $
18 ///////////////////////////////////////////////////////////////////////////
20 // Creation and investigation of an Alice physics event.
21 // An AliEvent can be constructed by adding AliTracks, Alivertices, AliJets
22 // and/or devices like AliCalorimeters or AliDevice (derived) objects.
24 // All objects which are derived from TObject can be regarded as a device.
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.
32 // The basic functionality of AliEvent is identical to the one of AliVertex.
33 // So, an AliEvent may be used as the primary vertex with some additional
34 // functionality compared to AliVertex.
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.
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
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
47 // In this way the AliEvent just represents a 'logical structure' for the
51 // Modifications made to the original devices also affect the device
52 // objects which are stored in the AliEvent.
55 // Of every 'added' device a private copy will be made of which the pointer
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.
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.
65 // The copy is made using the Clone() memberfunction.
66 // All devices (i.e. classes derived from TObject) have the default TObject::Clone()
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.
72 // Examples for this may be seen from AliCalorimeter, AliSignal and AliDevice.
74 // See also the documentation provided for the memberfunction SetOwner().
76 // Coding example to make an event consisting of a primary vertex,
77 // 2 secondary vertices and a calorimeter.
78 // --------------------------------------------------------------
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)
85 // Specify the event object as the repository of all objects
86 // for the event building and physics analysis.
89 // evt.SetTrackCopy(1);
91 // Fill the event structure with the basic objects
93 // AliCalorimeter emcal1;
94 // AliCalorimeter emcal2;
96 // ... // code to fill the emcal1 and emcal2 calorimeter data
99 // evt.AddDevice(emcal1);
100 // evt.AddDevice(emcal2);
102 // // Assume AliTOF has been derived from AliDevice
106 // ... // code to fill the tof1 and tof2 data
109 // evt.AddDevice(tof1);
110 // evt.AddDevice(tof2);
112 // AliTrack* tx=new AliTrack();
113 // for (Int_t i=0; i<10; i++)
116 // ... // code to fill the track data
128 // Order and investigate all the hits of all the TOF devices
130 // TObjArray* hits=evt.GetHits("AliTOF");
131 // TObjArray* orderedtofs=evt.SortHits(hits);
133 // if (orderedtofs) nhits=orderedtofs->GetEntries();
134 // for (Int_t i=0; i<nhits; i++)
136 // AliSignal* sx=(AliSignal*)orderedtofs->At(i);
137 // if (sx) sx->Data();
140 // Order and investigate all the hits of all the calorimeter devices
142 // TObjArray* hits=evt.GetHits("AliCalorimeter");
143 // TObjArray* orderedcals=evt.SortHits(hits);
145 // if (orderedcals) nhits=orderedcals->GetEntries();
146 // for (Int_t i=0; i<nhits; i++)
148 // AliSignal* sx=(AliSignal*)orderedcals->At(i);
149 // if (sx) sx->Data();
152 // Build the event structure (vertices, jets, ...) for physics analysis
153 // based on the basic objects from the event repository.
156 // for (Int_t i=0; i<evt.GetNtracks(); i++)
158 // tx=evt.GetTrack(i);
160 // ... // code to fill the jet data
165 // tx=evt.GetTrack(1);
167 // tx=evt.GetTrack(2);
169 // tx=evt.GetTrack(3);
171 // tx=evt.GetTrack(4);
174 // Float_t rp[3]={2.4,0.1,-8.5};
175 // vp.SetPosition(rp,"car");
178 // tx=evt.GetTrack(5);
180 // tx=evt.GetTrack(6);
182 // tx=evt.GetTrack(7);
185 // Float_t r1[3]={1.6,-3.2,5.7};
186 // v1.SetPosition(r1,"car");
194 // Float_t r2[3]={6.2,4.8,1.3};
195 // v2.SetPosition(r2,"car");
197 // Specify the vertices v1 and v2 as secondary vertices of the primary
199 // vp.SetVertexCopy(1);
203 // Enter the physics structures into the event
204 // evt.SetVertexCopy(1);
205 // evt.AddVertex(vp,0);
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.
219 // Float_t etot=evt.GetEnergy();
220 // Ali3Vector ptot=evt.Get3Momentum();
222 // evt.GetPosition(loc,"sph");
223 // AliPosition r=v1.GetPosition();
225 // Int_t nt=v2.GetNtracks();
226 // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
230 // Int_t nv=evt.GetNvtx();
231 // AliVertex* vx=evt.GetVertex(1); // Access primary vertex
232 // Float_t e=vx->GetEnergy();
234 // Float_t M=evt.GetInvmass();
236 // Reconstruct the event from scratch
239 // evt.SetNvmax(25); // Increase initial no. of sec. vertices
241 // ... // code to create tracks etc...
244 // Note : By default all quantities are in meter, GeV, GeV/c or GeV/c**2
245 // but the user can indicate the usage of a different scale for
246 // the metric and/or energy-momentum units via the SetUnitScale()
247 // and SetEscale() memberfunctions, respectively.
248 // The actual metric and energy-momentum unit scales in use can be
249 // obtained via the GetUnitScale() and GetEscale() memberfunctions.
251 //--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
252 //- Modified: NvE $Date: 2004/10/20 10:49:44 $ UU-SAP Utrecht
253 ///////////////////////////////////////////////////////////////////////////
255 #include "AliEvent.h"
256 #include "Riostream.h"
258 ClassImp(AliEvent) // Class implementation to enable ROOT I/O
260 AliEvent::AliEvent() : AliVertex(),AliTimestamp()
262 // Default constructor.
263 // All variables initialised to default values.
273 ///////////////////////////////////////////////////////////////////////////
274 AliEvent::AliEvent(Int_t n) : AliVertex(n),AliTimestamp()
276 // Create an event to hold initially a maximum of n tracks
277 // All variables initialised to default values
280 cout << " *** This AliVertex initialisation was invoked via the AliEvent ctor." << endl;
291 ///////////////////////////////////////////////////////////////////////////
292 AliEvent::~AliEvent()
294 // Default destructor
321 ///////////////////////////////////////////////////////////////////////////
322 AliEvent::AliEvent(const AliEvent& evt) : AliVertex(evt),AliTimestamp(evt)
327 fDevCopy=evt.fDevCopy;
335 Int_t ndevs=evt.GetNdevices();
338 fDevices=new TObjArray(ndevs);
339 if (fDevCopy) fDevices->SetOwner();
340 for (Int_t i=1; i<=ndevs; i++)
342 TObject* dev=evt.GetDevice(i);
347 fDevices->Add(dev->Clone());
357 ///////////////////////////////////////////////////////////////////////////
358 void AliEvent::Reset()
360 // Reset all variables to default values
361 // The max. number of tracks is set to the initial value again
362 // The max. number of vertices is set to the default value again
363 // Note : The DevCopy mode is maintained as it was set by the user before.
397 ///////////////////////////////////////////////////////////////////////////
398 void AliEvent::SetOwner(Bool_t own)
400 // Set ownership of all added objects.
401 // The default parameter is own=kTRUE.
403 // Invokation of this memberfunction also sets all the copy modes
404 // (e.g. TrackCopy & co.) according to the value of own.
406 // This function (with own=kTRUE) is particularly useful when reading data
407 // from a tree/file, since Reset() will then actually remove all the
408 // added objects from memory irrespective of the copy mode settings
409 // during the tree/file creation process. In this way it provides a nice way
410 // of preventing possible memory leaks in the reading/analysis process.
412 // In addition this memberfunction can also be used as a shortcut to set all
413 // copy modes in one go during a tree/file creation process.
414 // However, in this case the user has to take care to only set/change the
415 // ownership (and copy mode) for empty objects (e.g. newly created objects
416 // or after invokation of the Reset() memberfunction) otherwise it will
417 // very likely result in inconsistent destructor behaviour.
421 if (fDevices) fDevices->SetOwner(own);
424 AliVertex::SetOwner(own);
426 ///////////////////////////////////////////////////////////////////////////
427 void AliEvent::SetDayTime(TTimeStamp& stamp)
429 // Set the date and time stamp for this event.
430 // An exact copy of the entered date/time stamp will be saved with an
431 // accuracy of 1 nanosecond.
433 // Note : Since the introduction of the more versatile class AliTimestamp
434 // and the fact that AliEvent has now been derived from it,
435 // this memberfunction has become obsolete.
436 // It is recommended to use the corresponding AliTimestamp
437 // functionality directly for AliEvent instances.
438 // This memberfunction is only kept for backward compatibility.
440 Set(stamp.GetDate(),stamp.GetTime(),0,kTRUE,0);
442 ///////////////////////////////////////////////////////////////////////////
443 void AliEvent::SetDayTime(TDatime& stamp)
445 // Set the date and time stamp for this event.
446 // The entered date/time will be interpreted as being the local date/time
447 // and the accuracy is 1 second.
449 // This function with the TDatime argument is mainly kept for backward
450 // compatibility reasons.
451 // It is recommended to use the corresponding AliTimestamp functionality
452 // directly for AliEvent instances.
454 Set(stamp.GetDate(),stamp.GetTime(),0,kFALSE,0);
456 ///////////////////////////////////////////////////////////////////////////
457 void AliEvent::SetRunNumber(Int_t run)
459 // Set the run number for this event
462 ///////////////////////////////////////////////////////////////////////////
463 void AliEvent::SetEventNumber(Int_t evt)
465 // Set the event number for this event
468 ///////////////////////////////////////////////////////////////////////////
469 TTimeStamp AliEvent::GetDayTime() const
471 // Provide the date and time stamp for this event
473 // Note : Since the introduction of the more versatile class AliTimestamp
474 // and the fact that AliEvent has now been derived from it,
475 // this memberfunction has become obsolete.
476 // It is recommended to use the corresponding AliTimestamp
477 // functionality directly for AliEvent instances.
478 // This memberfunction is only kept for backward compatibility.
480 return (TTimeStamp)(*this);
482 ///////////////////////////////////////////////////////////////////////////
483 Int_t AliEvent::GetRunNumber() const
485 // Provide the run number for this event
488 ///////////////////////////////////////////////////////////////////////////
489 Int_t AliEvent::GetEventNumber() const
491 // Provide the event number for this event
494 ///////////////////////////////////////////////////////////////////////////
495 void AliEvent::SetProjectile(Int_t a,Int_t z,Double_t pnuc,Int_t id)
497 // Set the projectile A, Z, momentum per nucleon and user defined particle ID.
498 // If not explicitly specified by the user, the projectile particle ID is set
499 // to zero by default and will not be stored in the event structure.
500 // The projectile specifications will be stored in a device named "Beam"
501 // which is an instance of AliSignal.
502 // As such these data are easily retrievable from the event structure.
503 // However, for backward compatibility reasons the beam data can also be
504 // retrieved via memberfunctions like GetProjectileA() etc...
508 AliSignal* beam=(AliSignal*)GetDevice("Beam");
512 beam=new AliSignal();
513 beam->SetNameTitle("Beam","Beam and target specifications");
519 beam->AddNamedSlot("Aproj");
520 beam->SetSignal(a,"Aproj");
521 beam->AddNamedSlot("Zproj");
522 beam->SetSignal(z,"Zproj");
524 beam->AddNamedSlot("Pnucproj");
525 beam->SetSignal(pnuc,"Pnucproj");
528 beam->AddNamedSlot("Idproj");
529 beam->SetSignal(id,"Idproj");
535 if (fDevCopy) delete beam;
538 ///////////////////////////////////////////////////////////////////////////
539 Int_t AliEvent::GetProjectileA() const
541 // Provide the projectile A value.
543 AliSignal* beam=(AliSignal*)GetDevice("Beam");
544 if (beam) val=int(beam->GetSignal("Aproj"));
547 ///////////////////////////////////////////////////////////////////////////
548 Int_t AliEvent::GetProjectileZ() const
550 // Provide the projectile Z value.
552 AliSignal* beam=(AliSignal*)GetDevice("Beam");
553 if (beam) val=int(beam->GetSignal("Zproj"));
556 ///////////////////////////////////////////////////////////////////////////
557 Double_t AliEvent::GetProjectilePnuc() const
559 // Provide the projectile momentum value per nucleon.
561 AliSignal* beam=(AliSignal*)GetDevice("Beam");
562 if (beam) val=beam->GetSignal("Pnucproj");
565 ///////////////////////////////////////////////////////////////////////////
566 Int_t AliEvent::GetProjectileId() const
568 // Provide the user defined particle ID of the projectile.
570 AliSignal* beam=(AliSignal*)GetDevice("Beam");
571 if (beam) val=int(beam->GetSignal("Idproj"));
574 ///////////////////////////////////////////////////////////////////////////
575 void AliEvent::SetTarget(Int_t a,Int_t z,Double_t pnuc,Int_t id)
577 // Set the target A, Z, momentum per nucleon and user defined particle ID.
578 // If not explicitly specified by the user, the target particle ID is set
579 // to zero by default and will not be stored in the event structure.
580 // The target specifications will be stored in a device named "Beam"
581 // which is an instance of AliSignal.
582 // As such these data are easily retrievable from the event structure.
583 // However, for backward compatibility reasons the beam data can also be
584 // retrieved via memberfunctions like GetTargetA() etc...
588 AliSignal* beam=(AliSignal*)GetDevice("Beam");
592 beam=new AliSignal();
593 beam->SetNameTitle("Beam","Beam and target specifications");
599 beam->AddNamedSlot("Atarg");
600 beam->SetSignal(a,"Atarg");
601 beam->AddNamedSlot("Ztarg");
602 beam->SetSignal(z,"Ztarg");
604 beam->AddNamedSlot("Pnuctarg");
605 beam->SetSignal(pnuc,"Pnuctarg");
608 beam->AddNamedSlot("Idtarg");
609 beam->SetSignal(id,"Idtarg");
615 if (fDevCopy) delete beam;
618 ///////////////////////////////////////////////////////////////////////////
619 Int_t AliEvent::GetTargetA() const
621 // Provide the target A value.
623 AliSignal* beam=(AliSignal*)GetDevice("Beam");
624 if (beam) val=int(beam->GetSignal("Atarg"));
627 ///////////////////////////////////////////////////////////////////////////
628 Int_t AliEvent::GetTargetZ() const
630 // Provide the target Z value.
632 AliSignal* beam=(AliSignal*)GetDevice("Beam");
633 if (beam) val=int(beam->GetSignal("Ztarg"));
636 ///////////////////////////////////////////////////////////////////////////
637 Double_t AliEvent::GetTargetPnuc() const
639 // Provide the target momentum value per nucleon.
641 AliSignal* beam=(AliSignal*)GetDevice("Beam");
642 if (beam) val=beam->GetSignal("Pnuctarg");
645 ///////////////////////////////////////////////////////////////////////////
646 Int_t AliEvent::GetTargetId() const
648 // Provide the user defined particle ID of the target.
650 AliSignal* beam=(AliSignal*)GetDevice("Beam");
651 if (beam) val=int(beam->GetSignal("Idtarg"));
654 ///////////////////////////////////////////////////////////////////////////
655 void AliEvent::HeaderData()
657 // Provide event header information
658 const char* name=GetName();
659 const char* title=GetTitle();
660 cout << " *" << ClassName() << "::Data*";
661 if (strlen(name)) cout << " Name : " << GetName();
662 if (strlen(title)) cout << " Title : " << GetTitle();
665 cout << " Run : " << fRun << " Event : " << fEvent << endl;
669 ///////////////////////////////////////////////////////////////////////////
670 void AliEvent::Data(TString f,TString u)
672 // Provide event information within the coordinate frame f
674 // The string argument "u" allows to choose between different angular units
675 // in case e.g. a spherical frame is selected.
676 // u = "rad" : angles provided in radians
677 // "deg" : angles provided in degrees
679 // The defaults are f="car" and u="rad".
682 AliVertex::Data(f,u);
684 ///////////////////////////////////////////////////////////////////////////
685 Int_t AliEvent::GetNdevices() const
687 // Provide the number of stored devices
689 if (fDevices) ndevs=fDevices->GetEntries();
692 ///////////////////////////////////////////////////////////////////////////
693 void AliEvent::AddDevice(TObject& d)
695 // Add a device to the event.
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()
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.
709 fDevices=new TObjArray();
710 if (fDevCopy) fDevices->SetOwner();
713 // Add the device to this event
716 fDevices->Add(d.Clone());
723 ///////////////////////////////////////////////////////////////////////////
724 void AliEvent::SetDevCopy(Int_t j)
726 // (De)activate the creation of private copies of the added devices.
727 // j=0 ==> No private copies are made; pointers of original devices are stored.
728 // j=1 ==> Private copies of the devices are made and these pointers are stored.
732 // In case a private copy is made, this is performed via the Clone() memberfunction.
733 // All devices (i.e. classes derived from TObject) have the default TObject::Clone()
735 // However, devices generally contain an internal (signal) data structure
736 // which may include pointers to other objects. Therefore it is recommended to provide
737 // for all devices a specific copy constructor and override the default Clone()
738 // memberfunction using this copy constructor.
739 // An example for this may be seen from AliCalorimeter.
741 // Once the storage contains pointer(s) to device(s) one cannot
742 // change the DevCopy mode anymore.
743 // To change the DevCopy mode for an existing AliEvent containing
744 // devices one first has to invoke Reset().
754 cout << " *" << ClassName() << "::SetDevCopy* Invalid argument : " << j << endl;
759 cout << " *" << ClassName() << "::SetDevCopy* Storage already contained devices."
760 << " ==> DevCopy mode not changed." << endl;
763 ///////////////////////////////////////////////////////////////////////////
764 Int_t AliEvent::GetDevCopy() const
766 // Provide value of the DevCopy mode.
767 // 0 ==> No private copies are made; pointers of original devices are stored.
768 // 1 ==> Private copies of the devices are made and these pointers are stored.
771 // In case a private copy is made, this is performed via the Clone() memberfunction.
772 // All devices (i.e. classes derived from TObject) have the default TObject::Clone()
774 // However, devices generally contain an internal (signal) data structure
775 // which may include pointers to other objects. Therefore it is recommended to provide
776 // for all devices a specific copy constructor and override the default Clone()
777 // memberfunction using this copy constructor.
778 // An example for this may be seen from AliCalorimeter.
782 ///////////////////////////////////////////////////////////////////////////
783 TObject* AliEvent::GetDevice(Int_t i) const
785 // Return the i-th device of this event.
786 // The first device corresponds to i=1.
794 Int_t ndevs=GetNdevices();
797 cout << " *" << ClassName() << "::GetDevice* Invalid argument i : " << i
798 << " ndevs = " << ndevs << endl;
803 return fDevices->At(i-1);
807 ///////////////////////////////////////////////////////////////////////////
808 TObject* AliEvent::GetDevice(TString name) const
810 // Return the device with name tag "name"
818 Int_t ndevs=GetNdevices();
819 for (Int_t i=0; i<ndevs; i++)
821 TObject* dev=fDevices->At(i);
825 if (s == name) return dev;
829 return 0; // No matching name found
832 ///////////////////////////////////////////////////////////////////////////
833 TObject* AliEvent::GetIdDevice(Int_t id) const
835 // Return the device with unique identifier "id".
836 if (!fDevices || id<0) return 0;
839 for (Int_t i=0; i<GetNdevices(); i++)
841 TObject* dev=fDevices->At(i);
844 idx=dev->GetUniqueID();
845 if (idx==id) return dev;
848 return 0; // No matching id found
850 ///////////////////////////////////////////////////////////////////////////
851 void AliEvent::ShowDevices(Int_t mode) const
853 // Provide an overview of the available devices.
854 // The argument mode determines the amount of information as follows :
855 // mode = 0 ==> Only printout of the number of devices
856 // 1 ==> Provide a listing with 1 line of info for each device
858 // The default is mode=1.
860 Int_t ndevs=GetNdevices();
865 cout << " There are " << ndevs << " devices available." << endl;
869 cout << " The following " << ndevs << " devices are available :" << endl;
870 for (Int_t i=1; i<=ndevs; i++)
872 TObject* dev=GetDevice(i);
875 const char* name=dev->GetName();
876 cout << " Device number : " << i;
877 cout << " Class : " << dev->ClassName() << " Id : " << dev->GetUniqueID();
878 if (strlen(name)) cout << " Name : " << name;
879 if (dev->InheritsFrom("AliDevice")) cout << " Nhits : " << ((AliDevice*)dev)->GetNhits();
880 if (dev->InheritsFrom("AliSignal")) cout << " Nwaveforms : " << ((AliSignal*)dev)->GetNwaveforms();
888 cout << " No devices present for this event." << endl;
891 ///////////////////////////////////////////////////////////////////////////
892 TObjArray* AliEvent::GetDevices(const char* classname)
894 // Provide the references to the various devices derived from the
896 if (fDevs) fDevs->Clear();
898 Int_t ndev=GetNdevices();
899 for (Int_t idev=1; idev<=ndev; idev++)
901 TObject* obj=GetDevice(idev);
904 if (obj->InheritsFrom(classname))
906 if (!fDevs) fDevs=new TObjArray();
912 ///////////////////////////////////////////////////////////////////////////
913 Int_t AliEvent::GetNhits(const char* classname)
915 // Provide the number of hits registered to the specified device class.
916 // The specified device class has to be derived from AliDevice.
917 // It is possible to indicate with the argument "classname" a specific
918 // device instead of a whole class of devices. However, in such a case
919 // it is more efficient to use the GetDevice() memberfunction directly.
922 if (fHits) nhits=fHits->GetEntries();
925 ///////////////////////////////////////////////////////////////////////////
926 TObjArray* AliEvent::GetHits(const char* classname)
928 // Provide the references to all the hits registered to the specified
930 // The specified device class has to be derived from AliDevice.
931 // It is possible to indicate with the argument "classname" a specific
932 // device instead of a whole class of devices. However, in such a case
933 // it is more efficient to use the GetDevice() memberfunction directly.
937 ///////////////////////////////////////////////////////////////////////////
938 AliSignal* AliEvent::GetIdHit(Int_t id,const char* classname)
940 // Return the hit with unique identifier "id" for the specified device class.
943 Int_t nhits=GetNhits(classname);
944 if (!nhits) return 0;
948 for (Int_t i=0; i<nhits; i++)
950 sx=(AliSignal*)fHits->At(i);
953 sid=sx->GetUniqueID();
954 if (id==sid) return sx;
957 return 0; // No matching id found
959 ///////////////////////////////////////////////////////////////////////////
960 void AliEvent::LoadHits(const char* classname)
962 // Load the references to the various hits registered to the specified
964 // The specified device class has to be derived from AliDevice.
965 if (fHits) fHits->Clear();
967 Int_t ndev=GetNdevices();
968 for (Int_t idev=1; idev<=ndev; idev++)
970 TObject* obj=GetDevice(idev);
973 if (obj->InheritsFrom(classname) && obj->InheritsFrom("AliDevice"))
975 AliDevice* dev=(AliDevice*)GetDevice(idev);
976 Int_t nhits=dev->GetNhits();
979 if (!fHits) fHits=new TObjArray();
980 for (Int_t ih=1; ih<=nhits; ih++)
982 AliSignal* sx=dev->GetHit(ih);
983 if (sx) fHits->Add(sx);
989 ///////////////////////////////////////////////////////////////////////////
990 TObjArray* AliEvent::SortHits(const char* classname,Int_t idx,Int_t mode,Int_t mcal)
992 // Order the references to the various hits registered to the specified
993 // device class. The ordered array is returned as a TObjArray.
994 // A "hit" represents an abstract object which is derived from AliSignal.
995 // The user can specify the index of the signal slot to perform the sorting on.
996 // By default the slotindex will be 1.
997 // Via the "mode" argument the user can specify ordering in decreasing
998 // order (mode=-1) or ordering in increasing order (mode=1).
999 // The default is mode=-1.
1000 // Signals which were declared as "Dead" will be rejected.
1001 // The gain etc... corrected signals will be used in the ordering process as
1002 // specified by the "mcal" argument. The definition of this "mcal" parameter
1003 // corresponds to the signal correction mode described in the GetSignal
1004 // memberfunction of class AliSignal.
1005 // The default is mcal=1 (for backward compatibility reasons).
1007 // For more extended functionality see class AliDevice.
1009 if (idx<=0 || abs(mode)!=1) return 0;
1011 LoadHits(classname);
1014 TObjArray* ordered=dev.SortHits(idx,mode,fHits,mcal);
1021 if (ordered) fHits=new TObjArray(*ordered);
1024 ///////////////////////////////////////////////////////////////////////////
1025 TObjArray* AliEvent::SortHits(const char* classname,TString name,Int_t mode,Int_t mcal)
1027 // Order the references to the various hits registered to the specified
1028 // device class. The ordered array is returned as a TObjArray.
1029 // A "hit" represents an abstract object which is derived from AliSignal.
1030 // The user can specify the name of the signal slot to perform the sorting on.
1031 // In case no matching slotname is found, the signal will be skipped.
1032 // Via the "mode" argument the user can specify ordering in decreasing
1033 // order (mode=-1) or ordering in increasing order (mode=1).
1034 // The default is mode=-1.
1035 // Signals which were declared as "Dead" will be rejected.
1036 // The gain etc... corrected signals will be used in the ordering process as
1037 // specified by the "mcal" argument. The definition of this "mcal" parameter
1038 // corresponds to the signal correction mode described in the GetSignal
1039 // memberfunction of class AliSignal.
1040 // The default is mcal=1 (for backward compatibility reasons).
1042 // For more extended functionality see class AliDevice.
1044 if (abs(mode)!=1) return 0;
1046 LoadHits(classname);
1049 TObjArray* ordered=dev.SortHits(name,mode,fHits,mcal);
1056 if (ordered) fHits=new TObjArray(*ordered);
1059 ///////////////////////////////////////////////////////////////////////////
1060 void AliEvent::GetExtremes(const char* classname,Float_t& vmin,Float_t& vmax,Int_t idx,Int_t mode)
1062 // Provide the min. and max. signal values of the various hits registered
1063 // to the specified device class.
1064 // The input argument "idx" denotes the index of the signal slots to be investigated.
1065 // The default is idx=1;
1066 // Signals which were declared as "Dead" will be rejected.
1067 // The gain etc... corrected signals will be used in the process as specified
1068 // by the "mode" argument. The definition of this "mode" parameter corresponds to
1069 // the description provided in the GetSignal memberfunction of class AliSignal.
1070 // The default is mode=1 (for backward compatibility reasons).
1072 // For more extended functionality see class AliDevice.
1076 LoadHits(classname);
1079 dev.GetExtremes(vmin,vmax,idx,fHits,mode);
1081 ///////////////////////////////////////////////////////////////////////////
1082 void AliEvent::GetExtremes(const char* classname,Float_t& vmin,Float_t& vmax,TString name,Int_t mode)
1084 // Provide the min. and max. signal values of the various hits registered
1085 // to the specified device class.
1086 // The input argument "name" denotes the name of the signal slots to be investigated.
1087 // Signals which were declared as "Dead" will be rejected.
1088 // The gain etc... corrected signals will be used in the process as specified
1089 // by the "mode" argument. The definition of this "mode" parameter corresponds to
1090 // the description provided in the GetSignal memberfunction of class AliSignal.
1091 // The default is mode=1 (for backward compatibility reasons).
1093 // For more extended functionality see class AliDevice.
1095 LoadHits(classname);
1098 dev.GetExtremes(vmin,vmax,name,fHits,mode);
1100 ///////////////////////////////////////////////////////////////////////////
1101 void AliEvent::DisplayHits(const char* classname,Int_t idx,Float_t scale,Int_t dp,Int_t mode,Int_t mcol)
1103 // 3D color display of the various hits registered to the specified device class.
1104 // The user can specify the index (default=1) of the signal slot to perform the display for.
1105 // The marker size will indicate the absolute value of the signal (specified by the slotindex)
1106 // as a percentage of the input argument "scale".
1107 // In case scale<0 the maximum absolute signal value encountered in the hit array will be used
1108 // to define the 100% scale. The default is scale=-1.
1109 // In case dp=1 the owning device position will be used, otherwise the hit position will
1110 // be used in the display. The default is dp=0.
1111 // Via the "mcol" argument the user can specify the marker color (see TPolyMarker3D).
1112 // The default is mcol=blue.
1113 // Signals which were declared as "Dead" will not be displayed.
1114 // The gain etc... corrected signals will be used to determine the marker size.
1115 // The gain correction is performed according to "mode" argument. The definition of this
1116 // "mode" parameter corresponds to the description provided in the GetSignal
1117 // memberfunction of class AliSignal.
1118 // The default is mode=1 (for backward compatibility reasons).
1120 // For more extended functionality see class AliDevice.
1124 // Before any display activity, a TCanvas and a TView have to be initiated
1125 // first by the user like for instance
1127 // TCanvas* c1=new TCanvas("c1","c1");
1128 // TView* view=new TView(1);
1129 // view->SetRange(-1000,-1000,-1000,1000,1000,1000);
1130 // view->ShowAxis();
1134 LoadHits(classname);
1136 AliDevice* dev=new AliDevice();
1137 dev->DisplayHits(idx,scale,fHits,dp,mode,mcol);
1146 ///////////////////////////////////////////////////////////////////////////
1147 void AliEvent::DisplayHits(const char* classname,TString name,Float_t scale,Int_t dp,Int_t mode,Int_t mcol)
1149 // 3D color display of the various hits registered to the specified device class.
1150 // The user can specify the name of the signal slot to perform the display for.
1151 // The marker size will indicate the absolute value of the signal (specified by the slotname)
1152 // as a percentage of the input argument "scale".
1153 // In case scale<0 the maximum absolute signal value encountered in the hit array will be used
1154 // to define the 100% scale. The default is scale=-1.
1155 // In case dp=1 the owning device position will be used, otherwise the hit position will
1156 // be used in the display. The default is dp=0.
1157 // The marker size will indicate the percentage of the maximum encountered value
1158 // of the absolute value of the name-specified input signal slots.
1159 // Via the "mcol" argument the user can specify the marker color (see TPolyMarker3D).
1160 // The default is mcol=blue.
1161 // Signals which were declared as "Dead" will not be displayed.
1162 // The gain etc... corrected signals will be used to determine the marker size.
1163 // The gain correction is performed according to "mode" argument. The definition of this
1164 // "mode" parameter corresponds to the description provided in the GetSignal
1165 // memberfunction of class AliSignal.
1166 // The default is mode=1 (for backward compatibility reasons).
1168 // For more extended functionality see class AliDevice.
1172 // Before any display activity, a TCanvas and a TView have to be initiated
1173 // first by the user like for instance
1175 // TCanvas* c1=new TCanvas("c1","c1");
1176 // TView* view=new TView(1);
1177 // view->SetRange(-1000,-1000,-1000,1000,1000,1000);
1178 // view->ShowAxis();
1180 LoadHits(classname);
1182 AliDevice* dev=new AliDevice();
1183 dev->DisplayHits(name,scale,fHits,dp,mode,mcol);
1192 ///////////////////////////////////////////////////////////////////////////
1193 TObjArray* AliEvent::SortDevices(const char* classname,TString name,Int_t mode,Int_t mcal)
1195 // Order the references to the various devices based on hit signals registered
1196 // to the specified device class. The ordered array is returned as a TObjArray.
1197 // A "hit" represents an abstract object which is derived from AliSignal.
1198 // The user can specify the name of the signal slot to perform the sorting on.
1199 // In case no matching slotname is found, the signal will be skipped.
1200 // Via the "mode" argument the user can specify ordering in decreasing
1201 // order (mode=-1) or ordering in increasing order (mode=1).
1202 // The default is mode=-1.
1203 // Signals which were declared as "Dead" will be rejected.
1204 // The gain etc... corrected signals will be used in the ordering process as
1205 // specified by the "mcal" argument. The definition of this "mcal" parameter
1206 // corresponds to the signal correction mode described in the GetSignal
1207 // memberfunction of class AliSignal.
1208 // The default is mcal=1 (for backward compatibility reasons).
1211 TObjArray* ordered=SortHits(classname,name,mode,mcal);
1213 if (!ordered) return 0;
1215 TObjArray* devs=SortDevices(ordered,"*",0,mcal);
1218 ///////////////////////////////////////////////////////////////////////////
1219 TObjArray* AliEvent::SortDevices(const char* classname,Int_t idx,Int_t mode,Int_t mcal)
1221 // Order the references to the various devices based on hit signals registered
1222 // to the specified device class. The ordered array is returned as a TObjArray.
1223 // A "hit" represents an abstract object which is derived from AliSignal.
1224 // The user can specify the index of the signal slot to perform the sorting on.
1225 // By default the slotindex will be 1.
1226 // Via the "mode" argument the user can specify ordering in decreasing
1227 // order (mode=-1) or ordering in increasing order (mode=1).
1228 // The default is mode=-1.
1229 // Signals which were declared as "Dead" will be rejected.
1230 // The gain etc... corrected signals will be used in the ordering process as
1231 // specified by the "mcal" argument. The definition of this "mcal" parameter
1232 // corresponds to the signal correction mode described in the GetSignal
1233 // memberfunction of class AliSignal.
1234 // The default is mcal=1 (for backward compatibility reasons).
1237 TObjArray* ordered=SortHits(classname,idx,mode,mcal);
1239 if (!ordered) return 0;
1241 TObjArray* devs=SortDevices(ordered,0,0,mcal);
1244 ///////////////////////////////////////////////////////////////////////////
1245 TObjArray* AliEvent::SortDevices(TObjArray* hits,TString name,Int_t mode,Int_t mcal)
1247 // Order the references to the various devices based on hit signals contained
1248 // in the input array. The ordered array is returned as a TObjArray.
1249 // A "hit" represents an abstract object which is derived from AliSignal.
1250 // The user can specify the name of the signal slot to perform the sorting on.
1251 // In case no matching slotname is found, the signal will be skipped.
1252 // Via the "mode" argument the user can specify ordering in decreasing
1253 // order (mode=-1), ordering in increasing order (mode=1) or no ordering (mode=0).
1254 // The latter option provides a means to quickly obtain an ordered devices list
1255 // when the hits in the array were already ordered by the user. In this case
1256 // the input argument "name" is irrelevant.
1257 // The default is mode=-1.
1258 // Signals which were declared as "Dead" will be rejected.
1259 // The gain etc... corrected signals will be used in the ordering process as
1260 // specified by the "mcal" argument. The definition of this "mcal" parameter
1261 // corresponds to the signal correction mode described in the GetSignal
1262 // memberfunction of class AliSignal.
1263 // The default is mcal=1 (for backward compatibility reasons).
1266 if (!hits) return 0;
1268 TObjArray* ordered=hits;
1270 if (mode) ordered=dev.SortHits(name,mode,hits,mcal);
1272 if (!ordered) return 0;
1280 fOrdered=new TObjArray();
1283 Int_t nhits=ordered->GetEntries();
1285 for (Int_t ih=0; ih<nhits; ih++)
1287 AliSignal* sx=(AliSignal*)ordered->At(ih);
1289 AliDevice* dx=sx->GetDevice();
1291 for (Int_t id=0; id<fOrdered->GetEntries(); id++)
1293 AliDevice* odx=(AliDevice*)fOrdered->At(id);
1300 if (!exist) fOrdered->Add(dx);
1304 ///////////////////////////////////////////////////////////////////////////
1305 TObjArray* AliEvent::SortDevices(TObjArray* hits,Int_t idx,Int_t mode,Int_t mcal)
1307 // Order the references to the various devices based on hit signals contained
1308 // in the input array. The ordered array is returned as a TObjArray.
1309 // A "hit" represents an abstract object which is derived from AliSignal.
1310 // The user can specify the index of the signal slot to perform the sorting on.
1311 // By default the slotindex will be 1.
1312 // Via the "mode" argument the user can specify ordering in decreasing
1313 // order (mode=-1), ordering in increasing order (mode=1) or no ordering (mode=0).
1314 // The latter option provides a means to quickly obtain an ordered devices list
1315 // when the hits in the array were already ordered by the user. In this case
1316 // the input argument "idx" is irrelevant.
1317 // The default is mode=-1.
1318 // Signals which were declared as "Dead" will be rejected.
1319 // The gain etc... corrected signals will be used in the ordering process as
1320 // specified by the "mcal" argument. The definition of this "mcal" parameter
1321 // corresponds to the signal correction mode described in the GetSignal
1322 // memberfunction of class AliSignal.
1323 // The default is mcal=1 (for backward compatibility reasons).
1326 if (!hits) return 0;
1328 TObjArray* ordered=hits;
1330 if (mode) ordered=dev.SortHits(idx,mode,hits,mcal);
1332 if (!ordered) return 0;
1340 fOrdered=new TObjArray();
1343 Int_t nhits=ordered->GetEntries();
1345 for (Int_t ih=0; ih<nhits; ih++)
1347 AliSignal* sx=(AliSignal*)ordered->At(ih);
1349 AliDevice* dx=sx->GetDevice();
1351 for (Int_t id=0; id<fOrdered->GetEntries(); id++)
1353 AliDevice* odx=(AliDevice*)fOrdered->At(id);
1360 if (!exist) fOrdered->Add(dx);
1364 ///////////////////////////////////////////////////////////////////////////
1365 TObject* AliEvent::Clone(const char* name) const
1367 // Make a deep copy of the current object and provide the pointer to the copy.
1368 // This memberfunction enables automatic creation of new objects of the
1369 // correct type depending on the object type, a feature which may be very useful
1370 // for containers when adding objects in case the container owns the objects.
1371 // This feature allows to store either AliEvent objects or objects derived from
1372 // AliEvent via some generic AddEvent memberfunction, provided these derived
1373 // classes also have a proper Clone memberfunction.
1375 AliEvent* evt=new AliEvent(*this);
1378 if (strlen(name)) evt->SetName(name);
1382 ///////////////////////////////////////////////////////////////////////////