ATLAS Offline Software
Loading...
Searching...
No Matches
StripCalculator.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUONNSWASBUILT_STRIPCALCULATOR_H
6#define MUONNSWASBUILT_STRIPCALCULATOR_H
7
8#include <vector>
9#include <string>
10#include <unordered_map>
11#include <functional>
12#include <memory>
13
18
19namespace NswAsBuilt {
20
21 /* The main interface of the NswAsBuilt package: determines strip positions
22 * in the frame of the quadruplet.
23 *
24 * Once instanciated, the as-built geometry must be read in from a stream of
25 * JSON formatted data, using the method parseJSON.
26 *
27 * Strip positions may then be queried, using the method getStrip. (The method
28 * getStrip is thread-safe.) */
29
31 public:
33
34 /* VALID: strip is found, INVALID: strip is not found */
35 enum class IsValid {
38 };
39
40 /* The return object for querying strip positions: three points along the
41 * strip are provided, in the coordinate system of the quadruplet.*/
42 struct strip_t {
44 Amg::Vector3D center{Amg::Vector3D::Zero()};
45 Amg::Vector3D left{Amg::Vector3D::Zero()};
46 Amg::Vector3D right{Amg::Vector3D::Zero()};
47 };
48
49 /* Computes 3 reference points along a strip identified by strip_id, in
50 * coordinate system of quadruplet.
51 * Use iclass=ParameterClass::NOMINAL or ParameterClass::CORRECTION to
52 * get the nominal or as-built values, respectively. */
53 strip_t getStrip(ParameterClass iclass, stripIdentifier_t strip_id) const;
54
55 /* The return object for querying strip positions with the method
56 * getPositionAlongStrip: a single point on strip is returned, in the
57 * coordinate system of the quadruplet */
58 struct position_t {
60 Amg::Vector3D pos{Amg::Vector3D::Zero()};
61 };
62
63 /* Returns a the position of a point within a band of 1 pitch around the strip (sx in [-0.5,0.5]),
64 parameterized by sy, in the coordinate system of the quadruplet.
65 * sy is in [-1,1]: -1 returns the left-most point along the strip, 0
66 * returns the center point and +1 return the right-most point */
67 position_t getPositionAlongStrip(ParameterClass iclass, stripIdentifier_t strip_id, double sx, double sy) const;
68
69 /* Parses a std::istream with JSON-formatted configuration of the as-built parameters */
70 void parseJSON(const std::string& in);
71
72 private:
73
74 std::vector<std::unique_ptr<Element>> m_rootElements;
75 std::unordered_map<pcbIdentifier_t, PcbElement> m_pcbMap;
76
77 /* Follow JSON parsing helper methods */
78 struct json_t; // wraps a nlhohman::json in a pimpl struct to hide dependency
79 /* Parse the JSON ROOT element */
81 /* Build a NswAsBuilt::Element, following description in JSON */
82 std::unique_ptr<Element> buildElement(json_t j) const;
83 /* Parse a quadruplet identifier in JSON */
85 /* Parse a PCB identidier in JSON */
87 /* Parse the strip information attached to an element */
88 void collectStrip(quadrupletIdentifier_t quad_id, Element& element, json_t j);
89 /* Parse the strip configuration parameters in JSON */
91
92 };
93}
94
95#endif
96
Element: a node in a hierarchy of alignment frames.
Definition Element.h:52
void collectStrip(quadrupletIdentifier_t quad_id, Element &element, json_t j)
std::vector< std::unique_ptr< Element > > m_rootElements
std::unique_ptr< Element > buildElement(json_t j) const
PcbElement::stripConfiguration_t getStripConfiguration(json_t j) const
Element::ParameterClass ParameterClass
position_t getPositionAlongStrip(ParameterClass iclass, stripIdentifier_t strip_id, double sx, double sy) const
quadrupletIdentifier_t getQuadrupletIdentifier(json_t j) const
strip_t getStrip(ParameterClass iclass, stripIdentifier_t strip_id) const
void parseJSON(const std::string &in)
std::unordered_map< pcbIdentifier_t, PcbElement > m_pcbMap
pcbIdentifier_t getPcbIdentifier(quadrupletIdentifier_t quad_id, json_t j) const
Eigen::Matrix< double, 3, 1 > Vector3D