From 70ff0a3b55c2953bf9990aba3334fe3b3b3616ae Mon Sep 17 00:00:00 2001
From: Scott Snyder <scott.snyder@cern.ch>
Date: Thu, 16 Jun 2016 03:07:42 +0200
Subject: [PATCH] 'Fix TrigNavigation dependency.'
 (DataModelTestDataWrite-01-03-26)

	* Tagging DataModelTestDataWrite-01-03-26.
	* CMakeLists.txt: Fix TrigNavigation dependency.

2016-04-19  scott snyder  <snyder@bnl.gov>

	* Tagging DataModelTestDataWrite-01-03-25.
	* CMakeLists.txt: Fixes.

2016-04-18  scott snyder  <snyder@bnl.gov>

	* Tagging DataModelTestDataWrite-01-03-24.
	* src/HLTResultWriter.h: Fix comment.
	* Tagging DataModelTestDataWrite-01-03-23.
	* Add HLTResultWriter.  Break write of cvec out of xAODTestWrite
	into xAODTestWriteCVec.


Former-commit-id: 2b7e91115d095a23ec4608cfb613d8c302da4a1f
---
 .../DataModelTestDataWrite/CMakeLists.txt     |   8 +-
 .../DataModelTestDataWrite/cmt/requirements   |   4 +
 .../src/HLTResultWriter.cxx                   | 105 ++++++++++++++
 .../src/HLTResultWriter.h                     |  79 ++++++++++
 .../DataModelTestDataWrite_entries.cxx        |   9 +-
 .../src/xAODTestWrite.cxx                     |  55 ++-----
 .../src/xAODTestWrite.h                       |   4 +-
 .../src/xAODTestWriteCVec.cxx                 | 136 ++++++++++++++++++
 .../src/xAODTestWriteCVec.h                   |  74 ++++++++++
 .../src/xAODTestWriteHelper.cxx               |   2 +-
 .../src/xAODTestWriteHelper.h                 |   3 +-
 11 files changed, 422 insertions(+), 57 deletions(-)
 create mode 100644 Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.cxx
 create mode 100644 Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.h
 create mode 100644 Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.cxx
 create mode 100644 Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.h

