ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
NswAsBuilt::StgcStripCalculator Class Reference

The main interface of the NswAsBuilt package: determines strip positions in the frame of the quadruplet. More...

#include <StgcStripCalculator.h>

Collaboration diagram for NswAsBuilt::StgcStripCalculator:

Classes

struct  json_t
 
struct  position_t
 The return object for querying strip positions with the method getPositionAlongStrip: a single point on strip is returned, in the coordinate system of the quadruplet. More...
 
struct  stgcStrip_t
 The return object for querying strip positions: three points along the strip are provided, in the coordinate system of the quadruplet. More...
 

Public Types

enum  IsValid { IsValid::INVALID =0, IsValid::VALID =1 }
 VALID: strip is found, INVALID: strip is not found. More...
 
using ParameterClass = Element::ParameterClass
 

Public Member Functions

stgcStrip_t getStgcStrip (ParameterClass iclass, stripIdentifier_t strip_id) const
 Computes 3 reference points along a strip identified by strip_id, in coordinate system of quadruplet. More...
 
position_t getPositionAlongStgcStrip (ParameterClass iclass, stripIdentifier_t strip_id, double sx, double sy) const
 Returns a the position of a point along the strip, parameterized by s, in the coordinate system of the quadruplet. More...
 
void parseJSON (const std::string &in)
 Parses a std::istream with JSON-formatted configuration of the as-built parameters. More...
 

Private Member Functions

void parseRootElement (json_t j)
 
std::unique_ptr< ElementbuildElement (json_t j) const
 
quadrupletIdentifier_t getQuadrupletIdentifier (json_t j) const
 
pcbIdentifier_t getPcbIdentifier (quadrupletIdentifier_t quad_id, json_t j) const
 
void collectStrip (quadrupletIdentifier_t quad_id, Element &element, json_t j)
 
CathodeBoardElement::stgcStripConfiguration_t getStgcStripConfiguration (json_t j) const
 

Private Attributes

std::vector< std::unique_ptr< Element > > m_rootElements
 
std::unordered_map< pcbIdentifier_t, CathodeBoardElementm_pcbMap
 

Detailed Description

The main interface of the NswAsBuilt package: determines strip positions in the frame of the quadruplet.

Once instanciated, the as-built geometry must be read in from a stream of JSON formatted data, using the method parseJSON.

Strip positions may then be queried, using the method getStgcStrip. (The method getStgcStrip is thread-safe.)

Definition at line 31 of file StgcStripCalculator.h.

Member Typedef Documentation

◆ ParameterClass

Definition at line 33 of file StgcStripCalculator.h.

Member Enumeration Documentation

◆ IsValid

VALID: strip is found, INVALID: strip is not found.

Enumerator
INVALID 
VALID 

Definition at line 38 of file StgcStripCalculator.h.

38  {
39  INVALID=0,
40  VALID=1
41  };

Member Function Documentation

◆ buildElement()

std::unique_ptr< Element > StgcStripCalculator::buildElement ( json_t  j) const
private

Definition at line 61 of file StgcStripCalculator.cxx.

61  {
62  // Build the appropriate deformation model
63  std::unique_ptr<ElementModel> deformation_model;
64  std::string model = j.json.at("model");
65  if (model == "nodefo") {
66  deformation_model = std::make_unique<ElementModelRigid>();
67  }
68  else if (model == "stgc") {
69  double lenX, lenY;
70  Amg::Vector3D defo0;
71  const auto& jc = j.json.at("model_constant_pars");
72  jc.at("len_x").get_to(lenX);
73  jc.at("len_y").get_to(lenY);
74  jc.at("defo0_x").get_to(defo0[0]);
75  jc.at("defo0_y").get_to(defo0[1]);
76  jc.at("defo0_z").get_to(defo0[2]);
77  deformation_model = std::make_unique<ElementModelSTGC>(lenX, lenY, defo0);
78  }
79  else {
80  throw std::runtime_error("Unknown model: "+model);
81  }
82 
83  // Build the element
84  std::unique_ptr<Element> el = std::make_unique<Element>(std::move(deformation_model));
85 
86  // Set the model parameters
87  std::map<std::string, double> correctionPars, nominalPars;
88  j.json.at("pars_corrected").get_to(correctionPars);
89  j.json.at("pars_nominal").get_to(nominalPars);
90  el->setParametersFromMap(ParameterClass::CORRECTION, correctionPars);
91  el->setParametersFromMap(ParameterClass::NOMINAL, nominalPars);
92 
93  return el;
94 }

