]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/AliHLTTPCClusterTransformation.cxx
add comment for setters which could be removed since already done in InitParameters...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterTransformation.cxx
index 54dc32720493f63af8451dd03db3a416bde67324..229af200b96924551fce48c94dea62eb848bf118 100644 (file)
 
 #include "AliHLTTPCClusterTransformation.h"
 #include "AliHLTTPCTransform.h"
+#include "AliHLTTPCFastTransform.h"
 
+#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 "Riostream.h"
+#include "AliRunInfo.h"
+#include "AliEventInfo.h"
+#include "AliRawEventHeaderBase.h"
+#include <iostream>
+#include <iomanip>
+
+using namespace std;
 
 ClassImp(AliHLTTPCClusterTransformation) //ROOT macro for the implementation of ROOT specific class methods
 
+AliRecoParam AliHLTTPCClusterTransformation::fOfflineRecoParam;
+
 AliHLTTPCClusterTransformation::AliHLTTPCClusterTransformation()
 :
-  fOfflineTransform(NULL),
-  fOfflineTPCParam( NULL ),
-  fLastSector(-1)
+  fError(),
+  fFastTransform()  
 {
   // see header file for class documentation
   // or
   // refer to README to build package
   // or
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt  
-  fAliT[0] = 0.;
-  fAliT[1] = 0.;
-  fAliT[2] = 0.;
-  for( int i=0; i<9; i++ ) fAliR[i] = 0;
-  fAliR[0] = 1.;
-  fAliR[4] = 1.;
-  fAliR[8] = 1.;
-}
-
-AliHLTTPCClusterTransformation::AliHLTTPCClusterTransformation(const AliHLTTPCClusterTransformation&)
-:
-  fOfflineTransform(NULL),
-  fOfflineTPCParam( NULL ),
-  fLastSector(-1)
-{
-  // copy constructor prohibited
-  fAliT[0] = 0.;
-  fAliT[1] = 0.;
-  fAliT[2] = 0.;
-  for( int i=0; i<9; i++ ) fAliR[i] = 0;
-  fAliR[0] = 1.;
-  fAliR[4] = 1.;
-  fAliR[8] = 1.;
-}
-
-AliHLTTPCClusterTransformation& AliHLTTPCClusterTransformation::operator=(const AliHLTTPCClusterTransformation&)
-{
-  // assignment operator prohibited
-  return *this;
 }
 
 AliHLTTPCClusterTransformation::~AliHLTTPCClusterTransformation() 
 { 
   // see header file for class documentation
-  //delete fOfflineTransform;
 }
 
 
