#include <Alignment/HIPAlignmentAlgorithm/interface/HIPUserVariablesIORoot.h>
Public Types | |
typedef std::vector< Alignable * > | Alignables |
Public Member Functions | |
HIPUserVariablesIORoot () | |
constructor | |
std::vector < AlignmentUserVariables * > | readHIPUserVariables (const Alignables &alivec, const char *filename, int iter, int &ierr) |
read user variables | |
void | writeHIPUserVariables (const Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr) |
write user variables | |
Private Types | |
typedef std::map< std::pair < int, int >, int > | treemaptype |
Private Member Functions | |
int | close (void) |
close IO | |
void | createBranches (void) |
create root branches | |
int | findEntry (unsigned int detId, int comp) |
int | open (const char *filename, int iteration, bool writemode) |
open IO | |
AlignmentUserVariables * | readOne (Alignable *ali, int &ierr) |
read AlignmentParameters of one Alignable | |
void | setBranchAddresses (void) |
set root branches | |
int | writeOne (Alignable *ali) |
write AlignmentParameters of one Alignable | |
Private Attributes | |
unsigned int | Id |
double | Jtve [nparmax] |
double | Jtvj [nparmax *(nparmax+1)/2] |
bool | newopen |
int | Nhit |
int | Npare |
int | Nparj |
int | ObjId |
alignment parameter tree | |
treemaptype | treemap |
Static Private Attributes | |
static const int | nparmax = 6 |
Definition at line 9 of file HIPUserVariablesIORoot.h.
typedef std::vector<Alignable*> HIPUserVariablesIORoot::Alignables |
Definition at line 15 of file HIPUserVariablesIORoot.h.
typedef std::map< std::pair<int,int> , int > HIPUserVariablesIORoot::treemaptype [private] |
Definition at line 63 of file HIPUserVariablesIORoot.h.
HIPUserVariablesIORoot::HIPUserVariablesIORoot | ( | ) |
constructor
Definition at line 16 of file HIPUserVariablesIORoot.cc.
References AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.
close IO
Implements AlignmentUserVariablesIO.
Definition at line 43 of file HIPUserVariablesIORoot.h.
References AlignmentIORootBase::closeRoot().
Referenced by readHIPUserVariables(), and writeHIPUserVariables().
00043 {return closeRoot();};
create root branches
Implements AlignmentIORootBase.
Definition at line 24 of file HIPUserVariablesIORoot.cc.
References Id, Jtve, Jtvj, Nhit, Npare, Nparj, ObjId, and AlignmentIORootBase::tree.
00025 { 00026 tree->Branch("Id", &Id, "Id/i"); 00027 tree->Branch("ObjId", &ObjId, "ObjId/I"); 00028 00029 tree->Branch("Nhit", &Nhit, "Nhit/I"); 00030 tree->Branch("Nparj", &Nparj, "Nparj/I"); 00031 tree->Branch("Jtvj", &Jtvj, "Jtvj[Nparj]/D"); 00032 tree->Branch("Npare", &Npare, "Npare/I"); 00033 tree->Branch("Jtve", &Jtve, "Jtve[Npare]/D"); 00034 }
Definition at line 53 of file HIPUserVariablesIORoot.cc.
References Id, newopen, ObjId, HLT_VtxMuL3::result, AlignmentIORootBase::tree, and treemap.
Referenced by readOne().
00054 { 00055 if (newopen) { // we're here first time 00056 edm::LogInfo("Alignment") <<"[HIPUserVariablesIORoot::findEntry] fill map ..."; 00057 treemap.erase(treemap.begin(),treemap.end()); 00058 for (int ev = 0;ev<tree->GetEntries();ev++) { 00059 tree->GetEntry(ev); 00060 treemap[std::make_pair(Id,ObjId)]=ev; 00061 } 00062 newopen=false; 00063 } 00064 00065 // now we have filled the map 00066 treemaptype::iterator imap = treemap.find(std::make_pair(detId,comp)); 00067 int result=-1; 00068 if (imap != treemap.end()) result=(*imap).second; 00069 return result; 00070 00071 00072 //double noAliPar = tree->GetEntries(); 00073 //for (int ev = 0;ev<noAliPar;ev++) { 00074 // tree->GetEntry(ev); 00075 // if(Id==detId&&comp==ObjId) return (ev); 00076 //} 00077 //return(-1); 00078 }
int HIPUserVariablesIORoot::open | ( | const char * | filename, | |
int | iteration, | |||
bool | writemode | |||
) | [inline, private, virtual] |
open IO
Implements AlignmentUserVariablesIO.
Definition at line 39 of file HIPUserVariablesIORoot.h.
References newopen, and AlignmentIORootBase::openRoot().
Referenced by readHIPUserVariables(), and writeHIPUserVariables().
std::vector< AlignmentUserVariables * > HIPUserVariablesIORoot::readHIPUserVariables | ( | const Alignables & | alivec, | |
const char * | filename, | |||
int | iter, | |||
int & | ierr | |||
) |
read user variables
Definition at line 170 of file HIPUserVariablesIORoot.cc.
References close(), open(), AlignmentUserVariablesIO::read(), and HLT_VtxMuL3::result.
Referenced by HIPAlignmentAlgorithm::collector().
00172 { 00173 std::vector<AlignmentUserVariables*> result; 00174 ierr=0; 00175 int iret; 00176 iret = open(filename,iter,false); 00177 if (iret!=0) { ierr=-1; return result;} 00178 result = read(alivec,iret); 00179 if (iret!=0) { ierr=-2; return result;} 00180 iret = close(); 00181 if (iret!=0) { ierr=-3; return result;} 00182 00183 return result; 00184 }
AlignmentUserVariables * HIPUserVariablesIORoot::readOne | ( | Alignable * | ali, | |
int & | ierr | |||
) | [private, virtual] |
read AlignmentParameters of one Alignable
Implements AlignmentUserVariablesIO.
Definition at line 118 of file HIPUserVariablesIORoot.cc.
References Alignable::alignableObjectId(), parsecf::pyparsing::col(), count, findEntry(), Alignable::id(), HIPUserVariables::jtve, Jtve, HIPUserVariables::jtvj, Jtvj, HIPUserVariables::nhit, Nhit, np, Npare, row, and AlignmentIORootBase::tree.
00120 { 00121 ierr=0; 00122 HIPUserVariables* uvar; 00123 00124 int entry = findEntry(ali->id(), ali->alignableObjectId()); 00125 if(entry!=-1) { 00126 tree->GetEntry(entry); 00127 00128 int np=Npare; 00129 AlgebraicVector jtve(np,0); 00130 AlgebraicSymMatrix jtvj(np,0); 00131 int count=0; 00132 for(int row=0;row<np;row++) { 00133 jtve[row]=Jtve[row]; 00134 for(int col=0; col < np;col++) { 00135 if(row-1<col) {jtvj[row][col]=Jtvj[count];count++;} 00136 } 00137 } 00138 00139 uvar = new HIPUserVariables(np); 00140 uvar->jtvj=jtvj; 00141 uvar->jtve=jtve; 00142 uvar->nhit=Nhit; 00143 00144 return uvar; 00145 } 00146 00147 // ierr=-1; 00148 return 0 ; 00149 }
set root branches
Implements AlignmentIORootBase.
Definition at line 38 of file HIPUserVariablesIORoot.cc.
References Id, Jtve, Jtvj, Nhit, Npare, Nparj, ObjId, and AlignmentIORootBase::tree.
00039 { 00040 tree->SetBranchAddress("Id", &Id); 00041 tree->SetBranchAddress("ObjId", &ObjId); 00042 00043 tree->SetBranchAddress("Nhit", &Nhit); 00044 tree->SetBranchAddress("Nparj", &Nparj); 00045 tree->SetBranchAddress("Jtvj", &Jtvj); 00046 tree->SetBranchAddress("Npare", &Npare); 00047 tree->SetBranchAddress("Jtve", &Jtve); 00048 }
void HIPUserVariablesIORoot::writeHIPUserVariables | ( | const Alignables & | alivec, | |
const char * | filename, | |||
int | iter, | |||
bool | validCheck, | |||
int & | ierr | |||
) |
write user variables
Definition at line 154 of file HIPUserVariablesIORoot.cc.
References close(), open(), and AlignmentUserVariablesIO::write().
Referenced by HIPAlignmentAlgorithm::terminate().
00156 { 00157 ierr=0; 00158 int iret; 00159 iret = open(filename,iter,true); 00160 if (iret!=0) { ierr=-1; return;} 00161 iret = write(alivec,validCheck); 00162 if (iret!=0) { ierr=-2; return;} 00163 iret = close(); 00164 if (iret!=0) { ierr=-3; return;} 00165 }
write AlignmentParameters of one Alignable
Implements AlignmentUserVariablesIO.
Definition at line 82 of file HIPUserVariablesIORoot.cc.
References Alignable::alignableObjectId(), Alignable::alignmentParameters(), parsecf::pyparsing::col(), count, Id, Alignable::id(), Jtve, HIPUserVariables::jtve, Jtvj, HIPUserVariables::jtvj, HIPUserVariables::nhit, Nhit, np, Npare, Nparj, ObjId, row, AlignmentIORootBase::tree, and AlignmentParameters::userVariables().
00083 { 00084 AlignmentParameters* ap=ali->alignmentParameters(); 00085 00086 if ((ap->userVariables())==0) { 00087 edm::LogError("Alignment") <<"UserVariables not found!"; 00088 return -1; 00089 } 00090 00091 HIPUserVariables* uvar = 00092 dynamic_cast<HIPUserVariables*>(ap->userVariables()); 00093 00094 AlgebraicSymMatrix jtvj = uvar->jtvj; 00095 AlgebraicVector jtve = uvar->jtve; 00096 int nhit=uvar->nhit; 00097 int np=jtve.num_row(); 00098 00099 Nhit=nhit; 00100 Npare=np; 00101 Nparj=np*(np+1)/2; 00102 int count=0; 00103 for(int row=0;row<np;row++){ 00104 Jtve[row]=jtve[row]; 00105 for(int col=0;col<np;col++){ 00106 if(row-1<col){Jtvj[count]=jtvj[row][col];count++;} 00107 } 00108 } 00109 Id = ali->id(); 00110 ObjId = ali->alignableObjectId(); 00111 00112 tree->Fill(); 00113 return 0; 00114 }
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] |
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 [static, private] |
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] |