24 const std::vector<int> &sdets)
25 : nparameters_(0), subdetids_(sdets) {
27 std::vector<std::string> parameterNames =
cfg.getParameterNames();
28 for (std::vector<std::string>::const_iterator iParam = parameterNames.begin(); iParam != parameterNames.end();
31 if (
name !=
"RunRange" &&
name !=
"ReferenceRun" &&
name !=
"Granularity") {
32 throw cms::Exception(
"BadConfig") <<
"@SUB=TkModuleGroupSelector::TkModuleGroupSelector:" 33 <<
" Unknown parameter name '" <<
name <<
"' in PSet. Maybe a typo?";
42 const std::vector<edm::RunNumber_t> defaultRunRange =
43 (
cfg.exists(
"RunRange") ?
cfg.getParameter<std::vector<edm::RunNumber_t> >(
"RunRange")
44 : std::vector<edm::RunNumber_t>());
48 aliTracker,
cfg.getParameter<
edm::VParameterSet>(
"Granularity"), defaultRunRange, defaultReferenceRun);
55 mapDetIdGroupId_.insert(std::pair<unsigned int, unsigned int>(detid, groupid));
57 throw cms::Exception(
"BadConfig") <<
"@SUB=TkModuleGroupSelector:fillDetIdMap:" 58 <<
" Module with det ID " << detid <<
" configured in group " << groupid
59 <<
" but it was already selected" 67 if (
pset.exists(
"split")) {
75 const std::vector<edm::RunNumber_t> &
range,
76 const std::list<Alignable *> &selected_alis,
78 bool modules_selected =
false;
83 for (std::list<Alignable *>::const_iterator it = selected_alis.begin(); it != selected_alis.end(); ++it) {
85 modules_selected =
true;
87 if (refrun > 0 && !
range.empty()) {
88 Id +=
range.size() - 1;
95 if (refrun > 0 &&
range.front() > refrun) {
96 throw cms::Exception(
"BadConfig") <<
"@SUB=TkModuleGroupSelector::createGroup:\n" 97 <<
"Invalid combination of reference run number and specified run dependence" 98 <<
"\n in module group " <<
firstId_.size() <<
"." 99 <<
"\n Reference run number (" << refrun <<
") is smaller than starting run " 100 <<
"\n number (" <<
range.front() <<
") of first IOV.";
102 return modules_selected;
107 std::vector<std::string> parameterNames =
pset.getParameterNames();
108 for (std::vector<std::string>::const_iterator iParam = parameterNames.begin(); iParam != parameterNames.end();
111 if (
name !=
"levels" &&
name !=
"RunRange" &&
name !=
"split" &&
name !=
"ReferenceRun") {
112 throw cms::Exception(
"BadConfig") <<
"@SUB=TkModuleGroupSelector::verifyParameterNames:" 113 <<
" Unknown parameter name '" <<
name <<
"' in PSet number " << psetnr
114 <<
". Maybe a typo?";
122 const std::vector<edm::RunNumber_t> &defaultRunRange,
124 std::set<edm::RunNumber_t> localRunRange;
127 unsigned int psetnr = 0;
129 for (edm::VParameterSet::const_iterator
pset = granularityConfig.begin();
pset != granularityConfig.end(); ++
pset) {
134 bool modules_selected =
false;
135 const std::vector<edm::RunNumber_t>
range =
136 ((*pset).exists(
"RunRange") ?
pset->getParameter<std::vector<edm::RunNumber_t> >(
"RunRange") : defaultRunRange);
138 throw cms::Exception(
"BadConfig") <<
"@SUB=TkModuleGroupSelector::createModuleGroups:\n" 139 <<
"Run range array empty!";
144 if ((*pset).exists(
"ReferenceRun")) {
147 refrun = defaultReferenceRun;
154 const auto &alis =
selector.selectedAlignables();
155 std::list<Alignable *> selected_alis;
156 for (
const auto &it : alis) {
157 const auto &aliDaughts = it->deepComponents();
158 for (
const auto &iD : aliDaughts) {
161 modules_selected = this->
createGroup(Id,
range, std::list<Alignable *>(1, iD), refrun);
163 selected_alis.push_back(iD);
174 for (std::vector<edm::RunNumber_t>::const_iterator iRun =
range.begin(); iRun !=
range.end(); ++iRun) {
175 localRunRange.insert((*iRun));
179 throw cms::Exception(
"BadConfig") <<
"@SUB=TkModuleGroupSelector::createModuleGroups:" 180 <<
" Run range not sorted.";
184 if (!modules_selected) {
185 throw cms::Exception(
"BadConfig") <<
"@SUB=TkModuleGroupSelector:createModuleGroups:" 186 <<
" No module was selected in the module group selector in group " 192 for (std::set<edm::RunNumber_t>::const_iterator itRun = localRunRange.begin(); itRun != localRunRange.end();
214 const DetId temp_id(detId);
219 for (std::vector<int>::const_iterator itSubDets =
subdetids_.begin(); itSubDets !=
subdetids_.end(); ++itSubDets) {
229 std::map<unsigned int, unsigned int>::const_iterator it =
mapDetIdGroupId_.find(detId);
231 const unsigned int iAlignableGroup = (*it).second;
232 const std::vector<edm::RunNumber_t> &
runs =
runRange_.at(iAlignableGroup);
233 const unsigned int id0 =
firstId_.at(iAlignableGroup);
236 unsigned int iovNum = 0;
237 for (; iovNum <
runs.size(); ++iovNum) {
242 throw cms::Exception(
"BadConfig") <<
"@SUB=TkModuleGroupSelector::getParameterIndexFromDetId:\n" 243 <<
"Run " <<
run <<
" not foreseen for detid '" << detId <<
"'" 244 <<
" in module group " << iAlignableGroup <<
".";
251 if (iovNum + 1 ==
runs.size()) {
252 if (refrun >=
runs[iovNum])
254 }
else if ((iovNum + 1) <
runs.size()) {
255 if (refrun >=
runs[iovNum] && refrun <
runs[iovNum + 1]) {
266 index = id0 + iovNum;
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
bool createGroup(unsigned int &Id, const std::vector< edm::RunNumber_t > &range, const std::list< Alignable *> &selected_alis, const edm::RunNumber_t refrun)
unsigned int numIovs() const
Total number of IOVs.
void verifyParameterNames(const edm::ParameterSet &pset, unsigned int psetnr) const
std::vector< int > subdetids_
std::vector< edm::RunNumber_t > globalRunRange_
std::vector< edm::RunNumber_t > referenceRun_
std::vector< ParameterSet > VParameterSet
void fillDetIdMap(const unsigned int detid, const unsigned int groupid)
unsigned int nparameters_
unsigned int getNumberOfParameters() const
constexpr Detector det() const
get the detector field from this detid
std::map< unsigned int, unsigned int > mapDetIdGroupId_
void createModuleGroups(AlignableTracker *aliTracker, const edm::VParameterSet &granularityConfig, const std::vector< edm::RunNumber_t > &defaultRunRange, edm::RunNumber_t defaultReferenceRun)
std::vector< std::vector< edm::RunNumber_t > > runRange_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
def split(sequence, size)
TkModuleGroupSelector(AlignableTracker *aliTracker, const edm::ParameterSet &cfg, const std::vector< int > &sdets)
Constructor.
const bool testSplitOption(const edm::ParameterSet &pset) const
std::vector< unsigned int > firstId_
edm::RunNumber_t firstRunOfIOV(unsigned int iovNum) const
First run of iov (0 if iovNum not treated).