Skip to content
Snippets Groups Projects
Commit a17840a5 authored by John Derek Chapman's avatar John Derek Chapman Committed by Frank Winklmeier
Browse files

New HepMcParticleLink_p3-based InDetSimDataCollection persistent type (ATLASSIM-6912)

Implement new InDetSimData_p3 and InDetSimDataCollection_p4 based on HepMcParticleLink_p3 (ATLASSIM-6912)
parent 3fe8c9bf
No related branches found
No related tags found
No related merge requests found
Showing
with 288 additions and 22 deletions
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
# Declare the package name:
atlas_subdir( InDetEventAthenaPool )
......@@ -11,7 +11,7 @@ atlas_add_library( InDetEventAthenaPool
AthenaBaseComps AthenaKernel SGTools StoreGateLib AthenaPoolCnvSvcLib
AthenaPoolUtilities GaudiKernel InDetIdentifier
InDetReadoutGeometry TRT_ReadoutGeometry InDetEventTPCnv InDetRawData InDetSimData
InDetLowBetaInfo InDetPrepRawData SCT_ConditionsData TrkTrack )
InDetLowBetaInfo InDetPrepRawData SCT_ConditionsData TrkTrack )
atlas_add_poolcnv_library( InDetEventAthenaPoolPoolCnv
FILES InDetRawData/PixelRDO_Container.h InDetRawData/SCT_RDO_Container.h
......@@ -55,6 +55,7 @@ foreach( name
InDetSimDataCollectionCnv_p1_test
InDetSimDataCollectionCnv_p2_test
InDetSimDataCollectionCnv_p3_test
InDetSimDataCollectionCnv_p4_test
TRT_LoLumRawDataContainerCnv_p1_test
TRT_LoLumRawDataContainerCnv_p2_test
TRT_LoLumRawDataContainerCnv_p3_test )
......@@ -62,7 +63,7 @@ foreach( name
atlas_add_test( ${name}
SOURCES test/${name}.cxx
LINK_LIBRARIES
AtlasHepMCLib IdDict IdDictParser InDetEventAthenaPool TestTools CxxUtils
AtlasHepMCLib IdDict IdDictParser InDetEventAthenaPool TruthUtils TestTools CxxUtils
ENVIRONMENT "JOBOPTSEARCHPATH=${CMAKE_CURRENT_SOURCE_DIR}/share"
POST_EXEC_SCRIPT nopost.sh )
set_target_properties ( InDetEventAthenaPool_${name} PROPERTIES ENABLE_EXPORTS True )
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INDETEVENTATHENAPOOLDICT_H
#define INDETEVENTATHENAPOOLDICT_H
#ifndef INDETEVENTATHENAPOOL_INDETEVENTATHENAPOOLDICT_H
#define INDETEVENTATHENAPOOL_INDETEVENTATHENAPOOLDICT_H
#include "InDetEventAthenaPool/InDetSimData_p1.h"
#include "InDetEventAthenaPool/InDetSimData_p2.h"
#include "InDetEventAthenaPool/InDetSimData_p3.h"
#include "InDetEventAthenaPool/InDetSimDataCollection_p1.h"
#include "InDetEventAthenaPool/InDetSimDataCollection_p2.h"
#include "InDetEventAthenaPool/InDetSimDataCollection_p3.h"
#include "InDetEventAthenaPool/InDetSimDataCollection_p4.h"
#include "InDetEventAthenaPool/InDetRawData_p1.h"
#include "InDetEventAthenaPool/SCT3_RawData_p1.h"
#include "InDetEventAthenaPool/SCT3_RawData_p2.h"
......@@ -31,6 +33,7 @@ namespace InDetEventAthenaPoolCnvDict
std::pair<unsigned long long, InDetSimData_p2> t2;
std::vector<std::pair<unsigned int, InDetSimData_p2> > t3;
std::vector<std::pair<unsigned long long, InDetSimData_p2> > t4;
std::vector<std::pair<unsigned long long, InDetSimData_p3> > t5;
}
#endif
#endif // INDETEVENTATHENAPOOL_INDETEVENTATHENAPOOLDICT_H
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INDETEVENTATHENAPOOL_INDETSIMDATACOLLECTION_P4_H
#define INDETEVENTATHENAPOOL_INDETSIMDATACOLLECTION_P4_H
#include <vector>
#include <utility>
#include "InDetEventAthenaPool/InDetSimData_p3.h"
#include "Identifier/Identifier.h"
class InDetSimDataCollection_p4
{
public:
InDetSimDataCollection_p4()
{ } ;
// container cnv does conversion
friend class InDetSimDataCollectionCnv_p4;
private:
std::vector<std::pair<Identifier::value_type, InDetSimData_p3> > m_simdata;
};
#endif // INDETEVENTATHENAPOOL_INDETSIMDATA_P4_H
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INDETEVENTATHENAPOOL_INDETSIMDATA_P3_H
#define INDETEVENTATHENAPOOL_INDETSIMDATA_P3_H
#include <vector>
#include "GeneratorObjectsTPCnv/HepMcParticleLink_p3.h"
class InDetSimData_p3 {
public:
InDetSimData_p3():m_word(0), m_links{}, m_enDeposits{} {};
// List of Cnv classes that convert this into SimData objects
friend class InDetSimDataCnv_p3;
private:
unsigned int m_word; // sim data word
std::vector<HepMcParticleLink_p3> m_links; // HepMCPLs
std::vector<float> m_enDeposits; // energy deposits
};
#endif // INDETEVENTATHENAPOOL_INDETSIMDATA_P3_H
......@@ -11,9 +11,13 @@
<class name="std::vector<std::pair<unsigned int, InDetSimData_p2> >" />
<class pattern="std::*pair*<unsigned long long, InDetSimData_p2>" />
<class name="std::vector<std::pair<unsigned long long, InDetSimData_p2> >" />
<class name="InDetSimData_p3" />
<class pattern="std::*pair*<unsigned long long, InDetSimData_p3>" />
<class name="std::vector<std::pair<unsigned long long, InDetSimData_p3> >" />
<class name="InDetSimDataCollection_p1" id="333EF996-1672-4AB8-917D-187F908F1EDE" />
<class name="InDetSimDataCollection_p2" id="C648CA66-013D-44AC-B0D9-99BFB0060E84" />
<class name="InDetSimDataCollection_p3" id="1430AA7B-EE92-5A41-92F3-5DD5367D6BAA" />
<class name="InDetSimDataCollection_p4" id="018E50BB-B807-75F9-828A-890C9AD1F7CB" />
<class name="InDetRawData_p1" />
<class name="InDetRawData_p2" />
<class name="SCT3_RawData_p1" />
......
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#include "InDetSimData/InDetSimData.h"
#include "MsgUtil.h"
// Persistent class and converter header file
#include "InDetEventAthenaPool/InDetSimData_p3.h"
#include "InDetSimDataCnv_p3.h"
#include "AthenaBaseComps/AthMessaging.h"
using depositIterator = std::vector<InDetSimData::Deposit>::const_iterator;
InDetSimDataCnv_p3::InDetSimDataCnv_p3()
: m_sg(nullptr)
{
}
void
InDetSimDataCnv_p3::persToTrans(const InDetSimData_p3* persObj, InDetSimData* transObj, MsgStream &log)
{
MSG_VERBOSE(log,"InDetSimDataCnv_p3::persToTrans called ");
std::vector<InDetSimData::Deposit> deposits;
const unsigned int ndeposits = persObj->m_enDeposits.size();
deposits.reserve( ndeposits );
for (unsigned int icount=0; icount < ndeposits; icount++) {
HepMcParticleLink mcLink (m_sg);
HepMcPLCnv.persToTrans(&(persObj->m_links[icount]),&mcLink, log);
deposits.emplace_back (mcLink, persObj->m_enDeposits[icount]);
}
*transObj = InDetSimData (std::move(deposits),
persObj->m_word);
}
void
InDetSimDataCnv_p3::transToPers(const InDetSimData* transObj, InDetSimData_p3* persObj, MsgStream &log)
{
MSG_VERBOSE(log,"InDetSimDataCnv_p3::transToPers called ");
HepMcParticleLinkCnv_p3 HepMcPLCnv;
persObj->m_word = transObj->word();
const std::vector<InDetSimData::Deposit> &dep(transObj->getdeposits());
const unsigned int ndeposits = dep.size();
persObj->m_links.resize(ndeposits);
persObj->m_enDeposits.resize(ndeposits);
for (unsigned int icount(0); icount < ndeposits; ++icount) {
HepMcPLCnv.transToPers(&(dep[icount].first), &(persObj->m_links[icount]), log);
persObj->m_enDeposits[icount] = dep[icount].second;
}
}
void InDetSimDataCnv_p3::setCurrentStore (IProxyDict* store)
{
m_sg = store;
}
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INDETEVENTATHENAPOOL_INDETSIMDATACNV_P3_H
#define INDETEVENTATHENAPOOL_INDETSIMDATACNV_P3_H
/*
Transient/Persistent converter for InDetSimData class
Author: Davide Costanzo
*/
#include "InDetSimData/InDetSimData.h"
#include "InDetEventAthenaPool/InDetSimData_p3.h"
#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h"
#include "GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p3.h"
class MsgStream;
class IProxyDict;
class InDetSimDataCnv_p3 : public T_AthenaPoolTPCnvBase<InDetSimData, InDetSimData_p3>
{
public:
InDetSimDataCnv_p3();
virtual void persToTrans(const InDetSimData_p3* persObj, InDetSimData* transObj, MsgStream &log);
virtual void transToPers(const InDetSimData* transObj, InDetSimData_p3* persObj, MsgStream &log);
void setCurrentStore (IProxyDict* store);
private:
IProxyDict* m_sg;
HepMcParticleLinkCnv_p3 HepMcPLCnv;
};
#endif // INDETEVENTATHENAPOOL_INDETSIMDATACNV_P3_H
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#include "InDetSimDataCollectionCnv.h"
#include "InDetSimDataCollectionCnv_p1.h"
#include "InDetSimDataCollectionCnv_p2.h"
#include "InDetSimDataCollectionCnv_p3.h"
#include "InDetSimDataCollectionCnv_p4.h"
InDetSimDataCollection_PERS* InDetSimDataCollectionCnv::createPersistent(InDetSimDataCollection* transCont) {
......@@ -18,14 +22,20 @@ InDetSimDataCollection* InDetSimDataCollectionCnv::createTransient() {
InDetSimDataCollectionCnv_p1 converter_p1;
InDetSimDataCollectionCnv_p2 converter_p2;
InDetSimDataCollectionCnv_p3 converter_p3;
InDetSimDataCollectionCnv_p4 converter_p4;
InDetSimDataCollection *trans_cont(nullptr);
static const pool::Guid p4_guid("018E50BB-B807-75F9-828A-890C9AD1F7CB");
static const pool::Guid p3_guid("1430AA7B-EE92-5A41-92F3-5DD5367D6BAA");
static const pool::Guid p2_guid("C648CA66-013D-44AC-B0D9-99BFB0060E84");
static const pool::Guid p1_guid("333EF996-1672-4AB8-917D-187F908F1EDE");
static const pool::Guid old_guid("5A50C32E-C036-4A49-AE97-716D53210BE1");
if( this->compareClassGuid(p3_guid)) {
if( this->compareClassGuid(p4_guid)) {
std::unique_ptr< InDetSimDataCollection_p4 > col_vect( this->poolReadObject< InDetSimDataCollection_p4 >() );
trans_cont = converter_p4.createTransient( col_vect.get(), mlog );
}
else if( this->compareClassGuid(p3_guid)) {
std::unique_ptr< InDetSimDataCollection_p3 > col_vect( this->poolReadObject< InDetSimDataCollection_p3 >() );
trans_cont = converter_p3.createTransient( col_vect.get(), mlog );
}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INDETSIMDATACOLLECTIONCNV_H
#define INDETSIMDATACOLLECTIONCNV_H
#ifndef INDETEVENTATHENAPOOL_INDETSIMDATACOLLECTIONCNV_H
#define INDETEVENTATHENAPOOL_INDETSIMDATACOLLECTIONCNV_H
#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h"
#include "InDetSimData/InDetSimDataCollection.h"
#include "InDetSimDataCollectionCnv_p1.h"
#include "InDetSimDataCollectionCnv_p2.h"
#include "InDetSimDataCollectionCnv_p3.h"
#include "InDetSimDataCollectionCnv_p4.h"
// Gaudi
#include "GaudiKernel/MsgStream.h"
......@@ -18,12 +19,12 @@
typedef InDetSimDataCollection_p3 InDetSimDataCollection_PERS;
typedef InDetSimDataCollectionCnv_p3 InDetSimDataCollectionCnv_PERS;
// base class
// base class
typedef T_AthenaPoolCustomCnv<InDetSimDataCollection, InDetSimDataCollection_PERS > InDetSimDataCollectionCnvBase;
class InDetSimDataCollectionCnv : public InDetSimDataCollectionCnvBase {
friend class CnvFactory<InDetSimDataCollectionCnv >;
protected:
public:
InDetSimDataCollectionCnv (ISvcLocator* svcloc) : InDetSimDataCollectionCnvBase(svcloc) {}
......@@ -31,6 +32,5 @@ protected:
virtual InDetSimDataCollection_PERS* createPersistent (InDetSimDataCollection* transCont);
virtual InDetSimDataCollection* createTransient ();
};
#endif
#endif // INDETEVENTATHENAPOOL_INDETSIMDATACOLLECTIONCNV_H
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#include "InDetSimData/InDetSimData.h"
#include "InDetSimData/InDetSimDataCollection.h"
#include "InDetEventAthenaPool/InDetSimDataCollection_p4.h"
#include "InDetSimDataCollectionCnv_p4.h"
#include "InDetSimDataCnv_p3.h"
#include "Identifier/Identifier.h"
#include "SGTools/CurrentEventStore.h"
#include "MsgUtil.h"
void InDetSimDataCollectionCnv_p4::transToPers(const InDetSimDataCollection* transCont, InDetSimDataCollection_p4* persCont, MsgStream &log)
{
InDetSimDataCnv_p3 simDataCnv;
persCont->m_simdata.resize(transCont->size());
MSG_DEBUG(log," Preparing " << persCont->m_simdata.size() << "Collections");
unsigned int collIndex(0);
for (const auto& transSimDataPair : *transCont) {
// Add in new collection
(persCont->m_simdata[collIndex]).first = transSimDataPair.first.get_compact();
const InDetSimData& simData = transSimDataPair.second;
InDetSimData_p3& psimData = persCont->m_simdata[collIndex].second;
simDataCnv.transToPers(&simData,&psimData,log);
++collIndex;
}
MSG_DEBUG(log," *** Writing InDetSimdataCollection");
}
void InDetSimDataCollectionCnv_p4::persToTrans(const InDetSimDataCollection_p4* persCont, InDetSimDataCollection* transCont, MsgStream &log)
{
InDetSimDataCnv_p3 simDataCnv;
MSG_DEBUG(log," Preparing " << persCont->m_simdata.size() << "Collections");
simDataCnv.setCurrentStore (SG::CurrentEventStore::store());
for (const auto& persSimDataPair : persCont->m_simdata) {
// Add in new collection
const InDetSimData_p3& psimData = persSimDataPair.second;
InDetSimData simData;
simDataCnv.persToTrans(&psimData,&simData,log);
transCont->insert( transCont->end(), std :: make_pair( Identifier( persSimDataPair.first ), simData ) );
}
MSG_DEBUG(log," *** Reading InDetSimdataCollection");
}
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INDETEVENTATHENAPOOL_INDETSIMDATACOLLECTIONCNV_P4_H
#define INDETEVENTATHENAPOOL_INDETSIMDATACOLLECTIONCNV_P4_H
// INDetSimDataCollectionCnv_p4, T/P separation of InDetSimData
// author D.Costanzo <davide.costanzo@cern.ch>,O.Arnaez <olivier.arnaez@cern.ch>
#include "InDetSimData/InDetSimDataCollection.h"
#include "InDetEventAthenaPool/InDetSimDataCollection_p4.h"
#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h"
class InDetSimDataCollectionCnv_p4 : public T_AthenaPoolTPCnvBase<InDetSimDataCollection, InDetSimDataCollection_p4>
{
public:
InDetSimDataCollectionCnv_p4() {};
virtual void persToTrans(const InDetSimDataCollection_p4* persCont,
InDetSimDataCollection* transCont,
MsgStream &log) ;
virtual void transToPers(const InDetSimDataCollection* transCont,
InDetSimDataCollection_p4* persCont,
MsgStream &log) ;
};
#endif // INDETEVENTATHENAPOOL_INDETSIMDATACOLLECTIONCNV_P4_H
......@@ -16,6 +16,7 @@
#include "AtlasHepMC/GenEvent.h"
#include "AtlasHepMC/GenParticle.h"
#include "AtlasHepMC/Operators.h"
#include "TruthUtils/MagicNumbers.h"
#include "GeneratorObjectsTPCnv/initMcEventCollection.h"
#include "InDetIdentifier/PixelID.h"
#include "IdDictParser/IdDictParser.h"
......@@ -95,7 +96,7 @@ void test1 ATLAS_NOT_THREAD_SAFE (std::vector<HepMC::GenParticlePtr>& genPartVec
std::cout << "test1\n";
auto particle = genPartVector.at(0);
// Create HepMcParticleLink outside of leak check.
HepMcParticleLink dummyHMPL(HepMC::barcode(particle), particle->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM,HepMcParticleLink::IS_BARCODE);
HepMcParticleLink dummyHMPL(HepMC::uniqueID(particle), particle->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM,HepMcParticleLink::IS_ID);
assert(dummyHMPL.cptr()==particle);
Athena_test::Leakcheck check;
......@@ -103,11 +104,11 @@ void test1 ATLAS_NOT_THREAD_SAFE (std::vector<HepMC::GenParticlePtr>& genPartVec
// Assumme genPartVector is filled by Athena_test::initMcEventCollection. Do not check the vector size.
for (int i=0; i<3; i++) {
std::vector<InDetSimData::Deposit> deps;
HepMcParticleLink trkLink1(HepMC::barcode(genPartVector.at(0+(3*i))), genPartVector.at(0+(3*i))->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM,HepMcParticleLink::IS_BARCODE);
HepMcParticleLink trkLink1(HepMC::uniqueID(genPartVector.at(0+(3*i))), genPartVector.at(0+(3*i))->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM,HepMcParticleLink::IS_ID);
deps.emplace_back(trkLink1, 2.5+i);
HepMcParticleLink trkLink2(HepMC::barcode(genPartVector.at(1+(3*i))), genPartVector.at(1+(3*i))->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM,HepMcParticleLink::IS_BARCODE);
HepMcParticleLink trkLink2(HepMC::uniqueID(genPartVector.at(1+(3*i))), genPartVector.at(1+(3*i))->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM,HepMcParticleLink::IS_ID);
deps.emplace_back(trkLink2, 13.5+i);
HepMcParticleLink trkLink3(HepMC::barcode(genPartVector.at(2+(3*i))), genPartVector.at(2+(3*i))->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM,HepMcParticleLink::IS_BARCODE);
HepMcParticleLink trkLink3(HepMC::uniqueID(genPartVector.at(2+(3*i))), genPartVector.at(2+(3*i))->parent_event()->event_number(),HepMcParticleLink::IS_EVENTNUM,HepMcParticleLink::IS_ID);
deps.emplace_back(trkLink3, 23.5+i);
trans1[Identifier(1234+i)] = InDetSimData(deps, 4321+i);
......
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file InDetEventAthenaPool/test/InDetSimDataCollectionCnv_p4_test.cxx
* @author Susumu Oda <Susumu.Oda@cern.ch>
* @date 2020-05-22
* @brief Regression tests.
*/
#undef NDEBUG
#include "../src/InDetSimDataCollectionCnv_p4.h"
#include "InDetSimDataCollectionCnv_common_test.h"
int main ATLAS_NOT_THREAD_SAFE ()
{
return commonMain<InDetSimDataCollectionCnv_p4, InDetSimDataCollection_p4>();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment