/* $Id$ */
-/**
- * @file AliHLTMUONRecHitsSource.cxx
- * @author Artur Szostak <artursz@iafrica.com>
- * @date
- * @brief Implementation of the AliHLTMUONRecHitsSource component.
- */
+///
+/// @file AliHLTMUONRecHitsSource.cxx
+/// @author Artur Szostak <artursz@iafrica.com>
+/// @date
+/// @brief Implementation of the AliHLTMUONRecHitsSource component.
+///
#include "AliHLTMUONRecHitsSource.h"
#include "AliHLTMUONConstants.h"
#include "AliMUONMCDataInterface.h"
#include "AliMUONDataInterface.h"
#include "AliMUONHit.h"
-#include "AliMUONRawCluster.h"
+#include "AliMUONVCluster.h"
#include "AliMUONConstants.h"
#include "AliMUONVClusterStore.h"
#include "AliMUONVHitStore.h"
#include "mapping/AliMpCDB.h"
#include "mapping/AliMpDEManager.h"
#include "mapping/AliMpDetElement.h"
-#include "TClonesArray.h"
#include <cstdlib>
#include <cstdio>
#include <cerrno>
#include <cassert>
#include <new>
-namespace
-{
- // The global object used for automatic component registration.
- // Note DO NOT use this component for calculation!
- AliHLTMUONRecHitsSource gAliHLTMUONRecHitsSource;
-}
-
-
ClassImp(AliHLTMUONRecHitsSource);
AliHLTMUONRecHitsSource::AliHLTMUONRecHitsSource() :
AliHLTOfflineDataSource(),
- fMCDataInterface(NULL), fDataInterface(NULL),
- fSelection(kWholePlane)
+ fMCDataInterface(NULL),
+ fDataInterface(NULL),
+ fSelection(kWholePlane),
+ fCurrentEventIndex(0)
{
+ ///
+ /// Default constructor.
+ ///
+
for (Int_t i = 0; i < AliMUONConstants::NTrackingCh(); i++)
fServeChamber[i] = false;
}
AliHLTMUONRecHitsSource::~AliHLTMUONRecHitsSource()
{
+ ///
+ /// Default destructor.
+ ///
+
assert( fMCDataInterface == NULL );
assert( fDataInterface == NULL );
}
int AliHLTMUONRecHitsSource::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 simdata = false;
bool recdata = false;
bool chamberWasSet = false;
+ fCurrentEventIndex = 0;
+ bool firstEventSet = false;
+ bool eventNumLitSet = false;
for (int i = 0; i < argc; i++)
{
if (result != 0) return result;
chamberWasSet = true;
}
+ 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
{
Logging(kHLTLogError,
}
}
+ // 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 AliHLTMUONRecHitsSource::DoDeinit()
{
+ ///
+ /// Inherited from AliHLTComponent. Performs a cleanup of the component.
+ ///
+
if (fMCDataInterface != NULL)
{
delete fMCDataInterface;
const char* AliHLTMUONRecHitsSource::GetComponentID()
{
+ ///
+ /// Inherited from AliHLTComponent. Returns the component ID.
+ ///
+
return AliHLTMUONConstants::RecHitsSourceId();
}
AliHLTComponentDataType AliHLTMUONRecHitsSource::GetOutputDataType()
{
+ ///
+ /// Inherited from AliHLTComponent. Returns the output data type.
+ ///
+
return AliHLTMUONConstants::RecHitsBlockDataType();
}
unsigned long& constBase, double& inputMultiplier
)
{
+ ///
+ /// Inherited from AliHLTComponent. Returns an estimate of the expected output data size.
+ ///
+
constBase = sizeof(AliHLTMUONRecHitsBlockStruct)
+ 256*16*sizeof(AliHLTMUONRecHitStruct);
inputMultiplier = 0;
AliHLTComponent* AliHLTMUONRecHitsSource::Spawn()
{
+ ///
+ /// Inherited from AliHLTComponent. Creates a new object instance.
+ ///
+
return new AliHLTMUONRecHitsSource();
}
vector<AliHLTComponentBlockData>& outputBlocks
)
{
+ ///
+ /// Inherited from AliHLTOfflineDataSource. Creates new event data blocks.
+ ///
+
assert( fMCDataInterface != NULL or fDataInterface != NULL );
// Check the size of the event descriptor structure.
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,
if (not fServeChamber[chamber]) continue;
TIter next(clusterStore->CreateChamberIterator(chamber,chamber));
- AliMUONRawCluster* cluster;
- while ( ( cluster = static_cast<AliMUONRawCluster*>(next()) ) )
+ AliMUONVCluster* cluster;
+ while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
{
// Only select hits from the given part of the plane
if (fSelection == kLeftPlane and not (cluster->GetX() < 0)) continue;
rechit->fZ = cluster->GetZ();
// Workout which DDL this hit will be readout of.
- AliMpDetElement* de = AliMpDEManager::GetDetElement(cluster->DetElemId());
+ AliMpDetElement* de = AliMpDEManager::GetDetElement(cluster->GetDetElemId());
if (de != NULL and (0 <= de->GetDdlId() and de->GetDdlId() < 22))
ddlList[de->GetDdlId()] = true;
else
int AliHLTMUONRecHitsSource::ParseChamberString(const char* str)
{
+ ///
+ /// Parses a string with the following format:
+ /// <number>|<number>-<number>[,<number>|<number>-<number>]...
+ /// For example: 1 1,2,3 1-2 1,2-4,5 etc...
+ /// Flags in the fServeChamber will be set to 'true' for all appropriate
+ /// values parsed.
+ /// @param str The string to parse.
+ /// @return Zero on success and EINVAL if there is a parse error.
+ ///
+
char* end = const_cast<char*>(str);
long lastChamber = -1;
do