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
const static int itermax = 1000
 
const static 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

anonymous enum
private
Enumerator
kMaxNumPar 

Definition at line 67 of file MillePedeVariablesIORoot.h.

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

Constructor & Destructor Documentation

◆ MillePedeVariablesIORoot()

MillePedeVariablesIORoot::MillePedeVariablesIORoot ( )

Definition at line 20 of file MillePedeVariablesIORoot.cc.

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

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

◆ ~MillePedeVariablesIORoot()

MillePedeVariablesIORoot::~MillePedeVariablesIORoot ( )
inlineoverride

Definition at line 32 of file MillePedeVariablesIORoot.h.

32 {}

Member Function Documentation

◆ close()

int MillePedeVariablesIORoot::close ( void  )
inlineoverrideprotectedvirtual

close IO

Implements AlignmentUserVariablesIO.

Definition at line 58 of file MillePedeVariablesIORoot.h.

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

References AlignmentIORootBase::closeRoot().

Referenced by esMonitoring.AsyncLineReaderMixin::handle_close(), esMonitoring.FDJsonServer::handle_close(), readMillePedeVariables(), and writeMillePedeVariables().

◆ createBranches()

void MillePedeVariablesIORoot::createBranches ( void  )
overrideprotectedvirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 149 of file MillePedeVariablesIORoot.cc.

149  {
150  tree->Branch("Id", &myId, "Id/i");
151  tree->Branch("ObjId", &myObjId, "ObjId/I");
152  tree->Branch("NumPar", &myNumPar, "NumPar/i");
153  tree->Branch("IsValid", myIsValid, "IsValid[NumPar]/b");
154  tree->Branch("DiffBefore", myDiffBefore, "DiffBefore[NumPar]/F");
155  tree->Branch("GlobalCor", myGlobalCor, "GlobalCor[NumPar]/F");
156  tree->Branch("PreSigma", myPreSigma, "PreSigma[NumPar]/F");
157  tree->Branch("Par", myParameter, "Par[NumPar]/F"); // name as in AlignmentParametersIORoot
158  tree->Branch("Sigma", mySigma, "Sigma[NumPar]/F");
159  tree->Branch("HitsX", &myHitsX, "HitsX/i");
160  tree->Branch("HitsY", &myHitsY, "HitsY/i");
161  tree->Branch("Label", &myLabel, "Label/i");
162  tree->Branch("Name", &myNamePtr);
163 }

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

◆ open()

int MillePedeVariablesIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
)
inlineoverrideprotectedvirtual

open IO

Implements AlignmentUserVariablesIO.

Definition at line 53 of file MillePedeVariablesIORoot.h.

53  {
54  return this->openRoot(filename, iteration, writemode);
55  }

References align_cfg::iteration, and AlignmentIORootBase::openRoot().

Referenced by readMillePedeVariables(), and writeMillePedeVariables().

◆ readMillePedeVariables()

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

62  {
63  std::vector<AlignmentUserVariables *> result;
64  ierr = 0;
65  int iret = this->open(filename, iter, false);
66  if (iret != 0) {
67  ierr = -1;
68  } else {
69  result = this->read(alivec, iret);
70  if (iret != 0) {
71  ierr = -2;
72  } else {
73  iret = this->close();
74  if (iret != 0) {
75  ierr = -3;
76  }
77  }
78  }
79 
80  return result;
81 }

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

Referenced by MillePedeAlignmentAlgorithm::addHitStatistics().

◆ readOne()

AlignmentUserVariables * MillePedeVariablesIORoot::readOne ( Alignable ali,
int &  ierr 
)
overrideprotectedvirtual

read MillePedeVariables belonging to one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 122 of file MillePedeVariablesIORoot.cc.

122  {
123  ierr = 0;
124 
125  if (tree->GetEntryWithIndex(ali->id(), ali->alignableObjectId()) < 0) {
126  edm::LogError("Alignment") << "@SUB=MillePedeVariablesIORoot::readOne"
127  << "No index for id/type = (" << ali->id() << "/" << ali->alignableObjectId()
128  << ") found!";
129  ierr = 1;
130  return nullptr;
131  }
132 
134  for (unsigned int iPar = 0; iPar < myNumPar; ++iPar) {
135  mpVar->isValid()[iPar] = myIsValid[iPar];
136  mpVar->diffBefore()[iPar] = myDiffBefore[iPar];
137  mpVar->globalCor()[iPar] = myGlobalCor[iPar];
138  mpVar->preSigma()[iPar] = myPreSigma[iPar];
139  mpVar->parameter()[iPar] = myParameter[iPar];
140  mpVar->sigma()[iPar] = mySigma[iPar];
141  }
142  mpVar->setHitsX(myHitsX);
143  mpVar->setHitsY(myHitsY);
144 
145  return mpVar;
146 }

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

◆ setBranchAddresses()