diff --git a/Control/DataModelTest/DataModelTestDataWrite/CMakeLists.txt b/Control/DataModelTest/DataModelTestDataWrite/CMakeLists.txt
index 5b4756a7545..a605ff609c3 100644
--- a/Control/DataModelTest/DataModelTestDataWrite/CMakeLists.txt
+++ b/Control/DataModelTest/DataModelTestDataWrite/CMakeLists.txt
@@ -16,6 +16,10 @@ atlas_depends_on_subdirs( PUBLIC
                           Event/xAOD/xAODCore
                           GaudiKernel
                           PRIVATE
+                          #Event/xAOD/xAODEventInfo
+                          Event/EventInfo
+                          Trigger/TrigEvent/TrigSteeringEvent
+                          Trigger/TrigEvent/TrigNavigation
                           Control/AthContainersInterfaces
                           Control/AthenaBaseComps
                           Control/AthenaKernel
@@ -30,13 +34,13 @@ atlas_add_library( DataModelTestDataWriteLib
                    src/*.cxx
                    PUBLIC_HEADERS DataModelTestDataWrite
                    PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                   LINK_LIBRARIES AthContainers AthLinks DataModelTestDataCommon SGTools xAODCore GaudiKernel DataModelAthenaPoolLib StoreGateLib SGtests
+                   LINK_LIBRARIES AthContainers AthLinks DataModelTestDataCommon SGTools xAODCore GaudiKernel DataModelAthenaPoolLib StoreGateLib SGtests TrigNavigationLib EventInfo TrigSteeringEvent
                    PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps AthenaKernel CxxUtils )
 
 atlas_add_component( DataModelTestDataWrite
                      src/components/*.cxx
                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthContainers AthLinks DataModelAthenaPoolLib DataModelTestDataCommon SGTools xAODCore GaudiKernel AthenaBaseComps AthenaKernel CxxUtils StoreGateLib SGtests DataModelTestDataWriteLib )
+                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthContainers AthLinks DataModelAthenaPoolLib DataModelTestDataCommon SGTools xAODCore GaudiKernel AthenaBaseComps AthenaKernel CxxUtils StoreGateLib SGtests TrigSteeringEvent DataModelTestDataWriteLib )
 
 atlas_add_dictionary( DataModelTestDataWriteDict
                       DataModelTestDataWrite/DataModelTestDataWriteDict.h
diff --git a/Control/DataModelTest/DataModelTestDataWrite/cmt/requirements b/Control/DataModelTest/DataModelTestDataWrite/cmt/requirements
index d223de7f093..ba97ab217ca 100644
--- a/Control/DataModelTest/DataModelTestDataWrite/cmt/requirements
+++ b/Control/DataModelTest/DataModelTestDataWrite/cmt/requirements
@@ -28,6 +28,10 @@ use AthenaKernel            AthenaKernel-*            Control
 use AthContainersInterfaces AthContainersInterfaces-* Control
 use StoreGate               StoreGate-*               Control
 use AthenaBaseComps         AthenaBaseComps-*         Control
+#use xAODEventInfo           xAODEventInfo-*           Event/xAOD
+use EventInfo               EventInfo-*               Event
+use TrigSteeringEvent       TrigSteeringEvent-*       Trigger/TrigEvent
+use TrigNavigation          TrigNavigation-*          Trigger/TrigEvent
 end_private
 
 ####apply_pattern component_library
diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.cxx
new file mode 100644
index 00000000000..a498a7c0919
--- /dev/null
+++ b/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.cxx
@@ -0,0 +1,105 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// $Id$
+/**
+ * @file DataModelTestDataWrite/src/HLTResultWriter.cxx
+ * @author snyder@bnl.gov
+ * @date Mar, 2016
+ * @brief Test for serializing an xAOD object into bytestream.
+ */
+
+
+#include "HLTResultWriter.h"
+#include "DataModelTestDataCommon/CVec.h"
+#include "DataModelTestDataCommon/C.h"
+#include "DataModelTestDataCommon/CAuxContainer.h"
+#include "TrigNavigation/Navigation.h"
+#include "TrigNavigation/Holder.icc"
+#include "TrigSteeringEvent/HLTResult.h"
+#include "CxxUtils/make_unique.h"
+
+
+HLT_BEGIN_TYPE_REGISTRATION
+  HLT_REGISTER_TYPE(DMTest::C, DMTest::CVec, DMTest::CVec, DMTest::CAuxContainer) 
+HLT_END_TYPE_REGISTRATION(DataModelTest)
+
+
+struct class_DataModelTest
+{
+  typedef TypeInfo_DataModelTest map;
+  static const std::string package_name;
+};
+  
+struct TypeInfo_EDM {
+  typedef HLT::TypeInformation::newlist
+  ::add<class_DataModelTest> ::go
+  ::done map;
+};
+
+
+using HLTNavDetails::HolderImp;
+
+
+namespace DMTest {
+
+
+/**
+ * @brief Constructor.
+ * @param name The algorithm name.
+ * @param svc The service locator.
+ */
+HLTResultWriter::HLTResultWriter (const std::string &name,
+                                    ISvcLocator *pSvcLocator)
+  : AthReentrantAlgorithm (name, pSvcLocator),
+    m_nav ("TestNav", this)
+{
+  declareProperty ("ResultKey", m_resultKey = "HLTResult_HLT");
+  declareProperty ("Nav", m_nav);
+}
+  
+
+/**
+ * @brief Algorithm initialization; called at the beginning of the job.
+ */
+StatusCode HLTResultWriter::initialize()
+{
+  ATH_CHECK( m_resultKey.initialize() );
+  ATH_CHECK( m_nav.retrieve() );
+  HLT::TypeMaps::registerFeatureContainer<DMTest::CVec,DMTest::CVec>();
+  HLT::TypeMaps::registerType<DMTest::CAuxContainer>();
+  return StatusCode::SUCCESS;
+}
+
+
+/**
+ * @brief Algorithm event processing.
+ */
+StatusCode HLTResultWriter::execute_r (const EventContext& ctx) const
+{
+  SG::WriteHandle<HLT::HLTResult> result (m_resultKey, ctx);
+  ATH_CHECK( result.record (CxxUtils::make_unique<HLT::HLTResult>()) );
+
+  m_nav->prepare();
+  if (!m_nav->serialize (result->getNavigationResult(),
+                         result->getNavigationResultCuts(),
+                         result->getNavigationResultIDName()))
+    return StatusCode::FAILURE;
+  m_nav->reset();
+
+  return StatusCode::SUCCESS;
+}
+
+
+/**
+ * @brief Algorithm finalization; called at the end of the job.
+ */
+StatusCode HLTResultWriter::finalize()
+{
+  return StatusCode::SUCCESS;
+}
+
+
+} // namespace DMTest
+
diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.h b/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.h
new file mode 100644
index 00000000000..1737e76d4c7
--- /dev/null
+++ b/Control/DataModelTest/DataModelTestDataWrite/src/HLTResultWriter.h
@@ -0,0 +1,79 @@
+// This file's extension implies that it's C, but it's really -*- C++ -*-.
+
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// $Id$
+/**
+ * @file DataModelTestDataWrite/src/HLTResultWriter.h
+ * @author scott snyder <snyder@bnl.gov>
+ * @date Mar, 2016
+ * @brief Test for serializing an xAOD object into bytestream.
+ */
+
+
+#ifndef DATAMODELTESTDATAWRITE_HLTRESULTWRITER_H
+#define DATAMODELTESTDATAWRITE_HLTRESULTWRITER_H
+
+
+#include "AthenaBaseComps/AthReentrantAlgorithm.h"
+#include "StoreGate/WriteHandleKey.h"
+#include "GaudiKernel/ToolHandle.h"
+
+
+namespace HLT {
+  class HLTResult;
+  class Navigation;
+}
+
+
+namespace DMTest {
+
+
+/**
+ * @brief Test for serializing an xAOD object into bytestream.
+ */
+class HLTResultWriter
+  : public AthReentrantAlgorithm
+{
+public:
+  /**
+   * @brief Constructor.
+   * @param name The algorithm name.
+   * @param svc The service locator.
+   */
+  HLTResultWriter (const std::string &name, ISvcLocator *pSvcLocator);
+  
+
+  /**
+   * @brief Algorithm initialization; called at the beginning of the job.
+   */
+  virtual StatusCode initialize() override;
+
+
+  /**
+   * @brief Algorithm event processing.
+   */
+  virtual StatusCode execute_r (const EventContext& ctx) const override;
+
+
+  /**
+   * @brief Algorithm finalization; called at the end of the job.
+   */
+  virtual StatusCode finalize() override;
+
+
+private:
+  /// Handle to write the HLTResult object.
+  SG::WriteHandleKey<HLT::HLTResult> m_resultKey;
+
+  /// Navigation object use to fill the result.
+  ToolHandle<HLT::Navigation>        m_nav;
+};
+
+
+} // namespace DMTest
+
+
+#endif // not DATAMODELTESTDATAWRITE_HLTRESULTWRITER_H
diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/components/DataModelTestDataWrite_entries.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/components/DataModelTestDataWrite_entries.cxx
index 96080e0d2e2..b3fa5e78c0e 100644
--- a/Control/DataModelTest/DataModelTestDataWrite/src/components/DataModelTestDataWrite_entries.cxx
+++ b/Control/DataModelTest/DataModelTestDataWrite/src/components/DataModelTestDataWrite_entries.cxx
@@ -10,13 +10,12 @@
 #include "../DMTestWrite.h"
 #include "../AuxDataTestWrite.h"
 #include "../xAODTestWrite.h"
+#include "../xAODTestWriteCVec.h"
+#include "../HLTResultWriter.h"
 
 DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, DMTestWrite)
 DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, AuxDataTestWrite)
 DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestWrite)
+DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, xAODTestWriteCVec)
+DECLARE_NAMESPACE_ALGORITHM_FACTORY(DMTest, HLTResultWriter)
 
-DECLARE_FACTORY_ENTRIES(DataModelTestDataWrite) {
-  DECLARE_NAMESPACE_ALGORITHM(DMTest, DMTestWrite);
-  DECLARE_NAMESPACE_ALGORITHM(DMTest, AuxDataTestWrite);
-  DECLARE_NAMESPACE_ALGORITHM(DMTest, xAODTestWrite);
-}
diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.cxx
index 8efdb71964e..77569dcfcfb 100644
--- a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.cxx
+++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.cxx
@@ -28,6 +28,7 @@
 #include "DataModelTestDataWrite/HView.h"
 #include "DataModelTestDataWrite/HAuxContainer.h"
 #include "AthContainersInterfaces/AuxDataOption.h"
+#include "AthContainers/ConstDataVector.h"
 #include "AthLinks/ElementLink.h"
 #include "AthenaKernel/errorcheck.h"
 #include "CxxUtils/make_unique.h"
@@ -54,6 +55,7 @@ xAODTestWrite::xAODTestWrite (const std::string &name,
                               ISvcLocator *pSvcLocator)
   : AthAlgorithm (name, pSvcLocator),
     m_count(0),
