CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TrackerScenarioBuilder.cc
Go to the documentation of this file.
1 
9 #include <string>
10 #include <iostream>
11 #include <sstream>
12 
13 // Framework
16 
17 // Alignment
20 
21 //__________________________________________________________________________________________________
23  : MisalignmentScenarioBuilder(alignable->objectIdProvider().geometry()), theAlignableTracker(alignable) {
24  if (!theAlignableTracker) {
25  throw cms::Exception("TypeMismatch") << "Pointer to AlignableTracker is empty.\n";
26  }
27 
28  // Fill what is needed for possiblyPartOf(..):
29  theSubdets.push_back(stripOffModule(align::TPBModule)); // Take care, order matters: 1st pixel, 2nd strip.
36 }
37 
38 //__________________________________________________________________________________________________
40  // Apply the scenario to all main components of tracker.
42 
43  // Seed is set at top-level, and is mandatory
44  if (this->hasParameter_("seed", scenario))
45  theModifier.setSeed(static_cast<long>(scenario.getParameter<int>("seed")));
46  else
47  throw cms::Exception("BadConfig") << "No generator seed defined!";
48 
49  // misalignment applied recursively ('subStructures("Tracker")' contains only tracker itself)
50  this->decodeMovements_(scenario, theAlignableTracker->subStructures("Tracker"));
51 
52  edm::LogInfo("TrackerScenarioBuilder") << "Applied modifications to " << theModifierCounter << " alignables";
53 }
54 
55 //__________________________________________________________________________________________________
56 bool TrackerScenarioBuilder::isTopLevel_(const std::string& parameterSetName) const {
57  // Get root name (strip last character [s])
58  std::string root = this->rootName_(parameterSetName);
59 
60  if (root == "Tracker")
61  return true;
62 
63  return false;
64 }
65 
66 //__________________________________________________________________________________________________
67 bool TrackerScenarioBuilder::possiblyPartOf(const std::string& subStruct, const std::string& largeStr) const {
68  // string::find(s) != nPos => 's' is contained in string!
69  const std::string::size_type nPos = std::string::npos;
70 
71  // First check whether anything from pixel in strip.
72  if (largeStr.find("Strip") != nPos) {
73  if (subStruct.find("Pixel") != nPos)
74  return false;
75  for (unsigned int iPix = 0; iPix < theFirstStripIndex; ++iPix) {
76  if (subStruct.find(theSubdets[iPix]) != nPos)
77  return false;
78  }
79  }
80 
81  // Now check whether anything from strip in pixel.
82  if (largeStr.find("Pixel") != nPos) {
83  if (subStruct.find("Strip") != nPos)
84  return false;
85  for (unsigned int iStrip = theFirstStripIndex; iStrip < theSubdets.size(); ++iStrip) {
86  if (subStruct.find(theSubdets[iStrip]) != nPos)
87  return false;
88  }
89  }
90 
91  // Finally check for any different detector parts, e.g. TIDEndcap/TIBString gives false.
92  for (unsigned int iSub = 0; iSub < theSubdets.size(); ++iSub) {
93  for (unsigned int iLarge = 0; iLarge < theSubdets.size(); ++iLarge) {
94  if (iLarge == iSub)
95  continue;
96  if (largeStr.find(theSubdets[iLarge]) != nPos && subStruct.find(theSubdets[iSub]) != nPos) {
97  return false;
98  }
99  }
100  }
101 
102  // It seems like a possible combination:
103  return true;
104 }
105 
106 //__________________________________________________________________________________________________
108  const std::string module{"Module"};
110  auto start = name.find(module);
111  if (start == std::string::npos) {
112  throw cms::Exception("LogicError") << "[TrackerScenarioBuilder] '" << name << "' is not a module type";
113  }
114  name.replace(start, module.length(), "");
115  return name;
116 }
std::string stripOffModule(const align::StructureType &type) const
void decodeMovements_(const edm::ParameterSet &, const align::Alignables &)
Decode movements defined in given parameter set for given set of alignables.
void setSeed(long seed)
Resets the generator seed according to the argument.
std::string typeToName(align::StructureType type) const
Convert type to name.
uint16_t size_type
unsigned int theFirstStripIndex
index of first strip subdet in &#39;theSubdets&#39; (pixel&lt;strip)
scenario
Definition: constants.h:173
bool isTopLevel_(const std::string &parameterSetName) const override
does this still make sense?
const std::string rootName_(const std::string &parameterSetName) const
Get root name of a parameter set (e.g. &#39;Rod&#39; in &#39;Rods&#39; or &#39;Rod1&#39;)
std::vector< std::string > theSubdets
following things are needed in possiblyPartOf:
TrackerScenarioBuilder(AlignableTracker *alignable)
Constructor.
const AlignableObjectId & objectIdProvider() const
Return tracker alignable object ID provider derived from the tracker&#39;s geometry.
Log< level::Info, false > LogInfo
AlignableModifier theModifier
Helper class for random movements.
Base class to build a scenario from configuration and apply to either tracker or muon.
Alignables & subStructures(const std::string &subStructName)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the tracker.
int theModifierCounter
Counter for applied modification.
bool hasParameter_(const std::string &name, const edm::ParameterSet &pSet) const
Check if given parameter exists in parameter set.
bool possiblyPartOf(const std::string &sub, const std::string &large) const override
True if hierarchy level &#39;sub&#39; could be part of hierarchy level &#39;large&#39;.
AlignableTracker * theAlignableTracker
tuple module
Definition: callgraph.py:69