test
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
 
double Par [nparmax]
 
double ParError [nparmax]
 
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 67 of file HIPUserVariablesIORoot.h.

Constructor & Destructor Documentation

HIPUserVariablesIORoot::HIPUserVariablesIORoot ( )

constructor

Definition at line 16 of file HIPUserVariablesIORoot.cc.

References i, Jtve, Jtvj, nparmax, Par, ParError, 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  Par[i] = 0.;
28  ParError[i] = 0.;}
29 }
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 33 of file HIPUserVariablesIORoot.cc.

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

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("Nparj", &Nparj, "Nparj/I");
40  tree->Branch("Jtvj", &Jtvj, "Jtvj[Nparj]/D");
41  tree->Branch("Npare", &Npare, "Npare/I");
42  tree->Branch("Jtve", &Jtve, "Jtve[Npare]/D");
43  tree->Branch("AlignableChi2", &AlignableChi2, "AlignableChi2/D");
44  tree->Branch("AlignableNdof", &AlignableNdof, "AlignableNdof/i");
45  tree->Branch("Par", &Par, "Par[Npare]/D");
46  tree->Branch("ParError", &ParError, "ParError[Npare]/D");
47 }
double Jtvj[nparmax *(nparmax+1)/2]
int HIPUserVariablesIORoot::findEntry ( unsigned int  detId,
int  comp 
)
private

Definition at line 70 of file HIPUserVariablesIORoot.cc.

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

Referenced by 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
tuple result
Definition: mps_fire.py:84
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 203 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::collector().

205 {
206  std::vector<AlignmentUserVariables*> result;
207  ierr=0;
208  int iret;
209  iret = open(filename,iter,false);
210  if (iret!=0) { ierr=-1; return result;}
211  result = read(alivec,iret);
212  if (iret!=0) { ierr=-2; return result;}
213  iret = close();
214  if (iret!=0) { ierr=-3; return result;}
215 
216  return result;
217 }
int open(const char *filename, int iteration, bool writemode)
tuple result
Definition: mps_fire.py:84
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 142 of file HIPUserVariablesIORoot.cc.

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

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

set root branches

Implements AlignmentIORootBase.

Definition at line 51 of file HIPUserVariablesIORoot.cc.

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

52 {
53  tree->SetBranchAddress("Id", &Id);
54  tree->SetBranchAddress("ObjId", &ObjId);
55 
56  tree->SetBranchAddress("Nhit", &Nhit);
57  tree->SetBranchAddress("Nparj", &Nparj);
58  tree->SetBranchAddress("Jtvj", &Jtvj);
59  tree->SetBranchAddress("Npare", &Npare);
60  tree->SetBranchAddress("Jtve", &Jtve);
61  tree->SetBranchAddress("AlignableChi2", &AlignableChi2);
62  tree->SetBranchAddress("AlignableNdof", &AlignableNdof);
63  tree->SetBranchAddress("Par", &Par);
64  tree->SetBranchAddress("ParError", &ParError);
65 }
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 187 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::terminate().

189 {
190  ierr=0;
191  int iret;
192  iret = open(filename,iter,true);
193  if (iret!=0) { ierr=-1; return;}
194  iret = write(alivec,validCheck);
195  if (iret!=0) { ierr=-2; return;}
196  iret = close();
197  if (iret!=0) { ierr=-3; return;}
198 }
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 99 of file HIPUserVariablesIORoot.cc.

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

100 {
102 
103  if ((ap->userVariables())==0) {
104  edm::LogError("Alignment") <<"UserVariables not found!";
105  return -1;
106  }
107 
108  HIPUserVariables* uvar =
109  dynamic_cast<HIPUserVariables*>(ap->userVariables());
110 
111  AlgebraicSymMatrix jtvj = uvar->jtvj;
112  AlgebraicVector jtve = uvar->jtve;
113  AlgebraicVector alipar = uvar->alipar;
114  AlgebraicVector alierr = uvar->alierr;
115  int nhit=uvar->nhit;
116  int np=jtve.num_row();
117 
118  Nhit=nhit;
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=0;col<np;col++){
127  if(row-1<col){Jtvj[count]=jtvj[row][col];count++;}
128  }
129  }
130  Id = ali->id();
131  ObjId = ali->alignableObjectId();
132 
133  //Chi^2 of alignable
134  AlignableChi2= uvar->alichi2 ;
135  AlignableNdof= uvar->alindof ;
136  tree->Fill();
137  return 0;
138 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:185
AlgebraicVector alipar
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
AlgebraicVector alierr
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 66 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().

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

Definition at line 68 of file HIPUserVariablesIORoot.h.

Referenced by findEntry().