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
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"
35 #include "AliHLTTrackMCLabel.h"
37 #include "AliTPCclusterMI.h"
38 #include "AliTPCseed.h"
39 #include "AliTPCcalibDB.h"
40 #include "AliTPCParam.h"
42 #include "AliRieman.h"
44 #include "AliCDBEntry.h"
45 #include "AliCDBManager.h"
46 #include "AliCDBStorage.h"
51 #include "TObjArray.h"
52 #include "TClonesArray.h"
61 ClassImp(AliHLTTPCCalibSeedMakerComponent) //ROOT macro for the implementation of ROOT specific class methods
63 AliHLTTPCCalibSeedMakerComponent::AliHLTTPCCalibSeedMakerComponent()
69 // see header file for class documentation
71 // refer to README to build package
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;
80 AliHLTTPCCalibSeedMakerComponent::~AliHLTTPCCalibSeedMakerComponent() {
81 // see header file for class documentation
83 for( int i=0; i<fkNPartition; i++ ){
84 delete[] fPartitionClusters[i];
88 const char* AliHLTTPCCalibSeedMakerComponent::GetComponentID() {
89 // see header file for class documentation
91 return "TPCCalibSeedMaker";
94 void AliHLTTPCCalibSeedMakerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
95 // see header file for class documentation
98 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
99 list.push_back( kAliHLTDataTypeTrack|kAliHLTDataOriginTPC );
100 list.push_back( kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC );
103 AliHLTComponentDataType AliHLTTPCCalibSeedMakerComponent::GetOutputDataType(){
104 // see header file for class documentation
106 return kAliHLTMultipleDataType;
107 //return kAliHLTDataTypeTObjArray;
110 int AliHLTTPCCalibSeedMakerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
111 // see header file for class documentation
114 tgtList.push_back( kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC );
115 tgtList.push_back( kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC );
116 return tgtList.size();
119 void AliHLTTPCCalibSeedMakerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
120 // see header file for class documentation
123 inputMultiplier=2.0; // to be estimated
126 AliHLTComponent* AliHLTTPCCalibSeedMakerComponent::Spawn() {
127 // see header file for class documentation
129 return new AliHLTTPCCalibSeedMakerComponent();
132 int AliHLTTPCCalibSeedMakerComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
133 // see header file for class documentation
135 fTPCGeomParam = AliTPCcalibDB::Instance()->GetParameters();
136 if(!fTPCGeomParam) HLTError("TPC Parameters are not loaded.");
138 fSeedArray = new TObjArray(10000);
139 //fSeedArray->SetOwner(kTRUE);
141 fdEdx = new TH2F("fdEdx","energy loss vs. momentum", 400, -200, 200, 300, 0, 300);
147 int AliHLTTPCCalibSeedMakerComponent::DoDeinit() {
148 // see header file for class documentation
150 if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = NULL;
151 if(fSeedArray) delete fSeedArray; fSeedArray = NULL;
152 if(fdEdx) delete fdEdx; fdEdx = NULL;
157 int AliHLTTPCCalibSeedMakerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
158 // see header file for class documentation
160 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR)) return 0;
162 int nInputClusters = 0;
165 for(Int_t i=0; i<fkNPartition; i++){
166 delete[] fPartitionClusters[i];
167 fPartitionClusters[i] = 0;
168 fNPartitionClusters[i] = 0;
172 // ---------- Access to clusters --------------------//
174 for(const AliHLTComponentBlockData *iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
176 if(iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType) continue;
178 Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
179 Int_t partition = AliHLTTPCDefinitions::GetMinPatchNr(iter->fSpecification);
181 Int_t slicepartition = slice*6+partition;
183 if(slicepartition > fkNPartition){
184 HLTWarning("Wrong header of TPC cluster data, slice %d, partition %d", slice, partition );
188 AliHLTTPCClusterData *inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
189 nInputClusters += inPtrSP->fSpacePointCnt;
191 delete[] fPartitionClusters[slicepartition];
192 fPartitionClusters[slicepartition] = new AliTPCclusterMI[inPtrSP->fSpacePointCnt];
193 fNPartitionClusters[slicepartition] = inPtrSP->fSpacePointCnt;
195 // create offline clusters out of the HLT clusters
196 // todo: check which cluster information is really needed for the dEdx
198 for ( unsigned int i = 0; i < inPtrSP->fSpacePointCnt; i++ ) {
199 AliHLTTPCSpacePointData *chlt = &( inPtrSP->fSpacePoints[i] );
200 AliTPCclusterMI *c = fPartitionClusters[slicepartition]+i;
204 c->SetSigmaY2(chlt->fSigmaY2);
206 c->SetSigmaZ2(chlt->fSigmaZ2);
207 c->SetQ( chlt->fCharge );
208 c->SetMax( chlt->fQMax );
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 );
215 c->SetPad( (Int_t) padtime[1] );
216 c->SetTimeBin( (Int_t) padtime[2] );
218 } // end of loop over blocks of clusters
223 // ------------ loop over the MC labels -----------------//
225 std::map<int,int> mcLabels;
226 for(const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()){
228 AliHLTTrackMCData *dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
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);
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);
241 } // end of loop over MC label blocks
247 //------------------ loop over track data blocks --------------------//
250 for(const AliHLTComponentBlockData *pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock != NULL; pBlock = GetNextInputBlock()){
252 AliHLTTracksData *dataPtr = (AliHLTTracksData*) pBlock->fPtr;
253 //int nTracks = dataPtr->fCount;
254 nTracks = dataPtr->fCount;
256 AliHLTExternalTrackParam *currTrack = dataPtr->fTracklets;
258 for(Int_t itr=0; itr<nTracks && ( (AliHLTUInt8_t *)currTrack < ((AliHLTUInt8_t *) pBlock->fPtr)+pBlock->fSize); itr++){
260 // create an offline track
261 AliHLTGlobalBarrelTrack gb(*currTrack);
263 tTPC.Set( gb.GetX(), gb.GetAlpha(), gb.GetParameter(), gb.GetCovariance() );
266 if( mcLabels.find(gb.TrackID())!=mcLabels.end() ) mcLabel = mcLabels[gb.TrackID()];
267 tTPC.SetLabel(mcLabel);
271 for(UInt_t ic=0; ic<currTrack->fNPoints; ic++){
273 tTPC.SetNumberOfClusters(currTrack->fNPoints);
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);
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);
285 AliTPCclusterMI *patchClusters = fPartitionClusters[iSlice*6 + iPartition];
287 HLTError("Clusters are missed for slice %d, partition %d", iSlice, iPartition );
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] );
296 AliTPCclusterMI *c = &(patchClusters[iCluster]);
297 int sec = c->GetDetector();
298 int row = c->GetRow();
299 if(sec >= 36) row = row + AliHLTTPCTransform::GetNRowLow();
301 tTPC.SetClusterPointer(row, c);
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();
306 angle2 = (angle2<1) ?TMath::Sqrt(angle2/(1-angle2)) :10.;
307 point.SetAngleY( angle2 );
308 point.SetAngleZ( tTPC.GetTgl() );
309 } // end of associated cluster loop
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) );
317 unsigned int step = sizeof( AliHLTExternalTrackParam ) + currTrack->fNPoints * sizeof( unsigned int );
318 currTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currTrack) + step );
320 }// end of vector track loop
321 } // end of loop over blocks of merged tracks
323 HLTDebug("Number of reconstructed tracks %d, number of produced seeds %d\n", nTracks, fSeedArray->GetEntries());
325 PushBack((TObject*)fSeedArray, kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC, 0x0);
326 PushBack((TObject*)fdEdx, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, 0x0);