(1) Introduced option to pass clusters and tracks using low-level HLT interface.
For that interface classes was created (AliHLTTRDTrack,
AliHLTTRDTracklet, AliHLTTRDCluster)
(2) Components are now registered using AliHLTTRDAgent
(3) Other minor changes
--- /dev/null
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+//* for The ALICE HLT Project. *
+//* *
+//* Permission to use, copy, modify and distribute this software and its *
+//* documentation strictly for non-commercial purposes is hereby granted *
+//* 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 *
+//* provided "as is" without express or implied warranty. *
+//**************************************************************************
+
+/** @file AliHLTTRDAgent.cxx
+ @author Matthias Richter
+ @date
+ @brief Agent of the libAliHLTTRD library
+*/
+
+#include "AliHLTTRDAgent.h"
+#include "AliHLTConfiguration.h"
+#include "AliHLTTRDDefinitions.h"
+
+// #include "AliHLTOUT.h"
+// #include "AliHLTOUTHandlerChain.h"
+// #include "AliRunLoader.h"
+
+/** global instance for agent registration */
+AliHLTTRDAgent gAliHLTTRDAgent;
+
+// component headers
+#include "AliHLTTRDClusterizerComponent.h"
+#include "AliHLTTRDTrackerComponent.h"
+#include "AliHLTTRDTrackerV1Component.h"
+#include "AliHLTTRDCalibrationComponent.h"
+#include "AliHLTTRDEsdWriterComponent.h"
+
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTTRDAgent)
+
+ AliHLTTRDAgent::AliHLTTRDAgent()
+ :
+ AliHLTModuleAgent("TRD"),
+ fRawDataHandler(NULL)
+{
+ // see header file for class documentation
+ // or
+ // refer to README to build package
+ // or
+ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTTRDAgent::~AliHLTTRDAgent()
+{
+ // see header file for class documentation
+}
+
+int AliHLTTRDAgent::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/,
+ AliRawReader* /*rawReader*/,
+ AliRunLoader* /*runloader*/) const
+{
+ // see header file for class documentation
+
+ return 0;
+}
+
+const char* AliHLTTRDAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
+ AliRunLoader* /*runloader*/) const
+{
+ // see header file for class documentation
+
+ return "";
+}
+
+const char* AliHLTTRDAgent::GetRequiredComponentLibraries() const
+{
+ return "";
+}
+
+int AliHLTTRDAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
+{
+ // see header file for class documentation
+ if (!pHandler) return -EINVAL;
+ pHandler->AddComponent(new AliHLTTRDClusterizerComponent);
+ pHandler->AddComponent(new AliHLTTRDTrackerComponent);
+ pHandler->AddComponent(new AliHLTTRDTrackerV1Component);
+ pHandler->AddComponent(new AliHLTTRDCalibrationComponent);
+ pHandler->AddComponent(new AliHLTTRDEsdWriterComponent);
+
+ return 0;
+}
+
+int AliHLTTRDAgent::GetHandlerDescription(AliHLTComponentDataType dt,
+ AliHLTUInt32_t spec,
+ AliHLTOUTHandlerDesc& desc) const
+{
+ // see header file for class documentation
+
+ // raw data blocks to be fed into offline reconstruction
+ if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTRD)) {
+ desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
+ HLTInfo("module %s handles data block type %s specification %d (0x%x)",
+ GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
+ return 1;
+ }
+ return 0;
+}
+
+AliHLTOUTHandler* AliHLTTRDAgent::GetOutputHandler(AliHLTComponentDataType dt,
+ AliHLTUInt32_t /*spec*/)
+{
+ // see header file for class documentation
+
+ // raw data blocks to be fed into offline reconstruction
+ if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTRD)) {
+ // use the default handler
+ if (!fRawDataHandler) {
+ fRawDataHandler=new AliHLTOUTHandlerEquId;
+ }
+ return fRawDataHandler;
+ }
+ return NULL;
+}
+
+int AliHLTTRDAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
+{
+ // see header file for class documentation
+ if (pInstance==NULL) return -EINVAL;
+
+ if (pInstance==fRawDataHandler) {
+ delete fRawDataHandler;
+ fRawDataHandler=NULL;
+ return 0;
+ }
+
+ delete pInstance;
+ return 0;
+}
+
--- /dev/null
+#ifndef ALIHLTTRDAGENT_H
+#define ALIHLTTRDAGENT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/** @file AliHLTTRDAgent.h
+ @author Matthias Richter
+ @date
+ @brief Agent of the libAliHLTTRD library
+*/
+
+#include "AliHLTModuleAgent.h"
+#include "AliHLTOUTHandlerEquId.h"
+
+class AliHLTOUTHandlerChain;
+
+/**
+ * @class AliHLTTRDAgent
+ * This is the agent for the AliHLTTRD library.
+ *
+ * @ingroup alihlt_system
+ */
+class AliHLTTRDAgent : public AliHLTModuleAgent {
+ public:
+ /**
+ * standard constructor. The agent is automatically registered in the
+ * global agent manager
+ */
+ AliHLTTRDAgent();
+ /** destructor */
+ virtual ~AliHLTTRDAgent();
+
+ /**
+ * Register all configurations belonging to this module with the
+ * AliHLTConfigurationHandler. The agent can adapt the configurations
+ * to be registered to the current AliRoot setup by checking the
+ * runloader.
+ * @param handler the configuration handler
+ * @param rawReader AliRawReader instance
+ * @param runloader AliRoot runloader
+ * @return neg. error code if failed
+ */
+ int CreateConfigurations(AliHLTConfigurationHandler* handler,
+ AliRawReader* rawReader=NULL,
+ AliRunLoader* runloader=NULL) const;
+
+ /**
+ * Get the top configurations belonging to this module.
+ * A top configuration describes a processing chain. It can simply be
+ * described by the last configuration(s) in the chain.
+ * The agent can adapt the configurations to be registered to the current
+ * AliRoot setup by checking the runloader.
+ * @param rawReader AliRawReader instance
+ * @param runloader AliRoot runloader
+ * @return number of configurations, neg. error code if failed
+ */
+ const char* GetReconstructionChains(AliRawReader* rawReader=NULL,
+ AliRunLoader* runloader=NULL) const;
+
+ /**
+ * Component libraries which the configurations of this agent depend on.
+ * @return list of component libraries as a blank-separated string.
+ */
+ const char* GetRequiredComponentLibraries() const;
+
+ /**
+ * Register components for the AliHLTTRD library.
+ * @param pHandler [in] instance of the component handler
+ */
+ int RegisterComponents(AliHLTComponentHandler* pHandler) const;
+
+ /**
+ * Get handler decription for TRD data in the HLTOUT data stream.
+ * @param dt [in] data type of the block
+ * @param spec [in] specification of the block
+ * @param desc [out] handler description
+ * @return 1 if the agent can provide a handler, 0 if not
+ */
+ int GetHandlerDescription(AliHLTComponentDataType dt,
+ AliHLTUInt32_t spec,
+ AliHLTOUTHandlerDesc& desc) const;
+
+ /**
+ * Get specific handler for TRD data in the HLTOUT data stream.
+ * @param dt [in] data type of the block
+ * @param spec [in] specification of the block
+ * @return pointer to handler
+ */
+ AliHLTOUTHandler* GetOutputHandler(AliHLTComponentDataType dt,
+ AliHLTUInt32_t spec);
+
+ /**
+ * Delete an HLTOUT handler.
+ * @param pInstance pointer to handler
+ */
+ int DeleteOutputHandler(AliHLTOUTHandler* pInstance);
+
+ protected:
+
+ private:
+ /** copy constructor prohibited */
+ AliHLTTRDAgent(const AliHLTTRDAgent&);
+ /** assignment operator prohibited */
+ AliHLTTRDAgent& operator=(const AliHLTTRDAgent&);
+
+ /** handler for TRD raw data in the HLTOUT stream */
+ AliHLTOUTHandlerEquId* fRawDataHandler; //!transient
+
+ ClassDef(AliHLTTRDAgent, 0);
+};
+
+#endif
#include "AliHLTTRDCalibrationComponent.h"
#include "AliHLTTRDDefinitions.h"
+#include "AliHLTTRDTrack.h"
#include "AliCDBManager.h"
#include "AliTRDclusterizerHLT.h"
ClassImp(AliHLTTRDCalibrationComponent);
-AliHLTTRDCalibrationComponent::AliHLTTRDCalibrationComponent()
- : AliHLTCalibrationProcessor()
- , fTRDCalibraFillHisto(NULL)
- , fOutputPercentage(100) // By default we copy to the output exactly what we got as input
- , fStrorageDBpath("local://$ALICE_ROOT")
- , fCDB(NULL)
+AliHLTTRDCalibrationComponent::AliHLTTRDCalibrationComponent():
+ AliHLTCalibrationProcessor(),
+ fTRDCalibraFillHisto(NULL),
+ fUseHLTTracks(kFALSE),
+ fOutputPercentage(100), // By default we copy to the output exactly what we got as input
+ fStrorageDBpath("local://$ALICE_ROOT"),
+ fCDB(NULL)
{
// Default constructor
}
char* cpErr;
while ( i < argc )
{
- Logging( kHLTLogDebug, "HLT::TRDCalibration::ScanArgument", "Arguments", "argv[%d] == %s", i, argv[i] );
+ HLTDebug("argv[%d] == %s", i, argv[i] );
if ( !strcmp( argv[i], "output_percentage" ) )
{
if ( i+1>=argc )
{
- Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Missing Argument", "Missing output_percentage parameter");
+ HLTError("Missing output_percentage parameter");
return ENOTSUP;
}
- Logging( kHLTLogDebug, "HLT::TRDCalibration::ScanArgument", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
+ HLTDebug("argv[%d+1] == %s", i, argv[i+1] );
fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
if ( *cpErr )
{
- Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
+ HLTError("Cannot convert output_percentage parameter '%s'", argv[i+1] );
return EINVAL;
}
- Logging( kHLTLogInfo, "HLT::TRDCalibration::ScanArgument", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
+ HLTInfo("Output percentage set to %lu %%", fOutputPercentage );
i += 2;
continue;
}
-
- if ( strcmp( argv[i], "-cdb" ) == 0)
+ else if ( strcmp( argv[i], "-cdb" ) == 0)
{
if ( i+1 >= argc )
{
- Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Missing Argument", "Missing -cdb argument");
+ HLTError("Missing -cdb argument");
return ENOTSUP;
}
fStrorageDBpath = argv[i+1];
- Logging( kHLTLogInfo, "HLT::TRDCalibration::ScanArgument", "DB storage set", "DB storage is %s", fStrorageDBpath.c_str() );
+ HLTInfo("DB storage is %s", fStrorageDBpath.c_str() );
i += 2;
continue;
- }
-
- Logging(kHLTLogError, "HLT::TRDCalibration::ScanArgument", "Unknown Option", "Unknown option '%s'", argv[i] );
- return EINVAL;
+ }
+ else if ( strcmp( argv[i], "-useHLTTracks" ) == 0){
+ fUseHLTTracks = kTRUE;
+ i++;
+ HLTInfo("Expecting block of AliHLTTracks as input. Using low-level interface");
+ }
+ else{
+ HLTError("Unknown option '%s'", argv[i] );
+ return EINVAL;
+ }
}
return 0;
}
fCDB = AliCDBManager::Instance();
if (!fCDB)
{
- Logging(kHLTLogError, "HLT::TRDCalibration::InitCalibration", "Could not get CDB instance", "fCDB 0x%x", fCDB);
+ HLTError("Could not get CDB instance, fCDB 0x%x", fCDB);
}
else
{
fCDB->SetRun(0); // THIS HAS TO BE RETRIEVED !!!
fCDB->SetDefaultStorage(fStrorageDBpath.c_str());
- Logging(kHLTLogDebug, "HLT::TRDCalibration::InitCalibration", "CDB instance", "fCDB 0x%x", fCDB);
+ HLTDebug("fCDB 0x%x", fCDB);
}
fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance();
fTRDCalibraFillHisto->SetHisto2d(); // choose to use histograms
HLTDebug("DeinitCalibration");
// Deinitialization of the component
- // gain histo
- //TH2I *hCH2d = fTRDCalibraFillHisto->GetCH2d();
- // drift velocity histo
- //TProfile2D *hPH2d = fTRDCalibraFillHisto->GetPH2d();
- // PRF histo
- //TProfile2D *hPRF2d = fTRDCalibraFillHisto->GetPRF2d();
if (fCDB)
{
- Logging( kHLTLogDebug, "HLT::TRDCalibration::DeinitCalibration", "destroy", "fCDB");
+ HLTDebug("destroy fCDB");
fCDB->Destroy();
fCDB = 0;
}
return 0;
}
-Int_t AliHLTTRDCalibrationComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
+Int_t AliHLTTRDCalibrationComponent::ProcessCalibration(const AliHLTComponent_EventData& evtData,
+ const AliHLTComponent_BlockData* blocks,
+ AliHLTComponent_TriggerData& /*trigData*/,
+ AliHLTUInt8_t* /*outputPtr*/,
+ AliHLTUInt32_t& /*size*/,
+ vector<AliHLTComponent_BlockData>& /*outputBlocks*/)
{
// Process an event
-// Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
- Logging( kHLTLogDebug, "HLT::TRDCalibration::ProcessCalibration", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt );
+ // Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
+ HLTDebug("NofBlocks %lu", evtData.fBlockCnt );
// Process an event
- //unsigned long totalSize = 0;
-
- //implement a usage of the following
-// AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
-// AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
-// void *triggerData = trigData.fData;
- Logging( kHLTLogDebug, "HLT::TRDCalibration::ProcessCalibration", "Trigger data received",
- "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
// Loop over all input blocks in the event
- int ibForce = 0;
- TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkTRDSATracksDataType, "AliTRDtrack", ibForce);
- Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "1stBLOCK", "Pointer = 0x%x", tobjin);
- while (tobjin)
+ vector<AliHLTComponent_DataType> expectedDataTypes;
+ GetInputDataTypes(expectedDataTypes);
+ for ( unsigned long iBlock = 0; iBlock < evtData.fBlockCnt; iBlock++ )
{
- tobjin = (TObject *)GetNextInputObject( ibForce );
- Logging( kHLTLogInfo, "HLT::TRDCalibration::ProcessCalibration", "nextBLOCK", "Pointer = 0x%x", tobjin);
- TClonesArray* trdTracks = (TClonesArray* )tobjin;
- if (trdTracks)
+ const AliHLTComponentBlockData &block = blocks[iBlock];
+ AliHLTComponentDataType inputDataType = block.fDataType;
+ Bool_t correctDataType = kFALSE;
+
+ for(UInt_t i = 0; i < expectedDataTypes.size(); i++)
+ if( expectedDataTypes.at(i) == inputDataType)
+ correctDataType = kTRUE;
+ if (!correctDataType)
+ {
+ HLTDebug( "Block # %i/%i; Event 0x%08LX (%Lu) Wrong received datatype: %s - Skipping",
+ iBlock, evtData.fBlockCnt,
+ evtData.fEventID, evtData.fEventID,
+ DataType2Text(inputDataType).c_str());
+ continue;
+ }
+ else
+ HLTDebug("We get the right data type: Block # %i/%i; Event 0x%08LX (%Lu) Received datatype: %s",
+ iBlock, evtData.fBlockCnt-1,
+ evtData.fEventID, evtData.fEventID,
+ DataType2Text(inputDataType).c_str());
+
+ TClonesArray* tracksArray = NULL;
+ int ibForce = 0;
+ if (fUseHLTTracks)
+ {
+ tracksArray = new TClonesArray("AliTRDtrackV1");
+ HLTDebug("BLOCK fPtr 0x%x, fOffset %i, fSize %i, fSpec 0x%x, fDataType %s", block.fPtr, block.fOffset, block.fSize, block.fSpecification, DataType2Text(block.fDataType).c_str());
+ ReadTracks(tracksArray, block.fPtr, block.fSize);
+ }
+ else
{
- Int_t nbEntries = trdTracks->GetEntries();
+ TObject *objIn = NULL;
+ if (iBlock == 0)
+ objIn = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkTRDSATracksDataType, "TClonesArray", ibForce);
+ else
+ objIn = (TObject *)GetNextInputObject( ibForce );
+ HLTDebug("1stBLOCK, Pointer = 0x%x", objIn);
+ if (objIn){
+ tracksArray = (TClonesArray* )objIn;
+ }
+ }
+
+ if (tracksArray)
+ {
+ Int_t nbEntries = tracksArray->GetEntries();
+ HLTDebug(" %i TRDtracks in tracksArray", nbEntries);
AliTRDtrackV1* trdTrack = 0x0;
for (Int_t i = 0; i < nbEntries; i++){
- trdTrack = (AliTRDtrackV1*)trdTracks->At(i);
+ HLTDebug("%i/%i: ", i+1, nbEntries);
+ trdTrack = (AliTRDtrackV1*)tracksArray->At(i);
+ trdTrack->Print();
fTRDCalibraFillHisto->UpdateHistogramsV1(trdTrack);
}
-
}
- }
+ TObjArray *outArray = FormOutput();
+ if (outArray){
+ PushBack(outArray, AliHLTTRDDefinitions::fgkCalibrationDataType);
+ delete outArray;
+ }
+
+ }
return 0;
+
}
+/**
+ * Read track to the TClonesArray from the memory
+ */
+//============================================================================
+Int_t AliHLTTRDCalibrationComponent::ReadTracks(TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size)
+{
+ AliHLTUInt8_t* iterPtr = (AliHLTUInt8_t* )inputPtr;
+
+ cout << "\nReading tracks from the Memory\n ============= \n";
+ AliHLTTRDTrack * hltTrack;
+ AliHLTUInt32_t trackSize = 0, curSize = 0;
+ Int_t counter=0;
+
+ while (curSize < size)
+ {
+ hltTrack = (AliHLTTRDTrack*) iterPtr;
+ HLTDebug("curSize %i, size %i",curSize, size);
+
+ trackSize = hltTrack->GetSize();
+ HLTDebug("GetSize() %i", trackSize);
+
+ hltTrack->ReadTrackletsFromMemory(iterPtr + sizeof(AliHLTTRDTrack));
+
+ AliTRDtrackV1* curTRDTrack = new((*outArray)[counter]) AliTRDtrackV1();
+ hltTrack->ExportTRDTrack(curTRDTrack);
+
+ curSize += trackSize;
+ iterPtr += trackSize;
+ counter++;
+ }
+
+ //CheckTrackArray(outArray);
+ return counter;
+}
+
+
Int_t AliHLTTRDCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
{
- //Int_t PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const char* pDDLNumber = "");
- //ireturn = PushToFXS(object, "TRD ", "TRDCalib", "1024 ");
- Logging( kHLTLogDebug, "HLT::TRDCalibration::ProcessCalibration", "Shipping data",
- "Nothing serious");
- Int_t ireturn = 0;
+// //Int_t PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const char* pDDLNumber = "");
+// //ireturn = PushToFXS(object, "TRD ", "TRDCalib", "1024 ");
+
+ TObjArray *outArray = FormOutput();
+ HLTDebug("Shipping data. Dummy. outputArray: pointer = 0x%x; NEntries = %i;", outArray, outArray->GetEntries());
+ Int_t ireturn = PushToFXS(outArray, "TRD ", "TRDCalib");
+
+ if (outArray){
+ outArray->Delete();
+ delete outArray;
+ }
+
return ireturn;
}
+
+
+/**
+ * Form output array of histrograms
+ */
+//============================================================================
+TObjArray* AliHLTTRDCalibrationComponent::FormOutput()
+{
+ TObjArray *outArray=new TObjArray(3);
+
+ // gain histo
+ TH2I *hCH2d = fTRDCalibraFillHisto->GetCH2d();
+ outArray->Add(hCH2d);
+
+ // drift velocity histo
+ TProfile2D *hPH2d = fTRDCalibraFillHisto->GetPH2d();
+ outArray->Add(hPH2d);
+
+ // PRF histo
+ TProfile2D *hPRF2d = fTRDCalibraFillHisto->GetPRF2d();
+ outArray->Add(hPRF2d);
+
+ HLTDebug("GetCH2d = 0x%x; NEntries = %i; size = %i", hCH2d, hCH2d->GetEntries(), sizeof(hCH2d));
+ hCH2d->Print();
+ HLTDebug("GetPH2d = 0x%x; NEntries = %i; size = %i", hPH2d, hPH2d->GetEntries(), sizeof(hPH2d));
+ hPH2d->Print();
+ HLTDebug("GetPRF2d = 0x%x; NEntries = %i; size = %i", hPRF2d, hPRF2d->GetEntries(), sizeof(hPRF2d));
+ hPRF2d->Print();
+ HLTDebug("output Array: pointer = 0x%x; NEntries = %i; size = %i", outArray, outArray->GetEntries(), sizeof(outArray));
+
+
+
+ return outArray;
+
+}
+
* @class AliHLTTRDCalibrationComponent
* @brief A TRDCalibration HLT processing component.
*
- * An implementiation of a TRDCalibration component that just copies its input data
- * as a test, demonstration, and example of the HLT component scheme.
* - @ref InitCalibration (optional)
* - @ref ScanArgument (optional)
* - @ref DeinitCalibration (optional)
virtual Int_t InitCalibration();
virtual Int_t ScanArgument(int argc, const char** argv);
virtual Int_t DeinitCalibration();
-/* virtual Int_t ProcessCalibration(const AliHLTComponent_EventData& evtData, */
-/* const AliHLTComponent_BlockData* blocks, */
-/* AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, */
-/* AliHLTUInt32_t& size, */
-/* vector<AliHLTComponent_BlockData>& outputBlocks); */
- virtual Int_t ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
+ virtual Int_t ProcessCalibration(const AliHLTComponent_EventData& evtData,
+ const AliHLTComponent_BlockData* blocks,
+ AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size,
+ vector<AliHLTComponent_BlockData>& outputBlocks);
+/* virtual Int_t ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData); */
virtual Int_t ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
-
+
using AliHLTCalibrationProcessor::ProcessCalibration;
using AliHLTCalibrationProcessor::ShipDataToFXS;
+
+ Bool_t fUseHLTTracks;
+ Int_t ReadTracks(TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size);
private:
/** copy constructor prohibited */
AliHLTTRDCalibrationComponent(const AliHLTTRDCalibrationComponent&);
/** assignment operator prohibited */
AliHLTTRDCalibrationComponent& operator=(const AliHLTTRDCalibrationComponent&);
-
+ TObjArray* FormOutput();
// The size of the output data produced, as a percentage of the input data's size.
// Can be greater than 100 (%)
--- /dev/null
+#include "AliHLTTRDCluster.h"
+
+
+/**
+ * Default Constructor
+ */
+//============================================================================
+AliHLTTRDCluster::AliHLTTRDCluster():
+ fSize(sizeof(AliHLTTRDCluster)),
+ fX(0),
+ fY(0),
+ fZ(0),
+ fIsInChamber(kFALSE),
+ fIsShared(kFALSE),
+ fDetector(-1),
+ fLocalTimeBin(0),
+ fQ(0),
+ fClusterMasking(0),
+ fPadCol(0),
+ fPadRow(0),
+ fPadTime(0)
+{
+}
+
+/**
+ * Main Constructor
+ */
+//============================================================================
+AliHLTTRDCluster::AliHLTTRDCluster(AliTRDcluster * inCluster):
+ fSize (sizeof(AliHLTTRDCluster)),
+ fX (inCluster->GetX()),
+ fY (inCluster->GetY()),
+ fZ (inCluster->GetZ()),
+ fIsInChamber(inCluster->IsInChamber()),
+ fIsShared (inCluster->IsShared()),
+ fDetector (inCluster->GetDetector()),
+ fLocalTimeBin (inCluster->GetLocalTimeBin()),
+ fQ (inCluster->GetQ()),
+ fClusterMasking (inCluster->IsMasked()),
+ fPadCol (inCluster->GetPadCol()),
+ fPadRow (inCluster->GetPadRow()),
+ fPadTime ( inCluster->GetPadTime())
+{
+ // fNPads = inCluster->GetNPads();
+ // fCenter = inCluster->GetCenter();
+}
+
+
+/**
+ * Copy data to the output TRDcluster
+ */
+//============================================================================
+void AliHLTTRDCluster::ExportTRDCluster(AliTRDcluster *outCluster)
+{
+ // Print();
+ outCluster->SetX(fX);
+ outCluster->SetY(fY);
+ outCluster->SetZ(fZ);
+ outCluster->SetInChamber(fIsInChamber);
+ outCluster->SetShared(fIsShared);
+ outCluster->SetDetector(fDetector);
+ outCluster->SetLocalTimeBin(fLocalTimeBin);
+ outCluster->SetQ(fQ);
+ outCluster->SetClusterMasking(fClusterMasking);
+
+ outCluster->SetPadCol(fPadCol);
+ outCluster->SetPadRow(fPadRow);
+ outCluster->SetPadTime(fPadTime);
+ // outCluster->SetNPads(fNPads);
+ // outCluster->SetCenter(fCenter);
+
+
+}
+
+/**
+ * Prints main info about cluster
+ */
+//============================================================================
+void AliHLTTRDCluster::Print()
+{
+ //printf(" --hltCluster-- addr 0x%x(%i); fSize %i\n", this, (int)this, this->GetSize());
+ //printf(" fX %f; fY %f; fZ %f\n",fX,fY,fZ);
+
+}
--- /dev/null
+#ifndef ALIHLTTRDCLUSTER_H
+#define ALIHLTTRDCLUSTER_H
+
+#include "AliTRDcluster.h"
+#include "AliHLTDataTypes.h"
+
+class AliHLTTRDCluster
+{
+ public:
+ AliHLTTRDCluster();
+ AliHLTTRDCluster(AliTRDcluster* inCluster);
+ void ExportTRDCluster(AliTRDcluster* outCluster);
+
+ AliHLTUInt8_t *GetEndPointer() // Returns pointer to the end of the cluster
+ { return ((AliHLTUInt8_t *) this + fSize); };
+ AliHLTUInt32_t GetSize(){ return fSize; };
+ void Print();
+
+ AliHLTUInt32_t fSize; // Size of the Cluster
+
+
+ private:
+ // From AliCluster
+ Float_t fX; // X of the cluster in the tracking c.s.
+ Float_t fY; // Y of the cluster in the tracking c.s.
+ Float_t fZ; // Z of the cluster in the tracking c.s.
+
+ Bool_t fIsInChamber;
+ Bool_t fIsShared;
+ Short_t fDetector; // TRD detector number
+ Char_t fLocalTimeBin; // T0-calibrated time bin number
+ Float_t fQ; // Amplitude
+ UChar_t fClusterMasking; // Bit field containing cluster status information;
+
+ // From AliTRDcluster
+ UChar_t fPadCol; // Central pad number in column direction
+ UChar_t fPadRow; // Central pad number in row direction
+ UChar_t fPadTime; // Uncalibrated time bin number
+ // Short_t fSignals[7]; // Signals in the cluster
+// UChar_t fNPads; // Number of pads in cluster
+// Float_t fCenter; // Center of the cluster relative to the pad
+
+
+};
+
+#endif
#include "AliHLTTRDClusterizerComponent.h"
#include "AliHLTTRDDefinitions.h"
+#include "AliHLTTRDCluster.h"
#include "AliGeomManager.h"
#include "AliTRDReconstructor.h"
#include "AliTRDclusterizerHLT.h"
#include "AliTRDrecoParam.h"
#include "AliTRDrawStreamBase.h"
+#include "AliTRDcluster.h"
#include "AliRawReaderMemory.h"
+#ifdef HAVE_VALGRIND_CALLGRIND_H
+#include <valgrind/callgrind.h>
+#else
+#define CALLGRIND_START_INSTRUMENTATION() do { } while (0)
+#define CALLGRIND_STOP_INSTRUMENTATION() do { } while (0)
+#endif
+
#include <cstdlib>
#include <cerrno>
#include <string>
-// this is a global object used for automatic component registration, do not use this
-AliHLTTRDClusterizerComponent gAliHLTTRDClusterizerComponent;
-
ClassImp(AliHLTTRDClusterizerComponent);
-AliHLTTRDClusterizerComponent::AliHLTTRDClusterizerComponent()
- : AliHLTProcessor()
- , fOutputPercentage(100) // By default we copy to the output exactly what we got as input
- , fStrorageDBpath("local://$ALICE_ROOT")
- , fClusterizer(NULL)
- , fRecoParam(NULL)
- , fCDB(NULL)
- , fMemReader(NULL)
- , fReconstructor(NULL)
- , fGeometryFileName("")
- , fGeometryFile(NULL)
+AliHLTTRDClusterizerComponent::AliHLTTRDClusterizerComponent():
+ AliHLTProcessor(),
+ fOutputPercentage(100), // By default we copy to the output exactly what we got as input
+ fStrorageDBpath("local://$ALICE_ROOT"),
+ fClusterizer(NULL),
+ fRecoParam(NULL),
+ fCDB(NULL),
+ fMemReader(NULL),
+ fReconstructor(NULL),
+ fGeometryFileName(""),
+ fUseHLTClusters(kFALSE)
{
// Default constructor
// Destructor
// Work is Done in DoDeInit()
}
+
+/**
+ * Convert AliTRDcluster to AliHLTTRDCluster
+ * Add HLTCluster to the output, defined by pointer
+ * Fill block desctiptors
+ * Return size of the added to ouput objects
+ */
+//============================================================================
+UInt_t AliHLTTRDClusterizerComponent::AddToOutput(TClonesArray* inClusterArray, AliHLTUInt8_t* outBlockPtr)
+{
+ AliTRDcluster* cluster = 0;
+ AliHLTUInt32_t addedSize = 0;
+ // == OUTdatatype pointer
+ AliHLTTRDCluster * outPtr = (AliHLTTRDCluster*)outBlockPtr;
+
+ if (inClusterArray){
+ Int_t nbEntries = inClusterArray->GetEntries();
+ for (Int_t iCluster = 0; iCluster<nbEntries; iCluster++){
+ //cout << "Geting cluster #" << iCluster << endl;
+ UInt_t blockSize=0;
+
+ cluster = dynamic_cast<AliTRDcluster*>(inClusterArray->At(iCluster));
+
+ AliHLTTRDCluster *hltCluster = new (outPtr) AliHLTTRDCluster(cluster);
+ //cout << Form("cluster added at 0x%x (%i)\n",outPtr,outPtr);
+
+ blockSize = sizeof(*hltCluster);
+
+ addedSize += blockSize;
+ outBlockPtr += blockSize;
+ outPtr = (AliHLTTRDCluster*)outBlockPtr;
+ }
+ }
+ return addedSize;
+
+}
+
const char* AliHLTTRDClusterizerComponent::GetComponentID()
{
// Return the component ID const char *
bWriteClusters = kTRUE;
i++;
}
+ else if ( strcmp( argv[i], "-useHLTClusters" ) == 0)
+ {
+ fUseHLTClusters = kTRUE;
+ i++;
+ HLTInfo("Using AliHLTCluster to pass data further in the chain");
+ }
else{
HLTError("Unknown option '%s'", argv[i] );
return EINVAL;
fReconstructor->SetStreamLevel(0, AliTRDReconstructor::kClusterizer); // default value
if (bWriteClusters)
{
- HLTInfo("Writing clusters. I.e. output is a TTree with clusters");
- fReconstructor->SetOption("cw,sl_cf_0");
+ HLTInfo("Writing clusters. I.e. output is a TTree with clusters");
+ fReconstructor->SetOption("cw,sl_cf_0");
}
else
{
- HLTInfo("Not witing clusters. I.e. output is a TClonesArray of clusters");
+ HLTInfo("Not writing clusters. I.e. output is a TClonesArray of clusters");
fReconstructor->SetOption("!cw,sl_cf_0");
}
HLTDebug("CDB instance; fCDB 0x%x", fCDB);
}
- fGeometryFile = TFile::Open(fGeometryFileName.c_str());
- if (fGeometryFile)
- {
+ if((AliGeomManager::GetGeometry()) == NULL){
+
+ if ( TFile::Open(fGeometryFileName.c_str())) {
AliGeomManager::LoadGeometry(fGeometryFileName.c_str());
}
- else
- {
- HLTError("Unable to open file. FATAL!");
- return -1;
+ else {
+ HLTError("Cannot load geometry from file %s",fGeometryFileName.c_str());
+ return EINVAL;
}
-
+ }
+ else
+ HLTInfo("Geometry Already Loaded");
+
fMemReader = new AliRawReaderMemory;
fClusterizer = new AliTRDclusterizerHLT("TRDCclusterizer", "TRDCclusterizer");
fReconstructor = 0x0;
return 0;
- if (fGeometryFile)
- {
- fGeometryFile->Close();
- delete fGeometryFile;
- fGeometryFile = 0;
- }
if (fCDB)
{
int AliHLTTRDClusterizerComponent::DoEvent( const AliHLTComponentEventData& evtData,
const AliHLTComponentBlockData* blocks,
AliHLTComponent_TriggerData& /*trigData*/,
- AliHLTUInt8_t* /*outputPtr*/,
+ AliHLTUInt8_t* outputPtr,
AliHLTUInt32_t& size,
- vector<AliHLTComponent_BlockData>& /*outputBlocks*/ )
+ vector<AliHLTComponent_BlockData>& outputBlocks )
{
// Process an event
HLTDebug( "NofBlocks %lu", evtData.fBlockCnt );
// Process an event
+ AliHLTUInt32_t totalSize = 0, offset = 0;
Bool_t bWriteClusters = fReconstructor->IsWritingClusters();
//implement a usage of the following
AliHLTComponentDataType expectedDataType = (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTRD);
for ( unsigned long i = 0; i < evtData.fBlockCnt; i++ )
{
+ if (evtData.fEventID == 1)
+ CALLGRIND_START_INSTRUMENTATION();
+
+ const AliHLTComponentBlockData &block = blocks[i];
+ offset = totalSize;
// lets not use the internal TRD data types here : AliHLTTRDDefinitions::fgkDDLRawDataType
// which is depreciated - we use HLT global defs instead
- // if ( blocks[i].fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTRD) )
- AliHLTComponentDataType inputDataType = blocks[i].fDataType;
+ // if ( block.fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTRD) )
+ AliHLTComponentDataType inputDataType = block.fDataType;
if ( inputDataType != expectedDataType)
{
HLTDebug( "Block # %i/%i; Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s; Skipping",
}
else
{
- HLTDebug("We get the right data type!");
+ HLTDebug("We get the right data type: Block # %i/%i; Event 0x%08LX (%Lu) Received datatype: %s",
+ i, evtData.fBlockCnt,
+ evtData.fEventID, evtData.fEventID,
+ DataType2Text(inputDataType).c_str());
}
// fMemReader->Reset();
- fMemReader->SetMemory((UChar_t*) blocks[i].fPtr, blocks[i].fSize);
+ fMemReader->SetMemory((UChar_t*) block.fPtr, block.fSize);
- AliHLTUInt32_t spec = blocks[i].fSpecification;
+ AliHLTUInt32_t spec = block.fSpecification;
Int_t id = 1024;
}
spec = spec >> 1 ;
}
-
- fMemReader->SetEquipmentID( id );
+ fMemReader->SetEquipmentID( id );
+
fClusterizer->ResetTree();
Bool_t iclustered = fClusterizer->Raw2ClustersChamber(fMemReader);
if (iclustered == kTRUE)
return -1;
}
- // put the tree into output blocks
+ // put the tree into output
//fcTree->Print();
if (bWriteClusters)
{
TTree *fcTree = fClusterizer->GetClusterTree();
if (fcTree)
{
- HLTDebug("fcTree: Entries - %i; Size - %i",fcTree->GetEntriesFast(),sizeof(fcTree));
- PushBack(fcTree, AliHLTTRDDefinitions::fgkClusterDataType, blocks[i].fSpecification);
+ Int_t nbEntries = fcTree->GetEntriesFast();
+ if (nbEntries > 0){
+ HLTDebug("fcTree: Entries - %i; Size - %i",nbEntries,sizeof(fcTree));
+ PushBack(fcTree, AliHLTTRDDefinitions::fgkClusterDataType, spec);
+ }
+
}
fClusterizer->RecPoints()->Delete();
{
TClonesArray *clustersArray = fClusterizer->RecPoints();
fClusterizer->SetClustersOwner(kFALSE);
-
if (clustersArray){
- clustersArray->BypassStreamer(kFALSE);
- HLTDebug("clustersArray: Entries - %i; Size - %i",clustersArray->GetEntriesFast(),sizeof(clustersArray));
- PushBack(clustersArray, AliHLTTRDDefinitions::fgkClusterDataType, blocks[i].fSpecification);
- clustersArray->Delete();
+ Int_t nbEntries = clustersArray->GetEntriesFast();
+ if (nbEntries > 0){
+ if (fUseHLTClusters){
+ // Using low-level interface
+ // with interface classes
+ AliHLTUInt32_t addedSize = AddToOutput(clustersArray, outputPtr);
+ totalSize += addedSize;
+ if ( totalSize > size )
+ {
+ HLTError("Too much data; Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
+ totalSize, size );
+ return EMSGSIZE;
+ }
+
+ // Fill block
+ AliHLTComponentBlockData bd;
+ FillBlockData( bd );
+ bd.fOffset = offset;
+ bd.fSize = addedSize;
+ //bd.fSpecification = spec;
+ bd.fSpecification = gkAliEventTypeData;
+ bd.fDataType = AliHLTTRDDefinitions::fgkClusterDataType;
+ outputBlocks.push_back( bd );
+ HLTDebug( "Block ; size %i; dataType %s; spec 0x%x ",
+ bd.fSize, DataType2Text(bd.fDataType).c_str(), spec);
+
+ }
+ else{
+ // Using high-level interface
+ // pass TClonesArray with streamers
+ clustersArray->BypassStreamer(kFALSE);
+ HLTDebug("clustersArray: Entries - %i; Size - %i",clustersArray->GetEntriesFast(),sizeof(clustersArray));
+ PushBack(clustersArray, AliHLTTRDDefinitions::fgkClusterDataType, spec);
+ //PrintObject(clustersArray);
+ }
+
+ clustersArray->Delete();
+ }
delete clustersArray;
}
else
HLTWarning("Array of clusters is empty!");
}
-
-
-
-
}// for ( unsigned long i = 0; i < evtData.fBlockCnt; i++ )
+ fReconstructor->SetClusters(0x0);
+ size = totalSize;
+ HLTDebug("Event is done. size written to the output is %i", size);
+ return 0;
+}
+
+
+void AliHLTTRDClusterizerComponent::PrintObject( TClonesArray* inClustersArray)
+{
+ AliTRDcluster* cluster=0x0;
+ for (Int_t i=0; i < inClustersArray->GetEntriesFast(); i++){
+ cluster = dynamic_cast<AliTRDcluster*>(inClustersArray->At(i));
+ HLTDebug("cluster[%i]",i);
+ HLTDebug(" PadCol = %i; PadRow = %i; PadTime = %i", cluster->GetPadCol(), cluster->GetPadRow(), cluster->GetPadTime());
+ HLTDebug(" Detector = %i, Amplitude = %f, Center = %f", cluster->GetDetector(), cluster->GetQ(), cluster->GetCenter());
+ HLTDebug(" LocalTimeBin = %i; NPads = %i; maskedPosition: %s, status: %s", cluster->GetLocalTimeBin(), cluster->GetNPads(),cluster->GetPadMaskedPosition(),cluster->GetPadMaskedPosition());
+ }
-
- size=0; // this function did not write data to the buffer directly
- return 0;
}
+
AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr,
AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
+ void PrintObject( TClonesArray* inClustersArray);
using AliHLTProcessor::DoEvent;
+
+
private:
/** copy constructor prohibited */
AliHLTTRDClusterizerComponent(const AliHLTTRDClusterizerComponent&);
/** assignment operator prohibited */
AliHLTTRDClusterizerComponent& operator=(const AliHLTTRDClusterizerComponent&);
+ UInt_t AddToOutput(TClonesArray* inClusterArray, AliHLTUInt8_t* outBlockPtr);
+
// The size of the output data produced, as a percentage of the input data's size.
// Can be greater than 100 (%)
string fGeometryFileName; // Path to geometry file
- TFile *fGeometryFile; //! // Pointer to the geom root file
+ Bool_t fUseHLTClusters; // Use or not AliHLTCluster interface
ClassDef(AliHLTTRDClusterizerComponent, 0)
--- /dev/null
+#include "AliHLTTRDTrack.h"
+#include "AliHLTTRDTracklet.h"
+
+
+/**
+ * Default Constructor
+ */
+//============================================================================
+AliHLTTRDTrack::AliHLTTRDTrack():
+ fSize(sizeof(AliHLTTRDTrack)),
+ fTRDtrack(NULL),
+ fPIDquality(0),
+ fDE(-1),
+ fFakeRatio(-1),
+ fChi2(-1),
+ fMass(-1),
+ fLab(-1),
+ fN(-1),
+ fIntegratedLength(-1),
+ fX(-1),
+ fAlpha(-1)
+{
+ InitArrays();
+ // not to be used
+}
+
+/**
+ * Constructor
+ * Creates hltTrack from TRDtrackV1
+ */
+//============================================================================
+AliHLTTRDTrack::AliHLTTRDTrack(AliTRDtrackV1 * inTrack):
+ fSize(sizeof(AliHLTTRDTrack)),
+ fTRDtrack(NULL),
+ fPIDquality(0),
+ fDE(-1),
+ fFakeRatio(-1),
+ fChi2(-1),
+ fMass(-1),
+ fLab(-1),
+ fN(-1),
+ fIntegratedLength(-1),
+ fX(-1),
+ fAlpha(-1)
+{
+ InitArrays();
+
+ fTRDtrack = inTrack;
+
+ CopyDataMembers();
+
+ AddTracklets();
+
+}
+
+/**
+ * Default Destructor
+ * In principle should not be empty, but... we do not use it
+ */
+//============================================================================
+AliHLTTRDTrack::~AliHLTTRDTrack()
+{
+
+}
+
+/**
+ * Copy tracklets to the HLTTRDTrack
+ */
+//============================================================================
+void AliHLTTRDTrack::AddTracklets()
+{
+ for (Int_t iTracklet = 0; iTracklet < kNplane; iTracklet++)
+ {
+ // if (fTracklet[iTracklet])
+ // HLTWarning("Trying to rewrite tracklets in the Track. Not good.");
+ AliTRDseedV1 * trdTracklet = fTRDtrack->GetTracklet(iTracklet);
+ if (trdTracklet){
+ AliHLTTRDTracklet * hltTracklet = new (GetEndPointer()) AliHLTTRDTracklet(trdTracklet);
+ fSize += hltTracklet->GetSize();
+ //HLTDebug("tracklet %i; adr 0x%x; endPointer 0x%x; fSize %i", iTracklet, hltTracklet, hltTracklet->GetEndPointer(), fSize);
+ fTracklet[iTracklet] = hltTracklet;
+ }
+ else
+ fTracklet[iTracklet] = NULL;
+ }
+}
+
+
+/**
+ * Copy data members (except tracklets) from TRDtrackV1 to HLTTRDTrack.
+ */
+//============================================================================
+void AliHLTTRDTrack::CopyDataMembers()
+{
+
+ fPIDquality = fTRDtrack->GetPIDquality();
+
+ for(Int_t i = 0; i < AliPID::kSPECIES; i++)
+ {
+ fPID[i] = fTRDtrack->GetPID(i);
+ }
+
+ for (Int_t i = 0; i < 3; i++)
+ {
+ fBudget[i] = fTRDtrack->GetBudget(i);
+ }
+ fDE = fTRDtrack->GetEdep();
+ fFakeRatio = fTRDtrack->GetFakeRatio();
+ fChi2 = fTRDtrack->GetChi2();
+ fMass = fTRDtrack->GetMass();
+ fLab = fTRDtrack->GetLabel();
+ fN = fTRDtrack->GetNumberOfClusters();
+ fIntegratedLength = fTRDtrack->GetIntegratedLength();
+
+ fX = fTRDtrack->GetX();
+ fAlpha = fTRDtrack->GetAlpha();
+ const Double_t *Ptemp = fTRDtrack->GetParameter();
+ for (Int_t i = 0; i < 5; i++)
+ {
+ fP[i] = Ptemp[i];
+ }
+ const Double_t *Ctemp = fTRDtrack->GetCovariance();
+ for (Int_t i = 0; i < 15; i++)
+ {
+ fC[i] = Ctemp[i];
+ }
+
+}
+
+/**
+ * Copy data to the output TRDtrackV1
+ */
+//============================================================================
+void AliHLTTRDTrack::ExportTRDTrack(AliTRDtrackV1 *outTrack)
+{
+ outTrack->Reset();
+
+ //Set members from AliTRDtrackV1
+ outTrack->SetPIDquality(fPIDquality);
+ outTrack->SetEdep(fDE);
+ for(Int_t i = 0; i < AliPID::kSPECIES; i++)
+ {
+ outTrack->SetPID(i,fPID[i]);
+ }
+ for (Int_t i = 0; i < 3; i++)
+ {
+ outTrack->SetBudget(i, fBudget[i]);
+ }
+ for (Int_t iTracklet = 0; iTracklet < kNplane; iTracklet++){
+ if (fTracklet[iTracklet]){
+ AliTRDseedV1* trdTracklet = new AliTRDseedV1();
+ fTracklet[iTracklet]->ExportTRDTracklet(trdTracklet);
+ outTrack->SetTracklet(trdTracklet,iTracklet);
+ }
+ }
+
+ //Set members from AliKalmanTrack
+ outTrack->SetFakeRatio(fFakeRatio);
+ //outTrack->SetChi2(fChi2);
+ outTrack->SetMass(fMass);
+ outTrack->SetLabel(fLab);
+ (dynamic_cast<AliKalmanTrack*>(outTrack))->SetNumberOfClusters(fN);
+ outTrack->SetIntegratedLength(fIntegratedLength);
+
+ //Set members from AliExternalTrackParam
+ outTrack->Set(fX, fAlpha, fP, fC);
+}
+
+
+/**
+ * Init of arrays
+ */
+//============================================================================
+void AliHLTTRDTrack::InitArrays()
+{
+ for(Int_t i = 0; i < kNplane; i++){
+ fTracklet[i]=NULL;
+ }
+
+ for(Int_t i = 0; i < AliPID::kSPECIES; i++)
+ {
+ fPID[i] = -1;
+ }
+
+ for (Int_t i = 0; i < 3; i++)
+ {
+ fBudget[i] = -1;
+ }
+ for (Int_t i = 0; i < 5; i++)
+ {
+ fP[i] = -1;
+ }
+ for (Int_t i = 0; i < 15; i++)
+ {
+ fC[i] = -1;
+ }
+}
+
+/**
+ * Print main values for HLTTrack
+ */
+//============================================================================
+void AliHLTTRDTrack::Print(Bool_t printTracklets)
+{
+ //printf("--hltTrack-- addr 0x%p(%i); fSize %i\n", this, (int)this, fSize);
+ //printf(" fPIDquality = %s; fX = %f; fAlpha = %f\n", fPIDquality, fX, fAlpha);
+ printf(" ");
+
+ for(Int_t i = 0; i < AliPID::kSPECIES; i++)
+ {
+ printf("fPID[%i] = %f; ",i, fPID[i]);
+ }
+ printf("\n ");
+
+ for (Int_t i = 0; i < 3; i++)
+ {
+ printf("fBudget[%i] = %f; ",i, fBudget[i]);
+ }
+ printf("\n");
+
+ if (printTracklets)
+ {
+ for (Int_t i = 0; i < kNplane; i++){
+ if (fTracklet[i]){
+ printf("[%i]",i);
+ fTracklet[i]->Print();
+ }
+ else
+ printf(" NULL ");
+ }
+ }
+
+ printf("\n");
+}
+
+/**
+ * Read tracklets from the memory.
+ * Number of tracklets should be already known
+ */
+//============================================================================
+void AliHLTTRDTrack::ReadTrackletsFromMemory(void* input)
+{
+ AliHLTUInt8_t *iterPtr = (AliHLTUInt8_t*) input;
+ AliHLTTRDTracklet* hltTracklet = NULL;
+
+ for (Int_t iTracklet = 0; iTracklet < kNplane; iTracklet++){
+ if (fTracklet[iTracklet]){
+ hltTracklet = (AliHLTTRDTracklet*) iterPtr;
+ hltTracklet->ReadClustersFromMemory(iterPtr+sizeof(AliHLTTRDTracklet));
+ fTracklet[iTracklet] = hltTracklet;
+ iterPtr += hltTracklet->GetSize();
+ //hltTracklet->Print(kFALSE);
+ }
+ }
+}
--- /dev/null
+#ifndef ALIHLTTRDTRACK_H
+#define ALIHLTTRDTRACK_H
+
+#include "AliTRDtrackV1.h"
+#include "AliHLTLogging.h"
+class AliHLTTRDTracklet;
+
+
+class AliHLTTRDTrack
+{
+ public:
+ AliHLTTRDTrack();
+ ~AliHLTTRDTrack();
+ AliHLTTRDTrack( AliTRDtrackV1* inTrack);
+
+ void AddTracklets();
+ void CopyDataMembers();
+ void ExportTRDTrack(AliTRDtrackV1* outTrack);
+ AliHLTUInt8_t *GetEndPointer() // Returns pointer to the end of the track
+ { return ((AliHLTUInt8_t *) this + fSize); };
+ AliHLTUInt32_t GetSize(){return fSize;};
+ void Print(Bool_t printTracklets = kTRUE);
+ void ReadTrackletsFromMemory(void* );
+
+ private:
+ AliHLTTRDTrack(const AliHLTTRDTrack& inTrack);
+ AliHLTTRDTrack& operator=(const AliHLTTRDTrack& inTrack);
+ void InitArrays();
+
+ AliHLTUInt32_t fSize; // Size of the track with tracklets and clusters in the memory
+ AliTRDtrackV1* fTRDtrack;
+
+ /* ======== From AliTRDtrackV1 ======== */
+ enum { kNdet = 540
+ , kNstacks = 90
+ , kNplane = AliESDtrack::kTRDnPlanes
+ , kNcham = 5
+ , kNsect = 18
+ , kNslice = 3
+ , kNMLPslice = 8 };
+
+ /* Defenitely need */
+ UChar_t fPIDquality; // No of planes used for PID calculation
+ AliHLTTRDTracklet *fTracklet[kNplane]; // Tracklets array defining the track
+
+ /* Probably need */
+ Double32_t fPID[AliPID::kSPECIES];// PID probabilities
+ Double32_t fBudget[3]; // Integrated material budget
+ Double32_t fDE; // Integrated delta energy
+
+ /* ======== From AliKalmanTrack ======== */
+
+ /* Defenitely need */
+ Double32_t fFakeRatio; // fake ratio
+ Double32_t fChi2; // total chi2 value for this track
+ Double32_t fMass; // mass hypothesis
+ Int_t fLab; // track label
+
+ /* Probably need */
+ Int_t fN; // number of associated clusters
+ Double32_t fIntegratedLength; // integrated length // variables for time integration (S.Radomski@gsi.de)
+
+ /* ======= From AliExternalTrackParam ======== */
+
+ /* Defenitely need */
+ Double32_t fX; // X coordinate for the point of parametrisation
+ Double32_t fAlpha; // Local <-->global coor.system rotation angle
+ Double32_t fP[5]; // The track parameters
+ Double32_t fC[15]; // The track parameter covariance matrix
+
+ /* Probably need */
+ // static Double32_t fgMostProbablePt; // "Most probable" pt (to be used if Bz=0)
+
+};
+
+#endif
#include "AliHLTTRDTrackerV1Component.h"
#include "AliHLTTRDDefinitions.h"
+#include "AliHLTTRDCluster.h"
+#include "AliHLTTRDTrack.h"
#include "TFile.h"
#include "TChain.h"
#include <cerrno>
#include <string>
-// this is a global object used for automatic component registration, do not use this
-AliHLTTRDTrackerV1Component gAliHLTTRDTrackerV1Component;
+#ifdef HAVE_VALGRIND_CALLGRIND_H
+#include <valgrind/callgrind.h>
+#else
+#define CALLGRIND_START_INSTRUMENTATION() do { } while (0)
+#define CALLGRIND_STOP_INSTRUMENTATION() do { } while (0)
+#endif
ClassImp(AliHLTTRDTrackerV1Component);
-AliHLTTRDTrackerV1Component::AliHLTTRDTrackerV1Component()
- : AliHLTProcessor()
- , fOutputPercentage(100) // By default we copy to the output exactly what we got as input
- , fStrorageDBpath("local://$ALICE_ROOT")
- , fCDB(NULL)
- , fField(NULL)
- , fGeometryFileName("")
- , fGeometryFile(NULL)
- , fGeoManager(NULL)
- , fTracker(NULL)
- , fRecoParam(NULL)
- , fReconstructor(NULL)
+AliHLTTRDTrackerV1Component::AliHLTTRDTrackerV1Component():
+ AliHLTProcessor(),
+ fOutputPercentage(100), // By default we copy to the output exactly what we got as input
+ fStrorageDBpath("local://$ALICE_ROOT"),
+ fCDB(NULL),
+ fField(NULL),
+ fGeometryFileName(""),
+ fUseHLTClusters(kFALSE),
+ fUseHLTTracks(kFALSE),
+ fTracker(NULL),
+ fRecoParam(NULL),
+ fReconstructor(NULL)
{
// Default constructor
return new AliHLTTRDTrackerV1Component;
};
+/**
+ * Convert AliTRDtrackV1 to AliHLTTRDTrack
+ * Add HLTTrack to the output, defined by pointer
+ * Fill block desctiptors
+ * Return size of the added to ouput objects
+ */
+//============================================================================
+AliHLTUInt32_t AliHLTTRDTrackerV1Component::AddToOutput(TClonesArray* inTrackArray, AliHLTUInt8_t* output)
+{
+ cout << "\nWriting tracks to the Memory\n ============= \n";
+ AliTRDtrackV1* track = 0;
+ AliHLTUInt32_t addedSize = 0;
+ AliHLTUInt8_t *iterPtr = output;
+ AliHLTTRDTrack * outPtr = (AliHLTTRDTrack*)iterPtr;
+
+ if (inTrackArray){
+ Int_t nbTracks = inTrackArray->GetEntries();
+ for (Int_t iTrack = 0; iTrack<nbTracks; iTrack++){
+ AliHLTUInt32_t trackSize=0;
+
+ track = dynamic_cast<AliTRDtrackV1*>(inTrackArray->At(iTrack));
+ //track->Print();
+
+ AliHLTTRDTrack *hltTrack = new (outPtr) AliHLTTRDTrack(track);
+ trackSize = hltTrack->GetSize();
+ addedSize += trackSize;
+ HLTDebug("addedSize %i, trackSize %i", addedSize, trackSize);
+
+ iterPtr += trackSize;
+ outPtr = (AliHLTTRDTrack*)iterPtr;
+ }
+ }
+ return addedSize;
+
+}
+
int AliHLTTRDTrackerV1Component::DoInit( int argc, const char** argv )
{
// perform initialization. We check whether our relative output size is specified in the arguments.
HLTDebug("Using standard offline tracking.");
i++;
}
+ else if ( strcmp( argv[i], "-useHLTClusters" ) == 0)
+ {
+ fUseHLTClusters = kTRUE;
+ i++;
+ HLTInfo("expecting AliHLTCluster as input");
+ }
+ else if ( strcmp( argv[i], "-useHLTTracks" ) == 0)
+ {
+ fUseHLTTracks = kTRUE;
+ i++;
+ HLTInfo("Using AliHLTTrack to pass data further in the chain");
+ }
else {
HLTError("Unknown option '%s'", argv[i] );
return EINVAL;
}
fReconstructor = new AliTRDReconstructor();
-// fRecoParam->SetChi2Y(.1);
-// fRecoParam->SetChi2Z(5.);
+ // fRecoParam->SetChi2Y(.1);
+ // fRecoParam->SetChi2Z(5.);
fReconstructor->SetRecoParam(fRecoParam);
// write clusters [cw] = true
// track seeding (stand alone tracking) [sa] = true
// drift gas [ar] = false
// sl_tr_0 = StreamLevel_task_Level
// fReconstructor->SetOption("sa,!cw,hlt,sl_tr_0");
- TString recoOptions="sa,sl_cf_0";
+ TString recoOptions="sa,sl_tr_0";
if (bWriteClusters)
{
fReconstructor->SetOption(recoOptions.Data());
HLTDebug("Reconstructor options are: %s",recoOptions.Data());
- fGeometryFile = 0;
- fGeometryFile = TFile::Open(fGeometryFileName.c_str());
- if (fGeometryFile)
- {
+ if((AliGeomManager::GetGeometry()) == NULL){
+
+ if ( TFile::Open(fGeometryFileName.c_str())) {
AliGeomManager::LoadGeometry(fGeometryFileName.c_str());
}
- else
- {
- HLTError("Unable to open file. FATAL!");
- return -1;
+ else {
+ HLTError("Cannot load geometry from file %s",fGeometryFileName.c_str());
+ return EINVAL;
}
+ }
+ else
+ HLTInfo("Geometry Already Loaded");
// create the tracker
fTracker = new AliTRDtrackerV1();
int AliHLTTRDTrackerV1Component::DoDeinit()
{
// Deinitialization of the component
-
+
delete fField;
fField = 0x0;
- // fTracker->SetClustersOwner(kFALSE);
+ fTracker->SetClustersOwner(kFALSE);
delete fTracker;
fTracker = 0x0;
AliTRDcalibDB::Terminate();
- if (fGeometryFile)
- {
- fGeometryFile->Close();
- delete fGeometryFile;
- fGeometryFile = 0x0;
- }
-
return 0;
}
-int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData & /*evtData*/,
- AliHLTComponentTriggerData & /*trigData*/ )
+int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtData,
+ const AliHLTComponentBlockData* blocks,
+ AliHLTComponent_TriggerData& /*trigData*/,
+ AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size,
+ vector<AliHLTComponent_BlockData>& outputBlocks )
{
// Process an event
Bool_t bWriteClusters = fReconstructor->IsWritingClusters();
- HLTDebug("Output percentage set to %lu %%", fOutputPercentage );
- HLTDebug("NofBlocks %lu", GetNumberOfInputBlocks() );
+ HLTDebug("NofBlocks %lu", evtData.fBlockCnt );
+ AliHLTUInt32_t totalSize = 0, offset = 0;
AliHLTUInt32_t dBlockSpecification = 0;
-
- //implement a usage of the following
- // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
- // AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
- // void *triggerData = trigData.fData;
- //HLTDebug("Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
-
- AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkClusterDataType );
- if (dblock != 0)
- {
- AliHLTComponentDataType inputDataType = dblock->fDataType;
- HLTDebug( "Event 0x%08LX (%Lu) received datatype: %s",
- GetEventId(), GetEventId(),
- DataType2Text(inputDataType).c_str());
- dBlockSpecification = dblock->fSpecification;
- }
- else
+ vector<AliHLTComponent_DataType> expectedDataTypes;
+ GetInputDataTypes(expectedDataTypes);
+ if (evtData.fEventID == 1)
+ CALLGRIND_START_INSTRUMENTATION();
+ for ( unsigned long iBlock = 0; iBlock < evtData.fBlockCnt; iBlock++ )
{
- HLTWarning("First Input Block not found! 0x%x", dblock);
- return 0;
+ const AliHLTComponentBlockData &block = blocks[iBlock];
+ offset = totalSize;
+ AliHLTComponentDataType inputDataType = block.fDataType;
+ Bool_t correctDataType = kFALSE;
+
+ for(UInt_t i = 0; i < expectedDataTypes.size(); i++)
+ if( expectedDataTypes.at(i) == inputDataType)
+ correctDataType = kTRUE;
+ if (!correctDataType)
+ {
+ HLTDebug( "Block # %i/%i; Event 0x%08LX (%Lu) Wrong received datatype: %s - Skipping",
+ iBlock, evtData.fBlockCnt-1,
+ evtData.fEventID, evtData.fEventID,
+ DataType2Text(inputDataType).c_str());
+ continue;
+ }
+ else
+ HLTDebug("We get the right data type: Block # %i/%i; Event 0x%08LX (%Lu) Received datatype: %s",
+ iBlock, evtData.fBlockCnt-1,
+ evtData.fEventID, evtData.fEventID,
+ DataType2Text(inputDataType).c_str());
+
+
+ TTree *clusterTree = 0x0;
+ TClonesArray* clusterArray = 0x0;
+ ReadAndLoadClusters(clusterTree, clusterArray, &block);
+
+ // maybe it is not so smart to create it each event? clear is enough ?
+ AliESDEvent *esd = new AliESDEvent();
+ esd->CreateStdContent();
+ fTracker->Clusters2Tracks(esd);
+
+ //here transport the esd tracks further
+ Int_t nTracks = esd->GetNumberOfTracks();
+ Int_t nTRDTracks = esd->GetNumberOfTrdTracks();
+ HLTInfo("Number of tracks == %d == Number of TRD tracks %d", nTracks, nTRDTracks);
+
+ TClonesArray* trdTracks = fTracker->GetListOfTracks();
+
+ if (trdTracks)
+ totalSize += TransportTracks(trdTracks, outputPtr, outputBlocks, offset, dBlockSpecification);
+ else
+ HLTDebug("Bad array trdTracks = 0x%x", trdTracks);
+ HLTDebug("totalSize: %i", totalSize);
+
+// if ( totalSize > allocSize )
+// {
+// HLTError("Too much data; Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
+// totalSize, size );
+// return EMSGSIZE;
+// }
+
+ //here we are deleting clusters (but not the TClonesArray itself)
+ fTracker->UnloadClusters();
+
+ AliTRDReconstructor::SetClusters(0x0);
+ delete esd;
+ if (bWriteClusters)
+ delete clusterTree;
+ else{
+ //clusterArray->Delete();
+ delete clusterArray;
+ }
+
}
+ size = totalSize;
+ HLTDebug("Event is done. size written to the output is %i", size);
+ // CALLGRIND_STOP_INSTRUMENTATION();
+ return 0;
+}
+
+
+/**
+ * ReadClusters from the component input and load them to the tracker
+ */
+//============================================================================
+void AliHLTTRDTrackerV1Component::ReadAndLoadClusters(TTree *inClusterTree,
+ TClonesArray *inClusterArray, const AliHLTComponentBlockData *inBlock)
+{
+ Bool_t bWriteClusters = fReconstructor->IsWritingClusters();
+ const AliHLTComponentBlockData &block = *inBlock;
+
- int ibForce = 0;
-
TObject *tobjin = 0x0;
+ int ibForce = 0; // almost obsolet
- TTree *clusterTree = 0x0;
- TClonesArray *clusterArray = 0x0;
if (bWriteClusters){
tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkClusterDataType, "TTree", ibForce);
HLTDebug("1stBLOCK; Pointer = 0x%x", tobjin);
- clusterTree = (TTree*)tobjin;
-
- // while (tobjin != 0)
- // {
- if (clusterTree)
+ inClusterTree = (TTree*)tobjin;
+ if (inClusterTree)
{
- HLTDebug("CLUSTERS; Pointer to TTree = 0x%x Name = %s", clusterTree, clusterTree->GetName());
- HLTDebug("TTree of clusters: nbEntries = %i", clusterTree->GetEntriesFast());
- fTracker->LoadClusters(clusterTree);
+ HLTDebug("CLUSTERS; Pointer to TTree = 0x%x Name = %s", inClusterTree, inClusterTree->GetName());
+ HLTDebug("TTree of clusters: nbEntries = %i", inClusterTree->GetEntriesFast());
+ fTracker->LoadClusters(inClusterTree);
}
else
{
- HLTError("First Input Block not a TTree 0x%x", tobjin);
+ HLTError("First Input Block is not a TTree 0x%x", tobjin);
}
}
- else{
- tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkClusterDataType, "TClonesArray", ibForce);
- HLTDebug("1stBLOCK; Pointer = 0x%x", tobjin);
- clusterArray = (TClonesArray*)tobjin;
- if (clusterArray)
- {
- HLTDebug("CLUSTERS; Pointer to TClonesArray = 0x%x Name = %s", clusterArray, clusterArray->GetName());
- HLTDebug("TClonesArray of clusters: nbEntries = %i", clusterArray->GetEntriesFast());
- Int_t nb = clusterArray->GetEntriesFast();
- for (Int_t i=0; i<nb; i++){
- //AliTRDcluster * cluster = (AliTRDcluster* ) clusterArray->At(i);
- //HLTDebug("Cluster[%i]: detector %i", i, cluster->GetDetector());
- }
-
- fTracker->LoadClusters(clusterArray);
- }
- else
- {
- HLTError("First Input Block not a TClonesArray 0x%x", tobjin);
- }
- }
-
- // maybe it is not so smart to create it each event? clear is enough ?
- AliESDEvent *esd = new AliESDEvent();
- esd->CreateStdContent();
- fTracker->Clusters2Tracks(esd);
-
- //here transport the esd tracks further
- Int_t nTracks = esd->GetNumberOfTracks();
- Int_t nTRDTracks = esd->GetNumberOfTrdTracks();
- HLTInfo("Number of tracks == %d == Number of TRD tracks %d", nTracks, nTRDTracks);
- //esd->Print();
- //PushBack(esd, AliHLTTRDDefinitions::fgkTRDSAEsdDataType);
-
- // extract the friend ?
- // AliESDfriend *esdFriend = new AliESDfriend();
- // esd->GetESDfriend(esdFriend);
- // PushBack(esdFriend, AliHLTTRDDefinitions::fgkTRDSAEsdDataType);
- // delete esdFriend;
-
- TClonesArray* trdTracks = fTracker->GetListOfTracks();
-
- if (trdTracks)
+ else if (fUseHLTClusters)
{
- nTracks=trdTracks->GetEntriesFast();
- if (nTracks>0)
+ inClusterArray = new TClonesArray("AliTRDcluster"); // would be nice to allocate memory for all clusters here.
+ ReadClusters(inClusterArray, block.fPtr, block.fSize);
+ HLTDebug("TClonesArray of clusters: nbEntries = %i", inClusterArray->GetEntriesFast());
+ fTracker->LoadClusters(inClusterArray);
+ }
+ else
+ {
+ tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkClusterDataType, "TClonesArray", ibForce);
+ HLTDebug("1stBLOCK; Pointer = 0x%x", tobjin);
+ inClusterArray = (TClonesArray*)tobjin;
+ if (inClusterArray)
{
- HLTDebug("We have an output array: pointer to trdTracks = 0x%x, nbEntries = %i", trdTracks, nTracks);
- HLTDebug("We have an output array: pointer to trdTracks = 0x%x, nbEntries = %i", trdTracks, nTracks);
-
- trdTracks->BypassStreamer(kFALSE);
- PushBack(trdTracks, AliHLTTRDDefinitions::fgkTRDSATracksDataType);
- //trdTracks->Delete();
- //delete trdTracks;
+ HLTDebug("CLUSTERS; Pointer to TClonesArray = 0x%x Name = %s", inClusterArray, inClusterArray->GetName());
+ HLTDebug("TClonesArray of clusters: nbEntries = %i", inClusterArray->GetEntriesFast());
+ fTracker->LoadClusters(inClusterArray);
+ }
+ else
+ {
+ HLTError("First Input Block not a TClonesArray 0x%x", tobjin);
}
}
- else {
- Bool_t foo; foo=kFALSE; //In order to supress warning in non-debug compile
- HLTDebug("Bad array trdTracks = 0x%x", trdTracks);
- }
+}
+/**
+ * Read cluster to the TClonesArray from the memory
+ */
+//============================================================================
+Int_t AliHLTTRDTrackerV1Component::ReadClusters(TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size)
+{
+ //HLTDebug("\nReading clusters from the Memory\n ============= \n");
+ AliHLTTRDCluster * curCluster;
+ UInt_t clusterSize = sizeof(AliHLTTRDCluster), curSize = 0;
+ Int_t i=0;
- //here we are deleting clusters (but not the TClonesArray itself)
- fTracker->UnloadClusters();
- delete esd;
- if (bWriteClusters)
- delete clusterTree;
- else
- delete clusterArray;
-
- HLTDebug("Event done.");
+ curCluster = (AliHLTTRDCluster*) inputPtr;
+ while (curSize + clusterSize <= size)
+ {
+ // HLTDebug(" fX = %f; fY = %f; fZ = %f", curCluster->fX, curCluster->fY, curCluster->fZ);
+
+ AliTRDcluster* curTRDCluster = new((*outArray)[i]) AliTRDcluster();
+ curCluster->ExportTRDCluster(curTRDCluster);
+ // HLTDebug(" fX = %f; fY = %f; fZ = %f", curTRDCluster->GetX(), curTRDCluster->GetY(), curTRDCluster->GetZ());
+ curSize += clusterSize;
+ i++;
+ curCluster++;
+ //cout << " current readed size is " << curSize << "/" << size << endl;
+ }
+
+ return i;
+}
+/**
+ * Transport tracks to the next component
+ * Return Numbers of bytes written to the output
+ */
+//============================================================================
+AliHLTUInt32_t AliHLTTRDTrackerV1Component::TransportTracks(TClonesArray *inTracksArray, AliHLTUInt8_t* output,
+ vector<AliHLTComponent_BlockData>& outputBlocks, AliHLTUInt32_t inOffset, AliHLTUInt32_t inSpec)
+{
+ Int_t nbTracks=inTracksArray->GetEntriesFast();
+ if (nbTracks>0)
+ {
+ HLTDebug("We have an output array: pointer to inTracksArray = 0x%x, nbEntries = %i", inTracksArray, nbTracks);
+ if (fUseHLTTracks){
+ // Using low-level interface
+ // with interface classes
+ AliHLTUInt32_t addedSize = AddToOutput(inTracksArray, output);
+
+ // Fill block
+ AliHLTComponentBlockData bd;
+ FillBlockData( bd );
+
+ bd.fPtr = output;
+ bd.fOffset = inOffset;
+ bd.fSize = addedSize;
+ bd.fSpecification = inSpec;
+ bd.fDataType = AliHLTTRDDefinitions::fgkTRDSATracksDataType;
+ outputBlocks.push_back( bd );
+ HLTDebug("BD fPtr 0x%x, fOffset %i, fSize %i, fSpec 0x%x", bd.fPtr, bd.fOffset, bd.fSize, bd.fSpecification);
+
+ return addedSize;
+ }
+ else{
+ inTracksArray->BypassStreamer(kFALSE);
+ PushBack(inTracksArray, AliHLTTRDDefinitions::fgkTRDSATracksDataType);
+ return 0;
+ }
+
+ }
return 0;
+
}
-
-///////////////////////////////
-/*
- consider transporting TRD tracks only as they might have signigicantly smaller size... on the other hand you will need to prodece ESDs at some point...
-
- // this is for ESDtrack
- // for (Int_t it = 0; it < nTracks; it++)
- // {
- // AliESDtrack* track = esd->GetTrack(it);
- // HLTInfo("Track %d 0x%x Pt %1.2f", it, track, track->Pt());
- // //PushBack(track, AliHLTTRDDefinitions::fgkTRDSATracksDataType, ++dBlockSpecification);
- // PushBack(track, AliHLTTRDDefinitions::fgkTRDSATracksDataType);
- // }
-
- // one can do similar things with the TRDtrack
- esd->GetNumberOfTrdTracks();
- and then
- for (i;;)
- AliESDTrdTrack *trdtrack = esd->GetTrdTrack(i)
-*/
-
#include "AliHLTProcessor.h"
class TFile;
+class TTree;
+
class TGeoManager;
class AliCDBManager;
class AliMagFMaps;
AliHLTComponent* Spawn();
protected:
+ AliHLTUInt32_t AddToOutput (TClonesArray* inTrackArray, AliHLTUInt8_t* output);
+ Int_t ReadClusters (TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size);
+ void ReadAndLoadClusters(TTree *inClusterTree, TClonesArray *inClusterArray, const AliHLTComponentBlockData *inBlock);
+ AliHLTUInt32_t TransportTracks(TClonesArray *inTracksArray, AliHLTUInt8_t* output,
+ vector<AliHLTComponent_BlockData>& outputBlocks, AliHLTUInt32_t inOffset, AliHLTUInt32_t inSpec);
// Protected functions to implement AliHLTComponent's interface.
// These functions provide initialization as well as the actual processing
int DoInit( int argc, const char** argv );
int DoDeinit();
- int DoEvent( const AliHLTComponentEventData & evtData,
- AliHLTComponentTriggerData & trigData );
-
+ int DoEvent( const AliHLTComponentEventData& evtData,
+ const AliHLTComponentBlockData* blocks,
+ AliHLTComponent_TriggerData& /*trigData*/,
+ AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size,
+ vector<AliHLTComponent_BlockData>& outputBlocks );
using AliHLTProcessor::DoEvent;
private:
AliMagFMaps* fField; //! magn. field settings
string fGeometryFileName; // Path to geometry file
- TFile *fGeometryFile; //! // Pointer to the geom root file
- TGeoManager *fGeoManager; //! Pointer to geometry manager
+ Bool_t fUseHLTClusters;
+ Bool_t fUseHLTTracks;
AliTRDtrackerV1 *fTracker;//! Offline-pure/HLT tracker V1
AliTRDrecoParam *fRecoParam; //! Offline reco params
--- /dev/null
+#include "AliHLTTRDTracklet.h"
+#include "AliHLTTRDCluster.h"
+
+/**
+ * Default Constructor
+ */
+//============================================================================
+AliHLTTRDTracklet::AliHLTTRDTracklet():
+ fTRDtracklet(NULL),
+ fSize(sizeof(AliHLTTRDTracklet)),
+ fSigmaY(-1),
+ fSigmaY2(-1),
+ fTilt(-1),
+ fPadLength(-1),
+ fX0(-1),
+ fMeanz(-1),
+ fZProb(-1),
+ fN(-1),
+ fN2(-1),
+ fNUsed(-1),
+ fFreq(-1),
+ fNChange(-1),
+ fMPads(-1),
+ fC(-1),
+ fCC(-1),
+ fChi2(-1),
+ fChi2Z(-1),
+ fDet(-1),
+ fMom(-1),
+ fdX(-1)
+{
+ InitArrays();
+}
+
+/**
+ * Main Constructor
+ */
+//============================================================================
+AliHLTTRDTracklet::AliHLTTRDTracklet(AliTRDseedV1 * inTracklet):
+ fTRDtracklet(NULL),
+ fSize(sizeof(AliHLTTRDTracklet)),
+ fSigmaY(-1),
+ fSigmaY2(-1),
+ fTilt(-1),
+ fPadLength(-1),
+ fX0(-1),
+ fMeanz(-1),
+ fZProb(-1),
+ fN(-1),
+ fN2(-1),
+ fNUsed(-1),
+ fFreq(-1),
+ fNChange(-1),
+ fMPads(-1),
+ fC(-1),
+ fCC(-1),
+ fChi2(-1),
+ fChi2Z(-1),
+ fDet(-1),
+ fMom(-1),
+ fdX(-1)
+{
+ InitArrays();
+
+ fTRDtracklet = inTracklet;
+ CopyDataMembers();
+ // Print(kFALSE);
+ AddClusters();
+}
+
+/**
+ * Add clusters to the HLTTRDTracklet
+ */
+//============================================================================
+void AliHLTTRDTracklet::AddClusters()
+{
+ for (Int_t iTimeBin = 0; iTimeBin < knTimebins; iTimeBin++)
+ {
+// if (fClusters[iTimeBin])
+// HLTWarning("Trying to rewrite cluster in tracklet. Not good.");
+ AliTRDcluster* trdCluster = fTRDtracklet->GetClusters(iTimeBin);
+ if (trdCluster){
+ AliHLTTRDCluster * hltCluster = new (GetEndPointer()) AliHLTTRDCluster(trdCluster);
+ fSize += hltCluster->GetSize();
+ //HLTInfo("cluster %i; adr 0x%x; endPointer 0x%x; fSize %i", iTimeBin, hltCluster, GetEndPointer(), fSize);
+ fClusters[iTimeBin] = hltCluster;
+ }
+ else
+ fClusters[iTimeBin] = NULL;
+
+ }
+}
+
+/**
+ * Copy simple (non-pointer) data members from TRDTracklet to HLTTRDTracklet
+ */
+//============================================================================
+void AliHLTTRDTracklet::CopyDataMembers()
+{
+ for (Int_t i=0; i < 2; i++){
+ fYref[i] = fTRDtracklet->GetYref(i);
+ fZref[i] = fTRDtracklet->GetZref(i);
+ }
+ fSigmaY = fTRDtracklet->GetSigmaY();
+ fSigmaY2 = fTRDtracklet->GetSigmaY2();
+ fTilt = fTRDtracklet->GetTilt();
+ fPadLength = fTRDtracklet->GetPadLength();
+
+ fX0 = fTRDtracklet->GetX0();
+ for (Int_t i = 0; i < knTimebins; i++){
+ fX[i] = fTRDtracklet->GetX(i);
+ fY[i] = fTRDtracklet->GetY(i);
+ fZ[i] = fTRDtracklet->GetZ(i);
+ fIndexes[i] = fTRDtracklet->GetIndexes(i);
+ fUsable[i] = fTRDtracklet->IsUsable(i);
+ }
+
+ for (Int_t i=0; i < 2; i++){
+ fYfit[i] = fTRDtracklet->GetYfit(i);
+ fZfit[i] = fTRDtracklet->GetZfit(i);
+ fYfitR[i] = fTRDtracklet->GetYfitR(i);
+ fZfitR[i] = fTRDtracklet->GetZfitR(i);
+ fLabels[i] = fTRDtracklet->GetLabels(i);
+ }
+
+ fMeanz = fTRDtracklet->GetMeanz();
+ fZProb = fTRDtracklet->GetZProb();
+ fN = fTRDtracklet->GetNbClusters();
+ fN2 = fTRDtracklet->GetN2();
+ fNUsed = fTRDtracklet->GetNUsed();
+ fFreq = fTRDtracklet->GetFreq();
+ fNChange = fTRDtracklet->GetNChange();
+ fMPads = fTRDtracklet->GetMPads();
+
+ fC = fTRDtracklet->GetC();
+ fCC = fTRDtracklet->GetCC();
+ fChi2 = fTRDtracklet->GetChi2();
+ fChi2Z = fTRDtracklet->GetChi2Z();
+
+ fDet = fTRDtracklet->GetDetector();
+ fMom = fTRDtracklet->GetMomentum();
+ fdX = fTRDtracklet->GetdX();
+
+}
+
+/**
+ * Copy data to the output TRDseedV1
+ */
+//============================================================================
+void AliHLTTRDTracklet::ExportTRDTracklet(AliTRDseedV1 *outTracklet)
+{
+ outTracklet->Reset();
+ /* ======= From AliTRDseedV1 ======== */
+ outTracklet->SetDetector(fDet);
+ outTracklet->SetMomentum(fMom);
+ outTracklet->SetDX(fdX);
+
+ /* ======= From AliTRDseed ======== */
+ for (Int_t i=0; i < 2; i++){
+ outTracklet->SetYref(i, fYref[i]);
+ outTracklet->SetZref(i, fZref[i]);
+ }
+
+ outTracklet->SetSigmaY(fSigmaY);
+ outTracklet->SetSigmaY2(fSigmaY2);
+ outTracklet->SetTilt(fTilt);
+ outTracklet->SetPadLength(fPadLength);
+ outTracklet->SetX0(fX0);
+
+ for (Int_t i=0; i < knTimebins; i++){
+ outTracklet->SetX(i,fX[i]);
+ outTracklet->SetX(i,fY[i]);
+ outTracklet->SetX(i,fZ[i]);
+ outTracklet->SetIndexes(i, fIndexes[i]);
+ outTracklet->SetUsable(i, fUsable[i]);
+ }
+ for (Int_t i=0; i < 2; i++){
+ outTracklet->SetYfit(i,fYfit[i]);
+ outTracklet->SetYfitR(i,fYfitR[i]);
+ outTracklet->SetZfit(i,fZfit[i]);
+ outTracklet->SetZfitR(i,fZfitR[i]);
+ outTracklet->SetLabels(i,fLabels[i]);
+ }
+
+ outTracklet->SetMeanz(fMeanz);
+ outTracklet->SetZProb(fZProb);
+ outTracklet->SetN(fN);
+ outTracklet->SetN2(fN2);
+ outTracklet->SetNUsed(fNUsed);
+ outTracklet->SetFreq(fFreq);
+ outTracklet->SetNChange(fNChange);
+ outTracklet->SetMPads(fMPads);
+ outTracklet->SetC(fC);
+ outTracklet->SetCC(fCC);
+ outTracklet->SetChi2(fChi2);
+ outTracklet->SetChi2Z(fChi2Z);
+
+ for (Int_t iCluster = 0; iCluster < knTimebins; iCluster++){
+ if (fClusters[iCluster]){
+ AliTRDcluster *trdCluster = new AliTRDcluster();
+ fClusters[iCluster]->ExportTRDCluster(trdCluster);
+ outTracklet->SetClusters(iCluster, trdCluster);
+ }
+ }
+
+}
+
+
+/**
+ * Init arrays
+ */
+//============================================================================
+void AliHLTTRDTracklet::InitArrays()
+{
+ for (Int_t i=0; i < knTimebins; i++){
+ fClusters[i] = NULL;
+ }
+
+ for (Int_t i=0; i < 2; i++){
+ fYref[i] = -1;
+ fZref[i] = -1;
+ }
+ for (Int_t i = 0; i < knTimebins; i++){
+ fX[i] = -1;
+ fY[i] = -1;
+ fZ[i] = -1;
+ fIndexes[i] = -1;
+ fUsable[i] = -1;
+ }
+
+ for (Int_t i=0; i < 2; i++){
+ fYfit[i] = -1;
+ fZfit[i] = -1;
+ fYfitR[i] = -1;
+ fZfitR[i] = -1;
+ fLabels[i] = -1;
+ }
+
+}
+
+/**
+ * Prints main info about tracklet
+ */
+//============================================================================
+void AliHLTTRDTracklet::Print(Bool_t printClusters)
+{
+ //printf("--hltTracklet-- addr 0x%p(%i); fSize %i\n", this, (int)this, fSize);
+ printf(" fDet %i; dMom %f; fdX %f fN %i\n", fDet, fMom, fdX, fN);
+
+ if (printClusters){
+
+ for (Int_t iCluster = 0; iCluster < knTimebins; iCluster++){
+ printf(" [%i] ",iCluster);
+ if (fClusters[iCluster]){
+ fClusters[iCluster]->Print();
+ }
+ else
+ printf(" NULL\n");
+ }
+ }
+
+}
+
+/**
+ * Read clusters to TRDtracklet from the memory
+ */
+//============================================================================
+void AliHLTTRDTracklet::ReadClustersFromMemory(void *input)
+{
+ AliHLTUInt8_t *iterPtr = (AliHLTUInt8_t*) input;
+ AliHLTTRDCluster* hltCluster = NULL;
+
+ for (Int_t iCluster = 0; iCluster < knTimebins; iCluster++){
+ // if we had something in the fClusters[iCluster] before copying,
+ // then this entry in the array should not be empty. Fill it.
+ if (fClusters[iCluster]){
+ hltCluster = (AliHLTTRDCluster*) iterPtr;
+ fClusters[iCluster] = hltCluster;
+ iterPtr += hltCluster->GetSize();
+ //hltCluster->Print();
+ }
+
+ }
+}
--- /dev/null
+#ifndef ALIHLTTRDTRACKLET_H
+#define ALIHLTTRDTRACKLET_H
+
+#include "AliTRDseedV1.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTLogging.h"
+class AliHLTTRDCluster;
+
+class AliHLTTRDTracklet
+{
+ public:
+ AliHLTTRDTracklet();
+ AliHLTTRDTracklet(AliTRDseedV1* inTracklet);
+
+ void ExportTRDTracklet(AliTRDseedV1* outTracklet);
+ void AddClusters();
+ void CopyDataMembers();
+ AliHLTUInt8_t *GetEndPointer() // Returns pointer to the end of the tracklet
+ { return ((AliHLTUInt8_t *) this + fSize); };
+ AliHLTUInt32_t GetSize(){ return fSize; };
+ void Print(Bool_t printClusters = kTRUE);
+ void ReadClustersFromMemory(void *input);
+
+ private:
+ AliHLTTRDTracklet(const AliHLTTRDTracklet&);
+ AliHLTTRDTracklet& operator=(const AliHLTTRDTracklet&);
+ void InitArrays();
+
+ AliTRDseedV1* fTRDtracklet;
+ AliHLTUInt32_t fSize; // Size of the tracklet with clusters in the memory
+
+
+ /* ======= From AliTRDseed ======== */
+ enum { knTimebins = 35 };
+
+ /* Defenitely need */
+ AliHLTTRDCluster *fClusters[knTimebins]; // Clusters
+ Float_t fYref[2]; // Reference y
+ Float_t fZref[2]; // Reference z
+ Float_t fSigmaY; // "Robust" sigma in Y - constant fit
+ Float_t fSigmaY2; // "Robust" sigma in Y - line fit
+
+ /* Probably need */
+ Float_t fTilt; // Tilting angle
+ Float_t fPadLength; // Pad length
+ Float_t fX0; // X0 position
+ Float_t fX[knTimebins]; //! X position
+ Float_t fY[knTimebins]; //! Y position
+ Float_t fZ[knTimebins]; //! Z position
+ Int_t fIndexes[knTimebins]; //! Indexes
+ Bool_t fUsable[knTimebins]; // Indication - usable cluster
+ Float_t fYfit[2]; // Y fit position +derivation
+ Float_t fYfitR[2]; // Y fit position +derivation
+ Float_t fZfit[2]; // Z fit position
+ Float_t fZfitR[2]; // Z fit position
+ Float_t fMeanz; // Mean vaue of z
+ Float_t fZProb; // Max probbable z
+ Int_t fLabels[2]; // Labels
+ Int_t fN; // Number of associated clusters
+ Int_t fN2; // Number of not crossed
+ Int_t fNUsed; // Number of used clusters
+ Int_t fFreq; // Frequency
+ Int_t fNChange; // Change z counter
+ Float_t fMPads; // Mean number of pads per cluster
+
+ Float_t fC; // Curvature
+ Float_t fCC; // Curvature with constrain
+ Float_t fChi2; // Global chi2
+ Float_t fChi2Z; // Global chi2
+
+ /* ======= From AliTRDseedV1 ======== */
+
+ /* Defenitely need */
+ Int_t fDet; // TRD detector
+ Float_t fMom; // Momentum estimate for tracklet [GeV/c]
+ Float_t fdX; // length of time bin
+
+ /* Probably need */
+
+};
+
+#endif
AliHLTTRDTrackerV1Component.h \
AliTRDclusterizerHLT.h \
AliHLTTRDEsdWriterComponent.h \
- AliHLTTRDCalibrationComponent.h
+ AliHLTTRDCalibrationComponent.h \
+ AliHLTTRDCluster.h \
+ AliHLTTRDTracklet.h \
+ AliHLTTRDTrack.h \
+ AliHLTTRDAgent.h
# library sources
MODULE_SRCS= \