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 //__________________________________________________________________________________________________
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 }
AlignableObjectId::typeToName
std::string typeToName(align::StructureType type) const
Convert type to name.
Definition: AlignableObjectId.cc:256
start
Definition: start.py:1
MessageLogger.h
MisalignmentScenarioBuilder::hasParameter_
bool hasParameter_(const std::string &name, const edm::ParameterSet &pSet) const
Check if given parameter exists in parameter set.
Definition: MisalignmentScenarioBuilder.cc:271
TrackerScenarioBuilder::isTopLevel_
bool isTopLevel_(const std::string &parameterSetName) const override
does this still make sense?
Definition: TrackerScenarioBuilder.cc:56
geometry
Definition: geometry.py:1
align::TOBModule
Definition: StructureType.h:54
edm::LogInfo
Definition: MessageLogger.h:254
align::TIBModule
Definition: StructureType.h:38
AlignableTracker::objectIdProvider
const AlignableObjectId & objectIdProvider() const
Return tracker alignable object ID provider derived from the tracker's geometry.
Definition: AlignableTracker.h:110
TrackerScenarioBuilder.h
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
TrackerScenarioBuilder::theAlignableTracker
AlignableTracker * theAlignableTracker
Definition: TrackerScenarioBuilder.h:44
TrackerScenarioBuilder::applyScenario
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the tracker.
Definition: TrackerScenarioBuilder.cc:39
AlignableTracker
Definition: AlignableTracker.h:17
MisalignmentScenarioBuilder
Base class to build a scenario from configuration and apply to either tracker or muon.
Definition: MisalignmentScenarioBuilder.h:22
AlignableTracker::subStructures
Alignables & subStructures(const std::string &subStructName)
Definition: AlignableTracker.h:27
MisalignmentScenarioBuilder::theModifierCounter
int theModifierCounter
Counter for applied modification.
Definition: MisalignmentScenarioBuilder.h:80
cmsdt::scenario
scenario
Definition: constants.h:166
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
align::StructureType
StructureType
Definition: StructureType.h:16
edm::ParameterSet
Definition: ParameterSet.h:36
MisalignmentScenarioBuilder::theModifier
AlignableModifier theModifier
Helper class for random movements.
Definition: MisalignmentScenarioBuilder.h:78
TrackerScenarioBuilder::theFirstStripIndex
unsigned int theFirstStripIndex
index of first strip subdet in 'theSubdets' (pixel<strip)
Definition: TrackerScenarioBuilder.h:47
TrackerScenarioBuilder::possiblyPartOf
bool possiblyPartOf(const std::string &sub, const std::string &large) const override
True if hierarchy level 'sub' could be part of hierarchy level 'large'.
Definition: TrackerScenarioBuilder.cc:67
TrackerScenarioBuilder::theSubdets
std::vector< std::string > theSubdets
following things are needed in possiblyPartOf:
Definition: TrackerScenarioBuilder.h:46
root
Definition: RooFitFunction.h:10
TrackerScenarioBuilder::stripOffModule
std::string stripOffModule(const align::StructureType &type) const
Definition: TrackerScenarioBuilder.cc:107
align::TIDModule
Definition: StructureType.h:47
module
Definition: vlib.h:198
type
type
Definition: HCALResponse.h:21
align::TPEModule
Definition: StructureType.h:30
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MisalignmentScenarioBuilder::decodeMovements_
void decodeMovements_(const edm::ParameterSet &, const align::Alignables &)
Decode movements defined in given parameter set for given set of alignables.
Definition: MisalignmentScenarioBuilder.cc:28
Exception.h
TrackerScenarioBuilder::TrackerScenarioBuilder
TrackerScenarioBuilder(AlignableTracker *alignable)
Constructor.
Definition: TrackerScenarioBuilder.cc:22
MisalignmentScenarioBuilder::rootName_
const std::string rootName_(const std::string &parameterSetName) const
Get root name of a parameter set (e.g. 'Rod' in 'Rods' or 'Rod1')
Definition: MisalignmentScenarioBuilder.cc:336
AlignableTracker.h
AlignableModifier::setSeed
void setSeed(long seed)
Resets the generator seed according to the argument.
Definition: AlignableModifier.cc:277
align::TECModule
Definition: StructureType.h:61
align::TPBModule
Definition: StructureType.h:23