From: slindal Date: Tue, 27 Apr 2010 22:47:30 +0000 (+0000) Subject: Updated track matcher to do PHOS and EMCAL in one instance X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=ec54c698ce0ea74526127e239c8dee4e2422149b Updated track matcher to do PHOS and EMCAL in one instance --- diff --git a/HLT/global/AliHLTGlobalTrackMatcher.h b/HLT/global/AliHLTGlobalTrackMatcher.h index 11b62123da3..06a0a80246e 100644 --- a/HLT/global/AliHLTGlobalTrackMatcher.h +++ b/HLT/global/AliHLTGlobalTrackMatcher.h @@ -30,7 +30,7 @@ public: //Main function, loops over tracks and calls appropriate functions to establish matches template - Int_t Match( TObjArray * trackArray, vector &clustersVector, Double_t bz ); + Int_t Match( TObjArray * trackArray, vector &phosClustersVector, vector &emcalClustersVector, Double_t bz ); private: @@ -66,20 +66,19 @@ private: template -Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector &clustersVector, Double_t bz ) { +Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector &phosClustersVector, vector &emcalClustersVector, Double_t bz ) { //See above for documentation + Int_t nTracks = trackArray->GetEntriesFast(); - Int_t nPhosClusters = clustersVector.size(); - - //TODO emcal not yet implemented - Int_t nEmcalClusters = 0; //BALLE event->GetEMCALClusters(fEmcalClustersArray); + Int_t nPhosClusters = phosClustersVector.size(); + Int_t nEmcalClusters = emcalClustersVector.size(); + + //See if there are tracks and clusters to match if ( nTracks <= 0 ) { - // HLTWarning("No tracks in event"); return 0; - } else if ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) { - //HLTWarning("No calorimeter clusters in Event"); + } else if ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) { return 0; } @@ -87,29 +86,24 @@ Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector &clus for(int ic = 0; ic < nPhosClusters; ic++) { bestMatchPhos[ic] = 999999; } - - //BALLE TODO EMCAL implement - // Float_t bestMatchEmcal[nEmcalClusters]; - // for(int ic = 0; ic < nEmcalClusters; ic++) { - // bestMatchEmcal[ic] = 999999; - // } - - + + Float_t bestMatchEmcal[nEmcalClusters]; + for(int ic = 0; ic < nEmcalClusters; ic++) { + bestMatchEmcal[ic] = 999999; + } + //Loop over tracks for (int it = 0; it < nTracks; it++ ) { AliExternalTrackParam * track = static_cast(trackArray->At(it)); if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) { - MatchTrackToClusters( track, clustersVector, nPhosClusters, bestMatchPhos, bz); - - //BALLE TODO EMCAL !!!! - // } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) { - // MatchTrackToClusters( track, fEmcalClustersArray, nEmcalClusters, bestMatchEmcal, bz); + MatchTrackToClusters( track, phosClustersVector, nPhosClusters, bestMatchPhos, bz); + + } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) { + MatchTrackToClusters( track, emcalClustersVector, nEmcalClusters, bestMatchEmcal, bz); } - - } // track loop - + } return 0; } @@ -134,19 +128,12 @@ Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * tr cluster->GetPosition(clusterPosition); //Get track postion at radius of cluster - Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1]); + Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1] + clusterPosition[2]*clusterPosition[2]); if (! (track->GetXYZAt(rCluster, bz, trackPosition)) ) { HLTInfo("Track reached detector but not cluster!!!!!!"); continue; } - - // HLTInfo("Cluster global position %f %f %f", clusterPosition[0],clusterPosition[1],clusterPosition[2]); - - - //Calculate track - cluster residual - - //Get residual in z= 0 plane (squared) Double_t dxy = 0; for(int i = 0; i < 2; i++) { @@ -160,8 +147,6 @@ Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * tr Double_t match = dz + dxy; - // HLTInfo("Track cluster residual %f, maxmatch %f", match, fMatchDistance); - if( match > fMatchDistance ) { continue; } @@ -176,7 +161,6 @@ Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * tr //Add track to cluster's array of matching tracks Int_t nTracksMatched = cluster->GetNTracksMatched(); iResult = AddTrackToCluster(track->GetID(), cluster->GetTracksMatched(), match < bestMatch[ic], nTracksMatched); - //HLTInfo("Added track %d to cluster %d, it now has %d matching tracks", track->GetID(), cluster->GetID(), cluster->GetNTracksMatched()); } return iResult; diff --git a/HLT/global/AliHLTGlobalTrackMatcherComponent.cxx b/HLT/global/AliHLTGlobalTrackMatcherComponent.cxx index ad50e90f536..3d73d370ec3 100644 --- a/HLT/global/AliHLTGlobalTrackMatcherComponent.cxx +++ b/HLT/global/AliHLTGlobalTrackMatcherComponent.cxx @@ -189,43 +189,51 @@ int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& / } - //Get the clusters - AliHLTCaloClusterDataStruct * caloClusterStruct; - vector phosClustersVector; - - for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) { + AliHLTCaloClusterDataStruct * caloClusterStruct; + //Get the PHOS Clusters + vector phosClustersVector; + + for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS); pBlock!=NULL; pBlock=GetNextInputBlock()) { AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast(pBlock->fPtr); fClusterReader->SetMemory(caloClusterHeader); - if ( (caloClusterHeader->fNClusters) < 0) { HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters)); - return -1; + continue; } else { - - //BALLE, TODO, make it able to do EMCAL as well!!! - phosClustersVector.resize((int) (caloClusterHeader->fNClusters)); - Int_t nClusters = 0; + phosClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + phosClustersVector.size() ); while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) { - //BALLE stil just phos - phosClustersVector[nClusters++] = caloClusterStruct; + phosClustersVector.push_back(caloClusterStruct); } - - iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, fBz); } - - if(iResult <0) { - //HLTWarning("Error in track matcher"); + } + + + //Get the EMCAL Clusters + vector emcalClustersVector; + for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL); pBlock!=NULL; pBlock=GetNextInputBlock()) { + AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast(pBlock->fPtr); + fClusterReader->SetMemory(caloClusterHeader); + if ( (caloClusterHeader->fNClusters) < 0) { + HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters)); + continue; + } else { + emcalClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + emcalClustersVector.size() ); + while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) { + emcalClustersVector.push_back(caloClusterStruct); + } } - PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification); - //PushBack(pBlock->fPtr, pBlock->fSize, kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny ); - } + } + + iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, emcalClustersVector, fBz); + //Push the blocks on + for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) { + PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification); + } fTrackArray->Clear(); - //BALLE TODO phos only !!!! return iResult; - } // int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)