CMS 3D CMS Logo

MillePedeVariablesIORoot Class Reference

ROOT based IO of MillePedeVariables. More...

#include <Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeVariablesIORoot.h>

Inheritance diagram for MillePedeVariablesIORoot:

AlignmentIORootBase AlignmentUserVariablesIO

List of all members.

Public Member Functions

 MillePedeVariablesIORoot ()
std::vector
< AlignmentUserVariables * > 
readMillePedeVariables (const std::vector< Alignable * > &alivec, const char *filename, int iter, int &ierr)
 read user variables (not that their memory is owned by this class!)
void writeMillePedeVariables (const std::vector< Alignable * > &alivec, const char *filename, int iter, bool validCheck, int &ierr)
 write user variables
virtual ~MillePedeVariablesIORoot ()

Protected Member Functions

virtual int close ()
 close IO
virtual void createBranches ()
 create root branches
virtual int open (const char *filename, int iteration, bool writemode)
 open IO
virtual AlignmentUserVariablesreadOne (Alignable *ali, int &ierr)
 read MillePedeVariables belonging to one Alignable
virtual void setBranchAddresses ()
 set root branche addresses
virtual int writeOne (Alignable *ali)
 write MillePedeVariables attached to AlignmentParameters of one Alignable

Private Types

enum  { kMaxNumPar = 10 }

Private Attributes

Float_t myDiffBefore [kMaxNumPar]
Float_t myGlobalCor [kMaxNumPar]
UInt_t myHitsX
UInt_t myHitsY
unsigned int myId
Byte_t myIsValid [kMaxNumPar]
UInt_t myLabel
unsigned int myNumPar
int myObjId
Float_t myParameter [kMaxNumPar]
Float_t myPreSigma [kMaxNumPar]
Float_t mySigma [kMaxNumPar]


Detailed Description

ROOT based IO of MillePedeVariables.

Author:
: Gero Flucke date : November 2006
Revision
1.3
Date
2007/03/16 17:03:02
(last update by
Author
flucke
)

Definition at line 29 of file MillePedeVariablesIORoot.h.


Member Enumeration Documentation

anonymous enum [private]

Enumerator:
kMaxNumPar 

Definition at line 66 of file MillePedeVariablesIORoot.h.

00066 {kMaxNumPar = 10}; // far above rigid body limit (RigidBodyAlignmentParameters::N_PARAM)


Constructor & Destructor Documentation

MillePedeVariablesIORoot::MillePedeVariablesIORoot (  ) 

Definition at line 23 of file MillePedeVariablesIORoot.cc.

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

00024 {
00025   treename = "MillePedeUser";
00026   treetxt = "MillePede User Variables";
00027 }

virtual MillePedeVariablesIORoot::~MillePedeVariablesIORoot (  )  [inline, virtual]

Definition at line 33 of file MillePedeVariablesIORoot.h.

00033 {}


Member Function Documentation

virtual int MillePedeVariablesIORoot::close ( void   )  [inline, protected, virtual]

close IO

Implements AlignmentUserVariablesIO.

Definition at line 57 of file MillePedeVariablesIORoot.h.

References AlignmentIORootBase::closeRoot().

Referenced by readMillePedeVariables(), and writeMillePedeVariables().

00057 {return this->closeRoot();} // inherited from AlignmentUserVariablesIO

void MillePedeVariablesIORoot::createBranches ( void   )  [protected, virtual]

create root branches

Implements AlignmentIORootBase.

Definition at line 147 of file MillePedeVariablesIORoot.cc.

References myDiffBefore, myGlobalCor, myHitsX, myHitsY, myId, myIsValid, myLabel, myNumPar, myObjId, myParameter, myPreSigma, mySigma, and AlignmentIORootBase::tree.

00148 {
00149   tree->Branch("Id",        &myId,        "Id/i");
00150   tree->Branch("ObjId",     &myObjId,     "ObjId/I");
00151   tree->Branch("NumPar",    &myNumPar,    "NumPar/i");
00152   tree->Branch("IsValid",    myIsValid,   "IsValid[NumPar]/b");
00153   tree->Branch("DiffBefore", myDiffBefore,"DiffBefore[NumPar]/F");
00154   tree->Branch("GlobalCor",  myGlobalCor, "GlobalCor[NumPar]/F");
00155   tree->Branch("PreSigma",   myPreSigma,  "PreSigma[NumPar]/F");
00156   tree->Branch("Par",        myParameter, "Par[NumPar]/F"); // name as in AlignmentParametersIORoot
00157   tree->Branch("Sigma",      mySigma,     "Sigma[NumPar]/F");
00158   tree->Branch("HitsX",     &myHitsX,     "HitsX/i");
00159   tree->Branch("HitsY",     &myHitsY,     "HitsY/i");
00160   tree->Branch("Label",     &myLabel,     "Label/i");
00161 }

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

open IO

Implements AlignmentUserVariablesIO.

Definition at line 53 of file MillePedeVariablesIORoot.h.

References AlignmentIORootBase::openRoot().

Referenced by readMillePedeVariables(), and writeMillePedeVariables().

00054     { return this->openRoot(filename, iteration, writemode);}

std::vector< AlignmentUserVariables * > MillePedeVariablesIORoot::readMillePedeVariables ( const std::vector< Alignable * > &  alivec,
const char *  filename,
int  iter,
int ierr 
)

read user variables (not that their memory is owned by this class!)

Definition at line 56 of file MillePedeVariablesIORoot.cc.

References close(), open(), AlignmentUserVariablesIO::read(), and HLT_VtxMuL3::result.

Referenced by MillePedeAlignmentAlgorithm::addHitStatistics().

00057 {
00058   std::vector<AlignmentUserVariables*> result;
00059   ierr = 0;
00060   int iret = this->open(filename, iter, false);
00061   if (iret != 0) {
00062     ierr = -1;
00063   } else {
00064     result = this->read(alivec, iret);
00065     if (iret != 0) {
00066       ierr = -2;
00067     } else {
00068       iret = this->close();
00069       if (iret != 0) {
00070         ierr = -3;
00071       }
00072     }
00073   }
00074 
00075   return result;
00076 }

AlignmentUserVariables * MillePedeVariablesIORoot::readOne ( Alignable ali,
int ierr 
) [protected, virtual]

read MillePedeVariables belonging to one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 118 of file MillePedeVariablesIORoot.cc.

References Alignable::alignableObjectId(), MillePedeVariables::diffBefore(), MillePedeVariables::globalCor(), Alignable::id(), MillePedeVariables::isValid(), myDiffBefore, myGlobalCor, myHitsX, myHitsY, myIsValid, myLabel, myNumPar, myParameter, myPreSigma, mySigma, MillePedeVariables::parameter(), MillePedeVariables::preSigma(), MillePedeVariables::setHitsX(), MillePedeVariables::setHitsY(), MillePedeVariables::setLabel(), MillePedeVariables::sigma(), and AlignmentIORootBase::tree.

00119 {
00120   ierr = 0;
00121 
00122   if (tree->GetEntryWithIndex(ali->id(), ali->alignableObjectId()) < 0) {
00123     edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::readOne"
00124                                << "No index for id/type = (" << ali->id() << "/"
00125                                << ali->alignableObjectId() << ") found!";
00126     ierr = 1;
00127     return 0;
00128   }
00129 
00130   MillePedeVariables *mpVar = new MillePedeVariables(myNumPar);
00131   for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
00132     mpVar->isValid()[iPar]    = myIsValid[iPar];
00133     mpVar->diffBefore()[iPar] = myDiffBefore[iPar];
00134     mpVar->globalCor()[iPar]  = myGlobalCor[iPar];
00135     mpVar->preSigma()[iPar]   = myPreSigma[iPar];
00136     mpVar->parameter()[iPar]  = myParameter[iPar];
00137     mpVar->sigma()[iPar]      = mySigma[iPar];
00138   }
00139   mpVar->setHitsX(myHitsX);
00140   mpVar->setHitsY(myHitsY);
00141   mpVar->setLabel(myLabel);
00142   
00143   return mpVar;
00144 }

void MillePedeVariablesIORoot::setBranchAddresses ( void   )  [protected, virtual]

set root branche addresses

Implements AlignmentIORootBase.

Definition at line 164 of file MillePedeVariablesIORoot.cc.

References myDiffBefore, myGlobalCor, myHitsX, myHitsY, myId, myIsValid, myLabel, myNumPar, myObjId, myParameter, myPreSigma, mySigma, and AlignmentIORootBase::tree.

00165 {
00166   tree->SetBranchAddress("Id",        &myId);
00167   tree->SetBranchAddress("ObjId",     &myObjId);
00168   tree->SetBranchAddress("NumPar",    &myNumPar);
00169   tree->SetBranchAddress("IsValid",    myIsValid);
00170   tree->SetBranchAddress("DiffBefore", myDiffBefore);
00171   tree->SetBranchAddress("GlobalCor",  myGlobalCor);
00172   tree->SetBranchAddress("PreSigma",   myPreSigma);
00173   tree->SetBranchAddress("Par",        myParameter);
00174   tree->SetBranchAddress("Sigma",      mySigma);
00175   tree->SetBranchAddress("HitsX",     &myHitsX);
00176   tree->SetBranchAddress("HitsY",     &myHitsY);
00177   tree->SetBranchAddress("Label",     &myLabel);
00178 }

void MillePedeVariablesIORoot::writeMillePedeVariables ( const std::vector< Alignable * > &  alivec,
const char *  filename,
int  iter,
bool  validCheck,
int ierr 
)

write user variables

Definition at line 31 of file MillePedeVariablesIORoot.cc.

References close(), open(), AlignmentIORootBase::tree, and AlignmentUserVariablesIO::write().

