CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Types | Private Attributes

MillePedeVariablesIORoot Class Reference

#include <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)
void writeMillePedeVariables (const std::vector< Alignable * > &alivec, const char *filename, int iter, bool validCheck, int &ierr)
virtual ~MillePedeVariablesIORoot ()

Protected Member Functions

virtual int close ()
virtual void createBranches ()
 create root branches
virtual int open (const char *filename, int iteration, bool writemode)
virtual AlignmentUserVariablesreadOne (Alignable *ali, int &ierr)
virtual void setBranchAddresses ()
 set root branche addresses
virtual int writeOne (Alignable *ali)

Private Types

enum  { kMaxNumPar = 20 }

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.4
Date:
2010/10/26 20:49:42

(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.

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

Constructor & Destructor Documentation

MillePedeVariablesIORoot::MillePedeVariablesIORoot ( )

Definition at line 23 of file MillePedeVariablesIORoot.cc.

References i, kMaxNumPar, myDiffBefore, myGlobalCor, myIsValid, myParameter, myPreSigma, mySigma, AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.

                                                   :
  myId(0), myObjId(0), myNumPar(0),
  myHitsX(0), myHitsY(0), myLabel(0)
{
  treename = "MillePedeUser";
  treetxt = "MillePede User Variables";
  for (unsigned int i=0;i<kMaxNumPar;i++) {
    myIsValid[i] = 0;
    myDiffBefore[i] = 0.;
    myGlobalCor[i] = 0.;
    myPreSigma[i] = 0.;
    myParameter[i] = 0.;
    mySigma[i] = 0.;
  }
}
virtual MillePedeVariablesIORoot::~MillePedeVariablesIORoot ( ) [inline, virtual]

Definition at line 33 of file MillePedeVariablesIORoot.h.

{}

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().

{return this->closeRoot();} // inherited from AlignmentUserVariablesIO
void MillePedeVariablesIORoot::createBranches ( void  ) [protected, virtual]

create root branches

Implements AlignmentIORootBase.

Definition at line 156 of file MillePedeVariablesIORoot.cc.

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

{
  tree->Branch("Id",        &myId,        "Id/i");
  tree->Branch("ObjId",     &myObjId,     "ObjId/I");
  tree->Branch("NumPar",    &myNumPar,    "NumPar/i");
  tree->Branch("IsValid",    myIsValid,   "IsValid[NumPar]/b");
  tree->Branch("DiffBefore", myDiffBefore,"DiffBefore[NumPar]/F");
  tree->Branch("GlobalCor",  myGlobalCor, "GlobalCor[NumPar]/F");
  tree->Branch("PreSigma",   myPreSigma,  "PreSigma[NumPar]/F");
  tree->Branch("Par",        myParameter, "Par[NumPar]/F"); // name as in AlignmentParametersIORoot
  tree->Branch("Sigma",      mySigma,     "Sigma[NumPar]/F");
  tree->Branch("HitsX",     &myHitsX,     "HitsX/i");
  tree->Branch("HitsY",     &myHitsY,     "HitsY/i");
  tree->Branch("Label",     &myLabel,     "Label/i");
}
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().

    { 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 66 of file MillePedeVariablesIORoot.cc.

References SiPixelLorentzAngle_cfi::read, and query::result.

Referenced by MillePedeAlignmentAlgorithm::addHitStatistics().

{
  std::vector<AlignmentUserVariables*> result;
  ierr = 0;
  int iret = this->open(filename, iter, false);
  if (iret != 0) {
    ierr = -1;
  } else {
    result = this->read(alivec, iret);
    if (iret != 0) {
      ierr = -2;
    } else {
      iret = this->close();
      if (iret != 0) {
        ierr = -3;
      }
    }
  }

  return result;
}
AlignmentUserVariables * MillePedeVariablesIORoot::readOne ( Alignable ali,
int &  ierr 
) [protected, virtual]

read MillePedeVariables belonging to one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 128 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::sigma(), and AlignmentIORootBase::tree.

{
  ierr = 0;

  if (tree->GetEntryWithIndex(ali->id(), ali->alignableObjectId()) < 0) {
    edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::readOne"
                               << "No index for id/type = (" << ali->id() << "/"
                               << ali->alignableObjectId() << ") found!";
    ierr = 1;
    return 0;
  }

  MillePedeVariables *mpVar = new MillePedeVariables(myNumPar, myLabel);
  for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
    mpVar->isValid()[iPar]    = myIsValid[iPar];
    mpVar->diffBefore()[iPar] = myDiffBefore[iPar];
    mpVar->globalCor()[iPar]  = myGlobalCor[iPar];
    mpVar->preSigma()[iPar]   = myPreSigma[iPar];
    mpVar->parameter()[iPar]  = myParameter[iPar];
    mpVar->sigma()[iPar]      = mySigma[iPar];
  }
  mpVar->setHitsX(myHitsX);
  mpVar->setHitsY(myHitsY);
  
  return mpVar;
}
void MillePedeVariablesIORoot::setBranchAddresses ( void  ) [protected, virtual]

set root branche addresses

Implements AlignmentIORootBase.

Definition at line 173 of file MillePedeVariablesIORoot.cc.

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

{
  tree->SetBranchAddress("Id",        &myId);
  tree->SetBranchAddress("ObjId",     &myObjId);
  tree->SetBranchAddress("NumPar",    &myNumPar);
  tree->SetBranchAddress("IsValid",    myIsValid);
  tree->SetBranchAddress("DiffBefore", myDiffBefore);
  tree->SetBranchAddress("GlobalCor",  myGlobalCor);
  tree->SetBranchAddress("PreSigma",   myPreSigma);
  tree->SetBranchAddress("Par",        myParameter);
  tree->SetBranchAddress("Sigma",      mySigma);
  tree->SetBranchAddress("HitsX",     &myHitsX);
  tree->SetBranchAddress("HitsY",     &myHitsY);
  tree->SetBranchAddress("Label",     &myLabel);
}
void MillePedeVariablesIORoot::writeMillePedeVariables ( const std::vector< Alignable * > &  alivec,
const char *  filename,
int  iter,
bool  validCheck,
int &  ierr 
)

write user variables

Definition at line 41 of file MillePedeVariablesIORoot.cc.

References diffTreeTool::tree, and TablePrint::write.

Referenced by MillePedeAlignmentAlgorithm::doIO().

{
  ierr = 0;

  int iret = this->open(filename, iter, true); 
  if (iret != 0) {
    ierr = -1; 
  } else {
    iret = this->write(alivec, validCheck);
    tree->BuildIndex("Id", "ObjId");
    if (iret != 0) {
      ierr = -2;
    } else {
      iret = this->close();
      if (iret != 0) {
        ierr = -3;
      }
    }
  }
  
  return;
}
int MillePedeVariablesIORoot::writeOne ( Alignable ali) [protected, virtual]

write MillePedeVariables attached to AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 89 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().

{
  if (!ali || !ali->alignmentParameters() 
      || !dynamic_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables())) {
    edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
                               << "No MillePedeVariables found!"; 
    return -1;
  }

  const MillePedeVariables *mpVar = 
    static_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables());
  myNumPar = mpVar->size();
  if (myNumPar >= kMaxNumPar) {
    edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
                               << "Ignoring parameters " << static_cast<int>(kMaxNumPar) << " to " << myNumPar-1;
    myNumPar = kMaxNumPar;
  }

  for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
    myIsValid[iPar]    = mpVar->isValid()[iPar];
    myDiffBefore[iPar] = mpVar->diffBefore()[iPar];
    myGlobalCor[iPar]  = mpVar->globalCor()[iPar];
    myPreSigma[iPar]   = mpVar->preSigma()[iPar];
    myParameter[iPar]  = mpVar->parameter()[iPar];
    mySigma[iPar]      = mpVar->sigma()[iPar];
  }
  myHitsX = mpVar->hitsX();
  myHitsY = mpVar->hitsY();
  myLabel = mpVar->label();

  myId = ali->id();
  myObjId = ali->alignableObjectId();

  tree->Fill();

  return 0;
}

Member Data Documentation

Float_t MillePedeVariablesIORoot::myDiffBefore[kMaxNumPar] [private]
Float_t MillePedeVariablesIORoot::myGlobalCor[kMaxNumPar] [private]

Definition at line 78 of file MillePedeVariablesIORoot.h.

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

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 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().

Definition at line 69 of file MillePedeVariablesIORoot.h.

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

Float_t MillePedeVariablesIORoot::myParameter[kMaxNumPar] [private]
Float_t MillePedeVariablesIORoot::myPreSigma[kMaxNumPar] [private]
Float_t MillePedeVariablesIORoot::mySigma[kMaxNumPar] [private]