+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/* $Id$ */
+
#include "AliHBTFunction.h"
+#include "AliLog.h"
-/* $Id: */
//--------------------------------------------------------------------
//AliHBTFunction
ClassImp( AliHBTFunction )
AliHBTFunction::AliHBTFunction():
- fPairCut(new AliHBTEmptyPairCut()), //dummy cut
- fWriteNumAndDen(kFALSE)
+ fPairCut(new AliAODPairEmptyCut()), //dummy cut
+ fWriteNumAndDen(kFALSE),
+ fAbs(kFALSE)
{
//Default constructor
}
AliHBTFunction::AliHBTFunction(const char* name,const char* title):
TNamed(name,title),
- fPairCut(new AliHBTEmptyPairCut()), //dummy cut
- fWriteNumAndDen(kFALSE)
+ fPairCut(new AliAODPairEmptyCut()), //dummy cut
+ fWriteNumAndDen(kFALSE),
+ fAbs(kFALSE)
{
//Constructor
}
AliHBTFunction::AliHBTFunction(const AliHBTFunction & source):
TNamed(source),
- fPairCut((AliHBTPairCut*)source.fPairCut->Clone()),
- fWriteNumAndDen(source.fWriteNumAndDen)
+ fPairCut((AliAODPairCut*)source.fPairCut->Clone()),
+ fWriteNumAndDen(source.fWriteNumAndDen),
+ fAbs(source.fAbs)
{
// Copy constructor needed by the coding conventions
}
AliHBTFunction::~AliHBTFunction()
{
//destructor
+ AliDebug(1,"Deleting");
delete fPairCut;
}
/******************************************************************/
{
// Assignment needed by the coding conventions
delete fPairCut;
- fPairCut = (AliHBTPairCut*)source.fPairCut->Clone();
+ fPairCut = (AliAODPairCut*)source.fPairCut->Clone();
+ fAbs = source.fAbs;
return * this;
}
-void AliHBTFunction::WriteFunction()
+Int_t AliHBTFunction::WriteFunction()
{
//writes result of the function to file
+ Int_t retval =0;
+ AliDebug(1,"Entering");
if (fWriteNumAndDen)
{
+ AliDebug(1,"Writing Num & Den");
if (GetNumerator()) GetNumerator()->Write();
if (GetDenominator()) GetDenominator()->Write();
+ AliDebug(1,"Writing Num & Den Done");
}
+ AliDebug(1,"Getting Result");
TH1* res = GetResult();
- if (res) res->Write();
+ AliDebug(1,"Getting Result Done");
+
+ if (res)
+ {
+ AliDebug(1,"Writing Result");
+ retval = res->Write();
+ AliDebug(1,"Writing Result Done");
+ }
+ return retval;
}
/******************************************************************/
{
//returns ratio of numerator and denominator
//
- if (AliHBTParticle::GetDebug()>0) Info("GetRatio","Norm. Factor is %f for %s",normfactor,GetName());
+ AliDebug(1,Form("Norm. Factor is %f for %s",normfactor,GetName()));
if (normfactor == 0.0)
{
- Error("GetRatio","Scaling Factor is 0. Null poiner returned");
+ AliError("Scaling Factor is 0. Null poiner returned");
return 0x0;
}
TString str = fName + " ratio";
TH1 *result = (TH1*)GetNumerator()->Clone(str.Data());
+ result->SetDirectory(0x0);
result->SetTitle(str.Data());
}
/******************************************************************/
-void AliHBTFunction::SetPairCut(AliHBTPairCut* cut)
+void AliHBTFunction::SetPairCut(AliAODPairCut* cut)
{
//Sets new Pair Cut. Old one is deleted
//Note that it is created new object instead of simple pointer set
if(!cut)
{
- Error("AliHBTFunction::SetPairCut","argument is NULL");
+ AliError("argument is NULL");
return;
}
delete fPairCut;
- fPairCut = (AliHBTPairCut*)cut->Clone();
+ fPairCut = (AliAODPairCut*)cut->Clone();
}
{
//Iniotializes fctn.: Resets histograms
//In case histograms are not created in ctor, builds with default parameters
+ AliDebug(1,"Entering");
if ( !(GetNumerator()&&GetDenominator()) ) BuildHistos();
GetNumerator()->Reset();
GetDenominator()->Reset();
+
+ GetNumerator()->SetDirectory(0x0);
+ GetDenominator()->SetDirectory(0x0);
+ AliDebug(1,"Done");
+}
+/******************************************************************/
+/******************************************************************/
+/******************************************************************/
+ClassImp(AliHBTCorrelFunction)
+//____________________________________________
+//////////////////////////////////////////////
+//
+// class AliHBTCorrelFunction
+//
+// Base class for correlation fuctions, that is which returns ratio.
+// Stores pointer the created ratio histogram and deletes it when function is deleted
+// created in order to evoid memory leak
+//
+////////////////////////////////////////////////////////
+AliHBTCorrelFunction& AliHBTCorrelFunction::operator=(const AliHBTCorrelFunction& in)
+{
+ //assigment operator
+ if (&in == this) return *this;
+ delete fRatio;
+ fRatio=(in.fRatio)?(TH1*)in.fRatio->Clone():0x0;
+ fRatio->SetDirectory(0x0);
+ return *this;
}
/******************************************************************/
//Calculates the factor that should be used to scale
//quatience of num and den to 1 at tail
- if (AliHBTParticle::GetDebug()>0) Info("Scale","Enetered Scale()");
+ AliDebug(1,"Entered");
if(!num)
{
- Error("Scale","No numerator");
+ AliError("No numerator");
return 0.0;
}
if(!den)
{
- Error("Scale","No denominator");
+ AliError("No denominator");
return 0.0;
}
if(fNBinsToScale < 1)
{
- Error("Scale","Number of bins for scaling is smaller thnan 1");
+ AliError("Number of bins for scaling is smaller than 1");
return 0.0;
}
UInt_t nbins = num->GetNbinsX();
if (fNBinsToScale > nbins)
{
- Error("Scale","Number of bins for scaling is bigger thnan number of bins in histograms");
+ AliError("Number of bins for scaling is bigger thnan number of bins in histograms");
return 0.0;
}
- if (AliHBTParticle::GetDebug()>0) Info("Scale","No errors detected");
+ AliDebug(1,"No errors detected");
- Double_t ratio;
- Double_t sum = 0;
- Int_t n = 0;
+ Double_t densum = 0.0;
+ Double_t numsum = 0.0;
Int_t offset = nbins - fNBinsToScale - 1;
{
if ( num->GetBinContent(i) > 0.0 )
{
- ratio = den->GetBinContent(i)/num->GetBinContent(i);
- sum += ratio;
- n++;
+ densum += den->GetBinContent(i);
+ numsum += num->GetBinContent(i);
}
}
- if(AliHBTParticle::GetDebug() > 0) Info("Scale","sum=%f fNBinsToScale=%d n=%d",sum,fNBinsToScale,n);
+ AliDebug(1,Form("numsum=%f densum=%f fNBinsToScaleX=%d",numsum,densum,fNBinsToScale));
- if (n == 0) return 0.0;
- Double_t ret = sum/((Double_t)n);
+ if (numsum == 0) return 0.0;
+ Double_t ret = densum/numsum;
- if(AliHBTParticle::GetDebug() > 0) Info("Scale","returning %f",ret);
+ AliDebug(1,Form("returning %f",ret));
return ret;
}
// Base Calss for 2-dimensinal Functions //
// //
// Piotr.Skowronski@cern.ch //
-// http://alisoft.cern.ch/people/skowron/analyzer //
+// http://aliweb.cern.ch/people/skowron/analyzer //
// //
///////////////////////////////////////////////////////
// Calculates the factor that should be used to scale
// quatience of fNumerator and fDenominator to 1 at
// given region
- if (AliHBTParticle::GetDebug()>0) Info("Scale","Enetered Scale()");
+ AliDebug(1,"Entered");
if(!fNumerator)
{
- Error("Scale","No numerator");
+ AliError("No numerator");
return 0.0;
}
if(!fDenominator)
{
- Error("Scale","No denominator");
+ AliError("No denominator");
return 0.0;
}
if( (fNBinsToScaleX < 1) || (fNBinsToScaleY < 1) )
{
- Error("Scale","Number of bins for scaling is smaller thnan 1");
+ AliError("Number of bins for scaling is smaller thnan 1");
return 0.0;
}
UInt_t nbinsX = fNumerator->GetNbinsX();
if (fNBinsToScaleX > nbinsX)
{
- Error("Scale","Number of X bins for scaling is bigger thnan number of bins in histograms");
+ AliError("Number of X bins for scaling is bigger thnan number of bins in histograms");
return 0.0;
}
UInt_t nbinsY = fNumerator->GetNbinsX();
if (fNBinsToScaleY > nbinsY)
{
- Error("Scale","Number of Y bins for scaling is bigger thnan number of bins in histograms");
+ AliError("Number of Y bins for scaling is bigger thnan number of bins in histograms");
return 0.0;
}
- if (AliHBTParticle::GetDebug()>0) Info("Scale","No errors detected");
+ AliDebug(1,"No errors detected");
Int_t offsetX = nbinsX - fNBinsToScaleX - 1; //bin that we start loop over bins in axis X
Int_t offsetY = nbinsY - fNBinsToScaleY - 1; //bin that we start loop over bins in axis X
- Double_t ratio;
- Double_t sum = 0;
- Int_t n = 0;
+ Double_t densum = 0.0;
+ Double_t numsum = 0.0;
for (UInt_t j = offsetY; j< nbinsY; j++)
for (UInt_t i = offsetX; i< nbinsX; i++)
{
if ( fNumerator->GetBinContent(i,j) > 0.0 )
{
- ratio = fDenominator->GetBinContent(i,j)/fNumerator->GetBinContent(i,j);
- sum += ratio;
- n++;
+ densum += fDenominator->GetBinContent(i,j);
+ numsum += fNumerator->GetBinContent(i,j);
}
}
- if(AliHBTParticle::GetDebug() > 0) Info("Scale","sum=%f fNBinsToScaleX=%d fNBinsToScaleY=%d n=%d",sum,fNBinsToScaleX,fNBinsToScaleY,n);
+ AliDebug(1,Form("numsum=%f densum=%f fNBinsToScaleX=%d fNBinsToScaleY=%d",
+ numsum,densum,fNBinsToScaleX,fNBinsToScaleY));
- if (n == 0) return 0.0;
- Double_t ret = sum/((Double_t)n);
+ if (numsum == 0) return 0.0;
+ Double_t ret = densum/numsum;
- if(AliHBTParticle::GetDebug() > 0) Info("Scale","returning %f",ret);
+ AliDebug(1,Form("returning %f",ret));
return ret;
}
// Base Calss for 3-dimensinal Functions //
// //
// Piotr.Skowronski@cern.ch //
-// http://alisoft.cern.ch/people/skowron/analyzer //
+// http://aliweb.cern.ch/people/skowron/analyzer //
// //
///////////////////////////////////////////////////////
Int_t nzbins, Float_t zmax, Float_t zmin)
{
//Builds numerator and denominator histograms (3d-case)
+
+ AliDebug(1,"Entered");
+
+ if (fNumerator )
+ {
+ delete fNumerator;
+ fNumerator = 0x0;
+ }
+
+ if (fDenominator )
+ {
+ delete fDenominator;
+ fDenominator = 0x0;
+ }
+
TString numstr = fName + " Numerator"; //title and name of the
//numerator histogram
TString denstr = fName + " Denominator";//title and name of the
//denominator histogram
- fNumerator = new TH3D(numstr.Data(),numstr.Data(),
+ fNumerator = new TH3F(numstr.Data(),numstr.Data(),
nxbins,xmin,xmax,nybins,ymin,ymax,nzbins,zmin,zmax);
- fDenominator = new TH3D(denstr.Data(),denstr.Data(),
+ fDenominator = new TH3F(denstr.Data(),denstr.Data(),
nxbins,xmin,xmax,nybins,ymin,ymax,nzbins,zmin,zmax);
fNumerator->Sumw2();
// Calculates the factor that should be used to scale
// quatience of fNumerator and fDenominator to 1 at
// given volume
- if (AliHBTParticle::GetDebug()>0) Info("Scale","Enetered Scale()");
+ AliDebug(1,"Entered");
if(!fNumerator)
{
- Error("Scale","No numerator");
+ AliError("No numerator");
return 0.0;
}
if(!fDenominator)
{
- Error("Scale","No denominator");
+ AliError("No denominator");
return 0.0;
}
if( (fNBinsToScaleX < 1) || (fNBinsToScaleY < 1) || (fNBinsToScaleZ < 1))
{
- Error("Scale","Number of bins for scaling is smaller thnan 1");
+ AliError("Number of bins for scaling is smaller thnan 1");
return 0.0;
}
UInt_t nbinsX = fNumerator->GetNbinsX();
if (fNBinsToScaleX > nbinsX)
{
- Error("Scale","Number of X bins for scaling is bigger thnan number of bins in histograms");
+ AliError("Number of X bins for scaling is bigger thnan number of bins in histograms");
return 0.0;
}
UInt_t nbinsY = fNumerator->GetNbinsX();
if (fNBinsToScaleY > nbinsY)
{
- Error("Scale","Number of Y bins for scaling is bigger thnan number of bins in histograms");
+ AliError("Number of Y bins for scaling is bigger thnan number of bins in histograms");
return 0.0;
}
UInt_t nbinsZ = fNumerator->GetNbinsZ();
if (fNBinsToScaleZ > nbinsZ)
{
- Error("Scale","Number of Z bins for scaling is bigger thnan number of bins in histograms");
+ AliError("Number of Z bins for scaling is bigger thnan number of bins in histograms");
return 0.0;
}
- if (AliHBTParticle::GetDebug()>0) Info("Scale","No errors detected");
+ AliDebug(1,"No errors detected");
Int_t offsetX = nbinsX - fNBinsToScaleX - 1; //bin that we start loop over bins in axis X
Int_t offsetY = nbinsY - fNBinsToScaleY - 1; //bin that we start loop over bins in axis Y
Int_t offsetZ = nbinsZ - fNBinsToScaleZ - 1; //bin that we start loop over bins in axis Z
- Double_t ratio;
- Double_t sum = 0;
- Int_t n = 0;
+ Double_t densum = 0.0;
+ Double_t numsum = 0.0;
for (UInt_t k = offsetZ; k<nbinsZ; k++)
for (UInt_t j = offsetY; j<nbinsY; j++)
{
if ( fNumerator->GetBinContent(i,j,k) > 0.0 )
{
- ratio = fDenominator->GetBinContent(i,j,k)/fNumerator->GetBinContent(i,j,k);
- sum += ratio;
- n++;
+
+ densum += fDenominator->GetBinContent(i,j,k);
+ numsum += fNumerator->GetBinContent(i,j,k);
}
}
- if(AliHBTParticle::GetDebug() > 0)
- Info("Scale","sum=%f fNBinsToScaleX=%d fNBinsToScaleY=%d fNBinsToScaleZ=%d n=%d",
- sum,fNBinsToScaleX,fNBinsToScaleY,fNBinsToScaleZ,n);
+ AliDebug(1,Form("numsum=%f densum=%f fNBinsToScaleX=%d fNBinsToScaleY=%d fNBinsToScaleZ=%d",
+ numsum,densum,fNBinsToScaleX,fNBinsToScaleY,fNBinsToScaleZ));
- if (n == 0) return 0.0;
- Double_t ret = sum/((Double_t)n);
+ if (numsum == 0) return 0.0;
+ Double_t ret = densum/numsum;
- if(AliHBTParticle::GetDebug() > 0) Info("Scale","returning %f",ret);
+ AliDebug(1,Form("returning %f",ret));
return ret;
}
/******************************************************************/
// one pair to fill function //
// //
// Piotr.Skowronski@cern.ch //
-// http://alisoft.cern.ch/people/skowron/analyzer //
+// http://aliweb.cern.ch/people/skowron/analyzer //
// //
///////////////////////////////////////////////////////
// one pair to fill function //
// //
// Piotr.Skowronski@cern.ch //
-// http://alisoft.cern.ch/people/skowron/analyzer //
+// http://aliweb.cern.ch/people/skowron/analyzer //
// //
///////////////////////////////////////////////////////
// one pair to fill function //
// //
// Piotr.Skowronski@cern.ch //
-// http://alisoft.cern.ch/people/skowron/analyzer //
+// http://aliweb.cern.ch/people/skowron/analyzer //
// //
///////////////////////////////////////////////////////
ClassImp( AliHBTOnePairFctn3D)
// to fill function //
// //
// Piotr.Skowronski@cern.ch //
-// http://alisoft.cern.ch/people/skowron/analyzer //
+// http://aliweb.cern.ch/people/skowron/analyzer //
// //
///////////////////////////////////////////////////////
ClassImp(AliHBTTwoPairFctn1D)
void AliHBTTwoPairFctn1D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
{
// Fills the numerator using pairs from the same event
- partpair = CheckPair(partpair);
- if( partpair )
- {
- Double_t x = GetValue(trackpair,partpair);
- fNumerator->Fill(x);
- }
+ trackpair = CheckPair(trackpair);
+ if( trackpair == 0x0) return;
+
+ Double_t x = GetValue(trackpair,partpair);
+ fNumerator->Fill(x);
}
/******************************************************************/
void AliHBTTwoPairFctn1D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
{
// Fills the denumerator usin mixed pairs
- partpair = CheckPair(partpair);
- if( partpair )
- {
- Double_t x = GetValue(trackpair,partpair);
- fDenominator->Fill(x);
- }
+ trackpair = CheckPair(trackpair);
+ if( trackpair == 0x0) return;
+
+ Double_t x = GetValue(trackpair,partpair);
+ fDenominator->Fill(x);
}
/******************************************************************/
/******************************************************************/
// to fill function //
// //
// Piotr.Skowronski@cern.ch //
-// http://alisoft.cern.ch/people/skowron/analyzer //
+// http://aliweb.cern.ch/people/skowron/analyzer //
// //
///////////////////////////////////////////////////////
void AliHBTTwoPairFctn2D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
{
//processes pair of particles coming from a same events (real pair)
- partpair = CheckPair(partpair); //check cuts
- if( partpair )
- {
- Double_t x,y;
- GetValues(trackpair,partpair,x,y);
- fNumerator->Fill(x,y);
- }
+ trackpair = CheckPair(trackpair);
+ if( trackpair == 0x0) return;
+
+ Double_t x,y;
+ GetValues(trackpair,partpair,x,y);
+ fNumerator->Fill(x,y);
}
/******************************************************************/
void AliHBTTwoPairFctn2D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
{
//processes pair of particles coming from a different events (mixed pair)
- partpair = CheckPair(partpair);
- if( partpair )
- {
- Double_t x,y;
- GetValues(trackpair,partpair,x,y);
- fDenominator->Fill(x,y);
- }
+ trackpair = CheckPair(trackpair);
+ if( trackpair == 0x0) return;
+
+ Double_t x,y;
+ GetValues(trackpair,partpair,x,y);
+ fDenominator->Fill(x,y);
}
/******************************************************************/
// to fill function //
// //
// Piotr.Skowronski@cern.ch //
-// http://alisoft.cern.ch/people/skowron/analyzer //
+// http://aliweb.cern.ch/people/skowron/analyzer //
// //
///////////////////////////////////////////////////////
void AliHBTTwoPairFctn3D::ProcessSameEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
{
// Fills th numerator using pairs from the same event
- partpair = CheckPair(partpair);
- if( partpair )
- {
- Double_t x,y,z;
- GetValues(trackpair,partpair,x,y,z);
- fNumerator->Fill(x,y,z);
- }
+ trackpair = CheckPair(trackpair);
+ if( trackpair == 0x0) return;
+
+ Double_t x,y,z;
+ GetValues(trackpair,partpair,x,y,z);
+ fNumerator->Fill(x,y,z);
+
}
/******************************************************************/
void AliHBTTwoPairFctn3D::ProcessDiffEventParticles(AliHBTPair* trackpair, AliHBTPair* partpair)
{
// Fills the denumerator using mixed pairs
- partpair = CheckPair(partpair);
- if( partpair )
- {
- Double_t x,y,z;
- GetValues(trackpair,partpair,x,y,z);
- fDenominator->Fill(x,y,z);
- }
-
+ trackpair = CheckPair(trackpair);
+ if( trackpair == 0x0) return;
+
+ Double_t x,y,z;
+ GetValues(trackpair,partpair,x,y,z);
+ fDenominator->Fill(x,y,z);
}
/******************************************************************/