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 
35 class CTPPSGeometryInfo : public edm::one::EDAnalyzer<> {
36 public:
37  explicit CTPPSGeometryInfo(const edm::ParameterSet&);
38 
39 private:
41  const bool printRPInfo_, printSensorInfo_;
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 
69 void CTPPSGeometryInfo::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
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 
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
VeryForwardRealGeometryRecord
Event setup record containing the real (actual) geometry information.
Definition: VeryForwardRealGeometryRecord.h:23
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
TotemTimingDetId::channel
uint32_t channel() const
Definition: TotemTimingDetId.h:56
electrons_cff.bool
bool
Definition: electrons_cff.py:366
EDAnalyzer.h
CTPPSGeometryInfo::watcherRealGeometry_
edm::ESWatcher< VeryForwardRealGeometryRecord > watcherRealGeometry_
Definition: CTPPSGeometryInfo.cc:50
CTPPSGeometry
The manager class for TOTEM RP geometry.
Definition: CTPPSGeometry.h:29
edm::ESWatcher< IdealGeometryRecord >
geometry
Definition: geometry.py:1
CTPPSPixelDetId.h
CTPPSDetId::sdTimingFastSilicon
Definition: CTPPSDetId.h:44
TotemTimingDetId::plane
uint32_t plane() const
Definition: TotemTimingDetId.h:49
TotemRPDetId::plane
uint32_t plane() const
Definition: TotemRPDetId.h:51
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
CTPPSGeometryInfo::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: CTPPSGeometryInfo.cc:68
VeryForwardMisalignedGeometryRecord.h
CTPPSDetId::sdTrackingStrip
Definition: CTPPSDetId.h:44
CTPPSGeometry.h
MakerMacros.h
CTPPSGeometryInfo::formatDetId
static std::string formatDetId(const CTPPSDetId &id, bool printDetails=true)
Definition: CTPPSGeometryInfo.cc:98
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CTPPSDiamondDetId::plane
uint32_t plane() const
Definition: CTPPSDiamondDetId.h:46
TotemTimingDetId.h
CTPPSGeometryInfo::tokReal_
const edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > tokReal_
Definition: CTPPSGeometryInfo.cc:46
CTPPSDiamondDetId::channel
uint32_t channel() const
Definition: CTPPSDiamondDetId.h:53
CTPPSDetId::sdTimingDiamond
Definition: CTPPSDetId.h:44
CTPPSGeometryInfo::CTPPSGeometryInfo
CTPPSGeometryInfo(const edm::ParameterSet &)
Definition: CTPPSGeometryInfo.cc:58
CTPPSDetId::sdTrackingPixel
Definition: CTPPSDetId.h:44
TotemTimingDetId
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...
Definition: TotemTimingDetId.h:26
funct::true
true
Definition: Factorize.h:173
CTPPSDiamondDetId.h
CTPPSGeometryInfo::watcherMisalignedGeometry_
edm::ESWatcher< VeryForwardMisalignedGeometryRecord > watcherMisalignedGeometry_
Definition: CTPPSGeometryInfo.cc:51
CTPPSDiamondDetId
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
Definition: CTPPSDiamondDetId.h:24
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
iEvent
int iEvent
Definition: GenABIO.cc:224
CTPPSPixelDetId::plane
uint32_t plane() const
Definition: CTPPSPixelDetId.h:37
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:58
CTPPSPixelDetId
Definition: CTPPSPixelDetId.h:16
VeryForwardRealGeometryRecord.h
edm::ESGetToken< CTPPSGeometry, IdealGeometryRecord >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
CTPPSGeometryInfo::tokMis_
const edm::ESGetToken< CTPPSGeometry, VeryForwardMisalignedGeometryRecord > tokMis_
Definition: CTPPSGeometryInfo.cc:47
VeryForwardMisalignedGeometryRecord
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
Definition: VeryForwardMisalignedGeometryRecord.h:24
CTPPSGeometryInfo::printRPInfo_
const bool printRPInfo_
Definition: CTPPSGeometryInfo.cc:44
std
Definition: JetResolutionObject.h:76
DetGeomDesc::Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: DetGeomDesc.h:54
CTPPSGeometryInfo::printGeometry
void printGeometry(const CTPPSGeometry &, const edm::Event &)
Definition: CTPPSGeometryInfo.cc:141
ESWatcher.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:245
CTPPSGeometryInfo::geometryType_
const std::string geometryType_
Definition: CTPPSGeometryInfo.cc:43
TotemRPDetId.h
EventSetup.h
CTPPSDetId.h
Exception.h
ParameterSet.h
CTPPSGeometryInfo::printSensorInfo_
const bool printSensorInfo_
Definition: CTPPSGeometryInfo.cc:44
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
CTPPSGeometryInfo::watcherIdealGeometry_
edm::ESWatcher< IdealGeometryRecord > watcherIdealGeometry_
Definition: CTPPSGeometryInfo.cc:49
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
CTPPSGeometryInfo::tokIdeal_
const edm::ESGetToken< CTPPSGeometry, IdealGeometryRecord > tokIdeal_
Definition: CTPPSGeometryInfo.cc:45
TotemRPDetId
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:29
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
CTPPSGeometry::Vector
DetGeomDesc::Translation Vector
Definition: CTPPSGeometry.h:39
CTPPSGeometryInfo
Class to print out information on current geometry.
Definition: CTPPSGeometryInfo.cc:34