Memory leak when passing from one input file to the next corrected.
[u/mrichter/AliRoot.git] / TPC / AliTPCclusterKr.cxx
CommitLineData
f5178f60 1/**************************************************************************\r\r\r * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r\r\r * *\r\r\r * Author: The ALICE Off-line Project. *\r\r\r * Contributors are mentioned in the code where appropriate. *\r\r\r * *\r\r\r * Permission to use, copy, modify and distribute this software and its *\r\r\r * documentation strictly for non-commercial purposes is hereby granted *\r\r\r * without fee, provided that the above copyright notice appears in all *\r\r\r * copies and that both the copyright notice and this permission notice *\r\r\r * appear in the supporting documentation. The authors make no claims *\r\r\r * about the suitability of this software for any purpose. It is *\r\r\r * provided "as is" without express or implied warranty. *\r\r\r **************************************************************************/\r\r\r\r\r\r/* $Id: AliTPCclusterKr.cxx,v 1.7 2008/01/22 17:24:53 matyja Exp $ */\r\r\r\r\r\r//-----------------------------------------------------------------\r\r\r// Implementation of the TPC Kr cluster class\r\r\r//\r\r\r// Origin: Adam Matyja, INP PAN, adam.matyja@ifj.edu.pl\r\r\r//-----------------------------------------------------------------\r\r\r\r\r\r#include "AliTPCclusterKr.h"\r\r\r#include "AliCluster.h"\r\r\r#include "AliTPCvtpr.h"\r\r\r#include "TObjArray.h"\r\r\r//#include "TH1F.h"\r\r\r#include "TMath.h"\r\r\r#include "TArrayI.h"\r\r\r\r\r\rClassImp(AliTPCclusterKr)\r\r\r\r\r\r\r\r\rAliTPCclusterKr::AliTPCclusterKr()\r\r\r:AliCluster(),\r\r\r fMax(),\r\r\r fADCcluster(0),\r\r\r fSec(0),\r\r\r fNPads(0),\r\r\r fNRows(0),\r\r\r fTimebins1D(0),\r\r\r fPads1D(0),\r\r\r fPadRMS(0),\r\r\r fRowRMS(0),\r\r\r fTimebinRMS(0),\r\r\r fSize(0),\r\r\r fCenterX(0),\r\r\r fCenterY(0),\r\r\r fCenterT(0),\r\r\r fCluster(0),\r\r\r fTimeStamp(0),\r fRun(0)\r\r\r{\r\r\r//\r\r\r// default constructor\r\r\r//\r\r\r fCluster=new TObjArray();\r\r\r}\r\r\r\r\r\rAliTPCclusterKr::AliTPCclusterKr(const AliTPCclusterKr &param)\r\r\r:AliCluster(param),\r\r\r fMax(),\r\r\r fADCcluster(0),\r\r\r fSec(0),\r\r\r fNPads(0),\r\r\r fNRows(0),\r\r\r fTimebins1D(0),\r\r\r fPads1D(0),\r\r\r fPadRMS(0),\r\r\r fRowRMS(0),\r\r\r fTimebinRMS(0),\r\r\r fSize(0),\r\r\r fCenterX(0),\r\r\r fCenterY(0),\r\r\r fCenterT(0),\r\r\r fCluster(0),\r\r\r fTimeStamp(0),\r fRun(0)\r\r\r{\r\r\r//\r\r\r// copy constructor\r\r\r//\r\r\r fADCcluster = param.fADCcluster;\r\r\r fSec = param.fSec ;\r\r\r fNPads = param.fNPads;\r\r\r fNRows = param.fNRows;\r\r\r fMax = param.fMax;\r\r\r // fCluster = param.fCluster;\r\r\r fCenterX = param.fCenterX;\r\r\r fCenterY = param.fCenterY;\r\r\r fCenterT = param.fCenterT;\r\r\r fCluster=new TObjArray(*(param.fCluster));\r\r\r fSize = param.fSize;\r\r\r fTimebins1D = param.fTimebins1D;\r\r\r fPads1D = param.fPads1D;\r\r\r fPadRMS = param.fPadRMS;\r\r\r fRowRMS = param.fRowRMS;\r\r\r fTimebinRMS = param.fTimebinRMS;\r\r\r fTimeStamp = param.fTimeStamp;\r fRun = param.fRun;\r\r\r} \r\r\r\r\r\rAliTPCclusterKr &AliTPCclusterKr::operator = (const AliTPCclusterKr & param)\r\r\r{\r\r\r //\r\r\r // assignment operator\r\r\r // \r\r\r (AliCluster&)(*this) = (AliCluster&)param;\r\r\r fADCcluster = param.fADCcluster;\r\r\r fSec = param.fSec ;\r\r\r fNPads = param.fNPads;\r\r\r fNRows = param.fNRows;\r\r\r fMax = param.fMax;\r\r\r // fCluster=param.fCluster;\r\r\r fCenterX = param.fCenterX;\r\r\r fCenterY = param.fCenterY;\r\r\r fCenterT = param.fCenterT;\r\r\r delete fCluster;\r\r\r fCluster=new TObjArray(*(param.fCluster));\r\r\r fSize=param.fSize;\r\r\r fTimebins1D = param.fTimebins1D;\r\r\r fPads1D = param.fPads1D;\r\r\r fPadRMS = param.fPadRMS;\r\r\r fRowRMS = param.fRowRMS;\r\r\r fTimebinRMS = param.fTimebinRMS;\r\r\r fTimeStamp = param.fTimeStamp;\r fRun = param.fRun;\r\r\r return (*this);\r\r\r}\r\r\r\r\r\rAliTPCclusterKr::~AliTPCclusterKr()\r\r\r{\r\r\r //\r\r\r // destructor\r\r\r //\r\r\r if(fCluster) {\r\r\r fCluster->SetOwner(kTRUE);\r\r\r fCluster->Delete();\r\r\r delete fCluster;\r\r\r }\r\r\r fCluster=0;\r\r\r}\r\r\r\r\r\r////____________________________________________________________________________\r\r\rvoid AliTPCclusterKr::SetCenter(){\r\r\r //\r\r\r // calculate geometrical center of the cluster\r\r\r //\r\r\r Double_t rX=0;\r\r\r Double_t rY=0;\r\r\r Double_t rT=0;\r\r\r\r\r\r Short_t adc;\r\r\r fADCcluster=0;\r\r\r for(Int_t iter = 0; iter < fCluster->GetEntriesFast(); ++iter) {\r\r\r AliTPCvtpr *iclus=(AliTPCvtpr *)fCluster->At(iter);\r\r\r\r\r\r //for( std::vector<AliTPCvtpr*>::iterator iclus = fCluster.begin();\r\r\r //iclus != fCluster.end(); ++iclus ) {\r\r\r adc = (iclus)->GetAdc();\r\r\r fADCcluster+=adc;\r\r\r rX += ((iclus)->GetX() * adc);\r\r\r rY += ((iclus)->GetY() * adc);\r\r\r rT += ((iclus)->GetT() * adc);\r\r\r }\r\r\r fCenterX=rX/fADCcluster;\r\r\r fCenterY=rY/fADCcluster;\r\r\r fCenterT=rT/fADCcluster;\r\r\r\r\r\r return;\r\r\r}\r\r\r\r\r\rvoid AliTPCclusterKr::SetPadRMS(){\r\r\r //\r\r\r // calculate RMS in pad direction\r\r\r //\r\r\r // TH1F *histo= new TH1F("","",200,0,200);\r\r\r TArrayI *array= new TArrayI(fCluster->GetEntriesFast());\r\r\r for(Int_t i=0;i<fCluster->GetEntriesFast();i++)\r\r\r {\r\r\r array->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetPad(),i);\r\r\r //histo->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetPad() );\r\r\r }\r\r\r // fPadRMS=histo->GetRMS();\r\r\r fPadRMS=TMath::RMS(array->GetSize(),array->GetArray());\r\r\r // delete histo;\r\r\r delete array;\r\r\r return;\r\r\r}\r\r\r\r\r\rvoid AliTPCclusterKr::SetRowRMS(){\r\r\r //\r\r\r // calculate RMS in row direction\r\r\r //\r\r\r TArrayI *array= new TArrayI(fCluster->GetEntriesFast());\r\r\r // TH1F *histo= new TH1F("","",120,0,120);\r\r\r for(Int_t i=0;i<fCluster->GetEntriesFast();i++)\r\r\r {\r\r\r array->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetRow(),i);\r\r\r // histo->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetRow() );\r\r\r }\r\r\r // fRowRMS=histo->GetRMS();\r\r\r fRowRMS=TMath::RMS(array->GetSize(),array->GetArray());\r\r\r // delete histo;\r\r\r delete array;\r\r\r return;\r\r\r}\r\r\r\r\r\rvoid AliTPCclusterKr::SetTimebinRMS(){\r\r\r //\r\r\r // calculate RMS in timebin direction\r\r\r //\r\r\r TArrayI *array= new TArrayI(fCluster->GetEntriesFast());\r\r\r // TH1F *histo= new TH1F("","",1000,0,1000);\r\r\r for(Int_t i=0;i<fCluster->GetEntriesFast();i++)\r\r\r {\r\r\r array->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetTime(),i);\r\r\r // histo->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetTime() );\r\r\r }\r\r\r fTimebinRMS=TMath::RMS(array->GetSize(),array->GetArray());\r\r\r //histo->GetRMS();\r\r\r // delete histo;\r\r\r delete array;\r\r\r return;\r\r\r}\r\r\r\r\r\rvoid AliTPCclusterKr::SetRMS(){\r\r\r //\r\r\r // calculate RMS in pad,row,timebin direction\r\r\r //\r\r\r TArrayI *arrayPad = new TArrayI(fCluster->GetEntriesFast());\r\r\r TArrayI *arrayRow = new TArrayI(fCluster->GetEntriesFast());\r\r\r TArrayI *arrayTime= new TArrayI(fCluster->GetEntriesFast());\r\r\r // TH1F *histoPad= new TH1F("p","p",200,0,200);\r\r\r // TH1F *histoRow= new TH1F("r","r",120,0,120);\r\r\r // TH1F *histoTime= new TH1F("t","t",1000,0,1000);\r\r\r for(Int_t i=0;i<fCluster->GetEntriesFast();i++)\r\r\r {\r\r\r arrayPad->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetPad(),i);\r\r\r arrayRow->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetRow(),i);\r\r\r arrayTime->SetAt(((AliTPCvtpr *)(fCluster->At(i)))->GetTime(),i);\r\r\r\r\r\r //histoPad->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetPad() );\r\r\r //histoRow->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetRow() );\r\r\r //histoTime->Fill( ((AliTPCvtpr *)(fCluster->At(i)))->GetTime() );\r\r\r }\r\r\r // fPadRMS=histoPad->GetRMS();\r\r\r fPadRMS=TMath::RMS(arrayPad->GetSize(),arrayPad->GetArray());\r\r\r fRowRMS=TMath::RMS(arrayRow->GetSize(),arrayRow->GetArray());\r\r\r //histoRow->GetRMS();\r\r\r fTimebinRMS=TMath::RMS(arrayTime->GetSize(),arrayTime->GetArray());\r\r\r //histoTime->GetRMS();\r\r\r\r\r\r delete arrayPad;\r\r\r delete arrayRow;\r\r\r delete arrayTime;\r\r\r // delete histoPad;\r\r\r // delete histoRow;\r\r\r // delete histoTime;\r\r\r\r\r\r return;\r\r\r}\r\r\r\r\r\r\r\r\rvoid AliTPCclusterKr::Set1D(){\r\r\r //\r\r\r //\r\r\r //\r\r\r Short_t maxTime=0;\r\r\r Short_t minTime=1000;\r\r\r Short_t maxPad=0;\r\r\r Short_t minPad=1000;\r\r\r \r\r\r for(Int_t i=0;i<fCluster->GetEntriesFast();i++)\r\r\r {\r\r\r if(((AliTPCvtpr *)(fCluster->At(i)))->GetPad()>maxPad)maxPad =((AliTPCvtpr *)(fCluster->At(i)))->GetPad();\r\r\r if(((AliTPCvtpr *)(fCluster->At(i)))->GetPad()<minPad)minPad =((AliTPCvtpr *)(fCluster->At(i)))->GetPad();\r\r\r if(((AliTPCvtpr *)(fCluster->At(i)))->GetTime()>maxTime)maxTime=((AliTPCvtpr *)(fCluster->At(i)))->GetTime();\r\r\r if(((AliTPCvtpr *)(fCluster->At(i)))->GetTime()<minTime)minTime=((AliTPCvtpr *)(fCluster->At(i)))->GetTime();\r\r\r }\r\r\r fPads1D=maxPad-minPad+1;\r\r\r fTimebins1D=maxTime-minTime+1;\r\r\r return;\r\r\r}\r\r\r