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 
36 class CTPPSGeometryInfo : public edm::one::EDAnalyzer<> {
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 
65 void CTPPSGeometryInfo::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
67 
68  if (geometryType_ == "ideal") {
69  if (watcherIdealGeometry_.check(iSetup)) {
72  }
73  return;
74  }
75 
76  else if (geometryType_ == "real") {
77  if (watcherRealGeometry_.check(iSetup)) {
80  }
81  return;
82  }
83 
84  else if (geometryType_ == "misaligned") {
85  if (watcherMisalignedGeometry_.check(iSetup)) {
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 auto gl_o = geometry.localToGlobal(detId, CTPPSGeometry::Vector(0, 0, 0));
174  const auto gl_a1 = geometry.localToGlobal(detId, CTPPSGeometry::Vector(1, 0, 0)) - gl_o;
175  const auto gl_a2 = geometry.localToGlobal(detId, CTPPSGeometry::Vector(0, 1, 0)) - gl_o;
176  const auto gl_a3 = geometry.localToGlobal(detId, CTPPSGeometry::Vector(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 
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
VeryForwardRealGeometryRecord
Event setup record containing the real (actual) geometry information.
Definition: VeryForwardRealGeometryRecord.h:22
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
geometry
ESHandle< TrackerGeometry > geometry
Definition: TkLasBeamFitter.cc:200
TotemTimingDetId::channel
uint32_t channel() const
Definition: TotemTimingDetId.h:56
electrons_cff.bool
bool
Definition: electrons_cff.py:393
EDAnalyzer.h
CTPPSGeometryInfo::watcherRealGeometry_
edm::ESWatcher< VeryForwardRealGeometryRecord > watcherRealGeometry_
Definition: CTPPSGeometryInfo.cc:49
CTPPSGeometry
The manager class for TOTEM RP geometry.
Definition: CTPPSGeometry.h:29
CTPPSGeometryInfo::geometryType_
std::string geometryType_
Definition: CTPPSGeometryInfo.cc:44
edm::ESWatcher< IdealGeometryRecord >
ESHandle.h
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:64
CTPPSGeometryInfo::printRPInfo_
bool printRPInfo_
Definition: CTPPSGeometryInfo.cc:46
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:96
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CTPPSDiamondDetId::plane
uint32_t plane() const
Definition: CTPPSDiamondDetId.h:46
CTPPSGeometryInfo::printSensorInfo_
bool printSensorInfo_
Definition: CTPPSGeometryInfo.cc:46
TotemTimingDetId.h
CTPPSDiamondDetId::channel
uint32_t channel() const
Definition: CTPPSDiamondDetId.h:53
edm::ESHandle< CTPPSGeometry >
CTPPSDetId::sdTimingDiamond
Definition: CTPPSDetId.h:44
CTPPSGeometryInfo::CTPPSGeometryInfo
CTPPSGeometryInfo(const edm::ParameterSet &)
Definition: CTPPSGeometryInfo.cc:57
CTPPSDetId::sdTrackingPixel
Definition: CTPPSDetId.h:44
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:50
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:57
CTPPSPixelDetId
Definition: CTPPSPixelDetId.h:16
get
#define get
VeryForwardRealGeometryRecord.h
VeryForwardMisalignedGeometryRecord
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
Definition: VeryForwardMisalignedGeometryRecord.h:23
std
Definition: JetResolutionObject.h:76
DetGeomDesc::Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: DetGeomDesc.h:53
CTPPSGeometryInfo::printGeometry
void printGeometry(const CTPPSGeometry &, const edm::Event &)
Definition: CTPPSGeometryInfo.cc:139
ESWatcher.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:246
TotemRPDetId.h
EventSetup.h
CTPPSDetId.h
Exception.h
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
CTPPSGeometryInfo::watcherIdealGeometry_
edm::ESWatcher< IdealGeometryRecord > watcherIdealGeometry_
Definition: CTPPSGeometryInfo.cc:48
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
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:35