CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 close IO More...
 
void createBranches (void)
 create root branches More...
 
int open (const char *filename, int iteration, bool writemode)
 open IO More...
 
align::Correlations read (const align::Alignables &alivec, int &ierr)
 read correlations More...
 
void setBranchAddresses (void)
 set root branches More...
 
int write (const align::Correlations &cor, bool validCheck)
 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  )
inlineprivatevirtual
void AlignmentCorrelationsIORoot::createBranches ( void  )
privatevirtual

create root branches

Implements AlignmentIORootBase.

Definition at line 21 of file AlignmentCorrelationsIORoot.cc.

References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, CorMatrix, corSize, and AlignmentIORootBase::tree.

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
int AlignmentCorrelationsIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
)
inlineprivatevirtual

open IO

Implements AlignmentCorrelationsIO.

Definition at line 20 of file AlignmentCorrelationsIORoot.h.

References AlignmentIORootBase::openRoot().

Referenced by Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::importConfig(), AlignmentIORoot::readCorrelations(), and AlignmentIORoot::writeCorrelations().

20  {
21  return openRoot(filename,iteration,writemode);
22  };
tuple iteration
Definition: align_cfg.py:5
int openRoot(const char *filename, int iteration, bool writemode)
open IO
tuple filename
Definition: lut2db_cfg.py:20
align::Correlations AlignmentCorrelationsIORoot::read ( const align::Alignables alivec,
int &  ierr 
)
privatevirtual

read correlations

Implements AlignmentCorrelationsIO.

Definition at line 79 of file AlignmentCorrelationsIORoot.cc.

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

Referenced by 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:31
CLHEP::HepMatrix AlgebraicMatrix
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
int col
Definition: cuy.py:1008
void AlignmentCorrelationsIORoot::setBranchAddresses ( void  )
privatevirtual

set root branches

Implements AlignmentIORootBase.

Definition at line 33 of file AlignmentCorrelationsIORoot.cc.

References Ali1Id, Ali1ObjId, Ali2Id, Ali2ObjId, CorMatrix, corSize, and AlignmentIORootBase::tree.

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
int AlignmentCorrelationsIORoot::write ( const align::Correlations cor,
bool  validCheck 
)
privatevirtual

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(), AlignmentParameters::isValid(), and AlignmentIORootBase::tree.

Referenced by pkg.AbstractPkg::generate(), 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:180
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
CLHEP::HepMatrix AlgebraicMatrix
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
bool isValid(void) const
Get validity flag.
int col
Definition: cuy.py:1008

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