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 {
38  public:
39  explicit CTPPSGeometryInfo( const edm::ParameterSet& );
40 
41  private:
43 
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 ) )
63 {}
64 
65 //----------------------------------------------------------------------------------------------------
66 
67 void
69 {
71 
72  if ( geometryType_ == "ideal" ) {
73  if ( watcherIdealGeometry_.check( iSetup ) ) {
74  iSetup.get<IdealGeometryRecord>().get( geometry );
75  printGeometry( *geometry, iEvent );
76  }
77  return;
78  }
79 
80  else if ( geometryType_ == "real" ) {
81  if ( watcherRealGeometry_.check( iSetup ) ) {
82  iSetup.get<VeryForwardRealGeometryRecord>().get( geometry );
83  printGeometry( *geometry, iEvent );
84  }
85  return;
86  }
87 
88  else if ( geometryType_ == "misaligned" ) {
89  if ( watcherMisalignedGeometry_.check( iSetup ) ) {
90  iSetup.get<VeryForwardMisalignedGeometryRecord>().get( geometry );
91  printGeometry( *geometry, iEvent );
92  }
93  return;
94  }
95 
96  throw cms::Exception("CTPPSGeometryInfo") << "Unknown geometry type: `" << geometryType_ << "'.";
97 }
98 
99 //----------------------------------------------------------------------------------------------------
100 
102 CTPPSGeometryInfo::formatDetId( const CTPPSDetId &id, bool printDetails )
103 {
104  std::ostringstream oss;
105  oss << id.rawId();
106 
107  const unsigned int rpDecId = id.arm()*100 + id.station()*10 + id.rp();
108 
109  if ( id.subdetId() == CTPPSDetId::sdTrackingStrip ) {
110  TotemRPDetId fid( id );
111  oss << " (strip RP " << std::setw(3) << rpDecId;
112  if ( printDetails )
113  oss << ", plane " << fid.plane();
114  oss << ")";
115  }
116 
117  else if ( id.subdetId() == CTPPSDetId::sdTrackingPixel ) {
118  CTPPSPixelDetId fid( id );
119  oss << " (pixel RP " << std::setw(3) << rpDecId;
120  if ( printDetails )
121  oss << ", plane " << fid.plane();
122  oss << ")";
123  }
124 
125  else if ( id.subdetId() == CTPPSDetId::sdTimingDiamond ) {
126  CTPPSDiamondDetId fid( id );
127  oss << " (diamd RP " << std::setw(3) << rpDecId;
128  if ( printDetails )
129  oss << ", plane " << fid.plane() << ", channel " << std::setw(2) << fid.channel();
130  oss << ")";
131  }
132 
133  else if ( id.subdetId() == CTPPSDetId::sdTimingFastSilicon ) {
134  TotemTimingDetId fid( id );
135  oss << " (totim RP " << std::setw(3) << rpDecId;
136  if ( printDetails )
137  oss << ", plane " << fid.plane() << ", channel " << std::setw(2) << fid.channel();
138  oss << ")";
139  }
140 
141  return oss.str();
142 }
143 
144 //----------------------------------------------------------------------------------------------------
145 
146 void
148 {
149  time_t unixTime = event.time().unixTime();
150  char timeStr[50];
151  strftime( timeStr, 50, "%F %T", localtime( &unixTime ) );
152 
153  std::ostringstream oss;
154 
155  // RP geometry
156  if ( printRPInfo_ ) {
157  oss << "* RPs:\n"
158  << " ce: RP center in global coordinates, in mm\n";
159 
160  for ( auto it = geometry.beginRP(); it != geometry.endRP(); ++it ) {
161  const DDTranslation &t = it->second->translation();
162 
163  oss << formatDetId( CTPPSDetId( it->first ), false )
164  << std::fixed << std::setprecision( 3 ) << std::showpos
165  << " | ce=(" << t.x() << ", " << t.y() << ", " << t.z() << ")\n";
166  }
167 
168  edm::LogVerbatim("CTPPSGeometryInfo") << oss.str();
169  }
170 
171  // sensor geometry
172  if ( printSensorInfo_ ) {
173  oss << "* sensors:\n"
174  << " ce: sensor center in global coordinates, in mm\n"
175  << " a1: local axis (1, 0, 0) in global coordinates\n"
176  << " a2: local axis (0, 1, 0) in global coordinates\n"
177  << " a3: local axis (0, 0, 1) in global coordinates\n";
178 
179  for ( auto it = geometry.beginSensor(); it != geometry.endSensor(); ++it ) {
180  CTPPSDetId detId( it->first );
181 
182  const CLHEP::Hep3Vector gl_o = geometry.localToGlobal( detId, CLHEP::Hep3Vector( 0, 0, 0 ) );
183  const CLHEP::Hep3Vector gl_a1 = geometry.localToGlobal( detId, CLHEP::Hep3Vector( 1, 0, 0 ) ) - gl_o;
184  const CLHEP::Hep3Vector gl_a2 = geometry.localToGlobal( detId, CLHEP::Hep3Vector( 0, 1, 0 ) ) - gl_o;
185  const CLHEP::Hep3Vector gl_a3 = geometry.localToGlobal( detId, CLHEP::Hep3Vector( 0, 0, 1 ) ) - gl_o;
186 
187  oss << formatDetId( detId )
188  << std::fixed << std::setprecision( 3 ) << std::showpos
189  << " | ce=(" << gl_o.x() << ", " << gl_o.y() << ", " << gl_o.z() << ")"
190  << " | a1=(" << gl_a1.x() << ", " << gl_a1.y() << ", " << gl_a1.z() << ")"
191  << " | a2=(" << gl_a2.x() << ", " << gl_a2.y() << ", " << gl_a2.z() << ")"
192  << " | a3=(" << gl_a3.x() << ", " << gl_a3.y() << ", " << gl_a3.z() << ")\n";
193  }
194  }
195 
196  edm::LogInfo("CTPPSGeometryInfo")
197  << "New " << geometryType_ << " geometry found in run="
198  << event.id().run() << ", event=" << event.id().event() << ", UNIX timestamp=" << unixTime
199  << " (" << timeStr << ")\n"
200  << oss.str();
201 }
202 
203 //----------------------------------------------------------------------------------------------------
204 
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_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
uint32_t channel() const
uint32_t plane() const
Definition: TotemRPDetId.h:49
mapType::const_iterator beginSensor() const
begin iterator over sensors
Definition: CTPPSGeometry.h:72
Event setup record containing the real (actual) geometry information.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
int iEvent
Definition: GenABIO.cc:230
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:77
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:74
RPDeviceMapType::const_iterator endRP() const
end iterator over RPs
Definition: CTPPSGeometry.h:79
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
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:63
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 ...