30 theOpenMomentumRange(std::pair<float,float>(0.0, 10000.0)),
31 theMaxNumberOfParameterInstances(0)
33 std::vector<Alignable*> alis;
39 for ( std::vector<Alignable*>::iterator it = allExtras.begin(); it != allExtras.end(); ++it ) {
62 if (!alignable)
return 0;
66 return position->second;
68 const DetId detId(alignable->
id());
71 <<
"@SUB=MomentumDependentPedeLabeler::alignableLabel" <<
"Alignable "
72 <<
typeid(*alignable).name() <<
" not in map, det/subdet/alignableStructureType = "
73 << detId.det() <<
"/" << detId.subdetId() <<
"/" << alignable->
alignableObjectId();
84 if (!alignable)
return 0;
90 MomentumRangeParamMap::const_iterator positionParam = (*positionAli).second.find(param);
91 if (positionParam!=(*positionAli).second.end()) {
92 if (instance>=(*positionParam).second.size()) {
93 throw cms::Exception(
"Alignment") <<
"@SUB=MomentumDependentPedeLabeler::alignableLabelFromParamAndMomentum"
94 <<
"iovIdx out of bounds";
98 return position->second;
101 return position->second;
104 const DetId detId(alignable->
id());
107 <<
"@SUB=MomentumDependentPedeLabeler::alignableLabel" <<
"Alignable "
108 <<
typeid(*alignable).name() <<
" not in map, det/subdet/alignableStructureType = "
109 << detId.det() <<
"/" << detId.subdetId() <<
"/" << alignable->
alignableObjectId();
119 return position->second;
122 edm::LogError(
"LogicError") <<
"@SUB=MomentumDependentPedeLabeler::lasBeamLabel"
123 <<
"No label for beam Id " << lasBeamId;
132 throw cms::Exception(
"Alignment") <<
"@SUB=MomentumDependentPedeLabeler::parameterLabel"
133 <<
"Parameter number " << parNum
136 return aliLabel + parNum;
144 if (!alignable)
return 0;
147 throw cms::Exception(
"Alignment") <<
"@SUB=MomentumDependentPedeLabeler::parameterLabel"
148 <<
"Parameter number " << parNum
158 MomentumRangeParamMap::const_iterator positionParam = (*positionAli).second.find(parNum);
159 if (positionParam!=(*positionAli).second.end()) {
164 for (MomentumRangeVector::const_iterator iMomentum = momentumRanges.begin();
165 iMomentum != momentumRanges.end();
168 if (iMomentum->first<=mom && mom<iMomentum->
second) {
173 const DetId detId(alignable->
id());
175 <<
"@SUB=MomentumDependentPedeLabeler::alignableLabel" <<
"Alignable "
176 <<
typeid(*alignable).name() <<
" not in map, det/subdet/alignableStructureType = "
177 << detId.det() <<
"/" << detId.subdetId() <<
"/" << alignable->
alignableObjectId();
180 return position->second + parNum;
184 return position->second + parNum;
187 const DetId detId(alignable->
id());
190 <<
"@SUB=MomentumDependentPedeLabeler::alignableLabel" <<
"Alignable "
191 <<
typeid(*alignable).name() <<
" not in map, det/subdet/alignableStructureType = "
192 << detId.det() <<
"/" << detId.subdetId() <<
"/" << alignable->
alignableObjectId();
211 size_t nMomentums = 1;
213 for (MomentumRangeParamMap::const_iterator iParam = (*positionAli).second.begin();
214 iParam != (*positionAli).second.end();
216 nMomentums =
std::max(nMomentums, iParam->second.size());
220 MomentumRangeParamMap::const_iterator iParam = (*positionAli).second.find(param);
221 if (iParam != (*positionAli).second.end()) {
222 return iParam->second.size();
236 edm::LogError(
"LogicError") <<
"@SUB=MomentumDependentPedeLabeler::paramNumFromLabel"
237 <<
"Label " << paramLabel <<
" should be >= " <<
theMinLabel;
255 if (
theIdToAlignableMap.empty()) const_cast<MomentumDependentPedeLabeler*>(
this)->buildReverseMap();
258 return position->second;
263 edm::LogError(
"LogicError") <<
"@SUB=MomentumDependentPedeLabeler::alignableFromLabel"
264 <<
"Alignable label " << aliLabel <<
" not in map.";
276 if (
theLabelToLasBeamMap.empty()) const_cast<MomentumDependentPedeLabeler*>(
this)->buildReverseMap();
279 return position->second;
281 edm::LogError(
"LogicError") <<
"@SUB=MomentumDependentPedeLabeler::lasBeamIdFromLabel"
282 <<
"Alignable label " << aliLabel <<
" not in map.";
291 std::vector<std::string>
result;
296 if (delimiterPos == std::string::npos) {
297 result.push_back(s.substr(previousPos));
300 result.push_back(s.substr(previousPos, delimiterPos - previousPos));
301 previousPos = delimiterPos + 1;
310 std::vector<unsigned int>
result;
312 if (selString[pos]==
'1') result.push_back(pos);
326 std::vector<char> paramSelDumthe(6,
'1');
328 const std::vector<edm::ParameterSet> parameterInstancesVPSet =
329 config.
getParameter<std::vector<edm::ParameterSet> >(
"parameterInstances");
331 for (std::vector<edm::ParameterSet>::const_iterator
iter = parameterInstancesVPSet.begin();
332 iter != parameterInstancesVPSet.end();
335 const std::vector<std::string> tempMomentumRanges = (*iter).getParameter<std::vector<std::string> >(
"momentumRanges");
336 if (tempMomentumRanges.size()==0) {
337 throw cms::Exception(
"BadConfig") <<
"@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
338 <<
"MomentumRanges empty\n";
344 for (
unsigned int iMomentum=0;iMomentum<tempMomentumRanges.size();++iMomentum) {
345 std::vector<std::string> tokens =
edm::tokenize(tempMomentumRanges[iMomentum],
":");
347 lower = strtod(tokens[0].c_str(), 0);
348 upper = strtod(tokens[1].c_str(), 0);
350 MomentumRanges.push_back(std::pair<float,float>(lower, upper));
353 const std::vector<std::string> selStrings = (*iter).getParameter<std::vector<std::string> >(
"selector");
354 for (std::vector<std::string>::const_iterator iSel = selStrings.begin();
355 iSel != selStrings.end();
357 std::vector<std::string> decompSel(this->
decompose(*iSel,
','));
359 if (decompSel.size()!=2) {
360 throw cms::Exception(
"BadConfig") <<
"@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
361 << *iSel <<
" should have at least 2 ','-separated parts\n";
364 std::vector<unsigned int> selParam = this->
convertParamSel(decompSel[1]);
369 for (std::vector<Alignable*>::const_iterator iAli = alis.begin();
373 if((*iAli)->alignmentParameters() ==
NULL) {
375 <<
"@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
376 <<
"Momentum dependence configured for alignable of type "
378 <<
" at (" << (*iAli)->globalPosition().x() <<
","<< (*iAli)->globalPosition().y() <<
"," << (*iAli)->globalPosition().z()<<
"), "
379 <<
"but that has no parameters. Please check that all run "
380 <<
"momentum parameters are also selected for alignment.\n";
383 for (std::vector<unsigned int>::const_iterator iParam = selParam.begin();
384 iParam != selParam.end();
390 if (static_cast<int>(selParam[selParam.size()-1]) >= AliParams->
size()) {
391 throw cms::Exception(
"BadConfig") <<
"@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
392 <<
"mismatch in number of parameters\n";
395 MomentumRangeParamMap::const_iterator positionParam = (*positionAli).second.find(*iParam);
396 if (positionParam!=(*positionAli).second.end()) {
397 throw cms::Exception(
"BadConfig") <<
"@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
398 <<
"Momentum range for parameter specified twice\n";
416 std::vector<Alignable*> allComps;
418 for (std::vector<Alignable*>::const_iterator iAli = alis.begin(); iAli != alis.end(); ++iAli) {
420 allComps.push_back(*iAli);
421 (*iAli)->recursiveComponents(allComps);
426 for (std::vector<Alignable*>::const_iterator
iter = allComps.begin();
436 unsigned int beamIds[] = { 0, 10, 20, 30, 40, 50, 60, 70,
437 1, 11, 21, 31, 41, 51, 61, 71,
438 100, 110, 120, 130, 140, 150, 160, 170,
439 101, 111, 121, 131, 141, 151, 161, 171,
440 200, 210, 220, 230, 240, 250, 260, 270};
442 const size_t nBeams =
sizeof(beamIds)/
sizeof(beamIds[0]);
443 for (
size_t iBeam = 0; iBeam < nBeams; ++iBeam) {
450 throw cms::Exception(
"Alignment") <<
"@SUB=MomentumDependentPedeLabeler::buildMap: "
451 <<
"Too many labels per instance (" <<
id-1 <<
") leading to double use, "
452 <<
"increase PedeLabelerBase::theParamInstanceOffset!\n";
466 const unsigned int key = (*it).second;
470 for (
unsigned int iInstance=0;iInstance<nInstances;++iInstance) {
T getParameter(std::string const &) const
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
Alignable * alignableFromLabel(unsigned int label) const
unsigned int lasBeamLabel(unsigned int lasBeamId) const
static PFTauRenderPlugin instance
std::vector< std::string > decompose(const std::string &s, std::string::value_type delimiter) const
UintUintMap theLabelToLasBeamMap
labels for las beams
static const unsigned int theMinLabel
unsigned int alignableLabelFromParamAndInstance(Alignable *alignable, unsigned int param, unsigned int instance) const
unsigned int buildMap(const std::vector< Alignable * > &alis)
returns size of map
MomentumDependentPedeLabeler(const PedeLabelerBase::TopLevelAlignables &alignables, const edm::ParameterSet &config)
constructor from three Alignables (null pointers allowed )
static int position[TOTALCHAMBERS][3]
static const unsigned int theMaxNumParam
U second(std::pair< T, U > const &p)
AlignableTracker * aliTracker_
~MomentumDependentPedeLabeler()
unsigned int paramNumFromLabel(unsigned int paramLabel) const
parameter number, 0 <= .. < theMaxNumParam, belonging to unique parameter label
void clear()
remove all selected Alignables and geometrical restrictions
unsigned int numberOfParameterInstances(Alignable *alignable, int param=-1) const
returns the number of instances for a given parameter
const T & max(const T &a, const T &b)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
bool hasSplitParameters(Alignable *alignable) const
returns true if the alignable has parameters that are split into various bins
unsigned int offset(bool)
Container::value_type value_type
UintUintMap theLasBeamToLabelMap
reverse map
unsigned int buildReverseMap()
returns size of map
unsigned int parameterLabel(unsigned int aliLabel, unsigned int parNum) const
returns the label for a given alignable parameter number combination
unsigned int lasBeamIdFromLabel(unsigned int label) const
AlignableExtras * aliExtras_
const align::Alignables & selectedAlignables() const
vector of alignables selected so far
int size(void) const
Get number of parameters.
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
static const unsigned int theParamInstanceOffset
std::vector< Alignable * > Alignables
std::vector< MomentumRange > MomentumRangeVector
unsigned int addSelection(const std::string &name, const std::vector< char > ¶mSel)
unsigned int buildMomentumDependencyMap(AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *extras, const edm::ParameterSet &config)
GlobalVector globalMomentum() const
unsigned int alignableLabel(Alignable *alignable) const
Return 32-bit unique label for alignable, 0 indicates failure.
#define DEFINE_EDM_PLUGIN(factory, type, name)
unsigned int theMaxNumberOfParameterInstances
static const char * idToString(align::StructureType type)
AlignableToIdMap theAlignableToIdMap
std::vector< unsigned int > convertParamSel(const std::string &selString) const
Constructor of the full muon geometry.
AlignableToMomentumRangeMap theAlignableToMomentumRangeMap
providing unique ID for alignable, space for param IDs
define event information passed to algorithms
AlignableToIdMap::value_type AlignableToIdPair
unsigned int alignableLabelFromLabel(unsigned int label) const
alignable label from parameter label (works also for alignable label...)
IdToAlignableMap theIdToAlignableMap
providing unique ID for alignable, space for param IDs