CMS 3D CMS Logo

List of all members | Private Member Functions | Private Attributes | Friends
AlignmentCorrelationsIORoot Class Reference

Concrete class for ROOT based IO of Correlations. More...

#include <AlignmentCorrelationsIORoot.h>

Inheritance diagram for AlignmentCorrelationsIORoot:
AlignmentIORootBase AlignmentCorrelationsIO

Private Member Functions

 AlignmentCorrelationsIORoot ()
 constructor More...
 
int close (void) override
 close IO More...
 
void createBranches (void) override
 create root branches More...
 
int open (const char *filename, int iteration, bool writemode) override
 open IO More...
 
align::Correlations read (const align::Alignables &alivec, int &ierr) override
 read correlations More...
 
void setBranchAddresses (void) override
 set root branches More...
 
int write (const align::Correlations &cor, bool validCheck) override
 write correlations More...
 

Private Attributes

align::ID Ali1Id
 correlation tree More...
 
align::StructureType Ali1ObjId
 
align::ID Ali2Id
 
align::StructureType Ali2ObjId
 
double CorMatrix [nParMax *nParMax]
 
int corSize
 

Friends

class AlignmentIORoot
 

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 AlignmentCorrelationsIO
virtual ~AlignmentCorrelationsIO ()
 destructor More...
 
- 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 Correlations.

Definition at line 10 of file AlignmentCorrelationsIORoot.h.

Constructor & Destructor Documentation

AlignmentCorrelationsIORoot::AlignmentCorrelationsIORoot ( )
private

constructor

Definition at line 13 of file AlignmentCorrelationsIORoot.cc.

References AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.

14 {
15  treename = "AlignmentCorrelations";
16  treetxt = "Correlations";
17 }

Member Function Documentation

int AlignmentCorrelationsIORoot::close ( void  )
inlineoverrideprivatevirtual
void AlignmentCorrelationsIORoot::createBranches ( void  )
overrideprivatevirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 21 of file AlignmentCorrelationsIORoot.cc.

References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, CorMatrix, and corSize.

Referenced by close().

22 {
23  tree->Branch("Ali1Id", &Ali1Id, "Ali1Id/i");
24  tree->Branch("Ali2Id", &Ali2Id, "Ali2Id/i");
25  tree->Branch("Ali1ObjId", &Ali1ObjId, "Ali1ObjId/I");
26  tree->Branch("Ali2ObjId", &Ali2ObjId, "Ali2ObjId/I");
27  tree->Branch("corSize", &corSize, "corSize/I");
28  tree->Branch("CorMatrix", &CorMatrix, "CorMatrix[corSize]/D");
29 }
align::ID Ali1Id
correlation tree
Definition: tree.py:1
int AlignmentCorrelationsIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
)
inlineoverrideprivatevirtual
align::Correlations AlignmentCorrelationsIORoot::read ( const align::Alignables alivec,
int &  ierr 
)
overrideprivatevirtual

read correlations

Implements AlignmentCorrelationsIO.

Definition at line 79 of file AlignmentCorrelationsIORoot.cc.

References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, cuy::col, CorMatrix, mps_splice::entry, and AlignmentIORootBase::nParMax.

Referenced by close(), edmIntegrityCheck.PublishToFileSystem::get(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), AlignmentIORoot::readCorrelations(), and Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

80 {
81  align::Correlations theMap;
82 
83  // create ID map for all Alignables in alivec
84  align::Alignables::const_iterator it1;
85  std::map< std::pair<unsigned int,int>, Alignable* > idAlis;
86  for( it1=alivec.begin();it1!=alivec.end();++it1 )
87  idAlis[std::make_pair((*it1)->id(),(*it1)->alignableObjectId())] = (*it1);
88 
89  std::map<std::pair<unsigned int,int>,Alignable*>::const_iterator aliSearch1;
90  std::map<std::pair<unsigned int,int>,Alignable*>::const_iterator aliSearch2;
91  int nfound=0;
92  double maxEntry = tree->GetEntries();
93  for( int entry = 0;entry<maxEntry;entry++ )
94  {
95  tree->GetEntry(entry);
96  aliSearch1 = idAlis.find(std::make_pair(Ali1Id,Ali1ObjId));
97  aliSearch2 = idAlis.find(std::make_pair(Ali2Id,Ali2ObjId));
98  if (aliSearch1!=idAlis.end()
99  && aliSearch2!=idAlis.end())
100  {
101  // Alignables for this pair found
102  nfound++;
103  Alignable* myAli1 = (*aliSearch1).second;
104  Alignable* myAli2 = (*aliSearch2).second;
105  // FIXME: instead of nParMax in the next few lines one should probably
106  // use something like sqrt(corSize) - but take care of rounding!
107  // I have no time to test... :-( GF
109  for(int row = 0;row<nParMax;row++)
110  for(int col = 0;col<nParMax;col++)
111  mat[row][col] = CorMatrix[row+col*nParMax];
112  theMap[ std::make_pair(myAli1,myAli2) ] = mat;
113  }
114  }
115 
116  edm::LogInfo("AlignmentCorrelationsIORoot") << "Read correlations: all,read: "
117  << alivec.size() << "," << nfound;
118 
119  ierr=0;
120  return theMap;
121 }
align::ID Ali1Id
correlation tree
static const int nParMax
std::map< std::pair< Alignable *, Alignable * >, AlgebraicMatrix > Correlations
Definition: Utilities.h:36
CLHEP::HepMatrix AlgebraicMatrix
col
Definition: cuy.py:1009
Definition: tree.py:1
void AlignmentCorrelationsIORoot::setBranchAddresses ( void  )
overrideprivatevirtual

