#include "AliHLTGlobalBarrelTrack.h"
#include "AliHLTCaloClusterDataStruct.h"
#include "AliHLTCaloClusterReader.h"
-
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "TGeoManager.h"
+#include "TRefArray.h"
+#include "TString.h"
+#include "TMap.h"
/** ROOT macro for the implementation of ROOT specific class methods */
AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent;
ClassImp(AliHLTGlobalTrackMatcherComponent);
AliHLTGlobalTrackMatcherComponent::AliHLTGlobalTrackMatcherComponent() :
+ fOCDBEntry("HLT/ConfigHLT/GlobalTrackMatcher"), //TODO
+ fMethod(1), //Method 1(PbPb) 2(pp)
fTrackMatcher(NULL),
fNEvents(0),
fBz(-9999999),
// see header file for class documentation
// XXX TODO: Find more realistic values.
constBase = 80000;
- inputMultiplier = 0;
+ inputMultiplier = 1;
}
AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn()
return new AliHLTGlobalTrackMatcherComponent;
}
-Int_t AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv ) {
-
+int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv )
+{
+ Int_t iResult=ConfigureFromCDBTObjString(fOCDBEntry); //MARCEL
+ // configure from the command line parameters if specified
+ if (iResult>=0 && argc>0) {
+ iResult=ConfigureFromArgumentString(argc, argv);
+ HLTImportant("Extrapolation Method from argument string: %d", fMethod);
+ } else if ( iResult >=0 ) {
+ HLTImportant("Extrapolation Method from OCDB database entry: %d", fMethod);
+ }
+
+
//BALLE TODO, use command line values to initialise matching vaules
- Int_t iResult = argc;
-
+ // init
+// Int_t iResult = argc;
+// iResult = argc;
- if(!(argc > 0)){
- HLTError("Component must be configured with detector as first parameter, either \"PHOS\" or \"EMCAL\"");
- return -ENODEV;
- } else {
- TString allArgs = "";
-
- for ( int i = 0; i < argc; i++ ) {
- if ( !allArgs.IsNull() ) allArgs += " ";
- allArgs += argv[i];
- }
-
- HLTInfo("Configuring with string \"%s\"", allArgs.Data());
+ if(argc > 0){
+ HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]);
}
- if(!strcmp("PHOS", argv[0])) {
- fTrackMatcher = new AliHLTGlobalTrackMatcher();
- fTrackMatcher->SetMaxX( 355. + 70. );
- fTrackMatcher->SetMaxZ( 64. + 70. );
- fTrackMatcher->SetYSign(kFALSE);
- fTrackMatcher->SetRadius(460.);
- fTrackMatcher->SetMatchDistance(40.*40);
- } else if(!strcmp("EMCAL", argv[0])) {
- fTrackMatcher = new AliHLTGlobalTrackMatcher();
- fTrackMatcher->SetMaxX( 500. + 70. );
- fTrackMatcher->SetMaxZ( 500. + 70. );
- fTrackMatcher->SetYSign(kTRUE);
- fTrackMatcher->SetRadius(470.);
- fTrackMatcher->SetMatchDistance(40.*40);
- } else {
- HLTError("Component must be configured with detector as first parameter, either \"PHOS\" or \"EMCAL\"");
- return -ENODEV;
- }
-
- if(!fTrackArray){
- fTrackArray = new TObjArray();
- fTrackArray->SetOwner(kFALSE);
- }
-
if(!fClusterReader)
fClusterReader = new AliHLTCaloClusterReader();
-
+
fBz = GetBz();
if(fBz == -999999) {
HLTError("Magnetic field not properly set, current value: %d", fBz);
- return -ENODEV;
}
- return 0;
-}
+ if(!fTrackMatcher)
+ fTrackMatcher = new AliHLTGlobalTrackMatcher();
+
+ fNEvents = 0;
+
+ if(!fTrackArray){
+ fTrackArray = new TObjArray();
+ fTrackArray->SetOwner(kFALSE);
+ }
+
+ //*** GeoManager ***
+ AliCDBPath path("GRP","Geometry","Data");
+ AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
+ if (pEntry) {
+ if(!gGeoManager) {
+ gGeoManager = (TGeoManager*)pEntry->GetObject();
+ }
+ }
+ else {
+ HLTError("can not fetch object \"%s\" from CDB",path.GetPath().Data());
+ }
+ // ****
+
+ return iResult;
+}
-Int_t AliHLTGlobalTrackMatcherComponent::DoDeinit() {
+int AliHLTGlobalTrackMatcherComponent::DoDeinit()
+{
// see header file for class documentation
Int_t iResult = 1;
fClusterReader = NULL;
+ fNEvents = 0;
+
return iResult;
}
-
-Int_t AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) {
+int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
+{
//See header file for documentation
-
Int_t iResult = 0;
if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
return 0;
+
+ if(!IsDataEvent()){//marcel test
+ return 0;//marcel test
+ }//marcel test
- fTrackArray->Clear();
- vector<AliHLTGlobalBarrelTrack> tracks;
+ fNEvents++;
+
+ //Loop over TPC blocks
+ //BALLE TODO check that the tracks in the TObjArray are fine over several blocks
+
+ fTrackArray->Clear();
+ vector<AliHLTGlobalBarrelTrack> tracks;
- for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()) {
-
- if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
- for(UInt_t it = 0; it < tracks.size(); it++) {
- fTrackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
- }
- } else {
- HLTError("Converting tracks to vector failed");
- }
+ for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()) {
+
+ if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
+ for(UInt_t it = 0; it < tracks.size(); it++) {
+ AliHLTGlobalBarrelTrack track = tracks.at(it);
+ fTrackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
+ }
+ } else {
+ HLTWarning("Converting tracks to vector failed");
+ }
- ///Push the TPC blocks on, without changes
- PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
- }
-
- //Get the clusters
- AliHLTCaloClusterDataStruct * caloClusterStruct;
- vector<AliHLTCaloClusterDataStruct*> clusterVec;
-
- for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
- AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
- fClusterReader->SetMemory(caloClusterHeader);
+ // //Push the TPC block on, without any changes
+ //PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
+ }
- if ( (caloClusterHeader->fNClusters) < 0) {
- HLTError("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
- continue;
- } else {
- clusterVec.reserve(clusterVec.size()+(int) (caloClusterHeader->fNClusters));
- while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
- clusterVec.push_back(caloClusterStruct);
- }
- }
- }
-
- iResult = fTrackMatcher->Match(fTrackArray, clusterVec, fBz);
-
- for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
- PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
- }
-
- fTrackArray->Clear();
+ AliHLTCaloClusterDataStruct * caloClusterStruct;
+ //Get the PHOS Clusters
+ vector<AliHLTCaloClusterDataStruct*> phosClustersVector;
- return iResult;
+ for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS); pBlock!=NULL; pBlock=GetNextInputBlock()) {
+ AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
+ fClusterReader->SetMemory(caloClusterHeader);
+ if ( (caloClusterHeader->fNClusters) < 0) {
+ HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
+ continue;
+ } else {
+ phosClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + phosClustersVector.size() );
+ while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
+ phosClustersVector.push_back(caloClusterStruct);
+ }
+ }
+ }
+
+ //Get the EMCAL Clusters
+ vector<AliHLTCaloClusterDataStruct*> emcalClustersVector;
+ for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL); pBlock!=NULL; pBlock=GetNextInputBlock()) {
+ AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
+ fClusterReader->SetMemory(caloClusterHeader);
+// HLTInfo("\n EMCAL: estou aqui");//marcel
+ if ( (caloClusterHeader->fNClusters) < 0) {
+ HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
+ continue;
+ } else {
+ emcalClustersVector.reserve( (int) (caloClusterHeader->fNClusters) + emcalClustersVector.size() );
+ while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
+ emcalClustersVector.push_back(caloClusterStruct);
+ }
+ }
+ }
+
+ iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, emcalClustersVector, fBz,fMethod); //With Method String
+
+
+ //Push the blocks on
+ for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
+ PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
+ }
+ fTrackArray->Clear();
+
+ return iResult;
+}
+
+int AliHLTGlobalTrackMatcherComponent::ScanConfigurationArgument(int argc, const char** argv) {
+ // see header file for class documentation
+ if (argc<=0) return 0;
+ int i=0;
+ TString argument=argv[i];
+
+ // -maxpt
+ if (argument.CompareTo("-method")==0) {
+ if (++i>=argc) return -EPROTO;
+ argument=argv[i];
+ fMethod=argument.Atoi(); //
+ return 2;
+ }
+
+// unknown argument
+ return -EINVAL;
}
// int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)
// Int_t iResult = 1;
// return iResult;
// }
+
+int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) {
+ // configure from the specified antry or the default one
+ const char* entry=cdbEntry;
+ if (!entry || entry[0]==0) entry=fOCDBEntry;
+
+ return ConfigureFromCDBTObjString(entry);
+}
+
+void AliHLTGlobalTrackMatcherComponent::GetOCDBObjectDescription( TMap* const targetMap) {
+
+ // Get a list of OCDB object description.
+ if (!targetMap) return;
+ targetMap->Add(new TObjString(fOCDBEntry),
+ new TObjString(Form("Track-Matcher Method OCDB object") )
+ );
+}
+
+