LCOV - code coverage report
Current view: top level - HLT/MUON/OfflineInterface - AliHLTMUONRootifierComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 473 1.7 %
Date: 2016-06-14 17:26:59 Functions: 7 18 38.9 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * This file is property of and copyright by the ALICE HLT Project        *
       3             :  * All rights reserved.                                                   *
       4             :  *                                                                        *
       5             :  * Primary Authors:                                                       *
       6             :  *   Artur Szostak <artursz@iafrica.com>                                  *
       7             :  *                                                                        *
       8             :  * Permission to use, copy, modify and distribute this software and its   *
       9             :  * documentation strictly for non-commercial purposes is hereby granted   *
      10             :  * without fee, provided that the above copyright notice appears in all   *
      11             :  * copies and that both the copyright notice and this permission notice   *
      12             :  * appear in the supporting documentation. The authors make no claims     *
      13             :  * about the suitability of this software for any purpose. It is          *
      14             :  * provided "as is" without express or implied warranty.                  *
      15             :  **************************************************************************/
      16             : 
      17             : // $Id$
      18             : 
      19             : ///
      20             : /// @file   AliHLTMUONRootifierComponent.cxx
      21             : /// @author Artur Szostak <artursz@iafrica.com>
      22             : /// @date   29 Sep 2007
      23             : /// @brief  Implementation of the AliHLTMUONRootifierComponent component.
      24             : ///
      25             : /// Implements a component to convert dHLT raw data into TObjects.
      26             : 
      27             : #include "AliHLTMessage.h"
      28             : #include "TString.h"
      29             : #include "AliESDEvent.h"
      30             : #include "AliHLTMUONRootifierComponent.h"
      31             : #include "AliHLTMUONEvent.h"
      32             : #include "AliHLTMUONConstants.h"
      33             : #include "AliHLTMUONUtils.h"
      34             : #include "AliHLTMUONRecHit.h"
      35             : #include "AliHLTMUONTriggerRecord.h"
      36             : #include "AliHLTMUONMansoTrack.h"
      37             : #include "AliHLTMUONTrack.h"
      38             : #include "AliHLTMUONDecision.h"
      39             : #include "AliMUONTriggerDDLDecoderEventHandler.h"
      40             : #include "TClonesArray.h"
      41             : #include <cassert>
      42             : #include <map>
      43             : 
      44           6 : ClassImp(AliHLTMUONRootifierComponent);
      45             : 
      46             : 
      47             : AliHLTMUONRootifierComponent::AliHLTMUONRootifierComponent() :
      48           3 :         AliHLTMUONProcessor(),
      49           3 :         fWarnForUnexpecedBlock(false)
      50          15 : {
      51             :         ///
      52             :         /// Default constructor.
      53             :         ///
      54           6 : }
      55             : 
      56             : 
      57             : AliHLTMUONRootifierComponent::~AliHLTMUONRootifierComponent()
      58          12 : {
      59             :         ///
      60             :         /// Default destructor.
      61             :         ///
      62          12 : }
      63             : 
      64             : 
      65             : bool AliHLTMUONRootifierComponent::IgnoreArgument(const char* arg) const
      66             : {
      67             :         /// Return true if the argument is one of -cdbpath -run or -delaysetup
      68             :         /// to prevent the parent class from parsing these arguments in DoInit.
      69             :         
      70           0 :         if (strcmp(arg, "-cdbpath") == 0 or strcmp(arg, "-run") == 0 or
      71           0 :             strcmp(arg, "-delaysetup") == 0)
      72             :         {
      73           0 :                 return true;
      74             :         }
      75             :         else
      76             :         {
      77           0 :                 return false;
      78             :         }
      79           0 : }
      80             : 
      81             : 
      82             : int AliHLTMUONRootifierComponent::DoInit(int argc, const char** argv)
      83             : {
      84             :         ///
      85             :         /// Inherited from AliHLTComponent.
      86             :         /// Parses the command line parameters and initialises the component.
      87             :         ///
      88             :         
      89           0 :         HLTInfo("Initialising dHLT rootifier component.");
      90             : 
      91             :         // Inherit the parents functionality.
      92           0 :         int result = AliHLTMUONProcessor::DoInit(argc, argv);
      93           0 :         if (result != 0) return result;
      94             :         
      95           0 :         fWarnForUnexpecedBlock = false;
      96             :         
      97           0 :         for (int i = 0; i < argc; i++)
      98             :         {
      99           0 :                 if (ArgumentAlreadyHandled(i, argv[i])) continue;
     100             : 
     101           0 :                 if (strcmp(argv[i], "-warn_on_unexpected_block") == 0)
     102             :                 {
     103           0 :                         fWarnForUnexpecedBlock = true;
     104           0 :                         continue;
     105             :                 }
     106             : 
     107           0 :                 HLTError("Unknown option '%s'.", argv[i]);
     108           0 :                 return -EINVAL;
     109             :         }
     110             :         
     111           0 :         return 0;
     112           0 : }
     113             : 
     114             : 
     115             : int AliHLTMUONRootifierComponent::DoDeinit()
     116             : {
     117             :         ///
     118             :         /// Inherited from AliHLTComponent. Performs a cleanup of the component.
     119             :         ///
     120             :         
     121           0 :         HLTInfo("Deinitialising dHLT rootifier component.");
     122           0 :         return 0;
     123             : }
     124             : 
     125             : 
     126             : const char* AliHLTMUONRootifierComponent::GetComponentID()
     127             : {
     128             :         ///
     129             :         /// Inherited from AliHLTComponent. Returns the component ID.
     130             :         ///
     131             :         
     132         234 :         return AliHLTMUONConstants::RootifierComponentId();
     133             : }
     134             : 
     135             : 
     136             : AliHLTComponentDataType AliHLTMUONRootifierComponent::GetOutputDataType()
     137             : {
     138             :         /// Inherited from AliHLTComponent. Returns kAliHLTMultipleDataType
     139             :         /// refer to GetOutputDataTypes for all returned data types.
     140             :         
     141           0 :         return kAliHLTMultipleDataType;
     142             : }
     143             : 
     144             : 
     145             : int AliHLTMUONRootifierComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
     146             : {
     147             :         /// Inherited from AliHLTComponent. Returns the output data types.
     148             :         
     149           0 :         tgtList.push_back(AliHLTMUONConstants::RootifiedEventDataType());
     150           0 :         return tgtList.size();
     151             : }
     152             : 
     153             : 
     154             : void AliHLTMUONRootifierComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
     155             : {
     156             :         ///
     157             :         /// Inherited from AliHLTProcessor. Returns the list of expected input data types.
     158             :         ///
     159             :         
     160           0 :         list.push_back(kAliHLTAnyDataType);
     161           0 : }
     162             : 
     163             : 
     164             : void AliHLTMUONRootifierComponent::GetOutputDataSize(
     165             :                 unsigned long& constBase, double& inputMultiplier
     166             :         )
     167             : {
     168             :         ///
     169             :         /// Inherited from AliHLTComponent. Returns an estimate of the expected output data size.
     170             :         ///
     171             :         
     172           0 :         constBase = 1024*1024;
     173           0 :         inputMultiplier = 100;
     174           0 : }
     175             : 
     176             : 
     177             : AliHLTComponent* AliHLTMUONRootifierComponent::Spawn()
     178             : {
     179             :         ///
     180             :         /// Inherited from AliHLTComponent. Creates a new object instance.
     181             :         ///
     182             :         
     183           0 :         return new AliHLTMUONRootifierComponent();
     184           0 : }
     185             : 
     186             : 
     187             : int AliHLTMUONRootifierComponent::DoEvent(
     188             :                 const AliHLTComponentEventData& evtData,
     189             :                 AliHLTComponentTriggerData& trigData
     190             :         )
     191             : {
     192             :         ///
     193             :         /// Inherited from AliHLTProcessor. Processes the new event data.
     194             :         ///
     195             :         
     196           0 :         if (not IsDataEvent()) return 0;
     197             :         
     198           0 :         AliHLTMUONEvent event(evtData.fEventID);
     199             :         const AliHLTComponentBlockData* block = NULL;
     200             :         AliHLTUInt32_t specification = 0;  // Contains the output data block spec bits.
     201           0 :         std::map<AliHLTInt32_t, AliHLTMUONTriggerRecord*> triggerMap;
     202             : 
     203             :         // First process the blocks of reconstructed hits and trigger records.
     204           0 :         for (int i = 0; i < GetNumberOfInputBlocks(); i++)
     205             :         {
     206           0 :                 block = GetInputBlock(i);
     207           0 :                 assert( block != NULL );
     208             :                 
     209             :                 HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
     210             :                         i, DataType2Text(block->fDataType).c_str(), block->fPtr, block->fSize
     211             :                 );
     212             :                 
     213           0 :                 if (block->fDataType == AliHLTMUONConstants::ESDDataType())
     214             :                 {
     215           0 :                         AliHLTMessage *fMessage = new AliHLTMessage( block->fPtr, block->fSize );
     216             :                         // -- Check if TMessage payload is TObject
     217           0 :                         if ( fMessage->What() == kMESS_OBJECT )
     218             :                         {
     219           0 :                                 AliESDEvent* esd = reinterpret_cast<AliESDEvent*>(fMessage->ReadObject( fMessage->GetClass() ));
     220           0 :                                 esd->GetStdContent();
     221           0 :                                 event.Add(esd);
     222           0 :                         }
     223           0 :                         fMessage->Reset();
     224           0 :                 }
     225           0 :                 else if (block->fDataType == AliHLTMUONConstants::RecHitsBlockDataType())
     226             :                 {
     227           0 :                         specification |= block->fSpecification;
     228           0 :                         AliHLTMUONRecHitsBlockReader inblock(block->fPtr, block->fSize);
     229           0 :                         if (not BlockStructureOk(inblock))
     230             :                         {
     231           0 :                                 if (DumpDataOnError()) DumpEvent(evtData, trigData);
     232           0 :                                 continue;
     233             :                         }
     234             :                         
     235             :                         // Decode the source DDL from the specification bits.
     236             :                         Int_t sourceDDL = -1;
     237           0 :                         bool ddl[22];
     238           0 :                         AliHLTMUONUtils::UnpackSpecBits(block->fSpecification, ddl);
     239           0 :                         for (int k = 0; k < 22; k++)
     240             :                         {
     241           0 :                                 if (ddl[k])
     242             :                                 {
     243           0 :                                         if (sourceDDL == -1)
     244             :                                         {
     245           0 :                                                 sourceDDL = k+1;
     246           0 :                                         }
     247             :                                         else
     248             :                                         {
     249           0 :                                                 HLTWarning("The input data block %d contains"
     250             :                                                         " data from multiple DDL sources.", i
     251             :                                                 );
     252             :                                         }
     253             :                                 }
     254             :                         }
     255           0 :                         if (sourceDDL > 20)
     256             :                         {
     257           0 :                                 HLTWarning("The source DDL for input data block %d is %d."
     258             :                                         " The expected range for the DDL is [1..20].",
     259             :                                         i, sourceDDL
     260             :                                 );
     261             :                         }
     262             :                         
     263           0 :                         for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     264             :                         {
     265           0 :                                 const AliHLTMUONRecHitStruct& h = inblock[n];
     266           0 :                                 AliHLTUInt8_t chamber;
     267           0 :                                 AliHLTUInt16_t detElemId;
     268           0 :                                 AliHLTMUONUtils::UnpackRecHitFlags(h.fFlags, chamber, detElemId);
     269           0 :                                 event.Add(new AliHLTMUONRecHit(h.fX, h.fY, h.fZ, sourceDDL, detElemId));
     270           0 :                         }
     271           0 :                 }
     272           0 :                 else if (block->fDataType == AliHLTMUONConstants::TriggerRecordsBlockDataType())
     273             :                 {
     274           0 :                         specification |= block->fSpecification;
     275           0 :                         AliHLTMUONTriggerRecordsBlockReader inblock(block->fPtr, block->fSize);
     276           0 :                         if (not BlockStructureOk(inblock))
     277             :                         {
     278           0 :                                 if (DumpDataOnError()) DumpEvent(evtData, trigData);
     279           0 :                                 continue;
     280             :                         }
     281             :                         
     282             :                         // Decode the source DDL from the specification bits.
     283             :                         Int_t sourceDDL = -1;
     284           0 :                         bool ddl[22];
     285           0 :                         AliHLTMUONUtils::UnpackSpecBits(block->fSpecification, ddl);
     286           0 :                         for (int k = 0; k < 22; k++)
     287             :                         {
     288           0 :                                 if (ddl[k])
     289             :                                 {
     290           0 :                                         if (sourceDDL == -1)
     291             :                                         {
     292           0 :                                                 sourceDDL = k+1;
     293           0 :                                         }
     294             :                                         else
     295             :                                         {
     296           0 :                                                 HLTWarning("The input data block %d contains"
     297             :                                                         " data from multiple DDL sources.", i
     298             :                                                 );
     299             :                                         }
     300             :                                 }
     301             :                         }
     302           0 :                         if (sourceDDL != -1 and (sourceDDL < 21 or sourceDDL > 22))
     303             :                         {
     304           0 :                                 HLTWarning("The source DDL for input data block %d is %d."
     305             :                                         " The expected range for the DDL is [21..22].",
     306             :                                         i, sourceDDL
     307             :                                 );
     308             :                         }
     309             :                         
     310           0 :                         for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     311             :                         {
     312           0 :                                 const AliHLTMUONTriggerRecordStruct& t = inblock[n];
     313             :                                 
     314           0 :                                 AliHLTMUONParticleSign sign;
     315           0 :                                 bool hitset[4];
     316           0 :                                 AliHLTMUONUtils::UnpackTriggerRecordFlags(
     317           0 :                                                 t.fFlags, sign, hitset
     318             :                                         );
     319             :                         
     320           0 :                                 AliHLTMUONTriggerRecord* tr = new AliHLTMUONTriggerRecord(
     321           0 :                                                 t.fId, sign, t.fPx, t.fPy, t.fPz, sourceDDL
     322             :                                         );
     323           0 :                                 for (int k = 0; k < 4; k++)
     324             :                                 {
     325           0 :                                         if (not hitset[k]) continue;
     326           0 :                                         Int_t detElemId = AliHLTMUONUtils::GetDetElemIdFromFlags(t.fHit[k].fFlags);
     327           0 :                                         tr->SetHit(k+11, t.fHit[k].fX, t.fHit[k].fY, t.fHit[k].fZ, detElemId);
     328           0 :                                 }
     329           0 :                                 event.Add(tr);
     330           0 :                                 triggerMap[t.fId] = tr;
     331           0 :                         }
     332           0 :                 }
     333             :                 else
     334             :                 {
     335           0 :                         if (block->fDataType != AliHLTMUONConstants::TrigRecsDebugBlockDataType() and
     336           0 :                             block->fDataType != AliHLTMUONConstants::ClusterBlockDataType() and
     337           0 :                             block->fDataType != AliHLTMUONConstants::ChannelBlockDataType() and
     338           0 :                             block->fDataType != AliHLTMUONConstants::MansoTracksBlockDataType() and
     339           0 :                             block->fDataType != AliHLTMUONConstants::MansoCandidatesBlockDataType() and
     340           0 :                             block->fDataType != AliHLTMUONConstants::SinglesDecisionBlockDataType() and
     341           0 :                             block->fDataType != AliHLTMUONConstants::PairsDecisionBlockDataType()
     342             :                            )
     343             :                         {
     344             :                                 // Log a message indicating that we got a data block that we
     345             :                                 // do not know how to handle.
     346           0 :                                 if (fWarnForUnexpecedBlock)
     347           0 :                                         HLTWarning("Received a data block of a type we cannot handle: '%s', spec: 0x%X",
     348             :                                                 DataType2Text(block->fDataType).c_str(), block->fSpecification
     349             :                                         );
     350             : #ifdef __DEBUG
     351             :                                 else
     352             :                                         HLTDebug("Received a data block of a type we cannot handle: '%s', spec: 0x%X",
     353             :                                                 DataType2Text(block->fDataType).c_str(), block->fSpecification
     354             :                                         );
     355             : #endif
     356             :                         }
     357             :                 }
     358             :         }
     359             :         
     360             :         // We need to check if there are any trigger record debug data blocks
     361             :         // and add their information to the AliHLTMUONTriggerRecord objects.
     362           0 :         for (block = GetFirstInputBlock(AliHLTMUONConstants::TrigRecsDebugBlockDataType());
     363           0 :              block != NULL;
     364           0 :              block = GetNextInputBlock()
     365             :             )
     366             :         {
     367           0 :                 specification |= block->fSpecification;
     368           0 :                 AliHLTMUONTrigRecsDebugBlockReader inblock(block->fPtr, block->fSize);
     369           0 :                 if (not BlockStructureOk(inblock))
     370             :                 {
     371           0 :                         if (DumpDataOnError()) DumpEvent(evtData, trigData);
     372           0 :                         continue;
     373             :                 }
     374             :                 
     375           0 :                 for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     376             :                 {
     377           0 :                         const AliHLTMUONTrigRecInfoStruct& triginfo = inblock[n];
     378             :                         
     379           0 :                         AliHLTMUONTriggerRecord* trigrec = triggerMap[triginfo.fTrigRecId];
     380           0 :                         if (trigrec == NULL)
     381             :                         {
     382             :                                 // Decode the source DDL from the specification bits.
     383             :                                 Int_t sourceDDL = -1;
     384           0 :                                 bool ddl[22];
     385           0 :                                 AliHLTMUONUtils::UnpackSpecBits(block->fSpecification, ddl);
     386           0 :                                 for (int k = 0; k < 22; k++)
     387             :                                 {
     388           0 :                                         if (ddl[k])
     389             :                                         {
     390           0 :                                                 if (sourceDDL == -1)
     391             :                                                 {
     392           0 :                                                         sourceDDL = k+1;
     393           0 :                                                 }
     394             :                                                 else
     395             :                                                 {
     396           0 :                                                         HLTWarning("An trigger debug information data block"
     397             :                                                                 " contains data from multiple DDL sources."
     398             :                                                         );
     399             :                                                 }
     400             :                                         }
     401             :                                 }
     402           0 :                                 if (sourceDDL != -1 and (sourceDDL < 21 or sourceDDL > 22))
     403             :                                 {
     404           0 :                                         HLTWarning("The source DDL for a trigger debug information data"
     405             :                                                 " block is %d. The expected range for the DDL is [21..22].",
     406             :                                                 sourceDDL
     407             :                                         );
     408             :                                 }
     409             :                                 
     410             :                                 // Add an new empty trigger record since none was found.
     411           0 :                                 trigrec = new AliHLTMUONTriggerRecord(
     412             :                                                 0, 0, 0, 0, 0, sourceDDL
     413             :                                         );
     414           0 :                                 triggerMap[triginfo.fTrigRecId] = trigrec;
     415           0 :                                 event.Add(trigrec);
     416           0 :                         }
     417             :                         else
     418             :                         {
     419           0 :                                 for (Int_t j = 0; j < 4; ++j)
     420             :                                 {
     421           0 :                                         if (trigrec->DetElemId(j+11) != -1 and triginfo.fDetElemId[j] != trigrec->DetElemId(j+11))
     422             :                                         {
     423           0 :                                                 HLTWarning("Found a trigger record with a hit on chamber %d with a different"
     424             :                                                         " detector element ID %d than the debug information %d.",
     425             :                                                         j, trigrec->DetElemId(j+11), triginfo.fDetElemId[j]
     426             :                                                 );
     427             :                                         }
     428             :                                 }
     429             :                         }
     430             :                         
     431             :                         typedef AliMUONTriggerDDLDecoderEventHandler Handler;
     432             :                         
     433           0 :                         trigrec->SetDebugInfo(triginfo.fZmiddle, triginfo.fBl);
     434             :                         
     435           0 :                         UShort_t patternX[4][3] = {
     436           0 :                                 {
     437           0 :                                         Handler::GetLocalX1(&triginfo.fL0StructPrev),
     438           0 :                                         Handler::GetLocalX1(&triginfo.fL0Struct),
     439           0 :                                         Handler::GetLocalX1(&triginfo.fL0StructNext)
     440           0 :                                 },{
     441           0 :                                         Handler::GetLocalX2(&triginfo.fL0StructPrev),
     442           0 :                                         Handler::GetLocalX2(&triginfo.fL0Struct),
     443           0 :                                         Handler::GetLocalX2(&triginfo.fL0StructNext)
     444           0 :                                 },{
     445           0 :                                         Handler::GetLocalX3(&triginfo.fL0StructPrev),
     446           0 :                                         Handler::GetLocalX3(&triginfo.fL0Struct),
     447           0 :                                         Handler::GetLocalX3(&triginfo.fL0StructNext)
     448           0 :                                 },{
     449           0 :                                         Handler::GetLocalX4(&triginfo.fL0StructPrev),
     450           0 :                                         Handler::GetLocalX4(&triginfo.fL0Struct),
     451           0 :                                         Handler::GetLocalX4(&triginfo.fL0StructNext)
     452             :                                 }
     453             :                         };
     454           0 :                         UShort_t patternY[4][3] = {
     455           0 :                                 {
     456           0 :                                         Handler::GetLocalY1(&triginfo.fL0StructPrev),
     457           0 :                                         Handler::GetLocalY1(&triginfo.fL0Struct),
     458           0 :                                         Handler::GetLocalY1(&triginfo.fL0StructNext)
     459           0 :                                 },{
     460           0 :                                         Handler::GetLocalY2(&triginfo.fL0StructPrev),
     461           0 :                                         Handler::GetLocalY2(&triginfo.fL0Struct),
     462           0 :                                         Handler::GetLocalY2(&triginfo.fL0StructNext)
     463           0 :                                 },{
     464           0 :                                         Handler::GetLocalY3(&triginfo.fL0StructPrev),
     465           0 :                                         Handler::GetLocalY3(&triginfo.fL0Struct),
     466           0 :                                         Handler::GetLocalY3(&triginfo.fL0StructNext)
     467           0 :                                 },{
     468           0 :                                         Handler::GetLocalY4(&triginfo.fL0StructPrev),
     469           0 :                                         Handler::GetLocalY4(&triginfo.fL0Struct),
     470           0 :                                         Handler::GetLocalY4(&triginfo.fL0StructNext)
     471             :                                 }
     472             :                         };
     473             :                         
     474           0 :                         for (Int_t j = 0; j < 4; ++j)
     475             :                         {
     476           0 :                                 trigrec->SetHitDebugInfo(j+11, patternX[j], patternY[j]);
     477             :                         }
     478           0 :                 }
     479           0 :         }
     480             :         
     481           0 :         std::map<AliHLTInt32_t, AliHLTMUONRecHit*> clusterMap;
     482             :         
     483             :         // We need to check if there are any cluster data blocks and add their
     484             :         // information to the AliHLTMUONRecHit objects.
     485           0 :         for (block = GetFirstInputBlock(AliHLTMUONConstants::ClusterBlockDataType());
     486           0 :              block != NULL;
     487           0 :              block = GetNextInputBlock()
     488             :             )
     489             :         {
     490           0 :                 specification |= block->fSpecification;
     491           0 :                 AliHLTMUONClustersBlockReader inblock(block->fPtr, block->fSize);
     492           0 :                 if (not BlockStructureOk(inblock))
     493             :                 {
     494           0 :                         if (DumpDataOnError()) DumpEvent(evtData, trigData);
     495           0 :                         continue;
     496             :                 }
     497             :                 
     498           0 :                 for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     499             :                 {
     500           0 :                         const AliHLTMUONClusterStruct& clust = inblock[n];
     501             :                         
     502           0 :                         AliHLTUInt8_t chamber;
     503           0 :                         AliHLTUInt16_t detElemId;
     504           0 :                         AliHLTMUONUtils::UnpackRecHitFlags(clust.fHit.fFlags, chamber, detElemId);
     505           0 :                         if (clust.fDetElemId != detElemId)
     506             :                         {
     507           0 :                                 HLTWarning("Found a cluster with a different detector element ID (%d)"
     508             :                                         " from its corresponding hit (x,y,z = %f,%f,%f and detElemId = %d).",
     509             :                                         clust.fDetElemId,
     510             :                                         clust.fHit.fX, clust.fHit.fY, clust.fHit.fZ,
     511             :                                         detElemId
     512             :                                 );
     513             :                         }
     514             :                         
     515             :                         // Try find the corresponding reconstructed hit in 'event'.
     516             :                         AliHLTMUONRecHit* hit = NULL;
     517           0 :                         for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++)
     518             :                         {
     519           0 :                                 if (event.Array()[k]->IsA() != AliHLTMUONRecHit::Class())
     520             :                                         continue;
     521           0 :                                 AliHLTMUONRecHit* h = static_cast<AliHLTMUONRecHit*>(event.Array()[k]);
     522           0 :                                 if (h->DetElemId() == detElemId and h->X() == clust.fHit.fX
     523           0 :                                     and h->Y() == clust.fHit.fY and h->Z() == clust.fHit.fZ)
     524             :                                 {
     525             :                                         hit = h;
     526           0 :                                         break;
     527             :                                 }
     528           0 :                         }
     529             :                         
     530             :                         // If we could not find the corresponding hit then we need to create
     531             :                         // a new hit object, otherwise we can just append the information.
     532           0 :                         if (hit == NULL)
     533             :                         {
     534             :                                 // Decode the source DDL from the specification bits.
     535             :                                 Int_t sourceDDL = -1;
     536           0 :                                 bool ddl[22];
     537           0 :                                 AliHLTMUONUtils::UnpackSpecBits(block->fSpecification, ddl);
     538           0 :                                 for (int k = 0; k < 22; k++)
     539             :                                 {
     540           0 :                                         if (ddl[k])
     541             :                                         {
     542           0 :                                                 if (sourceDDL == -1)
     543             :                                                 {
     544           0 :                                                         sourceDDL = k+1;
     545           0 :                                                 }
     546             :                                                 else
     547             :                                                 {
     548           0 :                                                         HLTWarning("An input block of cluster data contains"
     549             :                                                                 " data from multiple DDL sources."
     550             :                                                         );
     551             :                                                 }
     552             :                                         }
     553             :                                 }
     554           0 :                                 if (sourceDDL > 20)
     555             :                                 {
     556           0 :                                         HLTWarning("The source DDL of a cluster data input block is %d."
     557             :                                                 " The expected range for the DDL is [1..20].",
     558             :                                                 sourceDDL
     559             :                                         );
     560             :                                 }
     561           0 :                                 hit = new AliHLTMUONRecHit(
     562           0 :                                                 clust.fHit.fX, clust.fHit.fY, clust.fHit.fZ,
     563           0 :                                                 sourceDDL, detElemId
     564             :                                         );
     565           0 :                                 event.Add(hit);
     566           0 :                         }
     567             :                         else
     568             :                         {
     569           0 :                                 hit->SetDebugInfo(
     570           0 :                                                   detElemId, clust.fId,
     571           0 :                                                   clust.fNchannelsB, clust.fNchannelsNB,
     572           0 :                                                   clust.fChargeB, clust.fChargeNB,
     573           0 :                                                   hit->SourceDDL()
     574             :                                 );
     575             :                         }
     576             :                         
     577           0 :                         clusterMap[clust.fId] = hit;
     578           0 :                 }
     579           0 :         }
     580             :         
     581             :         // We need to check if there are any channel data blocks and add their
     582             :         // information to the AliHLTMUONRecHit objects.
     583           0 :         for (block = GetFirstInputBlock(AliHLTMUONConstants::ChannelBlockDataType());
     584           0 :              block != NULL;
     585           0 :              block = GetNextInputBlock()
     586             :             )
     587             :         {
     588           0 :                 specification |= block->fSpecification;
     589           0 :                 AliHLTMUONChannelsBlockReader inblock(block->fPtr, block->fSize);
     590           0 :                 if (not BlockStructureOk(inblock))
     591             :                 {
     592           0 :                         if (DumpDataOnError()) DumpEvent(evtData, trigData);
     593           0 :                         continue;
     594             :                 }
     595             :                 
     596           0 :                 for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     597             :                 {
     598           0 :                         const AliHLTMUONChannelStruct& channel = inblock[n];
     599             :                         
     600           0 :                         AliHLTMUONRecHit* hit = clusterMap[channel.fClusterId];
     601           0 :                         if (hit == NULL)
     602             :                         {
     603             :                                 // Decode the source DDL from the specification bits.
     604             :                                 Int_t sourceDDL = -1;
     605           0 :                                 bool ddl[22];
     606           0 :                                 AliHLTMUONUtils::UnpackSpecBits(block->fSpecification, ddl);
     607           0 :                                 for (int k = 0; k < 22; k++)
     608             :                                 {
     609           0 :                                         if (ddl[k])
     610             :                                         {
     611           0 :                                                 if (sourceDDL == -1)
     612             :                                                 {
     613           0 :                                                         sourceDDL = k+1;
     614           0 :                                                 }
     615             :                                                 else
     616             :                                                 {
     617           0 :                                                         HLTWarning("An input block of cluster data contains"
     618             :                                                                 " data from multiple DDL sources."
     619             :                                                         );
     620             :                                                 }
     621             :                                         }
     622             :                                 }
     623           0 :                                 if (sourceDDL > 20)
     624             :                                 {
     625           0 :                                         HLTWarning("The source DDL of a cluster data input block is %d."
     626             :                                                 " The expected range for the DDL is [1..20].",
     627             :                                                 sourceDDL
     628             :                                         );
     629             :                                 }
     630           0 :                                 hit = new AliHLTMUONRecHit(0, 0, 0, sourceDDL, -1);
     631           0 :                                 event.Add(hit);
     632           0 :                         }
     633             :                         
     634           0 :                         hit->AddChannel(
     635           0 :                                         channel.fBusPatch, channel.fManu,
     636           0 :                                         channel.fChannelAddress, channel.fSignal,
     637           0 :                                         channel.fRawDataWord
     638             :                                 );
     639             :                 }
     640           0 :         }
     641             :         
     642             :         // Now we can look for tracks to add. We needed the ROOT trigger records
     643             :         // and reco hits created before we can create track objects.
     644             :         
     645           0 :         std::map<AliHLTInt32_t, AliHLTMUONTrack*> trackMap;
     646             :         
     647           0 :         for (block = GetFirstInputBlock(AliHLTMUONConstants::TracksBlockDataType());
     648           0 :              block != NULL;
     649           0 :              block = GetNextInputBlock()
     650             :             )
     651             :         {
     652           0 :                 specification |= block->fSpecification;
     653           0 :                 AliHLTMUONTracksBlockReader inblock(block->fPtr, block->fSize);
     654           0 :                 if (not BlockStructureOk(inblock))
     655             :                 {
     656           0 :                         if (DumpDataOnError()) DumpEvent(evtData, trigData);
     657           0 :                         continue;
     658             :                 }
     659             :                 
     660           0 :                 for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     661             :                 {
     662           0 :                         const AliHLTMUONTrackStruct& t = inblock[n];
     663           0 :                         trackMap[t.fId] = AddTrack(event, t);
     664             :                 }
     665           0 :         }
     666             : 
     667           0 :         std::map<AliHLTInt32_t, AliHLTMUONMansoTrack*> mansoTrackMap;
     668             :         
     669           0 :         for (block = GetFirstInputBlock(AliHLTMUONConstants::MansoTracksBlockDataType());
     670           0 :              block != NULL;
     671           0 :              block = GetNextInputBlock()
     672             :             )
     673             :         {
     674           0 :                 specification |= block->fSpecification;
     675           0 :                 AliHLTMUONMansoTracksBlockReader inblock(block->fPtr, block->fSize);
     676           0 :                 if (not BlockStructureOk(inblock))
     677             :                 {
     678           0 :                         if (DumpDataOnError()) DumpEvent(evtData, trigData);
     679           0 :                         continue;
     680             :                 }
     681             :                 
     682           0 :                 for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     683             :                 {
     684           0 :                         const AliHLTMUONMansoTrackStruct& t = inblock[n];
     685           0 :                         mansoTrackMap[t.fId] = AddTrack(event, t);
     686             :                 }
     687           0 :         }
     688             :         
     689             :         // Look for Manso track candidates to add the debug info to the tracks.
     690           0 :         for (block = GetFirstInputBlock(AliHLTMUONConstants::MansoCandidatesBlockDataType());
     691           0 :              block != NULL;
     692           0 :              block = GetNextInputBlock()
     693             :             )
     694             :         {
     695           0 :                 specification |= block->fSpecification;
     696           0 :                 AliHLTMUONMansoCandidatesBlockReader inblock(block->fPtr, block->fSize);
     697           0 :                 if (not BlockStructureOk(inblock))
     698             :                 {
     699           0 :                         if (DumpDataOnError()) DumpEvent(evtData, trigData);
     700           0 :                         continue;
     701             :                 }
     702             :                 
     703           0 :                 for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     704             :                 {
     705           0 :                         const AliHLTMUONMansoCandidateStruct& tc = inblock[n];
     706           0 :                         AliHLTMUONMansoTrack* mtrack = mansoTrackMap[tc.fTrack.fId];
     707           0 :                         if (mtrack == NULL)
     708             :                         {
     709             :                                 // If we got here then we could not find the corresponding Manso
     710             :                                 // track. So we need to create and add a new track object.
     711           0 :                                 mtrack = AddTrack(event, tc.fTrack);
     712           0 :                         }
     713           0 :                         mtrack->SetDebugData(tc.fZmiddle, tc.fBl);
     714           0 :                         for (AliHLTUInt32_t i = 0; i < 4; ++i)
     715             :                         {
     716           0 :                                 if (tc.fRoI[i] == AliHLTMUONConstants::NilMansoRoIStruct()) continue;
     717           0 :                                 mtrack->SetRoI(i+7, tc.fRoI[i].fX, tc.fRoI[i].fY, tc.fRoI[i].fZ, tc.fRoI[i].fRadius);
     718             :                         }
     719             :                 }
     720           0 :         }
     721             :         
     722             :         bool decisionBlockFound = false;
     723             :         UInt_t numLowPt = 0;
     724             :         UInt_t numHighPt = 0;
     725           0 :         TClonesArray singlesDecisions("AliHLTMUONDecision::AliTrackDecision");
     726             :         
     727             :         // Find the single tracks decision blocks and add their information.
     728             :         // We just sum the trigger scalars and single decisions.
     729           0 :         for (block = GetFirstInputBlock(AliHLTMUONConstants::SinglesDecisionBlockDataType());
     730           0 :              block != NULL;
     731           0 :              block = GetNextInputBlock()
     732             :             )
     733             :         {
     734             :                 decisionBlockFound = true;
     735           0 :                 specification |= block->fSpecification;
     736           0 :                 AliHLTMUONSinglesDecisionBlockReader inblock(block->fPtr, block->fSize);
     737           0 :                 if (not BlockStructureOk(inblock))
     738             :                 {
     739           0 :                         if (DumpDataOnError()) DumpEvent(evtData, trigData);
     740           0 :                         continue;
     741             :                 }
     742             :                 
     743           0 :                 numLowPt += inblock.BlockHeader().fNlowPt;
     744           0 :                 numHighPt += inblock.BlockHeader().fNhighPt;
     745             :                 
     746           0 :                 for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     747             :                 {
     748           0 :                         const AliHLTMUONTrackDecisionStruct& t = inblock[n];
     749             :                         
     750           0 :                         bool highPt, lowPt;
     751           0 :                         AliHLTMUONUtils::UnpackTrackDecisionBits(t.fTriggerBits, highPt, lowPt);
     752             :                         
     753             :                         // Try find the corresponding track.
     754           0 :                         const TObject* track = trackMap[t.fTrackId];
     755           0 :                         if (track == NULL) track = mansoTrackMap[t.fTrackId];
     756             :                         
     757             :                         // If the track was not found then create a dummy one.
     758           0 :                         if (track == NULL)
     759             :                         {
     760           0 :                                 AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(t.fTrackId);
     761           0 :                                 event.Add(tr);
     762             :                                 track = tr;
     763           0 :                                 mansoTrackMap[t.fTrackId] = tr;
     764           0 :                         }
     765             :                         
     766           0 :                         new (singlesDecisions[singlesDecisions.GetEntriesFast()])
     767           0 :                                 AliHLTMUONDecision::AliTrackDecision(t.fPt, lowPt, highPt, track);
     768           0 :                 }
     769           0 :         }
     770             :         
     771             :         UInt_t numUnlikeAnyPt = 0;
     772             :         UInt_t numUnlikeLowPt = 0;
     773             :         UInt_t numUnlikeHighPt = 0;
     774             :         UInt_t numLikeAnyPt = 0;
     775             :         UInt_t numLikeLowPt = 0;
     776             :         UInt_t numLikeHighPt = 0;
     777             :         UInt_t numAnyMass = 0;
     778             :         UInt_t numLowMass = 0;
     779             :         UInt_t numHighMass = 0;
     780           0 :         TClonesArray pairsDecisions("AliHLTMUONDecision::AliPairDecision");
     781             :         
     782             :         // Find the track pairs decision blocks and add their information.
     783             :         // We just sum the trigger scalars and track pair decisions.
     784           0 :         for (block = GetFirstInputBlock(AliHLTMUONConstants::PairsDecisionBlockDataType());
     785           0 :              block != NULL;
     786           0 :              block = GetNextInputBlock()
     787             :             )
     788             :         {
     789             :                 decisionBlockFound = true;
     790           0 :                 specification |= block->fSpecification;
     791           0 :                 AliHLTMUONPairsDecisionBlockReader inblock(block->fPtr, block->fSize);
     792           0 :                 if (not BlockStructureOk(inblock))
     793             :                 {
     794           0 :                         if (DumpDataOnError()) DumpEvent(evtData, trigData);
     795           0 :                         continue;
     796             :                 }
     797             :                 
     798           0 :                 numUnlikeAnyPt += inblock.BlockHeader().fNunlikeAnyPt;
     799           0 :                 numUnlikeLowPt += inblock.BlockHeader().fNunlikeLowPt;
     800           0 :                 numUnlikeHighPt += inblock.BlockHeader().fNunlikeHighPt;
     801           0 :                 numLikeAnyPt += inblock.BlockHeader().fNlikeAnyPt;
     802           0 :                 numLikeLowPt += inblock.BlockHeader().fNlikeLowPt;
     803           0 :                 numLikeHighPt += inblock.BlockHeader().fNlikeHighPt;
     804           0 :                 numAnyMass += inblock.BlockHeader().fNmassAny;
     805           0 :                 numLowMass += inblock.BlockHeader().fNmassLow;
     806           0 :                 numHighMass += inblock.BlockHeader().fNmassHigh;
     807             :                 
     808           0 :                 for (AliHLTUInt32_t n = 0; n < inblock.Nentries(); n++)
     809             :                 {
     810           0 :                         const AliHLTMUONPairDecisionStruct& t = inblock[n];
     811             :                         
     812           0 :                         bool highMass, lowMass, unlike;
     813           0 :                         AliHLTUInt8_t highPtCount, lowPtCount;
     814           0 :                         AliHLTMUONUtils::UnpackPairDecisionBits(
     815           0 :                                         t.fTriggerBits, highMass, lowMass, unlike,
     816             :                                         highPtCount, lowPtCount
     817             :                                 );
     818             :                         
     819             :                         // Try find the corresponding tracks.
     820           0 :                         const TObject* trackA = trackMap[t.fTrackAId];
     821           0 :                         if (trackA == NULL) trackA = mansoTrackMap[t.fTrackAId];
     822           0 :                         const TObject* trackB = trackMap[t.fTrackBId];
     823           0 :                         if (trackB == NULL) trackB = mansoTrackMap[t.fTrackBId];
     824             :                         
     825             :                         // If either of the tracks was not found then create a dummy one.
     826           0 :                         if (trackA == NULL)
     827             :                         {
     828           0 :                                 AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(t.fTrackAId);
     829           0 :                                 event.Add(tr);
     830             :                                 trackA = tr;
     831           0 :                                 mansoTrackMap[t.fTrackAId] = tr;
     832           0 :                         }
     833           0 :                         if (trackB == NULL)
     834             :                         {
     835           0 :                                 AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(t.fTrackBId);
     836           0 :                                 event.Add(tr);
     837             :                                 trackB = tr;
     838           0 :                                 mansoTrackMap[t.fTrackBId] = tr;
     839           0 :                         }
     840             :                         
     841           0 :                         new (pairsDecisions[pairsDecisions.GetEntriesFast()])
     842           0 :                                 AliHLTMUONDecision::AliPairDecision(
     843           0 :                                         t.fInvMass, lowMass, highMass, unlike,
     844           0 :                                         lowPtCount, highPtCount, trackA, trackB
     845             :                                 );
     846           0 :                 }
     847           0 :         }
     848             :         
     849             :         // Do not add the decision if no decision blocks were found.
     850           0 :         if (decisionBlockFound)
     851             :         {
     852           0 :                 AliHLTMUONDecision* triggerDecision = new AliHLTMUONDecision(
     853             :                                 numLowPt, numHighPt, numUnlikeAnyPt, numUnlikeLowPt,
     854             :                                 numUnlikeHighPt, numLikeAnyPt, numLikeLowPt,
     855             :                                 numLikeHighPt, numAnyMass, numLowMass, numHighMass
     856             :                         );
     857           0 :                 for (Int_t i = 0; i < singlesDecisions.GetEntriesFast(); i++)
     858             :                 {
     859             :                         AliHLTMUONDecision::AliTrackDecision* decision =
     860           0 :                                 static_cast<AliHLTMUONDecision::AliTrackDecision*>( singlesDecisions[i] );
     861           0 :                         triggerDecision->AddDecision(decision);
     862             :                 }
     863           0 :                 for (Int_t j = 0; j < pairsDecisions.GetEntriesFast(); j++)
     864             :                 {
     865             :                         AliHLTMUONDecision::AliPairDecision* decision =
     866           0 :                                 static_cast<AliHLTMUONDecision::AliPairDecision*>( pairsDecisions[j] );
     867           0 :                         triggerDecision->AddDecision(decision);
     868             :                 }
     869             :                 
     870           0 :                 event.Add(triggerDecision);
     871           0 :         }
     872             :         
     873           0 :         PushBack(&event, AliHLTMUONConstants::RootifiedEventDataType(), specification);
     874             :         
     875             :         return 0;
     876           0 : }
     877             : 
     878             : 
     879             : AliHLTMUONMansoTrack* AliHLTMUONRootifierComponent::AddTrack(
     880             :                 AliHLTMUONEvent& event, const AliHLTMUONMansoTrackStruct& track
     881             :         )
     882             : {
     883             :         // Converts the track structure and adds it to the event object.
     884             :         
     885           0 :         AliHLTMUONParticleSign sign;
     886           0 :         bool hitset[4];
     887           0 :         AliHLTMUONUtils::UnpackMansoTrackFlags(
     888           0 :                         track.fFlags, sign, hitset
     889             :                 );
     890             :         
     891             :         // Try find the trigger record in 'event'.
     892             :         const AliHLTMUONTriggerRecord* trigrec = NULL;
     893           0 :         for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++)
     894             :         {
     895           0 :                 if (event.Array()[k]->IsA() != AliHLTMUONTriggerRecord::Class())
     896             :                         continue;
     897             :                 const AliHLTMUONTriggerRecord* tk =
     898           0 :                         static_cast<const AliHLTMUONTriggerRecord*>(event.Array()[k]);
     899           0 :                 if (tk->Id() == track.fTrigRec)
     900             :                 {
     901             :                         trigrec = tk;
     902           0 :                         break;
     903             :                 }
     904           0 :         }
     905             :         
     906             :         // Now try find the hits in 'event'.
     907             :         // If they cannot be found then create new ones.
     908             :         const AliHLTMUONRecHit* hit7 = NULL;
     909             :         const AliHLTMUONRecHit* hit8 = NULL;
     910             :         const AliHLTMUONRecHit* hit9 = NULL;
     911             :         const AliHLTMUONRecHit* hit10 = NULL;
     912           0 :         for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++)
     913             :         {
     914           0 :                 if (event.Array()[k]->IsA() != AliHLTMUONRecHit::Class())
     915             :                         continue;
     916             :                 const AliHLTMUONRecHit* h =
     917           0 :                         static_cast<const AliHLTMUONRecHit*>(event.Array()[k]);
     918             :                 
     919           0 :                 if (hitset[0] and h->X() == track.fHit[0].fX and h->Y() == track.fHit[0].fY
     920           0 :                         and h->Z() == track.fHit[0].fZ)
     921             :                 {
     922             :                         hit7 = h;
     923           0 :                 }
     924           0 :                 if (hitset[1] and h->X() == track.fHit[1].fX and h->Y() == track.fHit[1].fY
     925           0 :                         and h->Z() == track.fHit[1].fZ)
     926             :                 {
     927             :                         hit8 = h;
     928           0 :                 }
     929           0 :                 if (hitset[2] and h->X() == track.fHit[2].fX and h->Y() == track.fHit[2].fY
     930           0 :                         and h->Z() == track.fHit[2].fZ)
     931             :                 {
     932             :                         hit9 = h;
     933           0 :                 }
     934           0 :                 if (hitset[3] and h->X() == track.fHit[3].fX and h->Y() == track.fHit[3].fY
     935           0 :                         and h->Z() == track.fHit[3].fZ)
     936             :                 {
     937             :                         hit10 = h;
     938           0 :                 }
     939           0 :         }
     940             :         AliHLTMUONRecHit* newhit;
     941           0 :         if (hitset[0] and hit7 == NULL)
     942             :         {
     943           0 :                 newhit = new AliHLTMUONRecHit(track.fHit[0].fX, track.fHit[0].fY, track.fHit[0].fZ);
     944           0 :                 event.Add(newhit);
     945             :                 hit7 = newhit;
     946           0 :         }
     947           0 :         if (hitset[1] and hit8 == NULL)
     948             :         {
     949           0 :                 newhit = new AliHLTMUONRecHit(track.fHit[1].fX, track.fHit[1].fY, track.fHit[1].fZ);
     950           0 :                 event.Add(newhit);
     951             :                 hit8 = newhit;
     952           0 :         }
     953           0 :         if (hitset[2] and hit9 == NULL)
     954             :         {
     955           0 :                 newhit = new AliHLTMUONRecHit(track.fHit[2].fX, track.fHit[2].fY, track.fHit[2].fZ);
     956           0 :                 event.Add(newhit);
     957             :                 hit9 = newhit;
     958           0 :         }
     959           0 :         if (hitset[3] and hit10 == NULL)
     960             :         {
     961           0 :                 newhit = new AliHLTMUONRecHit(track.fHit[3].fX, track.fHit[3].fY, track.fHit[3].fZ);
     962           0 :                 event.Add(newhit);
     963             :                 hit10 = newhit;
     964           0 :         }
     965             : 
     966           0 :         AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(
     967           0 :                         track.fId, sign, track.fPx, track.fPy, track.fPz, track.fChi2,
     968             :                         trigrec, hit7, hit8, hit9, hit10
     969             :                 );
     970           0 :         event.Add(tr);
     971           0 :         return tr;
     972           0 : }
     973             : 
     974             : 
     975             : AliHLTMUONTrack* AliHLTMUONRootifierComponent::AddTrack(
     976             :                 AliHLTMUONEvent& event, const AliHLTMUONTrackStruct& track
     977             :         )
     978             : {
     979             :         // Converts the track structure and adds it to the event object.
     980             :         
     981           0 :         AliHLTMUONParticleSign sign;
     982           0 :         bool hitset[16];
     983           0 :         AliHLTMUONUtils::UnpackTrackFlags(
     984           0 :                         track.fFlags, sign, hitset
     985             :                 );
     986             :         
     987             :         // Try find the trigger record in 'event'.
     988             :         const AliHLTMUONTriggerRecord* trigrec = NULL;
     989           0 :         for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++)
     990             :         {
     991           0 :                 if (event.Array()[k]->IsA() != AliHLTMUONTriggerRecord::Class())
     992             :                         continue;
     993             :                 const AliHLTMUONTriggerRecord* tk =
     994           0 :                         static_cast<const AliHLTMUONTriggerRecord*>(event.Array()[k]);
     995           0 :                 if (tk->Id() == track.fTrigRec)
     996             :                 {
     997             :                         trigrec = tk;
     998           0 :                         break;
     999             :                 }
    1000           0 :         }
    1001             :         
    1002             :         // Now try find the hits in 'event'.
    1003             :         // If they cannot be found then create new ones.
    1004           0 :         const AliHLTMUONRecHit* hits[16];
    1005           0 :         for (int i = 0; i < 16; ++i) hits[i] = NULL;
    1006           0 :         for (Int_t k = 0; k < event.Array().GetEntriesFast(); k++)
    1007             :         {
    1008           0 :                 if (event.Array()[k]->IsA() != AliHLTMUONRecHit::Class())
    1009             :                         continue;
    1010             :                 const AliHLTMUONRecHit* h =
    1011           0 :                         static_cast<const AliHLTMUONRecHit*>(event.Array()[k]);
    1012           0 :                 for (int i = 0; i < 16; ++i)
    1013             :                 {
    1014           0 :                         if (hitset[i] and h->X() == track.fHit[i].fX and h->Y() == track.fHit[i].fY
    1015           0 :                             and h->Z() == track.fHit[i].fZ)
    1016             :                         {
    1017           0 :                                 hits[i] = h;
    1018           0 :                         }
    1019             :                 }
    1020           0 :         }
    1021             :         AliHLTMUONRecHit* newhit;
    1022           0 :         for (int i = 0; i < 16; ++i)
    1023             :         {
    1024           0 :                 if (hitset[i] and hits[i] == NULL)
    1025             :                 {
    1026           0 :                         newhit = new AliHLTMUONRecHit(track.fHit[i].fX, track.fHit[i].fY, track.fHit[i].fZ);
    1027           0 :                         event.Add(newhit);
    1028           0 :                         hits[i] = newhit;
    1029           0 :                 }
    1030             :         }
    1031             : 
    1032           0 :         AliHLTMUONTrack* tr = new AliHLTMUONTrack(
    1033           0 :                         track.fId, sign, track.fPx, track.fPy, track.fPz,
    1034           0 :                         track.fInverseBendingMomentum, track.fThetaX, track.fThetaY,
    1035           0 :                         track.fX, track.fY, track.fZ, track.fChi2,
    1036           0 :                         trigrec, hits
    1037             :                 );
    1038           0 :         event.Add(tr);
    1039           0 :         return tr;
    1040           0 : }

Generated by: LCOV version 1.11