set root branches

Implements AlignmentIORootBase.

Definition at line 33 of file AlignmentCorrelationsIORoot.cc.

References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, CorMatrix, and corSize.

Referenced by close().

34 {
35  tree->SetBranchAddress("corSize", &corSize);
36  tree->SetBranchAddress("Ali1Id", &Ali1Id);
37  tree->SetBranchAddress("Ali2Id", &Ali2Id);
38  tree->SetBranchAddress("Ali1ObjId", &Ali1ObjId);
39  tree->SetBranchAddress("Ali2ObjId", &Ali2ObjId);
40  tree->SetBranchAddress("CorMatrix", &CorMatrix);
41 }
align::ID Ali1Id
correlation tree
Definition: tree.py:1
int AlignmentCorrelationsIORoot::write ( const align::Correlations cor,
bool  validCheck 
)
overrideprivatevirtual

write correlations

Implements AlignmentCorrelationsIO.

Definition at line 45 of file AlignmentCorrelationsIORoot.cc.

References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, Alignable::alignableObjectId(), Alignable::alignmentParameters(), cuy::col, CorMatrix, corSize, Alignable::id(), and AlignmentParameters::isValid().

Referenced by close(), pkg.AbstractPkg::generate(), querying.connection::write_and_commit(), and AlignmentIORoot::writeCorrelations().

46 {
47  int icount=0;
48 
49  for(align::Correlations::const_iterator it=cor.begin();
50  it!=cor.end();++it) {
51  AlgebraicMatrix mat=(*it).second;
52  std::pair<Alignable*,Alignable*> Pair = (*it).first;
53  Alignable* ali1 = Pair.first;
54  Alignable* ali2 = Pair.second;
55  if( (ali1->alignmentParameters()->isValid()
56  && ali2->alignmentParameters()->isValid()) || !(validCheck)) {
57  Ali1ObjId = ali1->alignableObjectId();
58  Ali2ObjId = ali2->alignableObjectId();
59  Ali1Id = ali1->id();
60  Ali2Id = ali2->id();
61  int maxColumn = mat.num_row();
62  corSize = maxColumn*maxColumn;
63  for(int row = 0;row<maxColumn;row++)
64  for(int col = 0;col<maxColumn;col++)
65  CorMatrix[row+col*maxColumn] =mat[row][col];
66  tree->Fill();
67  icount++;
68  }
69  }
70  edm::LogInfo("AlignmentCorrelationsIORoot") << "Writing correlations: all,written: "
71  << cor.size() << "," << icount;
72  return 0;
73 }
align::ID Ali1Id
correlation tree
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
CLHEP::HepMatrix AlgebraicMatrix
bool isValid(void) const
Get validity flag.
col
Definition: cuy.py:1009
Definition: tree.py:1

Friends And Related Function Documentation

friend class AlignmentIORoot
friend

Definition at line 12 of file AlignmentCorrelationsIORoot.h.

Member Data Documentation

align::ID AlignmentCorrelationsIORoot::Ali1Id
private

correlation tree

Definition at line 39 of file AlignmentCorrelationsIORoot.h.

Referenced by createBranches(), read(), setBranchAddresses(), and write().

align::StructureType AlignmentCorrelationsIORoot::Ali1ObjId
private

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

align::StructureType AlignmentCorrelationsIORoot::Ali2ObjId
private

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