CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Types | Private Attributes
MillePedeVariablesIORoot Class Reference

#include <MillePedeVariablesIORoot.h>

Inheritance diagram for MillePedeVariablesIORoot:
AlignmentIORootBase AlignmentUserVariablesIO

Public Member Functions

 MillePedeVariablesIORoot ()
 
std::vector< AlignmentUserVariables * > readMillePedeVariables (const align::Alignables &alivec, const char *filename, int iter, int &ierr)
 
void writeMillePedeVariables (const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
 
 ~MillePedeVariablesIORoot () override
 

Protected Member Functions

int close () override
 
void createBranches () override
 create root branches More...
 
int open (const char *filename, int iteration, bool writemode) override
 
AlignmentUserVariablesreadOne (Alignable *ali, int &ierr) override
 
void setBranchAddresses () override
 set root branche addresses More...
 
int writeOne (Alignable *ali) override
 
- Protected Member Functions inherited from AlignmentIORootBase
 AlignmentIORootBase ()
 constructor More...
 
int closeRoot (void)
 close IO More...
 
int openRoot (const char *filename, int iteration, bool writemode)
 open IO More...
 
int testFile (const char *filename, const TString &tname)
 test if file is existing and if so, what the highest iteration is More...
 
TString treeName (int iter, const TString &tname)
 compose tree name More...
 
virtual ~AlignmentIORootBase ()
 destructor More...
 
- Protected Member Functions inherited from AlignmentUserVariablesIO
std::vector< AlignmentUserVariables * > read (const align::Alignables &alivec, int &ierr)
 
int write (const align::Alignables &alivec, bool validCheck)
 
virtual ~AlignmentUserVariablesIO ()
 

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
 
std::string myName
 
std::string * myNamePtr
 
unsigned int myNumPar
 
int myObjId
 
Float_t myParameter [kMaxNumPar]
 
Float_t myPreSigma [kMaxNumPar]
 
Float_t mySigma [kMaxNumPar]
 

Additional Inherited Members

- Protected Attributes inherited from AlignmentIORootBase
bool bWrite
 
TTree * tree
 
TString treename
 
TString treetxt
 
- Static Protected Attributes inherited from AlignmentIORootBase
static const int itermax = 1000
 
static const int nParMax = 20
 

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 31 of file MillePedeVariablesIORoot.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
kMaxNumPar 

Definition at line 68 of file MillePedeVariablesIORoot.h.

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

Constructor & Destructor Documentation

MillePedeVariablesIORoot::MillePedeVariablesIORoot ( )

Definition at line 20 of file MillePedeVariablesIORoot.cc.

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

20  :
21  myId(0), myObjId(0), myNumPar(0),
22  myHitsX(0), myHitsY(0), myLabel(0), myName(""), myNamePtr(&myName)
23 {
24  treename = "MillePedeUser";
25  treetxt = "MillePede User Variables";
26  for (unsigned int i=0;i<kMaxNumPar;i++) {
27  myIsValid[i] = 0;
28  myDiffBefore[i] = 0.;
29  myGlobalCor[i] = 0.;
30  myPreSigma[i] = 0.;
31  myParameter[i] = 0.;
32  mySigma[i] = 0.;
33  }
34 }
MillePedeVariablesIORoot::~MillePedeVariablesIORoot ( )
inlineoverride

Member Function Documentation

int MillePedeVariablesIORoot::close ( void  )
inlineoverrideprotectedvirtual
void MillePedeVariablesIORoot::createBranches ( void  )
overrideprotectedvirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 154 of file MillePedeVariablesIORoot.cc.

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

Referenced by close().

155 {
156  tree->Branch("Id", &myId, "Id/i");
157  tree->Branch("ObjId", &myObjId, "ObjId/I");
158  tree->Branch("NumPar", &myNumPar, "NumPar/i");
159  tree->Branch("IsValid", myIsValid, "IsValid[NumPar]/b");
160  tree->Branch("DiffBefore", myDiffBefore,"DiffBefore[NumPar]/F");
161  tree->Branch("GlobalCor", myGlobalCor, "GlobalCor[NumPar]/F");
162  tree->Branch("PreSigma", myPreSigma, "PreSigma[NumPar]/F");
163  tree->Branch("Par", myParameter, "Par[NumPar]/F"); // name as in AlignmentParametersIORoot
164  tree->Branch("Sigma", mySigma, "Sigma[NumPar]/F");
165  tree->Branch("HitsX", &myHitsX, "HitsX/i");
166  tree->Branch("HitsY", &myHitsY, "HitsY/i");
167  tree->Branch("Label", &myLabel, "Label/i");
168  tree->Branch("Name", &myNamePtr);
169 }
Definition: tree.py:1
int MillePedeVariablesIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
)
inlineoverrideprotectedvirtual

