1. binet
  2. mana-core-athenarootcomps

Commits

bi...@4525493e-7705-40b1-a816-d608a930855b  committed c4c9775

fix multiple outputstreams + add test with and w/o varhandles + add test w/ w/o output + add test w/ multiple outputs + populate tads at loadAddresses instead of at preLoadAddresses

  • Participants
  • Parent commits a677897
  • Branches default

Comments (0)

Files changed (7)

File ChangeLog

View file
+2012-03-22  Sebastien Binet  <sebastien.binet@cern.ch>
+
+	* tagging AthenaRootComps-00-10-05
+	* fix multiple outputstreams
+	* add test with and w/o varhandles
+	* add test w/ w/o output
+	* add test w/ multiple outputs
+	* populate tads at loadAddresses instead of at preLoadAddresses
+	* M test/run_test_athena_ntuple_dumper.sh
+	* M share/tests/test_athena_ntuple_dumper.py
+	* M src/RootOutputStreamTool.cxx
+	* M src/RootNtupleEventSelector.cxx
+	* M src/RootNtupleOutputStream.cxx
+	* M src/RootConnection.cxx
+
 2012-03-13  Sebastien Binet  <binet@voatlas51.cern.ch>
 
 	* tagging AthenaRootComps-00-10-04

File share/tests/test_athena_ntuple_dumper.py

View file
         "el_jetcone_dr",
         ]
     out.ForceRead = True
+    if DOWRITE>1:
+        # another output stream... with the same content.
+        out = arcw.createNtupleOutputStream("StreamD3PD_2",
+                                            "d3pd_2.root",
+                                            "egamma")
+        out.ItemList += [
+            "el_n",
+            "el_eta",
+            "el_jetcone_dr",
+            ]
+        out.ForceRead = True
+        
+    pass
+

File src/RootConnection.cxx

View file
 
 // AthenaRootComps includes
 #include "RootConnection.h"
+#include "RootGlobalsRestore.h"
 
 // fwk includes
 #include "GaudiKernel/ServiceHandle.h"
   // std::cerr << "::RootConnection::connectWrite(" << m_pfn
   //           << "|" << m_treeName
   //           << ")...\n";
-  if (m_file == 0) {
-    delete m_tree; m_tree = 0;
+  if (m_file == NULL) {
+    delete m_tree; m_tree = NULL;
     m_file = TFile::Open(m_pfn.c_str(),
                          IIoSvc::IoTypeName(mode).c_str(),
                          "AthenaRoot event data file");
   }
 
-  if (m_file != 0 && m_tree == 0) {
+  if (m_file == NULL) {
+    return StatusCode::FAILURE;
+  }
+
+  if (m_tree == NULL) {
+    RootGlobalsRestore rgr;
+
     int splitlevel = 0;
+    m_file->cd("/");
     m_tree = new TTree(m_treeName.c_str(), "Main event data tree", splitlevel);
+    m_tree->SetDirectory(m_file);
+    m_tree->Reset();
   }
   return StatusCode::SUCCESS;
 }
   if (!this->commit().isSuccess()) {
     return StatusCode::FAILURE;
   }
-  if (m_tree != 0 && m_file->IsWritable()) {
-    m_tree->Write(); m_tree = 0;
+  if (m_tree != NULL && m_file->IsWritable()) {
+    RootGlobalsRestore rgr;
+    m_file->cd("/");
+    m_tree->Write(); 
+    m_tree = NULL;
   }
-  m_file->Close(); m_file = 0;
+  m_file->Close(); m_file = NULL;
   return StatusCode::SUCCESS;
 }
 

File src/RootNtupleEventSelector.cxx

View file
     }
     return s[root_type_name];
   }
+
+  std::vector<std::string>
+  get_active_leaves(TTree *tuple) 
+  {
+    std::vector<std::string> active;
+    TObjArray *leaves = tuple->GetListOfLeaves(); 
+    if (leaves) { 
+      // loop over leaves 
+      for (Int_t i = 0; i < leaves->GetEntries(); ++i) { 
+        TLeaf *leaf = (TLeaf *)leaves->At(i); 
+        TBranch *branch = leaf->GetBranch(); 
+        if (branch) { 
+          const char *brname = branch->GetName(); 
+          if (tuple->GetBranchStatus(brname)) { 
+            active.push_back(std::string(brname));
+          } 
+        }
+      }
+    }
+    return active;
+  }
+
 }
 
 namespace Athena {
       delete evtInfo; evtInfo = 0;
       return StatusCode::FAILURE;
     }
