test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
MeasuredGeometryProducer Class Reference

Public Member Functions

 MeasuredGeometryProducer (const edm::ESHandle< DDCompactView > &idealCV, const edm::ESHandle< RPAlignmentCorrectionsData > &alignments)
 
DDCompactView *& produce ()
 

Private Member Functions

void applyCorrection (const DDLogicalPart &parent, const DDLogicalPart &child, const RPAlignmentCorrectionData &correction, DDTranslation &translation, DDRotationMatrix &rotation, const bool useMeasuredParent=true)
 
void positionDetectors (void)
 
void positionEverythingButDetectors (void)
 

Static Private Member Functions

static void applyCorrectionToTransform (const RPAlignmentCorrectionData &correction, TMatrixD &transform)
 
static DDExpandedViewdelExpandedView (DDExpandedView *expandedView)
 
static int getDetectorId (const int rpId, const int detNo)
 
static void getGlobalTransform (const DDLogicalPart &part, const DDCompactView &compactView, TMatrixD &transform)
 
static int getRPIdFromNamespace (const DDLogicalPart &part)
 
static bool isDetector (const DDLogicalPart &part)
 
static bool isRPBox (const DDLogicalPart &part)
 
static DDExpandedViewnewExpandedView (const DDCompactView &compactView, const DDLogicalPart &part)
 
static void translRotFromTransform (DDTranslation &translation, DDRotationMatrix &rotation, const TMatrixD &transform)
 
static void translRotToTransform (const DDTranslation &translation, const DDRotationMatrix &rotation, TMatrixD &transform)
 

Private Attributes

const
RPAlignmentCorrectionsData
*const 
alignments
 
const DDCompactViewidealCV
 
DDCompactViewmeasuredCV
 
DDLogicalPart root
 

Static Private Attributes

static bool evRotationStoreState
 

Detailed Description

Definition at line 167 of file TotemRPGeometryESModule.cc.

Constructor & Destructor Documentation

MeasuredGeometryProducer::MeasuredGeometryProducer ( const edm::ESHandle< DDCompactView > &  idealCV,
const edm::ESHandle< RPAlignmentCorrectionsData > &  alignments 
)
inline

Definition at line 388 of file TotemRPGeometryESModule.cc.

References pyrootRender::root.

389  : idealCV(*idealCV), alignments(alignments.isValid() ? &(*alignments) : NULL) {
390  root = this->idealCV.root();
391  }
const RPAlignmentCorrectionsData *const alignments
#define NULL
Definition: scimark2.h:8
bool isValid() const
Definition: ESHandle.h:47

Member Function Documentation

void MeasuredGeometryProducer::applyCorrection ( const DDLogicalPart parent,
const DDLogicalPart child,
const RPAlignmentCorrectionData correction,
DDTranslation translation,
DDRotationMatrix rotation,
const bool  useMeasuredParent = true 
)
inlineprivate

Definition at line 309 of file TotemRPGeometryESModule.cc.

References funct::C, and F().

310  {
311  TMatrixD C(4,4); // child relative transform
312  TMatrixD iP(4,4); // ideal parent global transform
313  TMatrixD mP(4,4); // measured parent global transform
314  TMatrixD F(4,4); // final child transform
315 
316  translRotToTransform(translation, rotation, C);
317 
318  if (useMeasuredParent)
319  getGlobalTransform(parent, *measuredCV, mP);
320  else
321  getGlobalTransform(parent, idealCV, mP);
322  getGlobalTransform(parent, idealCV, iP);
323 
324  // global final transform
325  F = iP * C;
326  applyCorrectionToTransform(correction, F);
327  // relative final transform
328  mP.Invert();
329  F = mP * F;
330 
331  translRotFromTransform(translation, rotation, F);
332  }
static void translRotFromTransform(DDTranslation &translation, DDRotationMatrix &rotation, const TMatrixD &transform)
static void applyCorrectionToTransform(const RPAlignmentCorrectionData &correction, TMatrixD &transform)
static void getGlobalTransform(const DDLogicalPart &part, const DDCompactView &compactView, TMatrixD &transform)
static void translRotToTransform(const DDTranslation &translation, const DDRotationMatrix &rotation, TMatrixD &transform)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
static void MeasuredGeometryProducer::applyCorrectionToTransform ( const RPAlignmentCorrectionData correction,
TMatrixD &  transform 
)
inlinestaticprivate