open IO

Implements AlignmentUserVariablesIO.

Definition at line 55 of file MillePedeVariablesIORoot.h.

References AlignmentIORootBase::openRoot().

Referenced by Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::importConfig(), readMillePedeVariables(), and writeMillePedeVariables().

56  { return this->openRoot(filename, iteration, writemode);}
int openRoot(const char *filename, int iteration, bool writemode)
open IO
std::vector< AlignmentUserVariables * > MillePedeVariablesIORoot::readMillePedeVariables ( const align::Alignables alivec,
const char *  filename,
int  iter,
int &  ierr 
)

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

Definition at line 63 of file MillePedeVariablesIORoot.cc.

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

Referenced by MillePedeAlignmentAlgorithm::addHitStatistics(), writeMillePedeVariables(), and ~MillePedeVariablesIORoot().

64 {
65  std::vector<AlignmentUserVariables*> result;
66  ierr = 0;
67  int iret = this->open(filename, iter, false);
68  if (iret != 0) {
69  ierr = -1;
70  } else {
71  result = this->read(alivec, iret);
72  if (iret != 0) {
73  ierr = -2;
74  } else {
75  iret = this->close();
76  if (iret != 0) {
77  ierr = -3;
78  }
79  }
80  }
81 
82  return result;
83 }
std::vector< AlignmentUserVariables * > read(const align::Alignables &alivec, int &ierr)
int open(const char *filename, int iteration, bool writemode) override
AlignmentUserVariables * MillePedeVariablesIORoot::readOne ( Alignable ali,
int &  ierr 
)
overrideprotectedvirtual

read MillePedeVariables belonging to one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 126 of file MillePedeVariablesIORoot.cc.

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

Referenced by ~MillePedeVariablesIORoot().

127 {
128  ierr = 0;
129 
130  if (tree->GetEntryWithIndex(ali->id(), ali->alignableObjectId()) < 0) {
131  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::readOne"
132  << "No index for id/type = (" << ali->id() << "/"
133  << ali->alignableObjectId() << ") found!";
134  ierr = 1;
135  return nullptr;
136  }
137 
139  for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
140  mpVar->isValid()[iPar] = myIsValid[iPar];
141  mpVar->diffBefore()[iPar] = myDiffBefore[iPar];
142  mpVar->globalCor()[iPar] = myGlobalCor[iPar];
143  mpVar->preSigma()[iPar] = myPreSigma[iPar];
144  mpVar->parameter()[iPar] = myParameter[iPar];
145  mpVar->sigma()[iPar] = mySigma[iPar];
146  }
147  mpVar->setHitsX(myHitsX);
148  mpVar->setHitsY(myHitsY);
149 
150  return mpVar;
151 }
const std::vector< float > & globalCor() const
get global correlation array
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
const std::vector< float > & parameter() const
get array of parameters
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
void setHitsY(unsigned int hitsY)
const std::vector< float > & preSigma() const
get array of presigmas (<= 0: means fixed)
const std::vector< float > & sigma() const
get array of sigmas
const std::vector< float > & diffBefore() const
get array of differences to start value
const std::vector< bool > & isValid() const
get valid flag array
Definition: tree.py:1
void setHitsX(unsigned int hitsX)
void MillePedeVariablesIORoot::setBranchAddresses ( void  )
overrideprotectedvirtual

set root branche addresses

Implements AlignmentIORootBase.

Definition at line 172 of file MillePedeVariablesIORoot.cc.

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

Referenced by close().

173 {
174  tree->SetBranchAddress("Id", &myId);
175  tree->SetBranchAddress("ObjId", &myObjId);
176  tree->SetBranchAddress("NumPar", &myNumPar);
177  tree->SetBranchAddress("IsValid", myIsValid);
178  tree->SetBranchAddress("DiffBefore", myDiffBefore);
179  tree->SetBranchAddress("GlobalCor", myGlobalCor);
180  tree->SetBranchAddress("PreSigma", myPreSigma);
181  tree->SetBranchAddress("Par", myParameter);
182  tree->SetBranchAddress("Sigma", mySigma);
183  tree->SetBranchAddress("HitsX", &myHitsX);
184  tree->SetBranchAddress("HitsY", &myHitsY);
185  tree->SetBranchAddress("Label", &myLabel);
186  tree->SetBranchAddress("Name", &myNamePtr);
187 }
Definition: tree.py:1
void MillePedeVariablesIORoot::writeMillePedeVariables ( const align::Alignables alivec,
const char *  filename,
int  iter,
bool  validCheck,
int &  ierr 
)

