CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignableDataIORoot.cc
Go to the documentation of this file.
1 #include "TTree.h"
2 
5 
7 
8 // ----------------------------------------------------------------------------
9 // constructor
12 {
13  if (thePosType == Abs) {
14  treename = "AlignablesAbsPos";
15  treetxt = "Alignables abs.Pos";
16  }
17  else if (thePosType == Org) {
18  treename = "AlignablesOrgPos";
19  treetxt = "Alignables org.Pos";
20  }
21  else if (thePosType == Rel) {
22  treename = "AlignablesRelPos";
23  treetxt = "Alignables rel.Pos";
24  }
25 }
26 
27 // ----------------------------------------------------------------------------
28 // create root tree branches (for writing)
29 
31 {
32  tree->Branch("Id", &Id, "Id/i");
33  tree->Branch("ObjId", &ObjId, "ObjId/I");
34  tree->Branch("Pos", &Pos, "Pos[3]/D");
35  tree->Branch("Rot", &Rot, "Rot[9]/D");
36 }
37 
38 // ----------------------------------------------------------------------------
39 // set root tree branch addresses (for reading)
40 
42 {
43  tree->SetBranchAddress("Id", &Id);
44  tree->SetBranchAddress("ObjId", &ObjId);
45  tree->SetBranchAddress("Pos", &Pos);
46  tree->SetBranchAddress("Rot", &Rot);
47 }
48 
49 // ----------------------------------------------------------------------------
50 // find root tree entry based on IDs
51 
53 {
54  if (newopen) { // we're here first time
55  edm::LogInfo("Alignment") << "@SUB=AlignableDataIORoot::findEntry"
56  << "Filling map ...";
57  treemap.erase(treemap.begin(),treemap.end());
58  for (int ev = 0;ev<tree->GetEntries();ev++) {
59  tree->GetEntry(ev);
60  treemap[ std::make_pair(Id,ObjId) ] = ev;
61  }
62  newopen=false;
63  }
64 
65  // now we have filled the map
66  treemaptype::iterator imap = treemap.find( std::make_pair(id,comp) );
67  int result=-1;
68  if (imap != treemap.end()) result=(*imap).second;
69  return result;
70 
71 }
72 
73 // ----------------------------------------------------------------------------
75 {
76  align::GlobalPoint pos = ad.pos();
77  align::RotationType rot = ad.rot();
78  Id = ad.id();
79  ObjId = ad.objId();
80  Pos[0]=pos.x(); Pos[1]=pos.y(); Pos[2]=pos.z();
81  Rot[0]=rot.xx(); Rot[1]=rot.xy(); Rot[2]=rot.xz();
82  Rot[3]=rot.yx(); Rot[4]=rot.yy(); Rot[5]=rot.yz();
83  Rot[6]=rot.zx(); Rot[7]=rot.zy(); Rot[8]=rot.zz();
84  tree->Fill();
85  return 0;
86 }
87 
88 // ----------------------------------------------------------------------------
90 {
92  align::RotationType rot = ad.rot();
93  Id = ad.id();
94  ObjId = ad.objId();
95  Pos[0]=pos.x(); Pos[1]=pos.y(); Pos[2]=pos.z();
96  Rot[0]=rot.xx(); Rot[1]=rot.xy(); Rot[2]=rot.xz();
97  Rot[3]=rot.yx(); Rot[4]=rot.yy(); Rot[5]=rot.yz();
98  Rot[6]=rot.zx(); Rot[7]=rot.zy(); Rot[8]=rot.zz();
99  tree->Fill();
100  return 0;
101 }
102 
103 // ----------------------------------------------------------------------------
105 {
108 
109  align::StructureType typeId = ali->alignableObjectId();
110  align::ID id = ali->id();
111  int entry = findEntry(id,typeId);
112  if(entry!=-1) {
113  tree->GetEntry(entry);
114  align::GlobalPoint pos2(Pos[0],Pos[1],Pos[2]);
115  align::RotationType rot2(Rot[0],Rot[1],Rot[2],
116  Rot[3],Rot[4],Rot[5],
117  Rot[6],Rot[7],Rot[8]);
118  pos=pos2;
119  rot=rot2;
120  ierr=0;
121  }
122  else ierr=-1;
123 
124  return AlignableAbsData(pos,rot,id,typeId);
125 }
126 
127 // ----------------------------------------------------------------------------
128 
130 {
133 
134  align::StructureType typeId = ali->alignableObjectId();
135  align::ID id = ali->id();
136  int entry = findEntry(id,typeId);
137  if(entry!=-1) {
138  tree->GetEntry(entry);
139  align::GlobalVector pos2(Pos[0],Pos[1],Pos[2]);
140  align::RotationType rot2(Rot[0],Rot[1],Rot[2],
141  Rot[3],Rot[4],Rot[5],
142  Rot[6],Rot[7],Rot[8]);
143  pos=pos2;
144  rot=rot2;
145  ierr=0;
146  }
147  else ierr=-1;
148 
149  return AlignableRelData(pos,rot,id,typeId);
150 }
T xx() const
align::StructureType objId() const
Definition: AlignableData.h:26
AlignableDataIORoot(PosType p)
constructor
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
int writeRelRaw(const AlignableRelData &ad)
write relative positions
void setBranchAddresses(void)
set root branches
uint32_t ID
Definition: Definitions.h:26
AlignableAbsData readAbsRaw(Alignable *ali, int &ierr)
read absolute positions
T y() const
Definition: PV3DBase.h:57
T yx() const
int writeAbsRaw(const AlignableAbsData &ad)
write absolute positions
void createBranches(void)
create root branches
AlignableData< align::GlobalVector > AlignableRelData
relative position/rotation
Definition: AlignableData.h:43
T zx() const
T xy() const
T zz() const
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
int findEntry(align::ID, align::StructureType)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
T zy() const
T yy() const
align::StructureType ObjId
root tree contents
AlignableData< align::GlobalPoint > AlignableAbsData
Absolute position/rotation.
Definition: AlignableData.h:41
T xz() const
AlignableRelData readRelRaw(Alignable *ali, int &ierr)
read relative positions
const T & pos() const
accessors
Definition: AlignableData.h:24
T x() const
Definition: PV3DBase.h:56
T yz() const
const align::RotationType & rot() const
Definition: AlignableData.h:25
align::ID id() const
Definition: AlignableData.h:27