Line data Source code
1 : // $Id: AliHLTTPCClusterTransformation.cxx 41244 2010-05-14 08:13:35Z kkanaki $
2 :
3 : //**************************************************************************
4 : //* This file is property of and copyright by the ALICE HLT Project *
5 : //* ALICE Experiment at CERN, All rights reserved. *
6 : //* *
7 : //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
8 : //* for The ALICE HLT Project. *
9 : //* *
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 : //**************************************************************************
18 :
19 : /** @file AliHLTTPCClusterTransformation.cxx
20 : @author Kalliopi Kanaki, Sergey Gorbubnov
21 : @date
22 : @brief
23 : */
24 :
25 :
26 : #include "AliHLTTPCClusterTransformation.h"
27 : #include "AliHLTTPCFastTransform.h"
28 : #include "AliHLTTPCDefinitions.h"
29 :
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"
42 : #include <iostream>
43 : #include <iomanip>
44 :
45 : using namespace std;
46 :
47 6 : ClassImp(AliHLTTPCClusterTransformation) //ROOT macro for the implementation of ROOT specific class methods
48 :
49 6 : AliRecoParam AliHLTTPCClusterTransformation::fOfflineRecoParam;
50 :
51 : AliHLTTPCClusterTransformation::AliHLTTPCClusterTransformation()
52 : :
53 6 : fError(),
54 6 : fFastTransform()
55 24 : {
56 : // see header file for class documentation
57 : // or
58 : // refer to README to build package
59 : // or
60 : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61 12 : }
62 :
63 : AliHLTTPCClusterTransformation::~AliHLTTPCClusterTransformation()
64 24 : {
65 : // see header file for class documentation
66 12 : }
67 :
68 :
69 : int AliHLTTPCClusterTransformation::Init( double FieldBz, Long_t TimeStamp )
70 : {
71 : // Initialisation
72 :
73 0 : if(!AliGeomManager::GetGeometry()){
74 0 : AliGeomManager::LoadGeometry();
75 0 : }
76 :
77 0 : if(!AliGeomManager::GetGeometry()) return Error(-1,"AliHLTTPCClusterTransformation::Init: Can not initialise geometry");
78 :
79 0 : AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
80 :
81 0 : if(!pCalib ) return Error(-2,"AliHLTTPCClusterTransformation::Init: Calibration not found");
82 :
83 0 : pCalib->SetExBField(FieldBz);
84 :
85 0 : if( !pCalib->GetTransform() ) return Error(-3,"AliHLTTPCClusterTransformation::Init: No TPC transformation found");
86 :
87 : // -- Get AliRunInfo variables
88 :
89 0 : AliGRPObject tmpGRP, *pGRP=0;
90 :
91 0 : AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
92 :
93 0 : if(!entry) return Error(-4,"AliHLTTPCClusterTransformation::Init: No GRP object found in data base");
94 :
95 : {
96 0 : TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
97 :
98 0 : if (m) {
99 : //cout<<"Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject"<<endl;
100 0 : m->Print();
101 : pGRP = &tmpGRP;
102 0 : pGRP->ReadValuesFromMap(m);
103 : }
104 : else {
105 : //cout<<"Found an AliGRPObject in GRP/GRP/Data, reading it"<<endl;
106 0 : pGRP = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
107 : }
108 : }
109 :
110 0 : if( !pGRP ){
111 0 : return Error(-5,"AliHLTTPCClusterTransformation::Init: Unknown format of the GRP object in data base");
112 : }
113 :
114 0 : AliRunInfo runInfo(pGRP->GetLHCState(),pGRP->GetBeamType(),pGRP->GetBeamEnergy(),pGRP->GetRunType(),pGRP->GetDetectorMask());
115 0 : AliEventInfo evInfo;
116 0 : evInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
117 :
118 0 : entry=AliCDBManager::Instance()->Get("TPC/Calib/RecoParam");
119 :
120 0 : if(!entry) return Error(-6,"AliHLTTPCClusterTransformation::Init: No TPC reco param entry found in data base");
121 :
122 0 : TObject *recoParamObj = entry->GetObject();
123 0 : if(!recoParamObj) return Error(-7,"AliHLTTPCClusterTransformation::Init: Empty TPC reco param entry in data base");
124 :
125 0 : if (dynamic_cast<TObjArray*>(recoParamObj)) {
126 : //cout<<"\n\nSet reco param from AliHLTTPCClusterTransformation: TObjArray found \n"<<endl;
127 0 : TObjArray *copy = (TObjArray*)( static_cast<TObjArray*>(recoParamObj)->Clone() );
128 0 : fOfflineRecoParam.AddDetRecoParamArray(1,copy);
129 0 : }
130 0 : else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
131 : //cout<<"\n\nSet reco param from AliHLTTPCClusterTransformation: AliDetectorRecoParam found \n"<<endl;
132 0 : AliDetectorRecoParam *copy = (AliDetectorRecoParam*)static_cast<AliDetectorRecoParam*>(recoParamObj)->Clone();
133 0 : fOfflineRecoParam.AddDetRecoParam(1,copy);
134 : } else {
135 0 : return Error(-8,"AliHLTTPCClusterTransformation::Init: Unknown format of the TPC Reco Param entry in the data base");
136 : }
137 :
138 :
139 0 : fOfflineRecoParam.SetEventSpecie(&runInfo, evInfo, 0);
140 :
141 : //
142 :
143 0 : AliTPCRecoParam* recParam = (AliTPCRecoParam*)fOfflineRecoParam.GetDetRecoParam(1);
144 :
145 0 : if( !recParam ) return Error(-9,"AliHLTTPCClusterTransformation::Init: No TPC Reco Param entry found for the given event specification");
146 :
147 :
148 0 : pCalib->GetTransform()->SetCurrentRecoParam(recParam);
149 :
150 : // set current time stamp and initialize the fast transformation
151 0 : int err = fFastTransform.Init( pCalib->GetTransform(), TimeStamp );
152 :
153 0 : if( err!=0 ){
154 0 : return Error(-10,Form( "AliHLTTPCClusterTransformation::Init: Initialisation of Fast Transformation failed with error %d :%s",err,fFastTransform.GetLastError()) );
155 : }
156 :
157 0 : return 0;
158 0 : }
159 :
160 :
161 : Int_t AliHLTTPCClusterTransformation::Init( const AliHLTTPCFastTransformObject &obj )
162 : {
163 : // Initialisation
164 :
165 0 : if(!AliGeomManager::GetGeometry()){
166 0 : AliGeomManager::LoadGeometry();
167 0 : }
168 :
169 0 : if(!AliGeomManager::GetGeometry()) return Error(-1,"AliHLTTPCClusterTransformation::Init: Can not initialise geometry");
170 :
171 : // set current time stamp and initialize the fast transformation
172 0 : int err = fFastTransform.ReadFromObject( obj );
173 :
174 0 : if( err!=0 ){
175 0 : return Error(-10,Form( "AliHLTTPCClusterTransformation::Init: Initialisation of Fast Transformation failed with error %d :%s",err,fFastTransform.GetLastError()) );
176 : }
177 0 : return(0);
178 0 : }
179 :
180 :
181 : Bool_t AliHLTTPCClusterTransformation::IsInitialised() const
182 : {
183 : // Is the transformation initialised
184 0 : return fFastTransform.IsInitialised();
185 : }
186 :
187 : void AliHLTTPCClusterTransformation::DeInit()
188 : {
189 : // Deinitialisation
190 0 : fFastTransform.DeInit();
191 0 : }
192 :
193 : Int_t AliHLTTPCClusterTransformation::SetCurrentTimeStamp( Long_t TimeStamp )
194 : {
195 : // Set the current time stamp
196 :
197 0 : AliTPCRecoParam* recParam = (AliTPCRecoParam*)fOfflineRecoParam.GetDetRecoParam(1);
198 0 : if( !recParam ) return Error(-1,"AliHLTTPCClusterTransformation::SetCurrentTimeStamp: No TPC Reco Param entry found");
199 :
200 0 : AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
201 0 : if(!pCalib ) return Error(-2,"AliHLTTPCClusterTransformation::Init: Calibration not found");
202 :
203 0 : if( !pCalib->GetTransform() ) return Error(-3,"AliHLTTPCClusterTransformation::SetCurrentTimeStamp: No TPC transformation found");
204 :
205 0 : pCalib->GetTransform()->SetCurrentRecoParam(recParam);
206 :
207 0 : int err = fFastTransform.SetCurrentTimeStamp( TimeStamp );
208 0 : if( err!=0 ){
209 0 : return Error(-4,Form( "AliHLTTPCClusterTransformation::SetCurrentTimeStamp: SetCurrentTimeStamp to the Fast Transformation failed with error %d :%s",err,fFastTransform.GetLastError()) );
210 : }
211 0 : return 0;
212 0 : }
213 :
214 : void AliHLTTPCClusterTransformation::Print(const char* /*option*/) const
215 : {
216 : // print info
217 0 : fFastTransform.Print();
218 0 : }
219 :
220 :
221 : Int_t AliHLTTPCClusterTransformation::GetSize() const
222 : {
223 : // total size of the object
224 0 : int size = sizeof(AliHLTTPCClusterTransformation) - sizeof(AliHLTTPCFastTransform) + fFastTransform.GetSize();
225 0 : return size;
226 : }
|