ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/Alignment/CommonAlignmentAlgorithm/src/AlignmentParametersIORoot.cc
Revision: 1.9
Committed: Tue Sep 2 15:31:23 2008 UTC (16 years, 8 months ago) by flucke
Content type: text/plain
Branch: MAIN
CVS Tags: CMSSW_3_0_0_pre10, CMSSW_3_0_0_pre9, CMSSW_3_1_0_pre1, CMSSW_3_0_0_pre8, CMSSW_3_0_0_pre7, CMSSW_3_0_0_pre6, CMSSW_3_0_0_pre5, CMSSW_3_0_0_pre4, V02-03-01, CMSSW_3_0_0_pre3, V02-03-00
Changes since 1.8: +11 -4 lines
Log Message:
Make choice of AlignmentParameters configurable,
it was hardcoded to RigidBody before.
RigidBody will become default in configuration of AlignmentProducer.

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