]>
Commit | Line | Data |
---|---|---|
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 | ||
3d144ee9 | 25 | #include <map> |
26 | ||
33a4976d | 27 | #include "AliHLTTPCCalibSeedMakerComponent.h" |
28 | #include "AliHLTTPCTransform.h" | |
29 | #include "AliHLTTPCDefinitions.h" | |
30 | #include "AliHLTTPCOfflineCluster.h" | |
31 | #include "AliHLTTPCSpacePointData.h" | |
32 | #include "AliHLTTPCTrackletDataFormat.h" | |
33 | #include "AliHLTExternalTrackParam.h" | |
34 | #include "AliHLTGlobalBarrelTrack.h" | |
3d144ee9 | 35 | #include "AliHLTTrackMCLabel.h" |
33a4976d | 36 | |
37 | #include "AliTPCclusterMI.h" | |
38 | #include "AliTPCseed.h" | |
39 | #include "AliTPCcalibDB.h" | |
472dbf06 | 40 | #include "AliTPCParam.h" |
33a4976d | 41 | |
42 | #include "AliRieman.h" | |
43 | ||
44 | #include "AliCDBEntry.h" | |
45 | #include "AliCDBManager.h" | |
46 | #include "AliCDBStorage.h" | |
47 | ||
48 | #include <cstdlib> | |
49 | #include <cerrno> | |
50 | ||
51 | #include "TObjArray.h" | |
4c4e26a3 | 52 | #include "TClonesArray.h" |
33a4976d | 53 | #include "TObject.h" |
3d144ee9 | 54 | #include "TFile.h" |
55 | #include "TH2F.h" | |
56 | ||
33a4976d | 57 | #include <sys/time.h> |
58 | ||
d5cf9283 | 59 | using namespace std; |
60 | ||
33a4976d | 61 | ClassImp(AliHLTTPCCalibSeedMakerComponent) //ROOT macro for the implementation of ROOT specific class methods |
62 | ||
63 | AliHLTTPCCalibSeedMakerComponent::AliHLTTPCCalibSeedMakerComponent() | |
64 | : | |
a00412ee | 65 | fTPCGeomParam(0) |
1a5a7a38 | 66 | ,fSeedArray(0x0) |
3d144ee9 | 67 | ,fdEdx(0x0) |
33a4976d | 68 | { |
69 | // see header file for class documentation | |
70 | // or | |
71 | // refer to README to build package | |
72 | // or | |
3d144ee9 | 73 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt |
74 | for( int i=0; i<fkNPartition; i++ ){ | |
75 | fPartitionClusters[i] = 0; | |
76 | fNPartitionClusters[i] = 0; | |
77 | } | |
33a4976d | 78 | } |
79 | ||
80 | AliHLTTPCCalibSeedMakerComponent::~AliHLTTPCCalibSeedMakerComponent() { | |
3d144ee9 | 81 | // see header file for class documentation |
82 | ||
83 | for( int i=0; i<fkNPartition; i++ ){ | |
84 | delete[] fPartitionClusters[i]; | |
85 | } | |
33a4976d | 86 | } |
87 | ||
33a4976d | 88 | const char* AliHLTTPCCalibSeedMakerComponent::GetComponentID() { |
89 | // see header file for class documentation | |
90 | ||
91 | return "TPCCalibSeedMaker"; | |
92 | } | |
93 | ||
94 | void AliHLTTPCCalibSeedMakerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
95 | // see header file for class documentation | |
96 | ||
97 | list.clear(); | |
3d144ee9 | 98 | list.push_back( AliHLTTPCDefinitions::fgkClustersDataType ); |
99 | list.push_back( kAliHLTDataTypeTrack|kAliHLTDataOriginTPC ); | |
100 | list.push_back( kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC ); | |
33a4976d | 101 | } |
102 | ||
103 | AliHLTComponentDataType AliHLTTPCCalibSeedMakerComponent::GetOutputDataType(){ | |
104 | // see header file for class documentation | |
105 | ||
3d144ee9 | 106 | return kAliHLTMultipleDataType; |
107 | //return kAliHLTDataTypeTObjArray; | |
33a4976d | 108 | } |
109 | ||
110 | int AliHLTTPCCalibSeedMakerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){ | |
111 | // see header file for class documentation | |
112 | ||
113 | tgtList.clear(); | |
3d144ee9 | 114 | tgtList.push_back( kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC ); |
115 | tgtList.push_back( kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC ); | |
33a4976d | 116 | return tgtList.size(); |
117 | } | |
118 | ||
119 | void AliHLTTPCCalibSeedMakerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { | |
120 | // see header file for class documentation | |
121 | ||
3d144ee9 | 122 | constBase=2000; |
33a4976d | 123 | inputMultiplier=2.0; // to be estimated |
124 | } | |
125 | ||
126 | AliHLTComponent* AliHLTTPCCalibSeedMakerComponent::Spawn() { | |
127 | // see header file for class documentation | |
128 | ||
129 | return new AliHLTTPCCalibSeedMakerComponent(); | |
130 | } | |
131 | ||
132 | int AliHLTTPCCalibSeedMakerComponent::DoInit( int /*argc*/, const char** /*argv*/ ) { | |
133 | // see header file for class documentation | |
134 | ||
472dbf06 | 135 | fTPCGeomParam = AliTPCcalibDB::Instance()->GetParameters(); |
136 | if(!fTPCGeomParam) HLTError("TPC Parameters are not loaded."); | |
5c1cc2ea | 137 | |
e90933cd | 138 | fSeedArray = new TObjArray(10000); |
1a5a7a38 | 139 | //fSeedArray->SetOwner(kTRUE); |
140 | ||
3d144ee9 | 141 | fdEdx = new TH2F("fdEdx","energy loss vs. momentum", 400, -200, 200, 300, 0, 300); |
142 | ||
33a4976d | 143 | return 0; |
144 | ||
145 | } // end DoInit() | |
146 | ||
147 | int AliHLTTPCCalibSeedMakerComponent::DoDeinit() { | |
148 | // see header file for class documentation | |
5c1cc2ea | 149 | |
1a5a7a38 | 150 | if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = NULL; |
151 | if(fSeedArray) delete fSeedArray; fSeedArray = NULL; | |
152 | if(fdEdx) delete fdEdx; fdEdx = NULL; | |
3d144ee9 | 153 | |
33a4976d | 154 | return 0; |
155 | } | |
156 | ||
157 | int AliHLTTPCCalibSeedMakerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){ | |
158 | // see header file for class documentation | |
159 | ||
33a4976d | 160 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR)) return 0; |
161 | ||
3d144ee9 | 162 | int nInputClusters = 0; |
1a5a7a38 | 163 | fSeedArray->Clear(); |
33a4976d | 164 | |
3d144ee9 | 165 | for(Int_t i=0; i<fkNPartition; i++){ |
166 | delete[] fPartitionClusters[i]; | |
167 | fPartitionClusters[i] = 0; | |
168 | fNPartitionClusters[i] = 0; | |
169 | } | |
170 | ||
171 | ||
33a4976d | 172 | // ---------- Access to clusters --------------------// |
173 | ||
3d144ee9 | 174 | for(const AliHLTComponentBlockData *iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){ |
33a4976d | 175 | |
3d144ee9 | 176 | if(iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType) continue; |
177 | ||
178 | Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification); | |
179 | Int_t partition = AliHLTTPCDefinitions::GetMinPatchNr(iter->fSpecification); | |
180 | ||
181 | Int_t slicepartition = slice*6+partition; | |
33a4976d | 182 | |
3d144ee9 | 183 | if(slicepartition > fkNPartition){ |
184 | HLTWarning("Wrong header of TPC cluster data, slice %d, partition %d", slice, partition ); | |
185 | continue; | |
33a4976d | 186 | } |
8677d183 | 187 | |
3d144ee9 | 188 | AliHLTTPCClusterData *inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr ); |
189 | nInputClusters += inPtrSP->fSpacePointCnt; | |
190 | ||
191 | delete[] fPartitionClusters[slicepartition]; | |
192 | fPartitionClusters[slicepartition] = new AliTPCclusterMI[inPtrSP->fSpacePointCnt]; | |
193 | fNPartitionClusters[slicepartition] = inPtrSP->fSpacePointCnt; | |
194 | ||
195 | // create offline clusters out of the HLT clusters | |
196 | // todo: check which cluster information is really needed for the dEdx | |
197 | ||
198 | for ( unsigned int i = 0; i < inPtrSP->fSpacePointCnt; i++ ) { | |
199 | AliHLTTPCSpacePointData *chlt = &( inPtrSP->fSpacePoints[i] ); | |
200 | AliTPCclusterMI *c = fPartitionClusters[slicepartition]+i; | |
201 | c->SetX(chlt->fX); | |
202 | c->SetY(chlt->fY); | |
203 | c->SetZ(chlt->fZ); | |
204 | c->SetSigmaY2(chlt->fSigmaY2); | |
205 | c->SetSigmaYZ( 0 ); | |
206 | c->SetSigmaZ2(chlt->fSigmaZ2); | |
207 | c->SetQ( chlt->fCharge ); | |
208 | c->SetMax( chlt->fQMax ); | |
209 | Int_t sector, row; | |
210 | Float_t padtime[3] = {0,chlt->fY,chlt->fZ}; | |
211 | AliHLTTPCTransform::Slice2Sector(slice,chlt->fPadRow, sector, row); | |
212 | AliHLTTPCTransform::Local2Raw( padtime, sector, row); | |
213 | c->SetDetector( sector ); | |
214 | c->SetRow( row ); | |
215 | c->SetPad( (Int_t) padtime[1] ); | |
216 | c->SetTimeBin( (Int_t) padtime[2] ); | |
217 | } | |
33a4976d | 218 | } // end of loop over blocks of clusters |
219 | ||
272c1851 | 220 | |
3d144ee9 | 221 | |
222 | ||
223 | // ------------ loop over the MC labels -----------------// | |
c1cd2f4b | 224 | |
3d144ee9 | 225 | std::map<int,int> mcLabels; |
226 | for(const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()){ | |
272c1851 | 227 | |
3d144ee9 | 228 | AliHLTTrackMCData *dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr ); |
229 | ||
230 | if(sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize){ | |
231 | for(UInt_t il=0; il<dataPtr->fCount; il++){ | |
232 | AliHLTTrackMCLabel &lab = dataPtr->fLabels[il]; | |
233 | mcLabels[lab.fTrackID] = lab.fMCLabel; | |
234 | HLTDebug("MC labels, track ID: %d, %d\n", lab.fMCLabel, lab.fTrackID); | |
235 | } | |
236 | } | |
237 | else { | |
238 | HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information", DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, | |
239 | dataPtr->fCount, pBlock->fSize); | |
240 | } | |
241 | } // end of loop over MC label blocks | |
242 | ||
243 | ||
244 | ||
245 | ||
246 | ||
247 | //------------------ loop over track data blocks --------------------// | |
248 | ||
1a5a7a38 | 249 | int nTracks = 0; |
3d144ee9 | 250 | for(const AliHLTComponentBlockData *pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock != NULL; pBlock = GetNextInputBlock()){ |
251 | ||
252 | AliHLTTracksData *dataPtr = (AliHLTTracksData*) pBlock->fPtr; | |
1a5a7a38 | 253 | //int nTracks = dataPtr->fCount; |
254 | nTracks = dataPtr->fCount; | |
3d144ee9 | 255 | |
1a5a7a38 | 256 | AliHLTExternalTrackParam *currTrack = dataPtr->fTracklets; |
257 | ||
3d144ee9 | 258 | for(Int_t itr=0; itr<nTracks && ( (AliHLTUInt8_t *)currTrack < ((AliHLTUInt8_t *) pBlock->fPtr)+pBlock->fSize); itr++){ |
259 | ||
260 | // create an offline track | |
261 | AliHLTGlobalBarrelTrack gb(*currTrack); | |
1a5a7a38 | 262 | AliTPCseed tTPC; |
263 | tTPC.Set( gb.GetX(), gb.GetAlpha(), gb.GetParameter(), gb.GetCovariance() ); | |
264 | ||
3d144ee9 | 265 | Int_t mcLabel = -1; |
266 | if( mcLabels.find(gb.TrackID())!=mcLabels.end() ) mcLabel = mcLabels[gb.TrackID()]; | |
1a5a7a38 | 267 | tTPC.SetLabel(mcLabel); |
3d144ee9 | 268 | |
1a5a7a38 | 269 | // set the clusters |
270 | ||
3d144ee9 | 271 | for(UInt_t ic=0; ic<currTrack->fNPoints; ic++){ |
1a5a7a38 | 272 | |
273 | tTPC.SetNumberOfClusters(currTrack->fNPoints); | |
3d144ee9 | 274 | |
a371a266 | 275 | UInt_t id = currTrack->fPointIDs[ic]; |
276 | int iSlice = AliHLTTPCSpacePointData::GetSlice(id); | |
277 | int iPartition = AliHLTTPCSpacePointData::GetPatch(id); | |
278 | int iCluster = AliHLTTPCSpacePointData::GetNumber(id); | |
472dbf06 | 279 | |
3d144ee9 | 280 | if(iSlice<0 || iSlice>36 || iPartition<0 || iPartition>5){ |
281 | HLTError("Corrupted TPC cluster Id: slice %d, partition %d, cluster %d", iSlice, iPartition, iCluster); | |
272c1851 | 282 | continue; |
3d144ee9 | 283 | } |
284 | ||
285 | AliTPCclusterMI *patchClusters = fPartitionClusters[iSlice*6 + iPartition]; | |
286 | if(!patchClusters){ | |
287 | HLTError("Clusters are missed for slice %d, partition %d", iSlice, iPartition ); | |
288 | continue; | |
289 | } | |
290 | ||
291 | if(iCluster >= fNPartitionClusters[iSlice*6 + iPartition]){ | |
292 | HLTError("TPC slice %d, partition %d: ClusterID==%d >= N Cluaters==%d ", iSlice, iPartition,iCluster, fNPartitionClusters[iSlice*6 + iPartition] ); | |
293 | continue; | |
294 | } | |
295 | ||
296 | AliTPCclusterMI *c = &(patchClusters[iCluster]); | |
297 | int sec = c->GetDetector(); | |
298 | int row = c->GetRow(); | |
299 | if(sec >= 36) row = row + AliHLTTPCTransform::GetNRowLow(); | |
300 | ||
1a5a7a38 | 301 | tTPC.SetClusterPointer(row, c); |
3d144ee9 | 302 | |
1a5a7a38 | 303 | AliTPCTrackerPoint &point = *( tTPC.GetTrackPoint( row ) ); |
304 | //tTPC.Propagate( TMath::DegToRad()*(sec%18*20.+10.), c->GetX(), fSolenoidBz ); | |
305 | Double_t angle2 = tTPC.GetSnp()*tTPC.GetSnp(); | |
3d144ee9 | 306 | angle2 = (angle2<1) ?TMath::Sqrt(angle2/(1-angle2)) :10.; |
307 | point.SetAngleY( angle2 ); | |
1a5a7a38 | 308 | point.SetAngleZ( tTPC.GetTgl() ); |
3d144ee9 | 309 | } // end of associated cluster loop |
310 | ||
311 | // Cook dEdx | |
1a5a7a38 | 312 | |
313 | AliTPCseed *seed = &(tTPC); | |
314 | fSeedArray->AddAt( seed, TMath::Abs(seed->GetLabel()) ); | |
315 | fdEdx->Fill( seed->P()*seed->Charge(), seed->CookdEdx(0.02, 0.6) ); | |
316 | ||
3d144ee9 | 317 | unsigned int step = sizeof( AliHLTExternalTrackParam ) + currTrack->fNPoints * sizeof( unsigned int ); |
318 | currTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currTrack) + step ); | |
8677d183 | 319 | |
9b99ccf1 | 320 | }// end of vector track loop |
1a5a7a38 | 321 | } // end of loop over blocks of merged tracks |
33a4976d | 322 | |
1a5a7a38 | 323 | HLTDebug("Number of reconstructed tracks %d, number of produced seeds %d\n", nTracks, fSeedArray->GetEntries()); |
324 | ||
325 | PushBack((TObject*)fSeedArray, kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC, 0x0); | |
326 | PushBack((TObject*)fdEdx, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, 0x0); | |
327 | ||
33a4976d | 328 | return 0; |
329 | } // end DoEvent() |