-int  AliHLTTPCClusterTransformation::Init( double FieldBz, UInt_t TimeStamp )
+int  AliHLTTPCClusterTransformation::Init( double FieldBz, Long_t TimeStamp )
 {
   // Initialisation
+  if(!AliGeomManager::GetGeometry()){
+    AliGeomManager::LoadGeometry();
+  }
 
-  //delete fOfflineTransform;
-  fOfflineTransform = 0;
-  fOfflineTPCParam = 0;
-
+  if(!AliGeomManager::GetGeometry()) return Error(-1,"AliHLTTPCClusterTransformation::Init: Can not initialise geometry");
+  
   AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
+  if(!pCalib ) return Error(-2,"AliHLTTPCClusterTransformation::Init: Calibration not found");
+  
+  pCalib->SetExBField(FieldBz);
+  if( !pCalib->GetTransform() ) return Error(-3,"AliHLTTPCClusterTransformation::Init: No TPC transformation found");
+  
+  // -- Get AliRunInfo variables  
 
-  if(!pCalib ) return -1;
+  AliGRPObject tmpGRP, *pGRP=0;
 
-  pCalib->SetExBField(FieldBz);
+  AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
   
-  if(!AliGeomManager::GetGeometry()){
-     AliGeomManager::LoadGeometry();
+  if(!entry) return Error(-4,"AliHLTTPCClusterTransformation::Init: No GRP object found in data base");
+
+  {
+    TMap* m = dynamic_cast<TMap*>(entry->GetObject());  // old GRP entry
+
+    if (m) {
+      //cout<<"Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject"<<endl;
+      m->Print();
+      pGRP = &tmpGRP;
+      pGRP->ReadValuesFromMap(m);
+    }
+    else {
+      //cout<<"Found an AliGRPObject in GRP/GRP/Data, reading it"<<endl;
+      pGRP = dynamic_cast<AliGRPObject*>(entry->GetObject());  // new GRP entry
+    }
+  }
+    
+  if( !pGRP ){
+    return Error(-5,"AliHLTTPCClusterTransformation::Init: Unknown format of the GRP object in data base");
+  }
+
+  AliRunInfo runInfo(pGRP->GetLHCState(),pGRP->GetBeamType(),pGRP->GetBeamEnergy(),pGRP->GetRunType(),pGRP->GetDetectorMask());
+  AliEventInfo evInfo;
+  evInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
+
+  entry=AliCDBManager::Instance()->Get("TPC/Calib/RecoParam");
+
+  if(!entry) return Error(-6,"AliHLTTPCClusterTransformation::Init: No TPC reco param entry found in data base");
+
+  TObject *recoParamObj = entry->GetObject();
+  if(!recoParamObj) return Error(-7,"AliHLTTPCClusterTransformation::Init: Empty TPC reco param entry in data base");
+
+  if (dynamic_cast<TObjArray*>(recoParamObj)) {
+    //cout<<"\n\nSet reco param from AliHLTTPCClusterTransformation: TObjArray found \n"<<endl;
+    TObjArray *copy = (TObjArray*)( static_cast<TObjArray*>(recoParamObj)->Clone() );
+    fOfflineRecoParam.AddDetRecoParamArray(1,copy);
+  }
+  else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
+    //cout<<"\n\nSet reco param from AliHLTTPCClusterTransformation: AliDetectorRecoParam found \n"<<endl;
+    AliDetectorRecoParam *copy = (AliDetectorRecoParam*)static_cast<AliDetectorRecoParam*>(recoParamObj)->Clone();
+    fOfflineRecoParam.AddDetRecoParam(1,copy);
+  } else {    
+    return Error(-8,"AliHLTTPCClusterTransformation::Init: Unknown format of the TPC Reco Param entry in the data base");
   }
+  
+  
+  fOfflineRecoParam.SetEventSpecie(&runInfo, evInfo, 0);    
+  // 
 
-  if( !pCalib->GetTransform() ) return -2; 
+  AliTPCRecoParam* recParam = (AliTPCRecoParam*)fOfflineRecoParam.GetDetRecoParam(1);
 
-  //fOfflineTransform = new AliTPCTransform (*pCalib->GetTransform());
-  fOfflineTransform = pCalib->GetTransform();
-  fOfflineTransform->SetCurrentRecoParam( AliTPCRecoParam::GetHLTParam() );
-  fOfflineTransform->SetCurrentTimeStamp( TimeStamp );
-  fOfflineTPCParam = pCalib->GetParameters(); 
-  if( !fOfflineTPCParam ) return -3;
+  if( !recParam ) return Error(-9,"AliHLTTPCClusterTransformation::Init: No TPC Reco Param entry found for the given event specification");
 
-  fOfflineTPCParam->Update();
-  fOfflineTPCParam->ReadGeoMatrices();  
+  pCalib->GetTransform()->SetCurrentRecoParam(recParam);
 
-  fLastSector = -1;
+  // set current time stamp and initialize the fast transformation
+  int err = fFastTransform.Init( pCalib->GetTransform(), TimeStamp );
 
-  fAliT[0] = 0.;
-  fAliT[1] = 0.;
-  fAliT[2] = 0.;
-  for( int i=0; i<9; i++ ) fAliR[i] = 0;
-  fAliR[0] = 1.;
-  fAliR[4] = 1.;
-  fAliR[8] = 1.;
+  if( err!=0 ){
+    return Error(-10,Form( "AliHLTTPCClusterTransformation::Init: Initialisation of Fast Transformation failed with error %d :%s",err,fFastTransform.GetLastError()) );
+  }
 
   return 0;
 }
 
-
-void AliHLTTPCClusterTransformation::SetCurrentTimeStamp( UInt_t TimeStamp )
+Bool_t AliHLTTPCClusterTransformation::IsInitialised() const 
 {
-  // Set the current time stamp
-  if( fOfflineTransform ) fOfflineTransform->SetCurrentTimeStamp( TimeStamp );
+  // Is the transformation initialised
+  return fFastTransform.IsInitialised();
 }
 
