//
////////////////////////////////////////////////////////////////////////////////
+/* AliHLTMUONTriggerSource is used to extract L0 trigger information for
+ the muon spectrometer from a simulated event stored in .root files by AliRoot.
+ It is used by the AliHLTMUONMicrodHLT class as a input data set for the
+ dHLT algorithm.
+ */
+
#include "AliRoot/TriggerSource.hpp"
#include "AliRoot/Base.hpp"
#include "Tracking/Calculations.hpp"
#endif
ClassImp(AliHLTMUONTriggerSource)
-ClassImp(AliHLTMUONTriggerSource::EventData)
+ClassImp(AliHLTMUONTriggerSource::AliEventData)
AliHLTMUONTriggerSource::AliHLTMUONTriggerSource()
- : TObject(), fEventList(AliHLTMUONTriggerSource::EventData::Class())
+ : TObject(), fEventList(AliHLTMUONTriggerSource::AliEventData::Class())
{
- fAreaToUse = FromWholePlane;
- fDataToUse = FromLocalTriggers;
+// Default constructor.
+
+ fAreaToUse = kFromWholePlane;
+ fDataToUse = kFromLocalTriggers;
fMaxBlockSize = 0xFFFFFFFF;
fUseLookupTable = kTRUE;
fFilename = "";
AliHLTMUONTriggerSource::AliHLTMUONTriggerSource(AliMUONDataInterface* data)
- : TObject(), fEventList(AliHLTMUONTriggerSource::EventData::Class())
+ : TObject(), fEventList(AliHLTMUONTriggerSource::AliEventData::Class())
{
- fAreaToUse = FromWholePlane;
- fDataToUse = FromLocalTriggers;
+// Creates a new trigger source object by filling data from the data interface.
+
+ fAreaToUse = kFromWholePlane;
+ fDataToUse = kFromLocalTriggers;
fMaxBlockSize = 0xFFFFFFFF;
fUseLookupTable = kTRUE;
fFilename = "";
void AliHLTMUONTriggerSource::FillFrom(AliMUONDataInterface* data)
{
+// Fills the internal data structures from the specified data interface
+// for all the events found in AliMUONDataInterface.
+
DebugMsg(1, "FillFrom(AliMUONDataInterface*)");
if (FileAndFolderOk(data))
void AliHLTMUONTriggerSource::FillFrom(AliMUONDataInterface* data, Int_t event)
{
+// Fills the internal data structures from the specified data interface
+// for the given event.
+
DebugMsg(1, "FillFrom(AliMUONDataInterface*, Int_t)");
if (FileAndFolderOk(data))
Int_t event, Int_t trigger, Bool_t newblock
)
{
+// Fills the internal data structures from the specified data interface
+// for the given event and trigger number.
+// If 'newblock' is set to true then the new trigger record is added to
+// a new block. Otherwise the point is added to the current block.
+// Note: This method ignores the fAreaToUse and fMaxBlockSize flags.
+// This is very usefull for custom trigger source filling.
+// For the case of adding data from AliMUONHit objects the 'trigger'
+// parameter becomes the track number in TreeH and not the index of the
+// AliMUONLocalTrigger object.
+
DebugMsg(1, "FillFrom(AliMUONDataInterface*, Int_t, Int_t, Bool_t)");
if (FileAndFolderOk(data))
}
else
{
- if (fCurrentEvent->fEventNumber != event)
+ if (fCurrentEvent->EventNumber() != event)
{
Bool_t found = GetEvent(event);
if ( ! found) AddEvent(event);
void AliHLTMUONTriggerSource::Clear(Option_t* /*option*/)
{
+// Clears all the internal arrays.
+
fFilename = "";
fFoldername = "";
ResetAllPointers();
Bool_t AliHLTMUONTriggerSource::GetEvent(Int_t eventnumber) const
{
+// Fetches the specified event number stored in this AliHLTMUONTriggerSource.
+// Sets the current block and trigger to the first block and trigger record in
+// the event. If there are no blocks or trigger records then these pointers are
+// set to NULL. kTRUE is returned if the event was found, kFALSE otherwise.
+
DebugMsg(1, "AliHLTMUONTriggerSource::GetEvent(" << eventnumber << ")" );
// Try find the corresponding event in the list of events.
for (Int_t i = 0; i < fEventList.GetEntriesFast(); i++)
{
- EventData* current = (EventData*) fEventList[i];
- if (current->fEventNumber == eventnumber)
+ AliEventData* current = (AliEventData*) fEventList[i];
+ if (current->EventNumber() == eventnumber)
{
fEventIndex = i;
fCurrentEvent = current;
Bool_t AliHLTMUONTriggerSource::GetFirstEvent() const
{
+// Fetches the first event stored in this AliHLTMUONTriggerSource.
+// Sets the current block and trigger record to the first block and trigger
+// in the event. If there are no blocks or trigger records then these pointers
+// are set to NULL. kTRUE is returned if the event was found, kFALSE otherwise.
+
DebugMsg(1, "AliHLTMUONTriggerSource::GetFirstEvent()");
if (fEventList.GetEntriesFast() > 0)
{
fEventIndex = 0;
- fCurrentEvent = (EventData*) fEventList[0];
+ fCurrentEvent = (AliEventData*) fEventList[0];
GetFirstBlock();
DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
<< " , fTriggerIndex = " << fTriggerIndex
Bool_t AliHLTMUONTriggerSource::MoreEvents() const
{
+// Returns kTRUE if there are more events to iterate over.
+
return 0 <= fEventIndex && fEventIndex < fEventList.GetEntriesFast();
}
Bool_t AliHLTMUONTriggerSource::GetNextEvent() const
{
+// Fetches the next event stored following the currently selected one.
+// kTRUE is returned if the event was found, kFALSE otherwise.
+// The internal pointers are reset if we reached the last event.
+
DebugMsg(1, "AliHLTMUONTriggerSource::GetNextEvent()");
if (fEventIndex < fEventList.GetEntriesFast() - 1)
{
- fCurrentEvent = (EventData*) fEventList[ ++fEventIndex ];
+ fCurrentEvent = (AliEventData*) fEventList[ ++fEventIndex ];
GetFirstBlock();
DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
<< " , fTriggerIndex = " << fTriggerIndex
Int_t AliHLTMUONTriggerSource::CurrentEvent() const
{
+// Returns the corresponding AliRoot event number for the current event.
+// -1 is returned if no event is selected.
+
if (fCurrentEvent != NULL)
- return fCurrentEvent->fEventNumber;
+ return fCurrentEvent->EventNumber();
else
return -1;
}
Int_t AliHLTMUONTriggerSource::NumberOfBlocks() const
{
+// Returns the number of trigger record blocks in the current event.
+// -1 is returned if no event is selected.
+
DebugMsg(1, "AliHLTMUONTriggerSource::NumberOfBlocks()");
if (fCurrentEvent == NULL)
{
return -1;
}
else
- return fCurrentEvent->fBlocks.GetEntriesFast();
+ return fCurrentEvent->Blocks().GetEntriesFast();
}
Bool_t AliHLTMUONTriggerSource::GetBlock(Int_t index) const
{
+// Fetches the index'th block in the current event.
+// Sets the current trigger record to the first trigger in the block.
+// If there are no trigger records then this pointer is set to NULL.
+// kTRUE is returned if the block was found, kFALSE otherwise.
+
DebugMsg(1, "AliHLTMUONTriggerSource::GetBlock(" << index << ")");
// Note NumberOfBlocks() also checks if the event was selected.
if ( 0 <= index && index < numberofblocks )
{
fBlockIndex = index;
- fCurrentBlock = (TClonesArray*) fCurrentEvent->fBlocks[index];
+ fCurrentBlock = (TClonesArray*) fCurrentEvent->Blocks()[index];
GetFirstTrigger();
DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
<< " , fTriggerIndex = " << fTriggerIndex
Bool_t AliHLTMUONTriggerSource::GetFirstBlock() const
{
+// Fetches the first block in the current event.
+// Sets the current trigger record to the first trigger in the block.
+// If there are no trigger records then this pointer is set to NULL.
+// kTRUE is returned if the block was found, kFALSE otherwise.
+
DebugMsg(1, "AliHLTMUONTriggerSource::GetFirstBlock()");
// Note: NumberOfBlocks() also checks if fCurrentEvent != NULL.
if (NumberOfBlocks() > 0)
{
fBlockIndex = 0;
- fCurrentBlock = (TClonesArray*) fCurrentEvent->fBlocks[fBlockIndex];
+ fCurrentBlock = (TClonesArray*) fCurrentEvent->Blocks()[fBlockIndex];
GetFirstTrigger();
DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
<< " , fTriggerIndex = " << fTriggerIndex
Bool_t AliHLTMUONTriggerSource::MoreBlocks() const
{
+// Returns kTRUE if there are more blocks to be traversed.
+
return 0 <= fBlockIndex && fBlockIndex < NumberOfBlocks();
}
Bool_t AliHLTMUONTriggerSource::GetNextBlock() const
{
+// Fetches the next block in the current event.
+// kTRUE is returned if the block was found, kFALSE otherwise.
+
DebugMsg(1, "AliHLTMUONTriggerSource::GetNextBlock()");
// Note: NumberOfBlocks() checks if fCurrentEvent != NULL. If it is then it returns -1
// and since fBlockIndex is always >= -1 the if statement must go to the else part.
if (fBlockIndex < NumberOfBlocks() - 1)
{
- fCurrentBlock = (TClonesArray*) fCurrentEvent->fBlocks[ ++fBlockIndex ];
+ fCurrentBlock = (TClonesArray*) fCurrentEvent->Blocks()[ ++fBlockIndex ];
GetFirstTrigger();
DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
<< " , fTriggerIndex = " << fTriggerIndex
Int_t AliHLTMUONTriggerSource::NumberOfTriggers() const
{
+// Returns the number of trigger records in the current block.
+// -1 is returned if no block is selected.
+
DebugMsg(1, "AliHLTMUONTriggerSource::NumberOfTriggers()");
if (fCurrentBlock == NULL)
{
const AliHLTMUONTriggerRecord* AliHLTMUONTriggerSource::GetTrigger(Int_t triggernumber) const
{
+// Fetches the trigger record with the specified trigger number from
+// the current block.
+// NULL is returned if the record was not found.
+
DebugMsg(1, "AliHLTMUONTriggerSource::GetTrigger(" << triggernumber << ")");
if (fCurrentBlock == NULL)
const AliHLTMUONTriggerRecord* AliHLTMUONTriggerSource::GetFirstTrigger() const
{
+// Fetches the first trigger record in the current block.
+// NULL is returned if the record was not found.
+
DebugMsg(1, "AliHLTMUONTriggerSource::GetFirstTrigger()");
// Note: NumberOfTriggers() also checks if fCurrentBlock != NULL.
if (NumberOfTriggers() > 0)
Bool_t AliHLTMUONTriggerSource::MoreTriggers() const
{
+// Returns kTRUE if there are more triggers to iterate over.
+
return 0 <= fTriggerIndex && fTriggerIndex < NumberOfTriggers();
}
const AliHLTMUONTriggerRecord* AliHLTMUONTriggerSource::GetNextTrigger() const
{
+// Fetches the next trigger record in the current block.
+// NULL is returned if the record was not found.
+
DebugMsg(1, "AliHLTMUONTriggerSource::GetNextTrigger()");
// Note: NumberOfTriggers() checks if fCurrentBlock != NULL. If it is then it returns -1
Int_t AliHLTMUONTriggerSource::CurrentTrigger() const
{
+// Returns the trigger record number for the currently selected trigger record.
+// This number corresponds to the index'th AliMUONLocalTrigger object for the
+// current event.
+// -1 is returned if no trigger record is selected.
+
if (fCurrentTrigger != NULL)
{
return fCurrentTrigger->TriggerNumber();
void AliHLTMUONTriggerSource::AddEvent(Int_t eventnumber)
{
+// Adds a new AliEventData block to the fEventList and updates the fCurrentEvent,
+// fCurrentBlock and fCurrentTrigger pointers.
+
DebugMsg(1, "AliHLTMUONTriggerSource::AddEvent(" << eventnumber << ")");
Assert( eventnumber >= 0 );
// Assume the eventnumber does not already exist in the event list.
fEventIndex = fEventList.GetEntriesFast();
- new ( fEventList[fEventIndex] ) EventData(eventnumber);
- fCurrentEvent = (EventData*) fEventList[fEventIndex];
+ new ( fEventList[fEventIndex] ) AliEventData(eventnumber);
+ fCurrentEvent = (AliEventData*) fEventList[fEventIndex];
// Remember to reset the other pointers because the new event is empty.
ResetBlockPointers();
void AliHLTMUONTriggerSource::AddBlock()
{
+// Adds a new block to the current event and updates fCurrentBlock and fCurrentTrigger.
+
DebugMsg(1, "AliHLTMUONTriggerSource::AddBlock()");
if (fCurrentEvent == NULL)
return;
}
- fBlockIndex = fCurrentEvent->fBlocks.GetEntriesFast();
- new ( fCurrentEvent->fBlocks[fBlockIndex] ) TClonesArray(AliHLTMUONTriggerRecord::Class());
- fCurrentBlock = (TClonesArray*) fCurrentEvent->fBlocks[fBlockIndex];
+ fBlockIndex = fCurrentEvent->Blocks().GetEntriesFast();
+ new ( fCurrentEvent->Blocks()[fBlockIndex] ) TClonesArray(AliHLTMUONTriggerRecord::Class());
+ fCurrentBlock = (TClonesArray*) fCurrentEvent->Blocks()[fBlockIndex];
// Remember to reset the trigger pointer because the new block is empty.
ResetTriggerPointers();
void AliHLTMUONTriggerSource::AddTrigger(const AliHLTMUONTriggerRecord& data)
{
+// Adds a new trigger record to the current event and block.
+// The fCurrentTrigger is updated appropriately.
+
DebugMsg(1, "AliHLTMUONTriggerSource::AddTrigger(" << (void*)&data << ")");
if (fCurrentBlock == NULL)
Bool_t AliHLTMUONTriggerSource::FileAndFolderOk(AliMUONDataInterface* data)
{
+// Checks if the file and folder names correspond to this AliHLTMUONTriggerSource's
+// file and folder names. kTRUE is returned if they do.
+// If the file and folder names are empty then they are assigned the names
+// as found in the data interface and kTRUE is returned.
+
if (fFilename == "")
{
// Nothing filled yet so set the file and folder names.
void AliHLTMUONTriggerSource::AddEventFrom(AliMUONDataInterface* data, AliMUON* module, Int_t event)
{
+// Adds the whole event from the data interface to the internal data structures.
+// It is assumed that FileAndFolderOk(data) returns true just before calling
+// this method.
+
if ( data->GetEvent(event) )
{
AddEvent(event);
switch (fDataToUse)
{
- case FromHits:
+ case kFromHits:
for (Int_t track = 0; track < data->NumberOfTracks(); track++)
{
if ( ! FillTriggerFromHits(data, track, trigdata) )
}
break;
- case FromLocalTriggers:
+ case kFromLocalTriggers:
Assert( module != NULL );
- DebugMsg(4, "Taking FromLocalTriggers branch...");
+ DebugMsg(4, "Taking kFromLocalTriggers branch...");
for (Int_t i = 0; i < data->NumberOfLocalTriggers(); i++)
{
DebugMsg(4, "for loop: i = " << i);
void AliHLTMUONTriggerSource::AddTriggerFrom(AliMUONDataInterface* data, AliMUON* module, Int_t trigger)
{
+// Adds the specified trigger record from the given data interface.
+// The data interface should be initialised correctly, that is the event
+// should already be selected before calling this method.
+
DebugMsg(1, "Entering AddTriggerFrom");
AliHLTMUONTriggerRecord trigdata;
switch (fDataToUse)
{
- case FromHits:
+ case kFromHits:
{
// Note: in this case we treat the trigger parameter as a track number.
if ( ! FillTriggerFromHits(data, trigger, trigdata) )
}
break;
- case FromLocalTriggers:
+ case kFromLocalTriggers:
{
Assert( module != NULL );
AliMUONLocalTrigger* lt = data->LocalTrigger(trigger);
}
-Bool_t AliHLTMUONTriggerSource::InFillRegion(const AliHLTMUONTriggerRecord& data)
+Bool_t AliHLTMUONTriggerSource::InFillRegion(const AliHLTMUONTriggerRecord& data) const
{
+// Checks to see if the specified trigger record is in the chamber region
+// we want to fill from.
+// kTRUE is returned if (x, y) is in the region, and kFALSE otherwise.
+
switch (fAreaToUse)
{
- case FromWholePlane: return kTRUE;
- case FromLeftHalfPlane: return data.Station1Point().fX <= 0;
- case FromRightHalfPlane: return data.Station1Point().fX > 0;
+ case kFromWholePlane: return kTRUE;
+ case kFromLeftHalfPlane: return data.Station1Point().fX <= 0;
+ case kFromRightHalfPlane: return data.Station1Point().fX > 0;
default:
Error("InFillRegion", "fAreaToUse is not set to a valid value.");
AliMUONLocalTrigger* trigger, AliMUON* module, AliHLTMUONTriggerRecord& record
)
{
+// Fills the trigger data from the AliMUONLocalTrigger object.
+// if the fUseLookupTable is set to true then we use the L0 lookup table to
+// fill the Pt value otherwise we use the PtCal method in AliMUONTriggerCircuit.
+// Note the fTriggerNumber parameter is not filled in to 'record'.
+
DebugMsg(2, "Creating TriggerRecord from AliMUONLocalTrigger object: " << (void*)trigger );
AliMUONTriggerCircuit& circuit = module->TriggerCircuit(trigger->LoCircuit());
AliMUONDataInterface* data, Int_t track, AliHLTMUONTriggerRecord& record
)
{
+// Fills the TriggerRecord structure from AliMUONHit objects.
+// The hits on the last 4 chambers are used (i.e. chambers 11 to 14).
+// kTRUE is returned if the structure was filled successfully.
+
DebugMsg(2, "Creating TriggerRecord from hits on track: " << track );
Float_t x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4;
Bool_t AliHLTMUONTriggerSource::FetchAliMUON(AliMUON*& module)
{
+// Fetches the AliMUON module from the AliRun global object. AliRun will be loaded
+// by the runloader if it has not yet been loaded. In such a case the AliRun object
+// will also we unloaded when we are done with it.
+// kTRUE is returned if no error occured and kFALSE otherwise.
+// Note that if fDataToUse is set to kFromHits then gAlice is not loaded and 'module'
+// will be left untouched. The method will still return kTRUE however since this is
+// not an error. We do not need the AliMUON module when filling from hits.
+
// Check if we even need the MUON module. Not having to load it will
// save a lot of loading time for AliRoot.
- if (fDataToUse == FromHits)
+ if (fDataToUse == kFromHits)
{
// Make sure we do not attempt to unload gAlice in FinishedWithAliMUON,
// by setting the fHadToLoadgAlice to false.
void AliHLTMUONTriggerSource::FinishedWithAliMUON()
{
+// After one is finished with the AliMUON object returned by GetAliMUON, one
+// should call this method.
+// If the gAlice object was loaded by GetAliMUON then it will be unloaded at
+// this point, otherwise nothing is done.
+
// Only unload the gAlice object if we had to load it ourselves.
if (fHadToLoadgAlice)
AliRunLoader::GetRunLoader()->UnloadgAlice();
void AliHLTMUONTriggerSource::ResetAllPointers() const
{
+// Sets all the current pointers to NULL and indices to -1.
+
fEventIndex = -1;
fCurrentEvent = NULL;
fBlockIndex = -1;
void AliHLTMUONTriggerSource::ResetBlockPointers() const
{
+// Sets the block and trigger pointers to NULL and indices to -1.
+
fBlockIndex = -1;
fCurrentBlock = NULL;
fTriggerIndex = -1;
void AliHLTMUONTriggerSource::ResetTriggerPointers() const
{
+// Sets just the current trigger record pointer to NULL and index to -1.
+
fTriggerIndex = -1;
fCurrentTrigger = NULL;
DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
}
-AliHLTMUONTriggerSource::EventData::EventData() : fBlocks(TClonesArray::Class())
+AliHLTMUONTriggerSource::AliEventData::AliEventData() : fBlocks(TClonesArray::Class())
{
fEventNumber = -1;
}
-AliHLTMUONTriggerSource::EventData::EventData(Int_t eventnumber)
+AliHLTMUONTriggerSource::AliEventData::AliEventData(Int_t eventnumber)
: fBlocks(TClonesArray::Class())
{
+// Create a new event data block with specified event number.
+
fEventNumber = eventnumber;
// If the following is not set then we do not write the fBlocks properly.
}
-AliHLTMUONTriggerSource::EventData::~EventData()
+AliHLTMUONTriggerSource::AliEventData::~AliEventData()
{
//fBlocks.Clear("C"); // Done in fBlocks destructor
}