ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/Alignment/CommonAlignmentAlgorithm/src/AlignmentParametersIORoot.cc
Revision: 1.1
Committed: Mon Aug 7 08:49:01 2006 UTC (18 years, 9 months ago) by fronga
Content type: text/plain
Branch: MAIN
CVS Tags: CMSSW_1_2_6, CMSSW_1_2_5, CMSSW_1_2_4, CMSSW_1_2_0_4821, CMSSW_1_2_0_g4_82p01, CMSSW_1_2_3, CMSSW_1_2_0_g4_82, CMSSW_1_2_2, CMSSW_1_2_1, CMSSW_1_2_0_g4_81, CMSSW_1_2_0_SL4, CMSSW_1_2_0, CMSSW_1_2_0_pre9, CMSSW_1_2_0_pre8_g4_81, CMSSW_1_2_0_pre8, CMSSW_1_1_2, CMSSW_1_2_0_pre7, V00-07-03, CMSSW_1_2_0_pre6, CMSSW_1_2_0_pre5, V00-07-02, V00-07-01, V00-07-00, V00-06-00, CMSSW_1_2_0_pre4, V00-05-00, CMSSW_1_1_1, CMSSW_1_2_0_pre3, V00-04-00, CMSSW_1_0_6, V00-03-00, CMSSW_1_2_0_pre2, CMSSW_1_0_5, CMSSW_1_1_0, CMSSW_1_2_0_pre1, CMSSW_1_0_4, CMSSW_1_1_0_pre4, CMSSW_1_0_3, CMSSW_1_0_0_g4_81, CMSSW_1_1_0_pre3, CMSSW_1_0_2, CMSSW_1_0_1, CMSSW_1_1_0_pre2, CMSSW_1_0_0, CMSSW_1_0_0_pre5, CMSSW_1_1_0_pre1, CMSSW_1_0_0_pre4, CMSSW_1_0_0_pre3, CMSSW_1_0_0_pre2, V00-02-00, CMSSW_1_0_0_pre1, V00-01-00
Log Message:
Ported ORCA version of I/O.

File Contents

# User Rev Content
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