CMS 3D CMS Logo

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

concrete class for ROOT based IO of Alignable positions More...

#include <AlignableDataIORoot.h>

Inheritance diagram for AlignableDataIORoot:
AlignmentIORootBase AlignableDataIO

Private Types

typedef std::map< std::pair
< align::ID,
align::StructureType >, int > 
treemaptype
 

Private Member Functions

 AlignableDataIORoot (PosType p)
 constructor More...
 
int close (void)
 close IO More...
 
void createBranches (void)
 create root branches More...
 
int findEntry (align::ID, align::StructureType)
 
int open (const char *filename, int iteration, bool writemode)
 open IO More...
 
AlignableAbsData readAbsRaw (Alignable *ali, int &ierr)
 read absolute positions More...
 
AlignableRelData readRelRaw (Alignable *ali, int &ierr)
 read relative positions More...
 
void setBranchAddresses (void)
 set root branches More...
 
int writeAbsRaw (const AlignableAbsData &ad)
 write absolute positions More...
 
int writeRelRaw (const AlignableRelData &ad)
 write relative positions More...
 

Private Attributes

align::ID Id
 
bool newopen
 
align::StructureType ObjId
 root tree contents More...
 
double Pos [3]
 
double Rot [9]
 
treemaptype treemap
 

Friends

class AlignmentIORoot
 

Additional Inherited Members

- Protected Types inherited from AlignableDataIO
enum  PosType { Abs, Org, Rel }
 
- Protected Member Functions inherited from AlignmentIORootBase
 AlignmentIORootBase ()
 constructor More...
 
int closeRoot (void)
 close IO More...
 
int openRoot (const char *filename, int iteration, bool writemode)
 open IO More...
 
int testFile (const char *filename, const TString &tname)
 test if file is existing and if so, what the highest iteration is More...
 
TString treeName (int iter, const TString &tname)
 compose tree name More...
 
virtual ~AlignmentIORootBase ()
 destructor More...
 
- Protected Member Functions inherited from AlignableDataIO
 AlignableDataIO (PosType p)
 Constructor. More...
 
AlignableAbsData readAbsPos (Alignable *ali, int &ierr)
 Read absolute positions of one Alignable. More...
 
AlignablePositions readAbsPos (const align::Alignables &alivec, int &ierr)
 Read absolute positions of many Alignables. More...
 
AlignableAbsData readOrgPos (Alignable *ali, int &ierr)
 Read original positions of one Alignable. More...
 
AlignablePositions readOrgPos (const align::Alignables &alivec, int &ierr)
 Read original positions of many Alignables. More...
 
AlignableRelData readRelPos (Alignable *ali, int &ierr)
 Read relative positions of one Alignable. More...
 
AlignableShifts readRelPos (const align::Alignables &alivec, int &ierr)
 Read relative positions of many Alignables. More...
 
int writeAbsPos (Alignable *ali, bool validCheck)
 Write absolute positions of one Alignable. More...
 
int writeAbsPos (const align::Alignables &alivec, bool validCheck)
 Write absolute positions of many Alignables. More...
 
int writeOrgPos (Alignable *ali, bool validCheck)
 Write original positions of one Alignable. More...
 
int writeOrgPos (const align::Alignables &alivec, bool validCheck)
 Write original positions of many Alignables. More...
 
int writeRelPos (Alignable *ali, bool validCheck)
 Write relative positions of one Alignable. More...
 
int writeRelPos (const align::Alignables &alivec, bool validCheck)
 Write relative positions of many Alignables. More...
 
virtual ~AlignableDataIO ()
 Destructor. More...
 
- Protected Attributes inherited from AlignmentIORootBase
bool bWrite
 
TTree * tree
 
TString treename
 
TString treetxt
 
- Protected Attributes inherited from AlignableDataIO
PosType thePosType
 
- Static Protected Attributes inherited from AlignmentIORootBase
static const int itermax = 1000
 
static const int nParMax = 20
 

Detailed Description

concrete class for ROOT based IO of Alignable positions

Definition at line 12 of file AlignableDataIORoot.h.

Member Typedef Documentation

typedef std::map< std::pair<align::ID, align::StructureType>, int > AlignableDataIORoot::treemaptype
private

Definition at line 51 of file AlignableDataIORoot.h.

Constructor & Destructor Documentation

AlignableDataIORoot::AlignableDataIORoot ( PosType  p)
private

constructor

Definition at line 10 of file AlignableDataIORoot.cc.

References AlignableDataIO::Abs, AlignableDataIO::Org, AlignableDataIO::Rel, AlignableDataIO::thePosType, AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.

10  :
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 }
AlignableDataIO(PosType p)
Constructor.

Member Function Documentation

int AlignableDataIORoot::close ( void  )
inlineprivatevirtual
void AlignableDataIORoot::createBranches ( void  )
privatevirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 30 of file AlignableDataIORoot.cc.

References Id, ObjId, Pos, Rot, and AlignmentIORootBase::tree.

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 }
align::StructureType ObjId
root tree contents
int AlignableDataIORoot::findEntry ( align::ID  id,
align::StructureType  comp 
)
private

