AliHLTEsdManagerImplementation::AliHLTEsdManagerImplementation()
:
- fESDs(),
- fDirectory()
+ fESDs()
+ , fDirectory()
+ , fWriteLocal(false)
{
// see header file for class documentation
// or
}
}
+int AliHLTEsdManagerImplementation::SetOption(const char* option)
+{
+ // see header file for class documentation
+ int iResult=0;
+ TString strOptions=option;
+ TObjArray* pTokens=strOptions.Tokenize(" ");
+ if (pTokens) {
+ if (pTokens->GetEntriesFast()>0) {
+ for (int n=0; n<pTokens->GetEntriesFast(); n++) {
+ TString data=((TObjString*)pTokens->At(n))->GetString();
+ if (data.IsNull()) continue;
+
+ if (data.CompareTo("-writelocal")==0) {
+ fWriteLocal=true;
+ } else if (data.Contains("-directory=")) {
+ data.ReplaceAll("-directory=", "");
+ SetDirectory(data.Data());
+ } else {
+ HLTError("unknown argument %s", data.Data());
+ iResult=-EINVAL;
+ break;
+ }
+ }
+ }
+ delete pTokens;
+ }
+ return iResult;
+}
+
AliHLTEsdManagerImplementation::AliHLTEsdListEntry* AliHLTEsdManagerImplementation::Find(AliHLTComponentDataType dt) const
{
// see header file for class documentation
if (pESD) {
AliHLTEsdListEntry* entry=Find(dt);
if (!entry) {
- AliHLTEsdListEntry* newEntry=new AliHLTEsdListEntry(dt);
- if (!fDirectory.IsNull()) {
- newEntry->SetDirectory(fDirectory);
+ if ((entry=new AliHLTEsdListEntry(dt))!=NULL) {
+ if (!fDirectory.IsNull()) {
+ entry->SetDirectory(fDirectory);
+ }
+ fESDs.push_back(entry);
}
- fESDs.push_back(newEntry);
}
- if (tgtesd) {
-#if 0 // later extension !defined(HAVE_NOT_ESD_NONSTD)
- entry=Find(dt);
- if (entry) {
- entry->CopyNonEmptyObjects(tgtesd, pESD);
- } else {
- HLTError("internal mismatch, can not create list entry");
- iResult=-ENOMEM;
- }
-#elif !defined(HAVE_NOT_ESD_COPY)
- *tgtesd=*pESD;
+ if (entry) {
+ if (tgtesd) {
+#if !defined(HAVE_NOT_ESD_COPY)
+ Merge(tgtesd, pESD);
#else //HAVE_NOT_ESD_COPY
- static bool warningPrinted=false;
- if (!warningPrinted) {
- HLTWarning("old version of AliESDEvent does not provide assignment operator, skip merging to global hltEsd");
- }
- warningPrinted=true;
+ static bool warningPrinted=false;
+ if (!warningPrinted) {
+ HLTWarning("old version of AliESDEvent does not provide assignment operator, skip merging to global hltEsd");
+ }
+ warningPrinted=true;
#endif //HAVE_NOT_ESD_COPY
- } else {
- entry=Find(dt);
- if (entry) {
- entry->WriteESD(pESD, eventno);
+ }
+
+ // Matthias 2009-06-06: writing of individual ESD files for the different origins was a
+ // first attempt when functionality was missing in the AliRoot framework and remained as
+ // debugging feature. ESD merging is now implemented and data written to the hltEsd, so
+ // the feature is now disabled by default because it causes increasing memory consumption.
+ // Presumably not because of a memory leak but the way the internal TTree is used and kept
+ // in memory.
+ // Writing of local files can be optionally switched on as e.g. by the EsdCollector component.
+ if (fWriteLocal) entry->WriteESD(pESD, eventno);
} else {
HLTError("internal mismatch, can not create list entry");
iResult=-ENOMEM;
}
- }
} else {
HLTWarning("data block %s is not of class type AliESDEvent, ignoring ...", AliHLTComponent::DataType2Text(dt).c_str());
}
{
// see header file for class documentation
int iResult=0;
+
#ifndef HAVE_NOT_ESD_COPY
if (fName.IsNull()) {
// this is the first event, create the file name
return fPrefix.Data();
}
-int AliHLTEsdManagerImplementation::AliHLTEsdListEntry::CopyNonEmptyObjects(AliESDEvent* pTgt, AliESDEvent* pSrc)
+int AliHLTEsdManagerImplementation::Merge(AliESDEvent* pTgt, AliESDEvent* pSrc) const
{
// see header file for class documentation
int iResult=0;
if (!pTgt || !pSrc) return -EINVAL;
- const char* defaultPrefix="HLT";
TIter next(pSrc->GetList());
TObject* pSrcObject=NULL;
- TString name;
+ static int warningCount=0;
while ((pSrcObject=next())) {
if(!pSrcObject->InheritsFrom("TCollection")){
// simple objects
+ TString name=pSrcObject->GetName();
+ if(pSrcObject->InheritsFrom("AliHLTTriggerDecision")){
+ //pSrcObject->Print();
+ TObject* pTgtObject=pTgt->FindListObject(name);
+ if (pTgtObject) {
+ pSrcObject->Copy(*pTgtObject);
+ } else {
+ pTgt->AddObject(pSrcObject->Clone());
+ }
+ } else {
+ // TODO: implement the handling of other objects, some kind of mapping
+ }
} else if(pSrcObject->InheritsFrom("TClonesArray")){
TClonesArray* pTClA=dynamic_cast<TClonesArray*>(pSrcObject);
if (pTClA!=NULL && pTClA->GetEntriesFast()>0) {
- bool bMakeNewName=true;
- name=defaultPrefix;
- name+=pTClA->GetName();
+ TString name=pTClA->GetName();
TObject* pTgtObject=pTgt->GetList()->FindObject(name);
TClonesArray* pTgtArray=NULL;
- if (bMakeNewName=(pTgtObject!=NULL) && pTgtObject->InheritsFrom("TClonesArray")){
+ if (pTgtObject!=NULL && pTgtObject->InheritsFrom("TClonesArray")){
pTgtArray=dynamic_cast<TClonesArray*>(pTgtObject);
if (pTgtArray) {
TString classType=pTClA->Class()->GetName();
if (classType.CompareTo(pTgtArray->Class()->GetName())==0) {
if (pTgtArray->GetEntries()==0) {
- bMakeNewName=false;
+ pTgtArray->ExpandCreate(pTClA->GetEntries());
+ for(int i=0; i<pTClA->GetEntriesFast(); ++i){
+ (*pTClA)[i]->Copy(*((*pTgtArray)[i]));
+ }
} else {
- HLTWarning("TClonesArray \"%s\" in target ESD %p is already filled with %d entries",
- name.Data(), pTgt, pTgtArray->GetEntries());
+ if (warningCount++<10) {
+ HLTWarning("TClonesArray \"%s\" in target ESD %p is already filled with %d entries",
+ name.Data(), pTgt, pTgtArray->GetEntries());
+ }
+ iResult=-EBUSY;
}
} else {
- HLTWarning("TClonesArray \"%s\" exists in target ESD %p, but describes incompatible class type %s instead of %s",
- name.Data(), pTgt, pTgtArray->GetClass()->GetName(), pTClA->GetClass()->GetName());
+ if (warningCount++<10) {
+ HLTWarning("TClonesArray \"%s\" exists in target ESD %p, but describes incompatible class type %s instead of %s",
+ name.Data(), pTgt, pTgtArray->GetClass()->GetName(), pTClA->GetClass()->GetName());
+ }
+ iResult=-EBUSY;
}
} else {
- HLTError("internal error: dynamic cast failed for object %s %p", pTgtObject->GetName(), pTgtObject);
+ if (warningCount++<10) {
+ HLTError("internal error: dynamic cast failed for object %s %p", pTgtObject->GetName(), pTgtObject);
+ }
+ iResult=-EBUSY;
}
} else if (pTgtObject) {
- HLTWarning("object \"%s\" does already exist in target ESD %p, but is %s rather than TClonesArray",
- name.Data(), pTgt, pTgtObject->Class()->GetName());
- // TODO: temporary solution, think about a general naming scheme and add
- // the name as property of AliHLTEsdListEntry
- }
-
- if (bMakeNewName) {
- pTgtArray=NULL;
- int count=1;
- while (pTgt->GetList()->FindObject(name)) {
- name.Form("%sESD_%s", GetPrefix(), pTClA->GetName());
- if (count++>1) {
- name+=Form("%d", count);
- }
+ if (warningCount++<10) {
+ HLTWarning("object \"%s\" does already exist in target ESD %p, but is %s rather than TClonesArray"
+ " skipping data",
+ name.Data(), pTgt, pTgtObject->Class()->GetName());
}
- HLTWarning("adding new TClonesArray \"%s\" because of conflicts", name.Data());
- }
-
- if (pTgtArray) {
- pTgtArray->ExpandCreate(pTClA->GetEntries());
- HLTInfo("Expanding TClonesArray \"%s\" to %d elements", pTgtArray->GetClass()->GetName(), pTClA->GetEntries());
+ iResult=-EBUSY;
} else {
- pTgtArray=new TClonesArray(pTClA->GetClass(), pTClA->GetEntries());
- pTgtArray->ExpandCreate(pTClA->GetEntries());
- pTgtArray->SetName(name);
- pTgt->AddObject(pTgtArray);
- HLTInfo("Adding TClonesArray \"%s\" with %d elements to ESD %p", name.Data(), pTClA->GetEntries(), pTgt);
- }
-
- if (pTgtArray) {
- for(int i=0; i<pTClA->GetEntriesFast(); ++i){
- (*pTClA)[i]->Copy(*((*pTgtArray)[i]));
+ if (warningCount++<10) {
+ HLTWarning("object \"%s\" does not exist in target ESD %p, data can not be copied because it will be lost when filling the tree",
+ name.Data(), pTgt);
}
- } else {
- iResult=-ENOMEM;
+ iResult=-ENOENT;
}
}
}