1 // $Id: AliHLTTPCClusterTransformation.cxx 41244 2010-05-14 08:13:35Z kkanaki $
3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /** @file AliHLTTPCClusterTransformation.cxx
20 @author Kalliopi Kanaki, Sergey Gorbubnov
26 #include "AliHLTTPCClusterTransformation.h"
27 #include "AliHLTTPCTransform.h"
28 #include "AliHLTTPCFastTransform.h"
30 #include "AliCDBPath.h"
31 #include "AliCDBManager.h"
32 #include "AliCDBEntry.h"
33 #include "AliGRPObject.h"
34 #include "AliTPCcalibDB.h"
35 #include "AliTPCTransform.h"
36 #include "AliTPCParam.h"
37 #include "AliTPCRecoParam.h"
38 #include "AliGeomManager.h"
39 #include "AliRunInfo.h"
40 #include "AliEventInfo.h"
41 #include "AliRawEventHeaderBase.h"
47 ClassImp(AliHLTTPCClusterTransformation) //ROOT macro for the implementation of ROOT specific class methods
49 AliRecoParam AliHLTTPCClusterTransformation::fOfflineRecoParam;
51 AliHLTTPCClusterTransformation::AliHLTTPCClusterTransformation()
56 // see header file for class documentation
58 // refer to README to build package
60 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
63 AliHLTTPCClusterTransformation::~AliHLTTPCClusterTransformation()
65 // see header file for class documentation
69 int AliHLTTPCClusterTransformation::Init( double FieldBz, Long_t TimeStamp )
73 if(!AliGeomManager::GetGeometry()){
74 AliGeomManager::LoadGeometry();
77 if(!AliGeomManager::GetGeometry()) return Error(-1,"AliHLTTPCClusterTransformation::Init: Can not initialise geometry");
79 AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
81 if(!pCalib ) return Error(-2,"AliHLTTPCClusterTransformation::Init: Calibration not found");
83 pCalib->SetExBField(FieldBz);
85 if( !pCalib->GetTransform() ) return Error(-3,"AliHLTTPCClusterTransformation::Init: No TPC transformation found");
87 // -- Get AliRunInfo variables
89 AliGRPObject tmpGRP, *pGRP=0;
91 AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
93 if(!entry) return Error(-4,"AliHLTTPCClusterTransformation::Init: No GRP object found in data base");
96 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
99 //cout<<"Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject"<<endl;
102 pGRP->ReadValuesFromMap(m);
105 //cout<<"Found an AliGRPObject in GRP/GRP/Data, reading it"<<endl;
106 pGRP = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
111 return Error(-5,"AliHLTTPCClusterTransformation::Init: Unknown format of the GRP object in data base");
114 AliRunInfo runInfo(pGRP->GetLHCState(),pGRP->GetBeamType(),pGRP->GetBeamEnergy(),pGRP->GetRunType(),pGRP->GetDetectorMask());
116 evInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
118 entry=AliCDBManager::Instance()->Get("TPC/Calib/RecoParam");
120 if(!entry) return Error(-6,"AliHLTTPCClusterTransformation::Init: No TPC reco param entry found in data base");
122 TObject *recoParamObj = entry->GetObject();
123 if(!recoParamObj) return Error(-7,"AliHLTTPCClusterTransformation::Init: Empty TPC reco param entry in data base");
125 if (dynamic_cast<TObjArray*>(recoParamObj)) {
126 //cout<<"\n\nSet reco param from AliHLTTPCClusterTransformation: TObjArray found \n"<<endl;
127 TObjArray *copy = (TObjArray*)( static_cast<TObjArray*>(recoParamObj)->Clone() );
128 fOfflineRecoParam.AddDetRecoParamArray(1,copy);
130 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
131 //cout<<"\n\nSet reco param from AliHLTTPCClusterTransformation: AliDetectorRecoParam found \n"<<endl;
132 AliDetectorRecoParam *copy = (AliDetectorRecoParam*)static_cast<AliDetectorRecoParam*>(recoParamObj)->Clone();
133 fOfflineRecoParam.AddDetRecoParam(1,copy);
135 return Error(-8,"AliHLTTPCClusterTransformation::Init: Unknown format of the TPC Reco Param entry in the data base");
139 fOfflineRecoParam.SetEventSpecie(&runInfo, evInfo, 0);
143 AliTPCRecoParam* recParam = (AliTPCRecoParam*)fOfflineRecoParam.GetDetRecoParam(1);
145 if( !recParam ) return Error(-9,"AliHLTTPCClusterTransformation::Init: No TPC Reco Param entry found for the given event specification");
148 pCalib->GetTransform()->SetCurrentRecoParam(recParam);
150 // set current time stamp and initialize the fast transformation
151 int err = fFastTransform.Init( pCalib->GetTransform(), TimeStamp );
154 return Error(-10,Form( "AliHLTTPCClusterTransformation::Init: Initialisation of Fast Transformation failed with error %d :%s",err,fFastTransform.GetLastError()) );
160 Bool_t AliHLTTPCClusterTransformation::IsInitialised() const
162 // Is the transformation initialised
163 return fFastTransform.IsInitialised();
166 void AliHLTTPCClusterTransformation::DeInit()
169 fFastTransform.DeInit();
172 Int_t AliHLTTPCClusterTransformation::SetCurrentTimeStamp( Long_t TimeStamp )
174 // Set the current time stamp
176 AliTPCRecoParam* recParam = (AliTPCRecoParam*)fOfflineRecoParam.GetDetRecoParam(1);
177 if( !recParam ) return Error(-1,"AliHLTTPCClusterTransformation::SetCurrentTimeStamp: No TPC Reco Param entry found");
179 AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
180 if(!pCalib ) return Error(-2,"AliHLTTPCClusterTransformation::Init: Calibration not found");
182 if( !pCalib->GetTransform() ) return Error(-3,"AliHLTTPCClusterTransformation::SetCurrentTimeStamp: No TPC transformation found");
184 pCalib->GetTransform()->SetCurrentRecoParam(recParam);
186 int err = fFastTransform.SetCurrentTimeStamp( TimeStamp );
188 return Error(-4,Form( "AliHLTTPCClusterTransformation::SetCurrentTimeStamp: SetCurrentTimeStamp to the Fast Transformation failed with error %d :%s",err,fFastTransform.GetLastError()) );
193 void AliHLTTPCClusterTransformation::Print(const char* /*option*/) const
196 fFastTransform.Print();
200 Int_t AliHLTTPCClusterTransformation::GetSize() const
202 // total size of the object
203 int size = sizeof(AliHLTTPCClusterTransformation) - sizeof(AliHLTTPCFastTransform) + fFastTransform.GetSize();