diff --git a/.github/workflows/key4hep.yml b/.github/workflows/key4hep.yml
index bb4e45b..738aec6 100644
--- a/.github/workflows/key4hep.yml
+++ b/.github/workflows/key4hep.yml
@@ -5,27 +5,14 @@ jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
+ matrix:
+ build_type: ["release", "nightly"]
+ image: ["alma9", "ubuntu22", "centos7"]
fail-fast: false
steps:
- - uses: actions/checkout@v3
- - uses: cvmfs-contrib/github-action-cvmfs@v3
- - uses: aidasoft/run-lcg-view@v4
+ - uses: actions/checkout@v4
+ - uses: key4hep/key4hep-actions/key4hep-build@main
with:
- container: centos7
- view-path: /cvmfs/sw-nightlies.hsf.org/key4hep
- run: |
- mkdir build
- cd build
- echo "::group::Run CMake"
- cmake -GNinja \
- -DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " \
- -DCMAKE_CXX_STANDARD=17 \
- -DCMAKE_INSTALL_PREFIX=../install \
- ..
- echo "::endgroup::" && echo "::group::Build"
- ninja -k0
- echo "::endgroup::" && echo "::group::Run Tests"
- ctest --output-on-failure
- echo "::endgroup::" && echo "::group::Install"
- ninja install
+ build_type: ${{ matrix.build_type }}
+ image: ${{ matrix.image }}
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index 499acf2..a24db65 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -7,11 +7,11 @@ jobs:
strategy:
fail-fast: false
matrix:
- COMPILER: [gcc10, clang11]
- LCG: [100]
+ COMPILER: [gcc11]
+ LCG: [104]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: cvmfs-contrib/github-action-cvmfs@v3
- uses: aidasoft/run-lcg-view@v4
with:
@@ -20,7 +20,7 @@ jobs:
run: |
mkdir build
cd build
- cmake -GNinja -C ${ILCSOFT}/ILCSoft.cmake -DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " -DINSTALL_DOC=ON ..
+ cmake -GNinja -C ${ILCSOFT}/ILCSoft.cmake -DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " ..
ninja -k0
ctest --output-on-failure
ninja install
diff --git a/doc/ReleaseNotes.md b/doc/ReleaseNotes.md
index 3b7b78f..d5b5831 100644
--- a/doc/ReleaseNotes.md
+++ b/doc/ReleaseNotes.md
@@ -1,3 +1,13 @@
+# v02-12-05
+
+* 2024-02-16 tmadlener ([PR#69](https://github.com/iLCSoft/MarlinTrkProcessors/pull/69))
+ - Use the `LCRelationNavigator` to create output relation collections with the necessary type information.
+ - This is necessary for automatic conversion from LCIO to EDM4hep when used within the MarlinWrapper and Gaudi.
+
+* 2024-02-16 tmadlener ([PR#68](https://github.com/iLCSoft/MarlinTrkProcessors/pull/68))
+ - Switch to the `key4hep-build` github action for building against key4hep stacks
+ - Update the clicdp nightlies based workflow to the latest available version of the nightlies
+
# v02-12-04
* 2023-06-12 tmadlener ([PR#66](https://github.com/iLCSoft/MarlinTrkProcessors/pull/66))
diff --git a/source/Digitisers/include/DDTPCDigiProcessor.h b/source/Digitisers/include/DDTPCDigiProcessor.h
index dfee072..88974a8 100644
--- a/source/Digitisers/include/DDTPCDigiProcessor.h
+++ b/source/Digitisers/include/DDTPCDigiProcessor.h
@@ -58,6 +58,10 @@ class Voxel_tpc;
class TPCModularEndplate ;
+namespace UTIL {
+ class LCRelationNavigator;
+}
+
/** ====== DDTPCDigiProcessor ======
*
* This Processor depends on Circle.h from MarlinUtil
@@ -138,8 +142,8 @@ class DDTPCDigiProcessor : public marlin::Processor {
*/
virtual void end() ;
- void writeVoxelToHit( Voxel_tpc* aVoxel) ;
- void writeMergedVoxelsToHit( std::vector * hitList ) ;
+ void writeVoxelToHit( Voxel_tpc* aVoxel, UTIL::LCRelationNavigator& hitSimHitNav) ;
+ void writeMergedVoxelsToHit( std::vector * hitList, UTIL::LCRelationNavigator& hitSimHitNav ) ;
void plotHelixHitResidual(MCParticle *mcp, CLHEP::Hep3Vector *thisPointRPhi);
double getPadPhi( CLHEP::Hep3Vector* thisPointRPhi, CLHEP::Hep3Vector* firstPointRPhi, CLHEP::Hep3Vector* middlePointRPhi, CLHEP::Hep3Vector* lastPointRPhi);
double getPadTheta( CLHEP::Hep3Vector* firstPointRPhi, CLHEP::Hep3Vector* middlePointRPhi, CLHEP::Hep3Vector* lastPointRPhi );
@@ -204,7 +208,6 @@ class DDTPCDigiProcessor : public marlin::Processor {
int lenpos{};
LCCollectionVec* _trkhitVec{};
- LCCollectionVec* _relCol{};
CellIDEncoder* _cellid_encoder {};
int _NSimTPCHits{};
diff --git a/source/Digitisers/src/DDSpacePointBuilder.cc b/source/Digitisers/src/DDSpacePointBuilder.cc
index 8e734b6..5bcb3b9 100644
--- a/source/Digitisers/src/DDSpacePointBuilder.cc
+++ b/source/Digitisers/src/DDSpacePointBuilder.cc
@@ -176,14 +176,10 @@ void DDSpacePointBuilder::processEvent( LCEvent * evt ) {
LCCollectionVec * spCol = new LCCollectionVec(LCIO::TRACKERHIT); // output spacepoint collection
- LCCollectionVec* relCol = new LCCollectionVec(LCIO::LCRELATION); // outpur relation collection
-
- // to store the weights
- LCFlagImpl lcFlag(0) ;
- lcFlag.setBit( LCIO::LCREL_WEIGHTED ) ;
- relCol->setFlag( lcFlag.getFlag() ) ;
-
-
+
+ // Relation navigator for creating SpacePoint - SimTrackerHit relations
+ auto spSimHitNav = UTIL::LCRelationNavigator(LCIO::TRACKERHIT, LCIO::SIMTRACKERHIT);
+
unsigned nHits = col->getNumberOfElements() ;
streamlog_out(DEBUG3) << "Number of hits: " << nHits <<"\n";
@@ -304,38 +300,22 @@ void DDSpacePointBuilder::processEvent( LCEvent * evt ) {
///////////////////////////////
// make the relations
-
if( simHitsFront.size() == 1 ){
SimTrackerHit* simHit = dynamic_cast< SimTrackerHit* >( simHitsFront[0] );
if( simHit != NULL ){
- LCRelationImpl* rel = new LCRelationImpl;
- rel->setFrom (spacePoint);
- rel->setTo (simHit);
- rel->setWeight( 0.5 );
- relCol->addElement(rel);
+ spSimHitNav.addRelation(spacePoint, simHit, 0.5);
}
}
-
-
-
if( simHitsBack.size() == 1 ){
SimTrackerHit* simHit = dynamic_cast< SimTrackerHit* >( simHitsBack[0] );
if( simHit != NULL ){
- LCRelationImpl* rel = new LCRelationImpl;
- rel->setFrom (spacePoint);
- rel->setTo (simHit);
- rel->setWeight( 0.5 );
- relCol->addElement(rel);
+ spSimHitNav.addRelation(spacePoint, simHit, 0.5);
}
}
-
-
-
-
} else {
if ( ghost_hit == true ) {
@@ -356,6 +336,7 @@ void DDSpacePointBuilder::processEvent( LCEvent * evt ) {
}
evt->addCollection( spCol, _SpacePointsCollection);
+ auto* relCol = spSimHitNav.createLCCollection();
evt->addCollection( relCol , _relColName ) ;
streamlog_out(DEBUG3)<< "\nCreated " << createdSpacePoints
diff --git a/source/Digitisers/src/DDTPCDigiProcessor.cc b/source/Digitisers/src/DDTPCDigiProcessor.cc
index db91de6..e9157d9 100644
--- a/source/Digitisers/src/DDTPCDigiProcessor.cc
+++ b/source/Digitisers/src/DDTPCDigiProcessor.cc
@@ -32,6 +32,7 @@
//
#include "UTIL/LCTrackerConf.h"
#include
+#include
// --- DD4hep ---
#include "DD4hep/Detector.h"
@@ -500,12 +501,8 @@ void DDTPCDigiProcessor::processEvent( LCEvent * evt )
// created the collection which will be written out
_trkhitVec = new LCCollectionVec( LCIO::TRACKERHIT ) ;
- _relCol = new LCCollectionVec(LCIO::LCRELATION);
-
- // to store the weights
- LCFlagImpl lcFlag(0) ;
- lcFlag.setBit( LCIO::LCREL_WEIGHTED ) ;
- _relCol->setFlag( lcFlag.getFlag() ) ;
+ // relations from created trackerhits to the SimTrackerHits that caused them
+ auto hitSimHitNav = UTIL::LCRelationNavigator(LCIO::TRACKERHIT, LCIO::SIMTRACKERHIT);
_cellid_encoder = new CellIDEncoder( lcio::LCTrackerCellID::encoding_string() , _trkhitVec ) ;
@@ -1017,7 +1014,7 @@ void DDTPCDigiProcessor::processEvent( LCEvent * evt )
}
if(seed_hit->getNumberOfAdjacent()==0){ // no adjacent hits so smear and write to hit collection
- writeVoxelToHit(seed_hit);
+ writeVoxelToHit(seed_hit, hitSimHitNav);
}
else if(seed_hit->getNumberOfAdjacent() < (_maxMerge)){ // potential 3-hit cluster, can use simple average merge.
@@ -1028,7 +1025,7 @@ void DDTPCDigiProcessor::processEvent( LCEvent * evt )
if( clusterSize <= _maxMerge ){ // merge cluster
seed_hit->setIsMerged();
- writeMergedVoxelsToHit(hitsToMerge);
+ writeMergedVoxelsToHit(hitsToMerge, hitSimHitNav);
}
delete hitsToMerge;
}
@@ -1074,7 +1071,8 @@ void DDTPCDigiProcessor::processEvent( LCEvent * evt )
// add the collection to the event
evt->addCollection( _trkhitVec , _TPCTrackerHitsCol ) ;
- evt->addCollection( _relCol , _outRelColName ) ;
+ auto relCol = hitSimHitNav.createLCCollection();
+ evt->addCollection( relCol , _outRelColName ) ;
// delete voxels
for (unsigned int i = 0; i<_tpcRowHits.size(); ++i){
@@ -1149,7 +1147,7 @@ void DDTPCDigiProcessor::end()
//
}
-void DDTPCDigiProcessor::writeVoxelToHit( Voxel_tpc* aVoxel){
+void DDTPCDigiProcessor::writeVoxelToHit( Voxel_tpc* aVoxel, UTIL::LCRelationNavigator& hitSimHitNav){
Voxel_tpc* seed_hit = aVoxel;
@@ -1261,13 +1259,8 @@ void DDTPCDigiProcessor::writeVoxelToHit( Voxel_tpc* aVoxel){
trkHit->rawHits().push_back( _tpcHitMap[seed_hit] );
}
- LCRelationImpl* rel = new LCRelationImpl;
-
- rel->setFrom (trkHit);
- rel->setTo (_tpcHitMap[seed_hit]);
- rel->setWeight( 1.0 );
- _relCol->addElement(rel);
-
+ hitSimHitNav.addRelation(trkHit, _tpcHitMap[seed_hit], 1.0);
+
_trkhitVec->addElement( trkHit );
_NRecTPCHits++;
}
@@ -1298,7 +1291,7 @@ void DDTPCDigiProcessor::writeVoxelToHit( Voxel_tpc* aVoxel){
#endif
}
-void DDTPCDigiProcessor::writeMergedVoxelsToHit( vector * hitsToMerge){
+void DDTPCDigiProcessor::writeMergedVoxelsToHit( vector * hitsToMerge, UTIL::LCRelationNavigator& hitSimHitNav){
TrackerHitImpl* trkHit = new TrackerHitImpl ;
@@ -1324,13 +1317,9 @@ void DDTPCDigiProcessor::writeMergedVoxelsToHit( vector * hitsToMerg
trkHit->rawHits().push_back( _tpcHitMap[hitsToMerge->at(ihitCluster)] );
}
- LCRelationImpl* rel = new LCRelationImpl;
-
- rel->setFrom (trkHit);
- rel->setTo (_tpcHitMap[ hitsToMerge->at(ihitCluster) ]);
- rel->setWeight( float(1.0/number_of_hits_to_merge) );
- _relCol->addElement(rel);
-
+ hitSimHitNav.addRelation(trkHit,
+ _tpcHitMap[hitsToMerge->at(ihitCluster)],
+ float(1.0/number_of_hits_to_merge));
}
double avgZ = sumZ/(hitsToMerge->size());
diff --git a/source/Refitting/include/RefitProcessor.h b/source/Refitting/include/RefitProcessor.h
index 541bed1..4be228e 100644
--- a/source/Refitting/include/RefitProcessor.h
+++ b/source/Refitting/include/RefitProcessor.h
@@ -9,6 +9,8 @@
#include
+#include
+
namespace MarlinTrk{
class IMarlinTrkSystem ;
}
@@ -79,7 +81,7 @@ class RefitProcessor : public marlin::Processor {
lcio::LCCollection* GetCollection( lcio::LCEvent * evt, std::string colName ) ;
/* helper function to get relations using try catch block */
- lcio::LCRelationNavigator* GetRelations(lcio::LCEvent * evt, std::string RelName ) ;
+ std::unique_ptr GetRelations(lcio::LCEvent * evt, std::string RelName ) ;
/** Input track collection name for refitting.
*/
diff --git a/source/Refitting/src/RefitProcessor.cc b/source/Refitting/src/RefitProcessor.cc
index e6e92bd..3ef22b9 100644
--- a/source/Refitting/src/RefitProcessor.cc
+++ b/source/Refitting/src/RefitProcessor.cc
@@ -195,7 +195,7 @@ void RefitProcessor::processEvent( LCEvent * evt ) {
// get input collection and relations
LCCollection* input_track_col = this->GetCollection( evt, _input_track_col_name ) ;
- LCRelationNavigator* input_track_rels = this->GetRelations( evt, _input_track_rel_name ) ;
+ auto input_track_rels = this->GetRelations( evt, _input_track_rel_name ) ;
if( input_track_col != 0 ){
@@ -207,12 +207,11 @@ void RefitProcessor::processEvent( LCEvent * evt ) {
LCFlagImpl trkFlag(0) ;
trkFlag.setBit( LCIO::TRBIT_HITS ) ;
trackVec->setFlag( trkFlag.getFlag() ) ;
-
- // establish the track relations collection that will be created
- LCCollectionVec* trackRelVec = new LCCollectionVec( LCIO::LCRELATION ) ;
-
+
+ // establish the track relations collection that will be created
+ auto trackRelNav = UTIL::LCRelationNavigator(LCIO::TRACK, LCIO::MCPARTICLE);
+
int nTracks = input_track_col->getNumberOfElements() ;
-
streamlog_out(DEBUG4) << "Processing input collection " << _input_track_col_name << " with " << nTracks << " tracks\n";
// loop over the input tacks and refit using KalTest
@@ -394,28 +393,18 @@ void RefitProcessor::processEvent( LCEvent * evt ) {
// assign the relations previously assigned to the input tracks
if(input_track_rels){
- LCObjectVec objVec = input_track_rels->getRelatedToObjects( track_to_refit );
- FloatVec weights = input_track_rels->getRelatedToWeights( track_to_refit );
+ const auto& objVec = input_track_rels->getRelatedToObjects( track_to_refit );
+ const auto& weights = input_track_rels->getRelatedToWeights( track_to_refit );
for( unsigned int irel=0 ; irel < objVec.size() ; ++irel ){
-
- LCRelationImpl* rel = new LCRelationImpl ;
- rel->setFrom (refittedTrack) ;
- rel->setTo ( objVec[irel] ) ;
- rel->setWeight(weights[irel]) ;
- trackRelVec->addElement( rel );
-
+ trackRelNav.addRelation(refittedTrack, objVec[irel], weights[irel]);
}
}
-
-
-
- }
+ }
evt->addCollection( trackVec , _output_track_col_name) ;
+ auto trackRelVec = trackRelNav.createLCCollection();
evt->addCollection( trackRelVec , _output_track_rel_name) ;
- delete input_track_rels; input_track_rels = 0;
-
}
++_n_evt ;
}
@@ -452,13 +441,13 @@ LCCollection* RefitProcessor::GetCollection( LCEvent * evt, std::string colName
}
-LCRelationNavigator* RefitProcessor::GetRelations(LCEvent * evt , std::string RelName ) {
+std::unique_ptr RefitProcessor::GetRelations(LCEvent * evt , std::string RelName ) {
- LCRelationNavigator* nav = 0 ;
+ std::unique_ptr nav = nullptr;
try{
- nav = new LCRelationNavigator(evt->getCollection( RelName.c_str() ));
- streamlog_out( DEBUG2 ) << "RefitProcessor --> " << RelName << " track relation collection in event = " << nav << std::endl;
+ nav.reset(new LCRelationNavigator(evt->getCollection( RelName.c_str() )));
+ streamlog_out( DEBUG2 ) << "RefitProcessor --> " << RelName << " track relation collection in event = " << nav.get() << std::endl;
}
catch(DataNotAvailableException &e){
streamlog_out( DEBUG2 ) << "RefitProcessor --> " << RelName.c_str() << " track relation collection absent in event" << std::endl;