CMS 3D CMS Logo

AlignableDataIO.cc
Go to the documentation of this file.
5 
6 // this class's header
8 
9 // ----------------------------------------------------------------------------
10 AlignableAbsData AlignableDataIO::readAbsPos(Alignable* ali, int& ierr) { return readAbsRaw(ali, ierr); }
11 
12 // ----------------------------------------------------------------------------
13 AlignableAbsData AlignableDataIO::readOrgPos(Alignable* ali, int& ierr) { return readAbsRaw(ali, ierr); }
14 
15 // ----------------------------------------------------------------------------
16 AlignableRelData AlignableDataIO::readRelPos(Alignable* ali, int& ierr) { return readRelRaw(ali, ierr); }
17 
18 // ----------------------------------------------------------------------------
19 int AlignableDataIO::writeAbsPos(Alignable* ali, bool validCheck) {
20  if (!(validCheck) || ali->alignmentParameters()->isValid()) {
21  // position in global frame
23  // global rotation
25  // if a unit: store surface deformation (little kind of hack)...
26  std::vector<double> pars;
27  if (ali->alignableObjectId() == align::AlignableDetUnit) { // only detunits have them
28  std::vector<std::pair<int, SurfaceDeformation*> > result;
29  if (1 == ali->surfaceDeformationIdPairs(result)) { // might not have any...
30  pars = result[0].second->parameters();
31  }
32  }
33 
34  // write
35  return writeAbsRaw(AlignableAbsData(pos, rot, ali->id(), ali->alignableObjectId(), pars));
36  }
37 
38  return 1;
39 }
40 
41 // ----------------------------------------------------------------------------
42 int AlignableDataIO::writeRelPos(Alignable* ali, bool validCheck) {
43  if (!(validCheck) || ali->alignmentParameters()->isValid()) {
44  // rel. shift in global frame
45  const align::GlobalVector& pos = ali->displacement();
46  // rel. rotation in global frame
48  // FIXME: should add something to store changes of surface deformations...
49  std::vector<double> pars;
50  // write
51  return writeRelRaw(AlignableRelData(pos, rot, ali->id(), ali->alignableObjectId(), pars));
52  }
53 
54  return 1;
55 }
56 
57 // ----------------------------------------------------------------------------
58 int AlignableDataIO::writeOrgPos(Alignable* ali, bool validCheck) {
59  if (!(validCheck) || ali->alignmentParameters()->isValid()) {
60  // orig position
62  // orig rotation
64  // FIXME: should add something to store changes of surface deformations...
65  std::vector<double> pars;
66  // write
67  return writeAbsRaw(AlignableAbsData(pos, rot, ali->id(), ali->alignableObjectId(), pars));
68  }
69 
70  return 1;
71 }
72 
73 // ----------------------------------------------------------------------------
74 int AlignableDataIO::writeAbsPos(const align::Alignables& alivec, bool validCheck) {
75  int icount = 0;
76  for (align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
77  int iret = writeAbsPos(*it, validCheck);
78  if (iret == 0)
79  icount++;
80  }
81  LogDebug("WriteAbsPos") << "all,written: " << alivec.size() << "," << icount;
82 
83  return 0;
84 }
85 
86 // ----------------------------------------------------------------------------
88  AlignablePositions retvec;
89  int ierr2 = 0;
90  ierr = 0;
91  for (align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
92  AlignableAbsData ad = readAbsPos(*it, ierr2);
93  if (ierr2 == 0)
94  retvec.push_back(ad);
95  }
96 
97  LogDebug("ReadAbsPos") << "all,written: " << alivec.size() << "," << retvec.size();
98 
99  return retvec;
100 }
101 
102 // ----------------------------------------------------------------------------
103 int AlignableDataIO::writeOrgPos(const align::Alignables& alivec, bool validCheck) {
104  int icount = 0;
105  for (align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
106  int iret = writeOrgPos(*it, validCheck);
107  if (iret == 0)
108  icount++;
109  }
110 
111  LogDebug("WriteOrgPos") << "all,written: " << alivec.size() << "," << icount;
112  return 0;
113 }
114 
115 // ----------------------------------------------------------------------------
117  AlignablePositions retvec;
118  int ierr2 = 0;
119  ierr = 0;
120  for (align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
121  AlignableAbsData ad = readOrgPos(*it, ierr2);
122  if (ierr2 == 0)
123  retvec.push_back(ad);
124  }
125 
126  LogDebug("ReadOrgPos") << "all,read: " << alivec.size() << ", " << retvec.size();
127 
128  return retvec;
129 }
130 
131 // ----------------------------------------------------------------------------
132 int AlignableDataIO::writeRelPos(const align::Alignables& alivec, bool validCheck) {
133  int icount = 0;
134  for (align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
135  int iret = writeRelPos(*it, validCheck);
136  if (iret == 0)
137  icount++;
138  }
139  LogDebug("WriteRelPos") << "all,written: " << alivec.size() << ", " << icount;
140  return 0;
141 }
142 
143 // ----------------------------------------------------------------------------
145  AlignableShifts retvec;
146  int ierr2 = 0;
147  ierr = 0;
148  for (align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
149  AlignableRelData ad = readRelPos(*it, ierr2);
150  if (ierr2 == 0)
151  retvec.push_back(ad);
152  }
153  LogDebug("ReadRelPos") << "all,read: " << alivec.size() << ", " << retvec.size();
154 
155  return retvec;
156 }
virtual int writeAbsRaw(const AlignableAbsData &ad)=0
Write absolute positions.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
AlignableAbsData readAbsPos(Alignable *ali, int &ierr)
Read absolute positions of one Alignable.
AlignableAbsData readOrgPos(Alignable *ali, int &ierr)
Read original positions of one Alignable.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
int writeAbsPos(Alignable *ali, bool validCheck)
Write absolute positions of one Alignable.
AlignableData< align::GlobalVector > AlignableRelData
relative position/rotation
Definition: AlignableData.h:45
std::vector< AlignableRelData > AlignableShifts
Definition: AlignableData.h:48
TkRotation transposed() const
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
virtual AlignableAbsData readAbsRaw(Alignable *ali, int &ierr)=0
Read absolute positions.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
int writeOrgPos(Alignable *ali, bool validCheck)
Write original positions of one Alignable.
int writeRelPos(Alignable *ali, bool validCheck)
Write relative positions of one Alignable.
bool isValid(void) const
Get validity flag.
virtual AlignableRelData readRelRaw(Alignable *ali, int &ierr)=0
Read relative positions.
AlignableRelData readRelPos(Alignable *ali, int &ierr)
Read relative positions of one Alignable.
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
const PositionType & position() const
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:141
AlignableData< align::GlobalPoint > AlignableAbsData
Absolute position/rotation.
Definition: AlignableData.h:43
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation *> > &) const =0
virtual int writeRelRaw(const AlignableRelData &ad)=0
Write relative positions.
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:138
const RotationType & rotation() const
std::vector< AlignableAbsData > AlignablePositions
Definition: AlignableData.h:47
#define LogDebug(id)
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:144