ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/Alignment/CommonAlignmentAlgorithm/src/AlignmentParametersIORoot.cc
Revision: 1.7
Committed: Mon Oct 8 14:38:16 2007 UTC (17 years, 6 months ago) by cklae
Content type: text/plain
Branch: MAIN
CVS Tags: CMSSW_1_8_0_pre2, CMSSW_1_8_0_pre1, V02-00-00
Branch point for: NewHierarchy165
Changes since 1.6: +7 -18 lines
Log Message:
Changes wrt CommmonAlignment and TrackerAlignment (use align::ID and StructureType). Clean up header files.

File Contents

# User Rev Content
1 flucke 1.2 // this class's header
2     #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParametersIORoot.h"
3    
4 cklae 1.7 #include "TTree.h"
5    
6 flucke 1.6 #include "Alignment/CommonAlignment/interface/Alignable.h"
7 flucke 1.5 #include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters.h"
8 flucke 1.2
9 fronga 1.1 // ----------------------------------------------------------------------------
10     // constructor
11    
12     AlignmentParametersIORoot::AlignmentParametersIORoot()
13     {
14     treename = "AlignmentParameters";
15     treetxt = "Alignment Parameters";
16     }
17    
18     // ----------------------------------------------------------------------------
19    
20     void AlignmentParametersIORoot::createBranches(void)
21     {
22     tree->Branch("parSize", &theCovRang, "CovRang/I");
23     tree->Branch("Id", &theId, "Id/I");
24     tree->Branch("Par", &thePar, "Par[CovRang]/D");
25     tree->Branch("covarSize", &theCovarRang, "CovarRang/I");
26     tree->Branch("Cov", &theCov, "Cov[CovarRang]/D");
27     tree->Branch("ObjId", &theObjId, "ObjId/I");
28 flucke 1.3 tree->Branch("HieraLevel",&theHieraLevel,"HieraLevel/I");
29 fronga 1.1 }
30    
31     // ----------------------------------------------------------------------------
32    
33     void AlignmentParametersIORoot::setBranchAddresses(void)
34     {
35     tree->SetBranchAddress("parSize", &theCovRang);
36     tree->SetBranchAddress("covarSize", &theCovarRang);
37     tree->SetBranchAddress("Id", &theId);
38     tree->SetBranchAddress("Par", &thePar);
39     tree->SetBranchAddress("Cov", &theCov);
40     tree->SetBranchAddress("ObjId", &theObjId);
41 flucke 1.3 tree->SetBranchAddress("HieraLevel",&theHieraLevel);
42 fronga 1.1 }
43    
44     // ----------------------------------------------------------------------------
45    
46 cklae 1.7 int AlignmentParametersIORoot::findEntry(align::ID id, align::StructureType comp)
47 fronga 1.1 {
48     double noAliPar = tree->GetEntries();
49     for (int ev = 0;ev<noAliPar;ev++) {
50     tree->GetEntry(ev);
51 cklae 1.7 if ( theId==id && theObjId==comp ) return (ev);
52 fronga 1.1 }
53     return -1;
54     }
55    
56     // ----------------------------------------------------------------------------
57     int AlignmentParametersIORoot::writeOne(Alignable* ali)
58     {
59 flucke 1.3 const AlignmentParameters* ap =ali->alignmentParameters();
60     const AlgebraicVector& params = ap->parameters();
61     const AlgebraicSymMatrix& cov = ap->covariance();
62 fronga 1.1
63     theCovRang = params.num_row();
64     theCovarRang = theCovRang*(theCovRang+1)/2;
65     int count=0;
66     for(int row=0;row<theCovRang;row++){
67     thePar[row]=params[row];
68     for(int col=0;col<theCovRang;col++){
69     if(row-1<col) { theCov[count] = cov[row][col]; count++; }
70     }
71     }
72    
73 cklae 1.7 theId = ali->id();
74     theObjId = ali->alignableObjectId();
75 flucke 1.3 theHieraLevel = ap->hierarchyLevel();
76 fronga 1.1
77     tree->Fill();
78     return 0;
79     }
80    
81     // ----------------------------------------------------------------------------
82    
83 flucke 1.2 AlignmentParameters* AlignmentParametersIORoot::readOne( Alignable* ali, int& ierr )
84 fronga 1.1 {
85    
86 flucke 1.5 AlignmentParameters* alipar = 0;
87 fronga 1.1 AlgebraicVector par(nParMax,0);
88     AlgebraicSymMatrix cov(nParMax,0);
89 flucke 1.5 const std::vector<bool> &sel = ali->alignmentParameters()->selector();
90 fronga 1.1
91 cklae 1.7 int entry = findEntry( ali->id(), ali->alignableObjectId() );
92 fronga 1.1 if( entry != -1 )
93     {
94     tree->GetEntry(entry);
95     int covsize = theCovRang;
96     int count=0;
97     for(int row=0;row<covsize;row++)
98     {
99     par[row]=thePar[row];
100     for(int col=0; col < covsize;col++) {
101     if(row-1<col) {cov[row][col]=theCov[count];count++;}
102     }
103     }
104 flucke 1.5 // FIXME: In future should check which kind of parameters to construct...
105     alipar = new RigidBodyAlignmentParameters(ali,par,cov,sel);
106 fronga 1.1 alipar->setValid(true);
107     ierr=0;
108     return alipar;
109     }
110    
111     ierr=-1;
112     return(0);
113     }