+void AliHLTTPCClusterTransformation::DeInit()
+{
+  // Deinitialisation
+  fFastTransform.DeInit();
+}
 
-int  AliHLTTPCClusterTransformation::Transform( int Slice, int Row, float Pad, float Time, float XYZ[] )
+Int_t AliHLTTPCClusterTransformation::SetCurrentTimeStamp( Long_t TimeStamp )
 {
-  // Convert row, pad, time to X Y Z
-          
-  Int_t sector=-99, thisrow=-99;
-  AliHLTTPCTransform::Slice2Sector( Slice, Row, sector, thisrow);
-
-  if( !fOfflineTransform ){               
-    AliHLTTPCTransform::Raw2Local( XYZ, sector, thisrow, Pad, Time); 
-    if(Slice>17) XYZ[1]= - XYZ[1];        
-    return 0;
-  }
+  // Set the current time stamp  
 
-  Int_t iSector[1]= {sector};   
-  Double_t x[3] = { thisrow, Pad, Time }; 
-  fOfflineTransform->Transform(x,iSector,0,1);
-         
-  if( sector!= fLastSector ){
-    if( fOfflineTPCParam && sector<fOfflineTPCParam->GetNSector() ){
-      TGeoHMatrix  *alignment = fOfflineTPCParam->GetClusterMatrix( sector );
-      if ( alignment ){
-       const Double_t *tr = alignment->GetTranslation();
-       const Double_t *rot = alignment->GetRotationMatrix();
-       if( tr && rot ){
-         for( int i=0; i<3; i++ ) fAliT[i] = tr[i];
-         for( int i=0; i<9; i++ ) fAliR[i] = rot[i];
-       }
-      }
-    } else {
-      fAliT[0] = 0.;
-      fAliT[1] = 0.;
-      fAliT[2] = 0.;
-      for( int i=0; i<9; i++ ) fAliR[i] = 0;
-      fAliR[0] = 1.;
-      fAliR[4] = 1.;
-      fAliR[8] = 1.;
-    }
-    fLastSector = sector;
+  AliTPCRecoParam* recParam = (AliTPCRecoParam*)fOfflineRecoParam.GetDetRecoParam(1);
+  if( !recParam )  return Error(-1,"AliHLTTPCClusterTransformation::SetCurrentTimeStamp: No TPC Reco Param entry found");
+
+  AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
+  if(!pCalib ) return Error(-2,"AliHLTTPCClusterTransformation::Init: Calibration not found");
+   
+  if( !pCalib->GetTransform() ) return Error(-3,"AliHLTTPCClusterTransformation::SetCurrentTimeStamp: No TPC transformation found");
+  
+  pCalib->GetTransform()->SetCurrentRecoParam(recParam);
+
+  int err = fFastTransform.SetCurrentTimeStamp( TimeStamp );
+  if( err!=0 ){
+    return Error(-4,Form( "AliHLTTPCClusterTransformation::SetCurrentTimeStamp: SetCurrentTimeStamp to the Fast Transformation failed with error %d :%s",err,fFastTransform.GetLastError()) );
   }
-  // alignment->LocalToMaster( x, y);
+  return 0;
+}
+
+void AliHLTTPCClusterTransformation::Print(const char* /*option*/) const
+{
+  // print info
+  fFastTransform.Print();
+}
 
-  XYZ[0] = fAliT[0] + x[0]*fAliR[0] + x[1]*fAliR[1] + x[2]*fAliR[2];
-  XYZ[1] = fAliT[1] + x[0]*fAliR[3] + x[1]*fAliR[4] + x[2]*fAliR[5];
-  XYZ[2] = fAliT[2] + x[0]*fAliR[6] + x[1]*fAliR[7] + x[2]*fAliR[8];
 
-  return 0; 
+Int_t AliHLTTPCClusterTransformation::GetSize() const
+{
+  // total size of the object
+  int size = sizeof(AliHLTTPCClusterTransformation) - sizeof(AliHLTTPCFastTransform) + fFastTransform.GetSize();
+  return size;
 }