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 
26 
27 #include <iostream>
28 #include <iomanip>
29 
30 //----------------------------------------------------------------------------------------------------
31 
36 {
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 //----------------------------------------------------------------------------------------------------
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  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  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  return oss.str();
134 }
135 
136 //----------------------------------------------------------------------------------------------------
137 
138 void
140 {
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 DDTranslation &t = it->second->translation();
154 
155  oss << formatDetId( CTPPSDetId( it->first ), false )
156  << std::fixed << std::setprecision( 3 ) << " | 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 )
179  << std::fixed << std::setprecision( 3 ) << std::showpos
180  << " | ce=(" << gl_o.x() << ", " << gl_o.y() << ", " << gl_o.z() << ")"
181  << " | a1=(" << gl_a1.x() << ", " << gl_a1.y() << ", " << gl_a1.z() << ")"
182  << " | a2=(" << gl_a2.x() << ", " << gl_a2.y() << ", " << gl_a2.z() << ")"
183  << " | a3=(" << gl_a3.x() << ", " << gl_a3.y() << ", " << gl_a3.z() << ")\n";
184  }
185  }
186 
187  edm::LogInfo("CTPPSGeometryInfo")
188  << "New " << geometryType_ << " geometry found in run="
189  << event.id().run() << ", 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
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 plane() const
Definition: TotemRPDetId.h:49
mapType::const_iterator beginSensor() const
begin iterator over sensors
Definition: CTPPSGeometry.h:70
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:75
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
const T & get() const
Definition: EventSetup.h:59
mapType::const_iterator endSensor() const
end iterator over sensors
Definition: CTPPSGeometry.h:72
RPDeviceMapType::const_iterator endRP() const
end iterator over RPs
Definition: CTPPSGeometry.h:77
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...
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