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

#include <StripCalculator.h>

Collaboration diagram for NswAsBuilt::StripCalculator:

Classes

struct  json_t
 
struct  position_t
 
struct  strip_t
 

Public Types

enum  IsValid { IsValid::INVALID =0, IsValid::VALID =1 }
 
using ParameterClass = Element::ParameterClass
 

Public Member Functions

strip_t getStrip (ParameterClass iclass, stripIdentifier_t strip_id) const
 
position_t getPositionAlongStrip (ParameterClass iclass, stripIdentifier_t strip_id, double sx, double sy) const
 
void parseJSON (const std::string &in)
 

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)
 
PcbElement::stripConfiguration_t getStripConfiguration (json_t j) const
 

Private Attributes

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

Detailed Description

Definition at line 30 of file StripCalculator.h.

Member Typedef Documentation

◆ ParameterClass

Definition at line 32 of file StripCalculator.h.

Member Enumeration Documentation

◆ IsValid

Enumerator
INVALID 
VALID 

Definition at line 35 of file StripCalculator.h.

35  {
36  INVALID=0,
37  VALID=1
38  };

Member Function Documentation

◆ buildElement()

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

Definition at line 75 of file StripCalculator.cxx.

75  {
76  // Build the appropriate deformation model
77  std::unique_ptr<ElementModel> deformation_model;
78  std::string model = j.json.at("model");
79  if (model == "nodefo") {
80  deformation_model = std::make_unique<ElementModelRigid>();
81  } else if (model == "scalesag") {
82  double lenX, lenY;
83  Amg::Vector3D defo0;
84  const auto& jc = j.json.at("model_constant_pars");
85  jc.at("len_x").get_to(lenX);
86  jc.at("len_y").get_to(lenY);
87  jc.at("defo0_x").get_to(defo0[0]);
88  jc.at("defo0_y").get_to(defo0[1]);
89  jc.at("defo0_z").get_to(defo0[2]);
90  deformation_model = std::make_unique<ElementModelScaleSag>(lenX, lenY, defo0);
91  } else {
92  throw std::runtime_error("Unknown model: "+model);
93  }
94 
95  // Build the element
96  std::unique_ptr<Element> el = std::make_unique<Element>(std::move(deformation_model));
97  el->setAsapId(j.json.at("id_asap"));
98 
99  // Set the model parameters
100  std::map<std::string, double> correctionPars, nominalPars;
101  j.json.at("pars_correction").get_to(correctionPars);
102  j.json.at("pars_nominal").get_to(nominalPars);
103  el->setParametersFromMap(ParameterClass::CORRECTION, correctionPars);
104  el->setParametersFromMap(ParameterClass::NOMINAL, nominalPars);
105 
106  return el;
107 }

◆ collectStrip()

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

Definition at line 159 of file StripCalculator.cxx.

159  {
160  if (j.json.contains("strip_configuration") && j.json.contains("identifier")) {
161  pcbIdentifier_t pcb_id = getPcbIdentifier(quad_id, j.json.at("identifier"));
162  PcbElement::stripConfiguration_t config = getStripConfiguration(j.json.at("strip_configuration"));
163  m_pcbMap.insert(std::make_pair(pcb_id, PcbElement(config, element)));
164  }
165 }

◆ getPcbIdentifier()

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

Definition at line 130 of file StripCalculator.cxx.

130  {
131  pcbIdentifier_t ret;
132  ret.quadruplet = quad_id;
133  j.json.at("ilayerath").get_to(ret.ilayer);
134  j.json.at("iboard").get_to(ret.ipcb);
135  return ret;
136 }

◆ getPositionAlongStrip()

StripCalculator::position_t StripCalculator::getPositionAlongStrip ( ParameterClass  iclass,
stripIdentifier_t  strip_id,
double  sx,
double  sy 
) const

Definition at line 42 of file StripCalculator.cxx.

42  {
43  int ipcb = (strip_id.istrip-1)/1024 + 1; // MM 1024 channels per PCB, hard-coded convention
44  if (std::abs(strip_id.quadruplet.stationEta)==2) {
45  ipcb += 5;
46  }
47  pcbIdentifier_t pcb_id { strip_id.quadruplet, strip_id.ilayer, ipcb };
48  auto it = m_pcbMap.find(pcb_id);
49 
50  if (it == m_pcbMap.end()) {
51  return {};
52  }
53 
54  return { IsValid::VALID, it->second.getPositionAlongStrip(iclass, strip_id.istrip, sx, sy) };
55 }

