Commit c74ba1ab authored by Scott Snyder's avatar Scott Snyder Committed by Graeme Stewart
Browse files

Add PackedContainer tests. (DataModelTestDataWrite-01-03-15)

	* Tagging DataModelTestDataWrite-01-03-15.
	* Add PackedContainer tests.
parent 33b7c074
......@@ -21,9 +21,12 @@
#include "DataModelTestDataWrite/DVec.h"
#include "DataModelTestDataWrite/DDer.h"
#include "DataModelTestDataWrite/ELVec.h"
#include "DataModelTestDataWrite/G.h"
#include "DataModelTestDataWrite/GVec.h"
#include "DataModelTestDataWrite/GAuxContainer.h"
struct dummy {
struct GCCXML_DUMMY_INSTANTIATION_DATAMODELTESTDATAWRITE {
ElementLink<DMTest::BVec> m_dum1;
DataLink<DMTest::BVec> m_dum2;
};
......
// 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/G.h
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2014
* @brief Test for xAOD auto schema evolution.
*/
#ifndef DATAMODELTESTDATAWRITE_G_H
#define DATAMODELTESTDATAWRITE_G_H
#include "DataModelTestDataWrite/versions/G_v1.h"
namespace DMTest {
typedef G_v1 G;
} // namespace DMTest
#endif // not DATAMODELTESTDATAWRITE_G_H
// 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/GAuxContainer.h
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2014
* @brief Test for xAOD auto schema evolution.
*/
#ifndef DATAMODELTESTDATAWRITE_GAUXCONTAINER_H
#define DATAMODELTESTDATAWRITE_GAUXCONTAINER_H
#include "DataModelTestDataWrite/versions/GAuxContainer_v1.h"
namespace DMTest {
typedef GAuxContainer_v1 GAuxContainer;
} // namespace DMTest
#endif // not DATAMODELTESTDATAWRITE_GAUXCONTAINER_H
// 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/versions/GVec.h
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2014
* @brief Test for xAOD auto schema evolution.
*/
#ifndef DATAMODELTESTDATAWRITE_GVEC_H
#define DATAMODELTESTDATAWRITE_GVEC_H
#include "DataModelTestDataWrite/versions/GVec_v1.h"
namespace DMTest {
typedef GVec_v1 GVec;
} // namespace DMTest
#endif // not DATAMODELTESTDATAWRITE_GVEC_H
......@@ -23,4 +23,8 @@
</class>
<class name="std::vector<ElementLink<DataVector<DMTest::B> > >"/>
<class name="DMTest::G_v1" id="0EA73CDC-FBD0-4241-9041-14D276B604CC"/>
<class name="DMTest::GVec_v1" id="C532D340-6D58-444F-9C34-54C7A3D645AD"/>
<class name="DMTest::GAuxContainer_v1" id="E70544A9-9D77-475E-AAD8-C5F967A44B66"/>
</lcgdict>
// 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/versions/GAuxContainer_v1.h
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2014
* @brief Test for xAOD auto schema evolution.
*/
#ifndef DATAMODELTESTDATAWRITE_GAUXCONTAINER_V1_H
#define DATAMODELTESTDATAWRITE_GAUXCONTAINER_V1_H
#include "xAODCore/AuxContainerBase.h"
#include "SGTools/CLASS_DEF.h"
#include "SGTools/BaseInfo.h"
#include <vector>
namespace DMTest {
class GAuxContainer_v1
: public xAOD::AuxContainerBase
{
public:
GAuxContainer_v1();
private:
std::vector<int> anInt;
};
} // namespace DMTest
CLASS_DEF (DMTest::GAuxContainer_v1, 9742, 1)
SG_BASE (DMTest::GAuxContainer_v1, xAOD::AuxContainerBase);
#endif // not DATAMODELTESTDATAWRITE_GAUXCONTAINER_V1_H
// 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/versions/GVec_v1.h
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2014
* @brief Test for xAOD auto schema evolution.
*/
#ifndef DATAMODELTESTDATAWRITE_GVEC_V1_H
#define DATAMODELTESTDATAWRITE_GVEC_V1_H
#include "DataModelTestDataWrite/versions/G_v1.h"
#include "AthContainers/DataVector.h"
#include "SGTools/CLASS_DEF.h"
namespace DMTest {
typedef DataVector<G_v1> GVec_v1;
} // namespace DMTest
CLASS_DEF (DMTest::GVec_v1, 9741, 1)
#endif // not DATAMODELTESTDATAWRITE_GVEC_V1_H
// 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/versions/G_v1.h
* @file G_v1.h
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2014
* @brief Test for xAOD auto schema evolution.
*/
#ifndef DATAMODELTESTDATAWRITE_G_V1_H
#define DATAMODELTESTDATAWRITE_G_V1_H
#include "AthContainers/AuxElement.h"
#include "SGTools/CLASS_DEF.h"
#include "SGTools/BaseInfo.h"
namespace DMTest {
class G_v1
: public SG::AuxElement
{
public:
int anInt() const;
void setAnInt (int i);
};
} // namespace DMTest
CLASS_DEF (DMTest::G_v1, 9744, 1)
SG_BASE (DMTest::G_v1, SG::AuxElement);
#endif // not DATAMODELTESTDATAWRITE_G_V1_H
......@@ -19,10 +19,12 @@ use DataModelTestDataCommon DataModelTestDataCommon-* Control/DataModelTest
use GaudiInterface GaudiInterface-* External
use CLIDSvc CLIDSvc-* Control
use SGTools SGTools-* Control
use xAODCore xAODCore-* Event/xAOD
private
use AthenaKernel AthenaKernel-* Control
use AthContainersInterfaces AthContainersInterfaces-* Control
use StoreGate StoreGate-* Control
use AthenaBaseComps AthenaBaseComps-* Control
end_private
......@@ -38,4 +40,5 @@ macro elemLinks_DataModelTestDataWrite "DataVector<DMTest::B>"
apply_tag no_rootmap
apply_pattern lcgdict dict=DataModelTestDataWrite selectionfile=selection.xml\
headerfiles="../DataModelTestDataWrite/DataModelTestDataWriteDict.h" \
elementLinks="$(elemLinks_DataModelTestDataWrite)"
elementLinks="$(elemLinks_DataModelTestDataWrite)" \
extralibfiles=../src/dict/*.cxx
......@@ -17,10 +17,20 @@
#include "DataModelTestDataCommon/BAuxStandalone.h"
#include "DataModelTestDataCommon/BAuxVec.h"
#include "AthContainers/AuxStoreInternal.h"
#include "AthContainersInterfaces/AuxDataOption.h"
#include "AthLinks/ElementLink.h"
#include "AthenaKernel/errorcheck.h"
#define CHECK_OPTION(ret) \
do { \
if (!ret) { \
ATH_MSG_ERROR("setOption failed"); \
return StatusCode::FAILURE; \
} \
} while(0)
namespace DMTest {
......@@ -63,6 +73,15 @@ StatusCode AuxDataTestWrite::execute()
static BAux::Accessor<DMTest::B> aB ("aB");
static BAux::Decorator<float> dFloat1 ("dFloat1");
static BAux::Accessor<unsigned int> pint ("pint");
static BAux::Accessor<float> pfloat ("pfloat");
static BAux::Accessor<std::vector<int> > pvint ("pvint");
static BAux::Accessor<std::vector<float> > pvfloat ("pvfloat");
CHECK_OPTION( vec->setOption ("pint", "nbits", 3) );
CHECK_OPTION( vec->setOption ("pvfloat", SG::AuxDataOption ("nbits", 13)) );
CHECK_OPTION( vec->setOption ("pvfloat", SG::AuxDataOption ("nmantissa",12)));
for (int i=0; i < 10; i++) {
vec->push_back (new BAux (i + m_count * 1000));
BAux& b = *vec->back();
......@@ -70,7 +89,27 @@ StatusCode AuxDataTestWrite::execute()
aFloat1(b) = m_count*1000 + i+200 + 0.5;
dFloat1(b) = m_count*1000 + i+400 + 0.5;
aB(b).m_x = m_count*1000 + i+300;
pint(b) = (m_count*2 + i) % 3;
pfloat(b) = i + (float)m_count / 100;
std::vector<int> pvi;
for (int j=0; j<i; j++)
pvi.push_back (j + i*10 + m_count*100 - 500);
pvint(b) = pvi;
std::vector<float> pvf;
for (int j=0; j<i; j++)
pvf.push_back ((float)j/10 + (float)i/100 + (float)m_count/1000 - 0.5);
pvfloat(b) = std::move (pvf);
}
CHECK_OPTION( vec->setOption ("pfloat", SG::AuxDataOption ("nbits", 17)) );
CHECK_OPTION( vec->setOption ("pfloat", SG::AuxDataOption ("signed", 0)) );
CHECK_OPTION( vec->setOption ("pfloat", SG::AuxDataOption ("nmantissa", 17)));
CHECK_OPTION( vec->setOption ("pfloat", SG::AuxDataOption ("scale", 10)) );
CHECK_OPTION( vec->setOption ("pvint", SG::AuxDataOption ("nbits", 13)) );
CHECK( evtStore()->record (vec, "bauxvec") );
CHECK( evtStore()->record (store, "bauxvecAux.") );
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
/**
* @file DataModelTestDataWrite/src/GAuxContainer_v1.cxx
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2014
* @brief Test for xAOD auto schema evolution.
*/
#include "DataModelTestDataWrite/versions/GAuxContainer_v1.h"
#include "AthContainersInterfaces/AuxDataOption.h"
#include <stdexcept>
namespace DMTest {
GAuxContainer_v1::GAuxContainer_v1()
: xAOD::AuxContainerBase()
{
AUX_VARIABLE (anInt);
}
} // namespace DMTest
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
/**
* @file DataModelTestDataWrite/src/G_v1.cxx
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2014
* @brief Test for xAOD auto schema evolution.
*/
#include "DataModelTestDataWrite/versions/G_v1.h"
#include "xAODCore/AuxStoreAccessorMacros.h"
namespace DMTest {
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER (G_v1, int, anInt, setAnInt)
} // namespace DMTest
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "xAODCore/AddDVProxy.h"
#include "DataModelTestDataWrite/GVec.h"
ADD_NS_DV_PROXY (DMTest, GVec);
......@@ -4,7 +4,7 @@
// $Id$
/**
* @file src/xAODTestWrite.cxx
* @file DataModelTestDataWrite/src/xAODTestWrite.cxx
* @author snyder@bnl.gov
* @date May 2014
* @brief Algorithm to test writing xAOD classes with auxiliary data.
......@@ -17,10 +17,23 @@
#include "DataModelTestDataCommon/CAuxContainer.h"
#include "DataModelTestDataCommon/CTrigAuxContainer.h"
#include "DataModelTestDataCommon/CInfoAuxContainer.h"
#include "DataModelTestDataWrite/GVec.h"
#include "DataModelTestDataWrite/G.h"
#include "DataModelTestDataWrite/GAuxContainer.h"
#include "AthContainersInterfaces/AuxDataOption.h"
#include "AthLinks/ElementLink.h"
#include "AthenaKernel/errorcheck.h"
#define CHECK_OPTION(ret) \
do { \
if (!ret) { \
ATH_MSG_ERROR("setOption failed"); \
return StatusCode::FAILURE; \
} \
} while(0)
namespace DMTest {
......@@ -61,9 +74,9 @@ StatusCode xAODTestWrite::execute()
DMTest::CTrigAuxContainer* trig_store = new DMTest::CTrigAuxContainer;
trig_coll->setStore (trig_store);
DMTest::C* c = new DMTest::C;
DMTest::C* cinfo = new DMTest::C;
DMTest::CInfoAuxContainer* info_store = new DMTest::CInfoAuxContainer;
c->setStore (info_store);
cinfo->setStore (info_store);
CHECK( evtStore()->record (coll, "cvec") );
CHECK( evtStore()->record (store, "cvecAux.") );
......@@ -72,17 +85,45 @@ StatusCode xAODTestWrite::execute()
static C::Decorator<int> dInt1 ("dInt1");
static C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL");
//static C::Decorator<SG::PackedElement<unsigned int> > dpInt1 ("dpInt1");
//static C::Decorator<SG::PackedElement<std::vector<float> > > dpvFloat ("dpvFloat");
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/10);
c.setPInt (m_count * 500 + i+1);
c.setPFloat (i + (float)m_count / 100);
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/10 + (float)i/100 + (float)m_count/1000 - 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/10 + (float)m_count/100 + (float)j/1000);
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();
......@@ -93,10 +134,10 @@ StatusCode xAODTestWrite::execute()
dInt1(c) = m_count*480 + i+1;
}
c->setAnInt (m_count * 1000);
c->setAFloat ((float)m_count / 10);
anInt2(*c) = m_count * 2000;
dInt1(*c) = m_count * 3000;
cinfo->setAnInt (m_count * 1000);
cinfo->setAFloat ((float)m_count / 10);
anInt2(*cinfo) = m_count * 2000;
dInt1(*cinfo) = m_count * 3000;
CHECK( evtStore()->setConst (coll) );
CHECK( evtStore()->setConst (store) );
......@@ -106,13 +147,28 @@ StatusCode xAODTestWrite::execute()
CHECK( evtStore()->setConst (trig_coll) );
CHECK( evtStore()->setConst (trig_store) );
cEL(*c).toIndexedElement (*coll, m_count % coll->size());
cEL(*cinfo).toIndexedElement (*coll, m_count % coll->size());
CHECK( evtStore()->record (c, "cinfo") );
CHECK( evtStore()->record (cinfo, "cinfo") );
CHECK( evtStore()->record (info_store, "cinfoAux.") );
CHECK( evtStore()->setConst (c) );
CHECK( evtStore()->setConst (cinfo) );
CHECK( evtStore()->setConst (info_store) );
DMTest::GVec* gvec = new DMTest::GVec;
DMTest::GAuxContainer* gstore = new DMTest::GAuxContainer;
gvec->setStore (gstore);
for (int i=0; i < 10; i++) {
gvec->push_back (new DMTest::G);
G& g = *gvec->back();
g.setAnInt (m_count * 700 + i+1);
}
CHECK( evtStore()->record (gvec, "gvec") );
CHECK( evtStore()->record (gstore, "gvecAux.") );
CHECK( evtStore()->setConst (gvec) );
CHECK( evtStore()->setConst (gstore) );
return StatusCode::SUCCESS;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment