CMS 3D CMS Logo

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 
22 //__________________________________________________________________________________________________
24  MisalignmentScenarioBuilder(alignable->objectIdProvider().geometry()),
25  theAlignableTracker(alignable)
26 {
27 
28  if (!theAlignableTracker) {
29  throw cms::Exception("TypeMismatch") << "Pointer to AlignableTracker is empty.\n";
30  }
31 
32  // Fill what is needed for possiblyPartOf(..):
33  theSubdets.push_back(stripOffModule(align::TPBModule)); // Take care, order matters: 1st pixel, 2nd strip.
40 }
41 
42 
43 //__________________________________________________________________________________________________
45 {
46 
47  // Apply the scenario to all main components of tracker.
49 
50  // Seed is set at top-level, and is mandatory
51  if ( this->hasParameter_( "seed", scenario) )
52  theModifier.setSeed( static_cast<long>(scenario.getParameter<int>("seed")) );
53  else
54  throw cms::Exception("BadConfig") << "No generator seed defined!";
55 
56  // misalignment applied recursively ('subStructures("Tracker")' contains only tracker itself)
57  this->decodeMovements_(scenario, theAlignableTracker->subStructures("Tracker"));
58 
59  edm::LogInfo("TrackerScenarioBuilder")
60  << "Applied modifications to " << theModifierCounter << " alignables";
61 
62 }
63 
64 
65 //__________________________________________________________________________________________________
66 bool TrackerScenarioBuilder::isTopLevel_(const std::string &parameterSetName) const
67 {
68  // Get root name (strip last character [s])
69  std::string root = this->rootName_(parameterSetName);
70 
71  if (root == "Tracker") return true;
72 
73  return false;
74 }
75 
76 //__________________________________________________________________________________________________
77 bool TrackerScenarioBuilder::possiblyPartOf(const std::string &subStruct, const std::string &largeStr) const
78 {
79  // string::find(s) != nPos => 's' is contained in string!
80  const std::string::size_type nPos = std::string::npos;
81 
82  // First check whether anything from pixel in strip.
83  if (largeStr.find("Strip") != nPos) {
84  if (subStruct.find("Pixel") != nPos) return false;
85  for (unsigned int iPix = 0; iPix < theFirstStripIndex; ++iPix) {
86  if (subStruct.find(theSubdets[iPix]) != nPos) return false;
87  }
88  }
89 
90  // Now check whether anything from strip in pixel.
91  if (largeStr.find("Pixel") != nPos) {
92  if (subStruct.find("Strip") != nPos) return false;
93  for (unsigned int iStrip = theFirstStripIndex; iStrip < theSubdets.size(); ++iStrip) {
94  if (subStruct.find(theSubdets[iStrip]) != nPos) return false;
95  }
96  }
97 
98  // Finally check for any different detector parts, e.g. TIDEndcap/TIBString gives false.
99  for (unsigned int iSub = 0; iSub < theSubdets.size(); ++iSub) {
100  for (unsigned int iLarge = 0; iLarge < theSubdets.size(); ++iLarge) {
101  if (iLarge == iSub) continue;
102  if (largeStr.find(theSubdets[iLarge]) != nPos && subStruct.find(theSubdets[iSub]) != nPos) {
103  return false;
104  }
105  }
106  }
107 
108  // It seems like a possible combination:
109  return true;
110 }
111 
112 //__________________________________________________________________________________________________
114  const std::string module{"Module"};
116  auto start = name.find(module);
117  if (start == std::string::npos) {
118  throw cms::Exception("LogicError")
119  << "[TrackerScenarioBuilder] '" << name << "' is not a module type";
120  }
121  name.replace(start, module.length(), "");
122  return name;
123 }
Definition: start.py:1
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
bool isTopLevel_(const std::string &parameterSetName) const override
does this still make sense?
std::string stripOffModule(const align::StructureType &type) const
void setSeed(long seed)
Resets the generator seed according to the argument.
std::string typeToName(align::StructureType type) const
Convert type to name.
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;.
uint16_t size_type
unsigned int theFirstStripIndex
index of first strip subdet in &#39;theSubdets&#39; (pixel<strip)
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.
void decodeMovements_(const edm::ParameterSet &pSet, const std::vector< Alignable * > &alignables)
Decode movements defined in given parameter set for given set of alignables.
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)
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.
AlignableTracker * theAlignableTracker
Definition: vlib.h:208