]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowCommon/AliStarTrack.cxx
coverity fix (Ruben)
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliStarTrack.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   AliStarTrack: Event container for flow analysis
18
19   origin:   Mikolaj Krzewicki  (mikolaj.krzewicki@cern.ch)
20 *****************************************************************/
21
22 #include <string.h>
23 #include <TObject.h>
24 #include <TString.h>
25 #include "AliStarTrack.h"
26
27 ClassImp(AliStarTrack)
28
29 //______________________________________________________________________________
30 AliStarTrack::AliStarTrack():
31   TObject(),
32   fParams()
33 {
34   //ctor
35 }
36
37 //______________________________________________________________________________
38 AliStarTrack::AliStarTrack( const Float_t* params ):
39   TObject(),
40   fParams()
41 {
42   //ctor
43   memcpy(fParams,params,fgkNparams*sizeof(Float_t));
44 }
45
46 //______________________________________________________________________________
47 AliStarTrack::AliStarTrack( const AliStarTrack& track ):
48   TObject(),
49   fParams()
50 {
51   //copy ctor
52   memcpy(fParams,track.fParams,fgkNparams*sizeof(Float_t));
53 }
54
55 //______________________________________________________________________________
56 AliStarTrack& AliStarTrack::operator=( const AliStarTrack& track )
57 {
58   //assignment
59   if (this == &track) return *this;
60   TObject::operator=(track);
61   memcpy(fParams,track.fParams,fgkNparams*sizeof(Float_t));
62   return *this;
63 }
64
65 //______________________________________________________________________________
66 void AliStarTrack::SetParams( const Float_t* params )
67 {
68   //set params
69   memcpy(fParams,params,fgkNparams*sizeof(Float_t));
70 }
71
72 //______________________________________________________________________________
73 AliStarTrack* AliStarTrack::Clone( const char* /*option*/) const
74 {
75   //clone "constructor"
76   return new AliStarTrack(*this);
77 }
78
79 //______________________________________________________________________________
80 void AliStarTrack::Print( Option_t* option ) const
81 {
82   // print info
83   // TNtuple* track: names are documented in the next 2 lines
84   // tracks = new TNtuple("tracks","tracks",
85   //   "ID:Charge:Eta:Phi:Pt:Dca:nHits:nHitsFit:nHitsPoss:nHitsDedx:dEdx:nSigElect:nSigPi:nSigK:nSigProton" ) ;
86   //
87   TString optionstr(option);
88   if ( optionstr.Contains("legend") )
89   {
90     printf(
91           "    id charge     eta     phi      pt     dca  nHits  nFit nPoss ndEdx   dEdx nSigElec nSigPi  nSigK nSigPr\n") ;
92     return;
93   }
94
95   Int_t   id             = (Int_t)   fParams[0]   ;  // id - a unique integer for each track in this event 
96   Int_t   charge         = (Int_t)   fParams[1]   ;  // +1 or -1 
97   Float_t eta            = (Float_t) fParams[2]   ;  // Pseudo-rapidity at the vertex
98   Float_t phi            = (Float_t) fParams[3]   ;  // Phi emission angle at the vertexcd 
99   Float_t pt             = (Float_t) fParams[4]   ;  // Pt of the track at the vertex
100   Float_t dca            = (Float_t) fParams[5]   ;  // Magnitude of 3D DCA to vertex
101   Int_t   nHits          = (Int_t)   fParams[6]   ;  // Number of clusters available to the Kalman Filter
102   Int_t   nHitsFit       = (Int_t)   fParams[7]   ;  // Number of clusters used in the fit (after cuts)
103   Int_t   nHitsPoss      = (Int_t)   fParams[8]   ;  // Number of possible cluster on track (theoretical max) 
104   Int_t   nHitsDedx      = (Int_t)   fParams[9]   ;  // Number of clusters used in the fit (after dEdx cuts)
105   Float_t dEdx           = 1.e6*(Float_t)fParams[10]  ;  // Measured dEdx (Note: GeV/cm so convert to keV/cm!!)
106   Float_t nSigmaElectron = (Float_t) fParams[11]  ;  // Number of sigma from electron Bethe-Bloch curve
107   Float_t nSigmaPion     = (Float_t) fParams[12]  ;  // Number of sigma from pion Bethe-Bloch curve
108   Float_t nSigmaKaon     = (Float_t) fParams[13]  ;  // Number of sigma from kaon Bethe-Bloch curve
109   Float_t nSigmaProton   = (Float_t) fParams[14]  ;  // Number of sigma from proton Bethe-Bloch curve
110   
111   // Alternative way to access the data 
112   // nHitsPoss      = (Int_t) ( fTracks->GetLeaf("nHitsPoss")->GetValue() ) ;  // Note alternative method to retrieve data
113   // Using the definition of the original NTuple
114   // TrackTuple      = new TNtuple("NTtracks","NTtracks",
115   // "ID:Charge:Eta:Phi:Pt:Dca:nHits:nHitsFit:nHitsPoss:nHitsDedx:dEdx:nSigElect:nSigPi:nSigK:nSigProton" ) 
116   
117   printf("%6d %4d   %7.3f %7.3f %7.3f %7.4f %6d %5d %5d %5d %6.2f   %6.2f %6.2f %6.2f %6.2f \n",
118          id, charge, eta, phi, pt, dca, nHits, nHitsFit, nHitsPoss, nHitsDedx, dEdx,
119          nSigmaElectron, nSigmaPion, nSigmaKaon, nSigmaProton ) ;
120 }
121
122 //______________________________________________________________________________
123 Int_t AliStarTrack::PID() const
124 {
125   // Note: This is a very simple PID selection scheme.  More elaborate methods (with multiple cuts) may be required.
126   // When you *are* using dEdx information, you must chose a finite number of good Dedx hits ... but the limit should
127   // be about 2/3 of nHitsMin.  This is because some clusters do not form good dEdx hits due to track
128   // merging, etc., and so nHitsDedx is always less than nHitsFit.  A rule of thumb says ~2/3 ratio.
129
130   Int_t pid = 0 ;
131
132   const Int_t   nHitDedxMin =    15  ;       // 10 to 20 is typical.  nHitDedxMin is often chosen to be about 2/3 of nHitMin.
133   const Float_t nSigmaPID   =    2.0 ;       // Number of Sigma cut to apply to PID bands
134
135   // Test on Number of dE/dx hits required, return 0 if not enough hits
136   if ( GetNHitsDedx() <  nHitDedxMin ) return pid;
137
138   // Begin PID
139
140   if ( TMath::Abs( GetNSigElect() ) >= nSigmaPID )
141   {
142     if ( TMath::Abs( GetNSigK()  ) <= nSigmaPID )
143     {
144       pid = 321  ;
145     }
146     if ( TMath::Abs( GetNSigProton()  ) <= nSigmaPID )
147     {
148       pid = 2212 ;
149     }
150     if ( TMath::Abs( GetNSigPi()  ) <= nSigmaPID )
151     {
152       pid = 211  ;
153     }
154   }
155
156   // Pion is the default in case of ambiguity because it is most abundent. Don't re-arrange order, above.
157
158   return pid ;
159 }
160