CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
HIPUserVariablesIORoot Class Reference

#include <HIPUserVariablesIORoot.h>

Inheritance diagram for HIPUserVariablesIORoot:
AlignmentIORootBase AlignmentUserVariablesIO

Public Types

using Alignables = align::Alignables
 

Public Member Functions

 HIPUserVariablesIORoot ()
 
std::vector< AlignmentUserVariables * > readHIPUserVariables (const Alignables &alivec, const char *filename, int iter, int &ierr)
 
void writeHIPUserVariables (const Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
 

Private Types

typedef std::map< std::pair< int, int >, int > treemaptype
 

Private Member Functions

int close (void) override
 
void createBranches (void) override
 create root branches More...
 
int findEntry (unsigned int detId, int comp)
 
int open (const char *filename, int iteration, bool writemode) override
 
AlignmentUserVariablesreadOne (Alignable *ali, int &ierr) override
 
void setBranchAddresses (void) override
 set root branches More...
 
int writeOne (Alignable *ali) override
 

Private Attributes

double AlignableChi2
 
unsigned int AlignableNdof
 
int DataType
 
unsigned int Id
 
double Jtve [nparmax]
 
double Jtvj [nparmax *(nparmax+1)/2]
 
bool newopen
 
int Nhit
 
int Npare
 
int Nparj
 
int ObjId
 
double Par [nparmax]
 
double ParError [nparmax]
 
treemaptype treemap
 

Static Private Attributes

static const int nparmax =19
 

Additional Inherited Members

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

concrete class for ROOT based IO of AlignmentUserVariables

Definition at line 10 of file HIPUserVariablesIORoot.h.

Member Typedef Documentation

Definition at line 12 of file HIPUserVariablesIORoot.h.

typedef std::map< std::pair<int, int>, int > HIPUserVariablesIORoot::treemaptype
private

Definition at line 61 of file HIPUserVariablesIORoot.h.

Constructor & Destructor Documentation

HIPUserVariablesIORoot::HIPUserVariablesIORoot ( )

constructor

Definition at line 16 of file HIPUserVariablesIORoot.cc.

References mps_fire::i, Jtve, Jtvj, nparmax, Par, ParError, AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.

16  :
17 ObjId(0), Id(0), Nhit(0), Nparj(0), Npare(0),
18 DataType(-1),
20 {
21  treename = "T9";
22  treetxt = "HIP User Variables";
23 
24  for (int i=0; i<nparmax*(nparmax+1)/2; ++i) Jtvj[i] = 0.;
25  for (int i=0; i<nparmax; ++i){
26  Jtve[i] = 0.;
27  Par[i] = 0.;
28  ParError[i] = 0.;
29  }
30 }
double Jtvj[nparmax *(nparmax+1)/2]

Member Function Documentation

int HIPUserVariablesIORoot::close ( void  )
inlineoverrideprivatevirtual
void HIPUserVariablesIORoot::createBranches ( void  )
overrideprivatevirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 34 of file HIPUserVariablesIORoot.cc.

References AlignableChi2, AlignableNdof, DataType, Id, Jtve, Jtvj, Nhit, Npare, Nparj, ObjId, Par, and ParError.

Referenced by close().

34  {
35  tree->Branch("Id", &Id, "Id/i");
36  tree->Branch("ObjId", &ObjId, "ObjId/I");
37 
38  tree->Branch("Nhit", &Nhit, "Nhit/I");
39  tree->Branch("DataType", &DataType, "DataType/I");
40  tree->Branch("Nparj", &Nparj, "Nparj/I");
41  tree->Branch("Jtvj", &Jtvj, "Jtvj[Nparj]/D");
42  tree->Branch("Npare", &Npare, "Npare/I");
43  tree->Branch("Jtve", &Jtve, "Jtve[Npare]/D");
44  tree->Branch("AlignableChi2", &AlignableChi2, "AlignableChi2/D");
45  tree->Branch("AlignableNdof", &AlignableNdof, "AlignableNdof/i");
46  tree->Branch("Par", &Par, "Par[Npare]/D");
47  tree->Branch("ParError", &ParError, "ParError[Npare]/D");
48 }
double Jtvj[nparmax *(nparmax+1)/2]
Definition: tree.py:1
int HIPUserVariablesIORoot::findEntry ( unsigned int  detId,
int  comp 
)
private

Definition at line 71 of file HIPUserVariablesIORoot.cc.

References ev, Id, newopen, ObjId, mps_fire::result, and treemap.

Referenced by close(), QGLikelihoodCalculator.QGLikelihoodCalculator::computeQGLikelihood(), and readOne().

71  {
72  if (newopen) { // we're here for the first time
73  edm::LogInfo("Alignment") << "[HIPUserVariablesIORoot::findEntry] fill map ...";
74  treemap.erase(treemap.begin(), treemap.end());
75  for (int ev = 0; ev<tree->GetEntries(); ev++){
76  tree->GetEntry(ev);
77  treemap[std::make_pair(Id, ObjId)]=ev;
78  }
79  newopen=false;
80  }
81 
82  // now we have filled the map
83  treemaptype::iterator imap = treemap.find(std::make_pair(detId, comp));
84  int result=-1;
85  if (imap != treemap.end()) result=(*imap).second;
86  return result;
87 
88 
89  //double noAliPar = tree->GetEntries();
90  //for (int ev = 0;ev<noAliPar;ev++) {
91  // tree->GetEntry(ev);
92  // if(Id==detId&&comp==ObjId) return (ev);
93  //}
94  //return(-1);
95 }
bool ev
Definition: tree.py:1
int HIPUserVariablesIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
)
inlineoverrideprivatevirtual
std::vector< AlignmentUserVariables * > HIPUserVariablesIORoot::readHIPUserVariables ( const Alignables alivec,
const char *  filename,
int  iter,
int &  ierr 
)

