29 StatusCode SystematicsSvc ::
36 return StatusCode::FAILURE;
43 ANA_MSG_ERROR (
"can't specify both sigmaRecommended and systematicsList");
44 return StatusCode::FAILURE;
47 return StatusCode::SUCCESS;
52 std::vector<CP::SystematicSet> SystematicsSvc ::
53 makeSystematicsVector ()
const
56 std::vector<CP::SystematicSet> systematicsVector;
64 sys.calc (m_recommendedSystematics);
69 if (!regex_match (mysys.name(), expr))
74 systematicsVector.push_back (mysys);
89 assert (!systematicsVector.empty());
90 return systematicsVector;
95 StatusCode SystematicsSvc ::
103 if (affecting.
find (mysys) == affecting.
end())
105 ANA_MSG_ERROR (
"systematic is only registered as recommended, not affecting: " << mysys);
106 return StatusCode::FAILURE;
110 m_affectingSystematics.insert (affecting);
111 m_recommendedSystematics.insert (recommended);
112 return StatusCode::SUCCESS;
118 getObjectSystematics (
const std::string&
name)
const
121 auto iter = m_objectSystematics.find (
name);
122 if (iter != m_objectSystematics.end())
130 StatusCode SystematicsSvc ::
131 setObjectSystematics (
const std::string&
name,
138 if (m_affectingSystematics.find (mysys) == m_affectingSystematics.end())
140 ANA_MSG_ERROR (
"systematic is set as object systematic, but not affecting: " << mysys);
141 return StatusCode::FAILURE;
144 m_objectSystematics[
name] = std::move (mysystematics);
145 return StatusCode::SUCCESS;
151 getDecorSystematics (
const std::string& objectName,
152 const std::string& decorName)
const
154 const std::string
name = objectName +
"." + decorName;
156 auto iter = m_decorSystematics.find (
name);
157 if (iter != m_decorSystematics.end())
159 auto jter = m_copies.find (objectName);
160 if (jter != m_copies.end())
162 const std::string& copyName = jter->second;
171 StatusCode SystematicsSvc ::
172 setDecorSystematics (
const std::string& objectName,
173 const std::string& decorName,
176 const std::string
name = objectName +
"." + decorName;
181 if (m_affectingSystematics.find (mysys) == m_affectingSystematics.end())
183 ANA_MSG_ERROR (
"systematic is set as object systematic, but not affecting: " << mysys);
184 return StatusCode::FAILURE;
187 m_decorSystematics[
name] = std::move (mysystematics);
188 return StatusCode::SUCCESS;
193 StatusCode SystematicsSvc ::
194 registerCopy (
const std::string& fromName,
195 const std::string& toName)
const
198 auto emplace_result = m_copies.try_emplace (toName, fromName);
199 if (emplace_result.second ==
false)
201 ANA_MSG_ERROR (
"duplicate copy registered for name " << toName);
202 return StatusCode::FAILURE;
204 return StatusCode::SUCCESS;
209 std::string SystematicsSvc ::
210 getCopySource (
const std::string& toName)
const
213 auto iter = m_copies.find (toName);
214 if (iter == m_copies.end())
222 std::vector<std::string> SystematicsSvc ::
223 getObjectDecorations (
const std::string&
name)
const
225 std::vector<std::string> result;
229 auto iter = m_copies.find (
name);
230 if (iter != m_copies.end())
232 const std::string copyName = iter->second;
239 const std::string prefix =
name +
".";
240 for (
const auto& entry : m_decorSystematics)
242 if (entry.first.compare(0, prefix.size(), prefix) == 0)
244 std::string decor = entry.first.substr(prefix.size());
245 if (std::find(result.begin(), result.end(), decor) == result.end())
246 result.push_back (std::move(decor));
254 StatusCode SystematicsSvc ::
255 makeSystematicsName (std::string& result,
256 const std::string&
name,
261 ANA_MSG_ERROR (
"not allowed to make systematic name for empty string");
262 return StatusCode::FAILURE;
267 const auto sysSplit = result.find (
"%SYS%");
268 if (sysSplit == std::string::npos)
272 ANA_MSG_ERROR (
"can't set systematics on name without \"%SYS%\": \"" <<
name <<
"\" sys=" << sys.name());
273 return StatusCode::FAILURE;
277 std::string sysName = sys.name();
280 result.replace (sysSplit, 5, sysName);
283 return StatusCode::SUCCESS;
288 StatusCode SystematicsSvc ::
300 if (m_recommendedSystematics.find (mysys) == m_recommendedSystematics.end())
313 return StatusCode::SUCCESS;
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
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.