write user variables

Definition at line 38 of file MillePedeVariablesIORoot.cc.

References close(), open(), readMillePedeVariables(), and AlignmentUserVariablesIO::write().

Referenced by MillePedeAlignmentAlgorithm::doIO(), MillePedeVariablesIORoot(), and ~MillePedeVariablesIORoot().

39 {
40  ierr = 0;
41 
42  int iret = this->open(filename, iter, true);
43  if (iret != 0) {
44  ierr = -1;
45  } else {
46  iret = this->write(alivec, validCheck);
47  tree->BuildIndex("Id", "ObjId");
48  if (iret != 0) {
49  ierr = -2;
50  } else {
51  iret = this->close();
52  if (iret != 0) {
53  ierr = -3;
54  }
55  }
56  }
57 
58  return;
59 }
int write(const align::Alignables &alivec, bool validCheck)
Definition: tree.py:1
int open(const char *filename, int iteration, bool writemode) override
int MillePedeVariablesIORoot::writeOne ( Alignable ali)
overrideprotectedvirtual

write MillePedeVariables attached to AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 86 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, myName, myNumPar, myObjId, myParameter, myPreSigma, mySigma, MillePedeVariables::name(), MillePedeVariables::parameter(), MillePedeVariables::preSigma(), MillePedeVariables::sigma(), MillePedeVariables::size(), and AlignmentParameters::userVariables().

Referenced by ~MillePedeVariablesIORoot().

87 {
88  if (!ali || !ali->alignmentParameters()
89  || !dynamic_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables())) {
90  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
91  << "No MillePedeVariables found!";
92  return -1;
93  }
94 
95  const MillePedeVariables *mpVar =
96  static_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables());
97  myNumPar = mpVar->size();
98  if (myNumPar >= kMaxNumPar) {
99  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
100  << "Ignoring parameters " << static_cast<int>(kMaxNumPar) << " to " << myNumPar-1;
102  }
103 
104  for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
105  myIsValid[iPar] = mpVar->isValid()[iPar];
106  myDiffBefore[iPar] = mpVar->diffBefore()[iPar];
107  myGlobalCor[iPar] = mpVar->globalCor()[iPar];
108  myPreSigma[iPar] = mpVar->preSigma()[iPar];
109  myParameter[iPar] = mpVar->parameter()[iPar];
110  mySigma[iPar] = mpVar->sigma()[iPar];
111  }
112  myHitsX = mpVar->hitsX();
113  myHitsY = mpVar->hitsY();
114  myLabel = mpVar->label();
115  myName = mpVar->name();
116 
117  myId = ali->id();
118  myObjId = ali->alignableObjectId();
119 
120  tree->Fill();
121 
122  return 0;
123 }
unsigned int hitsX() const
get number of hits for x-measurement
unsigned int label() const
get alignable label as used by pede
const std::vector< float > & globalCor() const
get global correlation array
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
unsigned int size() const
number of parameters
const std::vector< float > & parameter() const
get array of parameters
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
const std::string & name() const
get alignable name
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const std::vector< float > & preSigma() const
get array of presigmas (<= 0: means fixed)
unsigned int hitsY() const
get number of hits for y-measurement
const std::vector< float > & sigma() const
get array of sigmas
const std::vector< float > & diffBefore() const
get array of differences to start value
const std::vector< bool > & isValid() const
get valid flag array
Definition: tree.py:1

Member Data Documentation

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

Definition at line 80 of file MillePedeVariablesIORoot.h.

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

UInt_t MillePedeVariablesIORoot::myHitsY
private

Definition at line 81 of file MillePedeVariablesIORoot.h.

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

unsigned int MillePedeVariablesIORoot::myId
private

Definition at line 70 of file MillePedeVariablesIORoot.h.

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

Byte_t MillePedeVariablesIORoot::myIsValid[kMaxNumPar]
private
UInt_t MillePedeVariablesIORoot::myLabel
private

Definition at line 82 of file MillePedeVariablesIORoot.h.

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

std::string MillePedeVariablesIORoot::myName
private

Definition at line 83 of file MillePedeVariablesIORoot.h.

Referenced by readOne(), and writeOne().

std::string* MillePedeVariablesIORoot::myNamePtr
private

Definition at line 84 of file MillePedeVariablesIORoot.h.

Referenced by createBranches(), and setBranchAddresses().

unsigned int MillePedeVariablesIORoot::myNumPar
private

Definition at line 73 of file MillePedeVariablesIORoot.h.

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

int MillePedeVariablesIORoot::myObjId
private

Definition at line 71 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