Concrete class for ROOT based IO of Correlations. More...
#include <AlignmentCorrelationsIORoot.h>
Private Member Functions | |
AlignmentCorrelationsIORoot () | |
constructor | |
int | close (void) |
close IO | |
void | createBranches (void) |
create root branches | |
int | open (const char *filename, int iteration, bool writemode) |
open IO | |
align::Correlations | read (const align::Alignables &alivec, int &ierr) |
read correlations | |
void | setBranchAddresses (void) |
set root branches | |
int | write (const align::Correlations &cor, bool validCheck) |
write correlations | |
Private Attributes | |
align::ID | Ali1Id |
correlation tree | |
align::StructureType | Ali1ObjId |
align::ID | Ali2Id |
align::StructureType | Ali2ObjId |
double | CorMatrix [nParMax *nParMax] |
int | corSize |
Friends | |
class | AlignmentIORoot |
Concrete class for ROOT based IO of Correlations.
Definition at line 10 of file AlignmentCorrelationsIORoot.h.
AlignmentCorrelationsIORoot::AlignmentCorrelationsIORoot | ( | ) | [private] |
constructor
Definition at line 13 of file AlignmentCorrelationsIORoot.cc.
References AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.
int AlignmentCorrelationsIORoot::close | ( | void | ) | [inline, private, virtual] |
close IO
Implements AlignmentCorrelationsIO.
Definition at line 25 of file AlignmentCorrelationsIORoot.h.
References AlignmentIORootBase::closeRoot().
Referenced by AlignmentIORoot::readCorrelations(), and AlignmentIORoot::writeCorrelations().
{ return closeRoot(); };
void AlignmentCorrelationsIORoot::createBranches | ( | void | ) | [private, virtual] |
create root branches
Implements AlignmentIORootBase.
Definition at line 21 of file AlignmentCorrelationsIORoot.cc.
References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, CorMatrix, corSize, and AlignmentIORootBase::tree.
{ tree->Branch("Ali1Id", &Ali1Id, "Ali1Id/i"); tree->Branch("Ali2Id", &Ali2Id, "Ali2Id/i"); tree->Branch("Ali1ObjId", &Ali1ObjId, "Ali1ObjId/I"); tree->Branch("Ali2ObjId", &Ali2ObjId, "Ali2ObjId/I"); tree->Branch("corSize", &corSize, "corSize/I"); tree->Branch("CorMatrix", &CorMatrix, "CorMatrix[corSize]/D"); }
int AlignmentCorrelationsIORoot::open | ( | const char * | filename, |
int | iteration, | ||
bool | writemode | ||
) | [inline, private, virtual] |
open IO
Implements AlignmentCorrelationsIO.
Definition at line 20 of file AlignmentCorrelationsIORoot.h.
References AlignmentIORootBase::openRoot().
Referenced by AlignmentIORoot::readCorrelations(), and AlignmentIORoot::writeCorrelations().
align::Correlations AlignmentCorrelationsIORoot::read | ( | const align::Alignables & | alivec, |
int & | ierr | ||
) | [private, virtual] |
read correlations
Implements AlignmentCorrelationsIO.
Definition at line 79 of file AlignmentCorrelationsIORoot.cc.
References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, CorMatrix, AlignmentIORootBase::nParMax, and AlignmentIORootBase::tree.
Referenced by AlignmentIORoot::readCorrelations().
{ align::Correlations theMap; // create ID map for all Alignables in alivec align::Alignables::const_iterator it1; std::map< std::pair<unsigned int,int>, Alignable* > idAlis; for( it1=alivec.begin();it1!=alivec.end();it1++ ) idAlis[std::make_pair((*it1)->id(),(*it1)->alignableObjectId())] = (*it1); std::map<std::pair<unsigned int,int>,Alignable*>::const_iterator aliSearch1; std::map<std::pair<unsigned int,int>,Alignable*>::const_iterator aliSearch2; int nfound=0; double maxEntry = tree->GetEntries(); for( int entry = 0;entry<maxEntry;entry++ ) { tree->GetEntry(entry); aliSearch1 = idAlis.find(std::make_pair(Ali1Id,Ali1ObjId)); aliSearch2 = idAlis.find(std::make_pair(Ali2Id,Ali2ObjId)); if (aliSearch1!=idAlis.end() && aliSearch2!=idAlis.end()) { // Alignables for this pair found nfound++; Alignable* myAli1 = (*aliSearch1).second; Alignable* myAli2 = (*aliSearch2).second; // FIXME: instead of nParMax in the next few lines one should probably // use something like sqrt(corSize) - but take care of rounding! // I have no time to test... :-( GF AlgebraicMatrix mat(nParMax,nParMax); for(int row = 0;row<nParMax;row++) for(int col = 0;col<nParMax;col++) mat[row][col] = CorMatrix[row+col*nParMax]; theMap[ std::make_pair(myAli1,myAli2) ] = mat; } } edm::LogInfo("AlignmentCorrelationsIORoot") << "Read correlations: all,read: " << alivec.size() << "," << nfound; ierr=0; return theMap; }
void AlignmentCorrelationsIORoot::setBranchAddresses | ( | void | ) | [private, virtual] |
set root branches
Implements AlignmentIORootBase.
Definition at line 33 of file AlignmentCorrelationsIORoot.cc.
References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, CorMatrix, corSize, and AlignmentIORootBase::tree.
int AlignmentCorrelationsIORoot::write | ( | const align::Correlations & | cor, |
bool | validCheck | ||
) | [private, virtual] |
write correlations
Implements AlignmentCorrelationsIO.
Definition at line 45 of file AlignmentCorrelationsIORoot.cc.
References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, Alignable::alignableObjectId(), Alignable::alignmentParameters(), CorMatrix, corSize, Alignable::id(), AlignmentParameters::isValid(), and AlignmentIORootBase::tree.
Referenced by AlignmentIORoot::writeCorrelations().
{ int icount=0; for(align::Correlations::const_iterator it=cor.begin(); it!=cor.end();it++) { AlgebraicMatrix mat=(*it).second; std::pair<Alignable*,Alignable*> Pair = (*it).first; Alignable* ali1 = Pair.first; Alignable* ali2 = Pair.second; if( (ali1->alignmentParameters()->isValid() && ali2->alignmentParameters()->isValid()) || !(validCheck)) { Ali1ObjId = ali1->alignableObjectId(); Ali2ObjId = ali2->alignableObjectId(); Ali1Id = ali1->id(); Ali2Id = ali2->id(); int maxColumn = mat.num_row(); corSize = maxColumn*maxColumn; for(int row = 0;row<maxColumn;row++) for(int col = 0;col<maxColumn;col++) CorMatrix[row+col*maxColumn] =mat[row][col]; tree->Fill(); icount++; } } edm::LogInfo("AlignmentCorrelationsIORoot") << "Writing correlations: all,written: " << cor.size() << "," << icount; return 0; }
friend class AlignmentIORoot [friend] |
Definition at line 12 of file AlignmentCorrelationsIORoot.h.
align::ID AlignmentCorrelationsIORoot::Ali1Id [private] |
correlation tree
Definition at line 39 of file AlignmentCorrelationsIORoot.h.
Referenced by createBranches(), read(), setBranchAddresses(), and write().
Definition at line 40 of file AlignmentCorrelationsIORoot.h.
Referenced by createBranches(), read(), setBranchAddresses(), and write().
align::ID AlignmentCorrelationsIORoot::Ali2Id [private] |
Definition at line 39 of file AlignmentCorrelationsIORoot.h.
Referenced by createBranches(), read(), setBranchAddresses(), and write().
Definition at line 40 of file AlignmentCorrelationsIORoot.h.
Referenced by createBranches(), read(), setBranchAddresses(), and write().
double AlignmentCorrelationsIORoot::CorMatrix[nParMax *nParMax] [private] |
Definition at line 42 of file AlignmentCorrelationsIORoot.h.
Referenced by createBranches(), read(), setBranchAddresses(), and write().
int AlignmentCorrelationsIORoot::corSize [private] |
Definition at line 41 of file AlignmentCorrelationsIORoot.h.
Referenced by createBranches(), setBranchAddresses(), and write().