/************************************************************************** * 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$ */ // -- // -- // Implementation for TTree output in PHOS DA // for calibrating energy by pi0 and MIP. // -- // -- Author: Hisayuki Torii (Hiroshima Univ.) // -- #include #include #include #include "AliPHOSDATreeDigit.h" #include "AliPHOSDATreeCluster.h" ClassImp(AliPHOSDATreeCluster) //------------------------------------------------------------------------ AliPHOSDATreeCluster::AliPHOSDATreeCluster(const AliPHOSDATreeCluster& cluster): //fEnergy(cluster.fEnergy),fX(cluster.fX),fY(cluster.fY),fZ(cluster.fZ),fNDigits(cluster.fNDigits){ fEnergy(cluster.fEnergy),fRow(cluster.fRow),fCol(cluster.fCol),fNDigits(cluster.fNDigits),fDigits(0){ // Copy Constructor if( fNDigits > 0 ){ fDigits = new AliPHOSDATreeDigit[fNDigits]; int ndigits = fNDigits; while( ndigits-- ){ fDigits[ndigits] = cluster.fDigits[ndigits]; } } else { fDigits = 0; } } //------------------------------------------------------------------------ AliPHOSDATreeCluster& AliPHOSDATreeCluster::operator=(const AliPHOSDATreeCluster& cluster){ // Copy Operator if( fNDigits> 0 ) delete[] fDigits; fEnergy = cluster.fEnergy; fNDigits = cluster.fNDigits; fRow = cluster.fRow; fCol = cluster.fCol; //fX = cluster.fX; //fY = cluster.fY; //fZ = cluster.fZ; if( fNDigits > 0 ){ fDigits = new AliPHOSDATreeDigit[fNDigits]; int ndigits = fNDigits; while( ndigits-- ){ fDigits[ndigits] = cluster.fDigits[ndigits]; } } else { fDigits = 0; } return *this; } //------------------------------------------------------------------------ void AliPHOSDATreeCluster::Print(Option_t *opt) const { // Print out std::cout<<" AliPHOSDATreeCluster:: Energy="<["<["< 0 ) delete[] fDigits; fNDigits = 0; } //------------------------------------------------------------------------ bool AliPHOSDATreeCluster::Append(AliPHOSDATreeDigit& digit){ // Add digit information and sum all energy // if(! digit.IsValid() ){ std::cout<<" AliPHOSDATreeCluster::Append():: Error!! Digit is not valid.."<0 ) delete[] fDigits; fNDigits++; fDigits = newfDigits; fEnergy += digit.GetEnergy(); return true; } //------------------------------------------------------------------------ bool AliPHOSDATreeCluster::Append(AliPHOSDATreeCluster& cluster){ // Add another cluster information and sum all energy // AliPHOSDATreeDigit* newfDigits = new AliPHOSDATreeDigit[fNDigits+cluster.fNDigits]; int ndigits1 = fNDigits; int ndigits2 = cluster.fNDigits; int ndigitsall = ndigits1 + ndigits2; while( ndigitsall-- ){ //std::cout<<" ------ ndigits1:"<0) delete[] fDigits; fDigits = newfDigits; fNDigits += cluster.fNDigits; fEnergy += cluster.GetEnergy(); return true; } //------------------------------------------------------------------------ bool AliPHOSDATreeCluster::IsNeighbor(const AliPHOSDATreeDigit& digit) const{ // Check wether the given digit is neighboring to this cluster. // Return true if yes. bool status = false; int ndigits = fNDigits; while( ndigits-- && !status ){ status = digit.IsNeighbor(fDigits[ndigits]); } return status; } //------------------------------------------------------------------------ bool AliPHOSDATreeCluster::IsNeighbor(const AliPHOSDATreeCluster& cluster) const{ // Check wether the given cluster is neighboring to this cluster. // Return true if yes. bool status = false; int ndigits = fNDigits; while( ndigits-- && !status ){ status = cluster.IsNeighbor(fDigits[ndigits]); } return status; } //------------------------------------------------------------------------ bool AliPHOSDATreeCluster::CalculateProperty(){ // Calculate the hit position // (calculation of dispersion is not valid) fCol = 0; fRow = 0; float totweight = 0; float weight; int ndigits = fNDigits; while( ndigits-- ){ weight = log(fDigits[ndigits].GetEnergy()/fEnergy) + 4.5; //4.5 is for PHOS //std::cout<<" AliPHOSDATreeCluster::CalculateProperty() DEBUG: ndigits="<