Referenced by MillePedeAlignmentAlgorithm::doIO().

00032 {
00033   ierr = 0;
00034 
00035   int iret = this->open(filename, iter, true); 
00036   if (iret != 0) {
00037     ierr = -1; 
00038   } else {
00039     iret = this->write(alivec, validCheck);
00040     tree->BuildIndex("Id", "ObjId");
00041     if (iret != 0) {
00042       ierr = -2;
00043     } else {
00044       iret = this->close();
00045       if (iret != 0) {
00046         ierr = -3;
00047       }
00048     }
00049   }
00050   
00051   return;
00052 }

int MillePedeVariablesIORoot::writeOne ( Alignable ali  )  [protected, virtual]

write MillePedeVariables attached to AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 79 of file MillePedeVariablesIORoot.cc.

References Alignable::alignableObjectId(), Alignable::alignmentParameters(), MillePedeVariables::diffBefore(), MillePedeVariables::globalCor(), MillePedeVariables::hitsX(), MillePedeVariables::hitsY(), Alignable::id(), MillePedeVariables::isValid(), kMaxNumPar, MillePedeVariables::label(), myDiffBefore, myGlobalCor, myHitsX, myHitsY, myId, myIsValid, myLabel, myNumPar, myObjId, myParameter, myPreSigma, mySigma, MillePedeVariables::parameter(), MillePedeVariables::preSigma(), MillePedeVariables::sigma(), MillePedeVariables::size(), AlignmentIORootBase::tree, and AlignmentParameters::userVariables().

00080 {
00081   if (!ali || !ali->alignmentParameters() 
00082       || !dynamic_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables())) {
00083     edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
00084                                << "No MillePedeVariables found!"; 
00085     return -1;
00086   }
00087 
00088   const MillePedeVariables *mpVar = 
00089     dynamic_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables());
00090   myNumPar = mpVar->size();
00091   if (myNumPar >= kMaxNumPar) {
00092     edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
00093                                << "Ignoring parameters " << static_cast<int>(kMaxNumPar) << " to " << myNumPar-1;
00094     myNumPar = kMaxNumPar;
00095   }
00096 
00097   for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
00098     myIsValid[iPar]    = mpVar->isValid()[iPar];
00099     myDiffBefore[iPar] = mpVar->diffBefore()[iPar];
00100     myGlobalCor[iPar]  = mpVar->globalCor()[iPar];
00101     myPreSigma[iPar]   = mpVar->preSigma()[iPar];
00102     myParameter[iPar]  = mpVar->parameter()[iPar];
00103     mySigma[iPar]      = mpVar->sigma()[iPar];
00104   }
00105   myHitsX = mpVar->hitsX();
00106   myHitsY = mpVar->hitsY();
00107   myLabel = mpVar->label();
00108 
00109   myId = ali->id();
00110   myObjId = ali->alignableObjectId();
00111 
00112   tree->Fill();
00113 
00114   return 0;
00115 }


Member Data Documentation

Float_t MillePedeVariablesIORoot::myDiffBefore[kMaxNumPar] [private]

Definition at line 73 of file MillePedeVariablesIORoot.h.

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

Float_t MillePedeVariablesIORoot::myGlobalCor[kMaxNumPar] [private]

Definition at line 74 of file MillePedeVariablesIORoot.h.

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

UInt_t MillePedeVariablesIORoot::myHitsX [private]

Definition at line 78 of file MillePedeVariablesIORoot.h.

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

UInt_t MillePedeVariablesIORoot::myHitsY [private]

Definition at line 79 of file MillePedeVariablesIORoot.h.

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

unsigned int MillePedeVariablesIORoot::myId [private]

Definition at line 68 of file MillePedeVariablesIORoot.h.

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

Byte_t MillePedeVariablesIORoot::myIsValid[kMaxNumPar] [private]

Definition at line 72 of file MillePedeVariablesIORoot.h.

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

UInt_t MillePedeVariablesIORoot::myLabel [private]

Definition at line 80 of file MillePedeVariablesIORoot.h.

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

unsigned int MillePedeVariablesIORoot::myNumPar [private]

Definition at line 71 of file MillePedeVariablesIORoot.h.

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

int MillePedeVariablesIORoot::myObjId [private]

Definition at line 69 of file MillePedeVariablesIORoot.h.

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

Float_t MillePedeVariablesIORoot::myParameter[kMaxNumPar] [private]

Definition at line 76 of file MillePedeVariablesIORoot.h.

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

Float_t MillePedeVariablesIORoot::myPreSigma[kMaxNumPar] [private]

Definition at line 75 of file MillePedeVariablesIORoot.h.

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

Float_t MillePedeVariablesIORoot::mySigma[kMaxNumPar] [private]

Definition at line 77 of file MillePedeVariablesIORoot.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:28:16 2009 for CMSSW by  doxygen 1.5.4