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.

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

Member Function Documentation

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

create root branches

Implements AlignmentIORootBase.

Definition at line 20 of file AlignmentCorrelationsIORoot.cc.

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

Referenced by close().

20  {
21  tree->Branch("Ali1Id", &Ali1Id, "Ali1Id/i");
22  tree->Branch("Ali2Id", &Ali2Id, "Ali2Id/i");
23  tree->Branch("Ali1ObjId", &Ali1ObjId, "Ali1ObjId/I");
24  tree->Branch("Ali2ObjId", &Ali2ObjId, "Ali2ObjId/I");
25  tree->Branch("corSize", &corSize, "corSize/I");
26  tree->Branch("CorMatrix", &CorMatrix, "CorMatrix[corSize]/D");
27 }
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 71 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().

71  {
72  align::Correlations theMap;
73 
74  // create ID map for all Alignables in alivec
75  align::Alignables::const_iterator it1;
76  std::map<std::pair<unsigned int, int>, Alignable*> idAlis;
77  for (it1 = alivec.begin(); it1 != alivec.end(); ++it1)
78  idAlis[std::make_pair((*it1)->id(), (*it1)->alignableObjectId())] = (*it1);
79 
80  std::map<std::pair<unsigned int, int>, Alignable*>::const_iterator aliSearch1;
81  std::map<std::pair<unsigned int, int>, Alignable*>::const_iterator aliSearch2;
82  int nfound = 0;
83  double maxEntry = tree->GetEntries();
84  for (int entry = 0; entry < maxEntry; entry++) {
85  tree->GetEntry(entry);
86  aliSearch1 = idAlis.find(std::make_pair(Ali1Id, Ali1ObjId));
87  aliSearch2 = idAlis.find(std::make_pair(Ali2Id, Ali2ObjId));
88  if (aliSearch1 != idAlis.end() && aliSearch2 != idAlis.end()) {
89  // Alignables for this pair found
90  nfound++;
91  Alignable* myAli1 = (*aliSearch1).second;
92  Alignable* myAli2 = (*aliSearch2).second;
93  // FIXME: instead of nParMax in the next few lines one should probably
94  // use something like sqrt(corSize) - but take care of rounding!
95  // I have no time to test... :-( GF
97  for (int row = 0; row < nParMax; row++)
98  for (int col = 0; col < nParMax; col++)
99  mat[row][col] = CorMatrix[row + col * nParMax];
100  theMap[std::make_pair(myAli1, myAli2)] = mat;
101  }
102  }
103 
104  edm::LogInfo("AlignmentCorrelationsIORoot") << "Read correlations: all,read: " << alivec.size() << "," << nfound;
105 
106  ierr = 0;
107  return theMap;
108 }
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:1010
Definition: tree.py:1
void AlignmentCorrelationsIORoot::setBranchAddresses ( void  )
overrideprivatevirtual

set root branches

Implements AlignmentIORootBase.

Definition at line 31 of file AlignmentCorrelationsIORoot.cc.

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

Referenced by close().

31  {
32  tree->SetBranchAddress("corSize", &corSize);
33  tree->SetBranchAddress("Ali1Id", &Ali1Id);
34  tree->SetBranchAddress("Ali2Id", &Ali2Id);
35  tree->SetBranchAddress("Ali1ObjId", &Ali1ObjId);
36  tree->SetBranchAddress("Ali2ObjId", &Ali2ObjId);
37  tree->SetBranchAddress("CorMatrix", &CorMatrix);
38 }
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 42 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().

42  {
43  int icount = 0;
44 
45  for (align::Correlations::const_iterator it = cor.begin(); it != cor.end(); ++it) {
46  AlgebraicMatrix mat = (*it).second;
47  std::pair<Alignable*, Alignable*> Pair = (*it).first;
48  Alignable* ali1 = Pair.first;
49  Alignable* ali2 = Pair.second;
50  if ((ali1->alignmentParameters()->isValid() && ali2->alignmentParameters()->isValid()) || !(validCheck)) {
51  Ali1ObjId = ali1->alignableObjectId();
52  Ali2ObjId = ali2->alignableObjectId();
53  Ali1Id = ali1->id();
54  Ali2Id = ali2->id();
55  int maxColumn = mat.num_row();
56  corSize = maxColumn * maxColumn;
57  for (int row = 0; row < maxColumn; row++)
58  for (int col = 0; col < maxColumn; col++)
59  CorMatrix[row + col * maxColumn] = mat[row][col];
60  tree->Fill();
61  icount++;
62  }
63  }
64  edm::LogInfo("AlignmentCorrelationsIORoot") << "Writing correlations: all,written: " << cor.size() << "," << icount;
65  return 0;
66 }
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:1010
Definition: tree.py:1

Friends And Related Function Documentation

friend class AlignmentIORoot
friend

Definition at line 11 of file AlignmentCorrelationsIORoot.h.

Member Data Documentation

align::ID AlignmentCorrelationsIORoot::Ali1Id
private

correlation tree

Definition at line 37 of file AlignmentCorrelationsIORoot.h.

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

align::StructureType AlignmentCorrelationsIORoot::Ali1ObjId
private

Definition at line 38 of file AlignmentCorrelationsIORoot.h.

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

align::ID AlignmentCorrelationsIORoot::Ali2Id
private

Definition at line 37 of file AlignmentCorrelationsIORoot.h.

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

align::StructureType AlignmentCorrelationsIORoot::Ali2ObjId
private

Definition at line 38 of file AlignmentCorrelationsIORoot.h.

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

double AlignmentCorrelationsIORoot::CorMatrix[nParMax *nParMax]
private

Definition at line 40 of file AlignmentCorrelationsIORoot.h.

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

int AlignmentCorrelationsIORoot::corSize
private

Definition at line 39 of file AlignmentCorrelationsIORoot.h.

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