read user variables

Definition at line 203 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::collector().

206  {
207  std::vector<AlignmentUserVariables*> result;
208  ierr=0;
209  int iret;
210  iret = open(filename, iter, false);
211  if (iret!=0) { ierr=-1; return result; }
212  result = read(alivec, iret);
213  if (iret!=0) { ierr=-2; return result; }
214  iret = close();
215  if (iret!=0) { ierr=-3; return result; }
216 
217  return result;
218 }
std::vector< AlignmentUserVariables * > read(const align::Alignables &alivec, int &ierr)
int open(const char *filename, int iteration, bool writemode) override
AlignmentUserVariables * HIPUserVariablesIORoot::readOne ( Alignable ali,
int &  ierr 
)
overrideprivatevirtual

read AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 143 of file HIPUserVariablesIORoot.cc.

References HIPUserVariables::alichi2, HIPUserVariables::alierr, AlignableChi2, AlignableNdof, Alignable::alignableObjectId(), HIPUserVariables::alindof, HIPUserVariables::alipar, cuy::col, KineDebug3::count(), HIPUserVariables::datatype, DataType, mps_splice::entry, findEntry(), Alignable::id(), HIPUserVariables::jtve, Jtve, HIPUserVariables::jtvj, Jtvj, HIPUserVariables::nhit, Nhit, np, Npare, Par, and ParError.

