Revision: | 1.11 |
Committed: | Fri Jan 23 15:47:42 2009 UTC (16 years, 3 months ago) by ewidl |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | CMSSW_3_9_9_patch1, CMSSW_3_9_9, CMSSW_3_9_8_patch2, CMSSW_3_9_8_patch1, CMSSW_3_9_8, CMSSW_3_9_7, CMSSW_3_9_6, CMSSW_3_8_7_patch1, CMSSW_3_9_5_patch2, CMSSW_3_9_5_patch1, CMSSW_3_8_7, CMSSW_3_9_5, CMSSW_3_9_4, CMSSW_3_9_3, CMSSW_3_9_2_patch5, CMSSW_3_9_2_patch4, CMSSW_3_8_6_patch1, CMSSW_3_9_2_patch3, CMSSW_3_9_2_patch2, CMSSW_3_9_2_patch1, CMSSW_3_9_2, CMSSW_3_8_6, CMSSW_3_9_1_patch1, CMSSW_3_9_1, CMSSW_3_10_0_pre2, CMSSW_3_8_5_patch3, CMSSW_3_10_0_pre1, CMSSW_3_8_5_patch2, CMSSW_3_8_5_patch1, CMSSW_3_9_0, CMSSW_3_9_0_pre7, CMSSW_3_8_4_patch4, CMSSW_3_8_5, V03-03-02, CMSSW_3_9_0_pre6, CMSSW_3_8_4_patch3, CMSSW_3_9_0_pre5, CMSSW_3_8_4_patch2, CMSSW_3_8_4_patch1, CMSSW_3_9_0_pre4, CMSSW_3_8_4, CMSSW_3_8_3, V03-03-01, CMSSW_3_8_2_patch1, CMSSW_3_6_3_SLHC1, CMSSW_3_9_0_pre3, CMSSW_3_8_1_patch4, CMSSW_3_8_2, CMSSW_3_8_1_patch3, CMSSW_3_6_1_patch7, CMSSW_3_9_0_pre2, CMSSW_3_6_3_hltpatch4, CMSSW_3_8_1_patch2, CMSSW_3_8_1_patch1, CMSSW_3_7_1, CMSSW_3_8_1, CMSSW_3_6_3_patch2, CMSSW_3_9_0_pre1, CMSSW_3_8_0_patch1, CMSSW_3_8_0, CMSSW_3_6_1_patch6, CMSSW_3_8_0_pre8, CMSSW_3_8_0_pre7, CMSSW_3_8_0_pre6, CMSSW_3_6_3_patch1, CMSSW_3_7_0_patch4, CMSSW_3_7_0_patch3, CMSSW_3_8_0_pre5, CMSSW_3_6_1_patch5, CMSSW_3_8_0_pre4, CMSSW_3_6_3, CMSSW_3_8_0_pre2, CMSSW_3_7_0_patch2, CMSSW_3_6_2, CMSSW_3_7_0_patch1, CMSSW_3_8_0_pre1, CMSSW_3_6_1_patch4, CMSSW_3_7_0, CMSSW_3_6_1_patch3, CMSSW_3_5_7_hltpatch4, CMSSW_3_7_0_pre5, CMSSW_3_6_1_patch1, CMSSW_3_5_8_patch4, CMSSW_3_7_0_pre4, CMSSW_3_6_1, CMSSW_3_7_0_pre3, CMSSW_3_6_0_patch2, CMSSW_3_6_0_patch1, CMSSW_3_5_8_patch3, CMSSW_3_5_8_patch2, CMSSW_3_5_8_patch1, CMSSW_3_7_0_pre2, CMSSW_3_5_8, CMSSW_3_7_0_pre1, CMSSW_3_5_7, CMSSW_3_6_0, V03-02-03, CMSSW_3_6_0_pre6, CMSSW_3_6_0_pre5, CMSSW_3_5_6_patch1, CMSSW_3_5_6, CMSSW_3_5_4_patch2, CMSSW_3_5_5, CMSSW_3_6_0_pre4, CMSSW_3_5_4_patch1, CMSSW_3_6_0_pre3, CMSSW_3_5_4, CMSSW_3_5_3, CMSSW_3_6_0_pre2, CMSSW_3_5_2_patch2, CMSSW_3_5_2_patch1, CMSSW_3_6_0_pre1, V03-02-02, CMSSW_3_5_2, CMSSW_3_5_1_patch1, CMSSW_3_3_6_patch4, CMSSW_3_3_6_patch6, CMSSW_3_5_0_patch1, CMSSW_3_4_2_patch1, CMSSW_3_5_1, CMSSW_3_4_2, CMSSW_3_5_0, CMSSW_3_3_6_patch5, CMSSW_3_5_0_pre5, CMSSW_3_3_6_patch3, CMSSW_3_3_3_TSG, CMSSW_3_5_0_pre3, CMSSW_3_5_0_pre2, CMSSW_3_4_1, CMSSW_3_4_0, CMSSW_3_3_6_patch2, CMSSW_3_3_6_patch1, CMSSW_3_5_0_pre1, CMSSW_3_3_6, CMSSW_3_4_0_pre7, CMSSW_3_3_5, CMSSW_3_4_0_pre6, CMSSW_3_3_4, CMSSW_3_3_3_patch1, CMSSW_3_3_3, V03-02-01, CMSSW_3_4_0_pre5, CMSSW_3_4_0_pre4, CMSSW_3_3_2, CMSSW_3_4_0_pre3, CMSSW_3_3_1, CMSSW_3_4_0_pre2, CMSSW_3_2_8, CMSSW_3_2_7, V03-02-00, CMSSW_3_3_0, CMSSW_3_4_0_pre1, CMSSW_3_1_4, V03-01-04, CMSSW_3_3_0_pre6, V03-01-03, CMSSW_3_3_0_pre5, CMSSW_3_1_3, CMSSW_3_3_0_pre4, CMSSW_3_3_0_pre3, CMSSW_3_3_0_pre2, CMSSW_3_2_6, CMSSW_3_3_0_pre1, CMSSW_3_2_5, CMSSW_3_2_4, CMSSW_3_2_3, V03-01-02, CMSSW_3_2_2_patch2, CMSSW_3_2_2_patch1, CMSSW_3_2_2, CMSSW_3_1_2, CMSSW_3_2_1, CMSSW_3_2_0, CMSSW_3_1_1, CMSSW_3_1_0_patch1, CMSSW_3_1_0, CMSSW_3_1_0_pre11, V03-01-01, CMSSW_3_1_0_pre10, CMSSW_3_1_0_pre9, CMSSW_3_1_0_pre8, CMSSW_3_1_0_pre7, V03-01-00, V03-00-05, V03-00-04, CMSSW_3_1_0_pre6, V03-00-03, CMSSW_3_1_0_pre5, V03-00-02, V03-00-00, V02-04-00, CMSSW_3_1_0_pre4, CMSSW_3_1_0_pre3, V02-03-05, CMSSW_3_1_0_pre2, V02-03-04, V02-03-03 |
Changes since 1.10: | +13 -4 lines |
Log Message: | the tree indices are now written to file |
# | User | Rev | Content |
---|---|---|---|
1 | flucke | 1.2 | // this class's header |
2 | #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParametersIORoot.h" | ||
3 | |||
4 | flucke | 1.6 | #include "Alignment/CommonAlignment/interface/Alignable.h" |
5 | flucke | 1.9 | #include "Alignment/CommonAlignment/interface/AlignmentParameters.h" |
6 | #include "Alignment/CommonAlignmentParametrization/interface/AlignmentParametersFactory.h" | ||
7 | flucke | 1.2 | |
8 | ewidl | 1.10 | #include "FWCore/MessageLogger/interface/MessageLogger.h" |
9 | |||
10 | #include "TTree.h" | ||
11 | |||
12 | |||
13 | fronga | 1.1 | // ---------------------------------------------------------------------------- |
14 | // constructor | ||
15 | AlignmentParametersIORoot::AlignmentParametersIORoot() | ||
16 | { | ||
17 | treename = "AlignmentParameters"; | ||
18 | treetxt = "Alignment Parameters"; | ||
19 | } | ||
20 | |||
21 | ewidl | 1.10 | |
22 | fronga | 1.1 | // ---------------------------------------------------------------------------- |
23 | void AlignmentParametersIORoot::createBranches(void) | ||
24 | { | ||
25 | tree->Branch("parSize", &theCovRang, "CovRang/I"); | ||
26 | cklae | 1.8 | tree->Branch("Id", &theId, "Id/i"); |
27 | flucke | 1.9 | tree->Branch("paramType", &theParamType, "paramType/I"); |
28 | fronga | 1.1 | 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 | flucke | 1.3 | tree->Branch("HieraLevel",&theHieraLevel,"HieraLevel/I"); |
33 | fronga | 1.1 | } |
34 | |||
35 | ewidl | 1.10 | |
36 | fronga | 1.1 | // ---------------------------------------------------------------------------- |
37 | void AlignmentParametersIORoot::setBranchAddresses(void) | ||
38 | { | ||
39 | tree->SetBranchAddress("parSize", &theCovRang); | ||
40 | tree->SetBranchAddress("covarSize", &theCovarRang); | ||
41 | tree->SetBranchAddress("Id", &theId); | ||
42 | tree->SetBranchAddress("Par", &thePar); | ||
43 | flucke | 1.9 | tree->SetBranchAddress("paramType", &theParamType); |
44 | fronga | 1.1 | tree->SetBranchAddress("Cov", &theCov); |
45 | tree->SetBranchAddress("ObjId", &theObjId); | ||
46 | flucke | 1.3 | tree->SetBranchAddress("HieraLevel",&theHieraLevel); |
47 | fronga | 1.1 | } |
48 | |||
49 | |||
50 | // ---------------------------------------------------------------------------- | ||
51 | int AlignmentParametersIORoot::writeOne(Alignable* ali) | ||
52 | { | ||
53 | flucke | 1.3 | const AlignmentParameters* ap =ali->alignmentParameters(); |
54 | const AlgebraicVector& params = ap->parameters(); | ||
55 | const AlgebraicSymMatrix& cov = ap->covariance(); | ||
56 | fronga | 1.1 | |
57 | theCovRang = params.num_row(); | ||
58 | theCovarRang = theCovRang*(theCovRang+1)/2; | ||
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 | cklae | 1.7 | theId = ali->id(); |
68 | flucke | 1.9 | theParamType = ap->type(); |
69 | cklae | 1.7 | theObjId = ali->alignableObjectId(); |
70 | flucke | 1.3 | theHieraLevel = ap->hierarchyLevel(); |
71 | fronga | 1.1 | |
72 | tree->Fill(); | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | ewidl | 1.10 | |
77 | fronga | 1.1 | // ---------------------------------------------------------------------------- |
78 | flucke | 1.2 | AlignmentParameters* AlignmentParametersIORoot::readOne( Alignable* ali, int& ierr ) |
79 | fronga | 1.1 | { |
80 | |||
81 | AlgebraicVector par(nParMax,0); | ||
82 | AlgebraicSymMatrix cov(nParMax,0); | ||
83 | |||
84 | ewidl | 1.10 | if( tree->GetEntryWithIndex( ali->id(), ali->alignableObjectId() ) > 0 ) |
85 | { | ||
86 | int covsize = theCovRang; | ||
87 | int count=0; | ||
88 | for(int row=0;row<covsize;row++) | ||
89 | { | ||
90 | par[row]=thePar[row]; | ||
91 | for(int col=0; col < covsize;col++) { | ||
92 | if(row-1<col) {cov[row][col]=theCov[count];count++;} | ||
93 | } | ||
94 | } | ||
95 | |||
96 | using namespace AlignmentParametersFactory; | ||
97 | ParametersType parType = parametersType(theParamType); | ||
98 | AlignmentParameters* alipar1; | ||
99 | if ( ali->alignmentParameters() ) | ||
100 | { | ||
101 | const std::vector<bool>& sel = ali->alignmentParameters()->selector(); | ||
102 | alipar1 = createParameters(ali, parType, sel); | ||
103 | } else { | ||
104 | const std::vector<bool> sel( theCovRang, true ); | ||
105 | alipar1 = createParameters(ali, parType, sel); | ||
106 | } | ||
107 | AlignmentParameters* alipar = alipar1->clone(par,cov); | ||
108 | alipar->setValid(true); | ||
109 | ierr=0; | ||
110 | delete alipar1; | ||
111 | return alipar; | ||
112 | } | ||
113 | fronga | 1.1 | |
114 | ierr=-1; | ||
115 | return(0); | ||
116 | } | ||
117 | ewidl | 1.11 | |
118 | |||
119 | int AlignmentParametersIORoot::close() | ||
120 | { | ||
121 | if ( bWrite ) | ||
122 | { | ||
123 | int nIndices = tree->BuildIndex( "Id", "ObjId" ); | ||
124 | edm::LogInfo( "Alignment" ) << "@SUB=AlignmentParametersIORoot::setBranchAddresses" | ||
125 | << "number of indexed entries: " << nIndices; | ||
126 | } | ||
127 | |||
128 | return closeRoot(); | ||
129 | } |