◆ collectStrip()

void StgcStripCalculator::collectStrip ( quadrupletIdentifier_t  quad_id,
Element element,
json_t  j 
)
private

Definition at line 142 of file StgcStripCalculator.cxx.

142  {
143  if (j.json.contains("strip_configuration") && j.json.contains("identifier")) {
144  pcbIdentifier_t pcb_id = getPcbIdentifier(quad_id, j.json.at("identifier"));
146  m_pcbMap.insert(std::make_pair(pcb_id, CathodeBoardElement(config, element)));
147  }
148 }

◆ getPcbIdentifier()

pcbIdentifier_t StgcStripCalculator::getPcbIdentifier ( quadrupletIdentifier_t  quad_id,
json_t  j 
) const
private

Definition at line 112 of file StgcStripCalculator.cxx.

112  {
113  pcbIdentifier_t ret;
114  ret.quadruplet = quad_id;
115  j.json.at("ilayer").get_to(ret.ilayer);
116  j.json.at("ipcb").get_to(ret.ipcb);
117  return ret;
118 }

◆ getPositionAlongStgcStrip()

StgcStripCalculator::position_t StgcStripCalculator::getPositionAlongStgcStrip ( ParameterClass  iclass,
stripIdentifier_t  strip_id,
double  sx,
double  sy 
) const

Returns a the position of a point along the strip, parameterized by s, in the coordinate system of the quadruplet.

s is in [-1,1]: -1 returns the left-most point along the strip, 0 returns the center point and +1 return the right-most point

Definition at line 34 of file StgcStripCalculator.cxx.

34  {
35  int ipcb = 9; // since sTGC strip boards are identical
36  pcbIdentifier_t pcb_id { strip_id.quadruplet, strip_id.ilayer, ipcb };
37  auto it = m_pcbMap.find(pcb_id);
38 
39  if (it == m_pcbMap.end()) {
40  return {};
41  }
42 
43  return { IsValid::VALID, it->second.getPositionAlongStgcStrip(iclass, strip_id.istrip, sx, sy) };
44 }

◆ getQuadrupletIdentifier()

quadrupletIdentifier_t StgcStripCalculator::getQuadrupletIdentifier ( json_t  j) const
private

Definition at line 96 of file StgcStripCalculator.cxx.

96  {
98  std::string stationName;
99  j.json.at("station_name").get_to(stationName);
100  if (stationName == "STS") {
102  } else if (stationName == "STL") {
104  } else {
105  throw std::runtime_error("StgcStripCalculator: stationName not implemented: "+stationName);
106  }
107  j.json.at("station_eta").get_to(ret.stationEta);
108  j.json.at("station_phi").get_to(ret.stationPhi);
109  j.json.at("multilayer").get_to(ret.multilayer);
110  return ret;
111 }

◆ getStgcStrip()

StgcStripCalculator::stgcStrip_t StgcStripCalculator::getStgcStrip ( ParameterClass  iclass,
stripIdentifier_t  strip_id 
) const

Computes 3 reference points along a strip identified by strip_id, in coordinate system of quadruplet.

Use iclass=ParameterClass::NOMINAL or ParameterClass::CORRECTION to get the nominal or as-built values, respectively.

Definition at line 22 of file StgcStripCalculator.cxx.

22  {
23  int ipcb = 9; // since sTGC strip boards are identical
24  pcbIdentifier_t pcb_id { strip_id.quadruplet, strip_id.ilayer, ipcb };
25  auto it = m_pcbMap.find(pcb_id);
26 
27  if (it == m_pcbMap.end()) {
28  return {};
29  }
30 
31  auto strip = it->second.getStgcStrip(iclass, strip_id.istrip);
32  return { IsValid::VALID, strip.center, strip.left, strip.right };
33 }

◆ getStgcStripConfiguration()

CathodeBoardElement::stgcStripConfiguration_t StgcStripCalculator::getStgcStripConfiguration ( json_t  j) const
private

Definition at line 119 of file StgcStripCalculator.cxx.