-    // std::cout << "--done--" << std::endl;
     return StatusCode::SUCCESS;
   } else {
     // prepare for next file, if any...
 /// @c IAddressProvider interface
 ///get all addresses from Provider : Called before Begin Event
 StatusCode 
-RootNtupleEventSelector::preLoadAddresses(StoreID::type storeID, tadList& tads)
+RootNtupleEventSelector::preLoadAddresses(StoreID::type /*storeID*/, 
+                                          tadList& /*tads*/)
 {
   // std::cerr << "TTES::preLoadAddresses(" << int(storeID)
   // 	    << "," << tads.size()
   // 	    << ")...\n";
-
-  return createRootBranchAddresses(storeID, tads);
+  return StatusCode::SUCCESS;
 }
  
 /// get all new addresses from Provider for this Event.
 StatusCode 
-RootNtupleEventSelector::loadAddresses(StoreID::type /*storeID*/, tadList& /*tads*/)
+RootNtupleEventSelector::loadAddresses(StoreID::type storeID, tadList& tads)
 {
-  // do nothing. already done by preLoadAddresses.
+  if (m_rootAddresses.empty()) {
+    return createRootBranchAddresses(storeID, tads);
+  }
+
   return StatusCode::SUCCESS;
 }
  

File src/RootNtupleOutputStream.cxx

View file
     }
     if (m_forceRead && proxy->isValid()) {
       if (!m_persToPers) {
-	if (NULL == proxy->accessData()) {
-	  ATH_MSG_ERROR(" Could not get data object for id "
-			<< proxy->clID() << ",\"" << proxy->name());
-	}
+        if (NULL == proxy->accessData()) {
+          ATH_MSG_ERROR(" Could not get data object for id "
+                        << proxy->clID() << ",\"" << proxy->name());
+        }
       } else if (true /*m_exemptPersToPers.find(item.id()) != m_exemptPersToPers.end()*/) {
-	if (NULL == proxy->accessData()) {
-	  ATH_MSG_ERROR(" Could not get data object for id "
-			<< proxy->clID() << ",\"" << proxy->name());
-	}
+        if (NULL == proxy->accessData()) {
+          ATH_MSG_ERROR(" Could not get data object for id "
+                        << proxy->clID() << ",\"" << proxy->name());
+        }
       }
     }
     DataObject *obj = proxy->object();

File src/RootOutputStreamTool.cxx

View file
                   "Store from which to stream out data");
 
   declareProperty("TupleName",
-		  m_tupleName = "atlas_ntuple",
-		  "Name of the output n-tuple");
+                  m_tupleName = "atlas_ntuple",
+                  "Name of the output n-tuple");
 
   declareProperty("OutputFile",
-		  m_outputName,
-		  "Name of the output file");
+                  m_outputName,
+                  "Name of the output file");
 }
 
 RootOutputStreamTool::~RootOutputStreamTool() 

File test/run_test_athena_ntuple_dumper.sh

