+ // 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
+