-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a Gaudi Algorithm filling EventHeader eventNumber and runNumber #133
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1fc1572
Add a Gaudi Algorithm filling EventHeader eventNumber and runNumber
BrieucF bb7d60e
EventHeaderFiller --> EventHeaderCreator
BrieucF b5e4aef
Fix typo in EventHeaderCollection declareProperty
BrieucF e03d061
Merge branch 'main' into eventHeader
BrieucF 5863dbe
Merge branch 'main' into eventHeader
BrieucF 8b839e3
Update test/k4FWCoreTest/CMakeLists.txt
BrieucF f3c0484
Apply modification suggested by pre-commit
BrieucF feedae3
Add output file with eventHeader collection in the test
BrieucF 1f30df8
Merge branch 'main' into eventHeader
tmadlener File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stupid question (and I should know this), does this produce the expected output file if we don't use our Key4hep data service (
k4DataSvc
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand you question correctly: this steering file does not produce any output file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, you are obviously right. Could you make it produce an output file by adding the necessary algorithm. Mainly to make everyone see how a complete example looks like and so that they then also have an output file that they can look at after running the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, here it is