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 : All quantities are in GeV, GeV/c or GeV/c**2
246 //--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
247 //- Modified: NvE $Date: 2004/10/20 10:49:44 $ UU-SAP Utrecht
248 ///////////////////////////////////////////////////////////////////////////
250 #include "AliEvent.h"
251 #include "Riostream.h"
253 ClassImp(AliEvent) // Class implementation to enable ROOT I/O
255 AliEvent::AliEvent() : AliVertex(),AliTimestamp()
257 // Default constructor.
258 // All variables initialised to default values.
275 ///////////////////////////////////////////////////////////////////////////
276 AliEvent::AliEvent(Int_t n) : AliVertex(n),AliTimestamp()
278 // Create an event to hold initially a maximum of n tracks
279 // All variables initialised to default values
282 cout << " *** This AliVertex initialisation was invoked via the AliEvent ctor." << endl;
300 ///////////////////////////////////////////////////////////////////////////
301 AliEvent::~AliEvent()
303 // Default destructor
325 ///////////////////////////////////////////////////////////////////////////
326 AliEvent::AliEvent(const AliEvent& evt) : AliVertex(evt),AliTimestamp(evt)
333 fPnucProj=evt.fPnucProj;
337 fPnucTarg=evt.fPnucTarg;
339 fDevCopy=evt.fDevCopy;
346 Int_t ndevs=evt.GetNdevices();
349 fDevices=new TObjArray(ndevs);
350 if (fDevCopy) fDevices->SetOwner();
351 for (Int_t i=1; i<=ndevs; i++)
353 TObject* dev=evt.GetDevice(i);
358 fDevices->Add(dev->Clone());
368 ///////////////////////////////////////////////////////////////////////////
369 void AliEvent::Reset()
371 // Reset all variables to default values
372 // The max. number of tracks is set to the initial value again
373 // The max. number of vertices is set to the default value again
374 // Note : The DevCopy mode is maintained as it was set by the user before.
411 ///////////////////////////////////////////////////////////////////////////
412 void AliEvent::SetOwner(Bool_t own)
414 // Set ownership of all added objects.
415 // The default parameter is own=kTRUE.
417 // Invokation of this memberfunction also sets all the copy modes
418 // (e.g. TrackCopy & co.) according to the value of own.
420 // This function (with own=kTRUE) is particularly useful when reading data
421 // from a tree/file, since Reset() will then actually remove all the
422 // added objects from memory irrespective of the copy mode settings
423 // during the tree/file creation process. In this way it provides a nice way
424 // of preventing possible memory leaks in the reading/analysis process.
426 // In addition this memberfunction can also be used as a shortcut to set all
427 // copy modes in one go during a tree/file creation process.
428 // However, in this case the user has to take care to only set/change the
429 // ownership (and copy mode) for empty objects (e.g. newly created objects
430 // or after invokation of the Reset() memberfunction) otherwise it will
431 // very likely result in inconsistent destructor behaviour.
435 if (fDevices) fDevices->SetOwner(own);
438 AliVertex::SetOwner(own);
440 ///////////////////////////////////////////////////////////////////////////
441 void AliEvent::SetDayTime(TTimeStamp& stamp)
443 // Set the date and time stamp for this event.
444 // An exact copy of the entered date/time stamp will be saved with an
445 // accuracy of 1 nanosecond.
447 // Note : Since the introduction of the more versatile class AliTimestamp
448 // and the fact that AliEvent has now been derived from it,
449 // this memberfunction has become obsolete.
450 // It is recommended to use the corresponding AliTimestamp
451 // functionality directly for AliEvent instances.
452 // This memberfunction is only kept for backward compatibility.
454 Set(stamp.GetDate(),stamp.GetTime(),0,kTRUE,0);
456 ///////////////////////////////////////////////////////////////////////////
457 void AliEvent::SetDayTime(TDatime& stamp)
459 // Set the date and time stamp for this event.
460 // The entered date/time will be interpreted as being the local date/time
461 // and the accuracy is 1 second.
463 // This function with the TDatime argument is mainly kept for backward
464 // compatibility reasons.
465 // It is recommended to use the corresponding AliTimestamp functionality
466 // directly for AliEvent instances.
468 Set(stamp.GetDate(),stamp.GetTime(),0,kFALSE,0);
470 ///////////////////////////////////////////////////////////////////////////
471 void AliEvent::SetRunNumber(Int_t run)
473 // Set the run number for this event
476 ///////////////////////////////////////////////////////////////////////////
477 void AliEvent::SetEventNumber(Int_t evt)
479 // Set the event number for this event
482 ///////////////////////////////////////////////////////////////////////////
483 TTimeStamp AliEvent::GetDayTime() const
485 // Provide the date and time stamp for this event
487 // Note : Since the introduction of the more versatile class AliTimestamp
488 // and the fact that AliEvent has now been derived from it,
489 // this memberfunction has become obsolete.
490 // It is recommended to use the corresponding AliTimestamp
491 // functionality directly for AliEvent instances.
492 // This memberfunction is only kept for backward compatibility.
494 return (TTimeStamp)(*this);
496 ///////////////////////////////////////////////////////////////////////////
497 Int_t AliEvent::GetRunNumber() const
499 // Provide the run number for this event
502 ///////////////////////////////////////////////////////////////////////////
503 Int_t AliEvent::GetEventNumber() const
505 // Provide the event number for this event
508 ///////////////////////////////////////////////////////////////////////////
509 void AliEvent::SetProjectile(Int_t a,Int_t z,Double_t pnuc,Int_t id)
511 // Set the projectile A, Z, momentum per nucleon and user defined particle ID.
512 // By default the particle ID is set to zero.
518 ///////////////////////////////////////////////////////////////////////////
519 Int_t AliEvent::GetProjectileA() const
521 // Provide the projectile A value.
524 ///////////////////////////////////////////////////////////////////////////
525 Int_t AliEvent::GetProjectileZ() const
527 // Provide the projectile Z value.
530 ///////////////////////////////////////////////////////////////////////////
531 Double_t AliEvent::GetProjectilePnuc() const
533 // Provide the projectile momentum value per nucleon.
536 ///////////////////////////////////////////////////////////////////////////
537 Int_t AliEvent::GetProjectileId() const
539 // Provide the user defined particle ID of the projectile.
542 ///////////////////////////////////////////////////////////////////////////
543 void AliEvent::SetTarget(Int_t a,Int_t z,Double_t pnuc,Int_t id)
545 // Set the target A, Z, momentum per nucleon and user defined particle ID.
546 // By default the particle ID is set to zero.
552 ///////////////////////////////////////////////////////////////////////////
553 Int_t AliEvent::GetTargetA() const
555 // Provide the target A value.
558 ///////////////////////////////////////////////////////////////////////////
559 Int_t AliEvent::GetTargetZ() const
561 // Provide the target Z value.
564 ///////////////////////////////////////////////////////////////////////////
565 Double_t AliEvent::GetTargetPnuc() const
567 // Provide the target momentum value per nucleon.
570 ///////////////////////////////////////////////////////////////////////////
571 Int_t AliEvent::GetTargetId() const
573 // Provide the user defined particle ID of the target.
576 ///////////////////////////////////////////////////////////////////////////
577 void AliEvent::HeaderData()
579 // Provide event header information
580 const char* name=GetName();
581 const char* title=GetTitle();
582 cout << " *" << ClassName() << "::Data*";
583 if (strlen(name)) cout << " Name : " << GetName();
584 if (strlen(title)) cout << " Title : " << GetTitle();
587 cout << " Run : " << fRun << " Event : " << fEvent << endl;
591 ///////////////////////////////////////////////////////////////////////////
592 void AliEvent::Data(TString f)
594 // Provide event information within the coordinate frame f
598 ///////////////////////////////////////////////////////////////////////////
599 Int_t AliEvent::GetNdevices() const
601 // Provide the number of stored devices
603 if (fDevices) ndevs=fDevices->GetEntries();
606 ///////////////////////////////////////////////////////////////////////////
607 void AliEvent::AddDevice(TObject& d)
609 // Add a device to the event.
612 // In case a private copy is made, this is performed via the Clone() memberfunction.
613 // All devices (i.e. classes derived from TObject) have the default TObject::Clone()
615 // However, devices generally contain an internal (signal) data structure
616 // which may include pointers to other objects. Therefore it is recommended to provide
617 // for all devices a specific copy constructor and override the default Clone()
618 // memberfunction using this copy constructor.
619 // An example for this may be seen from AliCalorimeter.
623 fDevices=new TObjArray();
624 if (fDevCopy) fDevices->SetOwner();
627 // Add the device to this event
630 fDevices->Add(d.Clone());
637 ///////////////////////////////////////////////////////////////////////////
638 void AliEvent::SetDevCopy(Int_t j)
640 // (De)activate the creation of private copies of the added devices.
641 // j=0 ==> No private copies are made; pointers of original devices are stored.
642 // j=1 ==> Private copies of the devices are made and these pointers are stored.
646 // In case a private copy is made, this is performed via the Clone() memberfunction.
647 // All devices (i.e. classes derived from TObject) have the default TObject::Clone()
649 // However, devices generally contain an internal (signal) data structure
650 // which may include pointers to other objects. Therefore it is recommended to provide
651 // for all devices a specific copy constructor and override the default Clone()
652 // memberfunction using this copy constructor.
653 // An example for this may be seen from AliCalorimeter.
655 // Once the storage contains pointer(s) to device(s) one cannot
656 // change the DevCopy mode anymore.
657 // To change the DevCopy mode for an existing AliEvent containing
658 // devices one first has to invoke Reset().
668 cout << " *" << ClassName() << "::SetDevCopy* Invalid argument : " << j << endl;
673 cout << " *" << ClassName() << "::SetDevCopy* Storage already contained devices."
674 << " ==> DevCopy mode not changed." << endl;
677 ///////////////////////////////////////////////////////////////////////////
678 Int_t AliEvent::GetDevCopy() const
680 // Provide value of the DevCopy mode.
681 // 0 ==> No private copies are made; pointers of original devices are stored.
682 // 1 ==> Private copies of the devices are made and these pointers are stored.
685 // In case a private copy is made, this is performed via the Clone() memberfunction.
686 // All devices (i.e. classes derived from TObject) have the default TObject::Clone()
688 // However, devices generally contain an internal (signal) data structure
689 // which may include pointers to other objects. Therefore it is recommended to provide
690 // for all devices a specific copy constructor and override the default Clone()
691 // memberfunction using this copy constructor.
692 // An example for this may be seen from AliCalorimeter.
696 ///////////////////////////////////////////////////////////////////////////
697 TObject* AliEvent::GetDevice(Int_t i) const
699 // Return the i-th device of this event.
700 // The first device corresponds to i=1.
708 Int_t ndevs=GetNdevices();
711 cout << " *" << ClassName() << "::GetDevice* Invalid argument i : " << i
712 << " ndevs = " << ndevs << endl;
717 return fDevices->At(i-1);
721 ///////////////////////////////////////////////////////////////////////////
722 TObject* AliEvent::GetDevice(TString name) const
724 // Return the device with name tag "name"
732 Int_t ndevs=GetNdevices();
733 for (Int_t i=0; i<ndevs; i++)
735 TObject* dev=fDevices->At(i);
739 if (s == name) return dev;
743 return 0; // No matching name found
746 ///////////////////////////////////////////////////////////////////////////
747 TObject* AliEvent::GetIdDevice(Int_t id) const
749 // Return the device with unique identifier "id".
750 if (!fDevices || id<0) return 0;
753 for (Int_t i=0; i<GetNdevices(); i++)
755 TObject* dev=fDevices->At(i);
758 idx=dev->GetUniqueID();
759 if (idx==id) return dev;
762 return 0; // No matching id found
764 ///////////////////////////////////////////////////////////////////////////
765 void AliEvent::ShowDevices(Int_t mode) const
767 // Provide an overview of the available devices.
768 // The argument mode determines the amount of information as follows :
769 // mode = 0 ==> Only printout of the number of devices
770 // 1 ==> Provide a listing with 1 line of info for each device
772 // The default is mode=1.
774 Int_t ndevs=GetNdevices();
779 cout << " There are " << ndevs << " devices available." << endl;
783 cout << " The following " << ndevs << " devices are available :" << endl;
784 for (Int_t i=1; i<=ndevs; i++)
786 TObject* dev=GetDevice(i);
789 const char* name=dev->GetName();
790 cout << " Device number : " << i;
791 cout << " Class : " << dev->ClassName() << " Id : " << dev->GetUniqueID();
792 if (strlen(name)) cout << " Name : " << name;
793 if (dev->InheritsFrom("AliDevice")) cout << " Nhits : " << ((AliDevice*)dev)->GetNhits();
794 if (dev->InheritsFrom("AliSignal")) cout << " Nwaveforms : " << ((AliSignal*)dev)->GetNwaveforms();
802 cout << " No devices present for this event." << endl;
805 ///////////////////////////////////////////////////////////////////////////
806 Int_t AliEvent::GetNhits(const char* classname)
808 // Provide the number of hits registered to the specified device class.
809 // The specified device class has to be derived from AliDevice.
810 // It is possible to indicate with the argument "classname" a specific
811 // device instead of a whole class of devices. However, in such a case
812 // it is more efficient to use the GetDevice() memberfunction directly.
815 if (fHits) nhits=fHits->GetEntries();
818 ///////////////////////////////////////////////////////////////////////////
819 TObjArray* AliEvent::GetHits(const char* classname)
821 // Provide the references to all the hits registered to the specified
823 // The specified device class has to be derived from AliDevice.
824 // It is possible to indicate with the argument "classname" a specific
825 // device instead of a whole class of devices. However, in such a case
826 // it is more efficient to use the GetDevice() memberfunction directly.
830 ///////////////////////////////////////////////////////////////////////////
831 AliSignal* AliEvent::GetIdHit(Int_t id,const char* classname)
833 // Return the hit with unique identifier "id" for the specified device class.
836 Int_t nhits=GetNhits(classname);
837 if (!nhits) return 0;
841 for (Int_t i=0; i<nhits; i++)
843 sx=(AliSignal*)fHits->At(i);
846 sid=sx->GetUniqueID();
847 if (id==sid) return sx;
850 return 0; // No matching id found
852 ///////////////////////////////////////////////////////////////////////////
853 void AliEvent::LoadHits(const char* classname)
855 // Load the references to the various hits registered to the specified
857 // The specified device class has to be derived from AliDevice.
858 if (fHits) fHits->Clear();
860 Int_t ndev=GetNdevices();
861 for (Int_t idev=1; idev<=ndev; idev++)
863 TObject* obj=GetDevice(idev);
866 if (obj->InheritsFrom(classname) && obj->InheritsFrom("AliDevice"))
868 AliDevice* dev=(AliDevice*)GetDevice(idev);
869 Int_t nhits=dev->GetNhits();
872 if (!fHits) fHits=new TObjArray();
873 for (Int_t ih=1; ih<=nhits; ih++)
875 AliSignal* sx=dev->GetHit(ih);
876 if (sx) fHits->Add(sx);
882 ///////////////////////////////////////////////////////////////////////////
883 TObjArray* AliEvent::SortHits(const char* classname,Int_t idx,Int_t mode)
885 // Order the references to the various hits registered to the specified
886 // device class. The ordered array is returned as a TObjArray.
887 // A "hit" represents an abstract object which is derived from AliSignal.
888 // The user can specify the index of the signal slot to perform the sorting on.
889 // By default the slotindex will be 1.
890 // Via the "mode" argument the user can specify ordering in decreasing
891 // order (mode=-1) or ordering in increasing order (mode=1).
892 // The default is mode=-1.
893 // Signals which were declared as "Dead" will be rejected.
894 // The gain etc... corrected signals will be used in the ordering process.
896 // For more extended functionality see class AliDevice.
898 if (idx<=0 || abs(mode)!=1) return 0;
903 TObjArray* ordered=dev.SortHits(idx,mode,fHits);
910 if (ordered) fHits=new TObjArray(*ordered);
913 ///////////////////////////////////////////////////////////////////////////
914 TObjArray* AliEvent::SortHits(const char* classname,TString name,Int_t mode)
916 // Order the references to the various hits registered to the specified
917 // device class. The ordered array is returned as a TObjArray.
918 // A "hit" represents an abstract object which is derived from AliSignal.
919 // The user can specify the name of the signal slot to perform the sorting on.
920 // In case no matching slotname is found, the signal will be skipped.
921 // Via the "mode" argument the user can specify ordering in decreasing
922 // order (mode=-1) or ordering in increasing order (mode=1).
923 // The default is mode=-1.
924 // Signals which were declared as "Dead" will be rejected.
925 // The gain etc... corrected signals will be used in the ordering process.
927 // For more extended functionality see class AliDevice.
929 if (abs(mode)!=1) return 0;
934 TObjArray* ordered=dev.SortHits(name,mode,fHits);
941 if (ordered) fHits=new TObjArray(*ordered);
944 ///////////////////////////////////////////////////////////////////////////
945 void AliEvent::GetExtremes(const char* classname,Float_t& vmin,Float_t& vmax,Int_t idx)
947 // Provide the min. and max. signal values of the various hits registered
948 // to the specified device class.
949 // The input argument "idx" denotes the index of the signal slots to be investigated.
950 // The default is idx=1;
951 // Signals which were declared as "Dead" will be rejected.
952 // The gain etc... corrected signals will be used in the process.
954 // For more extended functionality see class AliDevice.
961 dev.GetExtremes(vmin,vmax,idx,fHits);
963 ///////////////////////////////////////////////////////////////////////////
964 void AliEvent::GetExtremes(const char* classname,Float_t& vmin,Float_t& vmax,TString name)
966 // Provide the min. and max. signal values of the various hits registered
967 // to the specified device class.
968 // The input argument "name" denotes the name of the signal slots to be investigated.
969 // Signals which were declared as "Dead" will be rejected.
970 // The gain etc... corrected signals will be used in the process.
972 // For more extended functionality see class AliDevice.
977 dev.GetExtremes(vmin,vmax,name,fHits);
979 ///////////////////////////////////////////////////////////////////////////
980 void AliEvent::DisplayHits(const char* classname,Int_t idx,Float_t scale,Int_t dp,Int_t mstyle,Int_t mcol)
982 // 3D color display of the various hits registered to the specified device class.
983 // The user can specify the index (default=1) of the signal slot to perform the display for.
984 // The marker size will indicate the absolute value of the signal (specified by the slotindex)
985 // as a percentage of the input argument "scale".
986 // In case scale<0 the maximum absolute signal value encountered in the hit array will be used
987 // to define the 100% scale. The default is scale=-1.
988 // In case dp=1 the owning device position will be used, otherwise the hit position will
989 // be used in the display. The default is dp=0.
990 // Via the "mstyle" and "mcol" arguments the user can specify the marker style
991 // and color (see TPolyMarker3D) respectively.
992 // The defaults are mstyle="large scalable dot" and mcol=blue.
993 // Signals which were declared as "Dead" will not be displayed.
994 // The gain etc... corrected signals will be used to determine the marker size.
996 // For more extended functionality see class AliDevice.
1000 // Before any display activity, a TCanvas and a TView have to be initiated
1001 // first by the user like for instance
1003 // TCanvas* c1=new TCanvas("c1","c1");
1004 // TView* view=new TView(1);
1005 // view->SetRange(-1000,-1000,-1000,1000,1000,1000);
1006 // view->ShowAxis();
1010 LoadHits(classname);
1012 AliDevice* dev=new AliDevice();
1013 dev->DisplayHits(idx,scale,fHits,dp,mstyle,mcol);
1022 ///////////////////////////////////////////////////////////////////////////
1023 void AliEvent::DisplayHits(const char* classname,TString name,Float_t scale,Int_t dp,Int_t mstyle,Int_t mcol)
1025 // 3D color display of the various hits registered to the specified device class.
1026 // The user can specify the name of the signal slot to perform the display for.
1027 // The marker size will indicate the absolute value of the signal (specified by the slotname)
1028 // as a percentage of the input argument "scale".
1029 // In case scale<0 the maximum absolute signal value encountered in the hit array will be used
1030 // to define the 100% scale. The default is scale=-1.
1031 // In case dp=1 the owning device position will be used, otherwise the hit position will
1032 // be used in the display. The default is dp=0.
1033 // The marker size will indicate the percentage of the maximum encountered value
1034 // of the absolute value of the name-specified input signal slots.
1035 // Via the "mstyle" and "mcol" arguments the user can specify the marker style
1036 // and color (see TPolyMarker3D) respectively.
1037 // The defaults are mstyle="large scalable dot" and mcol=blue.
1038 // Signals which were declared as "Dead" will not be displayed.
1039 // The gain etc... corrected signals will be used to determine the marker size.
1041 // For more extended functionality see class AliDevice.
1045 // Before any display activity, a TCanvas and a TView have to be initiated
1046 // first by the user like for instance
1048 // TCanvas* c1=new TCanvas("c1","c1");
1049 // TView* view=new TView(1);
1050 // view->SetRange(-1000,-1000,-1000,1000,1000,1000);
1051 // view->ShowAxis();
1053 LoadHits(classname);
1055 AliDevice* dev=new AliDevice();
1056 dev->DisplayHits(name,scale,fHits,dp,mstyle,mcol);
1065 ///////////////////////////////////////////////////////////////////////////
1066 TObjArray* AliEvent::SortDevices(const char* classname,TString name,Int_t mode)
1068 // Order the references to the various devices based on hit signals registered
1069 // to the specified device class. The ordered array is returned as a TObjArray.
1070 // A "hit" represents an abstract object which is derived from AliSignal.
1071 // The user can specify the name of the signal slot to perform the sorting on.
1072 // In case no matching slotname is found, the signal will be skipped.
1073 // Via the "mode" argument the user can specify ordering in decreasing
1074 // order (mode=-1) or ordering in increasing order (mode=1).
1075 // The default is mode=-1.
1076 // Signals which were declared as "Dead" will be rejected.
1077 // The gain etc... corrected signals will be used in the ordering process.
1080 TObjArray* ordered=SortHits(classname,name,mode);
1082 if (!ordered) return 0;
1084 TObjArray* devs=SortDevices(ordered,"*",0);
1087 ///////////////////////////////////////////////////////////////////////////
1088 TObjArray* AliEvent::SortDevices(const char* classname,Int_t idx,Int_t mode)
1090 // Order the references to the various devices based on hit signals registered
1091 // to the specified device class. The ordered array is returned as a TObjArray.
1092 // A "hit" represents an abstract object which is derived from AliSignal.
1093 // The user can specify the index of the signal slot to perform the sorting on.
1094 // By default the slotindex will be 1.
1095 // Via the "mode" argument the user can specify ordering in decreasing
1096 // order (mode=-1) or ordering in increasing order (mode=1).
1097 // The default is mode=-1.
1098 // Signals which were declared as "Dead" will be rejected.
1099 // The gain etc... corrected signals will be used in the ordering process.
1102 TObjArray* ordered=SortHits(classname,idx,mode);
1104 if (!ordered) return 0;
1106 TObjArray* devs=SortDevices(ordered,0,0);
1109 ///////////////////////////////////////////////////////////////////////////
1110 TObjArray* AliEvent::SortDevices(TObjArray* hits,TString name,Int_t mode)
1112 // Order the references to the various devices based on hit signals contained
1113 // in the input array. The ordered array is returned as a TObjArray.
1114 // A "hit" represents an abstract object which is derived from AliSignal.
1115 // The user can specify the name of the signal slot to perform the sorting on.
1116 // In case no matching slotname is found, the signal will be skipped.
1117 // Via the "mode" argument the user can specify ordering in decreasing
1118 // order (mode=-1), ordering in increasing order (mode=1) or no ordering (mode=0).
1119 // The latter option provides a means to quickly obtain an ordered devices list
1120 // when the hits in the array were already ordered by the user. In this case
1121 // the input argument "name" is irrelevant.
1122 // The default is mode=-1.
1123 // Signals which were declared as "Dead" will be rejected.
1124 // The gain etc... corrected signals will be used in the ordering process.
1127 if (!hits) return 0;
1129 TObjArray* ordered=hits;
1131 if (mode) ordered=dev.SortHits(name,mode,hits);
1133 if (!ordered) return 0;
1141 fOrdered=new TObjArray();
1144 Int_t nhits=ordered->GetEntries();
1146 for (Int_t ih=0; ih<nhits; ih++)
1148 AliSignal* sx=(AliSignal*)ordered->At(ih);
1150 AliDevice* dx=sx->GetDevice();
1152 for (Int_t id=0; id<fOrdered->GetEntries(); id++)
1154 AliDevice* odx=(AliDevice*)fOrdered->At(id);
1161 if (!exist) fOrdered->Add(dx);
1165 ///////////////////////////////////////////////////////////////////////////
1166 TObjArray* AliEvent::SortDevices(TObjArray* hits,Int_t idx,Int_t mode)
1168 // Order the references to the various devices based on hit signals contained
1169 // in the input array. The ordered array is returned as a TObjArray.
1170 // A "hit" represents an abstract object which is derived from AliSignal.
1171 // The user can specify the index of the signal slot to perform the sorting on.
1172 // By default the slotindex will be 1.
1173 // Via the "mode" argument the user can specify ordering in decreasing
1174 // order (mode=-1), ordering in increasing order (mode=1) or no ordering (mode=0).
1175 // The latter option provides a means to quickly obtain an ordered devices list
1176 // when the hits in the array were already ordered by the user. In this case
1177 // the input argument "idx" is irrelevant.
1178 // The default is mode=-1.
1179 // Signals which were declared as "Dead" will be rejected.
1180 // The gain etc... corrected signals will be used in the ordering process.
1183 if (!hits) return 0;
1185 TObjArray* ordered=hits;
1187 if (mode) ordered=dev.SortHits(idx,mode,hits);
1189 if (!ordered) return 0;
1197 fOrdered=new TObjArray();
1200 Int_t nhits=ordered->GetEntries();
1202 for (Int_t ih=0; ih<nhits; ih++)
1204 AliSignal* sx=(AliSignal*)ordered->At(ih);
1206 AliDevice* dx=sx->GetDevice();
1208 for (Int_t id=0; id<fOrdered->GetEntries(); id++)
1210 AliDevice* odx=(AliDevice*)fOrdered->At(id);
1217 if (!exist) fOrdered->Add(dx);
1221 ///////////////////////////////////////////////////////////////////////////
1222 TObject* AliEvent::Clone(const char* name) const
1224 // Make a deep copy of the current object and provide the pointer to the copy.
1225 // This memberfunction enables automatic creation of new objects of the
1226 // correct type depending on the object type, a feature which may be very useful
1227 // for containers when adding objects in case the container owns the objects.
1228 // This feature allows to store either AliEvent objects or objects derived from
1229 // AliEvent via some generic AddEvent memberfunction, provided these derived
1230 // classes also have a proper Clone memberfunction.
1232 AliEvent* evt=new AliEvent(*this);
1235 if (strlen(name)) evt->SetName(name);
1239 ///////////////////////////////////////////////////////////////////////////