]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowCommon/AliStarEvent.cxx
f1ae277ca2bd3b75f66a5807eb2ff165fbf38666
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliStarEvent.cxx
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
16 /*****************************************************************
17   AliStarEvent: Event container for star data
18
19   origin:   Mikolaj Krzewicki  (mikolaj.krzewicki@cern.ch)
20 *****************************************************************/
21
22 #include <string.h>
23 #include <TObjArray.h>
24 #include "AliStarTrack.h"
25 #include "AliStarEvent.h"
26
27 ClassImp(AliStarEvent)
28
29 //______________________________________________________________________________
30 AliStarEvent::AliStarEvent():
31   TObject(),
32   fParams(),
33   fTracks(NULL)
34 {
35   //ctor
36 }
37
38 //______________________________________________________________________________
39 AliStarEvent::AliStarEvent( Int_t n ):
40   TObject(),
41   fParams(),
42   fTracks(new TObjArray(n) )
43 {
44   //ctor
45 }
46
47 //______________________________________________________________________________
48 AliStarEvent::AliStarEvent( const AliStarEvent& event ):
49   TObject(event),
50   fParams(),
51   fTracks((TObjArray*)(event.fTracks)->Clone())
52 {
53   //copy ctor
54   memcpy(fParams,event.fParams,fgkNparams*sizeof(Float_t));
55 }
56
57 //______________________________________________________________________________
58 AliStarEvent& AliStarEvent::operator=( const AliStarEvent& event )
59 {
60   //assignment
61   if (this == &event) return *this;
62   TObject::operator=(event);
63   memcpy(fParams,event.fParams,fgkNparams*sizeof(Float_t));
64   if (fTracks) fTracks->Delete();
65   delete fTracks;
66   if (event.fTracks)
67     fTracks = (TObjArray*)(event.fTracks)->Clone(); //deep copy
68   return *this;
69 }
70
71 //______________________________________________________________________________
72 void AliStarEvent::SetParams( const Float_t* params )
73 {
74   //set params
75   memcpy(fParams,params,fgkNparams*sizeof(Float_t));
76 }
77
78 //______________________________________________________________________________
79 AliStarEvent::~AliStarEvent()
80 {
81   //dtor
82   if (fTracks) fTracks->Delete();
83   delete fTracks;
84 }
85
86 //______________________________________________________________________________
87 const AliStarTrack* AliStarEvent::GetTrack( const Int_t i ) const
88 {
89   //get track i
90   if (!fTracks) return NULL;
91   return static_cast<AliStarTrack*>(fTracks->At(i));
92 }
93
94 //______________________________________________________________________________
95 void AliStarEvent::AddTrack( AliStarTrack* track )
96 {
97   //add a new track to collection
98   if (!fTracks) return;
99   fTracks->Add(track);
100 }
101
102 //______________________________________________________________________________
103 void AliStarEvent::Reset()
104 {
105   //remove all tracks if any and zero the event information
106   if (!fTracks) 
107   {
108     fTracks=new TObjArray(1024);
109     return;
110   }
111   fTracks->Delete();
112   for (Int_t i=0;i<fgkNparams; i++){fParams[i]=0;}
113 }
114
115 //______________________________________________________________________________
116 void AliStarEvent::Print( Option_t* option ) const
117 {
118   //print info
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" ) ;
122   //
123   Float_t   primaryVertexPosition[3] ;
124
125   Int_t   runId                  = (Int_t)   fParams[0]  ;
126   Int_t   eventNumber            = (Int_t)   fParams[1]  ;     
127   primaryVertexPosition[0]       = (Float_t) fParams[2]  ;  // (cm)
128   primaryVertexPosition[1]       = (Float_t) fParams[3]  ;  // (cm)
129   primaryVertexPosition[2]       = (Float_t) fParams[4]  ;  // (cm)
130   Float_t magneticField          = (Float_t) fParams[5]  ;  // kilogauss
131   Int_t   refMult                = (Int_t)   fParams[6]  ;  // Raw Mult into 0.5 unit: a relative number, not total Mult.
132   Int_t   centralityId           = (Int_t)   fParams[7]  ;  // STAR centrality bin # based on refMult
133   Int_t   numberOfPrimaryTracks  = (Int_t)   fParams[8]  ;  // # of primaries, including FTPC tracks which are not in ntuple
134   Int_t   numberOfParticles      = (Int_t)   fParams[9]  ;  // # of particles passing track cuts, thus in ntuple
135   
136   printf("\n  runId eventNo    VtxX    VtxY    VtxZ  MagFld  refMult  CentBin  #PrimeTrak  #Tracks \n") ;
137   printf("%7d  %6d %7.4f %7.4f %7.3f  %6.3f   %6d   %6d      %6d   %6d \n\n", 
138          runId, eventNumber, primaryVertexPosition[0], primaryVertexPosition[1], primaryVertexPosition[2], 
139          magneticField, refMult, centralityId, numberOfPrimaryTracks, numberOfParticles ) ;
140   
141   //Int_t newCentralityID ;
142   //newCentralityID = Centrality( refMult) ;              // Should be the same as "centralityID" from tape
143   //cout << "Test: should be the same " << newCentralityID << " " << centralityId << endl ;  // JT test
144
145   TString optionstr(option);
146   if (!optionstr.Contains("all")) return;
147   if (!fTracks) return;
148   AliStarTrack* track = static_cast<AliStarTrack*>( fTracks->First() );
149   if (!track) return;
150   track->Print("legend");
151   fTracks->Print();
152 }