CMS 3D CMS Logo

CTPPSGeometryInfo.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Authors:
4  * Jan Kašpar (jan.kaspar@gmail.com)
5  *
6  ****************************************************************************/
7 
15 
20 
26 
27 #include <iostream>
28 #include <iomanip>
29 
30 //----------------------------------------------------------------------------------------------------
31 
36 public:
37  explicit CTPPSGeometryInfo(const edm::ParameterSet&);
38 
39 private:
45 
49 
50  void analyze(const edm::Event&, const edm::EventSetup&) override;
51 
52  static std::string formatDetId(const CTPPSDetId& id, bool printDetails = true);
53 
54  void printGeometry(const CTPPSGeometry&, const edm::Event&);
55 };
56 
57 //----------------------------------------------------------------------------------------------------
58 
60  : geometryType_(iConfig.getUntrackedParameter<std::string>("geometryType", "real")),
61  printRPInfo_(iConfig.getUntrackedParameter<bool>("printRPInfo", true)),
62  printSensorInfo_(iConfig.getUntrackedParameter<bool>("printSensorInfo", true)),
66 
67 //----------------------------------------------------------------------------------------------------
68 
70  if (geometryType_ == "ideal") {
71  if (watcherIdealGeometry_.check(iSetup)) {
72  const auto& geometry = iSetup.getData(tokIdeal_);
74  }
75  return;
76  }
77 
78  else if (geometryType_ == "real") {
79  if (watcherRealGeometry_.check(iSetup)) {
80  const auto& geometry = iSetup.getData(tokReal_);
82  }
83  return;
84  }
85 
86  else if (geometryType_ == "misaligned") {
87  if (watcherMisalignedGeometry_.check(iSetup)) {
88  const auto& geometry = iSetup.getData(tokMis_);
90  }
91  return;
92  }
93 
94  throw cms::Exception("CTPPSGeometryInfo") << "Unknown geometry type: `" << geometryType_ << "'.";
95 }
96 
97 //----------------------------------------------------------------------------------------------------
98 
99 std::string CTPPSGeometryInfo::formatDetId(const CTPPSDetId& id, bool printDetails) {
100  std::ostringstream oss;
101  oss << id.rawId();
102 
103  const unsigned int rpDecId = id.arm() * 100 + id.station() * 10 + id.rp();
104 
105  if (id.subdetId() == CTPPSDetId::sdTrackingStrip) {
106  TotemRPDetId fid(id);
107  oss << " (strip RP " << std::setw(3) << rpDecId;
108  if (printDetails)
109  oss << ", plane " << fid.plane();
110  oss << ")";
111  }
112 
113  else if (id.subdetId() == CTPPSDetId::sdTrackingPixel) {
114  CTPPSPixelDetId fid(id);
115  oss << " (pixel RP " << std::setw(3) << rpDecId;
116  if (printDetails)
117  oss << ", plane " << fid.plane();
118  oss << ")";
119  }
120 
121  else if (id.subdetId() == CTPPSDetId::sdTimingDiamond) {
122  CTPPSDiamondDetId fid(id);
123  oss << " (diamd RP " << std::setw(3) << rpDecId;
124  if (printDetails)
125  oss << ", plane " << fid.plane() << ", channel " << std::setw(2) << fid.channel();
126  oss << ")";
127  }
128 
129  else if (id.subdetId() == CTPPSDetId::sdTimingFastSilicon) {
130  TotemTimingDetId fid(id);
131  oss << " (totim RP " << std::setw(3) << rpDecId;
132  if (printDetails)
133  oss << ", plane " << fid.plane() << ", channel " << std::setw(2) << fid.channel();
134  oss << ")";
135  }
136 
137  return oss.str();
138 }
139 
140 //----------------------------------------------------------------------------------------------------
141 
143  time_t unixTime = event.time().unixTime();
144  char timeStr[50];
145  strftime(timeStr, 50, "%F %T", localtime(&unixTime));
146 
147  std::ostringstream oss;
148 
149  // RP geometry
150  if (printRPInfo_) {
151  oss << "* RPs:\n"
152  << " ce: RP center in global coordinates, in mm\n";
153 
154  for (auto it = geometry.beginRP(); it != geometry.endRP(); ++it) {
155  const DetGeomDesc::Translation& t = it->second->translation();
156 
157  oss << formatDetId(CTPPSDetId(it->first), false) << std::fixed << std::setprecision(3) << std::showpos
158  << " | ce=(" << t.x() << ", " << t.y() << ", " << t.z() << ")\n";
159  }
160 
161  edm::LogVerbatim("CTPPSGeometryInfo") << oss.str();
162  }
163 
164  // sensor geometry
165  if (printSensorInfo_) {
166  oss << "* sensors:\n"
167  << " ce: sensor center in global coordinates, in mm\n"
168  << " a1: local axis (1, 0, 0) in global coordinates\n"
169  << " a2: local axis (0, 1, 0) in global coordinates\n"
170  << " a3: local axis (0, 0, 1) in global coordinates\n";
171 
172  for (auto it = geometry.beginSensor(); it != geometry.endSensor(); ++it) {
173  CTPPSDetId detId(it->first);
174 
175  const auto gl_o = geometry.localToGlobal(detId, CTPPSGeometry::Vector(0, 0, 0));
176  const auto gl_a1 = geometry.localToGlobal(detId, CTPPSGeometry::Vector(1, 0, 0)) - gl_o;
177  const auto gl_a2 = geometry.localToGlobal(detId, CTPPSGeometry::Vector(0, 1, 0)) - gl_o;
178  const auto gl_a3 = geometry.localToGlobal(detId, CTPPSGeometry::Vector(0, 0, 1)) - gl_o;
179 
180  oss << formatDetId(detId) << std::fixed << std::setprecision(3) << std::showpos << " | ce=(" << gl_o.x() << ", "
181  << gl_o.y() << ", " << gl_o.z() << ")"
182  << " | a1=(" << gl_a1.x() << ", " << gl_a1.y() << ", " << gl_a1.z() << ")"
183  << " | a2=(" << gl_a2.x() << ", " << gl_a2.y() << ", " << gl_a2.z() << ")"
184  << " | a3=(" << gl_a3.x() << ", " << gl_a3.y() << ", " << gl_a3.z() << ")\n";
185  }
186  }
187 
188  edm::LogInfo("CTPPSGeometryInfo") << "New " << geometryType_ << " geometry found in run=" << event.id().run()
189  << ", event=" << event.id().event() << ", UNIX timestamp=" << unixTime << " ("
190  << timeStr << ")\n"
191  << oss.str();
192 }
193 
194 //----------------------------------------------------------------------------------------------------
195 
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
Log< level::Info, true > LogVerbatim
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Class to print out information on current geometry.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< CTPPSGeometry, IdealGeometryRecord > tokIdeal_
edm::ESWatcher< VeryForwardRealGeometryRecord > watcherRealGeometry_
uint32_t plane() const
Event setup record containing the real (actual) geometry information.
DetGeomDesc::Translation Vector
Definition: CTPPSGeometry.h:36
uint32_t plane() const
Definition: TotemRPDetId.h:46
const edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > tokReal_
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &) override
uint32_t channel() const
edm::ESWatcher< VeryForwardMisalignedGeometryRecord > watcherMisalignedGeometry_
uint32_t channel() const
CTPPSGeometryInfo(const edm::ParameterSet &)
uint32_t plane() const
static std::string formatDetId(const CTPPSDetId &id, bool printDetails=true)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
The manager class for TOTEM RP geometry.
Definition: CTPPSGeometry.h:30
Log< level::Info, false > LogInfo
const edm::ESGetToken< CTPPSGeometry, VeryForwardMisalignedGeometryRecord > tokMis_
const std::string geometryType_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
uint32_t plane() const
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: DetGeomDesc.h:55
void printGeometry(const CTPPSGeometry &, const edm::Event &)
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
edm::ESWatcher< IdealGeometryRecord > watcherIdealGeometry_
const bool printSensorInfo_
Definition: event.py:1
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...