-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into addAccessor
- Loading branch information
Showing
12 changed files
with
224 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2014-2023 Key4hep-Project. | ||
* | ||
* This file is part of Key4hep. | ||
* See https://key4hep.github.io/key4hep-doc/ for further info. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "EventHeaderCreator.h" | ||
#include "edm4hep/EventHeaderCollection.h" | ||
|
||
DECLARE_COMPONENT(EventHeaderCreator) | ||
|
||
EventHeaderCreator::EventHeaderCreator(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) { | ||
declareProperty("EventHeaderCollection", m_headerCol, | ||
"Name of the EventHeaderCollection that will be stored in the output root file."); | ||
} | ||
|
||
StatusCode EventHeaderCreator::initialize() { | ||
if (GaudiAlgorithm::initialize().isFailure()) | ||
return StatusCode::FAILURE; | ||
return StatusCode::SUCCESS; | ||
} | ||
|
||
StatusCode EventHeaderCreator::execute() { | ||
static int eventNumber = 0; | ||
debug() << "Filling EventHeader with runNumber " << int(m_runNumber) << " and eventNumber " | ||
<< eventNumber + m_eventNumberOffset << endmsg; | ||
auto headers = m_headerCol.createAndPut(); | ||
auto header = headers->create(); | ||
header.setRunNumber(m_runNumber); | ||
header.setEventNumber(eventNumber++ + m_eventNumberOffset); | ||
return StatusCode::SUCCESS; | ||
} | ||
|
||
StatusCode EventHeaderCreator::finalize() { | ||
if (GaudiAlgorithm::finalize().isFailure()) | ||
return StatusCode::FAILURE; | ||
return StatusCode::SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2014-2023 Key4hep-Project. | ||
* | ||
* This file is part of Key4hep. | ||
* See https://key4hep.github.io/key4hep-doc/ for further info. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef K4FWCORE_EVENTHEADERCREATOR | ||
#define K4FWCORE_EVENTHEADERCREATOR | ||
|
||
#include "GaudiAlg/GaudiAlgorithm.h" | ||
#include "k4FWCore/DataHandle.h" | ||
|
||
/*** | ||
* Algortihm that creates an EventHeader collection and fills it with eventNumber and runNumber | ||
*/ | ||
|
||
namespace edm4hep { | ||
class EventHeaderCollection; | ||
} | ||
|
||
class EventHeaderCreator : public GaudiAlgorithm { | ||
public: | ||
EventHeaderCreator(const std::string& name, ISvcLocator* svcLoc); | ||
|
||
virtual StatusCode initialize(); | ||
virtual StatusCode execute(); | ||
virtual StatusCode finalize(); | ||
|
||
private: | ||
// Run number value (fixed for the entire job, to be set by the job submitter) | ||
Gaudi::Property<int> m_runNumber{this, "runNumber", 1, "Run number value"}; | ||
// Event number offset, use it if you want two separated jobs with the same run number | ||
Gaudi::Property<int> m_eventNumberOffset{ | ||
this, "eventNumberOffset", 0, | ||
"Event number offset, eventNumber will be filled with 'event_index + eventNumberOffset'"}; | ||
// datahandle for the EventHeader | ||
DataHandle<edm4hep::EventHeaderCollection> m_headerCol{"EventHeader", Gaudi::DataHandle::Writer, this}; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Copyright (c) 2014-2023 Key4hep-Project. | ||
# | ||
# This file is part of Key4hep. | ||
# See https://key4hep.github.io/key4hep-doc/ for further info. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from Gaudi.Configuration import * | ||
|
||
from Configurables import EventHeaderCreator | ||
eventHeaderCreator = EventHeaderCreator("eventHeaderCreator", | ||
runNumber = 42, | ||
eventNumberOffset = 42, | ||
OutputLevel=DEBUG) | ||
|
||
from Configurables import k4DataSvc | ||
podioevent = k4DataSvc("EventDataSvc") | ||
|
||
from Configurables import PodioOutput | ||
out = PodioOutput("out") | ||
out.filename = "eventHeader.root" | ||
|
||
from Configurables import ApplicationMgr | ||
ApplicationMgr( | ||
TopAlg = [ | ||
eventHeaderCreator, | ||
out, | ||
], | ||
EvtSel = 'NONE', | ||
EvtMax = 2, | ||
ExtSvc = [podioevent], | ||
StopOnSignal = True) |