diff --git a/LArCalorimeter/LArCnv/LArSimEventAthenaPool/cmt/requirements b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/cmt/requirements new file mode 100755 index 0000000000000000000000000000000000000000..3418a0138731caed9c7e63caf9d3b2168ab64f27 --- /dev/null +++ b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/cmt/requirements @@ -0,0 +1,30 @@ +package LArSimEventAthenaPool + +author Hong Ma <hma@bnl.gov> +author Rolf Seuster <Rolf.Seuster@cern.ch> +author RD Schaffer <R.D.Schaffer@cern.ch> + +use AtlasPolicy AtlasPolicy-* +use AthenaPoolUtilities AthenaPoolUtilities-* Database/AthenaPOOL +use AtlasSealCLHEP AtlasSealCLHEP-* Database -no_auto_imports + +private +use GaudiInterface GaudiInterface-* External +use AthenaPoolCnvSvc AthenaPoolCnvSvc-* Database/AthenaPOOL +use LArSimEvent LArSimEvent-* LArCalorimeter +use LArSimEventTPCnv LArSimEventTPCnv-* LArCalorimeter/LArCnv +end_private + + +apply_pattern declare_joboptions files="*.txt *.py" + +macro converters "-s=${LArSimEvent_root}/LArSimEvent LArHitContainer.h LArHitFloatContainer.h " + +apply_pattern poolcnv files=${converters} + +macro_append LArSimEventAthenaPoolPoolCnv_shlibflags "$(LArSimEventAthenaPool_dict_linkopts)" + +#macro_append LArSimEventAthenaPoolPoolCnvGen_dependencies " LArSimEventAthenaPoolCnvDict " +#apply_pattern lcgdict dict=LArSimEventAthenaPoolCnv selectionfile=selection.xml headerfiles="../LArSimEventAthenaPool/LArSimEventAthenaPoolCnvDict.h" + +#macro_append LArSimEventAthenaPoolPoolCnv_dependencies " LArSimEventAthenaPool " diff --git a/LArCalorimeter/LArCnv/LArSimEventAthenaPool/share/LArSimAthenaPool_ReadTest_jobOptions.py b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/share/LArSimAthenaPool_ReadTest_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..f0a7d80066a950c1c4df8c1e8e447a011a04100b --- /dev/null +++ b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/share/LArSimAthenaPool_ReadTest_jobOptions.py @@ -0,0 +1,37 @@ +############################################################### +# +# Job options file +# +#============================================================== +#-------------------------------------------------------------- +# Load POOL support +#-------------------------------------------------------------- +include( "AthenaPoolCnvSvc/ReadAthenaPool_jobOptions.py" ) + +#-------------------------------------------------------------- +# Event related parameters +#-------------------------------------------------------------- +theApp.EvtMax = 200 +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +#-------------------------------------------------------------- +# Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL ) +#-------------------------------------------------------------- +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = 2 +##include "$ATHENASEALSVCROOT/share/AthenaSealSvc_joboptions.txt" +##include "$DETDESCRDICTIONARYROOT/dict/DetDescrDictionary_joboptions.txt" +##include "$LARSIMEVENTROOT/dict/LArSimEvent_joboptions.txt" +##include "$EVENTINFOROOT/dict/EventInfo_joboptions.txt" +theApp.Dlls += [ "LArSim" ] +theApp.TopAlg += [ "LArHitReader" ] +theApp.Dlls += [ "LArSimEventAthenaPoolPoolCnv" ] +EventSelector = Service( "EventSelector" ) +EventSelector.InputCollection = "LArSimTest.root" +PoolSvc = Service( "PoolSvc" ) +#============================================================== +# +# End of job options file +# +############################################################### diff --git a/LArCalorimeter/LArCnv/LArSimEventAthenaPool/share/LArSimAthenaPool_WriteTest_jobOptions.py b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/share/LArSimAthenaPool_WriteTest_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..3b8a111317c0dc5931de91575d5663bcd7f2aca7 --- /dev/null +++ b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/share/LArSimAthenaPool_WriteTest_jobOptions.py @@ -0,0 +1,44 @@ +############################################################### +# +# Job options file +# +#============================================================== +theApp.setup( MONTECARLO ) + +#-------------------------------------------------------------- +# Load POOL support +#-------------------------------------------------------------- +include( "AthenaPoolCnvSvc/WriteAthenaPool_jobOptions.py" ) + +#-------------------------------------------------------------- +# Event related parameters +#-------------------------------------------------------------- +theApp.EvtMax = 20 +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +#-------------------------------------------------------------- +# Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL ) +#-------------------------------------------------------------- +##include "$ATHENASEALSVCROOT/share/AthenaSealSvc_joboptions.txt" +##include "$LARSIMEVENTROOT/dict/LArSimEvent_joboptions.txt" +##include "$IDENTIFIERROOT/dict/Identifier_joboptions.txt" +##include "$EVENTINFOROOT/dict/EventInfo_joboptions.txt" +# LAr Hit +# #include "$TDRDETDESCRATHENAROOTROOT/share/TDRDetDescrAthenaRoot_jobOptions.txt" +# #include "$LARDETMGRDETDESCRCNVROOT/share/LArDetMgrDetDescrCnv_joboptions.txt" +# #include "$LARSIMROOT/share/LArSim_Fake_jobOptions.txt" +theApp.Dlls += [ "LArSim" ] +theApp.TopAlg += [ "LArFakeHitProducer" ] +theApp.Dlls += [ "LArSimEventAthenaPoolPoolCnv" ] +Stream1 = Algorithm( "Stream1" ) +Stream1.ItemList+=["LArHitContainer#*"] +Stream1.ItemList+=["EventInfo#*"] +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = 2 +Stream1.OutputFile="LArSimTest.root" +#============================================================== +# +# End of job options file +# +############################################################### diff --git a/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitContainerCnv.cxx b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..38e8c4b3afb9e505c8c0d7d489139f9b7d706c7e --- /dev/null +++ b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitContainerCnv.cxx @@ -0,0 +1,44 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArSimEventTPCnv/LArHitContainerCnv_p1.h" +#include "LArSimEventTPCnv/LArHitContainerCnv_p2.h" +#include "LArHitContainerCnv.h" +#include "LArSimEventTPCnv/LArHit_p1.h" + +LArHitContainer_PERS* LArHitContainerCnv::createPersistent(LArHitContainer* transCont) { + MsgStream mlog(messageService(), "LArHitContainerConverter" ); + LArHitContainerCnv_p2 converter; + LArHitContainer_PERS *persObj = converter.createPersistent( transCont, mlog ); + return persObj; +} + + +LArHitContainer* LArHitContainerCnv::createTransient() { + MsgStream mlog(messageService(), "LArHitContainerConverter" ); + LArHitContainerCnv_p1 converter_p1; + LArHitContainerCnv_p2 converter_p2; + + LArHitContainer *trans_cont(0); + + static const pool::Guid p2_guid("1F1DE705-E0CE-4F0E-941A-C405CB2CD137"); + static const pool::Guid p1_guid("ED1ECB80-B38C-46DE-94BF-22F9379796DB"); + static const pool::Guid p0_guid("32703AED-CAA5-45ED-B804-8556900CA6B5"); + + if( this->compareClassGuid(p2_guid)) { + std::auto_ptr< LArHitContainer_p2 > col_vect( this->poolReadObject< LArHitContainer_p2 >() ); + trans_cont = converter_p2.createTransient( col_vect.get(), mlog ); + } + else if( this->compareClassGuid(p1_guid)) { + std::auto_ptr< LArHitContainer_p1 > col_vect( this->poolReadObject< LArHitContainer_p1 >() ); + trans_cont = converter_p1.createTransient( col_vect.get(), mlog ); + } + else if( this->compareClassGuid(p0_guid)) { + // old version from before TP separation, just return it + trans_cont = this->poolReadObject<LArHitContainer>(); + } else { + throw std::runtime_error("Unsupported persistent version of Data container"); + } + return trans_cont; +} diff --git a/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitContainerCnv.h b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..42a8d320de4038ec8ccf2152b92188d2c7b79ea1 --- /dev/null +++ b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitContainerCnv.h @@ -0,0 +1,27 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARHITCONTAINERCNV +#define LARHITCONTAINERCNV + +#include "LArSimEvent/LArHitContainer.h" +#include "LArSimEventTPCnv/LArHitContainer_p1.h" +#include "LArSimEventTPCnv/LArHitContainer_p2.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" +// typedef to the latest persistent version +typedef LArHitContainer_p2 LArHitContainer_PERS; + +class LArHitContainerCnv : public T_AthenaPoolCustomCnv<LArHitContainer, LArHitContainer_PERS > { + friend class CnvFactory<LArHitContainerCnv>; +protected: + LArHitContainerCnv(ISvcLocator* svcloc) : T_AthenaPoolCustomCnv<LArHitContainer, LArHitContainer_PERS >( svcloc) {} + LArHitContainer_PERS* createPersistent(LArHitContainer* transCont); + LArHitContainer* createTransient (); +}; + +//#include "LArHitContainerCnv.icc" + +#endif diff --git a/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitFloatContainerCnv.cxx b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitFloatContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..2957e74fcf2c6e33cdbe3aa51dcedb73861d5163 --- /dev/null +++ b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitFloatContainerCnv.cxx @@ -0,0 +1,65 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArSimEventTPCnv/LArHitFloatContainerCnv_p1.h" +#include "LArSimEventTPCnv/LArHitFloatContainerCnv_p2.h" +#include "LArHitFloatContainerCnv.h" +#include "LArSimEvent/LArHitContainer.h" + +LArHitContainer_PERS* LArHitFloatContainerCnv::createPersistent(LArHitFloatContainer* transCont) { + MsgStream mlog(messageService(), "LArHitContainerConverter" ); + LArHitFloatContainerCnv_p2 converter; + LArHitContainer_PERS *persObj = converter.createPersistent( transCont, mlog ); + return persObj; +} + + +LArHitFloatContainer* LArHitFloatContainerCnv::createTransient() { + MsgStream mlog(messageService(), "LArHitFloatContainerConverter" ); + LArHitFloatContainerCnv_p1 converter_p1; + LArHitFloatContainerCnv_p2 converter_p2; + + LArHitFloatContainer *trans_cont(0); + + static const pool::Guid p2_guid("1F1DE705-E0CE-4F0E-941A-C405CB2CD137"); + static const pool::Guid p1_guid("ED1ECB80-B38C-46DE-94BF-22F9379796DB"); + static const pool::Guid p0_guid("32703AED-CAA5-45ED-B804-8556900CA6B5"); + + if( this->compareClassGuid(p2_guid)) { + std::auto_ptr< LArHitContainer_p2 > col_vect( this->poolReadObject< LArHitContainer_p2 >() ); + trans_cont = converter_p2.createTransient( col_vect.get(), mlog ); + } + else if( this->compareClassGuid(p1_guid)) { + std::auto_ptr< LArHitContainer_p1 > col_vect( this->poolReadObject< LArHitContainer_p1 >() ); + trans_cont = converter_p1.createTransient( col_vect.get(), mlog ); + } + else if( this->compareClassGuid(p0_guid)) { + // old version from before TP separation not supported + std::auto_ptr<LArHitContainer> double_cont (this->poolReadObject<LArHitContainer>() ); + trans_cont = this->copyLArHitToFloat(double_cont.get()); + } else { + throw std::runtime_error("Unsupported persistent version of Data container"); + } + return trans_cont; +} + +LArHitFloatContainer* LArHitFloatContainerCnv::copyLArHitToFloat(const LArHitContainer* double_cont) { + + LArHitFloatContainer* float_cont = new LArHitFloatContainer(); + float_cont->clear(); + float_cont->reserve(double_cont->size()); + + LArHitContainer::const_iterator it1 = double_cont->begin(); + LArHitContainer::const_iterator it2 = double_cont->end(); + for (;it1 != it2; it1++) { + LArHit* double_hit = (*it1); + float energy = (float)(double_hit->energy()); + float time = (float)(double_hit->time()); + LArHitFloat float_hit(double_hit->cellID(),energy,time); + float_cont->push_back(float_hit); + } + + return float_cont; + +} diff --git a/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitFloatContainerCnv.h b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitFloatContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..cffaf3633c7689e5fcbcec84624293b5af7a7e16 --- /dev/null +++ b/LArCalorimeter/LArCnv/LArSimEventAthenaPool/src/LArHitFloatContainerCnv.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARHITFLOATCONTAINERCNV +#define LARHITFLOATCONTAINERCNV + +#include "LArSimEvent/LArHitFloatContainer.h" +#include "LArSimEventTPCnv/LArHitContainer_p1.h" +#include "LArSimEventTPCnv/LArHitContainer_p2.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" +// typedef to the latest persistent version +typedef LArHitContainer_p2 LArHitContainer_PERS; + +class LArHitContainer; + +class LArHitFloatContainerCnv : public T_AthenaPoolCustomCnv<LArHitFloatContainer, LArHitContainer_PERS > { + friend class CnvFactory<LArHitFloatContainerCnv>; +protected: + LArHitFloatContainerCnv(ISvcLocator* svcloc) : T_AthenaPoolCustomCnv<LArHitFloatContainer, LArHitContainer_PERS >( svcloc) {} + LArHitContainer_PERS* createPersistent(LArHitFloatContainer* transCont); + LArHitFloatContainer* createTransient (); + LArHitFloatContainer* copyLArHitToFloat(const LArHitContainer* double_cont); +}; + +#endif