2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 * @file StoreGate/ThinningHandleKey.icc
6 * @author scott snyder <snyder@bnl.gov>
8 * @brief HandleKey object for adding thinning to an object.
20 * @param key The StoreGate key for the object.
21 * @param storeName Name to use for the store, if it's not encoded in sgkey.
23 * The provided key may actually start with the name of the store,
24 * separated by a "+": "MyStore+Obj". If no "+" is present
25 * the store named by @c storeName is used.
28 ThinningHandleKey<T>::ThinningHandleKey
29 (const std::string& key /*= ""*/,
30 const std::string& storeName /*= StoreID::storeName(StoreID::EVENT_STORE)*/)
31 : Base (key, storeName)
37 * @brief Auto-declaring Property constructor.
38 * @param owner Owning component.
39 * @param name Name of the Property.
40 * @param key Default StoreGate key for the object.
41 * @param doc Documentation string.
43 * Will associate the named Property with this key via declareProperty.
45 * The provided key may actually start with the name of the store,
46 * separated by a "+": "MyStore+Obj". If no "+" is present
47 * the store named by @c storeName is used.
50 template <class OWNER,
51 typename /*= typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type*/>
52 ThinningHandleKey<T>::ThinningHandleKey( OWNER* owner,
53 const std::string& name,
54 const std::string& key,
55 const std::string& doc)
56 : Base (owner, name, key, doc)
58 this->setOwner (owner);
64 * @param other Key to assign.
67 ThinningHandleKey<T>& ThinningHandleKey<T>::operator= (const ThinningHandleKey& other)
69 // Don't copy m_decisionKey.
70 Base::operator= (other);
76 * @brief Change the key of the object to which we're referring.
77 * @param sgkey The StoreGate key for the object.
79 * The provided key may actually start with the name of the store,
80 * separated by a "+": "MyStore+Obj". If no "+" is present,
81 * the store is not changed.
84 ThinningHandleKey<T>& ThinningHandleKey<T>::operator= (const std::string& sgkey)
86 // Don't copy m_decisionKey.
87 Base::operator= (sgkey);
93 * @brief Should be called during the initialize phase. It will fail
94 * if the requested StoreGate service cannot be found or if the key is blank.
95 * @param stream The name of the stream for which thinning is being applied.
96 * @param qualifier Qualifier to add on to the key for the decision object.
97 * If there are multiple algorithms thinning the same object,
98 * this can be used to keep them from interfering with
99 * each other. (The thinning decisions will be merged with AND
101 * @param used If false, then this handle is not to be used.
102 * Instead of normal initialization, the key will be cleared.
105 StatusCode ThinningHandleKey<T>::initialize (const std::string& stream,
106 const std::string& qualifier,
107 bool used /*= true*/)
110 std::string dkey = this->fullKey().key() + "_THINNED_" + stream;
111 if (!qualifier.empty()) {
112 // Make sure that the qualifier doesn't contain any periods.
113 std::string qual = qualifier;
114 std::replace (qual.begin(), qual.end(), '.', '_');
117 m_decisionKey = dkey;
119 this->owner()->addDependency (m_decisionKey.fullKey(), Gaudi::DataHandle::Writer);
121 if (m_decisionKey.initialize (used).isFailure())
122 return StatusCode::FAILURE;
124 return Base::initialize (used);
129 * @brief Should be called during the initialize phase. It will fail
130 * if the requested StoreGate service cannot be found or if the key is blank.
131 * @param stream The name of the stream for which thinning is being applied.
132 * @param qualifier Qualifier to add on to the key for the decision object.
133 * If there are multiple algorithms thinning the same object,
134 * this can be used to keep them from interfering with
135 * each other. (The thinning decisions will be merged with AND
137 * @param used If false, then this handle is not to be used.
138 * Instead of normal initialization, the key will be cleared.
141 StatusCode ThinningHandleKey<T>::initialize (const std::string& stream,
142 const char* qualifier,
143 bool used /*= true*/)
145 return initialize (stream, std::string(qualifier), used);
150 * @brief Should be called during the initialize phase. It will fail
151 * if the requested StoreGate service cannot be found or if the key is blank.
152 * @param stream The name of the stream for which thinning is being applied.
153 * @param used If false, then this handle is not to be used.
154 * Instead of normal initialization, the key will be cleared.
157 StatusCode ThinningHandleKey<T>::initialize (const std::string& stream,
158 bool used /*= true*/)
160 // Use the owner name as the default qualifier.
161 // It's possible that the owner name contains periods, which we don't
162 // want here; these will be removed in the delegated @c initialize().
165 oname = this->owner()->name();
167 return initialize (stream, oname, used);
172 * @brief Return the write key for the thinning decision.
176 const WriteHandleKey<ThinningDecision>&
177 ThinningHandleKey<T>::decisionHandleKey() const
179 return m_decisionKey;