1 /*************************************************************************
2 * Copyright(c) 1998-2009, 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 **************************************************************************/
17 // Dielectron helper functions wrapped in a namespace
21 // Jens Wiechula <Jens.Wiechula@cern.ch>
29 #include <TObjString.h>
30 #include <TObjArray.h>
33 #include <AliVEvent.h>
34 #include <AliKFParticle.h>
36 #include "AliDielectronHelper.h"
38 //_____________________________________________________________________________
39 TVectorD* AliDielectronHelper::MakeLogBinning(Int_t nbinsX, Double_t xmin, Double_t xmax)
42 // Make logarithmic binning
43 // the user has to delete the array afterwards!!!
47 if (xmin<1e-20 || xmax<1e-20){
48 Error("AliDielectronHelper::MakeLogBinning","For Log binning xmin and xmax must be > 1e-20. Using linear binning instead!");
49 return AliDielectronHelper::MakeLinBinning(nbinsX, xmin, xmax);
56 TVectorD *binLim=new TVectorD(nbinsX+1);
59 Double_t expMax=TMath::Log(last/first);
60 for (Int_t i=0; i<nbinsX+1; ++i){
61 (*binLim)[i]=first*TMath::Exp(expMax/nbinsX*(Double_t)i);
66 //_____________________________________________________________________________
67 TVectorD* AliDielectronHelper::MakeLinBinning(Int_t nbinsX, Double_t xmin, Double_t xmax)
70 // Make linear binning
71 // the user has to delete the array afterwards!!!
78 TVectorD *binLim=new TVectorD(nbinsX+1);
81 Double_t binWidth=(last-first)/nbinsX;
82 for (Int_t i=0; i<nbinsX+1; ++i){
83 (*binLim)[i]=first+binWidth*(Double_t)i;
88 //_____________________________________________________________________________
89 TVectorD* AliDielectronHelper::MakeArbitraryBinning(const char* bins)
92 // Make arbitrary binning, bins separated by a ','
96 Error("AliDielectronHelper::MakeArbitraryBinning","Bin Limit string is empty, cannot add the variable");
100 TObjArray *arr=limits.Tokenize(",");
101 Int_t nLimits=arr->GetEntries();
103 Error("AliDielectronHelper::MakeArbitraryBinning","Need at leas 2 bin limits, cannot add the variable");
108 TVectorD *binLimits=new TVectorD(nLimits);
109 for (Int_t iLim=0; iLim<nLimits; ++iLim){
110 (*binLimits)[iLim]=(static_cast<TObjString*>(arr->At(iLim)))->GetString().Atof();
117 //_____________________________________________________________________________
118 void AliDielectronHelper::RotateKFParticle(AliKFParticle * kfParticle,Double_t angle, const AliVEvent * const ev){
119 // Before rotate needs to be moved to position 0,0,0, ; move back after rotation
120 if (!kfParticle) return;
126 dx = ev->GetPrimaryVertex()->GetX()-0.;
127 dy = ev->GetPrimaryVertex()->GetY()-0.;
128 dz = ev->GetPrimaryVertex()->GetZ()-0.;
131 kfParticle->X() = kfParticle->GetX() - dx;
132 kfParticle->Y() = kfParticle->GetY() - dy;
133 kfParticle->Z() = kfParticle->GetZ() - dz;
136 // Rotate the kf particle
137 Double_t c = cos(angle);
138 Double_t s = sin(angle);
141 for( Int_t i=0; i<8; i++ ){
142 for( Int_t j=0; j<8; j++){
146 for( int i=0; i<8; i++ ){
149 mA[0][0] = c; mA[0][1] = s;
150 mA[1][0] = -s; mA[1][1] = c;
151 mA[3][3] = c; mA[3][4] = s;
152 mA[4][3] = -s; mA[4][4] = c;
157 for( Int_t i=0; i<8; i++ ){
159 for( Int_t k=0; k<8; k++){
160 mAp[i]+=mA[i][k] * kfParticle->GetParameter(k);
164 for( Int_t i=0; i<8; i++){
165 kfParticle->Parameter(i) = mAp[i];
168 for( Int_t i=0; i<8; i++ ){
169 for( Int_t j=0; j<8; j++ ){
171 for( Int_t k=0; k<8; k++ ){
172 mAC[i][j]+= mA[i][k] * kfParticle->GetCovariance(k,j);
177 for( Int_t i=0; i<8; i++ ){
178 for( Int_t j=0; j<=i; j++ ){
180 for( Int_t k=0; k<8; k++){
181 xx+= mAC[i][k]*mA[j][k];
183 kfParticle->Covariance(i,j) = xx;
187 kfParticle->X() = kfParticle->GetX() + dx;
188 kfParticle->Y() = kfParticle->GetY() + dy;
189 kfParticle->Z() = kfParticle->GetZ() + dz;