+    m_cvecKey ("cvec"),
     m_hvecKey ("hvec")
 {
 }
@@ -64,6 +66,7 @@ xAODTestWrite::xAODTestWrite (const std::string &name,
  */
 StatusCode xAODTestWrite::initialize()
 {
+  ATH_CHECK( m_cvecKey.initialize() );
   ATH_CHECK( m_hvecKey.initialize() );
   return StatusCode::SUCCESS;
 }
@@ -76,9 +79,7 @@ StatusCode xAODTestWrite::execute()
 {
   ++m_count;
 
-  DMTest::CVec* coll = new DMTest::CVec;
-  DMTest::CAuxContainer* store = new DMTest::CAuxContainer;
-  coll->setStore (store);
+  SG::ReadHandle<DMTest::CVec> cvec (m_cvecKey);
 
   DMTest::CVec* trig_coll = new DMTest::CVec;
   DMTest::CTrigAuxContainer* trig_store = new DMTest::CTrigAuxContainer;
@@ -88,9 +89,6 @@ StatusCode xAODTestWrite::execute()
   DMTest::CInfoAuxContainer* info_store = new DMTest::CInfoAuxContainer;
   cinfo->setStore (info_store);
 
-  CHECK( evtStore()->record (coll, "cvec") );
-  CHECK( evtStore()->record (store, "cvecAux.") );
-
   static C::Accessor<int> anInt2 ("anInt2");
   static C::Decorator<int> dInt1 ("dInt1");
   static C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL");
@@ -100,40 +98,6 @@ StatusCode xAODTestWrite::execute()
   static C::Decorator<unsigned int> dpInt1 ("dpInt1");
   static C::Decorator<std::vector<float> > dpvFloat ("dpvFloat");
 
-  for (int i=0; i < 10; i++) {
-    coll->push_back (new DMTest::C);
-    C& c = *coll->back();
-    c.setAnInt (m_count * 100 + i+1);
-    c.setAFloat (m_count * 200 + (float)i*0.1);
-    c.setPInt (m_count * 500 + i+1);
-    c.setPFloat (i + (float)m_count * 0.01);
-
-    std::vector<int> pvi;
-    for (int j=0; j<i; j++)
-      pvi.push_back (j + i*10 + m_count*100 - 500);
-    c.setPVInt (pvi);
-
-    std::vector<float> pvf;
-    for (int j=0; j<i; j++)
-      pvf.push_back ((float)j*0.1 + (float)i*0.01 + (float)m_count*0.001 - 0.5);
-    c.setPVFloat (std::move (pvf));
-
-    anInt2(c) = m_count*300 + i+1;
-    dInt1(c) = m_count*400 + i+1;
-    dpInt1(c) = m_count*50 + i+1;
-    cEL(c).toIndexedElement (*coll, 9-i);
-
-    pvf.clear();
-    for (int j=0; j<i; j++)
-      pvf.push_back ((float)i*0.1 + (float)m_count*0.01 + (float)j*0.001);
-    dpvFloat(c) = std::move(pvf);
-  }
-
-  CHECK_OPTION( coll->setOption ("dpInt1", SG::AuxDataOption ("nbits", 13)) );
-  CHECK_OPTION( coll->setOption ("dpvFloat", SG::AuxDataOption ("nbits", 13)) );
-  CHECK_OPTION( coll->setOption ("dpvFloat", SG::AuxDataOption ("signed", 0)));
-  CHECK_OPTION( coll->setOption ("dpvFloat", SG::AuxDataOption ("nmantissa", 13)) );
-
   for (int i=0; i < 8; i++) {
     trig_coll->push_back (new DMTest::C);
     C& c = *trig_coll->back();
@@ -149,15 +113,12 @@ StatusCode xAODTestWrite::execute()
   anInt2(*cinfo) = m_count * 2000;
   dInt1(*cinfo) = m_count * 3000;
 
-  CHECK( evtStore()->setConst (coll) );
-  CHECK( evtStore()->setConst (store) );
-
   CHECK( evtStore()->record (trig_coll, "ctrig") );
   CHECK( evtStore()->record (trig_store, "ctrigAux.") );
   CHECK( evtStore()->setConst (trig_coll) );
   CHECK( evtStore()->setConst (trig_store) );
 
-  cEL(*cinfo).toIndexedElement (*coll, m_count % coll->size());
+  cEL(*cinfo).toIndexedElement (*cvec, m_count % cvec->size());
 
   CHECK( evtStore()->record (cinfo, "cinfo") );
   CHECK( evtStore()->record (info_store, "cinfoAux.") );
@@ -180,7 +141,7 @@ StatusCode xAODTestWrite::execute()
   CHECK( evtStore()->setConst (gstore) );
 
   CHECK( write_cvec_with_data() );
-  CHECK( write_cview (*coll) );
+  CHECK( write_cview (*cvec) );
   CHECK( write_htest() );
 
   return StatusCode::SUCCESS;
@@ -215,9 +176,9 @@ StatusCode xAODTestWrite::write_cvec_with_data()
 /**
  * @brief Test writing view container.
  */
-StatusCode xAODTestWrite::write_cview (DMTest::CVec& coll)
+StatusCode xAODTestWrite::write_cview (const DMTest::CVec& coll)
 {
-  auto cview = CxxUtils::make_unique<DMTest::CView>();
+  auto cview = CxxUtils::make_unique<ConstDataVector<DMTest::CView> >(SG::VIEW_ELEMENTS);
   for (int i = coll.size()-1; i >= 0; --i)
     cview->push_back (coll[i]);
 
diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.h b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.h
index e3f6bea8237..944728ab08b 100644
--- a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.h
+++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWrite.h
@@ -20,6 +20,7 @@
 #include "DataModelTestDataWrite/HVec.h"
 #include "DataModelTestDataCommon/CVec.h"
 #include "AthenaBaseComps/AthAlgorithm.h"
+#include "StoreGate/ReadHandleKey.h"
 #include "StoreGate/WriteHandleKey.h"
 
 
@@ -64,7 +65,7 @@ private:
   StatusCode write_cvec_with_data();
 
   /// Test writing view container.
-  StatusCode write_cview (DMTest::CVec& coll);
+  StatusCode write_cview (const DMTest::CVec& coll);
 
   /// Test schema evolution involving view container.
   StatusCode write_htest();
@@ -72,6 +73,7 @@ private:
   /// Event counter.
   int m_count;
 
+  SG::ReadHandleKey<DMTest::CVec> m_cvecKey;
   SG::WriteHandleKey<DMTest::HVec> m_hvecKey;
 };
 
diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.cxx
new file mode 100644
index 00000000000..b7d769c82df
--- /dev/null
+++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.cxx
@@ -0,0 +1,136 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// $Id$
+/**
+ * @file DataModelTestDataWrite/src/xAODTestWriteCVec.cxx
+ * @author snyder@bnl.gov
+ * @date Apr 2016
+ * @brief Algorithm to test writing xAOD classes with auxiliary data (cvec).
+ */
+
+
+#include "xAODTestWriteCVec.h"
+#include "EventInfo/EventID.h"
+#include "DataModelTestDataCommon/CVec.h"
+#include "DataModelTestDataCommon/C.h"
+#include "DataModelTestDataCommon/CAuxContainer.h"
+#include "AthContainersInterfaces/AuxDataOption.h"
+#include "AthLinks/ElementLink.h"
+#include "AthenaKernel/errorcheck.h"
+#include "CxxUtils/make_unique.h"
+
+
+#define CHECK_OPTION(ret)                       \
+  do {                                          \
+    if (!ret) {                                 \
+      ATH_MSG_ERROR("setOption failed");        \
+      return StatusCode::FAILURE;               \
+    }                                           \
+  } while(0)
+
+
+namespace DMTest {
+
+
+/**
+ * @brief Constructor.
+ * @param name The algorithm name.
+ * @param svc The service locator.
+ */
+xAODTestWriteCVec::xAODTestWriteCVec (const std::string &name,
+                                      ISvcLocator *pSvcLocator)
+  : AthReentrantAlgorithm (name, pSvcLocator),
+    m_eventInfoKey ("McEventInfo"),
+    m_cvecKey ("cvec")
+{
+  declareProperty ("EventInfoKey", m_eventInfoKey);
+  declareProperty ("CVecKey", m_cvecKey);
+}
+  
+
+/**
+ * @brief Algorithm initialization; called at the beginning of the job.
+ */
+StatusCode xAODTestWriteCVec::initialize()
+{
+  ATH_CHECK( m_eventInfoKey.initialize() );
+  ATH_CHECK( m_cvecKey.initialize() );
+  return StatusCode::SUCCESS;
+}
+
+
+/**
+ * @brief Algorithm event processing.
+ */
+StatusCode xAODTestWriteCVec::execute_r (const EventContext& ctx) const
+{
+  //SG::ReadHandle<xAOD::EventInfo> eventInfo (m_eventInfoKey, ctx);
+  //unsigned int count = eventInfo->eventNumber()  + 1;
+  SG::ReadHandle<EventInfo> eventInfo (m_eventInfoKey, ctx);
+  unsigned int count = eventInfo->event_ID()->event_number() + 1;
+
+  auto coll = CxxUtils::make_unique<DMTest::CVec>();
+  auto store = CxxUtils::make_unique<DMTest::CAuxContainer>();
+  coll->setStore (store.get());
+
+  const static C::Accessor<int> anInt2 ("anInt2");
+  const static C::Decorator<int> dInt1 ("dInt1");
+  const static C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL");
+
+  const static C::Decorator<unsigned int> dpInt1 ("dpInt1");
+  const static C::Decorator<std::vector<float> > dpvFloat ("dpvFloat");
+
+  for (int i=0; i < 10; i++) {
+    coll->push_back (new DMTest::C);
+    C& c = *coll->back();
+    c.setAnInt (count * 100 + i+1);
+    c.setAFloat (count * 200 + (float)i*0.1);
+    c.setPInt (count * 500 + i+1);
+    c.setPFloat (i + (float)count * 0.01);
+
+    std::vector<int> pvi;
+    for (int j=0; j<i; j++)
+      pvi.push_back (j + i*10 + count*100 - 500);
+    c.setPVInt (pvi);
+
+    std::vector<float> pvf;
+    for (int j=0; j<i; j++)
+      pvf.push_back ((float)j*0.1 + (float)i*0.01 + (float)count*0.001 - 0.5);
+    c.setPVFloat (std::move (pvf));
+
+    anInt2(c) = count*300 + i+1;
+    dInt1(c) = count*400 + i+1;
+    dpInt1(c) = count*50 + i+1;
+    cEL(c).toIndexedElement (*coll, 9-i);
+
+    pvf.clear();
+    for (int j=0; j<i; j++)
+      pvf.push_back ((float)i*0.1 + (float)count*0.01 + (float)j*0.001);
+    dpvFloat(c) = std::move(pvf);
+  }
+
+  SG::WriteHandle<DMTest::CVec> cvec (m_cvecKey, ctx);
+  CHECK( cvec.record (std::move(coll), std::move(store)) );
+
+  CHECK_OPTION( cvec->setOption ("dpInt1", SG::AuxDataOption ("nbits", 13)) );
+  CHECK_OPTION( cvec->setOption ("dpvFloat", SG::AuxDataOption ("nbits", 13)) );
+  CHECK_OPTION( cvec->setOption ("dpvFloat", SG::AuxDataOption ("signed", 0)));
+  CHECK_OPTION( cvec->setOption ("dpvFloat", SG::AuxDataOption ("nmantissa", 13)) );
+
+  return StatusCode::SUCCESS;
+}
+
+
+/**
+ * @brief Algorithm finalization; called at the end of the job.
+ */
+StatusCode xAODTestWriteCVec::finalize()
+{
+  return StatusCode::SUCCESS;
+}
+
+
+} // namespace DMTest
+
diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.h b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.h
new file mode 100644
index 00000000000..699c4d75206
--- /dev/null
+++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteCVec.h
@@ -0,0 +1,74 @@
+// This file's extension implies that it's C, but it's really -*- C++ -*-.
+
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// $Id$
+/**
+ * @file DataModelTestDataWrite/src/xAODTestWriteCVec.h
+ * @author scott snyder <snyder@bnl.gov>
+ * @date Apr, 2016
+ * @brief Algorithm to test writing xAOD classes with auxiliary data (cvec).
+ */
+
+
+#ifndef DATAMODELTESTDATAWRITE_XAODTESTWRITECVEC_H
+#define DATAMODELTESTDATAWRITE_XAODTESTWRITECVEC_H
+
+
+//#include "xAODEventInfo/EventInfo.h"
+#include "EventInfo/EventInfo.h"
+#include "DataModelTestDataCommon/CVec.h"
+#include "AthenaBaseComps/AthReentrantAlgorithm.h"
+#include "StoreGate/WriteHandleKey.h"
+#include "StoreGate/ReadHandleKey.h"
+
+
+namespace DMTest {
+
+
+/**
+ * @brief Algorithm for creating test aux data.
+ */
+class xAODTestWriteCVec
+  : public AthReentrantAlgorithm
+{
+public:
+  /**
+   * @brief Constructor.
+   * @param name The algorithm name.
+   * @param svc The service locator.
+   */
+  xAODTestWriteCVec (const std::string &name, ISvcLocator *pSvcLocator);
+  
+
+  /**
+   * @brief Algorithm initialization; called at the beginning of the job.
+   */
+  virtual StatusCode initialize() override;
+
+
+  /**
+   * @brief Algorithm event processing.
+   */
+  virtual StatusCode execute_r (const EventContext& ctx) const override;
+
+
+  /**
+   * @brief Algorithm finalization; called at the end of the job.
+   */
+  virtual StatusCode finalize() override;
+
+
+private:
+  //SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey;
+  SG::ReadHandleKey<EventInfo> m_eventInfoKey;
+  SG::WriteHandleKey<DMTest::CVec> m_cvecKey;
+};
+
+
+} // namespace DMTest
+
+
+#endif // not DATAMODELTESTDATAWRITE_XAODTESTWRITECVEC_H
diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.cxx b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.cxx
index 0c4759609a5..f5841d11bb6 100644
--- a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.cxx
+++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.cxx
@@ -19,7 +19,7 @@ namespace DMTest {
 
 
 StatusCode recordView1 (StoreGateSvc* svc,
-                        std::unique_ptr<ViewVector<DMTest::CVec> > view,
+                        std::unique_ptr<ConstDataVector<ViewVector<DMTest::CVec> > > view,
                         const std::string& key)
 {
   return svc->record (std::move(view), key, false);
diff --git a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.h b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.h
index 6bafb4c1600..90756ff55fa 100644
--- a/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.h
+++ b/Control/DataModelTest/DataModelTestDataWrite/src/xAODTestWriteHelper.h
@@ -22,13 +22,14 @@
 #include "DataModelTestDataWrite/HVec.h"
 #include "StoreGate/StoreGateSvc.h"
 #include "AthContainers/ViewVector.h"
+#include "AthContainers/ConstDataVector.h"
 
 
 namespace DMTest {
 
 
 StatusCode recordView1 (StoreGateSvc* svc,
-                        std::unique_ptr<ViewVector<DMTest::CVec> > view,
+                        std::unique_ptr<ConstDataVector<ViewVector<DMTest::CVec> > > view,
                         const std::string& key);
 
 
-- 
GitLab