ATLAS Offline Software
LArShapeCompleteCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "LArShapeCompleteCnv.h"
12 #include <cmath>
13 #include <limits>
14 
15 static const LArShapeSubsetCnv_p1 TPconverter1;
16 static const LArShapeSubsetCnv_p2 TPconverter2;
17 
18 namespace {
19 
21 inline
22 float toFloat (double x)
23 {
24  if (std::abs (x) > std::numeric_limits<float>::max()) {
25  if (x > 0)
27  else
29  }
30  return x;
31 }
32 
33 } // anonymous namespace
34 
37 {
38  MsgStream log(msgSvc(), "LArShapeCompleteCnv" );
39  //log << MSG::DEBUG << "LArShapeComplete write" << endmsg;
40  LArShapePersType2* persObj = TPconverter2.createPersistentConst( transObj, log );
41  //log << MSG::DEBUG << "Success" << endmsg;
42  return persObj;
43 }
44 
47 {
48  static const pool::Guid p2_guid("5139AF4A-5947-421A-A775-B2D1134145C7");
49  static const pool::Guid p1_guid("95B61750-4C45-412D-B4D4-9758E9DB40D1");
50  static const pool::Guid p0_guid("055CF2F5-08D0-4EAA-B154-8CE5B1A599E7");
51 
52  MsgStream log(msgSvc(), "LArShapeCompleteCnv" );
53  if( compareClassGuid(p2_guid) ) {
54  std::unique_ptr< LArShapeSubset_p2 > col_vect( poolReadObject< LArShapeSubset_p2 >() );
55  log << MSG::DEBUG << "Reading LArShapeSubset_p1" << endmsg;
56  return TPconverter2.createTransientConst( col_vect.get(), log );
57  }
58  else if( compareClassGuid(p1_guid) ) {
59  log << MSG::ERROR << "Sorry if you really want to read LArShapeSubset_p1 you will need to provide a legacy converter" << endmsg;
60  }
61  else if( compareClassGuid(p0_guid) ) {
62  log << MSG::ERROR << "Sorry if you really want to read the very old LArShapeSubset you will need to provide a legacy converter" << endmsg;
63  }
64  throw std::runtime_error("Unsupported persistent version of LArShapeCompleteCnv");
65 }
66 
69 {
70 
71  //MsgStream log(msgSvc(), "LArShapeCompleteCnv" );
72  //log << MSG::DEBUG << "LArShapeCompleteCnv::createTransient orig " << orig << endmsg;
73 
75 
76  // Copy LArShapeP subset to LArShapeP1
77  LArShapeCopy copier;
78  copier.copyOldtoNew(orig, result);
79 
80  return (result);
81 }
82 
83 // Copy LArShapeP subset to LArShapeP1
84 void
87 {
88  newShape->assign (*oldShape,
89  [] (const LArShapeP& from,
90  LArShapeP1& to)
91  {
92  to.m_vShape.assign (from.m_vShape.begin(),
93  from.m_vShape.end());
94 
95  unsigned int nShapeDers = from.m_vShapeDer.size();
96  to.m_vShapeDer.resize (nShapeDers);
97  for (size_t k = 0; k < nShapeDers; k++)
98  to.m_vShapeDer[k] = toFloat (from.m_vShapeDer[k]);
99  });
100 }
LArShapeCompleteCnv::createTransient
virtual LArShapeTransType2 * createTransient()
method to be implemented by the developer.
Definition: LArShapeCompleteCnv.cxx:46
LArShapeSubsetCnv_p1
Definition: LArShapeSubsetCnv_p1.h:20
get_generator_info.result
result
Definition: get_generator_info.py:21
LArShapeP::m_vShape
std::vector< double > m_vShape
Definition: LArShapeP.h:20
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
LArShapeSubsetCnv_p2
Definition: LArShapeSubsetCnv_p2.h:20
x
#define x
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LArShapeP1
c-struct reproducing the structure of the persistent data
Definition: LArShapeP1.h:16
LArShapeCompleteCnv::createPersistent
virtual LArShapePersType2 * createPersistent(LArShapeTransType2 *transObj)
Definition: LArShapeCompleteCnv.cxx:36
LArShapeSubset_p2
persistent class container of LArConditionsSubset for LArShape data.
Definition: LArShapeSubset_p2.h:30
TPConverterConstBase::createPersistentConst
virtual PERS * createPersistentConst(const TRANS *transObj, MsgStream &log) const
LArShapeCopy
Definition: LArShapeCompleteCnv.h:40
LArShapeCompleteCnv.h
AthenaPool converter LArShapeComplete.
LArConditionsSubset
template class for use for I/O of conditions data
Definition: LArConditionsSubset.h:122
CxxUtils::to
CONT to(RANGE &&r)
Definition: ranges.h:39
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArShapeP::m_vShapeDer
std::vector< double > m_vShapeDer
Definition: LArShapeP.h:22
T_AthenaPoolCustCnv< COLL_T, ELEM_T >::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
LArShapeP
c-struct reproducing the structure of the persistent data
Definition: LArShapeP.h:16
LArConditionsSubset::assign
void assign(const LArConditionsSubset< U > &other, COPIER copier)
Copy from another subset object.
Definition: LArConditionsSubset.h:339
LArShapeCopy::copyOldtoNew
void copyOldtoNew(const LArConditionsSubset< LArShapeP > *oldShape, LArConditionsSubset< LArShapeP1 > *newShape)
Definition: LArShapeCompleteCnv.cxx:85
fitman.k
k
Definition: fitman.py:528
TPConverterConstBase::createTransientConst
virtual TRANS * createTransientConst(const PERS *persObj, MsgStream &log) const