]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
using the new ESD assignment operator to merge ESDs
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 May 2008 15:50:10 +0000 (15:50 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 May 2008 15:50:10 +0000 (15:50 +0000)
HLT/BASE/AliHLTModulePreprocessor.cxx
HLT/BASE/AliHLTSystem.cxx
HLT/BASE/AliHLTSystem.h
HLT/configure.ac
HLT/rec/AliHLTEsdManager.cxx
HLT/rec/AliHLTEsdManager.h

index 924cbfd41cb47785d3c5e00f64aa0032045f504f..cbbde3e9a945bc66f4ce0e87ba24efc97dfb27b2 100644 (file)
 
 ClassImp(AliHLTModulePreprocessor)
 
+AliHLTModulePreprocessor::AliHLTModulePreprocessor() 
+  :
+  fpInterface(NULL),
+  fActiveDetectors(0)
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTModulePreprocessor::~AliHLTModulePreprocessor() 
+{
+  // see header file for function documentation
+}
+
 const Int_t AliHLTModulePreprocessor::kNDetectors = 21;
 
 const char* AliHLTModulePreprocessor::fgkDetectorName[kNDetectors] = 
@@ -59,23 +76,6 @@ const char* AliHLTModulePreprocessor::fgkDetectorName[kNDetectors] =
   "HLT"
 };
 
-AliHLTModulePreprocessor::AliHLTModulePreprocessor() 
-  :
-  fpInterface(NULL),
-  fActiveDetectors(0)
-{
-  // see header file for class documentation
-  // or
-  // refer to README to build package
-  // or
-  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
-}
-
-AliHLTModulePreprocessor::~AliHLTModulePreprocessor() 
-{
-  // see header file for function documentation
-}
-
 void AliHLTModulePreprocessor::SetShuttleInterface(AliHLTShuttleInterface* pInterface)
 {
   assert(fpInterface==NULL || fpInterface==pInterface || pInterface==NULL);
index fe2bcf30f85485212ef670580b5e84d32fcf98da..804a3258a00053ce79a35b64e6eca49634e134b8 100644 (file)
@@ -62,7 +62,7 @@ const char* AliHLTSystem::fgkHLTDefaultLibs[]= {
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTSystem)
 
-AliHLTSystem::AliHLTSystem()
+AliHLTSystem::AliHLTSystem(AliHLTComponentLogSeverity loglevel)
   :
   fpComponentHandler(new AliHLTComponentHandler()),
   fpConfigurationHandler(new AliHLTConfigurationHandler()),
@@ -71,8 +71,7 @@ AliHLTSystem::AliHLTSystem()
   fChains(),
   fStopwatches(new TObjArray),
   fEventCount(-1),
-  fGoodEvents(-1),
-  bWriteGlobalEsd(false)
+  fGoodEvents(-1)
 {
   // see header file for class documentation
   // or
@@ -83,8 +82,8 @@ AliHLTSystem::AliHLTSystem()
   if (fgNofInstances++>0)
     HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
 
-  SetGlobalLoggingLevel(kHLTLogDefault);
-  SetFrameworkLog(kHLTLogDefault);
+  SetGlobalLoggingLevel(loglevel);
+  SetFrameworkLog(loglevel);
   if (fpComponentHandler) {
     AliHLTComponentEnvironment env;
     memset(&env, 0, sizeof(AliHLTComponentEnvironment));
@@ -743,7 +742,7 @@ int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd)
   // TTree::Fill in AliReconstruction, furthermore, the wrong ESD is passed
   // by the framework
   AliESDEvent* pMasterESD=NULL;
-  if (bWriteGlobalEsd) pMasterESD=esd;
+  pMasterESD=esd;
   for (iResult=pHLTOUT->SelectFirstDataBlock();
        iResult>=0;
        iResult=pHLTOUT->SelectNextDataBlock()) {
@@ -975,8 +974,6 @@ int AliHLTSystem::ScanOptions(const char* options)
              HLTWarning("wrong argument for option \'libmode=\', use \'static\' or \'dynamic\'");
            }
          }
-       } else if (token.Contains("globalesd")) {
-         bWriteGlobalEsd=true;
        } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
          libs+=token;
          libs+=" ";
index a3f10cca8c07d926b8e8e38b42f58e9337b8d7d7..70e17196926ecdbf1701a36b03237507d7f7c49f 100644 (file)
@@ -47,7 +47,7 @@ class TStopwatch;
 class AliHLTSystem : public AliHLTLogging {
  public:
   /** default constructor */
-  AliHLTSystem();
+  AliHLTSystem(AliHLTComponentLogSeverity loglevel=kHLTLogDefault);
   /** destructor */
   virtual ~AliHLTSystem();
 
@@ -451,16 +451,10 @@ class AliHLTSystem : public AliHLTLogging {
   /** number of events processed successfully */
   int fGoodEvents;                                                 //!transient
 
-  /** switch whether to write to the global hltesd or not
-   *  since this causes a crash outside the HLT code this
-   *  can be enabled by the 'globalesd' argument
-   */
-  bool bWriteGlobalEsd;                                            //!transient
-
   /** array of default libraries */
   static const char* fgkHLTDefaultLibs[];                          //!transient
 
-  ClassDef(AliHLTSystem, 6);
+  ClassDef(AliHLTSystem, 7);
 };
 
 #endif
index 7e603eafda1e8ad786c722f337b520e6f048a9f2..e95e1c2e0463dc0dcf44571415b4446af7b15f44 100644 (file)
@@ -252,6 +252,20 @@ if test ! "x$have_aliroot" = "xno" ; then
     ALIROOT_LIBS=
   fi
 
+  dnl
+  dnl ESD copy function added May 9 2008 rev 25667
+  dnl
+  have_esd_copy=no
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <AliESDEvent.h>],
+                                 [AliESDEvent esd1;
+                                  AliESDEvent esd2;
+                                  esd2=esd1;])],
+                 [AC_DEFINE(HAVE_ESD_COPY)
+                 have_esd_copy=yes], 
+                [])
+  AC_MSG_CHECKING(for ESD assignment operator)
+  AC_MSG_RESULT([$have_esd_copy])
+
   dnl
   dnl required header files and libraries for modules
   dnl
@@ -284,7 +298,7 @@ if test ! "x$have_aliroot" = "xno" ; then
                                      [have_alitpc=no
                                       ALITPC_LIBS= ])
     fi
-    AC_MSG_RESULT($have_alitpc)
+    AC_MSG_RESULT([$have_alitpc])
   fi
   AC_CHECK_HEADERS([AliTPCCalibPulser.h], [], [AC_DEFINE(HAVE_NOT_ALITPCCALIBPULSER)])
   AC_CHECK_HEADERS([AliTPCCalibPedestal.h], [], [AC_DEFINE(HAVE_NOT_ALITPCCALIBPEDESTAL)])
