LCOV - code coverage report
Current view: top level - HLT/MUON/OfflineInterface - AliHLTMUONTriggerRecordsSource.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 14 257 5.4 %
Date: 2016-06-14 17:26:59 Functions: 7 16 43.8 %

          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   AliHLTMUONTriggerRecordsSource.cxx
      21             :  * @author Artur Szostak <artursz@iafrica.com>
      22             :  * @date   16 Sep 2007
      23             :  * @brief  Implementation of the AliHLTMUONTriggerRecordsSource component.
      24             :  */
      25             : 
      26             : #include "AliHLTMUONTriggerRecordsSource.h"
      27             : #include "AliHLTMUONConstants.h"
      28             : #include "AliHLTMUONUtils.h"
      29             : #include "AliHLTMUONDataBlockWriter.h"
      30             : #include "AliHLTMUONCalculations.h"
      31             : #include "AliMUONMCDataInterface.h"
      32             : #include "AliMUONDataInterface.h"
      33             : #include "AliMUONHit.h"
      34             : #include "AliMUONRawCluster.h"
      35             : #include "AliMUONConstants.h"
      36             : #include "AliMUONVClusterStore.h"
      37             : #include "AliMUONVHitStore.h"
      38             : #include "AliMpCDB.h"
      39             : #include "AliMpDDLStore.h"
      40             : #include "AliMpLocalBoard.h"
      41             : #include "AliMpTriggerCrate.h"
      42             : #include "AliMpDEManager.h"
      43             : #include "AliMpDetElement.h"
      44             : #include "AliLog.h"
      45             : #include "TClonesArray.h"
      46             : #include <cstdlib>
      47             : #include <cstdio>
      48             : #include <cerrno>
      49             : #include <cassert>
      50             : #include <new>
      51             : 
      52             : namespace
      53             : {
      54             :         
      55             :         //TODO: The following method should be in MUON/mapping
      56             :         Int_t FindDDLOfDetElement(Int_t detElemId)
      57             :         {
      58             :                 // Find what the DDL ID number is for a detector element from
      59             :                 // trigger chambers 11 to 14. We first have to find the local
      60             :                 // board associated with the detector element and then we can
      61             :                 // associate that local board to the trigger crate which has
      62             :                 // the DDL number specified.
      63           0 :                 AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
      64           0 :                 if (ddlStore == NULL) return -1;
      65             :                 Int_t ddl = -1, boardIndex = 1;
      66           0 :                 do
      67             :                 {
      68           0 :                         AliMpLocalBoard* board = ddlStore->GetLocalBoard(boardIndex++);
      69           0 :                         if (board == NULL) break;
      70           0 :                         if (board->HasDEId(detElemId))
      71             :                         {
      72           0 :                                 AliMpTriggerCrate* crate = ddlStore->GetTriggerCrate(board->GetCrate());
      73           0 :                                 if (crate == NULL) continue;
      74           0 :                                 ddl = crate->GetDdlId();
      75           0 :                                 break;
      76             :                         }
      77           0 :                 }
      78           0 :                 while (ddl == -1);
      79             :                 return ddl;
      80           0 :         }
      81             : 
      82             : }
      83             : 
      84             : 
      85           6 : ClassImp(AliHLTMUONTriggerRecordsSource);
      86             : 
      87             : 
      88             : AliHLTMUONTriggerRecordsSource::AliHLTMUONTriggerRecordsSource() :
      89           3 :         AliHLTOfflineDataSource(),
      90           3 :         fMCDataInterface(NULL),
      91           3 :         fDataInterface(NULL),
      92           3 :         fBuildFromHits(false),
      93           3 :         fSelection(kWholePlane),
      94           3 :         fCurrentEventIndex(0)
      95          15 : {
      96             :         ///
      97             :         /// Default constructor.
      98             :         ///
      99           6 : }
     100             : 
     101             : 
     102           0 : AliHLTMUONTriggerRecordsSource::~AliHLTMUONTriggerRecordsSource()
     103          18 : {
     104             :         ///
     105             :         /// Default destructor.
     106             :         ///
     107             :         
     108           3 :         if (fMCDataInterface != NULL) delete fMCDataInterface;
     109           3 :         if (fDataInterface != NULL) delete fDataInterface;
     110           9 : }
     111             : 
     112             : 
     113             : int AliHLTMUONTriggerRecordsSource::DoInit(int argc, const char** argv)
     114             : {
     115             :         ///
     116             :         /// Inherited from AliHLTComponent.
     117             :         /// Parses the command line parameters and initialises the component.
     118             :         ///
     119             :         
     120           0 :         HLTInfo("Initialising dHLT trigger record source component.");
     121             :         
     122           0 :         if (fMCDataInterface != NULL)
     123             :         {
     124           0 :                 delete fMCDataInterface;
     125           0 :                 fMCDataInterface = NULL;
     126           0 :         }
     127           0 :         if (fDataInterface != NULL)
     128             :         {
     129           0 :                 delete fDataInterface;
     130           0 :                 fDataInterface = NULL;
     131           0 :         }
     132             :         
     133             :         // Parse the command line arguments:
     134             :         bool hitdata = false;
     135             :         bool simdata = false;
     136             :         bool recdata = false;
     137           0 :         fCurrentEventIndex = 0;
     138             :         bool firstEventSet = false;
     139             :         bool eventNumLitSet = false;
     140             :         
     141           0 :         for (int i = 0; i < argc; i++)
     142             :         {
     143           0 :                 if (strcmp(argv[i], "-hitdata") == 0)
     144             :                 {
     145             :                         hitdata = true;
     146           0 :                 }
     147           0 :                 else if (strcmp(argv[i], "-simdata") == 0)
     148             :                 {
     149             :                         simdata = true;
     150           0 :                 }
     151           0 :                 else if (strcmp(argv[i], "-recdata") == 0)
     152             :                 {
     153             :                         recdata = true;
     154           0 :                 }
     155           0 :                 else if (strcmp(argv[i], "-plane") == 0)
     156             :                 {
     157           0 :                         i++;
     158           0 :                         if (i >= argc)
     159             :                         {
     160           0 :                                 Logging(kHLTLogError,
     161             :                                         "AliHLTMUONTriggerRecordsSource::DoInit",
     162             :                                         "Missing parameter",
     163             :                                         "Expected one of 'left', 'right' or 'all' after '-plane'."
     164             :                                 );
     165           0 :                                 return -EINVAL;
     166             :                         }
     167           0 :                         if (strcmp(argv[i], "left") == 0)
     168           0 :                                 fSelection = kLeftPlane;
     169           0 :                         else if (strcmp(argv[i], "right") == 0)
     170           0 :                                 fSelection = kRightPlane;
     171           0 :                         else if (strcmp(argv[i], "all") == 0)
     172           0 :                                 fSelection = kWholePlane;
     173             :                         else
     174             :                         {
     175           0 :                                 Logging(kHLTLogError,
     176             :                                         "AliHLTMUONTriggerRecordsSource::DoInit",
     177             :                                         "Invalid parameter",
     178             :                                         "The parameter '%s' is invalid and must be one of 'left',"
     179             :                                           " 'right' or 'all'.",
     180           0 :                                         argv[i]
     181             :                                 );
     182           0 :                                 return -EINVAL;
     183             :                         }
     184             :                 }
     185           0 :                 else if (strcmp(argv[i], "-firstevent") == 0)
     186             :                 {
     187           0 :                         if (eventNumLitSet)
     188             :                         {
     189           0 :                                 HLTWarning("The -firstevent flag is overridden by a"
     190             :                                         " previous use of -event_number_literal."
     191             :                                 );
     192             :                         }
     193           0 :                         i++;
     194           0 :                         if (i >= argc)
     195             :                         {
     196           0 :                                 HLTError("Expected a positive number after -firstevent.");
     197           0 :                                 return -EINVAL;
     198             :                         }
     199           0 :                         char* end = NULL;
     200           0 :                         long num = strtol(argv[i], &end, 0);
     201           0 :                         if ((end != NULL and *end != '\0') or num < 0) // Check if the conversion is OK.
     202             :                         {
     203           0 :                                 HLTError(Form(
     204             :                                         "Expected a positive number after -firstevent"
     205             :                                         " but got: %s", argv[i]
     206             :                                 ));
     207           0 :                                 return -EINVAL;
     208             :                         }
     209           0 :                         fCurrentEventIndex = Int_t(num);
     210             :                         firstEventSet = true;
     211           0 :                 }
     212           0 :                 else if (strcmp(argv[i], "-event_number_literal") == 0)
     213             :                 {
     214           0 :                         if (firstEventSet)
     215             :                         {
     216           0 :                                 HLTWarning("The -event_number_literal option will"
     217             :                                         " override -firstevent."
     218             :                                 );
     219             :                         }
     220           0 :                         fCurrentEventIndex = -1;
     221             :                         eventNumLitSet = true;
     222             :                 }
     223             :                 else
     224             :                 {
     225           0 :                         Logging(kHLTLogError,
     226             :                                 "AliHLTMUONTriggerRecordsSource::DoInit",
     227             :                                 "Unknown argument",
     228             :                                 "The argument '%s' is invalid.",
     229           0 :                                 argv[i]
     230             :                         );
     231           0 :                         return -EINVAL;
     232             :                 }
     233             :         }
     234             : 
     235             :         // Check that one and only one of the the -hitdata, -simdata or
     236             :         // -recdata parameters was specified on the command line.
     237           0 :         if ((not hitdata and not simdata and not recdata) or
     238           0 :             (not hitdata and simdata and recdata) or
     239           0 :             (hitdata and not simdata and recdata) or
     240           0 :             (hitdata and simdata and not recdata) or
     241           0 :             (hitdata and simdata and recdata)
     242             :            )
     243             :         {
     244           0 :                 Logging(kHLTLogError,
     245             :                         "AliHLTMUONTriggerRecordsSource::DoInit",
     246             :                         "Missing arguments",
     247             :                         "Must have one and only one of -hitdata, -simdata or -recdata specified."
     248             :                 );
     249           0 :                 return -EINVAL;
     250             :         }
     251             :         
     252             :         // Must load the mapping data for AliMpTriggerCrate::GetDdlId()  //TODO AliMpTriggerCrate => AliMpDetElement
     253             :         // to return useful information later on.
     254           0 :         AliMpCDB::LoadDDLStore();
     255             :         
     256             :         // Now we can initialise the data interface objects and loaders.
     257           0 :         fBuildFromHits = hitdata;
     258           0 :         if (hitdata or simdata)
     259             :         {
     260           0 :                 const char* message = fBuildFromHits ?
     261             :                         "Loading simulated GEANT hits with AliMUONMCDataInterface."
     262             :                         : "Loading simulated local trigger objects with AliMUONMCDataInterface.";
     263             :                                 
     264           0 :                 Logging(kHLTLogDebug, "AliHLTMUONTriggerRecordsSource::DoInit",
     265             :                         "Data interface", message
     266             :                 );
     267             :                 
     268             :                 try
     269             :                 {
     270           0 :                         fMCDataInterface = new AliMUONMCDataInterface("galice.root");
     271           0 :                 }
     272             :                 catch (const std::bad_alloc&)
     273             :                 {
     274           0 :                         Logging(kHLTLogError,
     275             :                                 "AliHLTMUONTriggerRecordsSource::DoInit",
     276             :                                 "Out of memory",
     277             :                                 "Not enough memory to allocate AliMUONMCDataInterface."
     278             :                         );
     279             :                         return -ENOMEM;
     280           0 :                 }
     281           0 :         }
     282           0 :         else if (recdata)
     283             :         {
     284           0 :                 Logging(kHLTLogDebug,
     285             :                         "AliHLTMUONTriggerRecordsSource::DoInit",
     286             :                         "Data interface",
     287             :                         "Loading reconstructed local trigger objects with AliMUONDataInterface."
     288             :                 );
     289             :                 
     290             :                 try
     291             :                 {
     292           0 :                         fDataInterface = new AliMUONDataInterface("galice.root");
     293           0 :                 }
     294             :                 catch (const std::bad_alloc&)
     295             :                 {
     296           0 :                         Logging(kHLTLogError,
     297             :                                 "AliHLTMUONTriggerRecordsSource::DoInit",
     298             :                                 "Out of memory",
     299             :                                 "Not enough memory to allocate AliMUONDataInterface."
     300             :                         );
     301             :                         return -ENOMEM;
     302           0 :                 }
     303           0 :         }
     304             :         
     305             :         // Check that the fCurrentEventIndex number falls within the correct range.
     306             :         UInt_t maxevent = 0;
     307           0 :         if (fMCDataInterface != NULL)
     308           0 :                 maxevent = UInt_t(fMCDataInterface->NumberOfEvents());
     309           0 :         else if (fDataInterface != NULL)
     310           0 :                 maxevent = UInt_t(fDataInterface->NumberOfEvents());
     311           0 :         if (fCurrentEventIndex != -1 and UInt_t(fCurrentEventIndex) >= maxevent and maxevent != 0)
     312             :         {
     313           0 :                 fCurrentEventIndex = 0;
     314           0 :                 HLTWarning(Form("The selected first event number (%d) was larger than"
     315             :                         " the available number of events (%d). Resetting the event"
     316             :                         " counter to zero.", fCurrentEventIndex, maxevent
     317             :                 ));
     318             :         }
     319             :         
     320             :         return 0;
     321           0 : }
     322             : 
     323             : 
     324             : int AliHLTMUONTriggerRecordsSource::DoDeinit()
     325             : {
     326             :         ///
     327             :         /// Inherited from AliHLTComponent. Performs a cleanup of the component.
     328             :         ///
     329             :         
     330           0 :         HLTInfo("Deinitialising dHLT trigger record source component.");
     331             :         
     332           0 :         if (fMCDataInterface != NULL)
     333             :         {
     334           0 :                 delete fMCDataInterface;
     335           0 :                 fMCDataInterface = NULL;
     336           0 :         }
     337           0 :         if (fDataInterface != NULL)
     338             :         {
     339           0 :                 delete fDataInterface;
     340           0 :                 fDataInterface = NULL;
     341           0 :         }
     342           0 :         return 0;
     343             : }
     344             : 
     345             : 
     346             : const char* AliHLTMUONTriggerRecordsSource::GetComponentID()
     347             : {
     348             :         ///
     349             :         /// Inherited from AliHLTComponent. Returns the component ID.
     350             :         ///
     351             :         
     352         246 :         return AliHLTMUONConstants::TriggerRecordsSourceId();
     353             : }
     354             : 
     355             : 
     356             : AliHLTComponentDataType AliHLTMUONTriggerRecordsSource::GetOutputDataType()
     357             : {
     358             :         ///
     359             :         /// Inherited from AliHLTComponent. Returns the output data type.
     360             :         ///
     361             :         
     362           0 :         return AliHLTMUONConstants::TriggerRecordsBlockDataType();
     363             : }
     364             : 
     365             : 
     366             : void AliHLTMUONTriggerRecordsSource::GetOutputDataSize(
     367             :                 unsigned long& constBase, double& inputMultiplier
     368             :         )
     369             : {
     370             :         ///
     371             :         /// Inherited from AliHLTComponent. Returns an estimate of the expected output data size.
     372             :         ///
     373             :         
     374           0 :         constBase = sizeof(AliHLTMUONTriggerRecordsBlockStruct) +
     375           0 :                 sizeof(AliHLTMUONTriggerRecordStruct) * AliMUONConstants::NTriggerCircuit();
     376           0 :         inputMultiplier = 0;
     377           0 : }
     378             : 
     379             : 
     380             : AliHLTComponent* AliHLTMUONTriggerRecordsSource::Spawn()
     381             : {
     382             :         ///
     383             :         /// Inherited from AliHLTComponent. Creates a new object instance.
     384             :         ///
     385             :         
     386           0 :         return new AliHLTMUONTriggerRecordsSource();
     387           0 : }
     388             : 
     389             : 
     390             : int AliHLTMUONTriggerRecordsSource::GetEvent(
     391             :                 const AliHLTComponentEventData& evtData,
     392             :                 AliHLTComponentTriggerData& /*trigData*/,
     393             :                 AliHLTUInt8_t* outputPtr, 
     394             :                 AliHLTUInt32_t& size,
     395             :                 AliHLTComponentBlockDataList& outputBlocks
     396             :         )
     397             : {
     398             :         ///
     399             :         /// Inherited from AliHLTOfflineDataSource. Creates new event data blocks.
     400             :         ///
     401             :         
     402           0 :         assert( fMCDataInterface != NULL or fDataInterface != NULL );
     403             :         
     404           0 :         if (not IsDataEvent()) return 0;  // ignore non data events.
     405             : 
     406             :         AliHLTInt32_t trigRecId = 0;
     407             : 
     408             :         // Check the size of the event descriptor structure.
     409           0 :         if (evtData.fStructSize < sizeof(AliHLTComponentEventData))
     410             :         {
     411           0 :                 Logging(kHLTLogError,
     412             :                         "AliHLTMUONTriggerRecordsSource::GetEvent",
     413             :                         "Invalid event descriptor",
     414             :                         "The event descriptor (AliHLTComponentEventData) size is"
     415             :                           " smaller than expected. It claims to be %d bytes, but"
     416             :                           " we expect it to be %d bytes.",
     417             :                         evtData.fStructSize,
     418             :                         sizeof(AliHLTComponentEventData)
     419             :                 );
     420           0 :                 size = 0; // Important to tell framework that nothing was generated.
     421           0 :                 return -EINVAL;
     422             :         }
     423             :         
     424             :         // Use the fEventID as the event number to load if fCurrentEventIndex == -1,
     425             :         // check it and load that event with the runloader.
     426             :         // If fCurrentEventIndex is a positive number then use it instead and
     427             :         // increment it.
     428           0 :         UInt_t eventnumber = UInt_t(evtData.fEventID);
     429             :         UInt_t maxevent = 0;
     430           0 :         if (fMCDataInterface != NULL)
     431           0 :                 maxevent = UInt_t(fMCDataInterface->NumberOfEvents());
     432           0 :         else if (fDataInterface != NULL)
     433           0 :                 maxevent = UInt_t(fDataInterface->NumberOfEvents());
     434           0 :         if (fCurrentEventIndex != -1)
     435             :         {
     436             :                 eventnumber = UInt_t(fCurrentEventIndex);
     437           0 :                 fCurrentEventIndex++;
     438           0 :                 if (UInt_t(fCurrentEventIndex) >= maxevent)
     439           0 :                         fCurrentEventIndex = 0;
     440             :         }
     441           0 :         if ( eventnumber >= maxevent )
     442             :         {
     443           0 :                 Logging(kHLTLogError,
     444             :                         "AliHLTMUONTriggerRecordsSource::GetEvent",
     445             :                         "Bad event ID",
     446             :                         "The event number (%d) is larger than the available number"
     447             :                           " of events on file (%d).",
     448             :                         eventnumber,
     449             :                         maxevent
     450             :                 );
     451           0 :                 size = 0; // Important to tell framework that nothing was generated.
     452           0 :                 return -EINVAL;
     453             :         }
     454             :         
     455             :         // Create and initialise a new data block.
     456           0 :         AliHLTMUONTriggerRecordsBlockWriter block(outputPtr, size);
     457           0 :         if (not block.InitCommonHeader())
     458             :         {
     459           0 :                 Logging(kHLTLogError,
     460             :                         "AliHLTMUONTriggerRecordsSource::GetEvent",
     461             :                         "Buffer too small",
     462             :                         "There is not enough buffer space to create a new data block."
     463             :                           " We require at least %d bytes but the buffer is only %d bytes.",
     464             :                         sizeof(AliHLTMUONTriggerRecordsBlockWriter::HeaderType),
     465           0 :                         block.BufferSize()
     466             :                 );
     467           0 :                 size = 0; // Important to tell framework that nothing was generated.
     468           0 :                 return -ENOBUFS;
     469             :         }
     470             :         
     471             :         // Initialise the DDL list containing the DDLs which contributed to the
     472             :         // data block. These are required to create the specification word later.
     473           0 :         bool ddlList[22];
     474           0 :         for (Int_t i = 0; i < 22; i++)
     475           0 :                 ddlList[i] = false;
     476             :         
     477           0 :         if (fMCDataInterface != NULL and fBuildFromHits)
     478             :         {
     479           0 :                 Logging(kHLTLogDebug,
     480             :                         "AliHLTMUONTriggerRecordsSource::GetEvent",
     481             :                         "Filling triggers",
     482             :                         "Filling data block with trigger records from GEANT hits for event %d.",
     483             :                         eventnumber
     484             :                 );
     485             :                 
     486             :                 // Loop over all tracks, extract the hits from chambers 11 to 14 and
     487             :                 // create trigger records from them to write to the data block.
     488           0 :                 Int_t ntracks = fMCDataInterface->NumberOfTracks(eventnumber);
     489           0 :                 for (Int_t i = 0; i < ntracks; ++i)
     490             :                 {
     491             :                         AliMUONHit* hit11 = NULL;
     492             :                         AliMUONHit* hit12 = NULL;
     493             :                         AliMUONHit* hit13 = NULL;
     494             :                         AliMUONHit* hit14 = NULL;
     495             :                         Int_t ddl11 = -1;
     496             :                         Int_t ddl12 = -1;
     497             :                         Int_t ddl13 = -1;
     498             :                         Int_t ddl14 = -1;
     499             :                         
     500           0 :                         AliMUONVHitStore* hitStore = fMCDataInterface->HitStore(eventnumber,i);
     501             :                         AliMUONHit* hit;
     502           0 :                         TIter next(hitStore->CreateIterator());
     503           0 :                         while ( ( hit = static_cast<AliMUONHit*>(next()) ) )
     504             :                         {
     505             :                                 // Select only hits on trigger chambers.
     506           0 :                                 if (hit->Chamber() <= AliMUONConstants::NTrackingCh()) continue;
     507             :                                 
     508             :                                 // Only select hits from the given part of the plane
     509           0 :                                 if (fSelection == kLeftPlane and not (hit->Xref() < 0)) continue;
     510           0 :                                 if (fSelection == kRightPlane and not (hit->Xref() >= 0)) continue;
     511             :                                 
     512             :                                 // Workout which DDL this hit should be readout of.
     513           0 :                                 Int_t ddl = FindDDLOfDetElement(hit->DetElemId());
     514           0 :                                 if (not (0 <= ddl and ddl < 22))
     515             :                                 {
     516             :                                         ddl = -1;
     517           0 :                                         Logging(kHLTLogError,
     518             :                                                 "AliHLTMUONTriggerRecordsSource::GetEvent",
     519             :                                                 "No DDL ID",
     520             :                                                 "Could not find the DDL ID from which readout would take place."
     521             :                                         );
     522             :                                 }
     523             :                                 
     524           0 :                                 switch (hit->Chamber())
     525             :                                 {
     526           0 :                                 case 11: hit11 = hit; ddl11 = ddl; break;
     527           0 :                                 case 12: hit12 = hit; ddl12 = ddl; break;
     528           0 :                                 case 13: hit13 = hit; ddl13 = ddl; break;
     529           0 :                                 case 14: hit14 = hit; ddl14 = ddl; break;
     530             :                                 default: break;
     531             :                                 }
     532             :                         }
     533             :                         
     534             :                         // Check that there are at least 3 of 4 hits on the trigger chambers.
     535             :                         Int_t hitCount = 0;
     536           0 :                         if (hit11 != NULL) hitCount++;
     537           0 :                         if (hit12 != NULL) hitCount++;
     538           0 :                         if (hit13 != NULL) hitCount++;
     539           0 :                         if (hit14 != NULL) hitCount++;
     540           0 :                         if (hitCount < 3) continue;
     541             :                                 
     542           0 :                         AliHLTMUONTriggerRecordStruct* trigRec = block.AddEntry();
     543           0 :                         if (trigRec == NULL)
     544             :                         {
     545           0 :                                 Logging(kHLTLogError,
     546             :                                         "AliHLTMUONTriggerRecordsSource::GetEvent",
     547             :                                         "Buffer overflow",
     548             :                                         "There is not enough buffer space to add more trigger records."
     549             :                                           " We overflowed the buffer which is only %d bytes.",
     550           0 :                                         block.BufferSize()
     551             :                                 );
     552           0 :                                 size = 0; // Important to tell framework that nothing was generated.
     553           0 :                                 return -ENOBUFS;
     554             :                         }
     555             :                         
     556             :                         // Fill the new trigger record with the hit information.
     557           0 :                         bool hitset[4] = {false, false, false, false};
     558             :                         AliHLTFloat32_t x1 = 0, y1 = 0, y2 = 0, z1 = 0, z2 = 0;
     559           0 :                         if (hit11 != NULL)
     560             :                         {
     561           0 :                                 trigRec->fHit[0].fX = hit11->Xref();
     562           0 :                                 trigRec->fHit[0].fY = hit11->Yref();
     563           0 :                                 trigRec->fHit[0].fZ = hit11->Zref();
     564           0 :                                 hitset[0] = true;
     565           0 :                                 x1 = hit11->Xref();
     566           0 :                                 y1 = hit11->Yref();
     567           0 :                                 z1 = hit11->Zref();
     568           0 :                         }
     569           0 :                         if (hit12 != NULL)
     570             :                         {
     571           0 :                                 trigRec->fHit[1].fX = hit12->Xref();
     572           0 :                                 trigRec->fHit[1].fY = hit12->Yref();
     573           0 :                                 trigRec->fHit[1].fZ = hit12->Zref();
     574           0 :                                 hitset[1] = true;
     575           0 :                                 x1 = hit12->Xref();
     576           0 :                                 y1 = hit12->Yref();
     577           0 :                                 z1 = hit12->Zref();
     578           0 :                         }
     579           0 :                         if (hit13 != NULL)
     580             :                         {
     581           0 :                                 trigRec->fHit[2].fX = hit13->Xref();
     582           0 :                                 trigRec->fHit[2].fY = hit13->Yref();
     583           0 :                                 trigRec->fHit[2].fZ = hit13->Zref();
     584           0 :                                 hitset[2] = true;
     585           0 :                                 y2 = hit13->Yref();
     586           0 :                                 z2 = hit13->Zref();
     587           0 :                         }
     588           0 :                         if (hit14 != NULL)
     589             :                         {
     590           0 :                                 trigRec->fHit[3].fX = hit14->Xref();
     591           0 :                                 trigRec->fHit[3].fY = hit14->Yref();
     592           0 :                                 trigRec->fHit[3].fZ = hit14->Zref();
     593           0 :                                 hitset[3] = true;
     594           0 :                                 y2 = hit14->Yref();
     595           0 :                                 z2 = hit14->Zref();
     596           0 :                         }
     597             :                         
     598           0 :                         bool calculated = AliHLTMUONCalculations::ComputeMomentum(x1, y1, y2, z1, z2);
     599           0 :                         if (not calculated)
     600           0 :                                 Logging(kHLTLogDebug,
     601             :                                         "AliHLTMUONTriggerRecordsSource::GetEvent",
     602             :                                         "Calculation failure",
     603             :                                         "Something went wrong when calculating the momentum from"
     604             :                                           " x1 = %f, y1 = %f, y2 = %f, z1 = %f, z2 = %f.",
     605           0 :                                         x1, y1, y2, z1, z2
     606             :                                 );
     607             :                         
     608           0 :                         trigRec->fId = trigRecId++;
     609           0 :                         trigRec->fFlags = AliHLTMUONUtils::PackTriggerRecordFlags(
     610           0 :                                         AliHLTMUONCalculations::Sign(), hitset
     611             :                                 );
     612           0 :                         trigRec->fPx = AliHLTMUONCalculations::Px();
     613           0 :                         trigRec->fPy = AliHLTMUONCalculations::Py();
     614           0 :                         trigRec->fPz = AliHLTMUONCalculations::Pz();
     615             :                         
     616             :                         // Mark the DDLs over which this trigger record would be readout.
     617           0 :                         if (ddl11 != -1) ddlList[ddl11] = true;
     618           0 :                         if (ddl12 != -1) ddlList[ddl12] = true;
     619           0 :                         if (ddl13 != -1) ddlList[ddl13] = true;
     620           0 :                         if (ddl14 != -1) ddlList[ddl14] = true;
     621           0 :                 }
     622           0 :         }
     623           0 :         else if (fMCDataInterface != NULL and not fBuildFromHits)
     624             :         {
     625           0 :                 Logging(kHLTLogDebug,
     626             :                         "AliHLTMUONTriggerRecordsSource::GetEvent",
     627             :                         "Filling triggers",
     628             :                         "Filling data block with simulated local triggers for event %d.",
     629             :                         eventnumber
     630             :                 );
     631             :                 
     632           0 :                 AliFatal("Sorry, -simdata option not yet implemented!");
     633             :                 // TODO
     634           0 :         }
     635           0 :         else if (fDataInterface != NULL)
     636             :         {
     637           0 :                 Logging(kHLTLogDebug,
     638             :                         "AliHLTMUONTriggerRecordsSource::GetEvent",
     639             :                         "Filling triggers",
     640             :                         "Filling data block with reconstructed local triggers for event %d.",
     641             :                         eventnumber
     642             :                 );
     643             :                 // TODO
     644           0 :                 AliFatal("Sorry, -recdata option not yet implemented!");
     645             :         }
     646             :         else
     647             :         {
     648           0 :                 Logging(kHLTLogError,
     649             :                         "AliHLTMUONTriggerRecordsSource::GetEvent",
     650             :                         "Missing data interface",
     651             :                         "Neither AliMUONDataInterface nor AliMUONMCDataInterface were created."
     652             :                 );
     653           0 :                 size = 0; // Important to tell framework that nothing was generated.
     654           0 :                 return -EFAULT;
     655             :         }
     656             :         
     657           0 :         AliHLTComponentBlockData bd;
     658           0 :         FillBlockData(bd);
     659           0 :         bd.fPtr = outputPtr;
     660           0 :         bd.fOffset = 0;
     661           0 :         bd.fSize = block.BytesUsed();
     662           0 :         bd.fDataType = AliHLTMUONConstants::TriggerRecordsBlockDataType();
     663           0 :         bd.fSpecification = AliHLTMUONUtils::PackSpecBits(ddlList);
     664           0 :         outputBlocks.push_back(bd);
     665           0 :         size = block.BytesUsed();
     666             : 
     667             :         return 0;
     668           0 : }

Generated by: LCOV version 1.11