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 /*****************************************************************
17 AliStarEvent: Event container for star data
19 origin: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
20 *****************************************************************/
23 #include <TObjArray.h>
24 #include "AliStarTrack.h"
25 #include "AliStarEvent.h"
27 ClassImp(AliStarEvent)
29 //______________________________________________________________________________
30 AliStarEvent::AliStarEvent():
38 //______________________________________________________________________________
39 AliStarEvent::AliStarEvent( Int_t n ):
42 fTracks(new TObjArray(n) )
47 //______________________________________________________________________________
48 AliStarEvent::AliStarEvent( const AliStarEvent& event ):
51 fTracks((TObjArray*)(event.fTracks)->Clone())
54 memcpy(fParams,event.fParams,fgkNparams*sizeof(Float_t));
57 //______________________________________________________________________________
58 AliStarEvent& AliStarEvent::operator=( const AliStarEvent& event )
61 if (this == &event) return *this;
62 TObject::operator=(event);
63 memcpy(fParams,event.fParams,fgkNparams*sizeof(Float_t));
64 if (fTracks) fTracks->Delete();
67 fTracks = (TObjArray*)(event.fTracks)->Clone(); //deep copy
71 //______________________________________________________________________________
72 void AliStarEvent::SetParams( const Float_t* params )
75 memcpy(fParams,params,fgkNparams*sizeof(Float_t));
78 //______________________________________________________________________________
79 AliStarEvent::~AliStarEvent()
82 if (fTracks) fTracks->Delete();
86 //______________________________________________________________________________
87 const AliStarTrack* AliStarEvent::GetTrack( const Int_t i ) const
90 if (!fTracks) return NULL;
91 return static_cast<AliStarTrack*>(fTracks->At(i));
94 //______________________________________________________________________________
95 void AliStarEvent::AddTrack( AliStarTrack* track )
97 //add a new track to collection
102 //______________________________________________________________________________
103 void AliStarEvent::Reset()
105 //remove all tracks if any and zero the event information
108 fTracks=new TObjArray(1024);
112 for (Int_t i=0;i<fgkNparams; i++){fParams[i]=0;}
115 //______________________________________________________________________________
116 void AliStarEvent::Print( Option_t* option ) const
119 // TNtuple* event: names are documented in the next 2 lines
120 // event = new TNtuple("event","event",
121 // "runId:eventNumber:VtxX:VtxY:VtxZ:BField:refMult:centralityId:numberOfPrimaryTracks:numberOfParticles:h0:h1:h2:h3:h4" ) ;
124 Int_t runId = (Int_t) fParams[0] ;
125 Int_t eventNumber = (Int_t) fParams[1] ;
126 Float_t primaryVertexPosition[3]={ (Float_t) fParams[2],
127 (Float_t) fParams[3],
128 (Float_t) fParams[4] };
129 Float_t magneticField = (Float_t) fParams[5] ; // kilogauss
130 Int_t refMult = (Int_t) fParams[6] ; // Raw Mult into 0.5 unit: a relative number, not total Mult.
131 Int_t centralityId = (Int_t) fParams[7] ; // STAR centrality bin # based on refMult
132 Int_t numberOfPrimaryTracks = (Int_t) fParams[8] ; // # of primaries, including FTPC tracks which are not in ntuple
133 Int_t numberOfParticles = (Int_t) fParams[9] ; // # of particles passing track cuts, thus in ntuple
135 printf("\n runId eventNo VtxX VtxY VtxZ MagFld refMult CentBin #PrimeTrak #Tracks \n") ;
136 printf("%7d %6d %7.4f %7.4f %7.3f %6.3f %6d %6d %6d %6d \n\n",
137 runId, eventNumber, primaryVertexPosition[0], primaryVertexPosition[1], primaryVertexPosition[2],
138 magneticField, refMult, centralityId, numberOfPrimaryTracks, numberOfParticles ) ;
140 //Int_t newCentralityID ;
141 //newCentralityID = Centrality( refMult) ; // Should be the same as "centralityID" from tape
142 //cout << "Test: should be the same " << newCentralityID << " " << centralityId << endl ; // JT test
144 TString optionstr(option);
145 if (!optionstr.Contains("all")) return;
146 if (!fTracks) return;
147 AliStarTrack* track = static_cast<AliStarTrack*>( fTracks->First() );
149 track->Print("legend");