- will slow down digit maker, but give a significant speed up of the clusterizer at high multiplicities
- also need to always ship the full list of digits, even after clusterisation, but
this is anyway needed if one is to provide AliESDCaloCells in the ESDs
- now sorting the digits
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
for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++)
{
- digit = &(recPoint->fDigits);
- for(iDigit = 0; iDigit < recPoint->fMultiplicity; iDigit++)
+ digit = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Int_t>(fDigitHeaderPtr) + recPoint->fStartDigitOffset);
+ AliHLTPHOSDigitReader reader;
+ reader->SetCurrentDigit(digit);
+ while(digit)
{
-
xi = digit->fX;
zi = digit->fZ;
// cout << "COG digits (x:z:E:time): " << xi << " : " << zi << " : " << digit->fEnergy << " : " << digit->fTime << endl;
z += zi * w ;
wtot += w ;
}
- digit++;
+ digit = reader->NextDigit();
}
- //cout << endl;
if (wtot>0)
{
recPoint->fX = x/wtot ;
UInt_t maxClusterSize = sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t)
AliHLTPHOSRecPointDataStruct* recPointPtr = fRecPointDataPtr;
- AliHLTPHOSDigitDataStruct* digitPtr = &(recPointPtr->fDigits);
+ AliHLTPHOSDigitDataStruct* digitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Int_t>(fDigitHeaderPtr) + recPoint->fStartDigitOffset);
+
+ AliHLTPHOSReader reader;
+ reader.SetCurrentDigit(digitPtr);
AliHLTCaloClusterDataStruct* caloClusterPtr = fCaloClusterDataPtr;
UShort_t* cellIDPtr = &(caloClusterPtr->fCellsAbsId);
cellIDPtr = &(caloClusterPtr->fCellsAbsId);
cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction);
- for(UInt_t j = 0; j < caloClusterPtr->fNCells; j++)
+ while(digitPtr)
{
fPHOSGeometry->RelPosToAbsId((Int_t)(recPointPtr->fModule), (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));
+ digitPtr = reader.NextDigit()
}
caloClusterPtr->fEnergy = recPointPtr->fAmp;
continue;
}
specification = specification|iter->fSpecification;
- fClusterAnalyserPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(iter->fPtr));
- // HLTDebug("Number of rec points: %d", (reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(iter->fPtr))->fNRecPoints);
+ AliHLTPHOSDigitHeaderStruct *digitHeader = reinterpret_cast<AliHLTPHOSDigitHeaderStruct>(iter->fPtr);
+
+ fClusterAnalyserPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(iter->fPtr + sizeof(AliHLTPHOSDigitHeaderStruct) + digitHeader->fNDigits*sizeof(AliHLTPHOSDigitDataStruct)));
if(fDoDeconvolution)
{
fEmcTimeGate(0),
fDigitsInCluster(0),
fDigitContainerPtr(0),
- fMaxDigitIndexDiff(2*NZROWSMOD)
+ fMaxDigitIndexDiff(2*NZROWSMOD),
+ fDigitReader(0)
{
//See header file for documentation
fEmcClusteringThreshold = 0.2;
fEmcMinEnergyThreshold = 0.03;
fEmcTimeGate = 1.e-6 ;
+
+ fDigitReader = new AliHLTPHOSDigitReader();
}//end
}
Int_t
-AliHLTPHOSClusterizer::ClusterizeEvent(UInt_t availableSize, UInt_t& totSize)
+AliHLTPHOSClusterizer::ClusterizeEvent(AliHLTPHOSDigitHeaderStruct *digitHeader, UInt_t availableSize, UInt_t& totSize)
{
//see header file for documentation
Int_t nRecPoints = 0;
fAvailableSize = availableSize;
+ fDigitReader->SetDigitHeader(digitHeader);
+
// UInt_t maxRecPointSize = sizeof(AliHLTPHOSRecPointDataStruct) + (sizeof(AliHLTPHOSDigitDataStruct) << 7); //Reasonable estimate...
//Clusterization starts
- for(UInt_t i = 0; i < fDigitContainerPtr->fNDigits; i++)
+ while((fCurrentDigit = fDigitReader->NextDigit()) != 0)
{
+
fDigitsInCluster = 0;
- if(fDigitContainerPtr->fDigitDataStruct[i].fEnergy < fEmcClusteringThreshold)
+ if(fCurrentDigit.fEnergy < fEmcClusteringThreshold)
{
continue;
}
+
if(fAvailableSize < (sizeof(AliHLTPHOSRecPointDataStruct)))
{
HLTError("Out of buffer, stopping clusterisation");
return -1;
}
- // First digit is placed at the fDigits member variable in the recpoint
- fDigitDataPtr = &(fRecPointDataPtr->fDigits);
+ // Save the starting digit
+ fStartDigit = fCurrentDigit;
+ fPreviousDigit = fStartDigit;
+ // Get the offset of the digit starting the cluster relative to the start of the digit block
+ fRecPointDataPtr->fStartDigitOffset = fDigitReader->GetCurrentDigitOffset();
+ fDigitReader->DropDigit();
fRecPointDataPtr->fAmp = 0;
- fRecPointDataPtr->fModule = fDigitContainerPtr->fDigitDataStruct[i].fModule;
-
- // Assigning digit data to the digit pointer
- fRecPointDataPtr->fDigits = fDigitContainerPtr->fDigitDataStruct[i];
-
- fAvailableSize -= (sizeof(AliHLTPHOSRecPointDataStruct));
+ fRecPointDataPtr->fModule = fCurrentDigit->fModule;
- // Incrementing the pointer to be ready for new entry
- fDigitDataPtr++;
-
- fRecPointDataPtr->fAmp += fDigitContainerPtr->fDigitDataStruct[i].fEnergy;
- fDigitContainerPtr->fDigitDataStruct[i].fEnergy = 0;
+ fRecPointDataPtr->fAmp += fCurrentDigit->fEnergy;
fDigitsInCluster++;
+
nRecPoints++;
// Scanning for the neighbours
- if(ScanForNeighbourDigits(i, fRecPointDataPtr) < 0)
+ if(ScanForNeighbourDigits(fRecPointDataPtr) < 0)
{
return -1;
}
fRecPointDataPtr->fMultiplicity = fDigitsInCluster;
- fRecPointDataPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(fDigitDataPtr);
+ fRecPointDataPtr++;
}//end of clusterization
return nRecPoints;
}
Int_t
-AliHLTPHOSClusterizer::ScanForNeighbourDigits(Int_t index, AliHLTPHOSRecPointDataStruct* recPoint)
+AliHLTPHOSClusterizer::ScanForNeighbourDigits(AliHLTPHOSRecPointDataStruct* recPoint)
{
//see header file for documentation
+
Int_t max = TMath::Min((Int_t)fDigitContainerPtr->fNDigits, (Int_t)fMaxDigitIndexDiff+index);
Int_t min = TMath::Max(0, (Int_t)(index - (Int_t)fMaxDigitIndexDiff));
max = fDigitContainerPtr->fNDigits;
min = 0;
- for(Int_t j = min; j < max; j++)
+
+ fDigitReader->Rewind();
+
+ while((fCurrentDigit = fDigitReader->NextDigit()))
{
- if(fDigitContainerPtr->fDigitDataStruct[j].fEnergy > fEmcMinEnergyThreshold)
+ if(fCurrentDigit->fEnergy > fEmcMinEnergyThreshold)
{
- if(j != index)
+ if(AreNeighbours(fStartDigit, fCurrentDigit))
{
- if(AreNeighbours(&(fDigitContainerPtr->fDigitDataStruct[index]),
- &(fDigitContainerPtr->fDigitDataStruct[j])))
- {
- // Assigning value to digit ptr
- if(fAvailableSize < sizeof(AliHLTPHOSDigitDataStruct))
- {
- HLTError("Out of buffer, stopping clusterisation");
- return -1;
- }
- fAvailableSize -= sizeof(AliHLTPHOSDigitDataStruct);
-
- *fDigitDataPtr = fDigitContainerPtr->fDigitDataStruct[j];
- // Incrementing digit pointer to be ready for new entry
-
- fDigitDataPtr++;
-
- recPoint->fAmp += fDigitContainerPtr->fDigitDataStruct[j].fEnergy;
- fDigitContainerPtr->fDigitDataStruct[j].fEnergy = 0;
- fDigitsInCluster++;
- ScanForNeighbourDigits(j, recPoint);
- }
+ fDigitReader->DropDigit();
+ fPreviousDigit->fMemOffsetNext = reinterpret_cast<Int_t>(fCurrentDigit) - reinterpret_cast<Int_t>(fPreviousDigit);
+ recPoint->fAmp += fCurrentDigit.fEnergy;
+ fDigitsInCluster++;
+ ScanForNeighbourDigits(recPoint);
}
}
}
/** Current available buffer size */
UInt_t fAvailableSize; //COMMENT
+ /** object reading the digit */
+ AliHLTPHOSDigitReader *fDigitReader; //COMMENT
+
ClassDef(AliHLTPHOSClusterizer, 0);
};
UInt_t mysize = 0;
Int_t nRecPoints = 0;
Int_t nDigits = 0;
- Int_t j = 0;
-
+
+ UInt_t availableSize = size;
AliHLTUInt8_t* outBPtr;
outBPtr = outputPtr;
const AliHLTComponentBlockData* iter = 0;
UInt_t specification = 0;
- AliHLTPHOSDigitDataStruct *digitDataPtr = 0;
-
- AliHLTPHOSRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(outBPtr);
+ AliHLTPHOSDigitHeaderStruct *digitHeaderPtr = 0;
+ AliHLTPHOSDigitHeaderStruct *outputDigitHeaderPtr = reinterpret_cast<AliHLTPHOSDigitHeaderStruct*>(outBPtr);
- fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(outBPtr+sizeof(AliHLTPHOSRecPointHeaderStruct)));
+ AliHLTPHOSDigitDataStruct *firstDigitPtr = 0;
+ AliHLTPHOSDigitDataStruct *lastDigitPtr = 0;
+ // Adding together all the digits, should be put in standalone method
for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
{
iter = blocks+ndx;
if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType)
{
+ // Update the number of digits
+ nDigits += digitHeaderPtr->fNDigits;
+
+ // Get the specification
specification = specification|iter->fSpecification;
- nDigits = iter->fSize/sizeof(AliHLTPHOSDigitDataStruct);
- digitDataPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(iter->fPtr);
- for (Int_t i = 0; i < nDigits; i++)
+
+ // Get the digit header
+ digitHeaderPtr = reinterpret_cast<AliHLTPHOSDigitHeaderStruct*>(iter->fPtr);
+
+ // Check if we have the first buffer in the event
+ if(!firstDigitPtr)
+ {
+ if(availableSize < digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct) + sizeof(AliHLTPHOSDigitHeaderStruct))
+ {
+ HLTError("Buffer overflow: Trying to write data of size: %d bytes. Output buffer available: %d bytes.", totSize, size);
+ return -1;
+ }
+ // If so, lets copy the header and the corresponding digits to the output
+ memcpy(outBPtr, iter->fPtr, digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct) + sizeof(AliHLTPHOSDigitHeaderStruct));
+
+ // Set the pointer to the first digit in the list
+ firstDigitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(outBPtr + sizeof(AliHLTPHOSDigitHeaderStruct) + digitHeaderPtr->fFirstDigitOffset);
+
+ lastDigitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(outBPtr + sizeof(AliHLTPHOSDigitHeaderStruct) + digitHeaderPtr->fLastDigitOffset);
+
+ // Update the amount of the output buffer we have used
+ mysize += digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct) + sizeof(AliHLTPHOSDigitHeaderStruct);
+ }
+ else
{
- fAllDigitsPtr->fDigitDataStruct[j].fX = digitDataPtr->fX;
- fAllDigitsPtr->fDigitDataStruct[j].fZ = digitDataPtr->fZ;
- fAllDigitsPtr->fDigitDataStruct[j].fEnergy = digitDataPtr->fEnergy;
- fAllDigitsPtr->fDigitDataStruct[j].fTime = digitDataPtr->fTime;
- fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitDataPtr->fCrazyness;
- fAllDigitsPtr->fDigitDataStruct[j].fModule = digitDataPtr->fModule;
- j++;
- digitDataPtr++;
+ // Check if we have space for
+ if(availableSize < digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct))
+ {
+ HLTError("Buffer overflow: Trying to write data of size: %d bytes. Output buffer available: %d bytes.", totSize, size);
+ return -1;
+ }
+
+ // If we already have copied the first buffer to the output copy only the digits
+ memcpy(outBPtr, (iter->fPtr+sizeof(AliHLTPHOSDigitHeaderStruct)), digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct));
+
+ // Check if the first digit in this buffer has a ID less than the first digit in the previous
+ if(firstDigitPtr->fID > reinterpret_cast<AliHLTPHOSDigitDataStruct*>(iter->fPtr + sizeof(AliHLTPHOSDigitDataStruct) + digitHeaderPtr->fFirstDigitOffset)->fID)
+ {
+ // If that is the case we have to take care of the ordering
+
+ // The last digit in the current buffer has to link to the first digit in the previous buffer
+ lastDigitPtr->fMemOffsetNext = outBPtr + digitHeaderPtr->fFirstDigitOffset - reinterpret_cast<Int_t>(lastDigitPtr);
+
+ // Setting the pointer to the new first digit
+ firstDigitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(outBPtr + digitHeaderPtr->fFirstDigitOffset);
+ }
+ else
+ {
+ // Previous last digit need to link to the current first digit
+ lastDigitPtr->fMemOffsetNext = outBPtr + digitHeaderPtr->fFirstDigitOffset;
+
+ // We need to change the last digit pointer
+ lastDigitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(outBPtr + digitHeaderPtr->fLastDigitOffset);
+ }
+ // Update the amount of the output buffer we have used
+ mysize += digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct);
}
+
+ outBPtr += mysize;
}
}
+
+ // The digit header in the output needs to know about the position of the new first digit (the last digit is still the same)
+ outputDigitHeaderPtr->fFirstDigitOffset = reinterpret_cast<Int_t>(firstDigitPtr) - reinterpret_cast<Int_t>(outputDigitHeaderPtr) + sizeof(AliHLTPHOSDigitHeaderStruct);
+
+ // The digit header in the output needs to know about the position of the new last digit (the first digit is still the same)
+ outputDigitHeaderPtr->fLastDigitOffset = reinterpret_cast<Int_t>(lastDigitPtr) - reinterpret_cast<Int_t>(outputDigitHeaderPtr) + sizeof(AliHLTPHOSDigitHeaderStruct);
+
- fAllDigitsPtr->fNDigits = j;
- HLTDebug("Number of digits: %d", j);
- nRecPoints = fClusterizerPtr->ClusterizeEvent(size, mysize);
+ HLTDebug("Number of digits: %d", nDigits);
- if(nRecPoints == -1)
- {
- HLTError("Running out of buffer, exiting for safety.");
- return -ENOBUFS;
- }
+ AliHLTPHOSRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(outBPtr);
+
+ fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(outBPtr+sizeof(AliHLTPHOSRecPointHeaderStruct)));
+
+ nRecPoints = fClusterizerPtr->ClusterizeEvent(firstDigitPtr, size, mysize);
recPointHeaderPtr->fNRecPoints = nRecPoints;
+
mysize += sizeof(AliHLTPHOSRecPointHeaderStruct);
HLTDebug("Number of clusters: %d", nRecPoints);
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+/**
+ * @struct AliHLTPHOSDigitHeaderStruct
+ * Header used to pass digits around
+ * @ingroup alihlt_phos
+ */
+struct AliHLTPHOSDigitHeaderStruct
+{
+ /** Number of digits */
+ UInt_t fNDigits;
+
+ /** Start pointer */
+ Char_t *fStartPtr;
+
+ /** The relative offset in bytes to the first digit in the list */
+ Int_t fFirstDigitOffset;
+
+ /** The relative offset in bytes to the last digit in the list */
+ Int_t fLastDigitOffset;
+
+};
+
/**
* @struct AliHLTPHOSDigitDataStruct
* Digit struct for PHOS HLT
/** The baseline */
Float_t fBaseline;
+
+ /** Relative offset in memory to next digit */
+ Int_t fMemOffsetNext;
+
+ /** Digit ID */
+ UInt_t fID;
};
-// $Id$
+3// $Id$
/**************************************************************************
* This file is property of and copyright by the ALICE HLT Project *
#include "AliHLTPHOSChannelDataHeaderStruct.h"
#include "AliHLTPHOSDigitDataStruct.h"
#include "AliHLTPHOSSharedMemoryInterfacev2.h" // added by PTH
-#include "AliPHOSEMCAGeometry.h"
#include "TH2F.h"
-
+#include <cstdlib>
ClassImp(AliHLTPHOSDigitMaker);
fDigitStructPtr(0),
fDigitCount(0),
fOrdered(true),
- fMapperPtr(0)
+ fMapperPtr(0),
+ fDigitPtrArray(0)
{
// See header file for documentation
}
}
fMapperPtr = new AliHLTPHOSMapper();
+
+ fDigitPtrArray = new AliHLTPHOSDigitDataStruct*[NZROWSRCU*NXCOLUMNSMOD];
}
AliHLTPHOSDigitMaker::~AliHLTPHOSDigitMaker()
{
//See header file for documentation
+ fAvailableSize = availableSize;
Int_t j = 0;
UInt_t totSize = sizeof(AliHLTPHOSDigitDataStruct);
+
+
// Int_t xMod = -1;
// Int_t zMod = -1;
if(currentchannel->fEnergy < MAXBINVALUE) // Make sure we don't have signal overflow
{
AliHLTPHOSMapper::GetLocalCoord(currentchannel->fChannelID, locCoord);
- AddDigit(currentchannel, coord1, locCoord);
+ if(!AddDigit(currentchannel, coord1, locCoord)) return -1;
j++;
totSize += sizeof(AliHLTPHOSDigitDataStruct);
if(coord2[0] == coord1[0] && coord2[1] == coord1[1]) // It is a low gain channel with the same coordinates, we may use it
{
AliHLTPHOSMapper::GetLocalCoord(currentchannel->fChannelID, locCoord);
- AddDigit(currentchannel, coord2, locCoord);
+ if(!AddDigit(currentchannel, coord2, locCoord)) return -1;
j++;
totSize += sizeof(AliHLTPHOSDigitDataStruct);
currentchannel = fShmPtr->NextChannel();
else // No low gain channel with information about the overflow channel so we just use the overflowed one...
{
AliHLTPHOSMapper::GetLocalCoord(currentchannel->fChannelID, locCoord);
- AddDigit(tmpchannel, coord1, locCoord);
+ if(!AddDigit(tmpchannel, coord1, locCoord)) return -1;
j++;
totSize += sizeof(AliHLTPHOSDigitDataStruct);
// no need to get the next channel here, we already did...
else // Well, there seem to be missing a high gain channel for this crystal, let's use the low gain one
{
AliHLTPHOSMapper::GetLocalCoord(currentchannel->fChannelID, locCoord);
- AddDigit(tmpchannel, coord1, locCoord);
+ if(!AddDigit(tmpchannel, coord1, locCoord)) return -1;
j++;
totSize += sizeof(AliHLTPHOSDigitDataStruct);
currentchannel = fShmPtr->NextChannel();
if(currentchannel->fEnergy < MAXBINVALUE) // To overflow or not to overflow?
{
AliHLTPHOSMapper::GetLocalCoord(currentchannel->fChannelID, locCoord);
- AddDigit(currentchannel, coord2, locCoord);
+ if(!AddDigit(currentchannel, coord2, locCoord)) return -1;
j++;
totSize += sizeof(AliHLTPHOSDigitDataStruct);
currentchannel = fShmPtr->NextChannel();
else // Oh well, better use the low gain channel then
{
AliHLTPHOSMapper::GetLocalCoord(currentchannel->fChannelID, locCoord);
- AddDigit(currentchannelLG, coord1, locCoord);
+ if(!AddDigit(currentchannelLG, coord1, locCoord)) return -1;
j++;
totSize += sizeof(AliHLTPHOSDigitDataStruct);
currentchannel = fShmPtr->NextChannel();
else // No available high gain channel for this crystal, adding the low gain one
{
AliHLTPHOSMapper::GetLocalCoord(currentchannel->fChannelID, locCoord);
- AddDigit(currentchannelLG, coord1, locCoord);
+ if(!AddDigit(currentchannelLG, coord1, locCoord)) return -1;
j++;
totSize += sizeof(AliHLTPHOSDigitDataStruct);
}
else //Fine, no more channels, better add this one...
{
AliHLTPHOSMapper::GetLocalCoord(currentchannelLG->fChannelID, locCoord);
- AddDigit(currentchannelLG, coord1, locCoord);
+ if(!AddDigit(currentchannelLG, coord1, locCoord)) return -1;
j++;
totSize += sizeof(AliHLTPHOSDigitDataStruct);
}
else // Cool, no annoying low gain channel for this channel
{
AliHLTPHOSMapper::GetLocalCoord(currentchannel->fChannelID, locCoord);
- AddDigit(currentchannel, coord1, locCoord);
+ if(!AddDigit(currentchannel, coord1, locCoord)) return -1;
j++;
currentchannel = fShmPtr->NextChannel();
}
}
}
- fDigitCount += j;
return fDigitCount;
}
void
AliHLTPHOSDigitMaker::SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut)
{
+ // See header file for documentation
for(int x = 0; x < NXCOLUMNSMOD; x++)
{
for(int z = 0; z < NZROWSMOD; z++)
}
}
+void
+AliHLTPHOSDigitMaker::SortDigits()
+{
+
+ // See header file for documentation
+ qsort(fDigitPtrArray, fDigitCount, sizeof(AliHLTPHOSDigitDataStruct*), AliHLTPHOSDigitMaker::CompareDigits);
+
+ fDigitHeaderPtr->fFirstDigitOffset = fDigitPtrArray[0] - (fDigitHeaderPtr + sizeof(AliHLTPHOSDigitHeaderStruct));
+ for(Int_t i = 0; i < fDigitCount-1; i++)
+ {
+ fDigitPtrArray[0]->fMemOffsetNext = fDigitPtrArray[i+1] - fDigitPtrArray[i];
+ }
+ fDigitHeaderPtr->fLastDigitOffset = fDigitPtrArray[fDigitCount-1] - (fDigitHeaderPtr + sizeof(AliHLTPHOSDigitHeaderStruct));
+ fDigitPtrArray[fDigitCount-1]->fMemOffsetNext = 0;
+}
+
+Int_t
+AliHLTPHOSDigitMaker::CompareDigits(const void *dig0, const void *dig1)
+{
+ // See header file for documentation
+ return *((AliHLTPHOSDigitDataStruct**)(dig0))->fID - *((AliHLTPHOSDigitDataStruct**)(dig1))->fID;
+}
+
* Sets the pointer to the output
* @param the output pointer
*/
- void SetDigitDataPtr(AliHLTPHOSDigitDataStruct *digitDataPtr)
- { fDigitStructPtr = digitDataPtr; }
+ void SetDigitDataHeaderPtr(AliHLTPHOSDigitHeaderStruct *digitHeaderPtr)
+ {
+ fDigitHeaderPtr = digitHeaderPtr;
+ fDigitStructPtr = digitHeaderPtr + sizeof(AliHLTPHOSDigitHeaderStruct);
+ fDigitHeaderPtr.fStartPtr = reinterpret_cast<Char_t*>(fDigitStructPtr);
+ }
/**
* Set the global high gain conversion factory
* @param channelDataHeader is the data header from the AliHLTPHOSRawAnalyzer
* @return the number of digits found
*/
- Int_t MakeDigits(AliHLTPHOSChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize);
+ Int_t MakeDigits(AliHLTPHOSChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize)
/**
* Set ordering of gains or not
*/
void SetOrdered(bool val) { fOrdered = val; }
-
+
+ /**
+ * Reset the digit maker */
+ */
void Reset() { fDigitCount = 0; }
+ /**
+ * Sort the digits and make internal links between them
+ */
+ void SortDigits();
+
+ /**
+ * Compare two digits, used during the sorting
+ */
+ Int_t CompareDigits(const void *dig0, const void *dig);
+
+
private:
/**
* Add a new digit
* @param channelData is the channel data
* @param coordinates is the coordinates of the channel, including gain and module
+ * @return true if the digit is added correctly, false if out of buffer
*/
- void AddDigit(AliHLTPHOSChannelDataStruct* channelData, UShort_t* channelCoordinates, Float_t* localCoordinates)
+ bool AddDigit(AliHLTPHOSChannelDataStruct* channelData, UShort_t* channelCoordinates, Float_t* localCoordinates)
{
+ if(fAvailableSize < sizeof(AliHLTPHOSDigitDataStruct))
+ {
+ HLTError("Output buffer is full, stopping digit making");
+ return false;
+ }
+
+ fAvailableSize -= sizeof(AliHLTPHOSDigitDataStruct);
fDigitStructPtr->fX = channelCoordinates[0];
fDigitStructPtr->fZ = channelCoordinates[1];
+ fDigitStructPtr->fID = fDigitStructPtr->fZ * NXCOLUMNSRCU + fDigitStructPtr->fX;
+
fDigitStructPtr->fLocX = localCoordinates[0];
fDigitStructPtr->fLocZ = localCoordinates[1];
fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO
fDigitStructPtr->fCrazyness = channelData->fCrazyness;
fDigitStructPtr->fModule = channelCoordinates[3];
+
+ fDigitPtrArray[fDigitCount] = fDigitStructPtr;
+ fDigitCount++;
fDigitStructPtr++;
}
/** Bad channel mask */
Float_t fBadChannelMask[NXCOLUMNSMOD][NZROWSMOD][NGAINS]; //COMMENT
+ /** Array of digit pointers */
+ AliHLTPHOSDigitDataStruct **fDigitPtrArray; //COMMENT
+
+ /** The available size of the output buffer */
+ AliHLTUInt32_t fAvailableSize; //COMMENT
ClassDef(AliHLTPHOSDigitMaker, 0);
static void GetChannelCoord(const UShort_t channelId, UShort_t* channelCoord);
static void ChannelId2Coordinate(const UShort_t channelId, AliHLTPHOSCoordinate &channelCoord );
static void GetLocalCoord(const UShort_t channelId, Float_t* localCoord);
- int GetDDLFromSpec(Int_t specification);
+ static int GetDDLFromSpec(Int_t specification);
int GetModuleFromSpec(Int_t specification);
struct fAltromap{
-//-*- Mode: C++ -*-
+\//-*- Mode: C++ -*-
// $Id$
/** Distance to nearest bad channel */
Float_t fDistanceToBadChannel; //COMMENT
- /** Digits in the rec point */
- AliHLTPHOSDigitDataStruct fDigits; //COMMENT
+ /**
+ * Digit offset for the first digit in the
+ * rec point.
+ */
+ Int_t fStartDigitOffset; //COMMENT
};