/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project *
+ * This file is property of and copyright by the ALICE HLT Project *
* All rights reserved. *
* *
* Primary Authors: *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
+ * about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
namespace
{
- // The global object used for automatic component registration.
- // Note DO NOT use this component for calculation!
- AliHLTMUONTriggerRecordsSource gAliHLTMUONTriggerRecordsSource;
//TODO: The following method should be in MUON/mapping
Int_t FindDDLOfDetElement(Int_t detElemId)
fMCDataInterface(NULL),
fDataInterface(NULL),
fBuildFromHits(false),
- fSelection(kWholePlane)
+ fSelection(kWholePlane),
+ fCurrentEventIndex(0)
{
+ ///
+ /// Default constructor.
+ ///
}
AliHLTMUONTriggerRecordsSource::~AliHLTMUONTriggerRecordsSource()
{
+ ///
+ /// Default destructor.
+ ///
+
assert( fMCDataInterface == NULL );
assert( fDataInterface == NULL );
}
int AliHLTMUONTriggerRecordsSource::DoInit(int argc, const char** argv)
{
+ ///
+ /// Inherited from AliHLTComponent.
+ /// Parses the command line parameters and initialises the component.
+ ///
+
assert( fMCDataInterface == NULL );
assert( fDataInterface == NULL );
bool hitdata = false;
bool simdata = false;
bool recdata = false;
+ fCurrentEventIndex = 0;
+ bool firstEventSet = false;
+ bool eventNumLitSet = false;
for (int i = 0; i < argc; i++)
{
"Missing parameter",
"Expected one of 'left', 'right' or 'all' after '-plane'."
);
- return EINVAL;
+ return -EINVAL;
}
if (strcmp(argv[i], "left") == 0)
fSelection = kLeftPlane;
" 'right' or 'all'.",
argv[i]
);
- return EINVAL;
+ return -EINVAL;
+ }
+ }
+ else if (strcmp(argv[i], "-firstevent") == 0)
+ {
+ if (eventNumLitSet)
+ {
+ HLTWarning("The -firstevent flag is overridden by a"
+ " previous use of -event_number_literal."
+ );
+ }
+ i++;
+ if (i >= argc)
+ {
+ HLTError("Expected a positive number after -firstevent.");
+ return -EINVAL;
+ }
+ char* end = "";
+ long num = strtol(argv[i], &end, 0);
+ if (*end != '\0' or num < 0) // Check if the conversion is OK.
+ {
+ HLTError(Form(
+ "Expected a positive number after -firstevent"
+ " but got: %s", argv[i]
+ ));
+ return -EINVAL;
}
+ fCurrentEventIndex = Int_t(num);
+ firstEventSet = true;
+ }
+ else if (strcmp(argv[i], "-event_number_literal") == 0)
+ {
+ if (firstEventSet)
+ {
+ HLTWarning("The -event_number_literal option will"
+ " override -firstevent."
+ );
+ }
+ fCurrentEventIndex = -1;
+ eventNumLitSet = true;
}
else
{
"The argument '%s' is invalid.",
argv[i]
);
- return EINVAL;
+ return -EINVAL;
}
}
"Missing arguments",
"Must have one and only one of -hitdata, -simdata or -recdata specified."
);
- return EINVAL;
+ return -EINVAL;
}
// Must load the mapping data for AliMpTriggerCrate::GetDdlId() //TODO AliMpTriggerCrate => AliMpDetElement
"Out of memory",
"Not enough memory to allocate AliMUONMCDataInterface."
);
- return ENOMEM;
+ return -ENOMEM;
}
}
else if (recdata)
"Out of memory",
"Not enough memory to allocate AliMUONDataInterface."
);
- return ENOMEM;
+ return -ENOMEM;
}
}
+ // Check that the fCurrentEventIndex number falls within the correct range.
+ UInt_t maxevent = 0;
+ if (fMCDataInterface != NULL)
+ maxevent = UInt_t(fMCDataInterface->NumberOfEvents());
+ else if (fDataInterface != NULL)
+ maxevent = UInt_t(fDataInterface->NumberOfEvents());
+ if (fCurrentEventIndex != -1 and UInt_t(fCurrentEventIndex) >= maxevent and maxevent != 0)
+ {
+ fCurrentEventIndex = 0;
+ HLTWarning(Form("The selected first event number (%d) was larger than"
+ " the available number of events (%d). Resetting the event"
+ " counter to zero.", fCurrentEventIndex, maxevent
+ ));
+ }
+
return 0;
}
int AliHLTMUONTriggerRecordsSource::DoDeinit()
{
+ ///
+ /// Inherited from AliHLTComponent. Performs a cleanup of the component.
+ ///
+
if (fMCDataInterface != NULL)
{
delete fMCDataInterface;
const char* AliHLTMUONTriggerRecordsSource::GetComponentID()
{
+ ///
+ /// Inherited from AliHLTComponent. Returns the component ID.
+ ///
+
return AliHLTMUONConstants::TriggerRecordsSourceId();
}
AliHLTComponentDataType AliHLTMUONTriggerRecordsSource::GetOutputDataType()
{
+ ///
+ /// Inherited from AliHLTComponent. Returns the output data type.
+ ///
+
return AliHLTMUONConstants::TriggerRecordsBlockDataType();
}
unsigned long& constBase, double& inputMultiplier
)
{
+ ///
+ /// Inherited from AliHLTComponent. Returns an estimate of the expected output data size.
+ ///
+
constBase = sizeof(AliHLTMUONTriggerRecordsBlockStruct) +
sizeof(AliHLTMUONTriggerRecordStruct) * AliMUONConstants::NTriggerCircuit();
inputMultiplier = 0;
AliHLTComponent* AliHLTMUONTriggerRecordsSource::Spawn()
{
+ ///
+ /// Inherited from AliHLTComponent. Creates a new object instance.
+ ///
+
return new AliHLTMUONTriggerRecordsSource();
}
vector<AliHLTComponentBlockData>& outputBlocks
)
{
+ ///
+ /// Inherited from AliHLTOfflineDataSource. Creates new event data blocks.
+ ///
+
assert( fMCDataInterface != NULL or fDataInterface != NULL );
AliHLTInt32_t trigRecId = 0;
sizeof(AliHLTComponentEventData)
);
size = 0; // Important to tell framework that nothing was generated.
- return EINVAL;
+ return -EINVAL;
}
- // Use the fEventID as the event number to load, check it and load that
- // event with the runloader.
+ // Use the fEventID as the event number to load if fCurrentEventIndex == -1,
+ // check it and load that event with the runloader.
+ // If fCurrentEventIndex is a positive number then us it instead and
+ // increment it.
UInt_t eventnumber = UInt_t(evtData.fEventID);
UInt_t maxevent = fMCDataInterface != NULL ?
UInt_t(fMCDataInterface->NumberOfEvents())
: UInt_t(fDataInterface->NumberOfEvents());
+ if (fCurrentEventIndex != -1)
+ {
+ eventnumber = UInt_t(fCurrentEventIndex);
+ fCurrentEventIndex++;
+ if (UInt_t(fCurrentEventIndex) >= maxevent)
+ fCurrentEventIndex = 0;
+ }
if ( eventnumber >= maxevent )
{
Logging(kHLTLogError,
maxevent
);
size = 0; // Important to tell framework that nothing was generated.
- return EINVAL;
+ return -EINVAL;
}
// Create and initialise a new data block.
block.BufferSize()
);
size = 0; // Important to tell framework that nothing was generated.
- return ENOBUFS;
+ return -ENOBUFS;
}
// Initialise the DDL list containing the DDLs which contributed to the
block.BufferSize()
);
size = 0; // Important to tell framework that nothing was generated.
- return ENOBUFS;
+ return -ENOBUFS;
}
// Fill the new trigger record with the hit information.
"Neither AliMUONDataInterface nor AliMUONMCDataInterface were created."
);
size = 0; // Important to tell framework that nothing was generated.
- return EFAULT;
+ return -EFAULT;
}
AliHLTComponentBlockData bd;