1 |
fronga |
1.1 |
#include "Alignment/TrackerAlignment/interface/TrackerAlignableId.h"
|
2 |
|
|
|
3 |
|
|
// this class's header
|
4 |
|
|
#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParametersIORoot.h"
|
5 |
|
|
|
6 |
|
|
// ----------------------------------------------------------------------------
|
7 |
|
|
// constructor
|
8 |
|
|
|
9 |
|
|
AlignmentParametersIORoot::AlignmentParametersIORoot()
|
10 |
|
|
{
|
11 |
|
|
treename = "AlignmentParameters";
|
12 |
|
|
treetxt = "Alignment Parameters";
|
13 |
|
|
}
|
14 |
|
|
|
15 |
|
|
// ----------------------------------------------------------------------------
|
16 |
|
|
|
17 |
|
|
void AlignmentParametersIORoot::createBranches(void)
|
18 |
|
|
{
|
19 |
|
|
tree->Branch("parSize", &theCovRang, "CovRang/I");
|
20 |
|
|
tree->Branch("Id", &theId, "Id/I");
|
21 |
|
|
tree->Branch("Par", &thePar, "Par[CovRang]/D");
|
22 |
|
|
tree->Branch("covarSize", &theCovarRang, "CovarRang/I");
|
23 |
|
|
tree->Branch("Cov", &theCov, "Cov[CovarRang]/D");
|
24 |
|
|
tree->Branch("ObjId", &theObjId, "ObjId/I");
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
// ----------------------------------------------------------------------------
|
28 |
|
|
|
29 |
|
|
void AlignmentParametersIORoot::setBranchAddresses(void)
|
30 |
|
|
{
|
31 |
|
|
tree->SetBranchAddress("parSize", &theCovRang);
|
32 |
|
|
tree->SetBranchAddress("covarSize", &theCovarRang);
|
33 |
|
|
tree->SetBranchAddress("Id", &theId);
|
34 |
|
|
tree->SetBranchAddress("Par", &thePar);
|
35 |
|
|
tree->SetBranchAddress("Cov", &theCov);
|
36 |
|
|
tree->SetBranchAddress("ObjId", &theObjId);
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
// ----------------------------------------------------------------------------
|
40 |
|
|
// find tree entry based on detID and typeID
|
41 |
|
|
|
42 |
|
|
int AlignmentParametersIORoot::findEntry(unsigned int detId,int comp)
|
43 |
|
|
{
|
44 |
|
|
double noAliPar = tree->GetEntries();
|
45 |
|
|
for (int ev = 0;ev<noAliPar;ev++) {
|
46 |
|
|
tree->GetEntry(ev);
|
47 |
|
|
if ( theId==detId && theObjId==comp ) return (ev);
|
48 |
|
|
}
|
49 |
|
|
return -1;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
// ----------------------------------------------------------------------------
|
53 |
|
|
int AlignmentParametersIORoot::writeOne(Alignable* ali)
|
54 |
|
|
{
|
55 |
|
|
AlignmentParameters* ap =ali->alignmentParameters();
|
56 |
|
|
AlgebraicVector params = ap->parameters();
|
57 |
|
|
AlgebraicSymMatrix cov = ap->covariance();
|
58 |
|
|
|
59 |
|
|
theCovRang = params.num_row();
|
60 |
|
|
theCovarRang = theCovRang*(theCovRang+1)/2;
|
61 |
|
|
int count=0;
|
62 |
|
|
for(int row=0;row<theCovRang;row++){
|
63 |
|
|
thePar[row]=params[row];
|
64 |
|
|
for(int col=0;col<theCovRang;col++){
|
65 |
|
|
if(row-1<col) { theCov[count] = cov[row][col]; count++; }
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
TrackerAlignableId converter;
|
70 |
|
|
theId = converter.alignableId(ali);
|
71 |
|
|
theObjId = converter.alignableTypeId(ali);
|
72 |
|
|
|
73 |
|
|
tree->Fill();
|
74 |
|
|
return 0;
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
// ----------------------------------------------------------------------------
|
78 |
|
|
|
79 |
|
|
AlignmentParameters* AlignmentParametersIORoot::readOne( Alignable* ali,
|
80 |
|
|
int& ierr )
|
81 |
|
|
{
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
TrackerAlignableId converter;
|
85 |
|
|
int obj = converter.alignableTypeId(ali);
|
86 |
|
|
unsigned int detInt = converter.alignableId(ali);
|
87 |
|
|
|
88 |
|
|
AlignmentParameters* alipar;
|
89 |
|
|
AlgebraicVector par(nParMax,0);
|
90 |
|
|
AlgebraicSymMatrix cov(nParMax,0);
|
91 |
|
|
std::vector<bool> sel = ali->alignmentParameters()->selector();
|
92 |
|
|
|
93 |
|
|
int entry = findEntry(detInt,obj);
|
94 |
|
|
if( entry != -1 )
|
95 |
|
|
{
|
96 |
|
|
tree->GetEntry(entry);
|
97 |
|
|
int covsize = theCovRang;
|
98 |
|
|
int count=0;
|
99 |
|
|
for(int row=0;row<covsize;row++)
|
100 |
|
|
{
|
101 |
|
|
par[row]=thePar[row];
|
102 |
|
|
for(int col=0; col < covsize;col++) {
|
103 |
|
|
if(row-1<col) {cov[row][col]=theCov[count];count++;}
|
104 |
|
|
}
|
105 |
|
|
}
|
106 |
|
|
if (obj == 0 ) // create parameters for sensor
|
107 |
|
|
alipar = new RigidBodyAlignmentParameters(ali,par,cov,sel);
|
108 |
|
|
else // create parameters for composed object
|
109 |
|
|
alipar = new CompositeRigidBodyAlignmentParameters(ali,par,cov,sel);
|
110 |
|
|
alipar->setValid(true);
|
111 |
|
|
ierr=0;
|
112 |
|
|
return alipar;
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
ierr=-1;
|
116 |
|
|
return(0);
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
|