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 AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.

17 {
18  treename = "T9";
19  treetxt = "HIP User Variables";
20 }

Member Function Documentation

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

create root branches

Implements AlignmentIORootBase.

Definition at line 24 of file HIPUserVariablesIORoot.cc.

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

25 {
26  tree->Branch("Id", &Id, "Id/i");
27  tree->Branch("ObjId", &ObjId, "ObjId/I");
28 
29  tree->Branch("Nhit", &Nhit, "Nhit/I");
30  tree->Branch("Nparj", &Nparj, "Nparj/I");
31  tree->Branch("Jtvj", &Jtvj, "Jtvj[Nparj]/D");
32  tree->Branch("Npare", &Npare, "Npare/I");
33  tree->Branch("Jtve", &Jtve, "Jtve[Npare]/D");
34  tree->Branch("AlignableChi2", &AlignableChi2, "AlignableChi2/D");
35  tree->Branch("AlignableNdof", &AlignableNdof, "AlignableNdof/i");
36 }
double Jtvj[nparmax *(nparmax+1)/2]
int HIPUserVariablesIORoot::findEntry ( unsigned int  detId,
int  comp 
)
private

Definition at line 58 of file HIPUserVariablesIORoot.cc.

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

Referenced by readOne().

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

read user variables

Definition at line 183 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::collector().

185 {
186  std::vector<AlignmentUserVariables*> result;
187  ierr=0;
188  int iret;
189  iret = open(filename,iter,false);
190  if (iret!=0) { ierr=-1; return result;}
191  result = read(alivec,iret);
192  if (iret!=0) { ierr=-2; return result;}
193  iret = close();
194  if (iret!=0) { ierr=-3; return result;}
195 
196  return result;
197 }
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 127 of file HIPUserVariablesIORoot.cc.

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

129 {
130  ierr=0;
131  HIPUserVariables* uvar;
132 
133  int entry = findEntry(ali->id(), ali->alignableObjectId());
134  if(entry!=-1) {
135  tree->GetEntry(entry);
136 
137  int np=Npare;
138  AlgebraicVector jtve(np,0);
139  AlgebraicSymMatrix jtvj(np,0);
140  int count=0;
141  for(int row=0;row<np;row++) {
142  jtve[row]=Jtve[row];
143  for(int col=0; col < np;col++) {
144  if(row-1<col) {jtvj[row][col]=Jtvj[count];count++;}
145  }
146  }
147 
148  uvar = new HIPUserVariables(np);
149  uvar->jtvj=jtvj;
150  uvar->jtve=jtve;
151  uvar->nhit=Nhit;
152 
153  //Chi2n
154  uvar->alichi2=AlignableChi2;
155  uvar->alindof=AlignableNdof;
156 
157  return uvar;
158  }
159 
160  // ierr=-1;
161  return 0 ;
162 }
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
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
double Jtvj[nparmax *(nparmax+1)/2]
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
CLHEP::HepVector AlgebraicVector
CLHEP::HepSymMatrix AlgebraicSymMatrix
void HIPUserVariablesIORoot::setBranchAddresses ( void  )
privatevirtual

set root branches

Implements AlignmentIORootBase.

Definition at line 40 of file HIPUserVariablesIORoot.cc.

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

41 {
42  tree->SetBranchAddress("Id", &Id);
43  tree->SetBranchAddress("ObjId", &ObjId);
44 
45  tree->SetBranchAddress("Nhit", &Nhit);
46  tree->SetBranchAddress("Nparj", &Nparj);
47  tree->SetBranchAddress("Jtvj", &Jtvj);
48  tree->SetBranchAddress("Npare", &Npare);
49  tree->SetBranchAddress("Jtve", &Jtve);
50  tree->SetBranchAddress("AlignableChi2", &AlignableChi2);
51  tree->SetBranchAddress("AlignableNdof", &AlignableNdof);
52 
53 }
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 167 of file HIPUserVariablesIORoot.cc.

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

Referenced by HIPAlignmentAlgorithm::terminate().

169 {
170  ierr=0;
171  int iret;
172  iret = open(filename,iter,true);
173  if (iret!=0) { ierr=-1; return;}
174  iret = write(alivec,validCheck);
175  if (iret!=0) { ierr=-2; return;}
176  iret = close();
177  if (iret!=0) { ierr=-3; return;}
178 }
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 87 of file HIPUserVariablesIORoot.cc.

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

88 {
90 
91  if ((ap->userVariables())==0) {
92  edm::LogError("Alignment") <<"UserVariables not found!";
93  return -1;
94  }
95 
96  HIPUserVariables* uvar =
97  dynamic_cast<HIPUserVariables*>(ap->userVariables());
98 
99  AlgebraicSymMatrix jtvj = uvar->jtvj;
100  AlgebraicVector jtve = uvar->jtve;
101  int nhit=uvar->nhit;
102  int np=jtve.num_row();
103 
104  Nhit=nhit;
105  Npare=np;
106  Nparj=np*(np+1)/2;
107  int count=0;
108  for(int row=0;row<np;row++){
109  Jtve[row]=jtve[row];
110  for(int col=0;col<np;col++){
111  if(row-1<col){Jtvj[count]=jtvj[row][col];count++;}
112  }
113  }
114  Id = ali->id();
115  ObjId = ali->alignableObjectId();
116 
117  //Chi^2 of alignable
118  AlignableChi2= uvar->alichi2 ;
119  AlignableNdof= uvar->alindof ;
120 
121  tree->Fill();
122  return 0;
123 }
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.
double Jtvj[nparmax *(nparmax+1)/2]
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
CLHEP::HepVector AlgebraicVector
CLHEP::HepSymMatrix AlgebraicSymMatrix

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

Definition at line 60 of file HIPUserVariablesIORoot.h.

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

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

Definition at line 59 of file HIPUserVariablesIORoot.h.

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

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.

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