Skip to content
Snippets Groups Projects
Commit e7e1626d authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

Add AtlasFieldMap

parent e231723b
No related merge requests found
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
/**
......@@ -38,8 +38,8 @@ namespace MagField {
class AtlasFieldMap
{
public:
AtlasFieldMap();
~AtlasFieldMap();
AtlasFieldMap() = default;
~AtlasFieldMap() { delete m_meshZR; }
// initialize map from root file
bool initializeMap(TFile* rootfile,
......@@ -112,4 +112,5 @@ private:
} // namespace MagField
#include "AtlasFieldMap.icc"
#endif // MAGFIELDCONDITIONS_ATLASFIELDMAP_H
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
namespace MagField {
inline const BFieldZone*
MagField::AtlasFieldMap::findBFieldZone(double z, double r, double phi) const
{
// make sure it's inside the largest zone
// NB: the sign of the logic is chosen in order to return 0 on NaN inputs
if (z >= m_zmin && z <= m_zmax && r <= m_rmax) {
// find the edges of the zone
// z
int iz = int(m_invq[0] * (z - m_zmin)); // index to LUT
iz = m_edgeLUT[0][iz]; // tentative index from LUT
if (z > m_edge[0][iz + 1]) {
iz++;
}
// r
int ir = int(m_invq[1] * r); // index to LUT - note minimum r is always 0
ir = m_edgeLUT[1][ir]; // tentative index from LUT
if (r > m_edge[1][ir + 1]) {
ir++;
}
// phi
int iphi =
int(m_invq[2] * (phi + M_PI)); // index to LUT - minimum phi is -pi
iphi = m_edgeLUT[2][iphi]; // tentative index from LUT
if (phi > m_edge[2][iphi + 1]) {
iphi++;
}
// use LUT to get the zone
return m_zoneLUT[(iz * m_nr + ir) * m_nphi + iphi];
}
return nullptr;
}
// fast 2d map (made of one zone)
inline const BFieldMeshZR*
AtlasFieldMap::getBFieldMesh() const
{
return m_meshZR;
}
}
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -16,56 +16,7 @@
#include "TFile.h"
#include "TTree.h"
/** Constructor **/
MagField::AtlasFieldMap::AtlasFieldMap() = default;
MagField::AtlasFieldMap::~AtlasFieldMap()
{
delete m_meshZR;
}
const BFieldZone*
MagField::AtlasFieldMap::findBFieldZone(double z, double r, double phi) const
{
// make sure it's inside the largest zone
// NB: the sign of the logic is chosen in order to return 0 on NaN inputs
if (z >= m_zmin && z <= m_zmax && r <= m_rmax) {
// find the edges of the zone
// z
const std::vector<double>& edgez(m_edge[0]);
int iz = int(m_invq[0] * (z - m_zmin)); // index to LUT
iz = m_edgeLUT[0][iz]; // tentative index from LUT
if (z > edgez[iz + 1]) {
iz++;
}
// r
const std::vector<double>& edger(m_edge[1]);
int ir = int(m_invq[1] * r); // index to LUT - note minimum r is always 0
ir = m_edgeLUT[1][ir]; // tentative index from LUT
if (r > edger[ir + 1]) {
ir++;
}
// phi
const std::vector<double>& edgephi(m_edge[2]);
int iphi =
int(m_invq[2] * (phi + M_PI)); // index to LUT - minimum phi is -pi
iphi = m_edgeLUT[2][iphi]; // tentative index from LUT
if (phi > edgephi[iphi + 1]) {
iphi++;
}
// use LUT to get the zone
return m_zoneLUT[(iz * m_nr + ir) * m_nphi + iphi];
}
return nullptr;
}
// fast 2d map (made of one zone)
const BFieldMeshZR*
MagField::AtlasFieldMap::getBFieldMesh() const
{
return m_meshZR;
}
//
// read the map from a ROOT file.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment