// $Id$ //************************************************************************** //* This file is property of and copyright by the ALICE HLT Project * //* ALICE Experiment at CERN, All rights reserved. * //* * //* Primary Authors: Matthias Richter * //* Sergey Gorbunov * //* for The ALICE HLT Project. * //* * //* 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. * //************************************************************************** // @file AliHLTTPCHWClusterMerger.cxx // @author Matthias Richter, Sergey Gorbunov // @date 2011-11-25 // @brief Merger class for HLT TPC Hardware clusters // Handles merging of branch border clusters #include #include "AliHLTTPCHWClusterMerger.h" #include "AliHLTTPCTransform.h" #include "AliHLTTPCSpacePointData.h" #include "AliHLTTPCHWCFSupport.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTTPCHWClusterMerger) AliHLTTPCHWClusterMerger::AliHLTTPCHWClusterMerger() : AliHLTLogging() , fMapping(0) , fNRows(0) , fNRowPads(0) , fNBorders(0) , fBorders(0) , fBorderNClusters(0) , fBorderFirstCluster(0) , fBorderClusters(0) , fBorderNClustersTotal(0) , fClusters() , fRemovedClusterIds() , fIter() , fEnd() { // see header file for class documentation // or // refer to README to build package // or // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt // constructor } AliHLTTPCHWClusterMerger::~AliHLTTPCHWClusterMerger() { // destructor delete[] fMapping; delete [] fBorders; delete[] fBorderNClusters; delete[] fBorderFirstCluster; delete[] fBorderClusters; } void AliHLTTPCHWClusterMerger::Init() { // initialisation delete[] fMapping; delete[] fBorders; delete[] fBorderNClusters; delete[] fBorderFirstCluster; delete[] fBorderClusters; fMapping = 0; fBorders = 0; fBorderNClusters = 0; fBorderFirstCluster = 0; fBorderClusters = 0; fBorderNClustersTotal = 0; fNRows = AliHLTTPCTransform::GetNRows(); fNRowPads = 0; fNBorders = 0; for( int i=0; i>8) & 0x3F; int pad = configWord & 0xFF; bool border = (configWord>>14) & 0x1; if( !border ) continue; row+=AliHLTTPCTransform::GetFirstRow(iPart); if( row>fNRows ) continue; if( pad>=AliHLTTPCTransform::GetNPads(iPart) ) continue; fMapping[row*fNRowPads + pad] = -2; } } std::vector vBorders; for( int row=0; row=fNRowPads || m[pad+1+i]!=-1 ) break; m[pad+1+i] = fNBorders+1; } fNBorders+=2; vBorders.push_back(pad+1.); vBorders.push_back(pad+1.); } } } //cout<<" NBorders = "<=0 ) { cout<= fNRows ) return 0; int iPad = (int) pad; if( iPad<0 || iPad>=fNRowPads ) return 0; int atBorder = fMapping[slicerow*fNRowPads+iPad]; if( atBorder<0 ) return 0; float dPad = pad - fBorders[atBorder]; if( sigmaPad2>1.e-4 ){ if( dPad*dPad > 12.*sigmaPad2 ) return 0; } else { if( fabs(dPad)>1. ) return 0; } return 1; } int AliHLTTPCHWClusterMerger::AddCandidate(int slice, int partition, short partitionrow, float pad, float time, float sigmaY2, float sigmaZ2, unsigned short charge, unsigned short qmax, AliHLTUInt32_t id, const AliHLTTPCClusterMCLabel *mc ) { /// add a candidate for merging and register in the index grid int iBorder = -1; int iPad = (int) pad; if( !fMapping ) Init(); int slicerow=partitionrow+AliHLTTPCTransform::GetFirstRow(partition); if (id!=~AliHLTUInt32_t(0)) { if (slice<0) { slice=AliHLTTPCSpacePointData::GetSlice(id); } else if ((unsigned)slice!=AliHLTTPCSpacePointData::GetSlice(id)) { HLTError("cluster id 0x%08x is not consistent with specified slice %d", id, slice); } if (partition<0) { partition=AliHLTTPCSpacePointData::GetPatch(id); } else if ((unsigned)partition!=AliHLTTPCSpacePointData::GetPatch(id)) { HLTError("cluster id 0x%08x is not consistent with specified partition %d", id, partition); } } if( slice<0 || slice>=fkNSlices ){ HLTError("cluster id 0x%08x has wrong slice number %d", id, slice); } if( partition<0 || partition>=6 ){ HLTError("cluster id 0x%08x has wrong partition number %d", id, partition); } if( slice>=0 && slice=0 && slicerow =0 && iPad < fNRowPads ){ iBorder = fMapping[slicerow*fNRowPads+iPad]; if( iBorder>=0 ){ float dPad = pad - fBorders[iBorder]; if( sigmaY2>1.e-4 ){ if( dPad*dPad > 12.*sigmaY2 ) iBorder = -1; } else { if( fabs(dPad)>1. ) iBorder = -1; } } if( iBorder>=0 ) iBorder = slice*fNBorders + iBorder; } fClusters.push_back(AliClusterRecord(slice, partition, iBorder, -1, id, AliHLTTPCRawCluster(partitionrow, pad, time, sigmaY2, sigmaZ2, charge, qmax), mc!=NULL?*mc:AliHLTTPCClusterMCLabel() )); if( iBorder>=0 ){ fBorderNClusters[iBorder]++; fBorderNClustersTotal++; } return fClusters.size()-1; } int AliHLTTPCHWClusterMerger::FillIndex() { /// loop over cached raw clusters and fill index delete[] fBorderClusters; fBorderClusters = 0; fBorderClusters = new AliBorderRecord[fBorderNClustersTotal]; fBorderFirstCluster[0] = 0; for(int i=1; i0) && (n2>0); if( prn ){ cout<<"Border "<border2[ib2].fTimeBin+fkMergeTimeWindow ){ ib1++; } if( ib1>= n1 ) break; if( border1[ib1].fTimeBin < border2[ib2].fTimeBin-fkMergeTimeWindow) continue; // merge c2->c1 //if( prn ) cout<<"merge "<"<