void MillePedeVariablesIORoot::setBranchAddresses ( void  )
overrideprotectedvirtual

set root branche addresses

Implements AlignmentIORootBase.

Definition at line 166 of file MillePedeVariablesIORoot.cc.

166  {
167  tree->SetBranchAddress("Id", &myId);
168  tree->SetBranchAddress("ObjId", &myObjId);
169  tree->SetBranchAddress("NumPar", &myNumPar);
170  tree->SetBranchAddress("IsValid", myIsValid);
171  tree->SetBranchAddress("DiffBefore", myDiffBefore);
172  tree->SetBranchAddress("GlobalCor", myGlobalCor);
173  tree->SetBranchAddress("PreSigma", myPreSigma);
174  tree->SetBranchAddress("Par", myParameter);
175  tree->SetBranchAddress("Sigma", mySigma);
176  tree->SetBranchAddress("HitsX", &myHitsX);
177  tree->SetBranchAddress("HitsY", &myHitsY);
178  tree->SetBranchAddress("Label", &myLabel);
179  tree->SetBranchAddress("Name", &myNamePtr);
180 }

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

◆ writeMillePedeVariables()

void MillePedeVariablesIORoot::writeMillePedeVariables ( const align::Alignables alivec,
const char *  filename,
int  iter,
bool  validCheck,
int &  ierr 
)

write user variables

Definition at line 35 of file MillePedeVariablesIORoot.cc.

36  {
37  ierr = 0;
38 
39  int iret = this->open(filename, iter, true);
40  if (iret != 0) {
41  ierr = -1;
42  } else {
43  iret = this->write(alivec, validCheck);
44  tree->BuildIndex("Id", "ObjId");
45  if (iret != 0) {
46  ierr = -2;
47  } else {
48  iret = this->close();
49  if (iret != 0) {
50  ierr = -3;
51  }
52  }
53  }
54 
55  return;
56 }

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

Referenced by MillePedeAlignmentAlgorithm::doIO().

◆ writeOne()

int MillePedeVariablesIORoot::writeOne ( Alignable ali)
overrideprotectedvirtual

write MillePedeVariables attached to AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 84 of file MillePedeVariablesIORoot.cc.

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

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

Member Data Documentation

◆ myDiffBefore

Float_t MillePedeVariablesIORoot::myDiffBefore[kMaxNumPar]
private

◆ myGlobalCor

Float_t MillePedeVariablesIORoot::myGlobalCor[kMaxNumPar]
private

◆ myHitsX

UInt_t MillePedeVariablesIORoot::myHitsX
private

Definition at line 79 of file MillePedeVariablesIORoot.h.

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

◆ myHitsY

UInt_t MillePedeVariablesIORoot::myHitsY
private

Definition at line 80 of file MillePedeVariablesIORoot.h.

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

◆ myId

unsigned int MillePedeVariablesIORoot::myId
private

Definition at line 69 of file MillePedeVariablesIORoot.h.

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

◆ myIsValid

Byte_t MillePedeVariablesIORoot::myIsValid[kMaxNumPar]
private

◆ myLabel

UInt_t MillePedeVariablesIORoot::myLabel
private

Definition at line 81 of file MillePedeVariablesIORoot.h.

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

◆ myName

std::string MillePedeVariablesIORoot::myName
private

Definition at line 82 of file MillePedeVariablesIORoot.h.

Referenced by readOne(), and writeOne().

◆ myNamePtr

std::string* MillePedeVariablesIORoot::myNamePtr
private

Definition at line 83 of file MillePedeVariablesIORoot.h.

Referenced by createBranches(), and setBranchAddresses().

◆ myNumPar

unsigned int MillePedeVariablesIORoot::myNumPar
private

Definition at line 72 of file MillePedeVariablesIORoot.h.

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

◆ myObjId

int MillePedeVariablesIORoot::myObjId
private

Definition at line 70 of file MillePedeVariablesIORoot.h.

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

◆ myParameter

Float_t MillePedeVariablesIORoot::myParameter[kMaxNumPar]
private

◆ myPreSigma

Float_t MillePedeVariablesIORoot::myPreSigma[kMaxNumPar]
private

◆ mySigma