Definition at line 52 of file AlignableDataIORoot.cc.

References Id, newopen, ObjId, query::result, AlignmentIORootBase::tree, and treemap.

Referenced by readAbsRaw(), and readRelRaw().

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 }
tuple result
Definition: query.py:137
align::StructureType ObjId
root tree contents
int AlignableDataIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
)
inlineprivatevirtual
AlignableAbsData AlignableDataIORoot::readAbsRaw ( Alignable ali,
int &  ierr 
)
privatevirtual

read absolute positions

Implements AlignableDataIO.

Definition at line 104 of file AlignableDataIORoot.cc.

References Alignable::alignableObjectId(), findEntry(), Alignable::id(), pos, Pos, Rot, and AlignmentIORootBase::tree.

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 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
uint32_t ID
Definition: Definitions.h:26
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
int findEntry(align::ID, align::StructureType)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignableData< align::GlobalPoint > AlignableAbsData
Absolute position/rotation.
Definition: AlignableData.h:41
AlignableRelData AlignableDataIORoot::readRelRaw ( Alignable ali,
int &  ierr 
)
privatevirtual

read relative positions

Implements AlignableDataIO.

Definition at line 129 of file AlignableDataIORoot.cc.

References Alignable::alignableObjectId(), findEntry(), Alignable::id(), pos, Pos, Rot, and AlignmentIORootBase::tree.

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 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
uint32_t ID
Definition: Definitions.h:26
AlignableData< align::GlobalVector > AlignableRelData
relative position/rotation
Definition: AlignableData.h:43
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
int findEntry(align::ID, align::StructureType)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
void AlignableDataIORoot::setBranchAddresses ( void  )
privatevirtual

set root branches

Implements AlignmentIORootBase.

Definition at line 41 of file AlignableDataIORoot.cc.

References Id, ObjId, Pos, Rot, and AlignmentIORootBase::tree.

42 {
43  tree->SetBranchAddress("Id", &Id);
44  tree->SetBranchAddress("ObjId", &ObjId);
45  tree->SetBranchAddress("Pos", &Pos);
46  tree->SetBranchAddress("Rot", &Rot);
47 }
align::StructureType ObjId
root tree contents
int AlignableDataIORoot::writeAbsRaw ( const AlignableAbsData ad)
privatevirtual

write absolute positions

Implements AlignableDataIO.

Definition at line 74 of file AlignableDataIORoot.cc.

References AlignableData< T >::id(), Id, AlignableData< T >::objId(), ObjId, pos, AlignableData< T >::pos(), Pos, AlignableData< T >::rot(), Rot, AlignmentIORootBase::tree, PV3DBase< T, PVType, FrameType >::x(), TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), PV3DBase< T, PVType, FrameType >::y(), TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), PV3DBase< T, PVType, FrameType >::z(), TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

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 }
T xx() const
align::StructureType objId() const
Definition: AlignableData.h:26
T y() const
Definition: PV3DBase.h:57
T yx() const
T zx() const
T xy() const
T zz() const
T z() const
Definition: PV3DBase.h:58
T zy() const
T yy() const
align::StructureType ObjId
root tree contents
T xz() const
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
int AlignableDataIORoot::writeRelRaw ( const AlignableRelData ad)
privatevirtual

write relative positions

Implements AlignableDataIO.

Definition at line 89 of file AlignableDataIORoot.cc.

References AlignableData< T >::id(), Id, AlignableData< T >::objId(), ObjId, pos, AlignableData< T >::pos(), Pos, AlignableData< T >::rot(), Rot, AlignmentIORootBase::tree, PV3DBase< T, PVType, FrameType >::x(), TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), PV3DBase< T, PVType, FrameType >::y(), TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), PV3DBase< T, PVType, FrameType >::z(), TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

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 }
T xx() const
align::StructureType objId() const
Definition: AlignableData.h:26
T y() const
Definition: PV3DBase.h:57
T yx() const
T zx() const
T xy() const
T zz() const
T z() const
Definition: PV3DBase.h:58
T zy() const
T yy() const
align::StructureType ObjId
root tree contents
T xz() const
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

Friends And Related Function Documentation

friend class AlignmentIORoot
friend

Definition at line 15 of file AlignableDataIORoot.h.

Member Data Documentation

align::ID AlignableDataIORoot::Id
private
bool AlignableDataIORoot::newopen
private

Definition at line 50 of file AlignableDataIORoot.h.

Referenced by findEntry(), and open().

align::StructureType AlignableDataIORoot::ObjId
private

root tree contents

Definition at line 44 of file AlignableDataIORoot.h.

Referenced by createBranches(), findEntry(), setBranchAddresses(), writeAbsRaw(), and writeRelRaw().

double AlignableDataIORoot::Pos[3]
private
double AlignableDataIORoot::Rot[9]
private
treemaptype AlignableDataIORoot::treemap
private

Definition at line 52 of file AlignableDataIORoot.h.

Referenced by findEntry().