ATLAS Offline Software
BinnedLayerMaterialCnv_p1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // BinnedLayerMaterialCnv_p1.cxx, (c) ATLAS Detector software
8 
14 
16  Trk::BinnedLayerMaterial *transObj,
17  MsgStream &mlog )
18 {
19 
20  // create the transient BinUtility
21  auto binUtility = std::make_unique<Trk::BinUtility>();
22  m_gBinUtilityCnv.persToTrans(&persObj->binUtility, binUtility.get(), mlog);
23  transObj->updateBinning (binUtility.release());
24 
25  // assign the split factor
26  transObj->m_splitFactor = persObj->splitFactor;
27 
28  // create the transient material properties
29  // pointer to converter (will be auto-retrieved)
30  ITPConverterFor<Trk::MaterialProperties> *materialCnv = nullptr;
31  size_t matrixOuterDim = transObj->m_binUtility->max(1)+1;
32  size_t matrixInnerDim = transObj->m_binUtility->max(0)+1;
33  transObj->m_fullMaterial = std::vector< std::vector<const Trk::MaterialProperties*> >(matrixOuterDim, std::vector< const Trk::MaterialProperties* >(matrixInnerDim, nullptr) );
34  for ( size_t iod = 0; iod < matrixOuterDim; ++iod )
35  for ( size_t iid = 0; iid < matrixInnerDim; ++iid) {
36  // create the material properties
37  const Trk::MaterialProperties* mprop = createTransFromPStore( &materialCnv, persObj->materialMatrix[iid+matrixInnerDim*iod], mlog );
38  // check if the entry carries material or not
39  const bool carriesMaterial{mprop and not std::isnan(mprop->thicknessInX0()) and mprop->thicknessInX0()>10e-5 and mprop->averageZ() > 1};
40  if (carriesMaterial)
41  (transObj->m_fullMaterial)[iod][iid] = mprop;
42  else {
43  (transObj->m_fullMaterial)[iod][iid] = nullptr;
44  delete mprop; // clear this instance and set to 0
45  mprop=nullptr;
46  }
47  }
48 }
49 
52  MsgStream &mlog )
53 {
54 
55  // create the persistent BinUtility
56  m_gBinUtilityCnv.transToPers(transObj->binUtility(), &persObj->binUtility, mlog);
57 
58  // assign the split factor
59  persObj->splitFactor = transObj->m_splitFactor;
60 
61  // create the persistent material properties
62  // pointer to converter (will be auto-retrieved)
63  ITPConverterFor<Trk::MaterialProperties> *materialCnv = nullptr;
64  // prepare the matrix
65  size_t matrixOuterDim =transObj->m_binUtility->max(1)+1;
66  size_t matrixInnerDim =transObj->m_binUtility->max(0)+1;
67  persObj->materialMatrix = std::vector<TPObjRef> ( matrixInnerDim*matrixOuterDim, TPObjRef() ) ;
68  for ( size_t iod = 0; iod < matrixOuterDim; ++iod )
69  for ( size_t iid = 0; iid < matrixInnerDim; ++iid)
70  (persObj->materialMatrix)[iod*matrixInnerDim+iid] = toPersistent( &materialCnv, transObj->m_fullMaterial[iod][iid], mlog );
71 }
72 
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
ITPConverterFor
Definition: TPConverter.h:37
Trk::BinnedLayerMaterial_p1::splitFactor
float splitFactor
Definition: BinnedLayerMaterial_p1.h:29
Trk::BinnedLayerMaterial_p1
Definition: BinnedLayerMaterial_p1.h:21
BinUtilityCnv_p1::persToTrans
virtual void persToTrans(const Trk::BinUtility_p1 *persObj, Trk::BinUtility *transObj, MsgStream &log)
Definition: BinUtilityCnv_p1.cxx:10
MaterialProperties.h
Trk::BinUtility::max
size_t max(size_t ba=0) const
First bin maximal value.
Definition: BinUtility.h:215
Trk::BinnedLayerMaterial::updateBinning
virtual void updateBinning(BinUtility *bu) override
Update the BinUtility if necessary - passing ownership of the utility class.
Definition: BinnedLayerMaterial.h:132
Trk::MaterialProperties::thicknessInX0
float thicknessInX0() const
Return the radiationlength fraction.
BinUtility.h
Trk::BinnedLayerMaterial_p1::binUtility
BinUtility_p1 binUtility
Definition: BinnedLayerMaterial_p1.h:28
TPObjRef
Definition: TPObjRef.h:20
BinnedLayerMaterialCnv_p1.h
Trk::BinnedLayerMaterial_p1::materialMatrix
std::vector< TPObjRef > materialMatrix
Definition: BinnedLayerMaterial_p1.h:27
Trk::LayerMaterialProperties::m_splitFactor
double m_splitFactor
the split factor in favour of oppositePre
Definition: LayerMaterialProperties.h:126
python.InDetPriVxFinderConfig.mlog
mlog
Definition: InDetPriVxFinderConfig.py:139
Trk::BinnedLayerMaterial::m_binUtility
BinUtility * m_binUtility
the helper for the bin finding
Definition: BinnedLayerMaterial.h:107
BinnedLayerMaterial.h
Trk::BinnedLayerMaterial
Definition: BinnedLayerMaterial.h:33
BinnedLayerMaterialCnv_p1::m_gBinUtilityCnv
BinUtilityCnv_p1 m_gBinUtilityCnv
Definition: BinnedLayerMaterialCnv_p1.h:31
Trk::BinnedLayerMaterial::m_fullMaterial
MaterialPropertiesMatrix m_fullMaterial
The five different MaterialProperties.
Definition: BinnedLayerMaterial.h:110
ITPConverterFor< TRANS_BASE >::toPersistent
TPObjRef toPersistent(CNV **cnv, const typename CNV::TransBase_t *transObj, MsgStream &log) const
Persistify an object and store the persistent represenation in the storage vector of the top-level pe...
Definition: TPConverter.h:119
Trk::BinnedLayerMaterial::binUtility
virtual const BinUtility * binUtility() const override
Return the BinUtility.
Definition: BinnedLayerMaterial.h:121
BinnedLayerMaterialCnv_p1::persToTrans
void persToTrans(const Trk::BinnedLayerMaterial_p1 *, Trk::BinnedLayerMaterial *, MsgStream &)
Definition: BinnedLayerMaterialCnv_p1.cxx:15
Trk::MaterialProperties
Definition: MaterialProperties.h:40
BinnedLayerMaterialCnv_p1::transToPers
void transToPers(const Trk::BinnedLayerMaterial *, Trk::BinnedLayerMaterial_p1 *, MsgStream &)
Definition: BinnedLayerMaterialCnv_p1.cxx:50
BinUtility_p1.h
Trk::MaterialProperties::averageZ
float averageZ() const
Returns the average Z of the material.
BinUtilityCnv_p1::transToPers
virtual void transToPers(const Trk::BinUtility *transObj, Trk::BinUtility_p1 *persObj, MsgStream &log)
Definition: BinUtilityCnv_p1.cxx:52
ITPConverterFor< TRANS_BASE >::createTransFromPStore
CNV::Trans_t * createTransFromPStore(CNV **cnv, const TPObjRef &ref, MsgStream &log) const
Create transient representation of a persistent object, stored in the the top-level persistent object...
Definition: TPConverter.h:172