Definition at line 296 of file TotemRPGeometryESModule.cc.

References RPAlignmentCorrectionData::getRotationMatrix(), RPAlignmentCorrectionData::getTranslation(), and idealTransformation::rotation.

296  {
297  DDTranslation translation;
299 
300  translRotFromTransform(translation, rotation, transform);
301 
302  translation = correction.getTranslation() + translation;
303  rotation = correction.getRotationMatrix() * rotation;
304 
305  translRotToTransform(translation, rotation, transform);
306  }
RotationMatrix getRotationMatrix() const
static void translRotFromTransform(DDTranslation &translation, DDRotationMatrix &rotation, const TMatrixD &transform)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
const math::XYZVectorD & getTranslation() const
static void translRotToTransform(const DDTranslation &translation, const DDRotationMatrix &rotation, TMatrixD &transform)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
static DDExpandedView* MeasuredGeometryProducer::delExpandedView ( DDExpandedView expandedView)
inlinestaticprivate

Definition at line 209 of file TotemRPGeometryESModule.cc.

References DDI::Singleton< I >::instance(), and NULL.

209  {
210  delete expandedView;
212  return NULL;
213  }
#define NULL
Definition: scimark2.h:8
static value_type & instance()
static int MeasuredGeometryProducer::getDetectorId ( const int  rpId,
const int  detNo 
)
inlinestaticprivate

Definition at line 286 of file TotemRPGeometryESModule.cc.

286  {
287  return rpId * 10 + detNo;
288  }
static void MeasuredGeometryProducer::getGlobalTransform ( const DDLogicalPart part,
const DDCompactView compactView,
TMatrixD &  transform 
)
inlinestaticprivate

Definition at line 261 of file TotemRPGeometryESModule.cc.

References DDExpandedView::rotation(), create_public_lumi_plots::transform, and DDExpandedView::translation().

261  {
262  DDExpandedView *expandedView = newExpandedView(compactView, part);
263  translRotToTransform(expandedView->translation(), expandedView->rotation(), transform);
264  expandedView = delExpandedView(expandedView);
265  }
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
const DDTranslation & translation() const
The absolute translation of the current node.
static void translRotToTransform(const DDTranslation &translation, const DDRotationMatrix &rotation, TMatrixD &transform)
Provides an exploded view of the detector (tree-view)
static DDExpandedView * delExpandedView(DDExpandedView *expandedView)
static DDExpandedView * newExpandedView(const DDCompactView &compactView, const DDLogicalPart &part)
static int MeasuredGeometryProducer::getRPIdFromNamespace ( const DDLogicalPart part)
inlinestaticprivate

Definition at line 280 of file TotemRPGeometryESModule.cc.

References DDBase< N, C >::name(), and DDName::ns().

280  {
281  int nsLength = part.name().ns().length();
282  return atoi(part.name().ns().substr(nsLength - 3, nsLength).c_str());
283  }
const N & name() const
Definition: DDBase.h:78
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
static bool MeasuredGeometryProducer::isDetector ( const DDLogicalPart part)
inlinestaticprivate

Definition at line 275 of file TotemRPGeometryESModule.cc.

References DDD_TOTEM_RP_DETECTOR_NAME, DDName::name(), and DDBase< N, C >::name().

275  {
276  return (! part.name().name().compare(DDD_TOTEM_RP_DETECTOR_NAME));
277  }
const N & name() const
Definition: DDBase.h:78
const char DDD_TOTEM_RP_DETECTOR_NAME[]
DDD name of RP detector.
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
static bool MeasuredGeometryProducer::isRPBox ( const DDLogicalPart part)
inlinestaticprivate

Definition at line 270 of file TotemRPGeometryESModule.cc.

References DDD_TOTEM_RP_PRIMARY_VACUUM_NAME, DDName::name(), and DDBase< N, C >::name().

270  {
271  return (! part.name().name().compare(DDD_TOTEM_RP_PRIMARY_VACUUM_NAME));
272  }
const N & name() const
Definition: DDBase.h:78
const char DDD_TOTEM_RP_PRIMARY_VACUUM_NAME[]
DDD name of RP.
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
static DDExpandedView* MeasuredGeometryProducer::newExpandedView ( const DDCompactView compactView,
const DDLogicalPart part 
)
inlinestaticprivate

