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