30 StatusCode SystematicsSvc ::
37 return StatusCode::FAILURE;
44 ANA_MSG_ERROR (
"can't specify both sigmaRecommended and systematicsList");
45 return StatusCode::FAILURE;
48 return StatusCode::SUCCESS;
53 std::vector<CP::SystematicSet> SystematicsSvc ::
54 makeSystematicsVector ()
const
57 std::vector<CP::SystematicSet> systematicsVector;
65 sys.calc (m_recommendedSystematics);
70 if (!regex_match (mysys.name(), expr))
75 systematicsVector.push_back (mysys);
90 assert (!systematicsVector.empty());
91 return systematicsVector;
96 StatusCode SystematicsSvc ::
104 if (affecting.
find (mysys) == affecting.
end())
106 ANA_MSG_ERROR (
"systematic is only registered as recommended, not affecting: " << mysys);
107 return StatusCode::FAILURE;
111 m_affectingSystematics.insert (affecting);
112 m_recommendedSystematics.insert (recommended);
113 return StatusCode::SUCCESS;
119 getObjectSystematics (
const std::string&
name)
const
122 auto iter = m_objectSystematics.find (
name);
123 if (iter != m_objectSystematics.end())
131 StatusCode SystematicsSvc ::
132 setObjectSystematics (
const std::string&
name,
139 if (m_affectingSystematics.find (mysys) == m_affectingSystematics.end())
141 ANA_MSG_ERROR (
"systematic is set as object systematic, but not affecting: " << mysys);
142 return StatusCode::FAILURE;
145 m_objectSystematics[
name] = std::move (mysystematics);
146 return StatusCode::SUCCESS;
152 getDecorSystematics (
const std::string& objectName,
153 const std::string& decorName)
const
155 const std::string
name = objectName +
"." + decorName;
157 auto iter = m_decorSystematics.find (
name);
158 if (iter != m_decorSystematics.end())
160 auto jter = m_copies.find (objectName);
161 if (jter != m_copies.end())
163 const std::string& copyName = jter->second;
172 StatusCode SystematicsSvc ::
173 setDecorSystematics (
const std::string& objectName,
174 const std::string& decorName,
177 const std::string
name = objectName +
"." + decorName;
182 if (m_affectingSystematics.find (mysys) == m_affectingSystematics.end())
184 ANA_MSG_ERROR (
"systematic is set as object systematic, but not affecting: " << mysys);
185 return StatusCode::FAILURE;
188 m_decorSystematics[
name] = std::move (mysystematics);
189 return StatusCode::SUCCESS;
194 StatusCode SystematicsSvc ::
195 registerCopy (
const std::string& fromName,
196 const std::string& toName)
const
199 auto emplace_result = m_copies.try_emplace (toName, fromName);
200 if (emplace_result.second ==
false)
202 ANA_MSG_ERROR (
"duplicate copy registered for name " << toName);
203 return StatusCode::FAILURE;
205 return StatusCode::SUCCESS;
210 std::string SystematicsSvc ::
211 getCopySource (
const std::string& toName)
const
214 auto iter = m_copies.find (toName);
215 if (iter == m_copies.end())
223 std::vector<std::string> SystematicsSvc ::
224 getObjectDecorations (
const std::string&
name)
const
226 std::vector<std::string>
result;
230 auto iter = m_copies.find (
name);
231 if (iter != m_copies.end())
233 const std::string copyName = iter->second;
240 const std::string prefix =
name +
".";
241 for (
const auto& entry : m_decorSystematics)
243 if (entry.first.compare(0, prefix.size(), prefix) == 0)
245 std::string decor = entry.first.substr(prefix.size());
247 result.push_back (std::move(decor));
255 StatusCode SystematicsSvc ::
256 makeSystematicsName (std::string&
result,
257 const std::string&
name,
262 ANA_MSG_ERROR (
"not allowed to make systematic name for empty string");
263 return StatusCode::FAILURE;
268 const auto sysSplit =
result.find (
"%SYS%");
269 if (sysSplit == std::string::npos)
273 ANA_MSG_ERROR (
"can't set systematics on name without \"%SYS%\": \"" <<
name <<
"\" sys=" << sys.name());
274 return StatusCode::FAILURE;
278 std::string sysName = sys.name();
281 result.replace (sysSplit, 5, sysName);
284 return StatusCode::SUCCESS;
289 StatusCode SystematicsSvc ::
301 if (m_recommendedSystematics.find (mysys) == m_recommendedSystematics.end())
314 return StatusCode::SUCCESS;
static const std::vector< std::string > systematics
This class handles turning the list of systematics into the actual list of nuisance parameter points ...
Class to wrap a set of SystematicVariations.
const_iterator end() const
description: const iterator to the end of the set
iterator find(const SystematicVariation &sys) const
description: find an element in the set
Gaudi::Property< std::string > m_nominalSystematicsName
nominal systematics name
virtual std::vector< CP::SystematicSet > makeSystematicsVector() const override
Gaudi::Property< std::vector< std::string > > m_systematicsList
the names of the systematics to request
Gaudi::Property< float > m_sigmaRecommended
load all recommended systematics at the given number of sigmas
std::mutex m_systematicsMutex
a mutex for accessing the above mutable members
Gaudi::Property< std::string > m_systematicsRegex
the regular expression for filterinf systematics
virtual CP::SystematicSet getDecorSystematics(const std::string &objectName, const std::string &decorName) const override
virtual std::vector< std::string > getObjectDecorations(const std::string &name) const override
Select isolated Photons, Electrons and Muons.