CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 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 More...
 
virtual int open (const char *filename, int iteration, bool writemode)
 
virtual AlignmentUserVariablesreadOne (Alignable *ali, int &ierr)
 
virtual void setBranchAddresses ()
 set root branche addresses More...
 
virtual int writeOne (Alignable *ali)
 
- 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
 
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 29 of file MillePedeVariablesIORoot.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
kMaxNumPar 

Definition at line 66 of file MillePedeVariablesIORoot.h.

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

Constructor & Destructor Documentation

MillePedeVariablesIORoot::MillePedeVariablesIORoot ( )

Definition at line 23 of file MillePedeVariablesIORoot.cc.

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

24 {
25  treename = "MillePedeUser";
26  treetxt = "MillePede User Variables";
27 }
virtual MillePedeVariablesIORoot::~MillePedeVariablesIORoot ( )
inlinevirtual

Definition at line 33 of file MillePedeVariablesIORoot.h.

33 {}

Member Function Documentation

virtual int MillePedeVariablesIORoot::close ( void  )
inlineprotectedvirtual

close IO

Implements AlignmentUserVariablesIO.

Definition at line 57 of file MillePedeVariablesIORoot.h.

References AlignmentIORootBase::closeRoot().

Referenced by python.Vispa.Gui.BoxContentDialog.BoxContentDialog::keyPressEvent(), and python.Vispa.Gui.FindDialog.FindDialog::keyPressEvent().

57 {return this->closeRoot();} // inherited from AlignmentUserVariablesIO
int closeRoot(void)
close IO
void MillePedeVariablesIORoot::createBranches ( void  )
protectedvirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 146 of file MillePedeVariablesIORoot.cc.

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

147 {
148  tree->Branch("Id", &myId, "Id/i");
149  tree->Branch("ObjId", &myObjId, "ObjId/I");
150  tree->Branch("NumPar", &myNumPar, "NumPar/i");
151  tree->Branch("IsValid", myIsValid, "IsValid[NumPar]/b");
152  tree->Branch("DiffBefore", myDiffBefore,"DiffBefore[NumPar]/F");
153  tree->Branch("GlobalCor", myGlobalCor, "GlobalCor[NumPar]/F");
154  tree->Branch("PreSigma", myPreSigma, "PreSigma[NumPar]/F");
155  tree->Branch("Par", myParameter, "Par[NumPar]/F"); // name as in AlignmentParametersIORoot
156  tree->Branch("Sigma", mySigma, "Sigma[NumPar]/F");
157  tree->Branch("HitsX", &myHitsX, "HitsX/i");
158  tree->Branch("HitsY", &myHitsY, "HitsY/i");
159  tree->Branch("Label", &myLabel, "Label/i");
160 }
virtual int MillePedeVariablesIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
)
inlineprotectedvirtual

open IO

Implements AlignmentUserVariablesIO.

Definition at line 53 of file MillePedeVariablesIORoot.h.

References AlignmentIORootBase::openRoot().

Referenced by python.Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::importConfig().

54  { return this->openRoot(filename, iteration, writemode);}
tuple iteration
Definition: align_cfg.py:5
int openRoot(const char *filename, int iteration, bool writemode)
open IO
tuple filename
Definition: lut2db_cfg.py:20
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 SiPixelLorentzAngle_cfi::read, and query::result.

Referenced by MillePedeAlignmentAlgorithm::addHitStatistics().

57 {
58  std::vector<AlignmentUserVariables*> result;
59  ierr = 0;
60  int iret = this->open(filename, iter, false);
61  if (iret != 0) {
62  ierr = -1;
63  } else {
64  result = this->read(alivec, iret);
65  if (iret != 0) {
66  ierr = -2;
67  } else {
68  iret = this->close();
69  if (iret != 0) {
70  ierr = -3;
71  }
72  }
73  }
74 
75  return result;
76 }
tuple result
Definition: query.py:137
virtual int open(const char *filename, int iteration, bool writemode)
std::vector< AlignmentUserVariables * > read(const align::Alignables &alivec, int &ierr)
tuple filename
Definition: lut2db_cfg.py:20
AlignmentUserVariables * MillePedeVariablesIORoot::readOne ( Alignable ali,
int &  ierr 
)
protectedvirtual

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

