#include "AliHLTPHOSClusterAnalyser.h"
#include "AliHLTPHOSRecPointHeaderStruct.h"
#include "AliHLTPHOSRecPointDataStruct.h"
-#include "AliHLTPHOSCaloClusterHeaderStruct.h"
-#include "AliHLTPHOSCaloClusterDataStruct.h"
-#include "AliHLTPHOSPhysicsAnalyzerSpectrum.h"
-#include "AliPHOSGeometry.h"
+#include "AliHLTCaloClusterDataStruct.h"
+#include "AliHLTPHOSPhysicsAnalyzer.h"
+#include "AliHLTPHOSDigitReader.h"
+#include "AliPHOSGeoUtils.h"
+#include "AliESDCaloCluster.h"
#include "TMath.h"
+#include "TVector3.h"
ClassImp(AliHLTPHOSClusterAnalyser);
AliHLTPHOSClusterAnalyser::AliHLTPHOSClusterAnalyser() :
- AliHLTPHOSBase(),
- fLogWeight(0),
+ // AliHLTPHOSBase(),
+ fLogWeight(4.5),
fRecPointDataPtr(0),
fNRecPoints(0),
fCaloClusterDataPtr(0),
fCaloClusterHeaderPtr(0),
fPHOSGeometry(0),
- fAnalyzerPtr(0),
fDoClusterFit(false),
fHaveCPVInfo(false),
fDoPID(false),
- fHaveDistanceToBadChannel(false)
+ fHaveDistanceToBadChannel(false),
+ fDigitHeaderPtr(0)
{
//See header file for documentation
- fLogWeight = 4.5;
-
- fAnalyzerPtr = new AliHLTPHOSPhysicsAnalyzerSpectrum();
- fPHOSGeometry = AliPHOSGeometry::GetInstance("noCPV");
}
AliHLTPHOSClusterAnalyser::~AliHLTPHOSClusterAnalyser()
}
void
-AliHLTPHOSClusterAnalyser::SetCaloClusterDataPtr(AliHLTPHOSCaloClusterDataStruct *caloClusterDataPtr)
+AliHLTPHOSClusterAnalyser::SetCaloClusterDataPtr(AliHLTCaloClusterDataStruct *caloClusterDataPtr)
{
//see header file for documentation
fCaloClusterDataPtr = caloClusterDataPtr;
}
void
-AliHLTPHOSClusterAnalyser::SetRecPointDataPtr(AliHLTPHOSRecPointHeaderStruct *recPointDataPtr)
+AliHLTPHOSClusterAnalyser::SetRecPointDataPtr(AliHLTPHOSRecPointHeaderStruct *recPointDataPtr, AliHLTPHOSDigitHeaderStruct *digitHeaderPtr)
{
fNRecPoints = recPointDataPtr->fNRecPoints;
+
fRecPointDataPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(reinterpret_cast<Char_t*>(recPointDataPtr)+sizeof(AliHLTPHOSRecPointHeaderStruct));
+ fDigitHeaderPtr = digitHeaderPtr;
}
Int_t
//AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
AliHLTPHOSRecPointDataStruct *recPoint = fRecPointDataPtr;
-
- UInt_t iDigit = 0;
-
+ // UInt_t iDigit = 0;
+ if(!recPoint) return 0;
for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++)
{
- digit = &(recPoint->fDigits);
- for(iDigit = 0; iDigit < recPoint->fMultiplicity; iDigit++)
+ // cout << "CA: start digit offset: " << recPoint->fStartDigitOffset << endl;
+ digit = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<UChar_t*>(fDigitHeaderPtr) + recPoint->fStartDigitOffset);
+ // cout << "CA: digit offset: " << digit->fMemOffsetNext << endl;
+ AliHLTPHOSDigitReader reader;
+ reader.SetNextDigit(digit);
+ while(digit)
{
-
xi = digit->fX;
zi = digit->fZ;
- //cout << "COG digits (x:z:amp:time): " << xi << " : " << zi << " : " << digit->fEnergy << " : " << digit->fTime << endl;
+ // cout << "COG digits (x:z:E:time): " << xi << " : " << zi << " : " << digit->fEnergy << " : " << digit->fTime << endl;
if (recPoint->fAmp > 0 && digit->fEnergy > 0)
{
Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ;
z += zi * w ;
wtot += w ;
}
- digit++;
+ digit = reader.NextDigit();
}
- //cout << endl;
if (wtot>0)
{
recPoint->fX = x/wtot ;
recPoint->fZ = z/wtot ;
}
+
else
{
recPoint->fAmp = 0;
}
- recPoint = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digit);
- }
+ recPoint++;
+}
+
+
return 0;
}
}
Int_t
-AliHLTPHOSClusterAnalyser::CalculateClusterMoments(AliHLTPHOSRecPointDataStruct */*recPointPtr*/, AliHLTPHOSCaloClusterDataStruct* /*clusterPtr*/)
+AliHLTPHOSClusterAnalyser::CalculateClusterMoments(AliHLTPHOSRecPointDataStruct */*recPointPtr*/, AliHLTCaloClusterDataStruct* /*clusterPtr*/)
{
//See header file for documentation
return 0;
{
//See header file for documentation
- UInt_t maxClusterSize = sizeof(AliHLTPHOSCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t)
+ UInt_t maxClusterSize = sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t)
AliHLTPHOSRecPointDataStruct* recPointPtr = fRecPointDataPtr;
- AliHLTPHOSDigitDataStruct* digitPtr = &(recPointPtr->fDigits);
-
- AliHLTPHOSCaloClusterDataStruct* caloClusterPtr = fCaloClusterDataPtr;
- UShort_t* cellIDPtr = &(caloClusterPtr->fCellsAbsId);
- Float_t* cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction);
-
- Float_t localPos[2];
+ AliHLTPHOSDigitDataStruct* digitPtr = 0;
- Float_t globalPos[3];
- Int_t id = -1;
+ AliHLTPHOSDigitReader reader;
+
+ AliHLTCaloClusterDataStruct* caloClusterPtr = fCaloClusterDataPtr;
- //fPHOSGeometry = AliPHOSGeometry::GetInstance("noCPV");
+ //Int_t id = -1;
+ TVector3 globalPos;
- for(Int_t i = 0; i < fNRecPoints; i++) //CRAP needs fix when we start unfolding
+ for(Int_t i = 0; i < fNRecPoints; i++) //TODO needs fix when we start unfolding (number of clusters not necessarily same as number of recpoints gotten from the clusterizer
{
-
+ digitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(fDigitHeaderPtr) + recPointPtr->fStartDigitOffset);
+ reader.SetNextDigit(digitPtr);
+
if(availableSize < (totSize + maxClusterSize))
{
return -1; //Might get out of buffer, exiting
}
- localPos[0] = recPointPtr->fX;
- localPos[1] = recPointPtr->fZ;
-
- fAnalyzerPtr->GlobalPosition( localPos, globalPos, recPointPtr->fModule);
+ fPHOSGeometry->Local2Global(recPointPtr->fModule, recPointPtr->fX, recPointPtr->fZ, globalPos);
caloClusterPtr->fGlobalPos[0] = globalPos[0];
caloClusterPtr->fGlobalPos[1] = globalPos[1];
caloClusterPtr->fGlobalPos[2] = globalPos[2];
-
- //cout << "Local Position (x:z:module): " << localPos[0] << " : "<< localPos[1] << " : " << recPointPtr->fModule << endl;
-
- //cout << "Global Position (x:y:z): " << globalPos[0] << " : "<< globalPos[1] << " : " << globalPos[2] << endl << endl;
-
+ cout << "Global position: " << globalPos[0] << ", " << globalPos[1] << ", " << globalPos[2] << endl;
caloClusterPtr->fNCells = recPointPtr->fMultiplicity;
- cellIDPtr = &(caloClusterPtr->fCellsAbsId);
- cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction);
-
- for(UInt_t j = 0; j < caloClusterPtr->fNCells; j++)
+ while(digitPtr)
{
- // fPHOSGeometry->RelPosToAbsId((Int_t)(recPointPtr->fModule + 1), (double)(digitPtr->fX), (double)(digitPtr->fZ), id);
- *cellIDPtr = id;
- *cellAmpFracPtr = digitPtr->fEnergy/recPointPtr->fAmp;
- digitPtr++;
- cellIDPtr = reinterpret_cast<UShort_t*>(reinterpret_cast<char*>(cellAmpFracPtr) + sizeof(Float_t));
- cellAmpFracPtr = reinterpret_cast<Float_t*>(reinterpret_cast<char*>(cellIDPtr) + sizeof(Short_t));
}
caloClusterPtr->fEnergy = recPointPtr->fAmp;
-
+
if(fDoClusterFit)
{
FitCluster(recPointPtr);
caloClusterPtr->fFitQuality = 0;
caloClusterPtr->fM20 = 0;
caloClusterPtr->fM02 = 0;
- // caloClusterPtr->fM11 = 0;
+
}
if(fHaveCPVInfo)
{
caloClusterPtr->fDistanceToBadChannel = -1;
}
- caloClusterPtr->fClusterType = '\0';
- totSize += sizeof(AliHLTPHOSCaloClusterDataStruct) + (caloClusterPtr->fNCells)*(sizeof(Short_t) +sizeof(Float_t)-1);
+ caloClusterPtr->fClusterType = (AliESDCaloCluster::kPHOSCluster);
+
+ totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
- caloClusterPtr = reinterpret_cast<AliHLTPHOSCaloClusterDataStruct*>(cellAmpFracPtr);
- recPointPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digitPtr);
- digitPtr = &(recPointPtr->fDigits);
- }
+ // recPointPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digitPtr);
+ recPointPtr++;
+ }
+
return fNRecPoints;
}