Revision: | 1.17 |
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_8_7_patch1, CMSSW_3_8_7, CMSSW_3_8_6_patch1, CMSSW_3_8_6, CMSSW_3_8_5_patch3, CMSSW_3_8_5_patch2, CMSSW_3_8_5_patch1, CMSSW_3_8_4_patch4, CMSSW_3_8_5, CMSSW_3_8_4_patch3, CMSSW_3_8_4_patch2, CMSSW_3_8_4_patch1, CMSSW_3_9_0_pre4, CMSSW_3_8_4, CMSSW_3_8_3, 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, CMSSW_3_0_0_pre10, CMSSW_3_0_0_pre9, CMSSW_3_1_0_pre1, CMSSW_3_0_0_pre8, V02-03-03, CMSSW_3_0_0_pre7, V02-03-02, 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.16: | +42 -22 lines |
Log Message: | Make choice of AlignmentParameters configurable, it was hardcoded to RigidBody before. RigidBody will become default in configuration of AlignmentProducer. |
# | User | Rev | Content |
---|---|---|---|
1 | flucke | 1.5 | /** \file AlignableParameterBuilder.cc |
2 | * | ||
3 | flucke | 1.17 | * $Date: 2007/10/08 14:38:16 $ |
4 | * $Revision: 1.16 $ | ||
5 | fronga | 1.13 | |
6 | */ | ||
7 | flucke | 1.5 | |
8 | flucke | 1.17 | // This class's header should be first: |
9 | #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterBuilder.h" | ||
10 | |||
11 | fronga | 1.1 | #include "FWCore/MessageLogger/interface/MessageLogger.h" |
12 | flucke | 1.8 | #include "FWCore/ParameterSet/interface/ParameterSet.h" |
13 | flucke | 1.17 | #include "FWCore/Utilities/interface/Exception.h" |
14 | flucke | 1.8 | |
15 | fronga | 1.1 | #include "Alignment/CommonAlignment/interface/Alignable.h" |
16 | flucke | 1.17 | #include "Alignment/CommonAlignment/interface/AlignmentParameters.h" |
17 | fronga | 1.1 | |
18 | flucke | 1.17 | #include "Alignment/CommonAlignmentParametrization/interface/AlignmentParametersFactory.h" |
19 | fronga | 1.1 | |
20 | flucke | 1.9 | #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterSelector.h" |
21 | flucke | 1.12 | #include "Alignment/CommonAlignmentAlgorithm/interface/SelectionUserVariables.h" |
22 | flucke | 1.8 | |
23 | fronga | 1.1 | |
24 | flucke | 1.17 | using namespace AlignmentParametersFactory; |
25 | fronga | 1.1 | |
26 | //__________________________________________________________________________________________________ | ||
27 | flucke | 1.8 | AlignmentParameterBuilder::AlignmentParameterBuilder(AlignableTracker* alignableTracker) : |
28 | fronga | 1.13 | theAlignables(), theAlignableTracker(alignableTracker), theAlignableMuon(0) |
29 | { | ||
30 | } | ||
31 | |||
32 | //__________________________________________________________________________________________________ | ||
33 | AlignmentParameterBuilder::AlignmentParameterBuilder(AlignableTracker* alignableTracker, | ||
34 | AlignableMuon* alignableMuon) : | ||
35 | theAlignables(), theAlignableTracker(alignableTracker), theAlignableMuon(alignableMuon) | ||
36 | { | ||
37 | } | ||
38 | |||
39 | |||
40 | //__________________________________________________________________________________________________ | ||
41 | AlignmentParameterBuilder::AlignmentParameterBuilder(AlignableTracker* alignableTracker, | ||
42 | const edm::ParameterSet &pSet) : | ||
43 | theAlignables(), theAlignableTracker(alignableTracker), theAlignableMuon(0) | ||
44 | fronga | 1.1 | { |
45 | flucke | 1.17 | this->addAllSelections(pSet); |
46 | flucke | 1.8 | } |
47 | fronga | 1.1 | |
48 | flucke | 1.8 | //__________________________________________________________________________________________________ |
49 | AlignmentParameterBuilder::AlignmentParameterBuilder(AlignableTracker* alignableTracker, | ||
50 | fronga | 1.13 | AlignableMuon* alignableMuon, |
51 | const edm::ParameterSet &pSet) : | ||
52 | theAlignables(), theAlignableTracker(alignableTracker), theAlignableMuon(alignableMuon) | ||
53 | flucke | 1.8 | { |
54 | flucke | 1.17 | this->addAllSelections(pSet); |
55 | fronga | 1.1 | } |
56 | |||
57 | flucke | 1.17 | //__________________________________________________________________________________________________ |
58 | void AlignmentParameterBuilder::addAllSelections(const edm::ParameterSet &pSet) | ||
59 | { | ||
60 | AlignmentParameterSelector selector(0); | ||
61 | std::vector<std::string> selsTypes(pSet.getParameter<std::vector<std::string> >("parameterTypes")); | ||
62 | |||
63 | for (unsigned int i = 0; i < selsTypes.size(); ++i) { | ||
64 | std::vector<std::string> selSetType(selector.decompose(selsTypes[i], ',')); | ||
65 | if (selSetType.size() != 2) { | ||
66 | throw cms::Exception("BadConfig") << "AlignmentParameterBuilder" | ||
67 | << "parameterTypes should contain 2 comma separated strings" | ||
68 | << ", but found '" << selsTypes[i] << "'."; | ||
69 | } | ||
70 | this->addSelections(pSet.getParameter<edm::ParameterSet>(selSetType[0]), | ||
71 | AlignmentParametersFactory::parametersType(selSetType[1])); | ||
72 | } | ||
73 | } | ||
74 | fronga | 1.13 | |
75 | fronga | 1.1 | //__________________________________________________________________________________________________ |
76 | flucke | 1.17 | unsigned int AlignmentParameterBuilder::addSelections(const edm::ParameterSet &pSet, |
77 | ParametersType parType) | ||
78 | flucke | 1.8 | { |
79 | |||
80 | flucke | 1.17 | const unsigned int oldAliSize = theAlignables.size(); |
81 | |||
82 | fronga | 1.13 | AlignmentParameterSelector selector( theAlignableTracker, theAlignableMuon ); |
83 | const unsigned int addedSets = selector.addSelections(pSet); | ||
84 | flucke | 1.8 | |
85 | cklae | 1.16 | const align::Alignables &alignables = selector.selectedAlignables(); |
86 | fronga | 1.13 | const std::vector<std::vector<char> > ¶mSels = selector.selectedParameters(); |
87 | |||
88 | cklae | 1.16 | align::Alignables::const_iterator iAli = alignables.begin(); |
89 | fronga | 1.13 | std::vector<std::vector<char> >::const_iterator iParamSel = paramSels.begin(); |
90 | unsigned int nHigherLevel = 0; | ||
91 | |||
92 | while (iAli != alignables.end() && iParamSel != paramSels.end()) { | ||
93 | std::vector<bool> boolParSel; | ||
94 | bool charSelIsGeneral = this->decodeParamSel(*iParamSel, boolParSel); | ||
95 | flucke | 1.17 | if (this->add(*iAli, parType, boolParSel)) ++nHigherLevel; |
96 | fronga | 1.13 | if (charSelIsGeneral) this->addFullParamSel((*iAli)->alignmentParameters(), *iParamSel); |
97 | |||
98 | ++iAli; | ||
99 | ++iParamSel; | ||
100 | } | ||
101 | flucke | 1.5 | |
102 | fronga | 1.13 | edm::LogInfo("Alignment") << "@SUB=AlignmentParameterBuilder::addSelections" |
103 | << " Added " << addedSets << " set(s) of alignables with " | ||
104 | flucke | 1.17 | << theAlignables.size() - oldAliSize << " alignables in total," |
105 | << " of which " << nHigherLevel << " are higher level " | ||
106 | << "(using " << parametersTypeName(parType) << "AlignmentParameters)."; | ||
107 | flucke | 1.9 | |
108 | fronga | 1.13 | return addedSets; |
109 | flucke | 1.5 | } |
110 | |||
111 | //__________________________________________________________________________________________________ | ||
112 | flucke | 1.17 | bool AlignmentParameterBuilder::add(Alignable *alignable, |
113 | ParametersType parType, | ||
114 | const std::vector<bool> &sel) | ||
115 | flucke | 1.9 | { |
116 | flucke | 1.17 | AlignmentParameters *paras = AlignmentParametersFactory::createParameters(alignable, parType, sel); |
117 | flucke | 1.9 | alignable->setAlignmentParameters(paras); |
118 | theAlignables.push_back(alignable); | ||
119 | |||
120 | flucke | 1.15 | const int aliTypeId = alignable->alignableObjectId(); |
121 | cklae | 1.16 | const bool isHigherLevel = (aliTypeId != align::AlignableDet |
122 | && aliTypeId != align::AlignableDetUnit); | ||
123 | flucke | 1.9 | return isHigherLevel; |
124 | flucke | 1.5 | } |
125 | |||
126 | |||
127 | //__________________________________________________________________________________________________ | ||
128 | cklae | 1.16 | unsigned int AlignmentParameterBuilder::add(const align::Alignables &alignables, |
129 | flucke | 1.17 | ParametersType parType, const std::vector<bool> &sel) |
130 | flucke | 1.5 | { |
131 | |||
132 | flucke | 1.9 | unsigned int nHigherLevel = 0; |
133 | fronga | 1.1 | |
134 | cklae | 1.16 | for (align::Alignables::const_iterator iAli = alignables.begin(); |
135 | flucke | 1.9 | iAli != alignables.end(); ++iAli) { |
136 | flucke | 1.17 | if (this->add(*iAli, parType, sel)) ++nHigherLevel; |
137 | fronga | 1.1 | } |
138 | |||
139 | flucke | 1.9 | return nHigherLevel; |
140 | fronga | 1.1 | } |
141 | |||
142 | |||
143 | //__________________________________________________________________________________________________ | ||
144 | void AlignmentParameterBuilder::fixAlignables(int n) | ||
145 | { | ||
146 | |||
147 | fpschill | 1.3 | if (n<1 || n>3) { |
148 | flucke | 1.5 | edm::LogError("BadArgument") << " n = " << n << " is not in [1,3]"; |
149 | fronga | 1.1 | return; |
150 | } | ||
151 | |||
152 | cklae | 1.16 | align::Alignables theNewAlignables; |
153 | fronga | 1.1 | int i=0; |
154 | int imax = theAlignables.size(); | ||
155 | cklae | 1.16 | for ( align::Alignables::const_iterator ia=theAlignables.begin(); |
156 | fronga | 1.1 | ia!=theAlignables.end(); ia++ ) |
157 | { | ||
158 | i++; | ||
159 | if ( n==1 && i>1 ) | ||
160 | theNewAlignables.push_back(*ia); | ||
161 | else if ( n==2 && i>1 && i<imax ) | ||
162 | theNewAlignables.push_back(*ia); | ||
163 | else if ( n==3 && i>2 && i<imax) | ||
164 | theNewAlignables.push_back(*ia); | ||
165 | } | ||
166 | |||
167 | theAlignables = theNewAlignables; | ||
168 | |||
169 | flucke | 1.10 | edm::LogInfo("Alignment") << "@SUB=AlignmentParameterBuilder::fixAlignables" |
170 | << "removing " << n << " alignables, so that " | ||
171 | << theAlignables.size() << " alignables left"; | ||
172 | fronga | 1.1 | } |
173 | |||
174 | flucke | 1.12 | //__________________________________________________________________________________________________ |
175 | bool AlignmentParameterBuilder::decodeParamSel(const std::vector<char> ¶mSelChar, | ||
176 | std::vector<bool> &result) const | ||
177 | { | ||
178 | result.clear(); | ||
179 | bool anyNon01 = false; | ||
180 | |||
181 | for (unsigned int pos = 0; pos < paramSelChar.size(); ++pos) { | ||
182 | |||
183 | switch (paramSelChar[pos]) { | ||
184 | default: | ||
185 | anyNon01 = true; | ||
186 | // no break; | ||
187 | case '1': | ||
188 | result.push_back(true); | ||
189 | break; | ||
190 | case '0': | ||
191 | result.push_back(false); | ||
192 | break; | ||
193 | } | ||
194 | } | ||
195 | |||
196 | return anyNon01; | ||
197 | } | ||
198 | |||
199 | //__________________________________________________________________________________________________ | ||
200 | bool AlignmentParameterBuilder::addFullParamSel(AlignmentParameters *aliParams, | ||
201 | const std::vector<char> &fullSel) const | ||
202 | { | ||
203 | if (!aliParams) return false; | ||
204 | |||
205 | aliParams->setUserVariables(new SelectionUserVariables(fullSel)); | ||
206 | |||
207 | return true; | ||
208 | } |