+++ /dev/null
-// @(#) $Id: AliHLTTPCHWClusterFinderEmulator.cxx 45447 2010-11-14 21:05:13Z sgorbuno $
-
-//**************************************************************************
-//* This file is property of and copyright by the ALICE HLT Project *
-//* ALICE Experiment at CERN, All rights reserved. *
-//* *
-//* Primary Authors: Anders Vestbo, Constantin Loizides *
-//* Developers: Kenneth Aamodt <kenneth.aamodt@student.uib.no> *
-//* Kalliopi Kanaki *
-//* 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 AliHLTTPCHWClusterFinderEmulator.cxx
-// @author Kenneth Aamodt, Kalliopi Kanaki
-// @date
-// @brief Cluster Finder for the TPC
-// @note
-
-#include "AliHLTTPCHWClusterFinderEmulator.h"
-#include "AliHLTTPCClusterMCLabel.h"
-
-
-//#include <sys/time.h>
-#include <algorithm>
-//#include <cmath>
-
-#if __GNUC__ >= 3
-using namespace std;
-#endif
-
-#include "AliHLTTPCMapping.h"
-
-
-AliHLTTPCHWClusterFinderEmulator::AliHLTTPCHWClusterFinderEmulator()
- :
- fDeconvTime(0),
- fDeconvPad(0),
- fSlice(0),
- fPatch(0),
- fMapping(0)
-{
- //constructor
-}
-
-AliHLTTPCHWClusterFinderEmulator::~AliHLTTPCHWClusterFinderEmulator()
-{
- //destructor
- delete fMapping;
-}
-
-AliHLTTPCHWClusterFinderEmulator::AliHLTTPCHWClusterFinderEmulator(const AliHLTTPCHWClusterFinderEmulator&)
- :
- fDeconvTime(0),
- fDeconvPad(0),
- fSlice(0),
- fPatch(0),
- fMapping(0)
-{
- // dummy
-}
-
-AliHLTTPCHWClusterFinderEmulator& AliHLTTPCHWClusterFinderEmulator::operator=(const AliHLTTPCHWClusterFinderEmulator&)
-{
- // dummy
- return *this;
-}
-
-void AliHLTTPCHWClusterFinderEmulator::Init( int slice, int patch )
-{
- fSlice = slice;
- fPatch = patch;
- delete fMapping;
- fMapping = new AliHLTTPCMapping(fPatch);
-}
-
-
-struct AliHLTTPCHWCFClusterFragment
-{
- AliHLTTPCHWCFClusterFragment():fQ(0),fT(0),fT2(0),fP(0),fP2(0),fTMean(0),fMC(){}
- AliHLTUInt64_t fQ, fT, fT2, fP, fP2, fTMean;
- vector<AliHLTInt32_t> fMC;
-};
-
-int AliHLTTPCHWClusterFinderEmulator::FindClusters( const AliHLTUInt32_t *rawEvent,
- AliHLTUInt64_t rawEventSize32,
- AliHLTUInt32_t *output,
- AliHLTUInt64_t &outputSize32,
- const AliHLTInt32_t *mcLabels,
- AliHLTTPCClusterMCData *outputMC
- )
-{
- enum{ kWaitForNextChannel, kReadChannel, kForwardRCU, kStop };
-
- AliHLTTPCHWCFClusterFragment emptyFragment;
- emptyFragment.fQ = 0;
- emptyFragment.fT = 0;
- emptyFragment.fT2 = 0;
- emptyFragment.fP = 0;
- emptyFragment.fP2 = 0;
- emptyFragment.fTMean = 0;
-
- AliHLTTPCClusterMCWeight emptyWeight = {-1,0};
-
- AliHLTTPCClusterMCLabel emptyMC = {{emptyWeight,emptyWeight,emptyWeight}};
-
-
- AliHLTUInt64_t maxOutputSize32 = outputSize32;
- outputSize32 = 0;
- if( outputMC ) outputMC->fCount = 0;
-
- if( !fMapping ) return -1;
- if( !rawEvent ) return -2;
-
- // Initialise
-
- AliHLTTPCHWCFClusterFragment *arrFragments = new AliHLTTPCHWCFClusterFragment[kMaxNTimeBins*2];
- if( !arrFragments ) return -3;
-
- AliHLTTPCHWCFClusterFragment *searchRange = arrFragments;
- AliHLTTPCHWCFClusterFragment *insertRange = arrFragments + kMaxNTimeBins;
-
- Int_t searchNFragments = 0;
- Int_t insertNFragments = 0;
- Int_t insertRow = 0;
- Int_t insertPad = 0;
- Int_t insertBranch = -1;
- Int_t channelNWords = 0;
- Int_t channelIWord = 0;
- Int_t bunchNSignalsLeft = 0;
- Int_t bunchTime = 0;
- Int_t iMCLabel = 0;
- Int_t status = kWaitForNextChannel;
-
- int ret = 0;
-
- // Read the data, word by word
-
- for( AliHLTUInt64_t iWord=0; iWord<=rawEventSize32; iWord++ ){
-
- Int_t newRow = insertRow;
- Int_t newPad = insertPad;
- Bool_t newBranch = insertBranch;
-
- Int_t nRangesToFlush = 0;
-
- AliHLTUInt32_t word = 0;
-
- if( iWord==rawEventSize32 ){ // end of data
- nRangesToFlush = 2;
- status = kStop;
- } else {
- word = rawEvent[iWord];
- }
-
- UShort_t flag = (word >> 30);
-
- if( flag > 1 && (status==kWaitForNextChannel || status==kReadChannel) ){
-
- // RCU trailer received, stop the clusterfinder and forward the trailer
- //cout<<"RCU trailer received, stop the clusterfinder and forward the trailer"<<endl;
- nRangesToFlush = 2;
- status = kForwardRCU;
-
- } else if( flag==1 && (status==kWaitForNextChannel || status==kReadChannel) ){
-
- // header of a new channel
- Short_t hwAddress = word & 0xFFF;
- newBranch = (hwAddress >> 11) & 0x1;
- newRow = fMapping->GetRow(hwAddress);
- newPad = fMapping->GetPad(hwAddress);
-
- //cout<<"header of a new channel: "<<newRow<<" "<<newPad<<endl;
-
- // merge and flush search range, flush insert range in case there is a gap in pads
-
- nRangesToFlush = 1;
- if( newRow!=insertRow || newPad!=insertPad+1 || newBranch!=insertBranch ) nRangesToFlush = 2;
-
- channelNWords = (word >> 16) & 0x3FF; // payload size in 10-bit words
- channelIWord = 0;
- status = kReadChannel;
- if( (word >> 29) & 0x1 ) status = kWaitForNextChannel; // there were readout errors
-
- } else if( flag==0 && status==kReadChannel ){
-
- // bunch data, read three 10-bit words
-
- for( int ishift=20; ishift>=0; ishift-=10 ){
-
- if( ++channelIWord > channelNWords ){ // look for next channel
- //cout<<"wrong N channel words"<<endl;
- status = kWaitForNextChannel;
- break;
- }
-
- AliHLTTPCHWCFClusterFragment &f = insertRange[insertNFragments];
-
- AliHLTUInt64_t word10 = (word >> ishift) & 0x3FF;
-
- if( bunchNSignalsLeft <=0 ){ // start new bunch
- f = emptyFragment;
- bunchNSignalsLeft = ((Int_t)word10) - 1;
- bunchTime = -1;
- } else { // add data to the current bunch
- if( bunchTime <0 ){ // time has not been read so far
- bunchTime = word10;
- bunchNSignalsLeft--;
- f.fTMean = bunchTime + ( 1 - bunchNSignalsLeft )/2;
- } else { // add the signal
- AliHLTUInt64_t q = word10<<kFixedPoint;
- f.fQ += q;
- f.fT += q*bunchTime;
- f.fT2+= q*bunchTime*bunchTime;
- f.fP += q*insertPad;
- f.fP2+= q*insertPad*insertPad;
- if( mcLabels ) f.fMC.push_back(mcLabels[iMCLabel++]);
- bunchNSignalsLeft--;
- bunchTime--;
- if( bunchNSignalsLeft<=0 ){
- //cout<<"finish bunch "<<f.fP/f.fQ<<" "<<f.fT/f.fQ<<" "<<f.fQ<<endl;
- insertNFragments++; // current bunch is finished
- }
- }
- }
- }
- }
-
-
-
- if( nRangesToFlush>0 ){
-
- if( bunchNSignalsLeft>0 ){ // Should not happen, the data is corrupted. Finish the last bunch
- insertRange[insertNFragments].fTMean += bunchNSignalsLeft /2;
- insertNFragments++;
- bunchNSignalsLeft = 0;
- }
-
- // do 2D merging and write the output
-
- for( int iPad=0; iPad<nRangesToFlush; iPad++ ){
-
- int iSearch = 0;
-
- //cout<<"Flush row "<<insertRow<<" pad "<<insertPad-1+iPad<<":"<<endl;
- for( int iInsert=0; iInsert<=insertNFragments && iSearch<searchNFragments; iInsert++){
-
- // last iteration (iInsert==insertNFragments) to store fragments from the search range
-
- AliHLTTPCHWCFClusterFragment &f = insertRange[iInsert];
-
- while(iSearch<searchNFragments){
-
- AliHLTTPCHWCFClusterFragment &s = searchRange[iSearch];
-
- if( (iInsert==insertNFragments) || (s.fTMean > f.fTMean) ){ // store the fragment
- //cout<<"store "<< s.fP/s.fQ<<" "<<s.fT/s.fQ<<" "<<s.fQ<<endl;
- if( outputSize32+5 <= maxOutputSize32 ){
- AliHLTUInt32_t *c = &output[outputSize32];
- AliHLTUInt64_t q = s.fQ>>kFixedPoint;
- if( q>0 ){
- c[0] = (((AliHLTUInt32_t) 0x3)<<30) + ((insertRow &0x3f)<<24) + ((s.fQ>>(kFixedPoint-6))&0xFFFFFF);
- *((AliHLTFloat32_t*)&c[1]) = ((AliHLTFloat32_t)(s.fP/q))/(1<<kFixedPoint);
- *((AliHLTFloat32_t*)&c[2]) = ((AliHLTFloat32_t)(s.fT/q))/(1<<kFixedPoint);
- *((AliHLTFloat32_t*)&c[3]) = ((AliHLTFloat32_t)(s.fT2/q))/(1<<kFixedPoint);
- *((AliHLTFloat32_t*)&c[4]) = ((AliHLTFloat32_t)(s.fP2/q))/(1<<kFixedPoint);
- outputSize32+=5;
- if( mcLabels && outputMC ){
- AliHLTTPCClusterMCLabel &mc = outputMC->fLabels[outputMC->fCount];
- mc = emptyMC;
- sort(s.fMC.begin(), s.fMC.end() );
- int ilab = -1;
- int jlab = -1;
- for( UInt_t i=0; i<s.fMC.size(); i++ ){
- if( s.fMC[i]==-1 ) continue;
- if( ilab>=0 && s.fMC[i]==jlab ){
- mc.fClusterID[ilab].fWeight++;
- } else {
- if( ilab>=2 ) break;
- ilab++;
- jlab = s.fMC[i];
- mc.fClusterID[ilab].fMCID = jlab;
- mc.fClusterID[ilab].fWeight = 1;
- }
- }
- outputMC->fCount++;
- }
- }
- } else ret = -4;// No space in the output buffer
-
- } else if( s.fTMean == f.fTMean ){ // merge two fragments
- //cout<<"merge "<< s.fP/s.fQ<<" "<<s.fT/s.fQ<<" "<<s.fQ<<endl;
-
- f.fQ += s.fQ;
- f.fT += s.fT;
- f.fT2 += s.fT2;
- f.fP += s.fP;
- f.fP2 += s.fP2;
- f.fMC.insert(f.fMC.end(), s.fMC.begin(), s.fMC.end());
- } else break; // go to the next fragment in the insert range
-
- iSearch++;
- }
- }
-
- // swap insert and search ranges
-
- searchNFragments = insertNFragments;
- insertNFragments = 0;
- AliHLTTPCHWCFClusterFragment *tmp = searchRange;
- searchRange = insertRange;
- insertRange = tmp;
- }
- }
-
- if( status==kForwardRCU && flag>1 && outputSize32<maxOutputSize32 ){
- output[outputSize32++] = word;
- }
-
- insertRow = newRow;
- insertPad = newPad;
- insertBranch = newBranch;
- }
-
- delete[] arrFragments;
-
- return ret;
-}
-
+++ /dev/null
-// @(#) $Id: AliHLTTPCHWClusterFinderEmulator.h 43577 2010-09-15 09:08:42Z sgorbuno $
-// Original: AliHLTClustFinderNew.h,v 1.13 2004/06/18 10:55:26 loizides
-
-#ifndef ALIHLTTPCHWCLUSTERFINDEREMULATOR_H
-#define ALIHLTTPCHWCLUSTERFINDEREMULATOR_H
-//* This file is property of and copyright by the ALICE HLT Project *
-//* ALICE Experiment at CERN, All rights reserved. *
-//* See cxx source for full Copyright notice *
-
-// @file AliHLTTPCHWClusterFinderEmulator.h
-// @author Anders Vestbo, Constantin Loizides
-// Kenneth Aamodt kenneth.aamodt@student.uib.no
-// @brief HLT Cluster Finder for the TPC
-// @note
-
-#include "Rtypes.h"
-#include "AliHLTDataTypes.h"
-
-
-class AliHLTTPCMapping;
-class AliHLTTPCClusterMCData;
-
-/**
- * @class AliHLTTPCHWClusterFinderEmulator
- *
- * @ingroup alihlt_tpc
- */
-class AliHLTTPCHWClusterFinderEmulator
-{
- public:
-
- /** standard constructor */
- AliHLTTPCHWClusterFinderEmulator();
-
- /** destructor */
- virtual ~AliHLTTPCHWClusterFinderEmulator();
-
- /** setters */
- void SetDeconvPad(Bool_t f) {fDeconvPad=f;}
- void SetDeconvTime(Bool_t f) {fDeconvTime=f;}
-
- void Init( int slice, int patch );
-
- /** Loops over all rows finding the clusters */
-
- int FindClusters( const AliHLTUInt32_t *buffer,
- AliHLTUInt64_t bufferSize32,
- AliHLTUInt32_t *output,
- AliHLTUInt64_t &outputSize32,
- const Int_t *mcLabels,
- AliHLTTPCClusterMCData *outputMC
- );
-
- protected:
-
- /** copy constructor prohibited */
- AliHLTTPCHWClusterFinderEmulator(const AliHLTTPCHWClusterFinderEmulator&);
- /** assignment operator prohibited */
- AliHLTTPCHWClusterFinderEmulator& operator=(const AliHLTTPCHWClusterFinderEmulator&);
-
- Bool_t fDeconvTime; //! deconv in time direction
- Bool_t fDeconvPad; //! deconv in pad direction
-
-
- public :
-
- static const int kMaxNTimeBins = 1024+1; //
- static const int kFixedPoint = 12; // bits for fixed point operations
-
- private:
-
- Int_t fSlice;
- Int_t fPatch;
-
-
- AliHLTTPCMapping *fMapping;
-};
-#endif
+++ /dev/null
-// $Id: AliHLTTPCHWClusterFinderEmulatorComponent.cxx 48710 2011-03-24 12:14:53Z richterm $
-
-//**************************************************************************
-//* This file is property of and copyright by the ALICE HLT Project *
-//* ALICE Experiment at CERN, All rights reserved. *
-//* *
-//* Primary Authors: Timm Steinbeck, Matthias Richter *
-//* Developers: Kenneth Aamodt <kenneth.aamodt@student.uib.no> *
-//* 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 AliHLTTPCHWClusterFinderEmulatorComponent.cxx
- @author Kenneth Aamodt <kenneth.aamodt@student.uib.no>
- @date
- @brief The TPC cluster finder processing component
-*/
-
-#if __GNUC__>= 3
-using namespace std;
-#endif
-#include "AliHLTTPCHWClusterFinderEmulatorComponent.h"
-#include "AliHLTTPCHWClusterFinderSupport.h"
-#include "AliHLTTPCHWClusterFinderEmulator.h"
-#include "AliHLTTPCSpacePointData.h"
-#include "AliHLTTPCClusterDataFormat.h"
-#include "AliHLTTPCTransform.h"
-#include "AliHLTTPCClusters.h"
-#include "AliHLTTPCDefinitions.h"
-#include "AliGRPObject.h"
-#include "AliCDBEntry.h"
-#include "AliCDBManager.h"
-#include "AliTPCcalibDB.h"
-#include "AliTPCCalPad.h"
-#include "AliTPCParam.h"
-#include "AliTPCTransform.h"
-#include "AliRawDataHeader.h"
-#include "AliHLTTPCClusterMCLabel.h"
-
-#include <cstdlib>
-#include <cerrno>
-#include "TString.h"
-#include "TObjString.h"
-#include "TObjArray.h"
-#include "AliCDBEntry.h"
-#include "AliCDBManager.h"
-#include "AliCDBStorage.h"
-#include "TGeoGlobalMagField.h"
-#include "AliGeomManager.h"
-
-#include <sys/time.h>
-
-
-AliHLTTPCHWClusterFinderEmulatorComponent::AliHLTTPCHWClusterFinderEmulatorComponent()
- :
- fClusterFinder(NULL),
- fDeconvTime(kFALSE),
- fDeconvPad(kFALSE),
- fClusterDeconv(false),
- fPatch(0),
- fGetActivePads(0),
- fFirstTimeBin(-1),
- fLastTimeBin(-1),
- fDoMC(kFALSE),
- fReleaseMemory( kFALSE ),
- fBenchmark("TPCHWClusterFinderEmulator")
-{
- // see header file for class documentation
- // or
- // refer to README to build package
- // or
- // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
-}
-
-AliHLTTPCHWClusterFinderEmulatorComponent::~AliHLTTPCHWClusterFinderEmulatorComponent()
-{
- // see header file for class documentation
-}
-
-// Public functions to implement AliHLTComponent's interface.
-// These functions are required for the registration process
-
-const char* AliHLTTPCHWClusterFinderEmulatorComponent::GetComponentID()
-{
- // see header file for class documentation
- return "TPCHWClusterFinderEmulator";
-}
-
-void AliHLTTPCHWClusterFinderEmulatorComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
-{
- // see header file for class documentation
- list.clear();
- list.push_back( AliHLTTPCDefinitions::fgkUnpackedRawDataType );
- list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
-}
-
-AliHLTComponentDataType AliHLTTPCHWClusterFinderEmulatorComponent::GetOutputDataType()
-{
- // see header file for class documentation
- return kAliHLTMultipleDataType;
-}
-
-int AliHLTTPCHWClusterFinderEmulatorComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
-
-{
- // see header file for class documentation
- tgtList.clear();
- tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
- tgtList.push_back(kAliHLTDataTypeHwAddr16);
- //tgtList.push_back(AliHLTTPCCADefinitions::fgkCompressedInputDataType);
- return tgtList.size();
-}
-
-void AliHLTTPCHWClusterFinderEmulatorComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
-{
- // see header file for class documentation
- // XXX TODO: Find more realistic values.
- constBase = 0;
- inputMultiplier = (6 * 0.4);
-}
-
-AliHLTComponent* AliHLTTPCHWClusterFinderEmulatorComponent::Spawn()
-{
- // see header file for class documentation
- return new AliHLTTPCHWClusterFinderEmulatorComponent();
-}
-
-int AliHLTTPCHWClusterFinderEmulatorComponent::DoInit( int argc, const char** argv )
-{
- // see header file for class documentation
- if ( fClusterFinder )
- return -EINPROGRESS;
-
- fClusterFinder = new AliHLTTPCHWClusterFinderEmulator();
-
- TObject* pOCDBEntry=LoadAndExtractOCDBObject("GRP/GRP/Data");
- AliGRPObject* pGRP=pOCDBEntry?dynamic_cast<AliGRPObject*>(pOCDBEntry):NULL;
- TString beamType;
- if (pGRP) {
- beamType=pGRP->GetBeamType();
- }
-
- // first configure the default
- int iResult = 0;
- /*
- TString cdbPath="HLT/ConfigTPC/";
- cdbPath+=GetComponentID();
- iResult=ConfigureFromCDBTObjString(cdbPath, beamType.Data());
- */
-
- // configure from the command line parameters if specified
- if (iResult>=0 && argc>0)
- iResult=ConfigureFromArgumentString(argc, argv);
- // return iResult;
-
- /*
- Int_t iResult=0;
- TString configuration="";
- TString argument="";
- for (int i=0; i<argc && iResult>=0; i++) {
- argument=argv[i];
- if (!configuration.IsNull()) configuration+=" ";
- configuration+=argument;
- }
-
- if (!configuration.IsNull()) {
- iResult=Configure(configuration.Data());
- } else {
- iResult=Reconfigure(NULL, NULL);
- }
- */
-
-
- fClusterFinder->SetDeconvPad(fDeconvPad);
- fClusterFinder->SetDeconvTime(fDeconvPad);
-
- fBenchmark.Reset();
- fBenchmark.SetTimer(0,"total");
- fBenchmark.SetTimer(1,"reco");
-
- return iResult;
-}
-
-int AliHLTTPCHWClusterFinderEmulatorComponent::DoDeinit()
-{
- // see header file for class documentation
-
- if ( fClusterFinder )
- delete fClusterFinder;
- fClusterFinder = NULL;
-
- return 0;
-}
-
-struct AliHLTTPCHCWEmulationDigitData{
- UInt_t fSignal;//signal
- UInt_t fTime; // time
- Int_t fLabel[3];//MC label
-};
-
-bool CompareDigits( const AliHLTTPCHCWEmulationDigitData &a, const AliHLTTPCHCWEmulationDigitData &b){
- return a.fTime < b.fTime;
-}
-
-int AliHLTTPCHWClusterFinderEmulatorComponent::DoEvent( const AliHLTComponentEventData& evtData,
- const AliHLTComponentBlockData* blocks,
- AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
- AliHLTUInt32_t& size,
- vector<AliHLTComponentBlockData>& outputBlocks )
-{
- // see header file for class documentation
-
- int iResult=0;
- AliHLTUInt32_t maxSize = size;
- size = 0;
-
- //fTS->SetCurrentTimeStamp(GetTimeStamp());
- //fTS->SetCurrentTimeStamp(0);
-
- if(!IsDataEvent()){
- return 0;
- }
-
- fBenchmark.StartNewEvent();
- fBenchmark.Start(0);
-
- for ( unsigned long ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
- {
- const AliHLTComponentBlockData* iter = blocks+ndx;
-
- if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)
- && iter->fDataType != AliHLTTPCDefinitions::fgkUnpackedRawDataType ) continue;
-
- int slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
- int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
-
- const char *str=Form("slice %d patch %d:", slice, patch);
-
- fBenchmark.AddInput(iter->fSize);
-
- if (!iter->fPtr) continue;
-
- // create input block for the HW cluster finder
-
- const AliHLTUInt32_t *rawEvent=0;
- const AliHLTInt32_t *mcLabels = 0;
- AliHLTUInt64_t rawEventSize32 = 0;
- AliHLTUInt64_t mcLabelsSize32 = 0;
-
- AliHLTTPCHWClusterFinderSupport supp;
-
- if( supp.CreateRawEvent( iter, rawEvent, rawEventSize32, mcLabels, mcLabelsSize32 )<0 ) continue;
-
- // book memory for the output
-
- AliHLTUInt64_t maxNClusters = rawEventSize32 + 1; // N 32-bit words in input
- AliHLTUInt64_t clustersSize32 = maxNClusters*5;
- AliHLTUInt64_t nOutputMC = maxNClusters;
-
- AliHLTUInt64_t headerSize = sizeof(AliRawDataHeader);
- AliHLTUInt8_t *outBlock = new AliHLTUInt8_t[ headerSize+clustersSize32*sizeof(AliHLTUInt32_t) ];
-
- AliHLTTPCClusterMCData *outMC = reinterpret_cast<AliHLTTPCClusterMCData *>(new AliHLTTPCClusterMCLabel[nOutputMC+1]);
-
- if( !outBlock || !outMC ){
- HLTWarning("%s Not enouth memory!!!", str);
- delete[] outBlock;
- delete[] outMC;
- continue;
- }
-
- // fill CDH header here, since the HW clusterfinder does not receive it
-
- AliRawDataHeader *cdhHeader = reinterpret_cast<AliRawDataHeader*>(iter->fPtr);
- AliRawDataHeader *outCDHHeader = reinterpret_cast<AliRawDataHeader*>(outBlock);
- *outCDHHeader = *cdhHeader;
- outCDHHeader->fSize = 0xFFFFFFFF;
-
- AliHLTUInt32_t *outClusters = reinterpret_cast<AliHLTUInt32_t*> (outBlock + headerSize);
-
- fBenchmark.Start(1);
-
- fClusterFinder->Init(slice, patch );
-
- int err = fClusterFinder->FindClusters( rawEvent, rawEventSize32,
- outClusters, clustersSize32,
- mcLabels,
- outMC );
- //cout<<"HCF finished with error code "<<err<<endl;
- fBenchmark.Stop(1);
- /*
- for( AliHLTUInt64_t i=0; i<clustersSize32; i+=5 ){
- AliHLTUInt32_t *c = outClusters+i;
- AliHLTUInt32_t flag = (c[0]>>30);
- cout<<flag<<endl;
- if( flag == 0x3){ //beginning of a cluster
- int padRow = (c[0]>>24)&0x3f;
- int q = (c[0]&0xFFFFFF)>>6;
- Float_t tmpPad = *((Float_t*)&c[1]);
- Float_t tmpTime = *((Float_t*)&c[2]);
- //Float_t sigmaY2 = *((Float_t*)&c[3]);
- //Float_t sigmaZ2 = *((Float_t*)&c[4]);
- cout<<i<<" r "<<padRow<<" p,t ["<<tmpPad<<","<<tmpTime<<"] q "<<q<<endl;
- if( outMC && outMC->fCount>0 ){
- cout<<"mc"<<
- " ("<<outMC->fLabels[i/5].fClusterID[0].fMCID<<" "<<outMC->fLabels[i/5].fClusterID[0].fWeight<<")"
- " ("<<outMC->fLabels[i/5].fClusterID[1].fMCID<<" "<<outMC->fLabels[i/5].fClusterID[1].fWeight<<")"
- " ("<<outMC->fLabels[i/5].fClusterID[2].fMCID<<" "<<outMC->fLabels[i/5].fClusterID[2].fWeight<<")"
-
- <<endl;
- }
- }
- }
- */
-
- AliHLTUInt64_t outSize = headerSize + clustersSize32*sizeof(AliHLTUInt32_t);
-
- if( size + outSize <= maxSize ){
-
- memcpy( outputPtr, outBlock, outSize );
-
- AliHLTComponentBlockData bd;
- FillBlockData( bd );
- bd.fOffset = size;
- bd.fSize = outSize;
- bd.fSpecification = iter->fSpecification;
- bd.fDataType = AliHLTTPCDefinitions::fgkHWClustersDataType | kAliHLTDataOriginTPC;
- outputBlocks.push_back( bd );
- fBenchmark.AddOutput(bd.fSize);
- size+= outSize;
- outputPtr+=outSize;
- } else {
- HLTWarning( "Output buffer (%db) is too small, required %db", maxSize, size+outSize);
- iResult=-ENOSPC;
- }
-
-
- delete[] outBlock;
- delete[] outMC;
- //delete[] rawEvent;
- //delete[] mcLabels;
- }
-
- fBenchmark.Stop(0);
- HLTInfo(fBenchmark.GetStatistics());
- return iResult;
-}
-
-
-int AliHLTTPCHWClusterFinderEmulatorComponent::ScanConfigurationArgument(int argc, const char** argv){
-
- // see header file for class documentation
-
- if (argc<=0) return 0;
- int i=0;
- TString argument=argv[i];
-
- if (argument.CompareTo("-solenoidBz")==0){
- if (++i>=argc) return -EPROTO;
- HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
- return 2;
- }
-
- if (argument.CompareTo("-deconvolute-time")==0){
- HLTDebug("Switching on deconvolution in time direction.");
- fDeconvTime = kTRUE;
- fClusterFinder->SetDeconvTime(fDeconvTime);
- return 1;
- }
-
- if (argument.CompareTo("-deconvolute-pad")==0){
- HLTDebug("Switching on deconvolution in pad direction.");
- fDeconvPad = kTRUE;
- fClusterFinder->SetDeconvPad(fDeconvPad);
- return 1;
- }
-
- if (argument.CompareTo("-first-timebin")==0){
- if (++i>=argc) return -EPROTO;
- argument=argv[i];
- fFirstTimeBin = argument.Atoi();
- if(fFirstTimeBin>=0){
- HLTDebug("fFirstTimeBin set to %d",fFirstTimeBin);
- //fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
- }
- else{
- HLTError("-first-timebin specifier is negative: %d",fFirstTimeBin);
- }
- return 2;
- }
-
- if (argument.CompareTo("-last-timebin")==0){
- if (++i>=argc) return -EPROTO;
- argument=argv[i];
- fLastTimeBin = argument.Atoi();
- if(fLastTimeBin<AliHLTTPCTransform::GetNTimeBins()){
- HLTDebug("fLastTimeBin set to %d",fLastTimeBin);
- }
- else{
- HLTError("fLastTimeBins is too big: %d. Maximum: %d",fLastTimeBin,AliHLTTPCTransform::GetNTimeBins());
- }
- return 2;
- }
-
- if (argument.CompareTo("-do-mc")==0) {
- fDoMC=kTRUE;
- //fClusterFinder->SetDoMC(fDoMC);
- HLTDebug("Setting fDoMC to true.");
- return 1;
- }
-
- if (argument.CompareTo("-active-pads")==0 || argument.CompareTo("activepads")==0){
- if(argument.CompareTo("activepads" )==0){
- HLTWarning("Please change to new component argument naming scheme and use '-active-pads' instead of 'activepads'");
- }
- HLTDebug("Switching on ActivePads");
- fGetActivePads = 1;
- //fClusterFinder->SetDoPadSelection(kTRUE);
- return 1;
- }
-
- // unknown argument
- return -EINVAL;
-}
-
-int AliHLTTPCHWClusterFinderEmulatorComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
-{
- // see header file for class documentation
-
- TString cdbPath;
- if (cdbEntry) {
- cdbPath=cdbEntry;
- } else {
- cdbPath="HLT/ConfigTPC/";
- cdbPath+=GetComponentID();
- }
-
- return ConfigureFromCDBTObjString(cdbPath.Data());
-
- /*
- int iResult=0;
-
- const char* path="HLT/ConfigTPC/ClusterFinderComponent";
- if (cdbEntry) path=cdbEntry;
- if (path) {
- HLTInfo("reconfigure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
- AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);//,GetRunNo());
- if (pEntry) {
- TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
- if (pString) {
- HLTInfo("received configuration object: %s", pString->GetString().Data());
- iResult = Configure(pString->GetString().Data());
- } else {
- HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
- }
- } else {
- HLTError("can not fetch object \"%s\" from CDB", path);
- }
- }
- return iResult;
- */
-}
-
-int AliHLTTPCHWClusterFinderEmulatorComponent::Configure(const char* arguments){
- // see header file for class documentation
- int iResult=0;
- if (!arguments) return iResult;
-
- TString allArgs=arguments;
- TString argument;
- int bMissingParam=0;
-
- TObjArray* pTokens=allArgs.Tokenize(" ");
- if (pTokens) {
-
- for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
- argument=((TObjString*)pTokens->At(i))->GetString();
-
- if (argument.IsNull()) continue;
-
- // -- deconvolute-time option
- if (argument.CompareTo("-deconvolute-time")==0){
- HLTDebug("Switching on deconvolution in time direction.");
- fDeconvTime = kTRUE;
- fClusterFinder->SetDeconvTime(fDeconvTime);
- }
- else if (argument.CompareTo("-deconvolute-pad")==0){
- HLTDebug("Switching on deconvolution in pad direction.");
- fDeconvPad = kTRUE;
- fClusterFinder->SetDeconvPad(fDeconvPad);
- }
- else if (argument.CompareTo("-timebins")==0 || argument.CompareTo("timebins" )==0){
- HLTWarning("Argument %s is depreciated after moving to the offline AliTPCTransform class for xyz calculations.",argument.Data());
- /*
- if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
- AliHLTTPCTransform::SetNTimeBins(((TObjString*)pTokens->At(i))->GetString().Atoi());
- fClusterFinder->UpdateLastTimeBin();
- HLTInfo("number of timebins set to %d, zbin=%f", AliHLTTPCTransform::GetNTimeBins(), AliHLTTPCTransform::GetZWidth());
- */
- if(argument.CompareTo("timebins")==0){
- HLTWarning("Argument 'timebins' is old, please switch to new argument naming convention (-timebins). The timebins argument will still work, but please change anyway.");
- }
-
- }
- else if (argument.CompareTo("-first-timebin")==0){
- if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
- fFirstTimeBin = ((TObjString*)pTokens->At(i))->GetString().Atoi();
- if(fFirstTimeBin>=0){
- HLTDebug("fFirstTimeBin set to %d",fFirstTimeBin);
- //fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
- }
- else{
- HLTError("-first-timebin specifier is negative: %d",fFirstTimeBin);
- }
- }
- else if (argument.CompareTo("-last-timebin")==0){
- if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
- fLastTimeBin = ((TObjString*)pTokens->At(i))->GetString().Atoi();
- if(fLastTimeBin<AliHLTTPCTransform::GetNTimeBins()){
- HLTDebug("fLastTimeBin set to %d",fLastTimeBin);
- }
- else{
- HLTError("fLastTimeBins is too big: %d. Maximum: %d",fLastTimeBin,AliHLTTPCTransform::GetNTimeBins());
- }
- }
- else if (argument.CompareTo("-do-mc")==0) {
- fDoMC=kTRUE;
- //fClusterFinder->SetDoMC(fDoMC);
- HLTInfo("Setting fDoMC to true.");
- }
- else if (argument.CompareTo("-release-memory")==0) {
- fReleaseMemory = kTRUE;
- //fClusterFinder->SetReleaseMemory( kTRUE );
- HLTInfo("Setting fReleaseMemory to true.");
- }
- else if (argument.CompareTo("-active-pads")==0 || argument.CompareTo("activepads")==0){
- if(argument.CompareTo("activepads" )==0){
- HLTWarning("Please change to new component argument naming scheme and use '-active-pads' instead of 'activepads'");
- }
- HLTDebug("Switching on ActivePads");
- fGetActivePads = 1;
- //fClusterFinder->SetDoPadSelection(kTRUE);
- }
- else if (argument.CompareTo("-update-calibdb")==0){
- //fClusterFinder->UpdateCalibDB();
- }
- else {
- HLTError("unknown argument %s", argument.Data());
- iResult=-EINVAL;
- break;
- }
- }
- delete pTokens;
- }
- if (bMissingParam) {
- HLTError("missing parameter for argument %s", argument.Data());
- iResult=-EINVAL;
- }
- return iResult;
-}
-
-void AliHLTTPCHWClusterFinderEmulatorComponent::GetOCDBObjectDescription( TMap* const targetMap){
-// Get a list of OCDB object description needed for the particular component
-
- if (!targetMap) return;
-
- // OCDB entries for component arguments
- targetMap->Add(new TObjString("HLT/ConfigTPC/TPCClusterFinderUnpacked"), new TObjString("component arguments, empty at the moment"));
-
-
- // OCDB entries to be fetched by the TAXI (access via the AliTPCcalibDB class)
- targetMap->Add(new TObjString("TPC/Calib/Parameters"), new TObjString("unknown content"));
- targetMap->Add(new TObjString("TPC/Calib/TimeDrift"), new TObjString("drift velocity calibration"));
- targetMap->Add(new TObjString("TPC/Calib/Temperature"), new TObjString("temperature map"));
- targetMap->Add(new TObjString("TPC/Calib/PadGainFactor"), new TObjString("gain factor pad by pad"));
- targetMap->Add(new TObjString("TPC/Calib/ClusterParam"), new TObjString("cluster parameters"));
-
- // OCDB entries needed to be fetched by the Pendolino
- targetMap->Add(new TObjString("TPC/Calib/AltroConfig"), new TObjString("contains the altro config, e.g. info about the L0 trigger timing"));
- targetMap->Add(new TObjString("GRP/CTP/CTPtiming"), new TObjString("content used in the cluster coordinate transformation in relation to the L0 trigger timing"));
-
- // OCDB entries necessary for replaying data on the HLT cluster
- targetMap->Add(new TObjString("GRP/GRP/Data"), new TObjString("contains magnetic field info"));
-
- // OCDB entries needed to suppress fatals/errors/warnings during reconstruction
- targetMap->Add(new TObjString("TPC/Calib/PadTime0"), new TObjString("time0 offset pad by pad"));
- targetMap->Add(new TObjString("TPC/Calib/PadNoise"), new TObjString("pad noise values"));
- targetMap->Add(new TObjString("TPC/Calib/Pedestals"), new TObjString("pedestal info"));
- targetMap->Add(new TObjString("TPC/Calib/Pulser"), new TObjString("pulser info"));
- targetMap->Add(new TObjString("TPC/Calib/CE"), new TObjString("CE laser calibration result"));
- targetMap->Add(new TObjString("TPC/Calib/Raw"), new TObjString("unknown content"));
- targetMap->Add(new TObjString("TPC/Calib/QA"), new TObjString("not important"));
- targetMap->Add(new TObjString("TPC/Calib/Mapping"), new TObjString("unknown content"));
- targetMap->Add(new TObjString("TPC/Calib/Goofie"), new TObjString("Goofie values, not used at the moment (05.03.2010)"));
- targetMap->Add(new TObjString("TPC/Calib/HighVoltage"), new TObjString("high voltage values, not used"));
- targetMap->Add(new TObjString("TPC/Calib/Ref"), new TObjString("unknown content"));
-}
+++ /dev/null
-// $Id: AliHLTTPCHWClusterFinderEmulatorComponent.h 47875 2011-02-28 09:41:02Z richterm $
-
-#ifndef ALIHLTTPCHWCLUSTERFINDEREMULATORCOMPONENT_H
-#define ALIHLTTPCHWCLUSTERFINDEREMULATORCOMPONENT_H
-
-//* This file is property of and copyright by the ALICE HLT Project *
-//* ALICE Experiment at CERN, All rights reserved. *
-//* See cxx source for full Copyright notice *
-
-/// @file AliHLTTPCHWClusterFinderEmulatorComponent.h
-/// @author Timm Steinbeck, Matthias Richter, Kenneth Aamodt
-/// @date
-/// @brief The TPC cluster finder component.
-///
-
-#include "AliHLTProcessor.h"
-#include "AliHLTComponentBenchmark.h"
-
-class AliHLTTPCHWClusterFinderEmulator;
-class AliHLTTPCDigitReader;
-class AliTPCTransform;
-
-/**
- * @class AliHLTTPCHWClusterFinderEmulatorComponent
- * Implementation of the cluster finder component.
- * The component implements the interface methods of the @ref AliHLTProcessor.
- * The actual cluster finding algorithm is implemented in @ref AliHLTTPCHWClusterFinderEmulator.
- * Two components are registered, TPCHWClusterFinderEmulatorUnpacked is for reading the HLT
- * internal digit data format used in the simulation. TPCHWClusterFinderEmulator32Bit uses
- * the AliHLTTPCDigitReader for raw data. After a phase of different decoder/raw stream
- * implementations the CF for raw data is using the default offline raw stream for
- * the 32bit RCU format AliAltroRawStreamV3, which also has a fall back to the 40bit
- * AliAltroRawStream if the old RCU format is detected.
- *
- * The clusterfinder is now using the AliTPCTransform instead of the AliHLTTPCTransform for
- * transformations from row, pad time -> x,y,z.
- *
- * <h2>General properties:</h2>
- *
- * Component ID: \b TPCHWClusterFinderEmulatorUnpacked and TPCHWClusterFinderEmulator32Bit <br>
- * Library: \b libAliHLTTPC
- * Input Data Types: @ref kAliHLTDataTypeDDLRaw <br>
- * Output Data Types: @ref AliHLTTPCDefinitions::fgkClustersDataType and/or kAliHLTDataTypeHwAddr16 <br>
- *
- *
- * Mandatory arguments: <br>
- * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
- *
- * Optional arguments: <br>
- * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
- * \li -deconvolute-time <br>
- * Turns on deconvolution in the time direction.
- * \li -deconvolute-pad <br>
- * Turns on deconvolution in the pad direction.
- * \li -timebins <br>
- * Sets the number of timebins (446 for simulated data, and 1024 for real data) Default:1024
- * \li -first-timebin <br>
- * First timebin taken into consideration when reading the data.
- * \li -last-timebin <br>
- * Last timebin taken into consideration when reading the data.
- *
- * <h2>Default CDB entries:</h2>
- * The component has these default CDB entries
- * \li <tt>GRP/GRP/Data</tt>.
- * \li <tt>TPC/Calib/PadTime0</tt>.
- * \li <tt>TPC/Calib/Parameters</tt>.
- * \li <tt>TPC/Calib/TimeDrift</tt>.
- * \li <tt>TPC/Calib/Temperature</tt>.
- *
- * TODO: pad by pad gain calibration also has to be added to the clusterfinder
- *
- * And it also needs these below to avoid warnings during initialization and update of calibDB
- * \li <tt>TPC/Calib/PadGainFactor</tt>.
- * \li <tt>TPC/Calib/TimeGain</tt>.
- * \li <tt>TPC/Calib/GainFactorDedx</tt>.
- * \li <tt>TPC/Calib/PadNoise</tt>.
- * \li <tt>TPC/Calib/Pedestals</tt>.
- * \li <tt>TPC/Calib/ClusterParam</tt>.
- * \li <tt>TPC/Calib/AltroConfig</tt>.
- * \li <tt>TPC/Calib/Pulser</tt>.
- * \li <tt>TPC/Calib/CE</tt>.
- * \li <tt>TPC/Calib/Raw</tt>.
- * \li <tt>TPC/Calib/QA</tt>.
- * \li <tt>TPC/Calib/Mapping</tt>.
- * \li <tt>TPC/Calib/Goofie</tt>.
- * \li <tt>TPC/Calib/HighVoltage</tt>.
- * \li <tt>TPC/Calib/Ref</tt>.
- *
- * These entries are used by the AliTPCTransform class to correct for T0, drift and ExB.
- * @ingroup alihlt_tpc_components
- */
-class AliHLTTPCHWClusterFinderEmulatorComponent : public AliHLTProcessor
- {
- public:
- /**
- * constructor
- */
- AliHLTTPCHWClusterFinderEmulatorComponent();
- /** destructor */
- virtual ~AliHLTTPCHWClusterFinderEmulatorComponent();
-
- // Public functions to implement AliHLTComponent's interface.
- // These functions are required for the registration process
-
- /** interface function, see AliHLTComponent for description */
- const char* GetComponentID();
- /** interface function, see AliHLTComponent for description */
- void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
- /** interface function, see AliHLTComponent for description */
- AliHLTComponentDataType GetOutputDataType();
- /** interface function, see AliHLTComponent for description */
- int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
- /** interface function, see AliHLTComponent for description */
- virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
- /** interface function, see AliHLTComponent for description */
- AliHLTComponent* Spawn();
- /** interface function, see @ref AliHLTComponent for description */
- void GetOCDBObjectDescription( TMap* const targetMap);
-
- protected:
-
- // Protected functions to implement AliHLTComponent's interface.
- // These functions provide initialization as well as the actual processing
- // capabilities of the component.
-
- int DoInit( int argc, const char** argv );
- int DoDeinit();
- int DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
- AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
- AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks );
- int Configure(const char* arguments);
- int ScanConfigurationArgument(int argc, const char** argv);
- int Reconfigure(const char* cdbEntry, const char* chainId);
-
- using AliHLTProcessor::DoEvent;
-
- private:
- /** copy constructor prohibited */
- AliHLTTPCHWClusterFinderEmulatorComponent(const AliHLTTPCHWClusterFinderEmulatorComponent&);
- /** assignment operator prohibited */
- AliHLTTPCHWClusterFinderEmulatorComponent& operator=(const AliHLTTPCHWClusterFinderEmulatorComponent&);
- /** the cluster finder object */
- AliHLTTPCHWClusterFinderEmulator* fClusterFinder; //!transient
-
- /** flag to deconvolute in time direction */
- Bool_t fDeconvTime; //!transient
-
- /** flag to deconvolute in pad direction */
- Bool_t fDeconvPad; //!transient
- /** flag to switch on/off deconvolution in pad and time directions */
- bool fClusterDeconv; //!transient
-
- /*
- * Patch number to be read, currently given as component argument,
- * will be changed later.
- */
- Int_t fPatch; //!transient
-
- /*
- * Switch to specify if one ship out a list of active pads (pads conected to a cluster).
- */
- Int_t fGetActivePads; //!transient
-
- /** First timebin taken into account when reading the data */
- Int_t fFirstTimeBin; //!transient
-
- /** Last timebin taken in to account when reading the data */
- Int_t fLastTimeBin; //!transient
-
- Bool_t fDoMC; // flag to provide MC labels
- Bool_t fReleaseMemory; // flag to release the memory after each event
- AliHLTComponentBenchmark fBenchmark; // benchmark
-
-};
-#endif
+++ /dev/null
-// $Id: AliHLTTPCHWClusterFinderEmulatorComponent.cxx 48710 2011-03-24 12:14:53Z richterm $
-
-//**************************************************************************
-//* This file is property of and copyright by the ALICE HLT Project *
-//* ALICE Experiment at CERN, All rights reserved. *
-//* *
-//* Primary Authors: Timm Steinbeck, Matthias Richter *
-//* Developers: Kenneth Aamodt <kenneth.aamodt@student.uib.no> *
-//* 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 AliHLTTPCHWClusterFinderSupport.cxx
- @author Sergey Gorbunov <gorbunov@fias.uni-frankfurt.de>
- @date
- @brief Input interface for AliHLTTPCHWClusterFinderEmulator
-*/
-
-
-#include "AliHLTTPCHWClusterFinderSupport.h"
-#include "AliHLTDataTypes.h"
-#include "AliHLTTPCMapping.h"
-
-#include "AliHLTTPCDigitReaderUnpacked.h"
-#include "AliHLTTPCTransform.h"
-#include "AliHLTTPCDefinitions.h"
-#include "AliRawDataHeader.h"
-
-#if __GNUC__>= 3
-using namespace std;
-#endif
-
-#include <cstdlib>
-#include <cerrno>
-#include <sys/time.h>
-
-
-AliHLTTPCHWClusterFinderSupport::AliHLTTPCHWClusterFinderSupport()
- :
- AliHLTLogging(),
- fEventMemory(0),
- fEventMCMemory(0)
-{
- // see header file for class documentation
-}
-
-AliHLTTPCHWClusterFinderSupport::~AliHLTTPCHWClusterFinderSupport()
-{
- // see header file for class documentation
- delete[] fEventMemory;
- delete[] fEventMCMemory;
-}
-
-AliHLTTPCHWClusterFinderSupport::AliHLTTPCHWClusterFinderSupport(const AliHLTTPCHWClusterFinderSupport&)
- :
- AliHLTLogging(),
- fEventMemory(0),
- fEventMCMemory(0)
-{
- // dummy
-}
-
-AliHLTTPCHWClusterFinderSupport& AliHLTTPCHWClusterFinderSupport::operator=(const AliHLTTPCHWClusterFinderSupport&){
- // dummy
- return *this;
-}
-
-
-
-int AliHLTTPCHWClusterFinderSupport::CreateRawEvent
-( const AliHLTComponentBlockData* block,
- const AliHLTUInt32_t *&rawEvent, AliHLTUInt64_t &rawEventSize32,
- const AliHLTInt32_t *&mcLabels, AliHLTUInt64_t &mcLabelsSize32
- )
-{
- // the method creates TPC raw data out of the input block
- // MC labels are provided if possible
- //
-
- delete[] fEventMemory;
- delete[] fEventMCMemory;
-
- rawEvent = 0;
- rawEventSize32 = 0;
- mcLabels = 0;
- mcLabelsSize32 = 0;
-
- if( block->fPtr==NULL ){
- HLTWarning("NULL pointer to the data block");
- return 0;
- }
-
- Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *block );
- Int_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *block );
- AliHLTTPCMapping mapping(patch);
-
- const char *str=Form("slice %d patch %d:", slice, patch);
-
- if ( block->fDataType == (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC) )
- {
- // already raw format -> only set the pointers and estimate the size
-
- // read CDH header, estimate size of the data
-
- AliHLTUInt64_t headerSize = sizeof(AliRawDataHeader);
-
- AliRawDataHeader *cdhHeader = reinterpret_cast<AliRawDataHeader*>(block->fPtr);
-
- AliHLTUInt64_t blockSize = block->fSize; // size of the raw data in bytes
-
- if( cdhHeader->fSize!=0xFFFFFFFF ){ // use size information from the header
- blockSize = cdhHeader->fSize;
- if( blockSize > block->fSize ){
- HLTWarning("%s Could not find a valid DDL header!",str);
- return 0;
- }
- }
-
- if( blockSize < headerSize ){
- HLTWarning("%s Buffer size is smaller than CDH header size", str);
- return 0;
- }
-
- rawEvent = reinterpret_cast<AliHLTUInt32_t*> (reinterpret_cast<UChar_t*>(block->fPtr)+headerSize);
- rawEventSize32 = ( blockSize - headerSize )/sizeof(AliHLTUInt32_t);
-
- }
- else if ( block->fDataType == AliHLTTPCDefinitions::fgkUnpackedRawDataType )
- {
-
- AliHLTTPCDigitReaderUnpacked digitReader;
- digitReader.SetUnsorted(kTRUE);
-
- if( digitReader.InitBlock(block->fPtr,block->fSize,patch,slice)<0 ) {
- HLTWarning("failed setting up digit reader (InitBlock)");
- return 0;
- }
-
- int nDigitsTotal = 0;
- int nBunchesTotal = 0;
-
- while( digitReader.NextChannel() ){
- while(digitReader.NextBunch()){
- nBunchesTotal++;
- nDigitsTotal+=digitReader.GetBunchSize();
- }
- }
-
- digitReader.Reset();
-
- if( digitReader.InitBlock(block->fPtr,block->fSize,patch,slice)<0) {
- HLTWarning("failed setting up digit reader (InitBlock)");
- return 0;
- }
-
- Int_t nPadsTotal = 0;
- Int_t firstRow = AliHLTTPCTransform::GetFirstRow(patch);
- Int_t nRows = AliHLTTPCTransform::GetNRows(patch);
-
- for( int i=0; i<nRows; i++ ){
- nPadsTotal += AliHLTTPCTransform::GetNPads(firstRow+i);
- }
-
- int totalSize32 = (nDigitsTotal + nBunchesTotal*2)/3+2*nPadsTotal + 10;
- int totalSizeMC32 = 3*nDigitsTotal + 10;
-
- fEventMemory = new AliHLTUInt32_t[totalSize32];
- if( !fEventMemory ){
- HLTWarning("Not enougth memory: can not allocate %d bytes",totalSize32*8);
- return 0;
- }
-
- fEventMCMemory = new AliHLTInt32_t[totalSizeMC32];
- if( !fEventMCMemory ){
- HLTWarning("Not enougth memory: can not allocate %d bytes",totalSizeMC32*8);
- delete[] fEventMemory;
- return 0;
- }
-
- AliHLTUInt32_t nWords32 = 0;
- int mcIndex = 0;
- int err=0;
-
- AliHLTTPCDigitData tmpDigit;
- tmpDigit.fTrackID[0] = -1;
- tmpDigit.fTrackID[1] = -1;
- tmpDigit.fTrackID[2] = -1;
-
- while( !err && digitReader.NextChannel() ){
-
- Int_t row=digitReader.GetRow();
- Int_t pad=digitReader.GetPad();
-
- // create header
-
- if( nWords32 >= totalSize32){ err = 1; break; }
-
- AliHLTUInt32_t *header = fEventMemory + nWords32;
- nWords32++;
-
- int seek10 = 2;
- int prevTime = 10000000;
- int nWords10 = 0;
- while(digitReader.NextBunch()){
-
- Int_t nSignals = digitReader.GetBunchSize();
- if( nSignals <=0 ){
- HLTWarning("Empty bunch received");
- continue;
- }
-
- Int_t time = digitReader.GetTime() + nSignals-1;
-
- if( time-nSignals+1<0 || time>=AliHLTTPCTransform::GetNTimeBins() ){
- HLTWarning("Wrong time bins received: %d-%d for row %d pad %d", time-nSignals+1, time, row, pad);
- break;
- }
-
- if( time >= prevTime ){
- HLTWarning("Unexpected order of TPC bunches in row %d, pad %d", row, pad);
- break;
- }
-
- prevTime = time-nSignals+1;
-
- if( nWords32+( 2+nSignals)/3+1 >= totalSize32 ){ err = 1; break; }
- if( mcIndex + nSignals*3 >= totalSizeMC32 ){ err = 1; break; }
-
- if( nWords10 + 2 + nSignals > 0x2FF ){
- HLTWarning("Too much data in row %d, pad %d", row, pad);
- break;
- }
-
- nWords10 += 2 + nSignals;
-
- Add10Word( nWords32, seek10, nSignals + 2 );
- Add10Word( nWords32, seek10, time );
-
- const UInt_t *bunchData = digitReader.GetSignals();
- const AliHLTTPCDigitData *mcDigits = digitReader.GetBunchDigits();
- if( !mcDigits ){
- HLTWarning("No MC labels found for a bunch of digits");
- }
-
- for(Int_t i=nSignals-1; i>=0; i--){
- Add10Word( nWords32, seek10, bunchData[i] );
- const AliHLTTPCDigitData &digit = mcDigits ?mcDigits[i] :tmpDigit;
- fEventMCMemory[mcIndex++] = digit.fTrackID[0];
- fEventMCMemory[mcIndex++] = digit.fTrackID[1];
- fEventMCMemory[mcIndex++] = digit.fTrackID[2];
- }
-
- } // bunches
-
- *header = (1<<30) | ((nWords10&0x2FF)<<16) | (mapping.GetHwAddress(row, pad) & 0xFFF);
-
- }// channels (pads)
-
- if( err ){
- HLTError("Internal error: too less memory allocated");
- } else {
- rawEvent = fEventMemory;
- rawEventSize32 = nWords32;
- mcLabels = fEventMCMemory;
- mcLabelsSize32 = mcIndex;
- }
-
- } // unpacked data type
-
- return 0;
-}
-
-
-void AliHLTTPCHWClusterFinderSupport::Add10Word( AliHLTUInt32_t &nWords32, int &seek10, UInt_t data )
-{
- // add 10-bit data to the 32-bit word
- // fEventMemory [nWords32] --- current 32-bit word
- // *seek10 --- 10-bit position withing the word
- // pointers are increased, a new word is first initialised to 0
-
- data = data & 0x3FF; // truncate to 10 bits
- AliHLTUInt32_t *seek = fEventMemory + nWords32;
-
- if( seek10 == 2 ){
- nWords32++;
- fEventMemory[nWords32-1] = data<<20;
- seek10 = 1;
- } else if( seek10 == 1 ){
- fEventMemory[nWords32-1] &= 0xFFF003FF;
- fEventMemory[nWords32-1] |= (data<<10);
- seek10 = 0;
- } else if( seek10 == 0 ){
- fEventMemory[nWords32-1] &= 0xFFFFFC00;
- fEventMemory[nWords32-1] |= data;
- seek10 = 2;
- }
-}
-
-
-
-int AliHLTTPCHWClusterFinderSupport::CheckRawData( const AliHLTUInt32_t *buffer,
- unsigned long bufferSize32, int patch, int slice )
-{
- //
- // The procedure checks consistency of the data
- //
-
- const unsigned int headerSize32 = 8;
-
- if (!buffer) return 0;
-
- const char *str=Form("slice %d patch %d:", slice, patch);
-
- if( bufferSize32 < headerSize32 ){
- HLTWarning("%s Buffer size is smaller than CDH header size", str);
- return kFALSE;
- }
-
- // read data header
-
- AliHLTUInt32_t blockSize32 = bufferSize32; // size of the raw data in words
-
- if( buffer[0]!=0xFFFFFFFF ) blockSize32 = buffer[0]/4; // use size information from the header
- if( blockSize32 > bufferSize32 ){
- HLTWarning(Form("%s Could not find a valid DDL header!",str));
- return 0;
- }
-
- UChar_t rcuVer = (UChar_t)( (buffer[1] >> 24) & 0xFF );
-
- if (rcuVer < 2) {
- HLTWarning("%s Old data format, RCU version %d", str,rcuVer);
- return 0;
- }
-
- // is the block valid
- //AliHLTUInt32_t blockAttributes = buffer[3]; // block attributes (bits 24-31) and participating sub detectors
- //cout<<blockAttributes<<" "<<(blockAttributes >> 24)<<endl;
- //if ( !( (blockAttributes >> 24) & 1) ) return 0;
-
-
- const AliHLTUInt32_t* fData = buffer + headerSize32;
- unsigned long dataSize32 = blockSize32 - headerSize32;
-
- // Read the RCU trailer according to the RCU formware version specified in CDH
- // Cross-check with version found in the trailer
- // The two major bit should be 11 (identifies the end of the trailer)
-
- AliHLTUInt32_t word = fData[dataSize32 - 1];
-
- if ((word >> 30) != 3) {
- HLTWarning("%s Last RCU trailer word not found!", str);
- return 0;
- }
-
- UChar_t ver = (word >> 16) & 0xFF;
- Int_t rcuId = (Int_t)((word >> 7) & 0x1FF);
- Int_t rcuTrailerSize32 = (word & 0x7F); // size of RCU trailer data in words
-
- if (ver != rcuVer) {
- HLTWarning("%s Wrong RCU firmware version detected: %d != %d",
- str,ver,rcuVer);
- return 0;
- }
-
- if (rcuTrailerSize32 < 2) {
- HLTWarning(Form("Invalid trailer size found (%d bytes) !",
- rcuTrailerSize32*4));
- return 0;
- }
-
- if( rcuTrailerSize32 > dataSize32 ){
- HLTWarning(Form("%s Invalid trailer size found (%d bytes) ! The size is bigger than the raw data size (%d bytes)!",
- str, rcuTrailerSize32*4,dataSize32*4));
- return 0;
- }
-
- // check the trailer
-
- Int_t trailerIndex = dataSize32 - rcuTrailerSize32;
-
- for( int i=trailerIndex; i<dataSize32-1; i++){
- if ((fData[i] >> 30) != 2) {
- HLTWarning("%s Missing RCU trailer identifier pattern!",str);
- continue;
- }
- }
-
- // Read the payload size
-
- Int_t rcuPayloadSize32 = fData[trailerIndex] & 0x3FFFFFF;
-
- if ( rcuPayloadSize32 + rcuTrailerSize32 != dataSize32) {
- HLTWarning(Form("%s Inconsistent raw data size ! Raw data size - %d bytes (from CDH), RCU trailer - %d bytes, raw data size (from RCU trailer) - %d bytes !",
- str, dataSize32*4,
- (rcuTrailerSize32)*4,
- rcuPayloadSize32*4));
- return 0;
- }
-
-
- AliHLTTPCMapping *fMapping = new AliHLTTPCMapping(patch);
- const int kMaxNTimeBins = 2000;
-
- UShort_t *channelData10 = new UShort_t[kMaxNTimeBins]; // cache for the decoded altro payload
-
- Int_t position = 0; // current position (32-bit words) in fData
-
- while(1){
-
- // Search for the next Altro channel
-
- word = 0;
- while( position < rcuPayloadSize32 ){
- word = fData[position++];
- if( (word >> 30) == 1) break;
- }
- if (position >= rcuPayloadSize32 ) break; // no next channel found
-
- // extract channel payload and hw address
-
- Int_t channelPayloadSize10 = (word >> 16) & 0x3FF; // payload size in 10-bit words
- Int_t channelPayloadSize32 = (channelPayloadSize10+2)/3;
- Bool_t channelIOErrors = (word >> 29) & 0x1; // check for readout errors
- Short_t channelHWAddress = word & 0xFFF;
-
- if( position + channelPayloadSize32-1> rcuPayloadSize32 ){
- HLTWarning(Form("%s Inconsistent channel payload data size: expected <= %d bytes from RCU trailer, found %d bytes in the channel header!",
- str,(rcuPayloadSize32 - position)*4, channelPayloadSize32*4 ));
- continue;
- }
-
- bool channelBranchAB = ((channelHWAddress >> 11) & 0x1);
- int channelFEC = ((channelHWAddress >> 7) & 0xF); // front-end card index
- int channelAltro = ((channelHWAddress >> 4) & 0x7); // altro chip index
- int channelIndex = (channelHWAddress & 0xF); // channel index
- int channelRow = fMapping->GetRow(channelHWAddress);
- int channelPad = fMapping->GetPad(channelHWAddress);
-
- // Now unpack the Altro data: 10-bit words to 16 bit-words
-
- Int_t channelData10Index = 0;// current position in the payload
-
- for (Int_t iword = 0; iword < channelPayloadSize32; iword++) {
- word = fData[position++];
- if ((word >> 30) != 0) {
- HLTWarning(Form("%s Unexpected end of payload in altro channel payload! Address=0x%x, word=0x%x",
- str, channelHWAddress,word));
- channelIOErrors = 1;
- position--;
- break;
- }
- channelData10[channelData10Index++] = (word >> 20) & 0x3FF;
- channelData10[channelData10Index++] = (word >> 10) & 0x3FF;
- channelData10[channelData10Index++] = word & 0x3FF;
- }
-
- if ( channelIOErrors ) continue;
-
- // read bunches
-
- Int_t prevTimeBin = 1024;
- channelData10Index = 0;
-
- while(1){
-
- // Read next Altro bunch
-
- if ((channelData10Index+1 >= channelPayloadSize10) ) break;
-
- Int_t bunchLength = channelData10[channelData10Index++];
- Int_t bunchStartTimeBin = channelData10[channelData10Index++];
-
- if (bunchLength <= 2) {
- // Invalid bunch size
- HLTWarning(Form("%s Too short bunch length (%d) in Address=0x%x!",
- str, bunchLength,channelHWAddress));
- break;
- }
- if( channelData10Index + bunchLength - 2 > channelPayloadSize10 ){
- // Too long bunch detected
- HLTWarning(Form("%s Too long bunch detected in Address=0x%x! Expected <= %d 10-bit words, found %d !",
- str,channelHWAddress,channelPayloadSize10-channelData10Index,bunchLength));
- break;
- }
-
- if( bunchStartTimeBin-bunchLength+1 < 0) {
- HLTWarning(Form("%s Invalid start time-bin in Address=0x%x ! (%d-%d+1) < 0",
- str,channelHWAddress,bunchStartTimeBin,bunchLength));
- break;
- }
- if (bunchStartTimeBin >= prevTimeBin) {
- HLTWarning(Form("%s Invalid start time-bin in Address=0x%x! (%d>=%d)",
- str,channelHWAddress,bunchStartTimeBin,prevTimeBin));
- break;
- }
-
- prevTimeBin = bunchStartTimeBin-bunchLength+1;
-
- bunchLength -= 2;
-
- UShort_t* bunchData = &channelData10[channelData10Index]; // pointer to the current bunch samples
- channelData10Index += bunchLength;
- }
- }
-
- delete[] channelData10;
- delete fMapping;
-
- return 1;
-}
-
+++ /dev/null
-// $Id: AliHLTTPCHWClusterFinderSupport.h 47875 2011-02-28 09:41:02Z richterm $
-
-#ifndef ALIHLTTPCHWCLUSTERFINDERSUPPORT_H
-#define ALIHLTTPCHWCLUSTERFINDERSUPPORT_H
-
-//* This file is property of and copyright by the ALICE HLT Project *
-//* ALICE Experiment at CERN, All rights reserved. *
-//* See cxx source for full Copyright notice *
-
-/// @file AliHLTTPCHWClusterFinderSupport.h
-/// @author Sergey Gorbunov
-/// @date
-/// @brief Input interface for AliHLTTPCHWClusterFinderEmulator
-///
-
-#include "AliHLTLogging.h"
-
-class AliHLTComponentBlockData;
-
-/**
- * @class AliHLTTPCHWClusterFinderSupport
- * The class creates input for the FPGA cluster finder emulator
- *
- * @ingroup alihlt_tpc_components
- */
-class AliHLTTPCHWClusterFinderSupport : public AliHLTLogging
-{
- public:
- /** constructor */
- AliHLTTPCHWClusterFinderSupport();
- /** destructor */
- virtual ~AliHLTTPCHWClusterFinderSupport();
-
- /** method creates raw event from the HLT data block, error flag returned **/
- int CreateRawEvent( const AliHLTComponentBlockData* block,
- const AliHLTUInt32_t *&event, AliHLTUInt64_t &eventSize32,
- const AliHLTInt32_t *&mcLabels, AliHLTUInt64_t &mcLabelsSize32 );
-
- int CheckRawData( const AliHLTUInt32_t *buffer, unsigned long bufferSize32, int patch, int slice );
-
- private:
- /** copy constructor prohibited */
- AliHLTTPCHWClusterFinderSupport(const AliHLTTPCHWClusterFinderSupport&);
- /** assignment operator prohibited */
- AliHLTTPCHWClusterFinderSupport& operator=(const AliHLTTPCHWClusterFinderSupport&);
- void Add10Word( AliHLTUInt32_t &nWords32, int &seek10, UInt_t data );
-
- AliHLTUInt32_t *fEventMemory;
- AliHLTInt32_t *fEventMCMemory;
-};
-
-#endif