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

◆ Alignables

Definition at line 12 of file HIPUserVariablesIORoot.h.

◆ treemaptype

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

Definition at line 65 of file HIPUserVariablesIORoot.h.

Constructor & Destructor Documentation

◆ HIPUserVariablesIORoot()

HIPUserVariablesIORoot::HIPUserVariablesIORoot ( )

constructor

Definition at line 15 of file HIPUserVariablesIORoot.cc.

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

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

Member Function Documentation

◆ close()

int HIPUserVariablesIORoot::close ( void  )
inlineoverrideprivatevirtual

◆ createBranches()

void HIPUserVariablesIORoot::createBranches ( void  )
overrideprivatevirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 31 of file HIPUserVariablesIORoot.cc.

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

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

◆ findEntry()

int HIPUserVariablesIORoot::findEntry ( unsigned int  detId,
int  comp 
)
private

Definition at line 68 of file HIPUserVariablesIORoot.cc.

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

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

68  {
69  if (newopen) { // we're here for the first time
70  edm::LogInfo("Alignment") << "[HIPUserVariablesIORoot::findEntry] fill map ...";
71  treemap.erase(treemap.begin(), treemap.end());
72  for (int ev = 0; ev < tree->GetEntries(); ev++) {
73  tree->GetEntry(ev);
74  treemap[std::make_pair(Id, ObjId)] = ev;
75  }
76  newopen = false;
77  }
78 
79  // now we have filled the map
80  treemaptype::iterator imap = treemap.find(std::make_pair(detId, comp));
81  int result = -1;
82  if (imap != treemap.end())
83  result = (*imap).second;
84  return result;
85 
86  //double noAliPar = tree->GetEntries();
87  //for (int ev = 0;ev<noAliPar;ev++) {
88  // tree->GetEntry(ev);
89  // if(Id==detId&&comp==ObjId) return (ev);
90  //}
91  //return(-1);
92 }
Log< level::Info, false > LogInfo
Definition: tree.py:1

◆ open()

int HIPUserVariablesIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
)
inlineoverrideprivatevirtual

open IO

Implements AlignmentUserVariablesIO.

Definition at line 34 of file HIPUserVariablesIORoot.h.

References corrVsCorr::filename, align_cfg::iteration, newopen, and AlignmentIORootBase::openRoot().

Referenced by readHIPUserVariables(), and writeHIPUserVariables().

34  {
35  newopen = true;
36  return openRoot(filename, iteration, writemode);
37  }
int openRoot(const char *filename, int iteration, bool writemode)
open IO

◆ readHIPUserVariables()

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

read user variables

Definition at line 207 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::collector().

210  {
211  std::vector<AlignmentUserVariables*> result;
212  ierr = 0;
213  int iret;
214  iret = open(filename, iter, false);
215  if (iret != 0) {
216  ierr = -1;
217  return result;
218  }
219  result = read(alivec, iret);
220  if (iret != 0) {
221  ierr = -2;
222  return result;
223  }
224  iret = close();
225  if (iret != 0) {
226  ierr = -3;
227  return result;
228  }
229 
230  return result;
231 }
std::vector< AlignmentUserVariables * > read(const align::Alignables &alivec, int &ierr)
int open(const char *filename, int iteration, bool writemode) override

◆ readOne()

AlignmentUserVariables * HIPUserVariablesIORoot::readOne ( Alignable ali,
int &  ierr 
)
overrideprivatevirtual

read AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 140 of file HIPUserVariablesIORoot.cc.

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

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

◆ setBranchAddresses()

void HIPUserVariablesIORoot::setBranchAddresses ( void  )
overrideprivatevirtual

set root branches

Implements AlignmentIORootBase.

Definition at line 49 of file HIPUserVariablesIORoot.cc.

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