Definition at line 186 of file TotemRPGeometryESModule.cc.

References DDI::Singleton< I >::instance(), DDExpandedView::logicalPart(), DDName::name(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), DDExpandedView::next(), and DDName::ns().

186  {
188  DDExpandedView *expandedView = new DDExpandedView(compactView);
189  // traverse the tree until name and ns are mached
190  const string &name = part.name().name();
191  const string &ns = part.name().ns();
192  bool noMatch = true;
193 
194  noMatch = false;
195  noMatch |= expandedView->logicalPart().name().name().compare(name);
196  noMatch |= expandedView->logicalPart().name().ns().compare(ns);
197  while (noMatch) {
198  expandedView->next();
199  noMatch = false;
200  noMatch |= expandedView->logicalPart().name().name().compare(name);
201  noMatch |= expandedView->logicalPart().name().ns().compare(ns);
202  }
203  return expandedView;
204  }
bool next()
set current node to the next node in the expanded tree
const N & name() const
Definition: DDBase.h:78
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
static value_type & instance()
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
Provides an exploded view of the detector (tree-view)
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
void MeasuredGeometryProducer::positionDetectors ( void  )
inlineprivate

Definition at line 361 of file TotemRPGeometryESModule.cc.

References DDanonymousRot(), NULL, and idealTransformation::rotation.

361  {
362  DDCompactView::graph_type::const_iterator it = idealCV.graph().begin_iter();
363  DDCompactView::graph_type::const_iterator itEnd = idealCV.graph().end_iter();
364  for (; it != itEnd; ++it) {
365  if (isDetector(it->to())) {
366  const DDLogicalPart from = it->from();
367  const DDLogicalPart to = it->to();
368  const int copyNo = it->edge()->copyno_;
369  const DDDivision &division = it->edge()->division();
370  DDTranslation translation(it->edge()->trans());
371  DDRotationMatrix &rotationMatrix = *(new DDRotationMatrix(it->edge()->rot()));
372 
373  const int rpId = getRPIdFromNamespace(from);
374  const int detId = getDetectorId(rpId, copyNo);
375  if (alignments != NULL) {
377  applyCorrection(from, to, correction,
378  translation, rotationMatrix);
379  }
380 
381  const DDRotation rotation = DDanonymousRot(&rotationMatrix);
382  measuredCV->position(to, from, copyNo, translation, rotation, &division);
383  }
384  }
385  }
const RPAlignmentCorrectionsData *const alignments
static bool isDetector(const DDLogicalPart &part)
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
#define NULL
Definition: scimark2.h:8
static int getDetectorId(const int rpId, const int detNo)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDRotation DDanonymousRot(DDRotationMatrix *rot)
Defines a anonymous rotation or rotation-reflection matrix.
Definition: DDRotation.cc:194
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
Alignment correction or result of alignment procedure for a single RP sensor. Within the geometry des...
RPAlignmentCorrectionData GetFullSensorCorrection(unsigned int id, bool useRPErrors=false) const
const_iterator begin_iter() const
Definition: adjgraph.h:190
static int getRPIdFromNamespace(const DDLogicalPart &part)
void applyCorrection(const DDLogicalPart &parent, const DDLogicalPart &child, const RPAlignmentCorrectionData &correction, DDTranslation &translation, DDRotationMatrix &rotation, const bool useMeasuredParent=true)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const_iterator end_iter() const
Definition: adjgraph.h:192
void MeasuredGeometryProducer::positionEverythingButDetectors ( void  )
inlineprivate

Definition at line 334 of file TotemRPGeometryESModule.cc.

References DDanonymousRot(), NULL, and idealTransformation::rotation.

