From 9eb867b1b2deb32b4338688a7e2cb5940ca63609 Mon Sep 17 00:00:00 2001 From: sgorbuno Date: Sun, 4 Nov 2012 00:39:45 +0000 Subject: [PATCH] Bug fixes in HLT cluster transformation: 1. Treatment of AliHLTTPCFastTransform::Instance() static object changed. Before the static object was deinitialized at each call of AliTPCClusterTransformation destructor, that could made problems when running HLT offline. 2. The TPCRecoParam object is now loaded from OCDB properly, with respect to the content of the GRP entry --- HLT/TPCLib/AliHLTTPCClusterTransformation.cxx | 91 +++++++++++++++---- HLT/TPCLib/AliHLTTPCClusterTransformation.h | 3 +- .../AliHLTTPCHWClusterTransformComponent.cxx | 6 +- .../transform/AliHLTTPCFastTransform.cxx | 26 +----- HLT/TPCLib/transform/AliHLTTPCFastTransform.h | 8 +- 5 files changed, 88 insertions(+), 46 deletions(-) diff --git a/HLT/TPCLib/AliHLTTPCClusterTransformation.cxx b/HLT/TPCLib/AliHLTTPCClusterTransformation.cxx index 64f18e8aeed..4ae3e7b7cf0 100644 --- a/HLT/TPCLib/AliHLTTPCClusterTransformation.cxx +++ b/HLT/TPCLib/AliHLTTPCClusterTransformation.cxx @@ -29,11 +29,16 @@ #include "AliCDBPath.h" #include "AliCDBManager.h" +#include "AliCDBEntry.h" +#include "AliGRPObject.h" #include "AliTPCcalibDB.h" #include "AliTPCTransform.h" #include "AliTPCParam.h" #include "AliTPCRecoParam.h" #include "AliGeomManager.h" +#include "AliRunInfo.h" +#include "AliEventInfo.h" +#include "AliRawEventHeaderBase.h" #include #include @@ -44,6 +49,7 @@ ClassImp(AliHLTTPCClusterTransformation) //ROOT macro for the implementation of AliHLTTPCClusterTransformation::AliHLTTPCClusterTransformation() : fOfflineTPCParam( NULL ), + fOfflineRecoParam( NULL), fLastSector(-1) { // see header file for class documentation @@ -59,45 +65,98 @@ AliHLTTPCClusterTransformation::AliHLTTPCClusterTransformation() AliHLTTPCClusterTransformation::~AliHLTTPCClusterTransformation() { // see header file for class documentation - AliHLTTPCFastTransform::Terminate(); } int AliHLTTPCClusterTransformation::Init( double FieldBz, UInt_t TimeStamp ) { // Initialisation - fOfflineTPCParam = 0; - + fLastSector = -1; + fAliT[0] = 0.; + fAliT[1] = 0.; + fAliT[2] = 0.; + AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance(); if(!pCalib ) return -1; pCalib->SetExBField(FieldBz); - if(!AliGeomManager::GetGeometry()){ - AliGeomManager::LoadGeometry(); + AliGeomManager::LoadGeometry(); } if( !pCalib->GetTransform() ) return -2; + pCalib->GetTransform()->SetCurrentRecoParam(NULL); + + delete fOfflineRecoParam; + fOfflineRecoParam = new AliRecoParam; + if( !fOfflineRecoParam ) return -3; + + + AliCDBEntry *entry=AliCDBManager::Instance()->Get("TPC/Calib/RecoParam"); + if(!entry) return -4; + TObject *recoParamObj = entry->GetObject(); + if(!recoParamObj) return -5; + if (dynamic_cast(recoParamObj)) { + //cout<<"\n\nSet reco param from AliHLTTPCClusterTransformation: TObjArray found \n"<AddDetRecoParamArray(1,dynamic_cast(recoParamObj)); + } + else if (dynamic_cast(recoParamObj)) { + //cout<<"\n\nSet reco param from AliHLTTPCClusterTransformation: AliDetectorRecoParam found \n"<AddDetRecoParam(1,dynamic_cast(recoParamObj)); + } + + // -- Get AliRunInfo variables + + AliGRPObject tmpGRP, *pGRP=0; + + entry = AliCDBManager::Instance()->Get("GRP/GRP/Data"); + + if(!entry) return -6; - AliCDBPath cdbPath("TPC/Calib/RecoParam"); - AliTPCRecoParam* recParam = (AliTPCRecoParam*)AliCDBManager::Instance()->Get(cdbPath); - if(!recParam) return -3; + { + TMap* m = dynamic_cast(entry->GetObject()); // old GRP entry + + if (m) { + //cout<<"Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject"<Print(); + pGRP = &tmpGRP; + pGRP->ReadValuesFromMap(m); + } + else { + //cout<<"Found an AliGRPObject in GRP/GRP/Data, reading it"<(entry->GetObject()); // new GRP entry + } + } + + + if( !pGRP ){ + return -7; + } + + AliRunInfo runInfo(pGRP->GetLHCState(),pGRP->GetBeamType(),pGRP->GetBeamEnergy(),pGRP->GetRunType(),pGRP->GetDetectorMask()); + AliEventInfo evInfo; + evInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent); + + fOfflineRecoParam->SetEventSpecie(&runInfo, evInfo, 0); + + AliTPCRecoParam* recParam = (AliTPCRecoParam*)fOfflineRecoParam->GetDetRecoParam(1); + + // + pCalib->GetTransform()->SetCurrentRecoParam(recParam); - fOfflineTPCParam = pCalib->GetParameters(); - if( !fOfflineTPCParam ) return -4; + fOfflineTPCParam = pCalib->GetParameters(); + if( !fOfflineTPCParam ) return -8; fOfflineTPCParam->Update(); fOfflineTPCParam->ReadGeoMatrices(); - fLastSector = -1; - - fAliT[0] = 0.; - fAliT[1] = 0.; - fAliT[2] = 0.; SetRotationMatrix(); + + // set current time stamp and initialize the fast transformation instance, if necessary + SetCurrentTimeStamp( TimeStamp ); return 0; } @@ -105,7 +164,7 @@ int AliHLTTPCClusterTransformation::Init( double FieldBz, UInt_t TimeStamp ) void AliHLTTPCClusterTransformation::SetCurrentTimeStamp( UInt_t TimeStamp ) { - // Set the current time stamp + // Set the current time stamp AliHLTTPCFastTransform::Instance()->SetCurrentTimeStamp( TimeStamp ); } diff --git a/HLT/TPCLib/AliHLTTPCClusterTransformation.h b/HLT/TPCLib/AliHLTTPCClusterTransformation.h index eb62c9345cd..e02d75394fc 100644 --- a/HLT/TPCLib/AliHLTTPCClusterTransformation.h +++ b/HLT/TPCLib/AliHLTTPCClusterTransformation.h @@ -23,7 +23,7 @@ #include"Rtypes.h" class AliTPCParam; -class AliTPCTransform; +class AliRecoParam; /** * @class AliHLTTPCClusterTransformation @@ -56,6 +56,7 @@ class AliHLTTPCClusterTransformation{ protected: AliTPCParam * fOfflineTPCParam; //! transient + AliRecoParam * fOfflineRecoParam; //! transient Int_t fLastSector; // last sector Double_t fAliT[3]; // alignment - translation Double_t fAliR[9]; // alignment - rotation diff --git a/HLT/TPCLib/AliHLTTPCHWClusterTransformComponent.cxx b/HLT/TPCLib/AliHLTTPCHWClusterTransformComponent.cxx index b5aa0f3622d..e261a6f56d0 100644 --- a/HLT/TPCLib/AliHLTTPCHWClusterTransformComponent.cxx +++ b/HLT/TPCLib/AliHLTTPCHWClusterTransformComponent.cxx @@ -125,11 +125,11 @@ int AliHLTTPCHWClusterTransformComponent::DoInit( int argc, const char** argv ) } calib->SetRun(GetRunNo()); calib->UpdateRunInformations(GetRunNo()); - + int err = fTransform.Init( GetBz(), GetTimeStamp() ); if( err!=0 ){ - HLTError("Cannot retrieve offline transform from AliTPCcalibDB"); + HLTError(Form("Cannot retrieve offline transform from AliTPCcalibDB, AliHLTTPCClusterTransformation returns %d",err)); return -ENOENT; } @@ -161,7 +161,7 @@ int AliHLTTPCHWClusterTransformComponent::DoEvent(const AliHLTComponentEventData AliHLTUInt32_t& size, vector& outputBlocks ){ // see header file for class documentation - + UInt_t maxOutSize = size; size = 0; int iResult = 0; diff --git a/HLT/TPCLib/transform/AliHLTTPCFastTransform.cxx b/HLT/TPCLib/transform/AliHLTTPCFastTransform.cxx index 1fa67566ec3..94d76b48127 100644 --- a/HLT/TPCLib/transform/AliHLTTPCFastTransform.cxx +++ b/HLT/TPCLib/transform/AliHLTTPCFastTransform.cxx @@ -33,23 +33,9 @@ using namespace std; ClassImp(AliHLTTPCFastTransform); //ROOT macro for the implementation of ROOT specific class methods -AliHLTTPCFastTransform* AliHLTTPCFastTransform::fgInstance = 0; +AliHLTTPCFastTransform AliHLTTPCFastTransform::fgInstance; -void AliHLTTPCFastTransform::Terminate() -{ - // - // Singleton implementation - // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore - // This function can be called several times. - // - - if( fgInstance ){ - delete fgInstance; - fgInstance = 0; - } -} - AliHLTTPCFastTransform::AliHLTTPCFastTransform() : fOrigTransform(0), @@ -65,7 +51,6 @@ AliHLTTPCFastTransform::AliHLTTPCFastTransform() // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt for( Int_t i=0; i<72; i++) for( Int_t j=0; j<100; j++ ) fRows[i][j] = 0; - Init(); } AliHLTTPCFastTransform::~AliHLTTPCFastTransform() @@ -73,15 +58,13 @@ AliHLTTPCFastTransform::~AliHLTTPCFastTransform() // see header file for class documentation for( Int_t i=0; i<72; i++) for( Int_t j=0; j<100; j++ ) delete fRows[i][j]; - - if( fgInstance == this ) fgInstance = 0; } Int_t AliHLTTPCFastTransform::Init( AliTPCTransform *transform, Int_t TimeStamp ) { // Initialisation - + if( !transform ){ AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance(); if(!pCalib ) return 1; @@ -103,7 +86,7 @@ Int_t AliHLTTPCFastTransform::Init( AliTPCTransform *transform, Int_t TimeStamp if( !par ) return 1; for( int iSector=0; iSectorGetNSector(); iSector++ ){ - for( int iRow=0; iRowGetNRow(iSector); iRow++){ + for( int iRow=0; iRowGetNRow(iSector); iRow++){ InitRow( iSector, iRow ); } } @@ -149,8 +132,9 @@ void AliHLTTPCFastTransform::SetCurrentTimeStamp( Int_t TimeStamp ) fTimeBorder1 = 60; fTimeBorder2 = fLastTimeBin - 100; - for( Int_t i=0; i<72; i++ ) + for( Int_t i=0; i<72; i++ ){ for( Int_t j=0; j<100; j++ ) if( fRows[i][j] ) InitRow(i,j); + } } Int_t AliHLTTPCFastTransform::InitRow( Int_t iSector, Int_t iRow ) diff --git a/HLT/TPCLib/transform/AliHLTTPCFastTransform.h b/HLT/TPCLib/transform/AliHLTTPCFastTransform.h index bd7f0d9787e..843f2917957 100644 --- a/HLT/TPCLib/transform/AliHLTTPCFastTransform.h +++ b/HLT/TPCLib/transform/AliHLTTPCFastTransform.h @@ -37,7 +37,6 @@ class AliHLTTPCFastTransform{ public: static AliHLTTPCFastTransform* Instance(); - static void Terminate(); /** standard constructor */ AliHLTTPCFastTransform(); @@ -75,7 +74,7 @@ class AliHLTTPCFastTransform{ /** assignment operator prohibited */ AliHLTTPCFastTransform& operator=(const AliHLTTPCFastTransform&); - static AliHLTTPCFastTransform* fgInstance; // singleton control + static AliHLTTPCFastTransform fgInstance; // singleton control struct AliRowTransform{ AliHLTTPCSpline2D3D fSpline[3]; @@ -107,9 +106,8 @@ inline Int_t AliHLTTPCFastTransform::Transform( Int_t iSec, Int_t iRow, Float_t } -inline AliHLTTPCFastTransform* AliHLTTPCFastTransform::Instance(){ // Singleton implementation - if( !fgInstance ) fgInstance = new AliHLTTPCFastTransform(); - return fgInstance; +inline AliHLTTPCFastTransform* AliHLTTPCFastTransform::Instance(){ // Singleton implementation + return &fgInstance; } #endif -- 2.39.3