X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=HLT%2FMUON%2FOfflineInterface%2FAliHLTMUONRootifierComponent.cxx;h=7155bcfde2710ace3175fe8e24fe60bbbaf7099f;hp=1b22e6383ed72f2fb79807bbe1ebc000b94c79e1;hb=d7ef992b70f259ae309a17be3c4707265c82be1d;hpb=1d8ae082c8d76a35d632b33f4ea7889fac007ecb diff --git a/HLT/MUON/OfflineInterface/AliHLTMUONRootifierComponent.cxx b/HLT/MUON/OfflineInterface/AliHLTMUONRootifierComponent.cxx index 1b22e6383ed..7155bcfde27 100644 --- a/HLT/MUON/OfflineInterface/AliHLTMUONRootifierComponent.cxx +++ b/HLT/MUON/OfflineInterface/AliHLTMUONRootifierComponent.cxx @@ -24,6 +24,9 @@ /// /// Implements a component to convert dHLT raw data into TObjects. +#include "AliHLTMessage.h" +#include "TString.h" +#include "AliESDEvent.h" #include "AliHLTMUONRootifierComponent.h" #include "AliHLTMUONEvent.h" #include "AliHLTMUONConstants.h" @@ -31,9 +34,12 @@ #include "AliHLTMUONRecHit.h" #include "AliHLTMUONTriggerRecord.h" #include "AliHLTMUONMansoTrack.h" +#include "AliHLTMUONTrack.h" #include "AliHLTMUONDecision.h" +#include "AliMUONTriggerDDLDecoderEventHandler.h" #include "TClonesArray.h" #include +#include ClassImp(AliHLTMUONRootifierComponent); @@ -192,6 +198,7 @@ int AliHLTMUONRootifierComponent::DoEvent( AliHLTMUONEvent event(evtData.fEventID); const AliHLTComponentBlockData* block = NULL; AliHLTUInt32_t specification = 0; // Contains the output data block spec bits. + std::map triggerMap; // First process the blocks of reconstructed hits and trigger records. for (int i = 0; i < GetNumberOfInputBlocks(); i++) @@ -203,7 +210,20 @@ int AliHLTMUONRootifierComponent::DoEvent( i, DataType2Text(block->fDataType).c_str(), block->fPtr, block->fSize ); - if (block->fDataType == AliHLTMUONConstants::RecHitsBlockDataType()) + if (block->fDataType == AliHLTMUONConstants::ESDDataType()) + { + AliHLTMessage *fMessage = new AliHLTMessage( block->fPtr, block->fSize ); + // -- Check if TMessage payload is TObject + if ( fMessage->What() == kMESS_OBJECT ) + { + TString fClassName = fMessage->GetClass()->GetName(); + AliESDEvent* esd = reinterpret_cast(fMessage->ReadObject( fMessage->GetClass() )); + esd->GetStdContent(); + event.Add(esd); + } + fMessage->Reset(); + } + else if (block->fDataType == AliHLTMUONConstants::RecHitsBlockDataType()) { specification |= block->fSpecification; AliHLTMUONRecHitsBlockReader inblock(block->fPtr, block->fSize); @@ -302,13 +322,22 @@ int AliHLTMUONRootifierComponent::DoEvent( t.fId, sign, t.fPx, t.fPy, t.fPz, sourceDDL ); for (int k = 0; k < 4; k++) - tr->SetHit(k+11, t.fHit[k].fX, t.fHit[k].fY, t.fHit[k].fZ); + { + if (not hitset[k]) continue; + Int_t detElemId = AliHLTMUONUtils::GetDetElemIdFromFlags(t.fHit[k].fFlags); + tr->SetHit(k+11, t.fHit[k].fX, t.fHit[k].fY, t.fHit[k].fZ, detElemId); + } event.Add(tr); + triggerMap[t.fId] = tr; } } else { - if (block->fDataType != AliHLTMUONConstants::MansoTracksBlockDataType() and + if (block->fDataType != AliHLTMUONConstants::TrigRecsDebugBlockDataType() and + block->fDataType != AliHLTMUONConstants::ClusterBlockDataType() and + block->fDataType != AliHLTMUONConstants::ChannelBlockDataType() and + block->fDataType != AliHLTMUONConstants::MansoTracksBlockDataType() and + block->fDataType != AliHLTMUONConstants::MansoCandidatesBlockDataType() and block->fDataType != AliHLTMUONConstants::SinglesDecisionBlockDataType() and block->fDataType != AliHLTMUONConstants::PairsDecisionBlockDataType() ) @@ -329,6 +358,129 @@ int AliHLTMUONRootifierComponent::DoEvent( } } + // We need to check if there are any trigger record debug data blocks + // and add their information to the AliHLTMUONTriggerRecord objects. + for (block = GetFirstInputBlock(AliHLTMUONConstants::TrigRecsDebugBlockDataType()); + block != NULL; + block = GetNextInputBlock() + ) + { + specification |= block->fSpecification; + AliHLTMUONTrigRecsDebugBlockReader inblock(block->fPtr, block->fSize); + if (not BlockStructureOk(inblock)) + { + if (DumpDataOnError()) DumpEvent(evtData, trigData); + continue; + } + + for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++) + { + const AliHLTMUONTrigRecInfoStruct& triginfo = inblock[n]; + + AliHLTMUONTriggerRecord* trigrec = triggerMap[triginfo.fTrigRecId]; + if (trigrec == NULL) + { + // Decode the source DDL from the specification bits. + Int_t sourceDDL = -1; + bool ddl[22]; + AliHLTMUONUtils::UnpackSpecBits(block->fSpecification, ddl); + for (int k = 0; k < 22; k++) + { + if (ddl[k]) + { + if (sourceDDL == -1) + { + sourceDDL = k+1; + } + else + { + HLTWarning("An trigger debug information data block" + " contains data from multiple DDL sources." + ); + } + } + } + if (sourceDDL != -1 and (sourceDDL < 21 or sourceDDL > 22)) + { + HLTWarning("The source DDL for a trigger debug information data" + " block is %d. The expected range for the DDL is [21..22].", + sourceDDL + ); + } + + // Add an new empty trigger record since none was found. + trigrec = new AliHLTMUONTriggerRecord( + 0, 0, 0, 0, 0, sourceDDL + ); + triggerMap[triginfo.fTrigRecId] = trigrec; + event.Add(trigrec); + } + else + { + for (Int_t j = 0; j < 4; ++j) + { + if (trigrec->DetElemId(j+11) != -1 and triginfo.fDetElemId[j] != trigrec->DetElemId(j+11)) + { + HLTWarning("Found a trigger record with a hit on chamber %d with a different" + " detector element ID %d than the debug information %d.", + j, trigrec->DetElemId(j+11), triginfo.fDetElemId[j] + ); + } + } + } + + typedef AliMUONTriggerDDLDecoderEventHandler Handler; + + trigrec->SetDebugInfo(triginfo.fZmiddle, triginfo.fBl); + + UShort_t patternX[4][3] = { + { + Handler::GetLocalX1(&triginfo.fL0StructPrev), + Handler::GetLocalX1(&triginfo.fL0Struct), + Handler::GetLocalX1(&triginfo.fL0StructNext) + },{ + Handler::GetLocalX2(&triginfo.fL0StructPrev), + Handler::GetLocalX2(&triginfo.fL0Struct), + Handler::GetLocalX2(&triginfo.fL0StructNext) + },{ + Handler::GetLocalX3(&triginfo.fL0StructPrev), + Handler::GetLocalX3(&triginfo.fL0Struct), + Handler::GetLocalX3(&triginfo.fL0StructNext) + },{ + Handler::GetLocalX4(&triginfo.fL0StructPrev), + Handler::GetLocalX4(&triginfo.fL0Struct), + Handler::GetLocalX4(&triginfo.fL0StructNext) + } + }; + UShort_t patternY[4][3] = { + { + Handler::GetLocalY1(&triginfo.fL0StructPrev), + Handler::GetLocalY1(&triginfo.fL0Struct), + Handler::GetLocalY1(&triginfo.fL0StructNext) + },{ + Handler::GetLocalY2(&triginfo.fL0StructPrev), + Handler::GetLocalY2(&triginfo.fL0Struct), + Handler::GetLocalY2(&triginfo.fL0StructNext) + },{ + Handler::GetLocalY3(&triginfo.fL0StructPrev), + Handler::GetLocalY3(&triginfo.fL0Struct), + Handler::GetLocalY3(&triginfo.fL0StructNext) + },{ + Handler::GetLocalY4(&triginfo.fL0StructPrev), + Handler::GetLocalY4(&triginfo.fL0Struct), + Handler::GetLocalY4(&triginfo.fL0StructNext) + } + }; + + for (Int_t j = 0; j < 4; ++j) + { + trigrec->SetHitDebugInfo(j+11, patternX[j], patternY[j]); + } + } + } + + std::map clusterMap; + // We need to check if there are any cluster data blocks and add their // information to the AliHLTMUONRecHit objects. for (block = GetFirstInputBlock(AliHLTMUONConstants::ClusterBlockDataType()); @@ -407,10 +559,11 @@ int AliHLTMUONRootifierComponent::DoEvent( sourceDDL ); } - event.Add(new AliHLTMUONRecHit( + hit = new AliHLTMUONRecHit( clust.fHit.fX, clust.fHit.fY, clust.fHit.fZ, sourceDDL, detElemId - )); + ); + event.Add(hit); } else { @@ -421,18 +574,20 @@ int AliHLTMUONRootifierComponent::DoEvent( hit->SourceDDL() ); } + + clusterMap[clust.fId] = hit; } } - // Now we can look for tracks to add. We needed the ROOT trigger records - // and reco hits created before we can create track objects. - for (block = GetFirstInputBlock(AliHLTMUONConstants::MansoTracksBlockDataType()); + // We need to check if there are any channel data blocks and add their + // information to the AliHLTMUONRecHit objects. + for (block = GetFirstInputBlock(AliHLTMUONConstants::ChannelBlockDataType()); block != NULL; block = GetNextInputBlock() ) { specification |= block->fSpecification; - AliHLTMUONMansoTracksBlockReader inblock(block->fPtr, block->fSize); + AliHLTMUONChannelsBlockReader inblock(block->fPtr, block->fSize); if (not BlockStructureOk(inblock)) { if (DumpDataOnError()) DumpEvent(evtData, trigData); @@ -441,94 +596,127 @@ int AliHLTMUONRootifierComponent::DoEvent( for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++) { - const AliHLTMUONMansoTrackStruct& t = inblock[n]; - - AliHLTMUONParticleSign sign; - bool hitset[4]; - AliHLTMUONUtils::UnpackMansoTrackFlags( - t.fFlags, sign, hitset - ); - - // Try find the trigger record in 'event'. - const AliHLTMUONTriggerRecord* trigrec = NULL; - for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++) - { - if (event.Array()[k]->IsA() != AliHLTMUONTriggerRecord::Class()) - continue; - const AliHLTMUONTriggerRecord* tk = - static_cast(event.Array()[k]); - if (tk->Id() == t.fTrigRec) - { - trigrec = tk; - break; - } - } + const AliHLTMUONChannelStruct& channel = inblock[n]; - // Now try find the hits in 'event'. - // If they cannot be found then create new ones. - const AliHLTMUONRecHit* hit7 = NULL; - const AliHLTMUONRecHit* hit8 = NULL; - const AliHLTMUONRecHit* hit9 = NULL; - const AliHLTMUONRecHit* hit10 = NULL; - for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++) + AliHLTMUONRecHit* hit = clusterMap[channel.fClusterId]; + if (hit == NULL) { - if (event.Array()[k]->IsA() != AliHLTMUONRecHit::Class()) - continue; - const AliHLTMUONRecHit* h = - static_cast(event.Array()[k]); - - if (hitset[0] and h->X() == t.fHit[0].fX and h->Y() == t.fHit[0].fY - and h->Z() == t.fHit[0].fZ) - { - hit7 = h; - } - if (hitset[1] and h->X() == t.fHit[1].fX and h->Y() == t.fHit[1].fY - and h->Z() == t.fHit[1].fZ) - { - hit8 = h; - } - if (hitset[2] and h->X() == t.fHit[2].fX and h->Y() == t.fHit[2].fY - and h->Z() == t.fHit[2].fZ) + // Decode the source DDL from the specification bits. + Int_t sourceDDL = -1; + bool ddl[22]; + AliHLTMUONUtils::UnpackSpecBits(block->fSpecification, ddl); + for (int k = 0; k < 22; k++) { - hit9 = h; + if (ddl[k]) + { + if (sourceDDL == -1) + { + sourceDDL = k+1; + } + else + { + HLTWarning("An input block of cluster data contains" + " data from multiple DDL sources." + ); + } + } } - if (hitset[3] and h->X() == t.fHit[3].fX and h->Y() == t.fHit[3].fY - and h->Z() == t.fHit[3].fZ) + if (sourceDDL > 20) { - hit10 = h; + HLTWarning("The source DDL of a cluster data input block is %d." + " The expected range for the DDL is [1..20].", + sourceDDL + ); } + hit = new AliHLTMUONRecHit(0, 0, 0, sourceDDL, -1); + event.Add(hit); } - AliHLTMUONRecHit* newhit; - if (hitset[0] and hit7 == NULL) - { - newhit = new AliHLTMUONRecHit(t.fHit[0].fX, t.fHit[0].fY, t.fHit[0].fZ); - event.Add(newhit); - hit7 = newhit; - } - if (hitset[1] and hit8 == NULL) - { - newhit = new AliHLTMUONRecHit(t.fHit[1].fX, t.fHit[1].fY, t.fHit[1].fZ); - event.Add(newhit); - hit8 = newhit; - } - if (hitset[2] and hit9 == NULL) + + hit->AddChannel( + channel.fBusPatch, channel.fManu, + channel.fChannelAddress, channel.fSignal, + channel.fRawDataWord + ); + } + } + + // Now we can look for tracks to add. We needed the ROOT trigger records + // and reco hits created before we can create track objects. + + std::map trackMap; + + for (block = GetFirstInputBlock(AliHLTMUONConstants::TracksBlockDataType()); + block != NULL; + block = GetNextInputBlock() + ) + { + specification |= block->fSpecification; + AliHLTMUONTracksBlockReader inblock(block->fPtr, block->fSize); + if (not BlockStructureOk(inblock)) + { + if (DumpDataOnError()) DumpEvent(evtData, trigData); + continue; + } + + for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++) + { + const AliHLTMUONTrackStruct& t = inblock[n]; + trackMap[t.fId] = AddTrack(event, t); + } + } + + std::map mansoTrackMap; + + for (block = GetFirstInputBlock(AliHLTMUONConstants::MansoTracksBlockDataType()); + block != NULL; + block = GetNextInputBlock() + ) + { + specification |= block->fSpecification; + AliHLTMUONMansoTracksBlockReader inblock(block->fPtr, block->fSize); + if (not BlockStructureOk(inblock)) + { + if (DumpDataOnError()) DumpEvent(evtData, trigData); + continue; + } + + for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++) + { + const AliHLTMUONMansoTrackStruct& t = inblock[n]; + mansoTrackMap[t.fId] = AddTrack(event, t); + } + } + + // Look for Manso track candidates to add the debug info to the tracks. + for (block = GetFirstInputBlock(AliHLTMUONConstants::MansoCandidatesBlockDataType()); + block != NULL; + block = GetNextInputBlock() + ) + { + specification |= block->fSpecification; + AliHLTMUONMansoCandidatesBlockReader inblock(block->fPtr, block->fSize); + if (not BlockStructureOk(inblock)) + { + if (DumpDataOnError()) DumpEvent(evtData, trigData); + continue; + } + + for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++) + { + const AliHLTMUONMansoCandidateStruct& tc = inblock[n]; + AliHLTMUONMansoTrack* mtrack = mansoTrackMap[tc.fTrack.fId]; + if (mtrack == NULL) { - newhit = new AliHLTMUONRecHit(t.fHit[2].fX, t.fHit[2].fY, t.fHit[2].fZ); - event.Add(newhit); - hit9 = newhit; + // If we got here then we could not find the corresponding Manso + // track. So we need to create and add a new track object. + mtrack = AddTrack(event, tc.fTrack); } - if (hitset[3] and hit10 == NULL) + mtrack->SetDebugData(tc.fZmiddle, tc.fBl); + for (AliHLTUInt32_t i = 0; i < 4; ++i) { - newhit = new AliHLTMUONRecHit(t.fHit[3].fX, t.fHit[3].fY, t.fHit[3].fZ); - event.Add(newhit); - hit10 = newhit; + if (tc.fRoI[i] == AliHLTMUONConstants::NilMansoRoIStruct()) continue; + mtrack->SetRoI(i+7, tc.fRoI[i].fX, tc.fRoI[i].fY, tc.fRoI[i].fZ, tc.fRoI[i].fRadius); } - - AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack( - t.fId, sign, t.fPx, t.fPy, t.fPz, t.fChi2, - trigrec, hit7, hit8, hit9, hit10 - ); - event.Add(tr); } } @@ -563,20 +751,9 @@ int AliHLTMUONRootifierComponent::DoEvent( bool highPt, lowPt; AliHLTMUONUtils::UnpackTrackDecisionBits(t.fTriggerBits, highPt, lowPt); - // Try find the corresponding track in the 'event'. - const AliHLTMUONMansoTrack* track = NULL; - for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++) - { - if (event.Array()[k]->IsA() != AliHLTMUONMansoTrack::Class()) - continue; - const AliHLTMUONMansoTrack* tk = - static_cast(event.Array()[k]); - if (tk->Id() == t.fTrackId) - { - track = tk; - break; - } - } + // Try find the corresponding track. + const TObject* track = trackMap[t.fTrackId]; + if (track == NULL) track = mansoTrackMap[t.fTrackId]; // If the track was not found then create a dummy one. if (track == NULL) @@ -584,6 +761,7 @@ int AliHLTMUONRootifierComponent::DoEvent( AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(t.fTrackId); event.Add(tr); track = tr; + mansoTrackMap[t.fTrackId] = tr; } new (singlesDecisions[singlesDecisions.GetEntriesFast()]) @@ -639,19 +817,11 @@ int AliHLTMUONRootifierComponent::DoEvent( highPtCount, lowPtCount ); - // Try find the corresponding tracks in the 'event'. - const AliHLTMUONMansoTrack* trackA = NULL; - const AliHLTMUONMansoTrack* trackB = NULL; - for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++) - { - if (event.Array()[k]->IsA() != AliHLTMUONMansoTrack::Class()) - continue; - const AliHLTMUONMansoTrack* tk = - static_cast(event.Array()[k]); - if (tk->Id() == t.fTrackAId) trackA = tk; - if (tk->Id() == t.fTrackBId) trackB = tk; - if (trackA != NULL and trackB != NULL) break; - } + // Try find the corresponding tracks. + const TObject* trackA = trackMap[t.fTrackAId]; + if (trackA == NULL) trackA = mansoTrackMap[t.fTrackAId]; + const TObject* trackB = trackMap[t.fTrackBId]; + if (trackB == NULL) trackB = mansoTrackMap[t.fTrackBId]; // If either of the tracks was not found then create a dummy one. if (trackA == NULL) @@ -659,12 +829,14 @@ int AliHLTMUONRootifierComponent::DoEvent( AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(t.fTrackAId); event.Add(tr); trackA = tr; + mansoTrackMap[t.fTrackAId] = tr; } if (trackB == NULL) { AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(t.fTrackBId); event.Add(tr); trackB = tr; + mansoTrackMap[t.fTrackBId] = tr; } new (pairsDecisions[pairsDecisions.GetEntriesFast()]) @@ -675,7 +847,6 @@ int AliHLTMUONRootifierComponent::DoEvent( } } - // Do not add the decision if no decision blocks were found. if (decisionBlockFound) { @@ -705,3 +876,166 @@ int AliHLTMUONRootifierComponent::DoEvent( return 0; } + +AliHLTMUONMansoTrack* AliHLTMUONRootifierComponent::AddTrack( + AliHLTMUONEvent& event, const AliHLTMUONMansoTrackStruct& track + ) +{ + // Converts the track structure and adds it to the event object. + + AliHLTMUONParticleSign sign; + bool hitset[4]; + AliHLTMUONUtils::UnpackMansoTrackFlags( + track.fFlags, sign, hitset + ); + + // Try find the trigger record in 'event'. + const AliHLTMUONTriggerRecord* trigrec = NULL; + for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++) + { + if (event.Array()[k]->IsA() != AliHLTMUONTriggerRecord::Class()) + continue; + const AliHLTMUONTriggerRecord* tk = + static_cast(event.Array()[k]); + if (tk->Id() == track.fTrigRec) + { + trigrec = tk; + break; + } + } + + // Now try find the hits in 'event'. + // If they cannot be found then create new ones. + const AliHLTMUONRecHit* hit7 = NULL; + const AliHLTMUONRecHit* hit8 = NULL; + const AliHLTMUONRecHit* hit9 = NULL; + const AliHLTMUONRecHit* hit10 = NULL; + for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++) + { + if (event.Array()[k]->IsA() != AliHLTMUONRecHit::Class()) + continue; + const AliHLTMUONRecHit* h = + static_cast(event.Array()[k]); + + if (hitset[0] and h->X() == track.fHit[0].fX and h->Y() == track.fHit[0].fY + and h->Z() == track.fHit[0].fZ) + { + hit7 = h; + } + if (hitset[1] and h->X() == track.fHit[1].fX and h->Y() == track.fHit[1].fY + and h->Z() == track.fHit[1].fZ) + { + hit8 = h; + } + if (hitset[2] and h->X() == track.fHit[2].fX and h->Y() == track.fHit[2].fY + and h->Z() == track.fHit[2].fZ) + { + hit9 = h; + } + if (hitset[3] and h->X() == track.fHit[3].fX and h->Y() == track.fHit[3].fY + and h->Z() == track.fHit[3].fZ) + { + hit10 = h; + } + } + AliHLTMUONRecHit* newhit; + if (hitset[0] and hit7 == NULL) + { + newhit = new AliHLTMUONRecHit(track.fHit[0].fX, track.fHit[0].fY, track.fHit[0].fZ); + event.Add(newhit); + hit7 = newhit; + } + if (hitset[1] and hit8 == NULL) + { + newhit = new AliHLTMUONRecHit(track.fHit[1].fX, track.fHit[1].fY, track.fHit[1].fZ); + event.Add(newhit); + hit8 = newhit; + } + if (hitset[2] and hit9 == NULL) + { + newhit = new AliHLTMUONRecHit(track.fHit[2].fX, track.fHit[2].fY, track.fHit[2].fZ); + event.Add(newhit); + hit9 = newhit; + } + if (hitset[3] and hit10 == NULL) + { + newhit = new AliHLTMUONRecHit(track.fHit[3].fX, track.fHit[3].fY, track.fHit[3].fZ); + event.Add(newhit); + hit10 = newhit; + } + + AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack( + track.fId, sign, track.fPx, track.fPy, track.fPz, track.fChi2, + trigrec, hit7, hit8, hit9, hit10 + ); + event.Add(tr); + return tr; +} + + +AliHLTMUONTrack* AliHLTMUONRootifierComponent::AddTrack( + AliHLTMUONEvent& event, const AliHLTMUONTrackStruct& track + ) +{ + // Converts the track structure and adds it to the event object. + + AliHLTMUONParticleSign sign; + bool hitset[16]; + AliHLTMUONUtils::UnpackTrackFlags( + track.fFlags, sign, hitset + ); + + // Try find the trigger record in 'event'. + const AliHLTMUONTriggerRecord* trigrec = NULL; + for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++) + { + if (event.Array()[k]->IsA() != AliHLTMUONTriggerRecord::Class()) + continue; + const AliHLTMUONTriggerRecord* tk = + static_cast(event.Array()[k]); + if (tk->Id() == track.fTrigRec) + { + trigrec = tk; + break; + } + } + + // Now try find the hits in 'event'. + // If they cannot be found then create new ones. + const AliHLTMUONRecHit* hits[16]; + for (int i = 0; i < 16; ++i) hits[i] = NULL; + for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++) + { + if (event.Array()[k]->IsA() != AliHLTMUONRecHit::Class()) + continue; + const AliHLTMUONRecHit* h = + static_cast(event.Array()[k]); + for (int i = 0; i < 16; ++i) + { + if (hitset[i] and h->X() == track.fHit[i].fX and h->Y() == track.fHit[i].fY + and h->Z() == track.fHit[i].fZ) + { + hits[i] = h; + } + } + } + AliHLTMUONRecHit* newhit; + for (int i = 0; i < 16; ++i) + { + if (hitset[i] and hits[i] == NULL) + { + newhit = new AliHLTMUONRecHit(track.fHit[i].fX, track.fHit[i].fY, track.fHit[i].fZ); + event.Add(newhit); + hits[i] = newhit; + } + } + + AliHLTMUONTrack* tr = new AliHLTMUONTrack( + track.fId, sign, track.fPx, track.fPy, track.fPz, + track.fInverseBendingMomentum, track.fThetaX, track.fThetaY, + track.fX, track.fY, track.fZ, track.fChi2, + trigrec, hits + ); + event.Add(tr); + return tr; +}