334  {
335  DDCompactView::graph_type::const_iterator it = idealCV.graph().begin_iter();
336  DDCompactView::graph_type::const_iterator itEnd = idealCV.graph().end_iter();
337  for (; it != itEnd; ++it) {
338  if (!isDetector(it->to())) {
339  const DDLogicalPart from = it->from();
340  const DDLogicalPart to = it->to();
341  const int copyNo = it->edge()->copyno_;
342  const DDDivision &division = it->edge()->division();
343  DDTranslation translation(it->edge()->trans());
344  DDRotationMatrix &rotationMatrix = *(new DDRotationMatrix(it->edge()->rot()));
345 
346  if (isRPBox(to)) {
347  const int rpId = getRPIdFromNamespace(to);
348  if (alignments != NULL) {
349  const RPAlignmentCorrectionData correction = alignments->GetRPCorrection(rpId);
350  applyCorrection(from, to, correction,
351  translation, rotationMatrix, false);
352  }
353  }
354 
355  const DDRotation rotation = DDanonymousRot(&rotationMatrix);
356  measuredCV->position(to, from, copyNo, translation, rotation, &division);
357  }
358  }
359  }
const RPAlignmentCorrectionsData *const alignments
static bool isDetector(const DDLogicalPart &part)
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
#define NULL
Definition: scimark2.h:8
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDRotation DDanonymousRot(DDRotationMatrix *rot)
Defines a anonymous rotation or rotation-reflection matrix.
Definition: DDRotation.cc:194
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
Alignment correction or result of alignment procedure for a single RP sensor. Within the geometry des...
const_iterator begin_iter() const
Definition: adjgraph.h:190
static bool isRPBox(const DDLogicalPart &part)
static int getRPIdFromNamespace(const DDLogicalPart &part)
RPAlignmentCorrectionData & GetRPCorrection(unsigned int id)
returns the correction value from the RP map
void applyCorrection(const DDLogicalPart &parent, const DDLogicalPart &child, const RPAlignmentCorrectionData &correction, DDTranslation &translation, DDRotationMatrix &rotation, const bool useMeasuredParent=true)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const_iterator end_iter() const
Definition: adjgraph.h:192
DDCompactView*& MeasuredGeometryProducer::produce ( )
inline

Definition at line 393 of file TotemRPGeometryESModule.cc.

References pyrootRender::root.

Referenced by TotemRPGeometryESModule::ApplyAlignments().

393  {
394  // create DDCompactView for measured geometry
395  // notice that this class is not responsible for deleting this object
397  // CMSSW/DetectorDescription graph interface sucks, so instead of doing a one bfs
398  // we go over the tree twice (this is needed, as final detector postions are
399  // dependent on new positions of RP units).
402  return measuredCV;
403  }
type of data representation of DDCompactView
Definition: DDCompactView.h:77
static void MeasuredGeometryProducer::translRotFromTransform ( DDTranslation translation,
DDRotationMatrix rotation,
const TMatrixD &  transform 
)
inlinestaticprivate

Definition at line 248 of file TotemRPGeometryESModule.cc.

References i, and makeHLTPrescaleTable::values.

249  {
250  // set rotation
251  double values[9];
252  for (int i = 0; i < 9; ++i) {
253  values[i] = transform[i / 3][i % 3];
254  }
255  rotation.SetComponents(values, values + 9);
256  // set translation
257  translation.SetXYZ(transform[0][3], transform[1][3], transform[2][3]);
258  }
int i
Definition: DBlmapReader.cc:9
static void MeasuredGeometryProducer::translRotToTransform ( const DDTranslation translation,
const DDRotationMatrix rotation,
TMatrixD &  transform 
)
inlinestaticprivate

Definition at line 232 of file TotemRPGeometryESModule.cc.

References i, and makeHLTPrescaleTable::values.

233  {
234  // set rotation
235  double values[9];
236  rotation.GetComponents(values);
237  for (int i = 0; i < 9; ++i) {
238  transform[i / 3][i % 3] = values[i];
239  }
240  // set translation
241  transform[0][3] = translation.X();
242  transform[1][3] = translation.Y();
243  transform[2][3] = translation.Z();
244  transform[3][3] = 1.;
245  }
int i
Definition: DBlmapReader.cc:9

Member Data Documentation

const RPAlignmentCorrectionsData* const MeasuredGeometryProducer::alignments
private

Definition at line 170 of file TotemRPGeometryESModule.cc.

bool MeasuredGeometryProducer::evRotationStoreState
staticprivate

Definition at line 180 of file TotemRPGeometryESModule.cc.

const DDCompactView& MeasuredGeometryProducer::idealCV
private

Definition at line 169 of file TotemRPGeometryESModule.cc.

DDCompactView* MeasuredGeometryProducer::measuredCV
private

Definition at line 172 of file TotemRPGeometryESModule.cc.

DDLogicalPart MeasuredGeometryProducer::root
private

Definition at line 171 of file TotemRPGeometryESModule.cc.