CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

typedef std::vector< Alignable * > 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)
 
void createBranches (void)
 create root branches More...
 
int findEntry (unsigned int detId, int comp)
 
int open (const char *filename, int iteration, bool writemode)
 
AlignmentUserVariablesreadOne (Alignable *ali, int &ierr)
 
void setBranchAddresses (void)
 set root branches More...
 
int writeOne (Alignable *ali)
 

Private Attributes

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

Static Private Attributes

static const int nparmax =6
 

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 9 of file HIPUserVariablesIORoot.h.

Member Typedef Documentation

Definition at line 15 of file HIPUserVariablesIORoot.h.

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

Definition at line 65 of file HIPUserVariablesIORoot.h.

Constructor & Destructor Documentation

HIPUserVariablesIORoot::HIPUserVariablesIORoot ( )

constructor

Definition at line 16 of file HIPUserVariablesIORoot.cc.

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

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

Member Function Documentation

int HIPUserVariablesIORoot::close ( void  )
inlineprivatevirtual
void HIPUserVariablesIORoot::createBranches ( void  )
privatevirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 31 of file HIPUserVariablesIORoot.cc.

References AlignableChi2, AlignableNdof, Id, Jtve, Jtvj, Nhit, Npare, Nparj, ObjId, and AlignmentIORootBase::tree.

32 {
33  tree->Branch("Id", &Id, "Id/i");
34  tree->Branch("ObjId", &ObjId, "ObjId/I");
35 
36  tree->Branch("Nhit", &Nhit, "Nhit/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 }
double Jtvj[nparmax *(nparmax+1)/2]
int HIPUserVariablesIORoot::findEntry ( unsigned int  detId,
int  comp 
)
private

Definition at line 65 of file HIPUserVariablesIORoot.cc.

References ev, Id, newopen, ObjId, query::result, AlignmentIORootBase::tree, and treemap.

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

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

open IO

Implements AlignmentUserVariablesIO.

Definition at line 39 of file HIPUserVariablesIORoot.h.

References newopen, and AlignmentIORootBase::openRoot().

Referenced by Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::importConfig(), readHIPUserVariables(), and writeHIPUserVariables().

40  {newopen=true; return 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 * > HIPUserVariablesIORoot::readHIPUserVariables ( const Alignables alivec,
const char *  filename,
int  iter,
int &  ierr 
)

read user variables

Definition at line 190 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::collector().

192 {
193  std::vector<AlignmentUserVariables*> result;
194  ierr=0;
195  int iret;
196  iret = open(filename,iter,false);
197  if (iret!=0) { ierr=-1; return result;}
198  result = read(alivec,iret);
199  if (iret!=0) { ierr=-2; return result;}
200  iret = close();
201  if (iret!=0) { ierr=-3; return result;}
202 
203  return result;
204 }
int open(const char *filename, int iteration, bool writemode)
tuple result
Definition: query.py:137
std::vector< AlignmentUserVariables * > read(const align::Alignables &alivec, int &ierr)
tuple filename
Definition: lut2db_cfg.py:20
AlignmentUserVariables * HIPUserVariablesIORoot::readOne ( Alignable ali,
int &  ierr 
)
privatevirtual

read AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 134 of file HIPUserVariablesIORoot.cc.

References HIPUserVariables::alichi2, AlignableChi2, AlignableNdof, Alignable::alignableObjectId(), HIPUserVariables::alindof, cuy::col, KineDebug3::count(), findEntry(), Alignable::id(), HIPUserVariables::jtve, Jtve, HIPUserVariables::jtvj, Jtvj, HIPUserVariables::nhit, Nhit, np, Npare, and AlignmentIORootBase::tree.

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

set root branches

Implements AlignmentIORootBase.

Definition at line 47 of file HIPUserVariablesIORoot.cc.

References AlignableChi2, AlignableNdof, Id, Jtve, Jtvj, Nhit, Npare, Nparj, ObjId, and AlignmentIORootBase::tree.

48 {
49  tree->SetBranchAddress("Id", &Id);
50  tree->SetBranchAddress("ObjId", &ObjId);
51 
52  tree->SetBranchAddress("Nhit", &Nhit);
53  tree->SetBranchAddress("Nparj", &Nparj);
54  tree->SetBranchAddress("Jtvj", &Jtvj);
55  tree->SetBranchAddress("Npare", &Npare);
56  tree->SetBranchAddress("Jtve", &Jtve);
57  tree->SetBranchAddress("AlignableChi2", &AlignableChi2);
58  tree->SetBranchAddress("AlignableNdof", &AlignableNdof);
59 
60 }
double Jtvj[nparmax *(nparmax+1)/2]
void HIPUserVariablesIORoot::writeHIPUserVariables ( const Alignables alivec,
const char *  filename,
int  iter,
bool  validCheck,
int &  ierr 
)

write user variables

Definition at line 174 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::terminate().

176 {
177  ierr=0;
178  int iret;
179  iret = open(filename,iter,true);
180  if (iret!=0) { ierr=-1; return;}
181  iret = write(alivec,validCheck);
182  if (iret!=0) { ierr=-2; return;}
183  iret = close();
184  if (iret!=0) { ierr=-3; return;}
185 }
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 HIPUserVariablesIORoot::writeOne ( Alignable ali)
privatevirtual

write AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 94 of file HIPUserVariablesIORoot.cc.

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

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

Member Data Documentation

double HIPUserVariablesIORoot::AlignableChi2
private

Definition at line 61 of file HIPUserVariablesIORoot.h.

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

unsigned int HIPUserVariablesIORoot::AlignableNdof
private

Definition at line 62 of file HIPUserVariablesIORoot.h.

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

unsigned int HIPUserVariablesIORoot::Id
private

Definition at line 57 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 64 of file HIPUserVariablesIORoot.h.

Referenced by findEntry(), and open().

int HIPUserVariablesIORoot::Nhit
private

Definition at line 58 of file HIPUserVariablesIORoot.h.

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

int HIPUserVariablesIORoot::Npare
private

Definition at line 58 of file HIPUserVariablesIORoot.h.

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

int HIPUserVariablesIORoot::Nparj
private

Definition at line 58 of file HIPUserVariablesIORoot.h.

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

const int HIPUserVariablesIORoot::nparmax =6
staticprivate

Definition at line 53 of file HIPUserVariablesIORoot.h.

Referenced by HIPUserVariablesIORoot().

int HIPUserVariablesIORoot::ObjId
private

alignment parameter tree

Definition at line 56 of file HIPUserVariablesIORoot.h.

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

treemaptype HIPUserVariablesIORoot::treemap
private

Definition at line 66 of file HIPUserVariablesIORoot.h.

Referenced by findEntry().