*/
#include "AliHLTESDMCEventPublisherComponent.h"
+#include "AliHLTErrorGuard.h"
#include "TList.h"
#include "TTree.h"
fpTreeTR(NULL),
fpESD(NULL),
fpHLTESD(NULL),
+ fpESDClone(NULL),
fpMC(NULL),
fpHLTMC(NULL),
fOutputSize(0),
- fApplyParticleCuts(kFALSE) {
+ fApplyParticleCuts(kFALSE),
+ fSkippedEsdObjects() {
// see header file for class documentation
// or
// refer to README to build package
fApplyParticleCuts = kTRUE;
}
+ else if ( !argument.CompareTo("-skip-esd-object") ) {
+ if ((bMissingParam=(++iter>=argc))) break;
+ if (!fSkippedEsdObjects.IsNull()) fSkippedEsdObjects+=" ";
+ fSkippedEsdObjects+=argv[iter];
+ }
+
// -- Argument not known
else {
HLTError("Unknown argument %s.", argument.Data());
if ( iResult < 0 ) {
fEvents.Clear();
}
+
+ if (!fSkippedEsdObjects.IsNull()) {
+ fpESDClone=new AliESDEvent;
+ }
return iResult;
}
delete fpHLTESD;
fpHLTESD = NULL;
+ if ( fpESDClone )
+ delete fpESDClone;
+ fpESDClone = NULL;
+
if ( fpMC )
delete fpMC;
fpMC = NULL;
// -- Publish ESDs
if ( fPublishESD && fpTreeESD ) {
fpTreeESD->GetEntry(fCurrentEvent);
- if ((iResult=PushBack( fpESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOffline , fSpecification ))==-ENOSPC) {
+ AliESDEvent* pESDpublish=fpESD;
+ if (fpESDClone && CopyESDObjects(fpESDClone, fpESD, fSkippedEsdObjects.Data())>=0) {
+ pESDpublish=fpESDClone;
+ }
+ if ((iResult=PushBack( pESDpublish, kAliHLTDataTypeESDObject|kAliHLTDataOriginOffline , fSpecification ))==-ENOSPC) {
fOutputSize+=GetLastObjectSize();
}
}
// -- Publish HLTESDs
if ( fPublishHLTESD && fpTreeHLTESD ) {
fpTreeHLTESD->GetEntry(fCurrentEvent);
- if ((iResult=PushBack(fpHLTESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginHLT , fSpecification ))==-ENOSPC) {
+ AliESDEvent* pESDpublish=fpHLTESD;
+ if (fpESDClone && CopyESDObjects(fpESDClone, fpHLTESD, fSkippedEsdObjects.Data())>=0) {
+ pESDpublish=fpESDClone;
+ }
+ if ((iResult=PushBack(pESDpublish, kAliHLTDataTypeESDObject|kAliHLTDataOriginHLT , fSpecification ))==-ENOSPC) {
fOutputSize+=GetLastObjectSize();
}
}
while (flnk && iResult>=0) {
FileDesc* pFileDesc = dynamic_cast<FileDesc*>( flnk->GetObject() );
+ if (!pFileDesc) {
+ ALIHLTERRORGUARD(1, "internal mismatch, object is not of type FileDesc");
+ break;
+ }
TFile* pFile = *pFileDesc;
if ( !pFile ) {
HLTError("No pointer to file");
// ----------------------------------
while ( flnk && iResult>=0 ) {
FileDesc* pFileDesc = dynamic_cast<FileDesc*>( flnk->GetObject() );
- TFile* pFile = NULL;
+ if (!pFileDesc) {
+ ALIHLTERRORGUARD(1, "internal mismatch, object is not of type FileDesc");
+ break;
+ }
+ TFile* pFile = *pFileDesc;
// If file is not opened yet, open it ... which it should not
- if ( pFileDesc && ( pFile = *pFileDesc ) == NULL )
- pFileDesc->OpenFile();
- else {
+ if (pFile != NULL ) {
HLTError("File already open, this should not happen.");
iResult=-EFAULT;
continue;
}
+ pFileDesc->OpenFile();
if ( (pFile = *pFileDesc ) == NULL ) {
HLTError("Opening file failed." );
iResult=-EFAULT;
// -- Loop over all files in folder
while ( flnk && iResult>=0 ) {
FileDesc* pFileDesc = dynamic_cast<FileDesc*>( flnk->GetObject() );
+ if (!pFileDesc) {
+ ALIHLTERRORGUARD(1, "internal mismatch, object is not of type FileDesc");
+ break;
+ }
- TFile* pFile = NULL;
+ TFile* pFile = *pFileDesc;
// If is opened, close it
- if ( pFileDesc && ( pFile = *pFileDesc ) != NULL )
+ if ( pFile != NULL ) {
pFileDesc->CloseFile();
- else {
- HLTError("File already open, this should not happen.");
- iResult=-EFAULT;
}
if ( (pFile = *pFileDesc ) != NULL ) {
return iResult;
}
+
+// #################################################################################
+Int_t AliHLTESDMCEventPublisherComponent::CopyESDObjects(AliESDEvent* pTgt,
+ const AliESDEvent* pSrc,
+ const char* skippedObjects) const {
+ // clone an ESD by copying all objects but skip the specified ones
+
+ Int_t iResult = 0;
+ if (!pSrc || !pTgt) return -EINVAL;
+
+ // copy the full ESD
+ pTgt->Reset();
+ *pTgt=*pSrc;
+
+ // filter according to the list of objects to be skipped
+ if (pTgt->GetList() && skippedObjects!=NULL) {
+ TString skipObjects=skippedObjects;
+ TObjArray* pTokens=skipObjects.Tokenize(" ");
+ if (pTokens) {
+ const char* id=NULL;
+ TIter next(pTokens);
+ TObject* pObject=NULL;
+ while ((pObject=next())!=NULL) {
+ id=pObject->GetName();
+ TObject* pObj=pTgt->GetList()->FindObject(id);
+ if (pObj) {
+ HLTDebug("removing object %s", id);
+ pTgt->GetList()->Remove(pObj);
+ delete pObj;
+ } else {
+ HLTWarning("failed to remove object '%s' from ESD", id);
+ }
+ }
+ pTgt->GetStdContent();
+ delete pTokens;
+ }
+ }
+
+ return iResult;
+}
#include "TList.h"
#include "TTree.h"
+#include "TString.h"
#include "AliESDEvent.h"
#include "AliMCEvent.h"
*
* \li -applyParticleCuts <i> Apply particle cuts before filling in AliHLTMCEvent </i> <br>
*
+ * \li -skip-esd-object <i> object </i> <br>
+ * remove object from ESD content before publishing, can be a blank separated list of
+ * objects, but don't forget to enclose multiple names in quotes
*
* <h2>Configuration:</h2>
* <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
*/
Int_t CloseCurrentFileList();
+ /** clone an ESD by copying all objects but skip the specified ones
+ */
+ Int_t CopyESDObjects(AliESDEvent* pTgt, const AliESDEvent* pSrc, const char* skippedObjects) const;
+
/*
* ---------------------------------------------------------------------------------
* Members - private
/* Ptr to current HLT - AliESDEvent, to be shipped out*/
AliESDEvent* fpHLTESD; //! transient
+ /* Ptr for ESD with selected objects, to be shipped out*/
+ AliESDEvent* fpESDClone; //! transient
+
/* Ptr to current AliMCEvent, to be shipped out*/
AliMCEvent* fpMC; //! transient
/** Apply particle cuts, before filling in AliHLTMCEvent */
Bool_t fApplyParticleCuts; // see above
+ /// list of ESD objects to be skipped
+ TString fSkippedEsdObjects; //! transient
+
ClassDef(AliHLTESDMCEventPublisherComponent, 0)
};
#endif