CMS 3D CMS Logo

SurveyMisalignmentInput.cc
Go to the documentation of this file.
8 
11 
14 
17 
19 
21  : tTopoToken_(esConsumes()),
22  geomDetToken_(esConsumes()),
23  ptpToken_(esConsumes()),
24  aliToken_(esConsumes()),
25  textFileName(cfg.getParameter<std::string>("textFileName")) {}
26 
28  if (theFirstEvent) {
29  //Retrieve tracker topology from geometry
30  const TrackerTopology* const tTopo = &setup.getData(tTopoToken_);
31  const GeometricDet* geom = &setup.getData(geomDetToken_);
32  const PTrackerParameters& ptp = setup.getData(ptpToken_);
34 
36 
37  edm::LogInfo("SurveyMisalignmentInput") << "Starting!";
38  // Retrieve alignment[Error]s from DBase
39  alignments = setup.getHandle(aliToken_);
40 
41  //Get map from textreader
42  SurveyInputTextReader dataReader;
43  dataReader.readFile(textFileName);
44  uIdMap = dataReader.UniqueIdMap();
45 
47 
48  theFirstEvent = false;
49  }
50 }
51 
53  const align::Alignables& comp = ali->components();
54  unsigned int nComp = comp.size();
55  for (unsigned int i = 0; i < nComp; ++i)
57 
58  SurveyInputTextReader::MapType::const_iterator it = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
59 
61 
62  if (it != uIdMap.end()) {
63  //survey error values
64  const align::Scalars& parameters = (it)->second;
65  //sets the errors for the hierarchy level
66  double* errorData = error.Array();
67  for (unsigned int i = 0; i < 21; ++i) {
68  errorData[i] = parameters[i + 6];
69  }
70 
71  //because record only needs global value of modules
73  // fill survey values
74  ali->setSurvey(new SurveyDet(getAlignableSurface(ali->id()), error));
75  } else {
76  ali->setSurvey(new SurveyDet(ali->surface(), error));
77  }
78  } else {
79  //fill
80  error = ROOT::Math::SMatrixIdentity();
81  ali->setSurvey(new SurveyDet(ali->surface(), error * (1e-6)));
82  }
83  //std::cout << "UniqueId: " << id.first << ", " << id.second << std::endl;
84  //std::cout << error << std::endl;
85 }
86 
88  std::vector<AlignTransform>::const_iterator it;
89 
90  for (it = alignments->m_align.begin(); it != alignments->m_align.end(); ++it) {
91  if (id == (*it).rawId()) {
92  align::PositionType position((*it).translation().x(), (*it).translation().y(), (*it).translation().z());
93  CLHEP::HepRotation rot((*it).rotation());
95  rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz());
97  }
98  }
99 
100  return AlignableSurface();
101 }
102 
103 // Plug in to framework
104 
106 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void readFile(const std::string &textFileName)
Read given text file.
SurveyMisalignmentInput(const edm::ParameterSet &)
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
uint32_t ID
Definition: Definitions.h:24
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
SurveyInputTextReader::MapType uIdMap
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
static void addComponent(Alignable *)
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
void addSurveyInfo(Alignable *)
Add survey info to an alignable.
U second(std::pair< T, U > const &p)
edm::ESHandle< Alignments > alignments
std::vector< Scalar > Scalars
Definition: Utilities.h:26
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static Alignable * detector()
Get alignable detector as read from input.
virtual const Alignables & components() const =0
Return vector of all direct components.
Log< level::Info, false > LogInfo
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:266
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
AlignableSurface getAlignableSurface(align::ID)
Get alignable surface from misalignments.db.
static int position[264][3]
Definition: ReadPGInfo.cc:289
const edm::ESGetToken< Alignments, TrackerAlignmentRcd > aliToken_
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:37
void analyze(const edm::Event &, const edm::EventSetup &) override
Read ideal tracker geometry from DB.
const MapType & UniqueIdMap() const