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 AliHLTTPCCalibSeedMakerComponent.cxx
20 @author Kalliopi Kanaki
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"
38 #include "AliTPCclusterMI.h"
39 #include "AliTPCseed.h"
40 #include "AliTPCcalibDB.h"
41 #include "AliTPCParamSR.h"
43 #include "AliRieman.h"
45 #include "AliCDBEntry.h"
46 #include "AliCDBManager.h"
47 #include "AliCDBStorage.h"
52 #include "TObjArray.h"
56 ClassImp(AliHLTTPCCalibSeedMakerComponent) //ROOT macro for the implementation of ROOT specific class methods
58 AliHLTTPCCalibSeedMakerComponent::AliHLTTPCCalibSeedMakerComponent()
68 // see header file for class documentation
70 // refer to README to build package
72 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
75 AliHLTTPCCalibSeedMakerComponent::~AliHLTTPCCalibSeedMakerComponent() {
76 // see header file for class documentation
80 // Public functions to implement AliHLTComponent's interface.
81 // These functions are required for the registration process
83 const char* AliHLTTPCCalibSeedMakerComponent::GetComponentID() {
84 // see header file for class documentation
86 return "TPCCalibSeedMaker";
89 void AliHLTTPCCalibSeedMakerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
90 // see header file for class documentation
93 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
94 //list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType);
95 list.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
99 AliHLTComponentDataType AliHLTTPCCalibSeedMakerComponent::GetOutputDataType(){
100 // see header file for class documentation
102 //return kAliHLTMultipleDataType;
103 return kAliHLTDataTypeTObjArray;
106 int AliHLTTPCCalibSeedMakerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
107 // see header file for class documentation
110 //tgtList.push_back(AliHLTTPCDefinitions::fgkAliHLTDataTypeTPCSeed);
111 tgtList.push_back(kAliHLTDataTypeTObjArray);
112 return tgtList.size();
115 void AliHLTTPCCalibSeedMakerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
116 // see header file for class documentation
119 inputMultiplier=2.0; // to be estimated
122 AliHLTComponent* AliHLTTPCCalibSeedMakerComponent::Spawn() {
123 // see header file for class documentation
125 return new AliHLTTPCCalibSeedMakerComponent();
128 int AliHLTTPCCalibSeedMakerComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
129 // see header file for class documentation
131 fTPCGeomParam = new AliTPCParamSR;
132 if(fTPCGeomParam) fTPCGeomParam->ReadGeoMatrices();
134 fSeedArray = new TObjArray;
135 fSeedArray->SetOwner(kTRUE);
140 int AliHLTTPCCalibSeedMakerComponent::DoDeinit() {
141 // see header file for class documentation
143 if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = NULL;
144 if(fSeedArray) delete fSeedArray; fSeedArray = NULL;
148 int AliHLTTPCCalibSeedMakerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
149 // see header file for class documentation
151 const AliHLTComponentBlockData *iter = NULL;
152 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR)) return 0;
154 Int_t totalSpacePoints = 0;
155 Int_t usedSpacePoints = 0;
158 // ---------- Access to clusters --------------------//
160 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
162 if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType) continue;
164 AliHLTUInt8_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
165 AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
167 const AliHLTTPCClusterData *clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
168 Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt;
170 totalSpacePoints += nSpacepoint;
172 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
174 if(fClustersArray[minSlice][minPartition] != NULL){
175 //delete(fClustersArray[minSlice][minPartition]);
176 fClustersArray[minSlice][minPartition] = NULL;
179 // fill the array with AliHLTTPCSpacePointData pointers
180 // it will be used in the track loop to access information
181 // for the used clusters only
182 fClustersArray[minSlice][minPartition] = clusters;
183 fNSpacePoints[minSlice][minPartition] = nSpacepoint;
185 if(nSpacepoint==0) fClustersArray[minSlice][minPartition] = NULL;
187 } // end of loop over blocks of clusters
189 HLTDebug("Total space points: %d", totalSpacePoints);
192 //------------------ Access to track data blocks --------------------//
194 //TObjArray *offClusterArray = new TObjArray;
195 //offClusterArray->SetOwner(kTRUE);
196 //offClusterArray->Clear();
200 for(iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
202 if(iter->fDataType != (kAliHLTDataTypeTrack|kAliHLTDataOriginTPC)) continue;
204 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
205 AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
207 if( slice < fMinSlice ) fMinSlice = slice;
208 if( slice > fMaxSlice ) fMaxSlice = slice;
209 if( partition < fMinPartition ) fMinPartition = partition;
210 if( partition > fMaxPartition ) fMaxPartition = partition;
213 // create a vector of AliHLTGlobalBarrelTrack tracks from AliHLTTracksData
214 vector<AliHLTGlobalBarrelTrack> tracks;
215 AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracks);
217 // loop over the elements(tracks) of the AliHLTGlobalBarrelTrack vector
219 for(vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); element!=tracks.end(); element++){
221 AliRieman rieman(element->GetNumberOfPoints());
223 AliTPCseed *seed = 0x0;
224 Double_t param[5]; for(Int_t i=0; i<5; i++) param[i] = 0.;
225 Double_t cov[15]; for(Int_t i=0; i<15; i++) cov[i] = 0.;
226 Double_t xmin = 1000.;
229 // calculate padrow radius (x - radius)
230 Double_t xrow[160]; for(Int_t i=0; i<160; i++) xrow[i] = 0.;
231 Int_t nrowlow = fTPCGeomParam->GetNRowLow();
232 Int_t nrowup = fTPCGeomParam->GetNRowUp();
234 for (Int_t i=0;i<nrowlow;i++) xrow[i] = fTPCGeomParam->GetPadRowRadiiLow(i);
235 for (Int_t i=0;i<nrowup;i++) xrow[i+nrowlow] = fTPCGeomParam->GetPadRowRadiiUp(i);
237 // sector rotation angles
238 Double_t angle_in = fTPCGeomParam->GetInnerAngle();
239 Double_t angle_shift_in = fTPCGeomParam->GetInnerAngleShift();
240 Double_t angle_out = fTPCGeomParam->GetOuterAngle();
241 Double_t angle_shift_out = fTPCGeomParam->GetOuterAngleShift();
243 //offClusterArray->Clear();
245 const UInt_t *hitnum = element->GetPoints(); // store the clusters on each track in an array and loop over them
246 for(UInt_t i=0; i<element->GetNumberOfPoints(); i++){
248 // the id of the cluster contains information about the slice and partition it belongs too
249 // as well as its index (pos)
250 UInt_t idTrack = hitnum[i];
251 Int_t sliceTrack = (idTrack>>25) & 0x7f;
252 Int_t patchTrack = (idTrack>>22) & 0x7;
253 UInt_t pos = idTrack&0x3fffff;
255 // use the fClustersArray that was filled in the cluster loop
256 if( !fClustersArray[sliceTrack][patchTrack] ) continue;
257 if( fNSpacePoints[sliceTrack][patchTrack]<pos ) HLTError("Space point array out of boundaries!");
259 // get the sector(detector) information
260 Int_t sector, row = -99;
261 AliHLTTPCTransform::Slice2Sector(sliceTrack, (fClustersArray[sliceTrack][patchTrack])[pos].fPadRow, sector, row);
263 // next line recalculates rows in the sector(ROC) system
264 //if(patchTrack>1) (fClustersArray[sliceTrack][patchTrack])[pos].fPadRow -= 63;//(Int_t)AliHLTTPCTransform::GetFirstRow(2);
266 HLTDebug("slice %d, partition :%d, sector row: %d", sliceTrack, patchTrack, (fClustersArray[sliceTrack][patchTrack])[pos].fPadRow);
268 // convert the HTL clusters to AliTPCclusterMI
269 AliHLTTPCOfflineCluster pConv;
270 AliTPCclusterMI *offClus = pConv.ConvertHLTToOffline((fClustersArray[sliceTrack][patchTrack])[pos]);
271 offClus->SetDetector(sector);
274 //offClusterArray->Add(offClus);
276 // the clusters are not sorted from max to min X
277 rieman.AddPoint( offClus->GetX(),offClus->GetY(),offClus->GetZ(),TMath::Sqrt(offClus->GetSigmaY2()),TMath::Sqrt(offClus->GetSigmaZ2()) );
279 xmin = TMath::Min(xmin,xrow[offClus->GetRow()]); // min pad-row radius
282 //xmin = TMath::Min(xmin,xrow[offClus->GetRow()]); // min pad-row radius
283 alpha = angle_shift_in+angle_in*(sector%18);
285 //xmin = TMath::Min(xmin,xrow[nrowlow+offClus->GetRow()]); // min pad-row radius
286 alpha = angle_shift_out+angle_out*(sector%18);
288 //if(sector<36) HLTInfo("detector: %d, row: %d, xrow[row]: %f", sector, offClus->GetRow(), xrow[offClus->GetRow()]);
289 //else HLTInfo("detector: %d, row: %d, xrow[row]: %f", sector, offClus->GetRow(), xrow[nrowlow+offClus->GetRow()]);
290 } // end of cluster loop
292 // creation of AliTPCseed by means of a Riemann fit
294 rieman.GetExternalParameters(xmin,param,cov);
295 seed = new AliTPCseed(xmin,alpha,param,cov,0);
297 // is it necessay to set the cluster pointers inside the seed??
298 // for(Int_t j=0; j<offClusterArray->GetEntries(); j++) {
299 // AliTPCclusterMI *cl = (AliTPCclusterMI*)offClusterArray->At(j);
300 // if(cl) seed->SetClusterPointer(cl->GetRow(),cl);
304 HLTInfo("External track parameters: seed: 0x%08x, xmin: %f, alpha: %f, param[0]: %f, cov[0]: %f", seed, xmin, alpha, param[0], cov[0]);
305 fSeedArray->Add(seed);
307 }// end of vector track loop
308 } // end of loop over blocks of merged tracks
310 HLTDebug("Used space points: %d", usedSpacePoints);
311 HLTDebug("Number of entries in fSeedArray: %d", fSeedArray->GetEntries());
314 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( fMinSlice, fMaxSlice, fMinPartition, fMaxPartition );
315 //PushBack((TObject*)offClusterArray, kAliHLTDataTypeTObjArray, fSpecification);
316 PushBack((TObject*)fSeedArray, kAliHLTDataTypeTObjArray, fSpecification);