2 Copyright (C) 2002-2025 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.
28ThinningHandleKey<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.
50template <std::derived_from<IProperty> OWNER>
51ThinningHandleKey<T>::ThinningHandleKey( OWNER* owner,
52 const std::string& name,
53 const std::string& key,
54 const std::string& doc)
55 : Base (owner, name, key, doc)
57 this->setOwner (owner);
63 * @param other Key to assign.
66ThinningHandleKey<T>& ThinningHandleKey<T>::operator= (const ThinningHandleKey& other)
68 // Don't copy m_decisionKey.
69 Base::operator= (other);
75 * @brief Change the key of the object to which we're referring.
76 * @param sgkey The StoreGate key for the object.
78 * The provided key may actually start with the name of the store,
79 * separated by a "+": "MyStore+Obj". If no "+" is present,
80 * the store is not changed.
83ThinningHandleKey<T>& ThinningHandleKey<T>::operator= (const std::string& sgkey)
85 // Don't copy m_decisionKey.
86 Base::operator= (sgkey);
92 * @brief Should be called during the initialize phase. It will fail
93 * if the requested StoreGate service cannot be found or if the key is blank.
94 * @param stream The name of the stream for which thinning is being applied.
95 * @param qualifier Qualifier to add on to the key for the decision object.
96 * If there are multiple algorithms thinning the same object,
97 * this can be used to keep them from interfering with
98 * each other. (The thinning decisions will be merged with AND
100 * @param used If false, then this handle is not to be used.
101 * Instead of normal initialization, the key will be cleared.
104StatusCode ThinningHandleKey<T>::initialize (const std::string& stream,
105 const std::string& qualifier,
106 bool used /*= true*/)
109 std::string dkey = this->fullKey().key() + "_THINNED_" + stream;
110 if (!qualifier.empty()) {
111 // Make sure that the qualifier doesn't contain any periods.
112 std::string qual = qualifier;
113 std::replace (qual.begin(), qual.end(), '.', '_');
116 m_decisionKey = dkey;
118 this->owner()->addDependency (m_decisionKey.fullKey(), Gaudi::DataHandle::Writer);
120 if (m_decisionKey.initialize (used).isFailure())
121 return StatusCode::FAILURE;
123 return Base::initialize (used);
128 * @brief Should be called during the initialize phase. It will fail
129 * if the requested StoreGate service cannot be found or if the key is blank.
130 * @param stream The name of the stream for which thinning is being applied.
131 * @param qualifier Qualifier to add on to the key for the decision object.
132 * If there are multiple algorithms thinning the same object,
133 * this can be used to keep them from interfering with
134 * each other. (The thinning decisions will be merged with AND
136 * @param used If false, then this handle is not to be used.
137 * Instead of normal initialization, the key will be cleared.
140StatusCode ThinningHandleKey<T>::initialize (const std::string& stream,
141 const char* qualifier,
142 bool used /*= true*/)
144 return initialize (stream, std::string(qualifier), used);
149 * @brief Should be called during the initialize phase. It will fail
150 * if the requested StoreGate service cannot be found or if the key is blank.
151 * @param stream The name of the stream for which thinning is being applied.
152 * @param used If false, then this handle is not to be used.
153 * Instead of normal initialization, the key will be cleared.
156StatusCode ThinningHandleKey<T>::initialize (const std::string& stream,
157 bool used /*= true*/)
159 // Use the owner name as the default qualifier.
160 // It's possible that the owner name contains periods, which we don't
161 // want here; these will be removed in the delegated @c initialize().
164 oname = this->owner()->name();
166 return initialize (stream, oname, used);
171 * @brief Return the write key for the thinning decision.
175const WriteHandleKey<ThinningDecision>&
176ThinningHandleKey<T>::decisionHandleKey() const
178 return m_decisionKey;