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

enum  { kMaxNumPar = 20 }
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

Float_t deformationValues_ [kMaxNumPar]
align::ID Id
bool newopen
UInt_t numDeformationValues_
align::StructureType ObjId
 root tree contents
Double_t Pos [3]
Double_t 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 54 of file AlignableDataIORoot.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
kMaxNumPar 

Definition at line 50 of file AlignableDataIORoot.h.

{kMaxNumPar = 20}; // slighly above 'two bowed surfaces' limit

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 deformationValues_, Id, numDeformationValues_, 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");

  tree->Branch("NumDeform",   &numDeformationValues_, "NumDeform/i");
  tree->Branch("DeformValues", deformationValues_,    "DeformValues[NumDeform]/F");
}
int AlignableDataIORoot::findEntry ( align::ID  id,
align::StructureType  comp 
) [private]

Definition at line 58 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 124 of file AlignableDataIORoot.cc.

References Alignable::alignableObjectId(), findEntry(), Alignable::id(), pos, Pos, makeMuonMisalignmentScenario::rot, 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;

    // FIXME: Should add reading of deformation values?
    //        Then call Alignable::setSurfaceDeformation(..) ...
    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 152 of file AlignableDataIORoot.cc.

References Alignable::alignableObjectId(), findEntry(), Alignable::id(), pos, Pos, makeMuonMisalignmentScenario::rot, 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;

    // FIXME: Should add reading of deformation values?
    //        Then call Alignable::setSurfaceDeformation(..) ...
    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 44 of file AlignableDataIORoot.cc.

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

{
  tree->SetBranchAddress("Id",    &Id);
  tree->SetBranchAddress("ObjId", &ObjId);
  tree->SetBranchAddress("Pos",   &Pos);
  tree->SetBranchAddress("Rot",   &Rot);

  tree->SetBranchAddress("NumDeform",   &numDeformationValues_);
  tree->SetBranchAddress("DeformValues", deformationValues_);
}
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

Float_t AlignableDataIORoot::deformationValues_[kMaxNumPar] [private]

Definition at line 51 of file AlignableDataIORoot.h.

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

Definition at line 53 of file AlignableDataIORoot.h.

Referenced by findEntry(), and open().

Definition at line 49 of file AlignableDataIORoot.h.

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

root tree contents

Definition at line 44 of file AlignableDataIORoot.h.

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

Double_t AlignableDataIORoot::Pos[3] [private]
Double_t AlignableDataIORoot::Rot[9] [private]

Definition at line 55 of file AlignableDataIORoot.h.

Referenced by findEntry().