View file
 
 function run_test() {
     echo "::: running athenarootcomps-r/w basic test..."
+    /bin/rm -rf arc-ntuple-dumper-tests
+    mkdir arc-ntuple-dumper-tests
+    pushd arc-ntuple-dumper-tests
+
     echo "::: retrieve reference ascii file..."
     reffile=ref.d3pd.ascii
     chkfile=d3pd.ascii
     refdir=root://eosatlas//eos/atlas/user/b/binet/utests/utests/filter-d3pd/
     xrdcp $refdir/$reffile $reffile || return 1
 
-    echo "::: run athena-ntuple-dumper..."
-    time_cmd="/usr/bin/time -o d3pd.timing.log"
-    ($time_cmd athena.py AthenaRootComps/test_athena_ntuple_dumper.py >& d3pd.001.log.txt) || return 1
-    /bin/cat d3pd.timing.log
+    echo ""
+    echo "::::::::::::::::::::::::::::::::::::::::::::::"
+    echo "::: run athena-ntuple-dumper... (w/ multiple output-streams)"
+    time_cmd="/usr/bin/time -a -o d3pd.rw.timing.log"
+    /bin/rm -rf d3pd.rw.timing.log >& /dev/null
+    ($time_cmd athena.py -c'USEVARHANDLE=1; DOWRITE=2' -lERROR AthenaRootComps/test_athena_ntuple_dumper.py >& d3pd.000.0.log.txt) || return 1
+    grep "user" d3pd.rw.timing.log
+    echo "::: comparing ascii dumps..."
+    /bin/rm -f d3pd.ascii.diff
+    diff -urN $reffile $chkfile >& d3pd.ascii.diff
+    sc=$?
+    echo "::: comparing ascii dumps...[$sc]"
+    if [ $sc -ne 0 ]; then
+	    return $sc
+    fi
+    echo "::: comparing output n-tuples..."
+    acmd.py diff-root d3pd.root d3pd_2.root -t egamma 2> /dev/null
+    sc=$?
+    echo "::: comparing output n-tuples...[$sc]"
+    if [ $sc -ne 0 ]; then
+	    return $sc
+    fi
+
+    echo ""
+    echo "::::::::::::::::::::::::::::::::::::::::::::::"
+    echo "::: run athena-ntuple-dumper... (w/ varhandles, w/o output)"
+    time_cmd="/usr/bin/time -a -o d3pd.rw.timing.log"
+    /bin/rm -rf d3pd.rw.timing.log >& /dev/null
+    IIMAX=5
+    for ii in `seq $IIMAX`; do
+        echo " - iter $ii/$IIMAX..."
+        ($time_cmd athena.py -c'USEVARHANDLE=1; DOWRITE=0' -lERROR AthenaRootComps/test_athena_ntuple_dumper.py >& d3pd.001.$ii.log.txt) || return 1
+    done
+    grep "user" d3pd.rw.timing.log
+    echo "::: comparing ascii dumps..."
+    /bin/rm -f d3pd.ascii.diff
+    diff -urN $reffile $chkfile >& d3pd.ascii.diff
+    sc=$?
+    echo "::: comparing ascii dumps...[$sc]"
+
+    if [ $sc -ne 0 ]; then
+	    return $sc
+    fi
+
+    echo ""
+    echo "::::::::::::::::::::::::::::::::::::::::::::::"
+    echo "::: run athena-ntuple-dumper... (w/ varhandles)"
+    time_cmd="/usr/bin/time -a -o d3pd.rw.timing.log"
+    /bin/rm -rf d3pd.rw.timing.log >& /dev/null
+    IIMAX=5
+    for ii in `seq $IIMAX`; do
+        echo " - iter $ii/$IIMAX..."
+        ($time_cmd athena.py -c'USEVARHANDLE=1' -lERROR AthenaRootComps/test_athena_ntuple_dumper.py >& d3pd.002.$ii.log.txt) || return 1
+    done
+    grep "user" d3pd.rw.timing.log
+    echo "::: comparing ascii dumps..."
+    /bin/rm -f d3pd.ascii.diff
+    diff -urN $reffile $chkfile >& d3pd.ascii.diff
+    sc=$?
+    echo "::: comparing ascii dumps...[$sc]"
+
+    if [ $sc -ne 0 ]; then
+	    return $sc
+    fi
+
+
+    echo ""
+    echo "::::::::::::::::::::::::::::::::::::::::::::::"
+    echo "::: run athena-ntuple-dumper... (w/o varhandles)"
+    time_cmd="/usr/bin/time -a -o d3pd.rw.timing.log"
+    /bin/rm -rf d3pd.rw.timing.log >& /dev/null
+    IIMAX=5
+    for ii in `seq $IIMAX`; do
+        echo " - iter $ii/$IIMAX..."
+        ($time_cmd athena.py -c'USEVARHANDLE=0' -lERROR AthenaRootComps/test_athena_ntuple_dumper.py >& d3pd.003.$ii.log.txt) || return 1
+    done
+    grep "user" d3pd.rw.timing.log
     echo "::: comparing ascii dumps..."
     /bin/rm -f d3pd.ascii.diff
     diff -urN $reffile $chkfile >& d3pd.ascii.diff
 	return $sc
     fi
 
+    echo ""
+    echo "::::::::::::::::::::::::::::::::::::::::::::::"
     echo "::: reading back n-tuple file..."
     /bin/mv d3pd.root rb.d3pd.root || return 1
     /bin/rm -f $chkfile > /dev/null
-    ($time_cmd athena.py -c'FNAMES=["rb.d3pd.root"]' AthenaRootComps/test_athena_ntuple_dumper.py >& d3pd.002.log.txt) || return 1
-    /bin/cat d3pd.timing.log
+    time_cmd="/usr/bin/time -a -o d3pd.rb.timing.log"
+    /bin/rm -rf d3pd.rb.timing.log >& /dev/null
+    for ii in `seq $IIMAX`; do
+        echo " - iter $ii/$IIMAX..."
+        ($time_cmd athena.py -c'FNAMES=["rb.d3pd.root"]' -lERROR AthenaRootComps/test_athena_ntuple_dumper.py >& d3pd.004.$ii.log.txt) || return 1
+    done
+    grep "user" d3pd.rb.timing.log
     echo "::: comparing ascii dumps..."
     /bin/rm -f rb.d3pd.ascii.diff
     diff -urN $reffile $chkfile >& rb.d3pd.ascii.diff