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

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 }

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

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.

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 }

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

◆ findEntry()

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

Definition at line 68 of file HIPUserVariablesIORoot.cc.

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 }

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

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

◆ open()

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

open IO

Implements AlignmentUserVariablesIO.

Definition at line 34 of file HIPUserVariablesIORoot.h.

34  {
35  newopen = true;
36  return openRoot(filename, iteration, writemode);
37  }

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

Referenced by readHIPUserVariables(), and writeHIPUserVariables().

◆ 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.

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 }

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

Referenced by HIPAlignmentAlgorithm::collector().

◆ readOne()

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

read AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 140 of file HIPUserVariablesIORoot.cc.

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 }

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.

◆ setBranchAddresses()

void HIPUserVariablesIORoot::setBranchAddresses ( void  )
overrideprivatevirtual

set root branches

Implements AlignmentIORootBase.

Definition at line 49 of file HIPUserVariablesIORoot.cc.

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 }

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

◆ 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.

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 }

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

Referenced by HIPAlignmentAlgorithm::terminate().

◆ writeOne()

int HIPUserVariablesIORoot::writeOne ( Alignable ali)
overrideprivatevirtual

write AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 96 of file HIPUserVariablesIORoot.cc.

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 }

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

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

AlignmentIORootBase::closeRoot
int closeRoot(void)
close IO
Definition: AlignmentIORootBase.cc:92
HIPUserVariablesIORoot::Nparj
int Nparj
Definition: HIPUserVariablesIORoot.h:55
AlCaHLTBitMon_QueryRunRegistry.comp
string comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
HIPUserVariablesIORoot::AlignableNdof
unsigned int AlignableNdof
Definition: HIPUserVariablesIORoot.h:60
mps_fire.i
i
Definition: mps_fire.py:428
HIPUserVariablesIORoot::Jtve
double Jtve[nparmax]
Definition: HIPUserVariablesIORoot.h:58
HIPUserVariablesIORoot::Jtvj
double Jtvj[nparmax *(nparmax+1)/2]
Definition: HIPUserVariablesIORoot.h:57
HIPUserVariablesIORoot::Id
unsigned int Id
Definition: HIPUserVariablesIORoot.h:54
mps_splice.entry
entry
Definition: mps_splice.py:68
tree
Definition: tree.py:1
cuy.col
col
Definition: cuy.py:1009
np
int np
Definition: AMPTWrapper.h:43
AlignmentIORootBase::treename
TString treename
Definition: AlignmentIORootBase.h:39
AlignmentParameters::userVariables
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
Definition: AlignmentParameters.cc:101
HIPUserVariablesIORoot::findEntry
int findEntry(unsigned int detId, int comp)
Definition: HIPUserVariablesIORoot.cc:68
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
HIPUserVariablesIORoot::DataType
int DataType
Definition: HIPUserVariablesIORoot.h:56
AlignmentParameters
Definition: AlignmentParameters.h:35
AlignmentIORootBase::treetxt
TString treetxt
Definition: AlignmentIORootBase.h:40
HIPUserVariablesIORoot::Npare
int Npare
Definition: HIPUserVariablesIORoot.h:55
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
Alignable::alignableObjectId
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
HIPUserVariablesIORoot::treemap
treemaptype treemap
Definition: HIPUserVariablesIORoot.h:66
HIPUserVariables::alipar
AlgebraicVector alipar
Definition: HIPUserVariables.h:13
AlignmentUserVariablesIO::write
int write(const align::Alignables &alivec, bool validCheck)
Definition: AlignmentUserVariablesIO.cc:19
HIPUserVariablesIORoot::ParError
double ParError[nparmax]
Definition: HIPUserVariablesIORoot.h:62
HIPUserVariables::alindof
int alindof
Definition: HIPUserVariables.h:10
HIPUserVariables::nhit
int nhit
Definition: HIPUserVariables.h:11
HIPUserVariablesIORoot::open
int open(const char *filename, int iteration, bool writemode) override
Definition: HIPUserVariablesIORoot.h:34
HIPUserVariables::datatype
int datatype
Definition: HIPUserVariables.h:12
HIPUserVariables::alichi2
double alichi2
Definition: HIPUserVariables.h:9
Alignable::id
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
Definition: Alignable.h:180
HIPUserVariablesIORoot::Par
double Par[nparmax]
Definition: HIPUserVariablesIORoot.h:61
HIPUserVariablesIORoot::newopen
bool newopen
Definition: HIPUserVariablesIORoot.h:64
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
HIPUserVariables::jtvj
AlgebraicSymMatrix jtvj
Definition: HIPUserVariables.h:7
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
AlignmentIORootBase::openRoot
int openRoot(const char *filename, int iteration, bool writemode)
open IO
Definition: AlignmentIORootBase.cc:16
HIPUserVariables::alierr
AlgebraicVector alierr
Definition: HIPUserVariables.h:14
mps_fire.result
result
Definition: mps_fire.py:311
HIPUserVariablesIORoot::Nhit
int Nhit
Definition: HIPUserVariablesIORoot.h:55
HIPUserVariables::jtve
AlgebraicVector jtve
Definition: HIPUserVariables.h:8
HIPUserVariablesIORoot::nparmax
static const int nparmax
Definition: HIPUserVariablesIORoot.h:50
align_cfg.iteration
iteration
Definition: align_cfg.py:5
Alignable::alignmentParameters
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
HIPUserVariablesIORoot::AlignableChi2
double AlignableChi2
Definition: HIPUserVariablesIORoot.h:59
HIPUserVariablesIORoot::close
int close(void) override
Definition: HIPUserVariablesIORoot.h:40
HIPUserVariablesIORoot::ObjId
int ObjId
Definition: HIPUserVariablesIORoot.h:53
HIPUserVariables
Definition: HIPUserVariables.h:4
AlignmentUserVariablesIO::read
std::vector< AlignmentUserVariables * > read(const align::Alignables &alivec, int &ierr)
Definition: AlignmentUserVariablesIO.cc:37