File indexing completed on 2024-04-06 11:57:29
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <string>
0010 #include <iostream>
0011 #include <sstream>
0012
0013
0014 #include "FWCore/Utilities/interface/Exception.h"
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016
0017
0018 #include "Alignment/TrackerAlignment/interface/TrackerScenarioBuilder.h"
0019 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
0020
0021
0022 TrackerScenarioBuilder::TrackerScenarioBuilder(AlignableTracker* alignable)
0023 : MisalignmentScenarioBuilder(alignable->objectIdProvider().geometry()), theAlignableTracker(alignable) {
0024 if (!theAlignableTracker) {
0025 throw cms::Exception("TypeMismatch") << "Pointer to AlignableTracker is empty.\n";
0026 }
0027
0028
0029 theSubdets.push_back(stripOffModule(align::TPBModule));
0030 theSubdets.push_back(stripOffModule(align::TPEModule));
0031 theFirstStripIndex = theSubdets.size();
0032 theSubdets.push_back(stripOffModule(align::TIBModule));
0033 theSubdets.push_back(stripOffModule(align::TIDModule));
0034 theSubdets.push_back(stripOffModule(align::TOBModule));
0035 theSubdets.push_back(stripOffModule(align::TECModule));
0036 }
0037
0038
0039 void TrackerScenarioBuilder::applyScenario(const edm::ParameterSet& scenario) {
0040
0041 theModifierCounter = 0;
0042
0043
0044 if (this->hasParameter_("seed", scenario))
0045 theModifier.setSeed(static_cast<long>(scenario.getParameter<int>("seed")));
0046 else
0047 throw cms::Exception("BadConfig") << "No generator seed defined!";
0048
0049
0050 this->decodeMovements_(scenario, theAlignableTracker->subStructures("Tracker"));
0051
0052 edm::LogInfo("TrackerScenarioBuilder") << "Applied modifications to " << theModifierCounter << " alignables";
0053 }
0054
0055
0056 bool TrackerScenarioBuilder::isTopLevel_(const std::string& parameterSetName) const {
0057
0058 std::string root = this->rootName_(parameterSetName);
0059
0060 if (root == "Tracker")
0061 return true;
0062
0063 return false;
0064 }
0065
0066
0067 bool TrackerScenarioBuilder::possiblyPartOf(const std::string& subStruct, const std::string& largeStr) const {
0068
0069 const std::string::size_type nPos = std::string::npos;
0070
0071
0072 if (largeStr.find("Strip") != nPos) {
0073 if (subStruct.find("Pixel") != nPos)
0074 return false;
0075 for (unsigned int iPix = 0; iPix < theFirstStripIndex; ++iPix) {
0076 if (subStruct.find(theSubdets[iPix]) != nPos)
0077 return false;
0078 }
0079 }
0080
0081
0082 if (largeStr.find("Pixel") != nPos) {
0083 if (subStruct.find("Strip") != nPos)
0084 return false;
0085 for (unsigned int iStrip = theFirstStripIndex; iStrip < theSubdets.size(); ++iStrip) {
0086 if (subStruct.find(theSubdets[iStrip]) != nPos)
0087 return false;
0088 }
0089 }
0090
0091
0092 for (unsigned int iSub = 0; iSub < theSubdets.size(); ++iSub) {
0093 for (unsigned int iLarge = 0; iLarge < theSubdets.size(); ++iLarge) {
0094 if (iLarge == iSub)
0095 continue;
0096 if (largeStr.find(theSubdets[iLarge]) != nPos && subStruct.find(theSubdets[iSub]) != nPos) {
0097 return false;
0098 }
0099 }
0100 }
0101
0102
0103 return true;
0104 }
0105
0106
0107 std::string TrackerScenarioBuilder::stripOffModule(const align::StructureType& type) const {
0108 const std::string module{"Module"};
0109 std::string name{theAlignableTracker->objectIdProvider().typeToName(type)};
0110 auto start = name.find(module);
0111 if (start == std::string::npos) {
0112 throw cms::Exception("LogicError") << "[TrackerScenarioBuilder] '" << name << "' is not a module type";
0113 }
0114 name.replace(start, module.length(), "");
0115 return name;
0116 }