//-*- Mode: C++ -*- // $Id$ #ifndef ALIHLTTPCCLUSTERACCESSHLTOUT_H #define ALIHLTTPCCLUSTERACCESSHLTOUT_H //* This file is property of and copyright by the ALICE Project * //* ALICE Experiment at CERN, All rights reserved. * //* See cxx source for full Copyright notice * /// @file AliHLTTPCClusterAccessHLTOUT.h /// @author Matthias Richter /// @date 2011-06-06 /// @brief Interface to HLT TPC clusters /// #include "TObject.h" #include "AliHLTDataTypes.h" #include "AliHLTTPCClusterMCData.h" #include "AliTPCclusterMI.h" #include class AliTPCClustersRow; class AliHLTOUT; class TClonesArray; class AliHLTTPCDataCompressionDecoder; typedef std::map AliHLTTPCClusterMCDataList; /** * @class AliHLTTPCClusterAccessHLTOUT * Generator for TPC cluster array from HLT TPC clusters in the HLTOUT * data stream. It uses the TObject method interface. Combined with dynamic * loading, any cross dependency between the TPC code and HLT libraries * can be avoided. * * Creating the instance: * The class is implemented in libAliHLTTPC.so and can be loaded * through the TClass interface (you might want to add * further error messages on the various error conditions). *
 *     TObject* pClusterAccess=NULL;
 *     TClass* pCl=NULL;
 *     ROOT::NewFunc_t pNewFunc=NULL;
 *     do {
 *       pCl=TClass::GetClass("AliHLTTPCClusterAccessHLTOUT");
 *     } while (!pCl && gSystem->Load("libAliHLTTPC.so")==0);
 *     if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
 *       void* p=(*pNewFunc)(NULL);
 *       if (p) {
 *         pClusterAccess=reinterpret_cast(p);
 *       }
 *     }
 * 
* * Usage: * TObject::Execute can be used to execute commands. Command 'read' * will get hold on the HLTOUT data and read the clusters. The const char* * parameter 'param' is used to select the region. * - param="sector=sectorno" * 'sectorno' specifies sector number in the offline code, range 0 and 71, * enumerating first the 36 inner (partitions 0+1) and then 36 outer sectors * (partitions 2-5).
* If the error pointer parameter is provided the result code is returned * - >=0 success, number of clusters * - -ENODATA no data in HLTOUT * - -EINVAL invalid parameter/argument * - -ENOMEM memory allocation failed * - -EACCESS no access to HLTOUT * - -NODEV internal error, can not get AliHLTSystem * - -ENOBUFS internal error, can not get cluster array * * Command 'verbosity=level' sets the verbositylevel which is default 0 * (no info output). * *
 *     pClusterAccess->Execute("read", param);
 *     TObject* pClusterAccess->FindObject("clusterarray");
 * 
* * After processing the loop of sectors, the instance should be cleaned. *
 *     pClusterAccess->Clear("event");
 * 
