File tree Expand file tree Collapse file tree 5 files changed +30
-34
lines changed Expand file tree Collapse file tree 5 files changed +30
-34
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,9 @@ target_include_directories(MarlinWrapper PUBLIC
5858gaudi_add_library(k4MarlinWrapperUtils SHARED
5959 SOURCES
6060 src/components/StoreUtils.cpp
61- LINK k4FWCore::k4FWCore
61+ LINK
62+ k4FWCore::k4FWCore
63+ k4EDM4hep2LcioConv::k4EDM4hep2LcioConv
6264)
6365
6466# EDM4hep2lcio
Original file line number Diff line number Diff line change 1717 * limitations under the License.
1818 */
1919#include " k4MarlinWrapper/converters/EDM4hep2Lcio.h"
20- #include " GlobalConvertedObjectsMap.h"
2120#include " StoreUtils.h"
2221#include < GaudiKernel/StatusCode.h>
2322
@@ -515,22 +514,7 @@ StatusCode EDM4hep2LcioTool::convertCollections(lcio::LCEventImpl* lcio_event) {
515514
516515 EDM4hep2LCIOConv::attachDqdxInfo (collection_pairs.tracks , dQdxCollections);
517516
518- // We want one "global" map that is created the first time it is used in the event.
519- DataObject* obj = nullptr ;
520- auto sc = evtSvc ()->retrieveObject (GlobalConvertedObjectsMap::TESpath.data (), obj);
521- if (sc.isFailure ()) {
522- debug () << " Creating GlobalconvertedObjectsMap for this event since it is not already in the EventStore" << endmsg;
523- auto globalObjMapWrapper = new AnyDataWrapper (GlobalConvertedObjectsMap{});
524- auto nsc = evtSvc ()->registerObject (GlobalConvertedObjectsMap::TESpath.data (), globalObjMapWrapper);
525- if (nsc.isFailure ()) {
526- error () << " Could not register GlobalConvertedObjectsMap in the EventStore" << endmsg;
527- return StatusCode::FAILURE;
528- }
529- obj = globalObjMapWrapper;
530- }
531-
532- auto globalObjMapWrapper = static_cast <AnyDataWrapper<GlobalConvertedObjectsMap>*>(obj);
533- auto & globalObjMap = globalObjMapWrapper->getData ();
517+ auto & globalObjMap = getGlobalObjectMap (this );
534518
535519 debug () << " Updating global object map" << endmsg;
536520 globalObjMap.update (collection_pairs);
Original file line number Diff line number Diff line change @@ -249,22 +249,7 @@ StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) {
249249 }
250250 }
251251
252- // We want one "global" map that is created the first time it is used in the event.
253- DataObject* obj = nullptr ;
254- auto sc = evtSvc ()->retrieveObject (GlobalConvertedObjectsMap::TESpath.data (), obj);
255- if (sc.isFailure ()) {
256- debug () << " Creating GlobalconvertedObjectsMap for this event since it is not already in the EventStore" << endmsg;
257- auto globalObjMapWrapper = new AnyDataWrapper (GlobalConvertedObjectsMap{});
258- auto nsc = evtSvc ()->registerObject (GlobalConvertedObjectsMap::TESpath.data (), globalObjMapWrapper);
259- if (nsc.isFailure ()) {
260- error () << " Could not register GlobalConvertedObjectsMap in the EventStore" << endmsg;
261- return StatusCode::FAILURE;
262- }
263- obj = globalObjMapWrapper;
264- }
265-
266- auto globalObjMapWrapper = static_cast <AnyDataWrapper<GlobalConvertedObjectsMap>*>(obj);
267- auto & globalObjMap = globalObjMapWrapper->getData ();
252+ auto & globalObjMap = getGlobalObjectMap (this );
268253
269254 globalObjMap.update (lcio2edm4hepMaps);
270255
Original file line number Diff line number Diff line change @@ -99,3 +99,24 @@ std::vector<std::string> getAvailableCollectionsFromStore(const AlgTool* thisCla
9999 }
100100 return collectionNames;
101101}
102+
103+ k4MarlinWrapper::GlobalConvertedObjectsMap& getGlobalObjectMap (AlgTool* thisTool) {
104+ // We want one "global" map that is created the first time it is used in the event.
105+ DataObject* obj = nullptr ;
106+ auto sc = thisTool->evtSvc ()->retrieveObject (k4MarlinWrapper::GlobalConvertedObjectsMap::TESpath.data (), obj);
107+ if (sc.isFailure ()) {
108+ thisTool->debug () << " Creating GlobalconvertedObjectsMap for this event since it is not already in the EventStore"
109+ << endmsg;
110+ auto globalObjMapWrapper = new AnyDataWrapper (k4MarlinWrapper::GlobalConvertedObjectsMap{});
111+ auto nsc = thisTool->evtSvc ()->registerObject (k4MarlinWrapper::GlobalConvertedObjectsMap::TESpath.data (),
112+ globalObjMapWrapper);
113+ if (nsc.isFailure ()) {
114+ thisTool->error () << " Could not register GlobalConvertedObjectsMap in the EventStore" << endmsg;
115+ throw std::runtime_error (" Could not register GlobalConvertedObjectsMap in the EventStore" );
116+ }
117+ obj = globalObjMapWrapper;
118+ }
119+
120+ auto globalObjMapWrapper = static_cast <AnyDataWrapper<k4MarlinWrapper::GlobalConvertedObjectsMap>*>(obj);
121+ return globalObjMapWrapper->getData ();
122+ }
Original file line number Diff line number Diff line change 1616 * See the License for the specific language governing permissions and
1717 * limitations under the License.
1818 */
19+ #include " GlobalConvertedObjectsMap.h"
20+
1921#include " GaudiKernel/AlgTool.h"
2022
2123#include < string>
2729std::vector<std::string> getAvailableCollectionsFromStore (const AlgTool* thisClass,
2830 std::optional<std::map<uint32_t , std::string>>& idToName,
2931 bool returnFrameCollections = false );
32+
33+ k4MarlinWrapper::GlobalConvertedObjectsMap& getGlobalObjectMap (AlgTool* thisTool);
You can’t perform that action at this time.
0 commit comments