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 i, kMaxNumPar, myDiffBefore, myGlobalCor, myIsValid, myParameter, myPreSigma, mySigma, AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.

23  :
24  myId(0), myObjId(0), myNumPar(0),
25  myHitsX(0), myHitsY(0), myLabel(0)
26 {
27  treename = "MillePedeUser";
28  treetxt = "MillePede User Variables";
29  for (unsigned int i=0;i<kMaxNumPar;i++) {
30  myIsValid[i] = 0;
31  myDiffBefore[i] = 0.;
32  myGlobalCor[i] = 0.;
33  myPreSigma[i] = 0.;
34  myParameter[i] = 0.;
35  mySigma[i] = 0.;
36  }
37 }
int i
Definition: DBlmapReader.cc:9
virtual MillePedeVariablesIORoot::~MillePedeVariablesIORoot ( )
inlinevirtual

Definition at line 33 of file MillePedeVariablesIORoot.h.

33 {}

Member Function Documentation

virtual int MillePedeVariablesIORoot::close ( void  )
inlineprotectedvirtual
void MillePedeVariablesIORoot::createBranches ( void  )
protectedvirtual

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.

157 {
158  tree->Branch("Id", &myId, "Id/i");
159  tree->Branch("ObjId", &myObjId, "ObjId/I");
160  tree->Branch("NumPar", &myNumPar, "NumPar/i");
161  tree->Branch("IsValid", myIsValid, "IsValid[NumPar]/b");
162  tree->Branch("DiffBefore", myDiffBefore,"DiffBefore[NumPar]/F");
163  tree->Branch("GlobalCor", myGlobalCor, "GlobalCor[NumPar]/F");
164  tree->Branch("PreSigma", myPreSigma, "PreSigma[NumPar]/F");
165  tree->Branch("Par", myParameter, "Par[NumPar]/F"); // name as in AlignmentParametersIORoot
166  tree->Branch("Sigma", mySigma, "Sigma[NumPar]/F");
167  tree->Branch("HitsX", &myHitsX, "HitsX/i");
168  tree->Branch("HitsY", &myHitsY, "HitsY/i");
169  tree->Branch("Label", &myLabel, "Label/i");
170 }
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 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 66 of file MillePedeVariablesIORoot.cc.

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

Referenced by MillePedeAlignmentAlgorithm::addHitStatistics().

67 {
68  std::vector<AlignmentUserVariables*> result;
69  ierr = 0;
70  int iret = this->open(filename, iter, false);
71  if (iret != 0) {
72  ierr = -1;
73  } else {
74  result = this->read(alivec, iret);
75  if (iret != 0) {
76  ierr = -2;
77  } else {
78  iret = this->close();
79  if (iret != 0) {
80  ierr = -3;
81  }
82  }
83  }
84 
85  return result;
86 }
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 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.

129 {
130  ierr = 0;
131 
132  if (tree->GetEntryWithIndex(ali->id(), ali->alignableObjectId()) < 0) {
133  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::readOne"
134  << "No index for id/type = (" << ali->id() << "/"
135  << ali->alignableObjectId() << ") found!";
136  ierr = 1;
137  return 0;
138  }
139 
141  for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
142  mpVar->isValid()[iPar] = myIsValid[iPar];
143  mpVar->diffBefore()[iPar] = myDiffBefore[iPar];
144  mpVar->globalCor()[iPar] = myGlobalCor[iPar];
145  mpVar->preSigma()[iPar] = myPreSigma[iPar];
146  mpVar->parameter()[iPar] = myParameter[iPar];
147  mpVar->sigma()[iPar] = mySigma[iPar];
148  }
149  mpVar->setHitsX(myHitsX);
150  mpVar->setHitsY(myHitsY);
151 
152  return mpVar;
153 }
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:185
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 173 of file MillePedeVariablesIORoot.cc.

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

174 {
175  tree->SetBranchAddress("Id", &myId);
176  tree->SetBranchAddress("ObjId", &myObjId);
177  tree->SetBranchAddress("NumPar", &myNumPar);
178  tree->SetBranchAddress("IsValid", myIsValid);
179  tree->SetBranchAddress("DiffBefore", myDiffBefore);
180  tree->SetBranchAddress("GlobalCor", myGlobalCor);
181  tree->SetBranchAddress("PreSigma", myPreSigma);
182  tree->SetBranchAddress("Par", myParameter);
183  tree->SetBranchAddress("Sigma", mySigma);
184  tree->SetBranchAddress("HitsX", &myHitsX);
185  tree->SetBranchAddress("HitsY", &myHitsY);
186  tree->SetBranchAddress("Label", &myLabel);
187 }
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 MainPageGenerator::tree, and TablePrint::write.

Referenced by MillePedeAlignmentAlgorithm::doIO().

42 {
43  ierr = 0;
44 
45  int iret = this->open(filename, iter, true);
46  if (iret != 0) {
47  ierr = -1;
48  } else {
49  iret = this->write(alivec, validCheck);
50  tree->BuildIndex("Id", "ObjId");
51  if (iret != 0) {
52  ierr = -2;
53  } else {
54  iret = this->close();
55  if (iret != 0) {
56  ierr = -3;
57  }
58  }
59  }
60 
61  return;
62 }
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 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().

90 {
91  if (!ali || !ali->alignmentParameters()
92  || !dynamic_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables())) {
93  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
94  << "No MillePedeVariables found!";
95  return -1;
96  }
97 
98  const MillePedeVariables *mpVar =
99  static_cast<MillePedeVariables*>(ali->alignmentParameters()->userVariables());
100  myNumPar = mpVar->size();
101  if (myNumPar >= kMaxNumPar) {
102  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::writeOne"
103  << "Ignoring parameters " << static_cast<int>(kMaxNumPar) << " to " << myNumPar-1;
105  }
106 
107  for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
108  myIsValid[iPar] = mpVar->isValid()[iPar];
109  myDiffBefore[iPar] = mpVar->diffBefore()[iPar];
110  myGlobalCor[iPar] = mpVar->globalCor()[iPar];
111  myPreSigma[iPar] = mpVar->preSigma()[iPar];
112  myParameter[iPar] = mpVar->parameter()[iPar];
113  mySigma[iPar] = mpVar->sigma()[iPar];
114  }
115  myHitsX = mpVar->hitsX();
116  myHitsY = mpVar->hitsY();
117  myLabel = mpVar->label();
118 
119  myId = ali->id();
120  myObjId = ali->alignableObjectId();
121 
122  tree->Fill();
123 
124  return 0;
125 }
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:185
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
Float_t MillePedeVariablesIORoot::myGlobalCor[kMaxNumPar]
private
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
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
Float_t MillePedeVariablesIORoot::myPreSigma[kMaxNumPar]
private
Float_t MillePedeVariablesIORoot::mySigma[kMaxNumPar]
private