index 970fd6ff16047aea96bf362fc32043aa26bc2b23..b97e27ec88e610a11a2c6731561bf6df48834265 100644 (file)
@@ -117,6 +117,9 @@ int AliHLTEsdManager::WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size
          fESDs.push_back(newEntry);
        }
        if (tgtesd) {
+#ifdef HAVE_ESD_COPY
+         *tgtesd=*pESD;
+#else
          TTree* pTmpTree=AliHLTEsdManager::EmbedIntoTree(pESD);
          if (pTmpTree) {
            tgtesd->ReadFromTree(pTmpTree);
@@ -127,6 +130,7 @@ int AliHLTEsdManager::WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size
          } else {
            iResult=-ENOMEM;
          }
+#endif
        } else {
        entry=Find(dt);
        if (entry) {
@@ -214,7 +218,10 @@ AliHLTEsdManager::AliHLTEsdListEntry::AliHLTEsdListEntry(AliHLTComponentDataType
   :
   fName(),
   fDirectory(),
-  fDt(dt)
+  fDt(dt),
+  fpFile(NULL),
+  fpTree(NULL),
+  fpEsd(NULL)
 {
   // see header file for class documentation
 }
@@ -232,6 +239,73 @@ bool AliHLTEsdManager::AliHLTEsdListEntry::operator==(AliHLTComponentDataType dt
 
 int AliHLTEsdManager::AliHLTEsdListEntry::WriteESD(AliESDEvent* pSrcESD, int eventno)
 {
+  // see header file for class documentation
+  int iResult=0;
+#ifdef HAVE_ESD_COPY
+  if (fName.IsNull()) {
+    // this is the first event, create the file name
+    TString origin;
+    origin.Insert(0, fDt.fOrigin, kAliHLTComponentDataTypefOriginSize);
+    origin.Remove(TString::kTrailing, ' ');
+    origin.ToUpper();
+    fName="";
+    if (!fDirectory.IsNull()) {
+      fName+=fDirectory; fName+="/";
+    }
+    fName+="AliHLT"; fName+=origin;
+    if (fDt!=kAliHLTDataTypeESDObject &&
+       fDt!=kAliHLTDataTypeESDTree) {
+
+      HLTWarning("non-standard ESD type %s", AliHLTComponent::DataType2Text(fDt).c_str());
+      TString id;
+      id.Insert(0, fDt.fID, kAliHLTComponentDataTypefIDsize);
+      id.Remove(TString::kTrailing, ' ');
+      id.ToUpper();
+      fName+="_"; fName+=id; fName+=".root";
+    } else {
+      fName+="ESDs.root";
+    }
+
+    fpFile=new TFile(fName, "RECREATE");
+    fpTree=new TTree("esdTree", "Tree with HLT ESD objects");
+    fpEsd=new AliESDEvent;
+    if (fpEsd) {
+      fpEsd->CreateStdContent();
+      if (fpTree) {
+       fpEsd->WriteToTree(fpTree);
+      }
+    }
+  }
+
+  if (fpFile && fpTree && fpEsd) {
+    // synchronize and add empty events
+    fpEsd->Reset();
+    int nofCurrentEvents=fpTree->GetEntries();
+    if (nofCurrentEvents<eventno) {
+      iResult=1; // indicate tree to be written
+      HLTDebug("adding %d empty events to file %s", eventno-nofCurrentEvents, fName.Data());
+      for (int i=nofCurrentEvents; i<eventno; i++) {
+       fpTree->Fill();
+      }
+    }
+
+    if (iResult>=0 && pSrcESD) {
+      *fpEsd=*pSrcESD;
+      fpTree->Fill();
+      iResult=1; // indicate tree to be written
+    }
+
+    if (iResult>0) {
+      fpFile->cd();
+      fpTree->GetUserInfo()->Add(fpEsd);
+      fpTree->Write(fpTree->GetName(),TObject::kOverwrite);
+      fpTree->GetUserInfo()->Clear();
+    }
+  }
+#else //HAVE_ESD_COPY
+  // this is the old workaround, necessary for older AliRoot versions
+  // version<=v4-12-Release
+
   // we need to copy the ESD, I did not find an approptiate
   // method, the workaround is to save the ESD in a temporary
   // tree, read the content back into the ESD structure
@@ -256,7 +330,6 @@ int AliHLTEsdManager::AliHLTEsdListEntry::WriteESD(AliESDEvent* pSrcESD, int eve
   // We use temporary files for the new event to be copied into the
   // existing tree.
   //
-  int iResult=0;
   if (fName.IsNull()) {
     // this is the first event, create the file on disk and write ESD
     TString origin;
@@ -374,31 +447,33 @@ int AliHLTEsdManager::AliHLTEsdListEntry::WriteESD(AliESDEvent* pSrcESD, int eve
 
       // there have been problems with the memory consumption when using
       // TChain::Merge
-      //chain.Merge(tgtName);
-      TFile tgtFile(tgtName, "RECREATE");
-      TTree* pTgtTree=new TTree("esdTree", "Tree with HLT ESD objects");
-      AliESDEvent* pTgtESD=new AliESDEvent;
-      if (pTgtTree && pTgtESD) {
-       pTgtESD->ReadFromTree(&chain);
-       pTgtESD->WriteToTree(pTgtTree);
-
-       int nofEvents=chain.GetEntries();
-       for (int event=0; event<nofEvents; event++) {
-         chain.GetEntry(event);
-         pTgtTree->Fill();
-       }
-
-       pTgtTree->GetUserInfo()->Add(pTgtESD);
-       tgtFile.cd();
-       pTgtTree->Write();
-       pTgtTree->GetUserInfo()->Clear();
-      } else {
-       iResult=-ENOMEM;
-      }
-
-      if (pTgtTree) delete pTgtTree;
-      if (pTgtESD) delete pTgtESD;
-      tgtFile.Close();
+      // but using a separate loop soemtimes crashes in AliESDEvent::ReadFromTree
+      // since this is for backward compatiblity only, we take the TChain::Merge
+      chain.Merge(tgtName);
+//       TFile tgtFile(tgtName, "RECREATE");
+//       TTree* pTgtTree=new TTree("esdTree", "Tree with HLT ESD objects");
+//       AliESDEvent* pTgtESD=new AliESDEvent;
+//       if (pTgtTree && pTgtESD) {
+//     pTgtESD->ReadFromTree(&chain);
+//     pTgtESD->WriteToTree(pTgtTree);
+
+//     int nofEvents=chain.GetEntries();
+//     for (int event=0; event<nofEvents; event++) {
+//       chain.GetEntry(event);
+//       pTgtTree->Fill();
+//     }
+
+//     pTgtTree->GetUserInfo()->Add(pTgtESD);
+//     tgtFile.cd();
+//     pTgtTree->Write();
+//     pTgtTree->GetUserInfo()->Clear();
+//       } else {
+//     iResult=-ENOMEM;
+//       }
+
+//       if (pTgtTree) delete pTgtTree;
+//       if (pTgtESD) delete pTgtESD;
+//       tgtFile.Close();
 
       // rename the merged file to the original file
       TString shellcmd="mv ";
@@ -425,6 +500,7 @@ int AliHLTEsdManager::AliHLTEsdListEntry::WriteESD(AliESDEvent* pSrcESD, int eve
       gSystem->Exec(shellcmd);
     }
   }
+#endif //HAVE_ESD_COPY
 
   return iResult;
 }
index ace5212b6e925d9f31ca6cbbb5675ffd37c8379d..122fd81592bd1c58da264739f087b55796404603 100644 (file)
@@ -24,6 +24,17 @@ class TFile;
 
 /**
  * @class AliHLTEsdManager
+ * Tool to write and merge HLT ESD objects.
+ *
+ * HLT components can produce ESD output. The ESD objects are sent via
+ * a TMessage like mechanism as part of the HLTOUT data. This class retrieves
+ * streamed AliESDEvent objects from an HLT output block. An ESD object can be
+ * copied to a global ESD provided by the caller or to files. The name of the
+ * ROOT files follows the scheme AliHLTDETESDs.root where DET denotes a detector.
+ * E.g. the ESD from a data block of type {ESD_TREE,TPC} will be added to the
+ * file AliHLTTPCESDs.root.
+ *
+ * @ingroup alihlt_out
  */
 class AliHLTEsdManager : public AliHLTLogging {
  public:
@@ -138,6 +149,12 @@ class AliHLTEsdManager : public AliHLTLogging {
     TString fDirectory; //!transient
     /** data type of the corresponding block */
     AliHLTComponentDataType fDt; //!transient
+    /** the root file for this esd */
+    TFile* fpFile; //!transient
+    /** the tree for this esd */
+    TTree* fpTree; //!transient
+    /** the esd to fill into the tree */
+    AliESDEvent* fpEsd; //!transient
   };
 
   typedef vector<AliHLTEsdListEntry*> AliHLTEsdPList;
@@ -153,7 +170,7 @@ class AliHLTEsdManager : public AliHLTLogging {
   /** target directory */
   TString fDirectory; //!transient
 
-  ClassDef(AliHLTEsdManager, 0)
+  ClassDef(AliHLTEsdManager, 1)
 };
 
 #endif