ATLAS Offline Software
MaterialCnv_p1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // MaterialCnv_p1.cxx, (c) ATLAS Detector software
8 
9 #include "TrkGeometry/Material.h"
11 
13  Trk::Material *transObj,
14  MsgStream&)
15 {
16  transObj->X0 = persObj->materialData[0];
17  transObj->L0 = persObj->materialData[1];
18  transObj->A = persObj->materialData[2];
19  transObj->Z = persObj->materialData[3];
20  transObj->rho = persObj->materialData[4];
21 
22  if ( persObj->materialData.size() > 5 )
23  transObj->dEdX = persObj->materialData[5];
24 
25  // recreate the composition vector if possible
26  if ( !persObj->elements.empty() && !persObj->fractions.empty() ) {
27  transObj->composition = new Trk::MaterialComposition(persObj->elements, persObj->fractions);
28  }
29 
30  transObj->zOaTr = transObj->A *transObj->A > 10e-10 ? transObj->Z/transObj->A*transObj->rho : 0.;
31 
32 }
33 
35  Trk::Material_p1 *persObj,
36  MsgStream& )
37 {
38  if ( transObj->dEdX != 0. ){
39  persObj->materialData.resize(6);
40  persObj->materialData[5] = transObj->dEdX;
41  }
42 
43  persObj->materialData[0] = transObj->X0 ;
44  persObj->materialData[1] = transObj->L0 ;
45  persObj->materialData[2] = transObj->A ;
46  persObj->materialData[3] = transObj->Z ;
47  persObj->materialData[4] = transObj->rho;
48 
49  // write the composition vector if present
50  // disentangle the ElementFraction for columnwise write support (compression optimised)
51  if ( transObj->composition ){
52  persObj->elements.reserve(transObj->composition->size());
53  persObj->fractions.reserve(transObj->composition->size());
54  for (auto& iel: (*transObj->composition)){
55  persObj->elements.push_back(iel.first);
56  persObj->fractions.push_back(iel.second);
57  }
58  }
59 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Trk::Material::L0
float L0
Definition: Material.h:120
Trk::Material_p1::fractions
std::vector< unsigned char > fractions
Definition: Material_p1.h:42
Trk::Material_p1::materialData
std::vector< float > materialData
Definition: Material_p1.h:40
Trk::Material::Z
float Z
Definition: Material.h:122
Trk::Material_p1
Definition: Material_p1.h:32
MaterialCnv_p1::persToTrans
virtual void persToTrans(const Trk::Material_p1 *persObj, Trk::Material *transObj, MsgStream &log)
Definition: MaterialCnv_p1.cxx:12
Trk::MaterialComposition
Definition: Material.h:60
Trk::Material::A
float A
Definition: Material.h:121
Trk::Material::X0
float X0
Definition: Material.h:119
Trk::Material::rho
float rho
Definition: Material.h:123
MaterialCnv_p1.h
Trk::Material_p1::elements
std::vector< unsigned char > elements
Definition: Material_p1.h:41
Trk::Material::composition
MaterialComposition * composition
Definition: Material.h:126
MaterialCnv_p1::transToPers
virtual void transToPers(const Trk::Material *transObj, Trk::Material_p1 *persObj, MsgStream &log)
Definition: MaterialCnv_p1.cxx:34
Trk::Material::dEdX
float dEdX
Definition: Material.h:124
Trk::Material::zOaTr
float zOaTr
Definition: Material.h:125
Trk::Material
Definition: Material.h:116
Material.h