119  {
120  auto getPoint = [](const nlohmann::json& j) {
121  double xpos, ypos, xpitch, ypitch;
122  j.at("pos").at("x").get_to(xpos);
123  j.at("pos").at("y").get_to(ypos);
124  j.at("pitch").at("x").get_to(xpitch);
125  j.at("pitch").at("y").get_to(ypitch);
126  return CathodeBoardElement::stgcStripPoint_t{{xpos,ypos,0.0},{xpitch,ypitch,0.0}};
127  };
129  j.json.at("nstrip").get_to(ret.lastStripNumber);
130  ret.fCenterPoint = getPoint(j.json.at("first_strip_center"));
131  ret.fLeftPoint = getPoint(j.json.at("first_strip_left"));
132  ret.fRightPoint = getPoint(j.json.at("first_strip_right"));
133  ret.sCenterPoint = getPoint(j.json.at("second_strip_center"));
134  ret.sLeftPoint = getPoint(j.json.at("second_strip_left"));
135  ret.sRightPoint = getPoint(j.json.at("second_strip_right"));
136  ret.lCenterPoint = getPoint(j.json.at("last_strip_center"));
137  ret.lLeftPoint = getPoint(j.json.at("last_strip_left"));
138  ret.lRightPoint = getPoint(j.json.at("last_strip_right"));
139  return ret;
140 }

◆ parseJSON()

void StgcStripCalculator::parseJSON ( const std::string &  in)

Parses a std::istream with JSON-formatted configuration of the as-built parameters.

Definition at line 46 of file StgcStripCalculator.cxx.

46  {
47  try {
48  using json = nlohmann::json;
49  json jroot = json::parse(in);
50  for (const json& jmodule : jroot.at("elementarray")) {
51  parseRootElement(jmodule);
52  }
53  } catch (const std::exception& e) {
54  throw std::runtime_error(e.what());
55  }
56 }

◆ parseRootElement()

void StgcStripCalculator::parseRootElement ( json_t  j)
private

Definition at line 150 of file StgcStripCalculator.cxx.

150  {
151  using json = nlohmann::json;
152  struct tree_t {
153  json::const_iterator it;
154  json::const_iterator end;
155  };
156 
157  if (!j.json.contains("identifier")) {
158  // No athena identifier given for this element, skip
159  return;
160  }
161 
162  std::unique_ptr<Element> root = buildElement(j);
163  quadrupletIdentifier_t quad_id = getQuadrupletIdentifier(j.json.at("identifier"));
164  Element* mom = root.get();
165  const std::string KEY = "zdaughters";
166 
167  // Depth-traversal of json tree, collect elements along the way
168  std::list<tree_t> jtree;
169  jtree.push_back({j.json.at(KEY).begin(), j.json.at(KEY).end()});
170  while (!jtree.empty()) {
171  auto& it = jtree.back().it;
172  if (it != jtree.back().end) {
173  std::unique_ptr<Element> daughter = buildElement(*it);
174  collectStrip(quad_id, *daughter, *it);
175  Element* daugref = mom->addDaughter(std::move(daughter));
176  if (it->contains(KEY)) {
177  jtree.push_back({it->at(KEY).begin(), it->at(KEY).end()});
178  mom = daugref;
179  }
180  ++it;
181  } else {
182  jtree.pop_back();
183  mom = mom->mother();
184  }
185  }
186 
187  m_rootElements.push_back(std::move(root));
188 }

Member Data Documentation

◆ m_pcbMap

std::unordered_map<pcbIdentifier_t, CathodeBoardElement> NswAsBuilt::StgcStripCalculator::m_pcbMap
private

Definition at line 88 of file StgcStripCalculator.h.

◆ m_rootElements

std::vector<std::unique_ptr<Element> > NswAsBuilt::StgcStripCalculator::m_rootElements
private

