test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignmentParametersIORoot.cc
Go to the documentation of this file.
1 // this class's header
3 
7 
9 
10 #include "TTree.h"
11 
12 
13 // ----------------------------------------------------------------------------
14 // constructor
16 {
17  treename = "AlignmentParameters";
18  treetxt = "Alignment Parameters";
19 }
20 
21 
22 // ----------------------------------------------------------------------------
24 {
25  tree->Branch("parSize", &theCovRang, "CovRang/I");
26  tree->Branch("Id", &theId, "Id/i");
27  tree->Branch("paramType", &theParamType, "paramType/I");
28  tree->Branch("Par", &thePar, "Par[CovRang]/D");
29  tree->Branch("covarSize", &theCovarRang, "CovarRang/I");
30  tree->Branch("Cov", &theCov, "Cov[CovarRang]/D");
31  tree->Branch("ObjId", &theObjId, "ObjId/I");
32  tree->Branch("HieraLevel",&theHieraLevel,"HieraLevel/I");
33 }
34 
35 
36 // ----------------------------------------------------------------------------
38 {
39  tree->SetBranchAddress("parSize", &theCovRang);
40  tree->SetBranchAddress("covarSize", &theCovarRang);
41  tree->SetBranchAddress("Id", &theId);
42  tree->SetBranchAddress("Par", &thePar);
43  tree->SetBranchAddress("paramType", &theParamType);
44  tree->SetBranchAddress("Cov", &theCov);
45  tree->SetBranchAddress("ObjId", &theObjId);
46  tree->SetBranchAddress("HieraLevel",&theHieraLevel);
47 }
48 
49 
50 // ----------------------------------------------------------------------------
52 {
53  const AlignmentParameters* ap =ali->alignmentParameters();
54  const AlgebraicVector& params = ap->parameters();
55  const AlgebraicSymMatrix& cov = ap->covariance();
56 
57  theCovRang = params.num_row();
59  int count=0;
60  for(int row=0;row<theCovRang;row++){
61  thePar[row]=params[row];
62  for(int col=0;col<theCovRang;col++){
63  if(row-1<col) { theCov[count] = cov[row][col]; count++; }
64  }
65  }
66 
67  theId = ali->id();
68  theParamType = ap->type();
69  theObjId = ali->alignableObjectId();
71 
72  tree->Fill();
73  return 0;
74 }
75 
76 
77 // ----------------------------------------------------------------------------
79 {
80 
81  if( tree->GetEntryWithIndex( ali->id(), ali->alignableObjectId() ) > 0 )
82  {
83  int covsize = theCovRang;
84  int count=0;
85  AlgebraicVector par(covsize, 0);
86  AlgebraicSymMatrix cov(covsize, 0);
87  for(int row=0;row<covsize;row++)
88  {
89  par[row]=thePar[row];
90  for(int col=0; col < covsize;col++) {
91  if(row-1<col) {cov[row][col]=theCov[count];count++;}
92  }
93  }
94 
95  using namespace AlignmentParametersFactory;
97  AlignmentParameters* alipar1;
98  if ( ali->alignmentParameters() )
99  {
100  const std::vector<bool>& sel = ali->alignmentParameters()->selector();
101  alipar1 = createParameters(ali, parType, sel);
102  } else {
103  const std::vector<bool> sel( theCovRang, true );
104  alipar1 = createParameters(ali, parType, sel);
105  }
106  AlignmentParameters* alipar = alipar1->clone(par,cov);
107  alipar->setValid(true);
108  ierr=0;
109  delete alipar1;
110  return alipar;
111  }
112 
113  ierr=-1;
114  return(0);
115 }
116 
117 
119 {
120  if ( bWrite )
121  {
122  int nIndices = tree->BuildIndex( "Id", "ObjId" );
123  edm::LogInfo( "Alignment" ) << "@SUB=AlignmentParametersIORoot::setBranchAddresses"
124  << "number of indexed entries: " << nIndices;
125  }
126 
127  return closeRoot();
128 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:185
int writeOne(Alignable *ali)
Write AlignmentParameters of one Alignable.
AlignmentParameters * readOne(Alignable *ali, int &ierr)
Read AlignmentParameters of one Alignable.
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
ParametersType
enums for all available AlignmentParameters
const AlgebraicVector & parameters(void) const
Get alignment parameters.
void createBranches(void)
Create all branches and give names.
double theCov[nParMax *(nParMax+1)/2]
void setValid(bool v)
Set validity flag.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignmentParameters * createParameters(Alignable *ali, ParametersType parType, const std::vector< bool > &sel)
CLHEP::HepVector AlgebraicVector
virtual int type() const =0
tell type (AlignmentParametersFactory::ParametersType - but no circular dependency) ...
int closeRoot(void)
close IO
virtual AlignmentParameters * clone(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Enforce clone methods in derived classes.
void setBranchAddresses(void)
Set branch adresses.
CLHEP::HepSymMatrix AlgebraicSymMatrix
ParametersType parametersType(const std::string &typeString)
convert string to ParametersType - exception if not known
virtual unsigned int hierarchyLevel() const
int col
Definition: cuy.py:1008
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.