◆ getQuadrupletIdentifier()

quadrupletIdentifier_t StripCalculator::getQuadrupletIdentifier ( json_t  j) const
private

Definition at line 111 of file StripCalculator.cxx.

111  {
113  std::string stationName;
114  j.json.at("station_name").get_to(stationName);
115  if (stationName == "MMS") {
117  } else if (stationName == "MML") {
119  } else {
120  throw std::runtime_error("StripCalculator: stationName not implemented: "+stationName);
121  }
122  j.json.at("station_eta").get_to(ret.stationEta);
123  j.json.at("station_phi").get_to(ret.stationPhi);
124  j.json.at("multilayer").get_to(ret.multilayer);
125  return ret;
126 }

◆ getStrip()

StripCalculator::strip_t StripCalculator::getStrip ( ParameterClass  iclass,
stripIdentifier_t  strip_id 
) const

Definition at line 24 of file StripCalculator.cxx.

24  {
25  int ipcb = (strip_id.istrip-1)/1024 + 1; // MM 1024 channels per PCB, hard-coded convention
26  if (std::abs(strip_id.quadruplet.stationEta)==2) {
27  ipcb += 5;
28  }
29  pcbIdentifier_t pcb_id { strip_id.quadruplet, strip_id.ilayer, ipcb };
30  auto it = m_pcbMap.find(pcb_id);
31 
32  if (it == m_pcbMap.end()) {
33  return {};
34  }
35 
36  auto strip = it->second.getStrip(iclass, strip_id.istrip);
37  return { IsValid::VALID, strip.center, strip.left, strip.right };
38 }

◆ getStripConfiguration()

PcbElement::stripConfiguration_t StripCalculator::getStripConfiguration ( json_t  j) const
private

Definition at line 140 of file StripCalculator.cxx.

140  {
141  auto getPoint = [](const nlohmann::json& j) {
142  double xpos, ypos, xpitch, ypitch;
143  j.at("pos").at("x").get_to(xpos);
144  j.at("pos").at("y").get_to(ypos);
145  j.at("pitchvec").at("x").get_to(xpitch);
146  j.at("pitchvec").at("y").get_to(ypitch);
147  return PcbElement::stripPoint_t{{xpos,ypos,0.0},{xpitch,ypitch,0.0}};
148  };
150  j.json.at("central_strip_number").get_to(ret.centralStripNumber);
151  ret.centerPoint = getPoint(j.json.at("strip_center"));
152  ret.leftPoint = getPoint(j.json.at("strip_left"));
153  ret.rightPoint = getPoint(j.json.at("strip_right"));
154  return ret;
155 }

◆ parseJSON()

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

Definition at line 59 of file StripCalculator.cxx.

59  {
60  try {
61  using json = nlohmann::json;
62  json jroot = json::parse(in);
63  for (const json& jmodule : jroot.at("elementarray")) {
64  parseRootElement(jmodule);
65  }
66  } catch (std::exception& e) {
67  throw std::runtime_error(e.what());
68  }
69 }

◆ parseRootElement()

void StripCalculator::parseRootElement ( json_t  j)
private

Definition at line 169 of file StripCalculator.cxx.

169  {
170  using json = nlohmann::json;
171  struct tree_t {
172  json::const_iterator it;
173  json::const_iterator end;
174  };
175 
176  if (!j.json.contains("identifier")) {
177  // No athena identifier given for this element, skip
178  return;
179  }
180 
181  std::unique_ptr<Element> root = buildElement(j);
182  quadrupletIdentifier_t quad_id = getQuadrupletIdentifier(j.json.at("identifier"));
183  Element* mom = root.get();
184  const std::string KEY = "zdaughters";
185 
186  // Depth-traversal of json tree, collect elements along the way
187  std::list<tree_t> jtree;
188  jtree.push_back({j.json.at(KEY).begin(), j.json.at(KEY).end()});
189  while (!jtree.empty()) {
190  auto& it = jtree.back().it;
191  if (it != jtree.back().end) {
192  std::unique_ptr<Element> daughter = buildElement(*it);
193  collectStrip(quad_id, *daughter, *it);
194  Element* daugref = mom->addDaughter(std::move(daughter));
195  if (it->contains(KEY)) {
196  jtree.push_back({it->at(KEY).begin(), it->at(KEY).end()});
197  mom = daugref;
198  }
199  ++it;
200  } else {
201  jtree.pop_back();
202  mom = mom->mother();
203  }
204  }
205 
206  m_rootElements.push_back(std::move(root));
207 }