Definition at line 87 of file StgcStripCalculator.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CxxUtils::VALID
@ VALID
Definition: CachedValue.h:30
fitman.sy
sy
Definition: fitman.py:524
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t
Definition: CathodeBoardElement.h:38
NswAsBuilt::stripIdentifier_t::quadruplet
quadrupletIdentifier_t quadruplet
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:82
json
nlohmann::json json
Definition: HistogramDef.cxx:9
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::fCenterPoint
stgcStripPoint_t fCenterPoint
Definition: CathodeBoardElement.h:40
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::lastStripNumber
int lastStripNumber
Definition: CathodeBoardElement.h:39
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:1054
NswAsBuilt::StgcStripCalculator::m_rootElements
std::vector< std::unique_ptr< Element > > m_rootElements
Definition: StgcStripCalculator.h:87
NswAsBuilt::quadrupletIdentifier_t::stationEta
int stationEta
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:34
python.compressB64.sx
string sx
Definition: compressB64.py:96
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
NswAsBuilt::quadrupletIdentifier_t::STS
@ STS
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:29
NswAsBuilt::StgcStripCalculator::getQuadrupletIdentifier
quadrupletIdentifier_t getQuadrupletIdentifier(json_t j) const
Definition: StgcStripCalculator.cxx:96
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
NswAsBuilt::StgcStripCalculator::m_pcbMap
std::unordered_map< pcbIdentifier_t, CathodeBoardElement > m_pcbMap
Definition: StgcStripCalculator.h:88
CxxUtils::INVALID
@ INVALID
Definition: CachedValue.h:28
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::sRightPoint
stgcStripPoint_t sRightPoint
Definition: CathodeBoardElement.h:45
keylayer_zslicemap.strip
strip
Definition: keylayer_zslicemap.py:151
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
NswAsBuilt::CathodeBoardElement
Helper class saving all the needed information to compute strips for a particular cathode board.
Definition: CathodeBoardElement.h:26
NswAsBuilt::StgcStripCalculator::IsValid::VALID
@ VALID
NswAsBuilt::pcbIdentifier_t
The indices of a MM PCB.
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:59
NswAsBuilt::quadrupletIdentifier_t::stationName
StationName stationName
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:33
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
NswAsBuilt::CathodeBoardElement::stgcStripPoint_t
Definition: CathodeBoardElement.h:33
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::fLeftPoint
stgcStripPoint_t fLeftPoint
Definition: CathodeBoardElement.h:41
NswAsBuilt::quadrupletIdentifier_t::multilayer
int multilayer
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:36
NswAsBuilt::pcbIdentifier_t::quadruplet
quadrupletIdentifier_t quadruplet
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:60
NswAsBuilt::quadrupletIdentifier_t
Athena indices for a MM quadruplet:
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:25
NswAsBuilt::Element::ParameterClass::NOMINAL
@ NOMINAL
calibdata.exception
exception
Definition: calibdata.py:496
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
NswAsBuilt::StgcStripCalculator::buildElement
std::unique_ptr< Element > buildElement(json_t j) const
Definition: StgcStripCalculator.cxx:61
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::sLeftPoint
stgcStripPoint_t sLeftPoint
Definition: CathodeBoardElement.h:44
NswAsBuilt::StgcStripCalculator::collectStrip
void collectStrip(quadrupletIdentifier_t quad_id, Element &element, json_t j)
Definition: StgcStripCalculator.cxx:142
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::sCenterPoint
stgcStripPoint_t sCenterPoint
Definition: CathodeBoardElement.h:43
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::lLeftPoint
stgcStripPoint_t lLeftPoint
Definition: CathodeBoardElement.h:47
NswAsBuilt::StgcStripCalculator::parseRootElement
void parseRootElement(json_t j)
Definition: StgcStripCalculator.cxx:150
NswAsBuilt::StgcStripCalculator::getPcbIdentifier
pcbIdentifier_t getPcbIdentifier(quadrupletIdentifier_t quad_id, json_t j) const
Definition: StgcStripCalculator.cxx:112
NswAsBuilt::StgcStripCalculator::getStgcStripConfiguration
CathodeBoardElement::stgcStripConfiguration_t getStgcStripConfiguration(json_t j) const
Definition: StgcStripCalculator.cxx:119
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::lRightPoint
stgcStripPoint_t lRightPoint
Definition: CathodeBoardElement.h:48
NswAsBuilt::pcbIdentifier_t::ipcb
int ipcb
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:62
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
NswAsBuilt::stripIdentifier_t::ilayer
int ilayer
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:83
correlationModel::model
model
Definition: AsgElectronEfficiencyCorrectionTool.cxx:46
NswAsBuilt::stripIdentifier_t::istrip
int istrip
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:84
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::fRightPoint
stgcStripPoint_t fRightPoint
Definition: CathodeBoardElement.h:42
NswAsBuilt::quadrupletIdentifier_t::STL
@ STL
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:30
NswAsBuilt::Element
Element: a node in a hierarchy of alignment frames.
Definition: Element.h:52
NswAsBuilt::pcbIdentifier_t::ilayer
int ilayer
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:61
NswAsBuilt::Element::ParameterClass::CORRECTION
@ CORRECTION
NswAsBuilt::quadrupletIdentifier_t::stationPhi
int stationPhi
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:35
NswAsBuilt::CathodeBoardElement::stgcStripConfiguration_t::lCenterPoint
stgcStripPoint_t lCenterPoint
Definition: CathodeBoardElement.h:46