143  {
144  ierr=0;
145  HIPUserVariables* uvar;
146 
147  int entry = findEntry(ali->id(), ali->alignableObjectId());
148  if (entry!=-1){
149  tree->GetEntry(entry);
150 
151  int np=Npare;
152  AlgebraicVector jtve(np, 0);
153  AlgebraicSymMatrix jtvj(np, 0);
154  AlgebraicVector alipar(np, 0);
155  AlgebraicVector alierr(np, 0);
156  int count=0;
157  for (int row=0; row<np; row++){
158  jtve[row]=Jtve[row];
159  alipar[row]=Par[row];
160  alierr[row]=ParError[row];
161  for (int col=row; col < np; col++){
162  jtvj[row][col]=Jtvj[count];
163  count++;
164  }
165  }
166 
167  uvar = new HIPUserVariables(np);
168  uvar->jtvj=jtvj;
169  uvar->jtve=jtve;
170  uvar->nhit=Nhit;
171  uvar->datatype=DataType;
172  uvar->alipar=alipar;
173  uvar->alierr=alierr;
174  //Chi2n
175  uvar->alichi2=AlignableChi2;
176  uvar->alindof=AlignableNdof;
177 
178  return uvar;
179  }
180 
181  // ierr=-1;
182  return nullptr;
183 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
int findEntry(unsigned int detId, int comp)
AlgebraicVector alipar
AlgebraicVector jtve
AlgebraicSymMatrix jtvj
int np
Definition: AMPTWrapper.h:33
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlgebraicVector alierr
double Jtvj[nparmax *(nparmax+1)/2]
CLHEP::HepVector AlgebraicVector
col
Definition: cuy.py:1008
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: tree.py:1
void HIPUserVariablesIORoot::setBranchAddresses ( void  )
overrideprivatevirtual

set root branches

Implements AlignmentIORootBase.

Definition at line 52 of file HIPUserVariablesIORoot.cc.

References AlignableChi2, AlignableNdof, DataType, Id, Jtve, Jtvj, Nhit, Npare, Nparj, ObjId, Par, and ParError.

Referenced by close().

52  {
53  tree->SetBranchAddress("Id", &Id);
54  tree->SetBranchAddress("ObjId", &ObjId);
55 
56  tree->SetBranchAddress("Nhit", &Nhit);
57  tree->SetBranchAddress("DataType", &DataType);
58  tree->SetBranchAddress("Nparj", &Nparj);
59  tree->SetBranchAddress("Jtvj", &Jtvj);
60  tree->SetBranchAddress("Npare", &Npare);
61  tree->SetBranchAddress("Jtve", &Jtve);
62  tree->SetBranchAddress("AlignableChi2", &AlignableChi2);
63  tree->SetBranchAddress("AlignableNdof", &AlignableNdof);
64  tree->SetBranchAddress("Par", &Par);
65  tree->SetBranchAddress("ParError", &ParError);
66 }
double Jtvj[nparmax *(nparmax+1)/2]
Definition: tree.py:1
void HIPUserVariablesIORoot::writeHIPUserVariables ( const Alignables alivec,
const char *  filename,
int  iter,
bool  validCheck,
int &  ierr 
)

write user variables

Definition at line 187 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::terminate().

190  {
191  ierr=0;
192  int iret;
193  iret = open(filename, iter, true);
194  if (iret!=0) { ierr=-1; return; }
195  iret = write(alivec, validCheck);
196  if (iret!=0) { ierr=-2; return; }
197  iret = close();
198  if (iret!=0) { ierr=-3; return; }
199 }
int write(const align::Alignables &alivec, bool validCheck)
int open(const char *filename, int iteration, bool writemode) override
int HIPUserVariablesIORoot::writeOne ( Alignable ali)
overrideprivatevirtual

write AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 99 of file HIPUserVariablesIORoot.cc.

References HIPUserVariables::alichi2, HIPUserVariables::alierr, AlignableChi2, AlignableNdof, Alignable::alignableObjectId(), Alignable::alignmentParameters(), HIPUserVariables::alindof, HIPUserVariables::alipar, cuy::col, KineDebug3::count(), HIPUserVariables::datatype, DataType, Id, Alignable::id(), HIPUserVariables::jtve, Jtve, HIPUserVariables::jtvj, Jtvj, HIPUserVariables::nhit, Nhit, np, Npare, Nparj, ObjId, Par, ParError, and AlignmentParameters::userVariables().

99  {
101 
102  if ((ap->userVariables())==nullptr){
103  edm::LogError("Alignment") << "UserVariables not found!";
104  return -1;
105  }
106 
107  HIPUserVariables* uvar = dynamic_cast<HIPUserVariables*>(ap->userVariables());
108 
109  AlgebraicSymMatrix jtvj = uvar->jtvj;
110  AlgebraicVector jtve = uvar->jtve;
111  AlgebraicVector alipar = uvar->alipar;
112  AlgebraicVector alierr = uvar->alierr;
113  int nhit=uvar->nhit;
114  int datatype=uvar->datatype;
115  int np=jtve.num_row();
116 
117  Nhit=nhit;
118  DataType=datatype;
119  Npare=np;
120  Nparj=np*(np+1)/2;
121  int count=0;
122  for (int row=0; row<np; row++){
123  Jtve[row]=jtve[row];
124  Par[row]=alipar[row];
125  ParError[row]=alierr[row];
126  for (int col=row; col<np; col++){
127  Jtvj[count]=jtvj[row][col];
128  count++;
129  }
130  }
131  Id = ali->id();
132  ObjId = ali->alignableObjectId();
133 
134  //Chi^2 of alignable
135  AlignableChi2= uvar->alichi2;
136  AlignableNdof= uvar->alindof;
137  tree->Fill();
138  return 0;
139 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
AlgebraicVector alipar
AlgebraicVector jtve
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
AlgebraicSymMatrix jtvj
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
int np
Definition: AMPTWrapper.h:33
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlgebraicVector alierr
double Jtvj[nparmax *(nparmax+1)/2]
CLHEP::HepVector AlgebraicVector
col
Definition: cuy.py:1008
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: tree.py:1

Member Data Documentation

double HIPUserVariablesIORoot::AlignableChi2
private

Definition at line 55 of file HIPUserVariablesIORoot.h.

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

unsigned int HIPUserVariablesIORoot::AlignableNdof
private

Definition at line 56 of file HIPUserVariablesIORoot.h.

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

int HIPUserVariablesIORoot::DataType
private

Definition at line 52 of file HIPUserVariablesIORoot.h.

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

unsigned int HIPUserVariablesIORoot::Id
private

Definition at line 50 of file HIPUserVariablesIORoot.h.

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

double HIPUserVariablesIORoot::Jtve[nparmax]
private
double HIPUserVariablesIORoot::Jtvj[nparmax *(nparmax+1)/2]
private
bool HIPUserVariablesIORoot::newopen
private

Definition at line 60 of file HIPUserVariablesIORoot.h.

Referenced by findEntry(), and open().

int HIPUserVariablesIORoot::Nhit
private

Definition at line 51 of file HIPUserVariablesIORoot.h.

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

int HIPUserVariablesIORoot::Npare
private

Definition at line 51 of file HIPUserVariablesIORoot.h.

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

int HIPUserVariablesIORoot::Nparj
private

Definition at line 51 of file HIPUserVariablesIORoot.h.

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

const int HIPUserVariablesIORoot::nparmax =19
staticprivate

Definition at line 46 of file HIPUserVariablesIORoot.h.

Referenced by HIPUserVariablesIORoot().

int HIPUserVariablesIORoot::ObjId
private

alignment parameter tree

Definition at line 49 of file HIPUserVariablesIORoot.h.

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

double HIPUserVariablesIORoot::Par[nparmax]
private
double HIPUserVariablesIORoot::ParError[nparmax]
private
treemaptype HIPUserVariablesIORoot::treemap
private

Definition at line 62 of file HIPUserVariablesIORoot.h.

Referenced by findEntry().