CMS 3D CMS Logo

AlignmentParametersIORoot Class Reference

Concrete class for ROOT-based I/O of AlignmentParameters. More...

#include <Alignment/CommonAlignmentAlgorithm/interface/AlignmentParametersIORoot.h>

Inheritance diagram for AlignmentParametersIORoot:

AlignmentIORootBase AlignmentParametersIO

List of all members.

Private Member Functions

 AlignmentParametersIORoot ()
 Constructor.
int close (void)
 Close IO.
void createBranches (void)
 Create all branches and give names.
int findEntry (align::ID, align::StructureType)
 Find entry number corresponding to ID and structure type.
int open (const char *filename, int iteration, bool writemode)
 Open IO.
AlignmentParametersreadOne (Alignable *ali, int &ierr)
 Read AlignmentParameters of one Alignable.
void setBranchAddresses (void)
 Set branch adresses.
int writeOne (Alignable *ali)
 Write AlignmentParameters of one Alignable.

Private Attributes

double theCov [nParMax *(nParMax+1)/2]
int theCovarRang
int theCovRang
int theHieraLevel
align::ID theId
align::StructureType theObjId
double thePar [nParMax]

Friends

class AlignmentIORoot


Detailed Description

Concrete class for ROOT-based I/O of AlignmentParameters.

Date
2007/10/08 14:38:15
Revision
1.5
(last update by
Author
cklae
)

Definition at line 16 of file AlignmentParametersIORoot.h.


Constructor & Destructor Documentation

AlignmentParametersIORoot::AlignmentParametersIORoot (  )  [private]

Constructor.

Definition at line 12 of file AlignmentParametersIORoot.cc.

References AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.

00013 {
00014   treename = "AlignmentParameters";
00015   treetxt = "Alignment Parameters";
00016 }


Member Function Documentation

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

Close IO.

Implements AlignmentParametersIO.

Definition at line 36 of file AlignmentParametersIORoot.h.

References AlignmentIORootBase::closeRoot().

Referenced by AlignmentIORoot::readAlignmentParameters(), AlignmentIORoot::writeAlignmentParameters(), and AlignmentIORoot::writeOrigRigidBodyAlignmentParameters().

00036 {return closeRoot();};

void AlignmentParametersIORoot::createBranches ( void   )  [private, virtual]

Create all branches and give names.

Implements AlignmentIORootBase.

Definition at line 20 of file AlignmentParametersIORoot.cc.

References theCov, theCovarRang, theCovRang, theHieraLevel, theId, theObjId, thePar, and AlignmentIORootBase::tree.

00021 {
00022   tree->Branch("parSize",   &theCovRang,   "CovRang/I");
00023   tree->Branch("Id",        &theId,        "Id/i");
00024   tree->Branch("Par",       &thePar,       "Par[CovRang]/D");
00025   tree->Branch("covarSize", &theCovarRang, "CovarRang/I");
00026   tree->Branch("Cov",       &theCov,       "Cov[CovarRang]/D");
00027   tree->Branch("ObjId",     &theObjId,     "ObjId/I");
00028   tree->Branch("HieraLevel",&theHieraLevel,"HieraLevel/I");
00029 }

int AlignmentParametersIORoot::findEntry ( align::ID  id,
align::StructureType  comp 
) [private]

Find entry number corresponding to ID and structure type.

Returns -1 on failure.

Definition at line 46 of file AlignmentParametersIORoot.cc.

References theId, theObjId, and AlignmentIORootBase::tree.

Referenced by readOne().

00047 {
00048   double noAliPar = tree->GetEntries();
00049   for (int ev = 0;ev<noAliPar;ev++) {
00050     tree->GetEntry(ev); 
00051     if ( theId==id && theObjId==comp ) return (ev);
00052   }
00053   return -1;
00054 }

int AlignmentParametersIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
) [inline, private, virtual]

Open IO.

Implements AlignmentParametersIO.

Definition at line 32 of file AlignmentParametersIORoot.h.

References AlignmentIORootBase::openRoot().

Referenced by AlignmentIORoot::readAlignmentParameters(), AlignmentIORoot::writeAlignmentParameters(), and AlignmentIORoot::writeOrigRigidBodyAlignmentParameters().

00033     {return openRoot(filename,iteration,writemode);};

AlignmentParameters * AlignmentParametersIORoot::readOne ( Alignable ali,
int ierr 
) [private, virtual]

Read AlignmentParameters of one Alignable.

Implements AlignmentParametersIO.

Definition at line 83 of file AlignmentParametersIORoot.cc.

References Alignable::alignableObjectId(), Alignable::alignmentParameters(), parsecf::pyparsing::col(), count, findEntry(), Alignable::id(), AlignmentIORootBase::nParMax, row, EgammaValidation_Zee_cff::sel, AlignmentParameters::selector(), AlignmentParameters::setValid(), theCov, theCovRang, thePar, and AlignmentIORootBase::tree.

