CMS 3D CMS Logo

CTPPSGeometry.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TOTEM offline software.
4 * Authors:
5 * Jan Kaspar (jan.kaspar@gmail.com)
6 *
7 ****************************************************************************/
8 
10 #include <regex>
11 
12 //----------------------------------------------------------------------------------------------------
13 
14 void CTPPSGeometry::build(const DetGeomDesc* gD) {
15  // reset
16  sensors_map_.clear();
17  rps_map_.clear();
18  stations_in_arm_.clear();
19  rps_in_station_.clear();
20  dets_in_rp_.clear();
21 
22  // propagate through the GeometricalDet structure and add all detectors to 'sensors_map_'
23  std::deque<const DetGeomDesc*> buffer;
24  buffer.emplace_back(gD);
25  while (!buffer.empty()) {
26  const DetGeomDesc* d = buffer.front();
27  buffer.pop_front();
28 
29  // check if it is a sensor
30  if (d->name() == DDD_TOTEM_RP_SENSOR_NAME ||
31  std::regex_match(d->name(), std::regex(DDD_TOTEM_TIMING_SENSOR_TMPL)) ||
34  addSensor(d->geographicalID(), d);
35 
36  // check if it is a RP
37  if (d->name() == DDD_TOTEM_RP_RP_NAME || d->name() == DDD_TOTEM_TIMING_RP_NAME ||
38  d->name() == DDD_CTPPS_DIAMONDS_RP_NAME || d->name() == DDD_CTPPS_PIXELS_RP_NAME)
39  addRP(d->geographicalID(), d);
40 
41  for (const auto& comp : d->components())
42  buffer.emplace_back(comp);
43  }
44 
45  // build sets
46  for (const auto& it : sensors_map_) {
47  const CTPPSDetId detId(it.first);
48  const CTPPSDetId rpId = detId.rpId();
49  const CTPPSDetId stId = detId.stationId();
50  const CTPPSDetId armId = detId.armId();
51 
52  stations_in_arm_[armId].insert(armId);
53  rps_in_station_[stId].insert(rpId);
54  dets_in_rp_[rpId].insert(detId);
55  }
56 }
57 
58 //----------------------------------------------------------------------------------------------------
59 
60 bool CTPPSGeometry::addSensor(unsigned int id, const DetGeomDesc*& gD) {
61  if (sensors_map_.find(id) != sensors_map_.end())
62  return false;
63 
64  sensors_map_[id] = gD;
65  return true;
66 }
67 
68 //----------------------------------------------------------------------------------------------------
69 
70 bool CTPPSGeometry::addRP(unsigned int id, const DetGeomDesc*& gD) {
71  if (rps_map_.find(id) != rps_map_.end())
72  return false;
73 
74  rps_map_[id] = gD;
75  return true;
76 }
77 
78 //----------------------------------------------------------------------------------------------------
79 
80 const DetGeomDesc* CTPPSGeometry::sensor(unsigned int id) const {
81  auto g = sensorNoThrow(id);
82  if (nullptr == g) {
83  throw cms::Exception("CTPPSGeometry") << "Not found detector with ID " << id << ", i.e. " << CTPPSDetId(id);
84  }
85  return g;
86 }
87 
88 //----------------------------------------------------------------------------------------------------
89 
90 const DetGeomDesc* CTPPSGeometry::sensorNoThrow(unsigned int id) const noexcept {
91  auto it = sensors_map_.find(id);
92  if (it == sensors_map_.end()) {
93  return nullptr;
94  }
95  return it->second;
96 }
97 
98 //----------------------------------------------------------------------------------------------------
99 
100 const DetGeomDesc* CTPPSGeometry::rp(unsigned int id) const {
101  auto rp = rpNoThrow(id);
102  if (nullptr == rp) {
103  throw cms::Exception("CTPPSGeometry") << "Not found RP device with ID " << id << ", i.e. " << CTPPSDetId(id);
104  }
105  return rp;
106 }
107 
108 //----------------------------------------------------------------------------------------------------
109 
110 const DetGeomDesc* CTPPSGeometry::rpNoThrow(unsigned int id) const noexcept {
111  auto it = rps_map_.find(id);
112  if (it == rps_map_.end()) {
113  return nullptr;
114  }
115 
116  return it->second;
117 }
118 
119 //----------------------------------------------------------------------------------------------------
120 const std::set<unsigned int>& CTPPSGeometry::stationsInArm(unsigned int id) const {
121  auto it = stations_in_arm_.find(id);
122  if (it == stations_in_arm_.end())
123  throw cms::Exception("CTPPSGeometry") << "Arm with ID " << id << " not found.";
124  return it->second;
125 }
126 
127 //----------------------------------------------------------------------------------------------------
128 
129 const std::set<unsigned int>& CTPPSGeometry::rpsInStation(unsigned int id) const {
130  auto it = rps_in_station_.find(id);
131  if (it == rps_in_station_.end())
132  throw cms::Exception("CTPPSGeometry") << "Station with ID " << id << " not found.";
133  return it->second;
134 }
135 
136 //----------------------------------------------------------------------------------------------------
137 
138 const std::set<unsigned int>& CTPPSGeometry::sensorsInRP(unsigned int id) const {
139  auto it = dets_in_rp_.find(id);
140  if (it == dets_in_rp_.end())
141  throw cms::Exception("CTPPSGeometry") << "RP with ID " << id << " not found.";
142  return it->second;
143 }
144 
145 //----------------------------------------------------------------------------------------------------
146 
148  return gd->rotation() * r + gd->translation();
149 }
150 
151 //----------------------------------------------------------------------------------------------------
152 
154  return localToGlobal(sensor(id), r);
155 }
156 
157 //----------------------------------------------------------------------------------------------------
158 
160  return gd->rotation().Inverse() * (r - gd->translation());
161 }
162 
163 //----------------------------------------------------------------------------------------------------
164 
166  return globalToLocal(sensor(id), r);
167 }
168 
169 //----------------------------------------------------------------------------------------------------
170 
172  return sensor(id)->rotation() * dir;
173 }
174 
175 //----------------------------------------------------------------------------------------------------
176 
178  return sensor(id)->rotation().Inverse() * dir;
179 }
180 
181 //----------------------------------------------------------------------------------------------------
182 
184  auto gd = sensor(id);
185  return gd->translation();
186 }
187 
188 //----------------------------------------------------------------------------------------------------
189 
191  auto gd = rp(id);
192  return gd->translation();
193 }
DetGeomDesc::rotation
RotationMatrix rotation() const
geometry information
Definition: DetGeomDesc.h:63
CTPPSGeometry::globalToLocal
Vector globalToLocal(const DetGeomDesc *, const Vector &) const
Definition: CTPPSGeometry.cc:158
CTPPSGeometry::rpTranslation
Vector rpTranslation(unsigned int id) const
Definition: CTPPSGeometry.cc:189
CTPPSGeometry::globalToLocalDirection
Vector globalToLocalDirection(unsigned int id, const Vector &) const
Definition: CTPPSGeometry.cc:176
DDD_CTPPS_UFSD_SEGMENT_NAME
const std::string DDD_CTPPS_UFSD_SEGMENT_NAME
Definition: CTPPSDDDNames.h:17
DDD_CTPPS_PIXELS_SENSOR_NAME
const std::string DDD_CTPPS_PIXELS_SENSOR_NAME
Definition: CTPPSDDDNames.h:14
CTPPSGeometry::stationsInArm
const std::set< unsigned int > & stationsInArm(unsigned int) const
after checks returns set of station ids corresponding to the given arm id
Definition: CTPPSGeometry.cc:119
DDD_CTPPS_PIXELS_RP_NAME
const std::string DDD_CTPPS_PIXELS_RP_NAME
Definition: CTPPSDDDNames.h:22
DDD_TOTEM_TIMING_RP_NAME
const std::string DDD_TOTEM_TIMING_RP_NAME
Definition: CTPPSDDDNames.h:25
year_2016_postTS2_cff.rpId
rpId
Definition: year_2016_postTS2_cff.py:23
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
DDD_CTPPS_DIAMONDS_SEGMENT_NAME
const std::string DDD_CTPPS_DIAMONDS_SEGMENT_NAME
Definition: CTPPSDDDNames.h:16
CTPPSDetId::armId
CTPPSDetId armId() const
Definition: CTPPSDetId.h:78
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
CTPPSGeometry.h
CTPPSGeometry::stations_in_arm_
mapSetType stations_in_arm_
map: parent ID -> set of subelements E.g. stations_in_arm_ is map of arm ID -> set of stations (in th...
Definition: CTPPSGeometry.h:125
CTPPSGeometry::sensors_map_
mapType sensors_map_
map: sensor id --> DetGeomDesc
Definition: CTPPSGeometry.h:118
CTPPSGeometry::localToGlobalDirection
Vector localToGlobalDirection(unsigned int id, const Vector &) const
Definition: CTPPSGeometry.cc:170
CTPPSGeometry::sensorTranslation
Vector sensorTranslation(unsigned int id) const
Definition: CTPPSGeometry.cc:182
CTPPSGeometry::sensorNoThrow
const DetGeomDesc * sensorNoThrow(unsigned int id) const noexcept
Definition: CTPPSGeometry.cc:89
CTPPSGeometry::dets_in_rp_
mapSetType dets_in_rp_
Definition: CTPPSGeometry.h:125
DDD_CTPPS_DIAMONDS_RP_NAME
const std::string DDD_CTPPS_DIAMONDS_RP_NAME
Definition: CTPPSDDDNames.h:24
CTPPSGeometry::rps_map_
RPDeviceMapType rps_map_
map: rp id --> DetGeomDesc
Definition: CTPPSGeometry.h:121
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
DDD_TOTEM_TIMING_SENSOR_TMPL
const std::string DDD_TOTEM_TIMING_SENSOR_TMPL
Definition: CTPPSDDDNames.h:18
DetGeomDesc
Geometrical description of a sensor.
Definition: DetGeomDesc.h:34
CTPPSGeometry::rpNoThrow
const DetGeomDesc * rpNoThrow(unsigned int id) const noexcept
Definition: CTPPSGeometry.cc:109
DDD_TOTEM_RP_RP_NAME
const std::string DDD_TOTEM_RP_RP_NAME
DDD names of RP volumes.
Definition: CTPPSDDDNames.h:21
CTPPSGeometry::rpsInStation
const std::set< unsigned int > & rpsInStation(unsigned int) const
after checks returns set of RP ids corresponding to the given station id
Definition: CTPPSGeometry.cc:128
alignCSCRings.r
r
Definition: alignCSCRings.py:93
CTPPSGeometry::addRP
bool addRP(unsigned int id, const DetGeomDesc *&)
adds a RP box to a map
Definition: CTPPSGeometry.cc:69
CTPPSGeometry::addSensor
bool addSensor(unsigned int, const DetGeomDesc *&)
adds an item to the map (detector ID --> DetGeomDesc) performs necessary checks
Definition: CTPPSGeometry.cc:59
CTPPSDetId::stationId
CTPPSDetId stationId() const
Definition: CTPPSDetId.h:80
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Exception
Definition: hltDiff.cc:246
CTPPSGeometry::sensorsInRP
const std::set< unsigned int > & sensorsInRP(unsigned int) const
after checks returns set of sensor ids corresponding to the given RP id
Definition: CTPPSGeometry.cc:137
DDD_TOTEM_RP_SENSOR_NAME
const std::string DDD_TOTEM_RP_SENSOR_NAME
DDD names of sensors.
Definition: CTPPSDDDNames.h:13
CTPPSGeometry::rp
const DetGeomDesc * rp(unsigned int id) const
returns geometry of a RP box
Definition: CTPPSGeometry.cc:99
DetGeomDesc::translation
Translation translation() const
Definition: DetGeomDesc.h:64
ztail.d
d
Definition: ztail.py:151
cms::Exception
Definition: Exception.h:70
CTPPSDetId::rpId
CTPPSDetId rpId() const
Definition: CTPPSDetId.h:82
CTPPSGeometry::localToGlobal
Vector localToGlobal(const DetGeomDesc *, const Vector &) const
Definition: CTPPSGeometry.cc:146
CTPPSGeometry::rps_in_station_
mapSetType rps_in_station_
Definition: CTPPSGeometry.h:125
CTPPSGeometry::build
void build(const DetGeomDesc *)
build up from DetGeomDesc structure
Definition: CTPPSGeometry.cc:13
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
CTPPSGeometry::sensor
const DetGeomDesc * sensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
Definition: CTPPSGeometry.cc:79
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
CTPPSGeometry::Vector
DetGeomDesc::Translation Vector
Definition: CTPPSGeometry.h:39