Member Data Documentation

◆ m_pcbMap

std::unordered_map<pcbIdentifier_t, PcbElement> NswAsBuilt::StripCalculator::m_pcbMap
private

Definition at line 75 of file StripCalculator.h.

◆ m_rootElements

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

Definition at line 74 of file StripCalculator.h.


The documentation for this class was generated from the following files:
NswAsBuilt::PcbElement::stripPoint_t
Definition: PcbElement.h:32
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CxxUtils::VALID
@ VALID
Definition: CachedValue.h:30
fitman.sy
sy
Definition: fitman.py:524
NswAsBuilt::stripIdentifier_t::quadruplet
quadrupletIdentifier_t quadruplet
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:82
json
nlohmann::json json
Definition: HistogramDef.cxx:9
NswAsBuilt::StripCalculator::IsValid::VALID
@ VALID
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
NswAsBuilt::StripCalculator::parseRootElement
void parseRootElement(json_t j)
Definition: StripCalculator.cxx:169
NswAsBuilt::StripCalculator::getQuadrupletIdentifier
quadrupletIdentifier_t getQuadrupletIdentifier(json_t j) const
Definition: StripCalculator.cxx:111
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:1054
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::StripCalculator::m_rootElements
std::vector< std::unique_ptr< Element > > m_rootElements
Definition: StripCalculator.h:74
NswAsBuilt::PcbElement::stripConfiguration_t::centralStripNumber
int centralStripNumber
Definition: PcbElement.h:39
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
NswAsBuilt::StripCalculator::m_pcbMap
std::unordered_map< pcbIdentifier_t, PcbElement > m_pcbMap
Definition: StripCalculator.h:75
CxxUtils::INVALID
@ INVALID
Definition: CachedValue.h:28
NswAsBuilt::PcbElement::stripConfiguration_t::leftPoint
stripPoint_t leftPoint
Definition: PcbElement.h:41
NswAsBuilt::StripCalculator::collectStrip
void collectStrip(quadrupletIdentifier_t quad_id, Element &element, json_t j)
Definition: StripCalculator.cxx:159
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::PcbElement::stripConfiguration_t::rightPoint
stripPoint_t rightPoint
Definition: PcbElement.h:42
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::StripCalculator::getStripConfiguration
PcbElement::stripConfiguration_t getStripConfiguration(json_t j) const
Definition: StripCalculator.cxx:140
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::quadrupletIdentifier_t::MML
@ MML
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:28
NswAsBuilt::Element::ParameterClass::NOMINAL
@ NOMINAL
calibdata.exception
exception
Definition: calibdata.py:496
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
NswAsBuilt::StripCalculator::getPcbIdentifier
pcbIdentifier_t getPcbIdentifier(quadrupletIdentifier_t quad_id, json_t j) const
Definition: StripCalculator.cxx:130
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
NswAsBuilt::quadrupletIdentifier_t::MMS
@ MMS
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:27
correlationModel::model
model
Definition: AsgElectronEfficiencyCorrectionTool.cxx:46
NswAsBuilt::StripCalculator::buildElement
std::unique_ptr< Element > buildElement(json_t j) const
Definition: StripCalculator.cxx:75
NswAsBuilt::stripIdentifier_t::istrip
int istrip
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:84
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::PcbElement::stripConfiguration_t
Definition: PcbElement.h:38
NswAsBuilt::PcbElement::stripConfiguration_t::centerPoint
stripPoint_t centerPoint
Definition: PcbElement.h:40
NswAsBuilt::PcbElement
Helper class saving all the needed information to compute strips for a particular PCB.
Definition: PcbElement.h:26
NswAsBuilt::quadrupletIdentifier_t::stationPhi
int stationPhi
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:35