00084 {
00085   
00086   AlignmentParameters* alipar = 0;
00087   AlgebraicVector par(nParMax,0);
00088   AlgebraicSymMatrix cov(nParMax,0);
00089   const std::vector<bool> &sel = ali->alignmentParameters()->selector();
00090  
00091   int entry = findEntry( ali->id(), ali->alignableObjectId() );
00092   if( entry != -1 ) 
00093         {
00094           tree->GetEntry(entry);
00095           int covsize = theCovRang;
00096           int count=0;
00097           for(int row=0;row<covsize;row++) 
00098                 {
00099                   par[row]=thePar[row];
00100                   for(int col=0; col < covsize;col++) {
00101                         if(row-1<col) {cov[row][col]=theCov[count];count++;}
00102                   }
00103                 } 
00104           // FIXME: In future should check which kind of parameters to construct...
00105           alipar = new RigidBodyAlignmentParameters(ali,par,cov,sel);
00106           alipar->setValid(true); 
00107           ierr=0;
00108           return alipar;
00109         }
00110 
00111   ierr=-1;
00112   return(0);
00113 }

void AlignmentParametersIORoot::setBranchAddresses ( void   )  [private, virtual]

Set branch adresses.

Implements AlignmentIORootBase.

Definition at line 33 of file AlignmentParametersIORoot.cc.

References theCov, theCovarRang, theCovRang, theHieraLevel, theId, theObjId, thePar, and AlignmentIORootBase::tree.

00034 {
00035   tree->SetBranchAddress("parSize",   &theCovRang);
00036   tree->SetBranchAddress("covarSize", &theCovarRang);
00037   tree->SetBranchAddress("Id",        &theId);
00038   tree->SetBranchAddress("Par",       &thePar);
00039   tree->SetBranchAddress("Cov",       &theCov);
00040   tree->SetBranchAddress("ObjId",     &theObjId);
00041   tree->SetBranchAddress("HieraLevel",&theHieraLevel);
00042 }

int AlignmentParametersIORoot::writeOne ( Alignable ali  )  [private, virtual]

Write AlignmentParameters of one Alignable.

Implements AlignmentParametersIO.

Definition at line 57 of file AlignmentParametersIORoot.cc.

References Alignable::alignableObjectId(), Alignable::alignmentParameters(), parsecf::pyparsing::col(), count, AlignmentParameters::covariance(), AlignmentParameters::hierarchyLevel(), Alignable::id(), AlignmentParameters::parameters(), params, row, theCov, theCovarRang, theCovRang, theHieraLevel, theId, theObjId, thePar, and AlignmentIORootBase::tree.

00058 {
00059   const AlignmentParameters* ap =ali->alignmentParameters();
00060   const AlgebraicVector& params = ap->parameters();
00061   const AlgebraicSymMatrix& cov = ap->covariance();
00062 
00063   theCovRang   = params.num_row();
00064   theCovarRang = theCovRang*(theCovRang+1)/2;
00065   int count=0;
00066   for(int row=0;row<theCovRang;row++){
00067     thePar[row]=params[row];
00068     for(int col=0;col<theCovRang;col++){
00069       if(row-1<col) { theCov[count] = cov[row][col]; count++; }
00070     }
00071   }
00072 
00073   theId = ali->id();
00074   theObjId = ali->alignableObjectId();
00075   theHieraLevel = ap->hierarchyLevel();
00076 
00077   tree->Fill();
00078   return 0;
00079 }


Friends And Related Function Documentation

friend class AlignmentIORoot [friend]

Definition at line 18 of file AlignmentParametersIORoot.h.


Member Data Documentation

double AlignmentParametersIORoot::theCov[nParMax *(nParMax+1)/2] [private]

Definition at line 55 of file AlignmentParametersIORoot.h.

Referenced by createBranches(), readOne(), setBranchAddresses(), and writeOne().

int AlignmentParametersIORoot::theCovarRang [private]

Definition at line 51 of file AlignmentParametersIORoot.h.

Referenced by createBranches(), setBranchAddresses(), and writeOne().

int AlignmentParametersIORoot::theCovRang [private]

Definition at line 51 of file AlignmentParametersIORoot.h.

Referenced by createBranches(), readOne(), setBranchAddresses(), and writeOne().

int AlignmentParametersIORoot::theHieraLevel [private]

Definition at line 51 of file AlignmentParametersIORoot.h.

Referenced by createBranches(), setBranchAddresses(), and writeOne().

align::ID AlignmentParametersIORoot::theId [private]

Definition at line 52 of file AlignmentParametersIORoot.h.

Referenced by createBranches(), findEntry(), setBranchAddresses(), and writeOne().

align::StructureType AlignmentParametersIORoot::theObjId [private]

Definition at line 53 of file AlignmentParametersIORoot.h.

Referenced by createBranches(), findEntry(), setBranchAddresses(), and writeOne().

double AlignmentParametersIORoot::thePar[nParMax] [private]

Definition at line 55 of file AlignmentParametersIORoot.h.

Referenced by createBranches(), readOne(), setBranchAddresses(), and writeOne().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:14:35 2009 for CMSSW by  doxygen 1.5.4