ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11#include "LArShapeCompleteCnv.h"
12#include <cmath>
13#include <limits>
14
17
18namespace {
19
21inline
22float toFloat (double x)
23{
24 if (std::abs (x) > std::numeric_limits<float>::max()) {
25 if (x > 0)
26 return std::numeric_limits<float>::max();
27 else
28 return - std::numeric_limits<float>::max();
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
84void
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}
#define endmsg
static const LArCaliWaveSubsetCnv_p2 TPconverter2
static const LArCaliWaveSubsetCnv_p1 TPconverter1
AthenaPool converter LArShapeComplete.
LArConditionsSubset< LArShapeP2 > LArShapeTransType2
LArShapeSubset_p2 LArShapePersType2
#define x
template class for use for I/O of conditions data
void assign(const LArConditionsSubset< U > &other, COPIER copier)
Copy from another subset object.
virtual LArShapeTransType2 * createTransient()
method to be implemented by the developer.
virtual LArShapePersType2 * createPersistent(LArShapeTransType2 *transObj)
method to be implemented by the developer.
void copyOldtoNew(const LArConditionsSubset< LArShapeP > *oldShape, LArConditionsSubset< LArShapeP1 > *newShape)
c-struct reproducing the structure of the persistent data
Definition LArShapeP1.h:16
c-struct reproducing the structure of the persistent data
Definition LArShapeP.h:16
std::vector< double > m_vShapeDer
Definition LArShapeP.h:22
std::vector< double > m_vShape
Definition LArShapeP.h:21
persistent class container of LArConditionsSubset for LArShape data.