CMS 3D CMS Logo

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

List of all members.

Private Types

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

Private Member Functions

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

Private Attributes

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

Friends

class AlignmentIORoot

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.

                                                  : 
  AlignableDataIO(p)
{
  if (thePosType == Abs) {
    treename = "AlignablesAbsPos";
    treetxt = "Alignables abs.Pos";
  }
  else if (thePosType == Org) {
    treename = "AlignablesOrgPos";
    treetxt = "Alignables org.Pos";
  }
  else if (thePosType == Rel) {
    treename = "AlignablesRelPos";
    treetxt = "Alignables rel.Pos";
  }
}

Member Function Documentation

int AlignableDataIORoot::close ( void  ) [inline, private, virtual]
void AlignableDataIORoot::createBranches ( void  ) [private, virtual]

create root branches

Implements AlignmentIORootBase.

Definition at line 30 of file AlignableDataIORoot.cc.

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

{
  tree->Branch("Id",    &Id,    "Id/i");
  tree->Branch("ObjId", &ObjId, "ObjId/I");
  tree->Branch("Pos",   &Pos,   "Pos[3]/D");
  tree->Branch("Rot",   &Rot,   "Rot[9]/D");
}
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().

{
  if (newopen) { // we're here first time
    edm::LogInfo("Alignment") << "@SUB=AlignableDataIORoot::findEntry"
                              << "Filling map ...";
    treemap.erase(treemap.begin(),treemap.end());
    for (int ev = 0;ev<tree->GetEntries();ev++) {
      tree->GetEntry(ev); 
      treemap[ std::make_pair(Id,ObjId) ] = ev;
    }
    newopen=false;
  }
  
  // now we have filled the map
  treemaptype::iterator imap = treemap.find( std::make_pair(id,comp) );
  int result=-1;
  if (imap != treemap.end()) result=(*imap).second;
  return result;

}
int AlignableDataIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
) [inline, private, virtual]
AlignableAbsData AlignableDataIORoot::readAbsRaw ( Alignable ali,
int &  ierr 
) [private, virtual]

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.

{
  align::GlobalPoint pos;
  align::RotationType rot;

  align::StructureType typeId = ali->alignableObjectId();
  align::ID id = ali->id();
  int entry = findEntry(id,typeId);
  if(entry!=-1) {
    tree->GetEntry(entry);
    align::GlobalPoint pos2(Pos[0],Pos[1],Pos[2]);
    align::RotationType rot2(Rot[0],Rot[1],Rot[2],
                             Rot[3],Rot[4],Rot[5],
                             Rot[6],Rot[7],Rot[8]);
    pos=pos2;
    rot=rot2;
    ierr=0;
  }
  else ierr=-1;

  return AlignableAbsData(pos,rot,id,typeId);
}
AlignableRelData AlignableDataIORoot::readRelRaw ( Alignable ali,
int &  ierr 
) [private, virtual]

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.

{
  align::GlobalVector pos;
  align::RotationType rot;

  align::StructureType typeId = ali->alignableObjectId();
  align::ID id = ali->id();
  int entry = findEntry(id,typeId);
  if(entry!=-1) {
    tree->GetEntry(entry);
    align::GlobalVector pos2(Pos[0],Pos[1],Pos[2]);
    align::RotationType rot2(Rot[0],Rot[1],Rot[2],
                             Rot[3],Rot[4],Rot[5],
                             Rot[6],Rot[7],Rot[8]);
    pos=pos2;
    rot=rot2;
    ierr=0;
  }
  else ierr=-1;

  return AlignableRelData(pos,rot,id,typeId);
}
void AlignableDataIORoot::setBranchAddresses ( void  ) [private, virtual]

set root branches

Implements AlignmentIORootBase.

Definition at line 41 of file AlignableDataIORoot.cc.

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

{
  tree->SetBranchAddress("Id",    &Id);
  tree->SetBranchAddress("ObjId", &ObjId);
  tree->SetBranchAddress("Pos",   &Pos);
  tree->SetBranchAddress("Rot",   &Rot);
}
int AlignableDataIORoot::writeAbsRaw ( const AlignableAbsData ad) [private, virtual]
int AlignableDataIORoot::writeRelRaw ( const AlignableRelData ad) [private, virtual]

Friends And Related Function Documentation

friend class AlignmentIORoot [friend]

Definition at line 15 of file AlignableDataIORoot.h.


Member Data Documentation

Definition at line 50 of file AlignableDataIORoot.h.

Referenced by findEntry(), and open().

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]

Definition at line 52 of file AlignableDataIORoot.h.

Referenced by findEntry().