]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/calibration/AliHLTTPCCalibSeedMakerComponent.cxx
- removed TObjArray for the storing of clusters
[u/mrichter/AliRoot.git] / HLT / TPCLib / calibration / AliHLTTPCCalibSeedMakerComponent.cxx
CommitLineData
33a4976d 1// $Id$
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 AliHLTTPCCalibSeedMakerComponent.cxx
20 @author Kalliopi Kanaki
21 @date 2009-07-08
22 @brief
23*/
24
25#if __GNUC__>= 3
26using namespace std;
27#endif
28
29#include "AliHLTTPCCalibSeedMakerComponent.h"
30#include "AliHLTTPCTransform.h"
31#include "AliHLTTPCDefinitions.h"
32#include "AliHLTTPCOfflineCluster.h"
33#include "AliHLTTPCSpacePointData.h"
34#include "AliHLTTPCTrackletDataFormat.h"
35#include "AliHLTExternalTrackParam.h"
36#include "AliHLTGlobalBarrelTrack.h"
37
38#include "AliTPCclusterMI.h"
39#include "AliTPCseed.h"
40#include "AliTPCcalibDB.h"
472dbf06 41#include "AliTPCParam.h"
33a4976d 42
43#include "AliRieman.h"
44
45#include "AliCDBEntry.h"
46#include "AliCDBManager.h"
47#include "AliCDBStorage.h"
48
49#include <cstdlib>
50#include <cerrno>
51
52#include "TObjArray.h"
4c4e26a3 53#include "TClonesArray.h"
33a4976d 54#include "TObject.h"
55#include <sys/time.h>
56
57ClassImp(AliHLTTPCCalibSeedMakerComponent) //ROOT macro for the implementation of ROOT specific class methods
58
59AliHLTTPCCalibSeedMakerComponent::AliHLTTPCCalibSeedMakerComponent()
60 :
a00412ee 61 fTPCGeomParam(0)
62 ,fSeedArray(0)
33a4976d 63{
64 // see header file for class documentation
65 // or
66 // refer to README to build package
67 // or
68 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
69}
70
71AliHLTTPCCalibSeedMakerComponent::~AliHLTTPCCalibSeedMakerComponent() {
72// see header file for class documentation
33a4976d 73}
74
33a4976d 75const char* AliHLTTPCCalibSeedMakerComponent::GetComponentID() {
76// see header file for class documentation
77
78 return "TPCCalibSeedMaker";
79}
80
81void AliHLTTPCCalibSeedMakerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
82// see header file for class documentation
83
84 list.clear();
85 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
33a4976d 86 list.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
87
88}
89
90AliHLTComponentDataType AliHLTTPCCalibSeedMakerComponent::GetOutputDataType(){
91// see header file for class documentation
92
93 //return kAliHLTMultipleDataType;
94 return kAliHLTDataTypeTObjArray;
95}
96
97int AliHLTTPCCalibSeedMakerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
98// see header file for class documentation
99
100 tgtList.clear();
1151db47 101 tgtList.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
33a4976d 102 return tgtList.size();
103}
104
105void AliHLTTPCCalibSeedMakerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
106// see header file for class documentation
107
108 constBase=0;
109 inputMultiplier=2.0; // to be estimated
110}
111
112AliHLTComponent* AliHLTTPCCalibSeedMakerComponent::Spawn() {
113// see header file for class documentation
114
115 return new AliHLTTPCCalibSeedMakerComponent();
116}
117
118int AliHLTTPCCalibSeedMakerComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
119// see header file for class documentation
120
472dbf06 121 fTPCGeomParam = AliTPCcalibDB::Instance()->GetParameters();
122 if(!fTPCGeomParam) HLTError("TPC Parameters are not loaded.");
5c1cc2ea 123
8008c07c 124 fSeedArray = new TClonesArray("AliTPCseed");
33a4976d 125 return 0;
126
127} // end DoInit()
128
129int AliHLTTPCCalibSeedMakerComponent::DoDeinit() {
130// see header file for class documentation
5c1cc2ea 131
a00412ee 132 if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = NULL;
133 if(fSeedArray) delete fSeedArray; fSeedArray = NULL;
8008c07c 134
33a4976d 135 return 0;
136}
137
138int AliHLTTPCCalibSeedMakerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
139// see header file for class documentation
140
141 const AliHLTComponentBlockData *iter = NULL;
142 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR)) return 0;
143
144 Int_t totalSpacePoints = 0;
145 Int_t usedSpacePoints = 0;
146
147
148 // ---------- Access to clusters --------------------//
149
150 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
151
152 if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType) continue;
153
154 AliHLTUInt8_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
155 AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
272c1851 156
33a4976d 157 const AliHLTTPCClusterData *clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
158 Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt;
159
160 totalSpacePoints += nSpacepoint;
161
162 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
163
164 if(fClustersArray[minSlice][minPartition] != NULL){
165 //delete(fClustersArray[minSlice][minPartition]);
166 fClustersArray[minSlice][minPartition] = NULL;
167 }
8677d183 168
169 // fill the array with AliHLTTPCSpacePointData pointers
170 // it will be used in the track loop to access information
171 // for the used clusters only
33a4976d 172 fClustersArray[minSlice][minPartition] = clusters;
173 fNSpacePoints[minSlice][minPartition] = nSpacepoint;
272c1851 174
33a4976d 175 if(nSpacepoint==0) fClustersArray[minSlice][minPartition] = NULL;
176
177 } // end of loop over blocks of clusters
178
179 HLTDebug("Total space points: %d", totalSpacePoints);
272c1851 180
8677d183 181 //------------------ Access to track data blocks --------------------//
a00412ee 182
183 fSeedArray->Clear();
c1cd2f4b 184 for(iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
185
33a4976d 186 if(iter->fDataType != (kAliHLTDataTypeTrack|kAliHLTDataOriginTPC)) continue;
272c1851 187
8677d183 188 // create a vector of AliHLTGlobalBarrelTrack tracks from AliHLTTracksData
33a4976d 189 vector<AliHLTGlobalBarrelTrack> tracks;
272c1851 190 AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracks);
191
5c1cc2ea 192 // loop over the elements(tracks) of the AliHLTGlobalBarrelTrack vector
4c4e26a3 193
194 Int_t nTracks = 0;
33a4976d 195 for(vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); element!=tracks.end(); element++){
4c4e26a3 196
b592e87a 197 AliRieman rieman(element->GetNumberOfPoints());
33a4976d 198 rieman.Reset();
f138d9f6 199 //AliTPCseed *seed = 0x0;
33a4976d 200 Double_t param[5]; for(Int_t i=0; i<5; i++) param[i] = 0.;
201 Double_t cov[15]; for(Int_t i=0; i<15; i++) cov[i] = 0.;
202 Double_t xmin = 1000.;
203 Double_t alpha = 0.;
204
205 // calculate padrow radius (x - radius)
206 Double_t xrow[160]; for(Int_t i=0; i<160; i++) xrow[i] = 0.;
207 Int_t nrowlow = fTPCGeomParam->GetNRowLow();
208 Int_t nrowup = fTPCGeomParam->GetNRowUp();
472dbf06 209
33a4976d 210 for (Int_t i=0;i<nrowlow;i++) xrow[i] = fTPCGeomParam->GetPadRowRadiiLow(i);
211 for (Int_t i=0;i<nrowup;i++) xrow[i+nrowlow] = fTPCGeomParam->GetPadRowRadiiUp(i);
472dbf06 212
9b99ccf1 213 // sector rotation angles - only one angle is needed
214 Double_t angle = fTPCGeomParam->GetInnerAngle();
272c1851 215
8677d183 216 const UInt_t *hitnum = element->GetPoints(); // store the clusters on each track in an array and loop over them
a00412ee 217
8008c07c 218 AliTPCclusterMI* offClusterArray[element->GetNumberOfPoints()];
219 for(UInt_t k=0; k<element->GetNumberOfPoints(); k++) offClusterArray[k] = 0x0;
220
221 for(UInt_t i=0; i<element->GetNumberOfPoints(); i++){
222
272c1851 223 // the id of the cluster contains information about the slice and partition it belongs to
8677d183 224 // as well as its index (pos)
272c1851 225
226 UInt_t idTrack = hitnum[i];
227 Int_t sliceTrack = idTrack>>25; //(idTrack>>25) & 0x7f;
33a4976d 228 Int_t patchTrack = (idTrack>>22) & 0x7;
229 UInt_t pos = idTrack&0x3fffff;
230
8677d183 231 // use the fClustersArray that was filled in the cluster loop
272c1851 232 if( !fClustersArray[sliceTrack][patchTrack] ) continue;
233
234 if(sliceTrack<0 || sliceTrack>36 || patchTrack<0 || patchTrack>5 ){
235 HLTError("Corrupted TPC cluster Id: slice %d, patch %d, cluster %d", sliceTrack, patchTrack, idTrack);
236 continue;
237 }
238
239 if(fNSpacePoints[sliceTrack][patchTrack]<=pos ){
240 HLTError("Space point array out of boundaries!");
241 continue;
242 }
33a4976d 243
8677d183 244 // get the sector(detector) information
33a4976d 245 Int_t sector, row = -99;
246 AliHLTTPCTransform::Slice2Sector(sliceTrack, (fClustersArray[sliceTrack][patchTrack])[pos].fPadRow, sector, row);
ac2b8030 247
248 // next line recalculates rows in the sector(ROC) system
249 //if(patchTrack>1) (fClustersArray[sliceTrack][patchTrack])[pos].fPadRow -= 63;//(Int_t)AliHLTTPCTransform::GetFirstRow(2);
33a4976d 250
33a4976d 251 HLTDebug("slice %d, partition :%d, sector row: %d", sliceTrack, patchTrack, (fClustersArray[sliceTrack][patchTrack])[pos].fPadRow);
c1cd2f4b 252
a00412ee 253 // convert the HLT clusters to AliTPCclusterMI
254 AliHLTTPCOfflineCluster pConv;
255 AliTPCclusterMI *offClus = pConv.ConvertHLTToOffline((fClustersArray[sliceTrack][patchTrack])[pos]);
8008c07c 256 offClus->SetDetector(sector);
257 offClusterArray[i] = offClus;
258
a00412ee 259 rieman.AddPoint( offClus->GetX(), offClus->GetY(), offClus->GetZ(),TMath::Sqrt(offClus->GetSigmaY2()),TMath::Sqrt(offClus->GetSigmaZ2()) );
260 alpha = 0.5*angle+angle*(sector%18); //sector rotation angle
9b99ccf1 261
8008c07c 262 //HLTInfo("detector: %d, row: %d, xrow[row]: %f", sector, offClus->GetRow(), xrow[offClus->GetRow()]);
9b99ccf1 263
a00412ee 264 usedSpacePoints++;
8008c07c 265 } // end of cluster loop
33a4976d 266
8677d183 267 // creation of AliTPCseed by means of a Riemann fit
33a4976d 268 rieman.Update();
269 rieman.GetExternalParameters(xmin,param,cov);
4c4e26a3 270
8008c07c 271 new((*fSeedArray)[nTracks]) AliTPCseed(xmin,alpha,param,cov,0);
4c4e26a3 272 dynamic_cast<AliTPCseed*>(fSeedArray->At(nTracks))->SetLabel(element->GetID());
8008c07c 273 //dynamic_cast<AliTPCseed*>(fSeedArray->At(nTracks))->fClusterOwner = kTRUE;
274
275 // set the cluster pointers for the seed
276 for( UInt_t j=0; j<element->GetNumberOfPoints(); j++){
277 dynamic_cast<AliTPCseed*>(fSeedArray->At(nTracks))->SetClusterPointer(offClusterArray[j]->GetRow(), offClusterArray[j]);
a00412ee 278 }
8008c07c 279
280 //printf("kelly seed number of clusters %i\n", dynamic_cast<AliTPCseed*>(fSeedArray->At(nTracks))->GetNumberOfClusters()); // not set properly, always 1
a00412ee 281 //printf("kelly seed calib dedx: %f, P: %f\n", dynamic_cast<AliTPCseed*>(fSeedArray->At(nTracks))->CookdEdx(0.02,0.6), dynamic_cast<AliTPCseed*>(fSeedArray->At(nTracks))->P());
282
8008c07c 283 HLTDebug("External track parameters: seed: 0x%08x, xmin: %f, alpha: %f, param[0]: %f, cov[0]: %f\n", dynamic_cast<AliTPCseed*>(fSeedArray->At(nTracks)), xmin, alpha, param[0], cov[0]);
4c4e26a3 284 nTracks++;
8677d183 285
9b99ccf1 286 }// end of vector track loop
33a4976d 287 } // end of loop over blocks of merged tracks
288
289 HLTDebug("Used space points: %d", usedSpacePoints);
5c1cc2ea 290 HLTDebug("Number of entries in fSeedArray: %d", fSeedArray->GetEntries());
a00412ee 291
272c1851 292 PushBack((TObject*)fSeedArray, kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC, 0x0);
a00412ee 293
33a4976d 294 return 0;
295} // end DoEvent()