Float_t MillePedeVariablesIORoot::mySigma[kMaxNumPar]
private
AlignmentIORootBase::closeRoot
int closeRoot(void)
close IO
Definition: AlignmentIORootBase.cc:92
MillePedeVariablesIORoot::myId
unsigned int myId
Definition: MillePedeVariablesIORoot.h:69
MillePedeVariables::setHitsY
void setHitsY(unsigned int hitsY)
Definition: MillePedeVariables.h:85
MillePedeVariablesIORoot::myObjId
int myObjId
Definition: MillePedeVariablesIORoot.h:70
mps_fire.i
i
Definition: mps_fire.py:428
MillePedeVariablesIORoot::close
int close() override
Definition: MillePedeVariablesIORoot.h:58
MillePedeVariablesIORoot::myIsValid
Byte_t myIsValid[kMaxNumPar]
Definition: MillePedeVariablesIORoot.h:73
MillePedeVariables::setHitsX
void setHitsX(unsigned int hitsX)
Definition: MillePedeVariables.h:79
MillePedeVariablesIORoot::myGlobalCor
Float_t myGlobalCor[kMaxNumPar]
Definition: MillePedeVariablesIORoot.h:75
MillePedeVariablesIORoot::kMaxNumPar
Definition: MillePedeVariablesIORoot.h:67
MillePedeVariablesIORoot::myName
std::string myName
Definition: MillePedeVariablesIORoot.h:82
tree
Definition: tree.py:1
MillePedeVariablesIORoot::myParameter
Float_t myParameter[kMaxNumPar]
Definition: MillePedeVariablesIORoot.h:77
AlignmentIORootBase::treename
TString treename
Definition: AlignmentIORootBase.h:39
AlignmentParameters::userVariables
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
Definition: AlignmentParameters.cc:101
AlignmentIORootBase::treetxt
TString treetxt
Definition: AlignmentIORootBase.h:40
MillePedeVariables::hitsY
unsigned int hitsY() const
get number of hits for y-measurement
Definition: MillePedeVariables.h:82
MillePedeVariablesIORoot::myLabel
UInt_t myLabel
Definition: MillePedeVariablesIORoot.h:81
MillePedeVariables::size
unsigned int size() const
number of parameters
Definition: MillePedeVariables.h:33
MillePedeVariables::label
unsigned int label() const
get alignable label as used by pede
Definition: MillePedeVariables.h:66
MillePedeVariables::isValid
const std::vector< bool > & isValid() const
get valid flag array
Definition: MillePedeVariables.h:36
MillePedeVariablesIORoot::myDiffBefore
Float_t myDiffBefore[kMaxNumPar]
Definition: MillePedeVariablesIORoot.h:74
Alignable::alignableObjectId
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
MillePedeVariables::hitsX
unsigned int hitsX() const
get number of hits for x-measurement
Definition: MillePedeVariables.h:76
AlignmentUserVariablesIO::write
int write(const align::Alignables &alivec, bool validCheck)
Definition: AlignmentUserVariablesIO.cc:19
Alignable::id
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
Definition: Alignable.h:180
MillePedeVariables::preSigma
const std::vector< float > & preSigma() const
get array of presigmas (<= 0: means fixed)
Definition: MillePedeVariables.h:51
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
MillePedeVariables::diffBefore
const std::vector< float > & diffBefore() const
get array of differences to start value
Definition: MillePedeVariables.h:41
MillePedeVariablesIORoot::open
int open(const char *filename, int iteration, bool writemode) override
Definition: MillePedeVariablesIORoot.h:53
MillePedeVariablesIORoot::myPreSigma
Float_t myPreSigma[kMaxNumPar]
Definition: MillePedeVariablesIORoot.h:76
MillePedeVariablesIORoot::myHitsX
UInt_t myHitsX
Definition: MillePedeVariablesIORoot.h:79
MillePedeVariablesIORoot::myNamePtr
std::string * myNamePtr
Definition: MillePedeVariablesIORoot.h:83
MillePedeVariables::parameter
const std::vector< float > & parameter() const
get array of parameters
Definition: MillePedeVariables.h:61
AlignmentIORootBase::openRoot
int openRoot(const char *filename, int iteration, bool writemode)
open IO
Definition: AlignmentIORootBase.cc:16
MillePedeVariablesIORoot::myHitsY
UInt_t myHitsY
Definition: MillePedeVariablesIORoot.h:80
MillePedeVariables::sigma
const std::vector< float > & sigma() const
get array of sigmas
Definition: MillePedeVariables.h:56
MillePedeVariables::globalCor
const std::vector< float > & globalCor() const
get global correlation array
Definition: MillePedeVariables.h:46
mps_fire.result
result
Definition: mps_fire.py:311
MillePedeVariables
Definition: MillePedeVariables.h:21
MillePedeVariablesIORoot::mySigma
Float_t mySigma[kMaxNumPar]
Definition: MillePedeVariablesIORoot.h:78
align_cfg.iteration
iteration
Definition: align_cfg.py:5
Alignable::alignmentParameters
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
MillePedeVariablesIORoot::myNumPar
unsigned int myNumPar
Definition: MillePedeVariablesIORoot.h:72
MillePedeVariables::name
const std::string & name() const
get alignable name
Definition: MillePedeVariables.h:71
AlignmentUserVariablesIO::read
std::vector< AlignmentUserVariables * > read(const align::Alignables &alivec, int &ierr)
Definition: AlignmentUserVariablesIO.cc:37