49  {
50  tree->SetBranchAddress("Id", &Id);
51  tree->SetBranchAddress("ObjId", &ObjId);
52 
53  tree->SetBranchAddress("Nhit", &Nhit);
54  tree->SetBranchAddress("DataType", &DataType);
55  tree->SetBranchAddress("Nparj", &Nparj);
56  tree->SetBranchAddress("Jtvj", &Jtvj);
57  tree->SetBranchAddress("Npare", &Npare);
58  tree->SetBranchAddress("Jtve", &Jtve);
59  tree->SetBranchAddress("AlignableChi2", &AlignableChi2);
60  tree->SetBranchAddress("AlignableNdof", &AlignableNdof);
61  tree->SetBranchAddress("Par", &Par);
62  tree->SetBranchAddress("ParError", &ParError);
63 }
double Jtvj[nparmax *(nparmax+1)/2]
Definition: tree.py:1

◆ writeHIPUserVariables()

void HIPUserVariablesIORoot::writeHIPUserVariables ( const Alignables alivec,
const char *  filename,
int  iter,
bool  validCheck,
int &  ierr 
)

write user variables

Definition at line 184 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::terminate().

185  {
186  ierr = 0;
187  int iret;
188  iret = open(filename, iter, true);
189  if (iret != 0) {
190  ierr = -1;
191  return;
192  }
193  iret = write(alivec, validCheck);
194  if (iret != 0) {
195  ierr = -2;
196  return;
197  }
198  iret = close();
199  if (iret != 0) {
200  ierr = -3;
201  return;
202  }
203 }
int write(const align::Alignables &alivec, bool validCheck)
int open(const char *filename, int iteration, bool writemode) override

◆ writeOne()

int HIPUserVariablesIORoot::writeOne ( Alignable ali)
overrideprivatevirtual

write AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 96 of file HIPUserVariablesIORoot.cc.

References HIPUserVariables::alichi2, HIPUserVariables::alierr, AlignableChi2, AlignableNdof, Alignable::alignableObjectId(), Alignable::alignmentParameters(), HIPUserVariables::alindof, HIPUserVariables::alipar, cuy::col, submitPVResolutionJobs::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().

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

Member Data Documentation

◆ AlignableChi2

double HIPUserVariablesIORoot::AlignableChi2
private

Definition at line 59 of file HIPUserVariablesIORoot.h.

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

◆ AlignableNdof

unsigned int HIPUserVariablesIORoot::AlignableNdof
private

Definition at line 60 of file HIPUserVariablesIORoot.h.

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

◆ DataType

int HIPUserVariablesIORoot::DataType
private

Definition at line 56 of file HIPUserVariablesIORoot.h.

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

◆ Id

unsigned int HIPUserVariablesIORoot::Id
private

Definition at line 54 of file HIPUserVariablesIORoot.h.

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

◆ Jtve

double HIPUserVariablesIORoot::Jtve[nparmax]
private

◆ Jtvj

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

◆ newopen

bool HIPUserVariablesIORoot::newopen
private

Definition at line 64 of file HIPUserVariablesIORoot.h.

Referenced by findEntry(), and open().

◆ Nhit

int HIPUserVariablesIORoot::Nhit
private

Definition at line 55 of file HIPUserVariablesIORoot.h.

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

◆ Npare

int HIPUserVariablesIORoot::Npare
private

Definition at line 55 of file HIPUserVariablesIORoot.h.

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

◆ Nparj

int HIPUserVariablesIORoot::Nparj
private

Definition at line 55 of file HIPUserVariablesIORoot.h.

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

◆ nparmax

const int HIPUserVariablesIORoot::nparmax = 19
staticprivate

Definition at line 50 of file HIPUserVariablesIORoot.h.

Referenced by HIPUserVariablesIORoot().

◆ ObjId

int HIPUserVariablesIORoot::ObjId
private

alignment parameter tree

Definition at line 53 of file HIPUserVariablesIORoot.h.

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

◆ Par

double HIPUserVariablesIORoot::Par[nparmax]
private

◆ ParError

double HIPUserVariablesIORoot::ParError[nparmax]
private

◆ treemap

treemaptype HIPUserVariablesIORoot::treemap
private

Definition at line 66 of file HIPUserVariablesIORoot.h.

Referenced by findEntry().