* * @ingroup alihlt_tpc */ class AliHLTTPCClusterAccessHLTOUT : public TObject { public: /** standard constructor */ AliHLTTPCClusterAccessHLTOUT(); /** destructor */ ~AliHLTTPCClusterAccessHLTOUT(); /// inherited from TObject: abstract command interface virtual void Execute(const char *method, const char *params, Int_t *error=0); /// inherited from TObject: return the cluster array if name id "clusterarray" virtual TObject *FindObject(const char *name) const; /// inherited from TObject: cleanup virtual void Clear(Option_t * option =""); /// inherited from TObject virtual void Print(Option_t *option="") const; /// process the cluster data block of various formats from HLTOUT int ProcessClusters(const char* params); /** * @class AliTPCclusterMIContainer * Cluster read interface for offline. * The class implements the interface to be used in the decoding * of compressed TPC data. */ class AliTPCclusterMIContainer { public: AliTPCclusterMIContainer(); virtual ~AliTPCclusterMIContainer(); struct AliClusterIdBlock { AliClusterIdBlock() : fIds(NULL), fSize(0) {} AliHLTUInt32_t* fIds; //! AliHLTUInt32_t fSize; //! }; class iterator { public: iterator() : fClusterNo(-1), fData(NULL), fCluster(NULL), fRowOffset(0) {} iterator(AliTPCclusterMIContainer* pData) : fClusterNo(-1), fData(pData), fCluster(NULL), fRowOffset(0) {} iterator(const iterator& other) : fClusterNo(other.fClusterNo), fData(other.fData), fCluster(other.fCluster), fRowOffset(other.fRowOffset) {} iterator& operator=(const iterator& other) { if (this==&other) return *this; fClusterNo=other.fClusterNo; fData=other.fData; fCluster=other.fCluster; fRowOffset=other.fRowOffset; return *this; } ~iterator() {} void SetPadRow(int row) {if (fCluster) fCluster->SetRow(row-fRowOffset);} void SetPad(float pad) {if (fCluster) fCluster->SetPad(pad);} void SetTime(float time) {if (fCluster) fCluster->SetTimeBin(time);} void SetSigmaY2(float sigmaY2) {if (fCluster) fCluster->SetSigmaY2(sigmaY2);} void SetSigmaZ2(float sigmaZ2) {if (fCluster) fCluster->SetSigmaZ2(sigmaZ2);} void SetCharge(unsigned charge) {if (fCluster) fCluster->SetQ(charge);} void SetQMax(unsigned qmax) {if (fCluster) fCluster->SetMax(qmax);} void SetMC(const AliHLTTPCClusterMCLabel* pMC) { if (!fCluster || !pMC) return; for (int k=0; k<3; k++) fCluster->SetLabel(pMC->fClusterID[k].fMCID, k); } // switch to next cluster iterator& Next(int slice, int partition); private: int fClusterNo; //! cluster no in the current block AliTPCclusterMIContainer* fData; //! pointer to actual data AliTPCclusterMI* fCluster; //! pointer to current cluster int fRowOffset; //! row offset for current partition }; /// iterator of remaining clusters block of specification iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification); /// iterator of track model clusters iterator& BeginTrackModelClusterBlock(int count); /// internal cleanup virtual void Clear(Option_t * option=""); /// get the cluster array for a sector TObjArray* GetSectorArray(unsigned sector) const; /// print info virtual void Print(Option_t *option=NULL) const; protected: /// load next cluster from array of the sepcific sector AliTPCclusterMI* NextCluster(int slice, int partition); private: AliTPCclusterMIContainer(const AliTPCclusterMIContainer&); AliTPCclusterMIContainer& operator=(const AliTPCclusterMIContainer&); vector fClusterArrays; //! cluster arrays per sector (offline notation 0-71) vector fRemainingClusterIds; //! clusters ids for remaining cluster ids AliClusterIdBlock fTrackModelClusterIds; //! cluster ids for track model clusters AliClusterIdBlock* fCurrentClusterIds; //! id block currently active in the iteration vector fClusterMCData; //! references to MC data blocks iterator fIterator; //! }; private: /// copy constructor prohibited AliHLTTPCClusterAccessHLTOUT(const AliHLTTPCClusterAccessHLTOUT&); /// assignment operator prohibited AliHLTTPCClusterAccessHLTOUT& operator=(const AliHLTTPCClusterAccessHLTOUT&); enum EOptions { // skip the track clusters kSkipTrackClusters = BIT(15), // skip the partition (remaining) clusters kSkipPartitionClusters = BIT(16) }; int fVerbosity; //! verbosity level AliTPCclusterMIContainer* fClusters; //! cluster container int fCurrentSector; //! current sector AliHLTTPCDataCompressionDecoder* fpDecoder; //! decoder instance ClassDef(AliHLTTPCClusterAccessHLTOUT, 0) }; #endif