Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
myliu-hub authored Mar 11, 2024
2 parents 5664a31 + f519663 commit 65ab1b6
Show file tree
Hide file tree
Showing 143 changed files with 4,949 additions and 522 deletions.
1 change: 0 additions & 1 deletion .build.ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ logfile=mylog.txt

if [ "$LCG_RELEASE" = "KEY4HEP_STACK" ]; then
logfile=mylog-k4.sh
source /cvmfs/sw.hsf.org/key4hep/setup.sh
./build-k4.sh >& ${logfile} &
buildpid=$!
else
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: self-hosted
strategy:
matrix:
LCG_RELEASE: [LCG_101, KEY4HEP_STACK]
LCG_RELEASE: [LCG_EXTERNAL, KEY4HEP_STACK]
# CEPCSW_BLDTOOL: [make, ninja]
CEPCSW_BLDTOOL: [ninja]

Expand Down
1 change: 1 addition & 0 deletions Analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

add_subdirectory(TotalInvMass)
add_subdirectory(TrackInspect)
add_subdirectory(DumpEvent)
2 changes: 2 additions & 0 deletions Analysis/DumpEvent/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
gaudi_add_module(DumpEvent
SOURCES src/DumpMCParticleAlg.cpp
src/DumpSimHitAlg.cpp
#src/DumpHitAlg.cpp
src/DumpTrackAlg.cpp
#src/DumpCalorimeterAlg.cpp
Expand All @@ -10,6 +11,7 @@ gaudi_add_module(DumpEvent
${CLHEP_LIBRARIES}
${DD4hep_COMPONENT_LIBRARIES}
DetInterface
k4FWCore::k4FWCore
)

install(TARGETS DumpEvent
Expand Down
4 changes: 2 additions & 2 deletions Analysis/DumpEvent/src/DumpMCParticleAlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ StatusCode DumpMCParticleAlg::execute(){
m_charge[m_nParticles] = particle.getCharge();
m_time[m_nParticles] = particle.getTime();
m_mass[m_nParticles] = particle.getMass();
const edm4hep::Vector3d& vertex = particle.getVertex();
const auto& vertex = particle.getVertex();
m_vx[m_nParticles] = vertex.x;
m_vy[m_nParticles] = vertex.y;
m_vz[m_nParticles] = vertex.z;
const edm4hep::Vector3f& momentum = particle.getMomentum();
const auto& momentum = particle.getMomentum();
m_px[m_nParticles] = momentum.x;
m_py[m_nParticles] = momentum.y;
m_pz[m_nParticles] = momentum.z;
Expand Down
83 changes: 83 additions & 0 deletions Analysis/DumpEvent/src/DumpSimHitAlg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Description:
* Dump the simulated information.
*
* Author:
* Tao Lin <lintao AT ihep.ac.cn>
*/

#include "k4FWCore/DataHandle.h"
#include "GaudiKernel/Algorithm.h"

#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"
#include "edm4hep/CaloHitContributionCollection.h"

#include "GaudiKernel/NTuple.h"

class DumpSimHitAlg: public Algorithm {
public:

DumpSimHitAlg(const std::string& name, ISvcLocator* pSvcLocator);

// Three mandatory member functions of any algorithm
StatusCode initialize() override;
StatusCode execute() override;
StatusCode finalize() override;

private:
// - collection MCParticleG4: the simulated particles in Geant4
DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticle",
Gaudi::DataHandle::Reader, this};

// Dedicated collections for CEPC
DataHandle<edm4hep::SimTrackerHitCollection> m_VXDCol{"VXDCollection",
Gaudi::DataHandle::Reader, this};

};

DECLARE_COMPONENT( DumpSimHitAlg )

DumpSimHitAlg::DumpSimHitAlg(const std::string& name, ISvcLocator* pSvcLocator)
: Algorithm(name, pSvcLocator) {

}

StatusCode DumpSimHitAlg::initialize() {
return StatusCode::SUCCESS;
}

StatusCode DumpSimHitAlg::execute() {
auto mcCol = m_mcParCol.get();

for (auto particle: *mcCol) {
info() << "mc particle -> "
<< " (ID: " << particle.getObjectID().index << ") "
<< " (simulator status: " << particle.getSimulatorStatus() << ") "
<< endmsg;
}

auto vxdCol = m_VXDCol.get();

for (auto hit: *vxdCol) {
auto mcparticle = hit.getMCParticle();

if (mcparticle.getGeneratorStatus() != 1) {
error() << "Found generator status is not 1 for hit. " << endmsg;
}

info() << "hit -> "
<< " mcparticle ("
<< " ID: " << mcparticle.getObjectID().index << "; "
<< " generator status: " << mcparticle.getGeneratorStatus() << "; "
<< " simulator status: " << mcparticle.getSimulatorStatus() << ") "
<< endmsg;
}

return StatusCode::SUCCESS;
}

StatusCode DumpSimHitAlg::finalize() {
return StatusCode::SUCCESS;
}
20 changes: 20 additions & 0 deletions Analysis/DumpEvent/src/DumpTrackAlg.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#include "DumpTrackAlg.h"

#if __has_include("edm4hep/EDM4hepVersion.h")
#include "edm4hep/EDM4hepVersion.h"
#else
// Copy the necessary parts from the header above to make whatever we need to work here
#define EDM4HEP_VERSION(major, minor, patch) ((UINT64_C(major) << 32) | (UINT64_C(minor) << 16) | (UINT64_C(patch)))
// v00-09 is the last version without the capitalization change of the track vector members
#define EDM4HEP_BUILD_VERSION EDM4HEP_VERSION(0, 9, 0)
#endif


#include "GaudiKernel/DataObject.h"
#include "GaudiKernel/IHistogramSvc.h"
#include "GaudiKernel/MsgStream.h"
Expand Down Expand Up @@ -119,13 +129,23 @@ StatusCode DumpTrackAlg::execute(){
// std::cout << track.getSubDetectorHitNumbers(ii) << " ";
//}
//std::cout << std::endl;
#if EDM4HEP_BUILD_VERSION > EDM4HEP_VERSION(0, 9, 0)
if(track.subdetectorHitNumbers_size()>=5){
m_nHitsVXD[m_nTracks] = track.getSubdetectorHitNumbers(0);
m_nHitsFTD[m_nTracks] = track.getSubdetectorHitNumbers(1);
m_nHitsSIT[m_nTracks] = track.getSubdetectorHitNumbers(2);
m_nHitsGAS[m_nTracks] = track.getSubdetectorHitNumbers(3);
m_nHitsSET[m_nTracks] = track.getSubdetectorHitNumbers(4);
}
#else
if(track.subDetectorHitNumbers_size()>=5){
m_nHitsVXD[m_nTracks] = track.getSubDetectorHitNumbers(0);
m_nHitsFTD[m_nTracks] = track.getSubDetectorHitNumbers(1);
m_nHitsSIT[m_nTracks] = track.getSubDetectorHitNumbers(2);
m_nHitsGAS[m_nTracks] = track.getSubDetectorHitNumbers(3);
m_nHitsSET[m_nTracks] = track.getSubDetectorHitNumbers(4);
}
#endif
else{
m_nHitsVXD[m_nTracks] = 0;
m_nHitsSIT[m_nTracks] = 0;
Expand Down
6 changes: 6 additions & 0 deletions Analysis/TrackInspect/src/TrackInspectAlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

#include "DataHelper/HelixClass.h"

#include "podio/podioVersion.h"

#include "CLHEP/Units/SystemOfUnits.h"
#include <math.h>
#include <TTree.h>
Expand Down Expand Up @@ -179,7 +181,11 @@ StatusCode TrackInspectAlg::execute(){
if (theTracks.size() == 0) {
totalCandidates[m_nParticles] = 0;
nCandidate[m_nParticles] = -1;
#if PODIO_BUILD_VERSION < PODIO_VERSION(0, 17, 4)
Fill(particle, edm4hep::Track(nullptr));
#else
Fill(particle, edm4hep::Track::makeEmpty());
#endif
m_nParticles++;
}
else {
Expand Down
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ endif()
# ``-DCMAKE_CXX_STANDARD=<standard>`` when invoking CMake
set(CMAKE_CXX_STANDARD 17 CACHE STRING "")

if(NOT CMAKE_CXX_STANDARD MATCHES "14|17")
if(NOT CMAKE_CXX_STANDARD MATCHES "17|20")
message(FATAL_ERROR "Unsupported C++ standard: ${CMAKE_CXX_STANDARD}")
endif()

Expand Down Expand Up @@ -52,3 +52,15 @@ install(EXPORT ${PROJECT_NAME}Targets
)

gaudi_install(CMAKE cmake/${PROJECT_NAME}Config.cmake)

file(WRITE ${CMAKE_BINARY_DIR}/setup.sh.in
"#!/bin/bash\n"
"# Generated by cmake \n"
"# Following is the extra envvar:\n"
"@RUN_SCRIPT_EXTRA_COMMANDS@"
)
configure_file("${CMAKE_BINARY_DIR}/setup.sh.in" "${CMAKE_BINARY_DIR}/setup.sh"
@ONLY)

install(FILES "${CMAKE_BINARY_DIR}/setup.sh"
DESTINATION ${CMAKE_INSTALL_PREFIX})
Loading

0 comments on commit 65ab1b6

Please sign in to comment.