119 {
120  ierr = 0;
121 
122  if (tree->GetEntryWithIndex(ali->id(), ali->alignableObjectId()) < 0) {
123  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::readOne"
124  << "No index for id/type = (" << ali->id() << "/"
125  << ali->alignableObjectId() << ") found!";
126  ierr = 1;
127  return 0;
128  }
129 
131  for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
132  mpVar->isValid()[iPar] = myIsValid[iPar];
133  mpVar->diffBefore()[iPar] = myDiffBefore[iPar];
134  mpVar->globalCor()[iPar] = myGlobalCor[iPar];
135  mpVar->preSigma()[iPar] = myPreSigma[iPar];
136  mpVar->parameter()[iPar] = myParameter[iPar];
137  mpVar->sigma()[iPar] = mySigma[iPar];
138  }
139  mpVar->setHitsX(myHitsX);
140  mpVar->setHitsY(myHitsY);
141 
142  return mpVar;
143 }
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:180
const std::vector< float > & parameter() const
get array of parameters
void setHitsY(unsigned int hitsY)
const std::vector< float > & preSigma() const
get array of presigmas (&lt;= 0: means fixed)
const std::vector< float > & sigma() const
get array of sigmas
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const std::vector< float > & diffBefore() const
get array of differences to start value
const std::vector< bool > & isValid() const
get valid flag array
void setHitsX(unsigned int hitsX)
void MillePedeVariablesIORoot::setBranchAddresses ( void  )
protectedvirtual

set root branche addresses

Implements AlignmentIORootBase.

Definition at line 163 of file MillePedeVariablesIORoot.cc.

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

164 {
165  tree->SetBranchAddress("Id", &myId);
166  tree->SetBranchAddress("ObjId", &myObjId);
167  tree->SetBranchAddress("NumPar", &myNumPar);
168  tree->SetBranchAddress("IsValid", myIsValid);
169  tree->SetBranchAddress("DiffBefore", myDiffBefore);
170  tree->SetBranchAddress("GlobalCor", myGlobalCor);
171  tree->SetBranchAddress("PreSigma", myPreSigma);
172  tree->SetBranchAddress("Par", myParameter);
173  tree->SetBranchAddress("Sigma", mySigma);
174  tree->SetBranchAddress("HitsX", &myHitsX);
175  tree->SetBranchAddress("HitsY", &myHitsY);
176  tree->SetBranchAddress("Label", &myLabel);
177 }
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 diffTreeTool::tree.

Referenced by MillePedeAlignmentAlgorithm::doIO().

32 {
33  ierr = 0;
34 
35  int iret = this->open(filename, iter, true);
36  if (iret != 0) {
37  ierr = -1;
38  } else {
39  iret = this->write(alivec, validCheck);
40  tree->BuildIndex("Id", "ObjId");
41  if (iret != 0) {
42  ierr = -2;
43  } else {
44  iret = this->close();
45  if (iret != 0) {
46  ierr = -3;
47  }
48  }
49  }
50 
51  return;
52 }
virtual int open(const char *filename, int iteration, bool writemode)
int write(const align::Alignables &alivec, bool validCheck)
tuple filename
Definition: lut2db_cfg.py:20
int MillePedeVariablesIORoot::writeOne ( Alignable ali)
protectedvirtual

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

80 {
81  if (!ali || !ali->alignmentParameters()
82  || !dynamic_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables())) {
83  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
84  << "No MillePedeVariables found!";
85  return -1;
86  }
87 
88  const MillePedeVariables *mpVar =
89  static_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables());
90  myNumPar = mpVar->size();
91  if (myNumPar >= kMaxNumPar) {
92  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
93  << "Ignoring parameters " << static_cast<int>(kMaxNumPar) << " to " << myNumPar-1;
95  }
96 
97  for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
98  myIsValid[iPar] = mpVar->isValid()[iPar];
99  myDiffBefore[iPar] = mpVar->diffBefore()[iPar];
100  myGlobalCor[iPar] = mpVar->globalCor()[iPar];
101  myPreSigma[iPar] = mpVar->preSigma()[iPar];
102  myParameter[iPar] = mpVar->parameter()[iPar];
103  mySigma[iPar] = mpVar->sigma()[iPar];
104  }
105  myHitsX = mpVar->hitsX();
106  myHitsY = mpVar->hitsY();
107  myLabel = mpVar->label();
108 
109  myId = ali->id();
110  myObjId = ali->alignableObjectId();
111 
112  tree->Fill();
113 
114  return 0;
115 }
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:180
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:57
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
const std::vector< float > & preSigma() const
get array of presigmas (&lt;= 0: means fixed)
unsigned int hitsY() const
get number of hits for y-measurement
const std::vector< float > & sigma() const
get array of sigmas
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const std::vector< float > & diffBefore() const
get array of differences to start value
const std::vector< bool > & isValid() const
get valid flag array

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