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
const static int itermax = 1000
 
const static 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::AlignmentCorrelationsIORoot ( )
private

constructor

Definition at line 13 of file AlignmentCorrelationsIORoot.cc.

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

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

Member Function Documentation

◆ close()

int AlignmentCorrelationsIORoot::close ( void  )
inlineoverrideprivatevirtual

◆ createBranches()

void AlignmentCorrelationsIORoot::createBranches ( void  )
overrideprivatevirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 20 of file AlignmentCorrelationsIORoot.cc.

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 }

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

◆ open()

int AlignmentCorrelationsIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
)
inlineoverrideprivatevirtual

◆ read()

align::Correlations AlignmentCorrelationsIORoot::read ( const align::Alignables alivec,
int &  ierr 
)
overrideprivatevirtual

read correlations

Implements AlignmentCorrelationsIO.

Definition at line 71 of file AlignmentCorrelationsIORoot.cc.

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 }

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

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), and AlignmentIORoot::readCorrelations().

◆ setBranchAddresses()

void AlignmentCorrelationsIORoot::setBranchAddresses ( void  )
overrideprivatevirtual

set root branches

Implements AlignmentIORootBase.

Definition at line 31 of file AlignmentCorrelationsIORoot.cc.

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 }

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

◆ write()

int AlignmentCorrelationsIORoot::write ( const align::Correlations cor,
bool  validCheck 
)
overrideprivatevirtual

write correlations

Implements AlignmentCorrelationsIO.

Definition at line 42 of file AlignmentCorrelationsIORoot.cc.

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 }

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

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

Friends And Related Function Documentation

◆ AlignmentIORoot

friend class AlignmentIORoot
friend

Definition at line 11 of file AlignmentCorrelationsIORoot.h.

Member Data Documentation

◆ Ali1Id

align::ID AlignmentCorrelationsIORoot::Ali1Id
private

correlation tree

Definition at line 37 of file AlignmentCorrelationsIORoot.h.

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

◆ Ali1ObjId

align::StructureType AlignmentCorrelationsIORoot::Ali1ObjId
private

Definition at line 38 of file AlignmentCorrelationsIORoot.h.

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

◆ Ali2Id

align::ID AlignmentCorrelationsIORoot::Ali2Id
private

Definition at line 37 of file AlignmentCorrelationsIORoot.h.

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

◆ Ali2ObjId

align::StructureType AlignmentCorrelationsIORoot::Ali2ObjId
private

Definition at line 38 of file AlignmentCorrelationsIORoot.h.

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

◆ CorMatrix

double AlignmentCorrelationsIORoot::CorMatrix[nParMax *nParMax]
private

Definition at line 40 of file AlignmentCorrelationsIORoot.h.

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

◆ corSize

int AlignmentCorrelationsIORoot::corSize
private

Definition at line 39 of file AlignmentCorrelationsIORoot.h.

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

AlignmentIORootBase::closeRoot
int closeRoot(void)
close IO
Definition: AlignmentIORootBase.cc:92
contentValuesCheck.nfound
nfound
Definition: contentValuesCheck.py:80
AlignmentCorrelationsIORoot::Ali2Id
align::ID Ali2Id
Definition: AlignmentCorrelationsIORoot.h:37
AlignmentCorrelationsIORoot::CorMatrix
double CorMatrix[nParMax *nParMax]
Definition: AlignmentCorrelationsIORoot.h:40
mps_splice.entry
entry
Definition: mps_splice.py:68
tree
Definition: tree.py:1
Alignable
Definition: Alignable.h:27
cuy.col
col
Definition: cuy.py:1009
AlignmentIORootBase::treename
TString treename
Definition: AlignmentIORootBase.h:39
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
AlignmentParameters::isValid
bool isValid(void) const
Get validity flag.
Definition: AlignmentParameters.cc:134
AlignmentIORootBase::treetxt
TString treetxt
Definition: AlignmentIORootBase.h:40
Alignable::alignableObjectId
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
AlignmentCorrelationsIORoot::Ali1Id
align::ID Ali1Id
correlation tree
Definition: AlignmentCorrelationsIORoot.h:37
align::Correlations
std::map< std::pair< Alignable *, Alignable * >, AlgebraicMatrix > Correlations
Definition: Utilities.h:35
AlignmentCorrelationsIORoot::Ali2ObjId
align::StructureType Ali2ObjId
Definition: AlignmentCorrelationsIORoot.h:38
Alignable::id
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
Definition: Alignable.h:180
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
AlignmentIORootBase::openRoot
int openRoot(const char *filename, int iteration, bool writemode)
open IO
Definition: AlignmentIORootBase.cc:16
AlignmentIORootBase::nParMax
const static int nParMax
Definition: AlignmentIORootBase.h:43
AlignmentCorrelationsIORoot::corSize
int corSize
Definition: AlignmentCorrelationsIORoot.h:39
align_cfg.iteration
iteration
Definition: align_cfg.py:5
Alignable::alignmentParameters
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
AlignmentCorrelationsIORoot::Ali1ObjId
align::StructureType Ali1ObjId
Definition: AlignmentCorrelationsIORoot.h:38