From aa2a3fbfa66ba8530fb51b90469c3260d2a5362b Mon Sep 17 00:00:00 2001 From: Juan Lieber Marin Date: Tue, 14 May 2024 16:09:47 -0400 Subject: [PATCH 1/3] start cutbased hypo implementation --- CMakeLists.txt | 2 + .../egamma/CaloCutBasedHypo/CMakeLists.txt | 20 ++++ .../python/CaloCutBasedHypoTool.py | 24 +++++ .../CaloCutBasedHypo/python/__init__.py | 6 ++ .../src/CaloCutBasedHypoTool.cxx | 91 +++++++++++++++++++ .../src/CaloCutBasedHypoTool.h | 52 +++++++++++ physics/egamma/CaloCutBasedHypo/src/LinkDef.h | 16 ++++ .../CaloClusterBuilder/src/ShowerShapes.cxx | 12 +-- scripts/reco_trf.py | 5 + 9 files changed, 222 insertions(+), 6 deletions(-) create mode 100644 physics/egamma/CaloCutBasedHypo/CMakeLists.txt create mode 100644 physics/egamma/CaloCutBasedHypo/python/CaloCutBasedHypoTool.py create mode 100644 physics/egamma/CaloCutBasedHypo/python/__init__.py create mode 100644 physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.cxx create mode 100644 physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.h create mode 100644 physics/egamma/CaloCutBasedHypo/src/LinkDef.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 51a42ccb..dd71ccdd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,7 @@ add_subdirectory( reconstruction/calorimeter/CaloCellBuilder ) add_subdirectory( reconstruction/calorimeter/CaloClusterBuilder ) add_subdirectory( reconstruction/calorimeter/CaloRingsBuilder ) add_subdirectory( reconstruction/io/RootStreamBuilder ) +add_subdirectory( physics/egamma/CaloCutBasedHypo ) # detector definitions add_subdirectory( geometry/ATLAS ) @@ -104,6 +105,7 @@ add_library(lorenzetti SHARED $ $ $ + $ $ $ $ diff --git a/physics/egamma/CaloCutBasedHypo/CMakeLists.txt b/physics/egamma/CaloCutBasedHypo/CMakeLists.txt new file mode 100644 index 00000000..aedd79c0 --- /dev/null +++ b/physics/egamma/CaloCutBasedHypo/CMakeLists.txt @@ -0,0 +1,20 @@ + +file(GLOB SOURCES src/*.cxx) +file(GLOB_RECURSE HEADERS src/CaloCutBasedHypo.h ) + +include_directories(${CMAKE_SOURCE_DIR} ${ROOT_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/CaloCluster) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/CaloCell) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/CaloRings) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../core/GaugiKernel) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../core/G4Kernel) + + + +ROOT_GENERATE_DICTIONARY(CaloCutBasedHypoDict ${HEADERS} LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/src/LinkDef.h MODULE CaloCutBasedHypo) + +add_library(CaloCutBasedHypo OBJECT ${SOURCES} CaloCutBasedHypoDict.cxx) +install(FILES ${HEADERS} DESTINATION CaloCutBasedHypo) + + +gaugi_install_python_modules( ${CMAKE_CURRENT_SOURCE_DIR}/python CaloCutBasedHypo) \ No newline at end of file diff --git a/physics/egamma/CaloCutBasedHypo/python/CaloCutBasedHypoTool.py b/physics/egamma/CaloCutBasedHypo/python/CaloCutBasedHypoTool.py new file mode 100644 index 00000000..820fb942 --- /dev/null +++ b/physics/egamma/CaloCutBasedHypo/python/CaloCutBasedHypoTool.py @@ -0,0 +1,24 @@ +__all__ = ["CaloCutBasedHypoTool","CaloCutBasedHypoCfg"] + +from GaugiKernel import Cpp +from GaugiKernel.macros import * +from CaloCell.CaloDefs import CaloSampling +import ROOT +import numpy as np + +class CaloCutBasedHypoTool( Cpp ): + def __init__( self, name, + OutputLevel : str=0, + ): + Cpp.__init__(self, ROOT.CaloCutBasedHypoTool(name) ) + + +def CaloCutBasedHypoCfg( name : str, + OutputLevel : int=0, + + ): + + hypo = CaloCutBasedHypoTool( "CaloCutBasedHypoTool", + OutputLevel = OutputLevel) + return hypo + diff --git a/physics/egamma/CaloCutBasedHypo/python/__init__.py b/physics/egamma/CaloCutBasedHypo/python/__init__.py new file mode 100644 index 00000000..3fc9e26c --- /dev/null +++ b/physics/egamma/CaloCutBasedHypo/python/__init__.py @@ -0,0 +1,6 @@ + +__all__ = [] + +from . import CaloCutBasedHypoTool +__all__.extend(CaloCutBasedHypoTool.__all__) +from .CaloCutBasedHypoTool import * diff --git a/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.cxx b/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.cxx new file mode 100644 index 00000000..a4b12e0d --- /dev/null +++ b/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.cxx @@ -0,0 +1,91 @@ + +#include "G4Kernel/CaloPhiRange.h" +#include "CaloCutBasedHypoTool.h" +#include "CaloCell/CaloCell.h" +#include "CaloCluster/CaloCluster.h" +#include "G4PhysicalConstants.hh" +#include "G4SystemOfUnits.hh" +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" + +using namespace SG; +using namespace Gaugi; + + + +CaloCutBasedHypoTool::CaloCutBasedHypoTool( std::string name ) : + IMsgService(name), + Algorithm() +{ + declareProperty( "OutputLevel" , m_outputLevel=1 ); +} + +//!===================================================================== + +CaloCutBasedHypoTool::~CaloCutBasedHypoTool() +{ +} + +//!===================================================================== + +StatusCode CaloCutBasedHypoTool::initialize() +{ + return StatusCode::SUCCESS; +} + +//!===================================================================== + +StatusCode CaloCutBasedHypoTool::bookHistograms( SG::EventContext &ctx ) const +{ + return StatusCode::SUCCESS; +} + +//!===================================================================== + +StatusCode CaloCutBasedHypoTool::pre_execute( EventContext &/*ctx*/ ) const +{ + return StatusCode::SUCCESS; +} + +//!===================================================================== + +StatusCode CaloCutBasedHypoTool::execute( EventContext &/*ctx*/, const G4Step * /*step*/ ) const +{ + return StatusCode::SUCCESS; +} + +//!===================================================================== + +StatusCode CaloCutBasedHypoTool::execute( EventContext &ctx, int /*evt*/ ) const +{ + MSG_INFO("running hypo code"); + return post_execute(ctx); +} + +//!===================================================================== + +StatusCode CaloCutBasedHypoTool::finalize() +{ + return StatusCode::SUCCESS; +} + +//!===================================================================== + +StatusCode CaloCutBasedHypoTool::post_execute( EventContext &ctx ) const +{ + return StatusCode::SUCCESS; +} + +//!===================================================================== + +StatusCode CaloCutBasedHypoTool::fillHistograms(EventContext &ctx ) const +{ + return StatusCode::SUCCESS; +} + +//!===================================================================== + + + + diff --git a/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.h b/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.h new file mode 100644 index 00000000..1c832332 --- /dev/null +++ b/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.h @@ -0,0 +1,52 @@ +#ifndef CaloCutBasedHypoTool_h +#define CaloCutBasedHypoTool_h + +#include "CaloCell/enumeration.h" +#include "GaugiKernel/StatusCode.h" +#include "GaugiKernel/DataHandle.h" +#include "GaugiKernel/Algorithm.h" +#include "CaloCell/CaloCellContainer.h" +#include "CaloCluster/CaloClusterContainer.h" + + + +class CaloCutBasedHypoTool : public Gaugi::Algorithm +{ + + public: + /** Constructor **/ + CaloCutBasedHypoTool( std::string ); + + virtual ~CaloCutBasedHypoTool(); + + virtual StatusCode initialize() override; + + /*! Book all histograms into the current storegate */ + virtual StatusCode bookHistograms( SG::EventContext &ctx ) const override; + + virtual StatusCode pre_execute( SG::EventContext &ctx ) const override; + + virtual StatusCode execute( SG::EventContext &ctx , const G4Step *step) const override; + + /*! Execute in ComponentAccumulator */ + virtual StatusCode execute( SG::EventContext &ctx , int /*evt*/ ) const override; + + virtual StatusCode post_execute( SG::EventContext &ctx ) const override; + + virtual StatusCode fillHistograms( SG::EventContext &ctx ) const override; + + virtual StatusCode finalize() override; + + + + private: + + + +}; + +#endif + + + + diff --git a/physics/egamma/CaloCutBasedHypo/src/LinkDef.h b/physics/egamma/CaloCutBasedHypo/src/LinkDef.h new file mode 100644 index 00000000..6ac5284f --- /dev/null +++ b/physics/egamma/CaloCutBasedHypo/src/LinkDef.h @@ -0,0 +1,16 @@ + +#include "src/CaloCutBasedHypoTool.h" + + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ nestedclass; + + +#pragma link C++ class CaloCutBasedHypoTool+; + + +#endif diff --git a/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.cxx b/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.cxx index c781f172..f025e1ba 100644 --- a/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.cxx +++ b/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.cxx @@ -102,13 +102,13 @@ StatusCode ShowerShapes::execute( SG::EventContext &/*ctx*/, Gaugi::EDM *edm ) c // Only EM energy since this is a eletromagnetic cluster clus->setEt( clus->eta() != 0.0 ? (e0+e1+e2+e3)/cosh(fabs(clus->eta())) : 0.0 ); clus->setE(e0+e1+e2+e3); - clus->setSecondR(secondR); + // clus->setSecondR(secondR); - clus->setLambdaCenter(lambdaCenter); - clus->setSecondLambda(secondLambda); - clus->setFracMax(fracMax); - clus->setLateralMom(lateralMom); - clus->setLongitudinalMom(longitudinalMom); + // clus->setLambdaCenter(lambdaCenter); + // clus->setSecondLambda(secondLambda); + // clus->setFracMax(fracMax); + // clus->setLateralMom(lateralMom); + // clus->setLongitudinalMom(longitudinalMom); return StatusCode::SUCCESS; } diff --git a/scripts/reco_trf.py b/scripts/reco_trf.py index e1b57b3c..9a9a50e1 100755 --- a/scripts/reco_trf.py +++ b/scripts/reco_trf.py @@ -89,7 +89,11 @@ OutputLevel = outputLevel) + from CaloCutBasedHypo import CaloCutBasedHypoCfg + hypo = CaloCutBasedHypoCfg( "CaloCutBasedHypo", + OutputLevel = outputLevel) + from RootStreamBuilder import RootStreamAODMaker AOD = RootStreamAODMaker( "RootStreamAODMaker", InputEventKey = recordable("Events"), @@ -103,6 +107,7 @@ # sequence acc+= cluster acc+= rings + acc+= hypo acc+= AOD acc.run(args.numberOfEvents) From 80f7f37c315b3b481bcffe5a86feab144eb7dca2 Mon Sep 17 00:00:00 2001 From: Juan Lieber Marin Date: Tue, 14 May 2024 16:37:20 -0400 Subject: [PATCH 2/3] add flag to forward moments --- .../python/CaloClusterFlags.py | 3 +- .../python/CaloClusterMaker.py | 2 ++ .../src/CaloClusterMaker.cxx | 2 ++ .../CaloClusterBuilder/src/CaloClusterMaker.h | 1 + .../CaloClusterBuilder/src/ShowerShapes.cxx | 29 ++++++++++--------- .../CaloClusterBuilder/src/ShowerShapes.h | 13 +++++---- 6 files changed, 30 insertions(+), 20 deletions(-) diff --git a/reconstruction/calorimeter/CaloClusterBuilder/python/CaloClusterFlags.py b/reconstruction/calorimeter/CaloClusterBuilder/python/CaloClusterFlags.py index 5038b5af..4938392a 100644 --- a/reconstruction/calorimeter/CaloClusterBuilder/python/CaloClusterFlags.py +++ b/reconstruction/calorimeter/CaloClusterBuilder/python/CaloClusterFlags.py @@ -7,4 +7,5 @@ class CaloClusterFlags(EnumStringification): MinCenterEnergy = 1*GeV EtaWindow = 0.4 - PhiWindow = 0.4 \ No newline at end of file + PhiWindow = 0.4 + doForwardMoments = False \ No newline at end of file diff --git a/reconstruction/calorimeter/CaloClusterBuilder/python/CaloClusterMaker.py b/reconstruction/calorimeter/CaloClusterBuilder/python/CaloClusterMaker.py index 57610872..15e605be 100644 --- a/reconstruction/calorimeter/CaloClusterBuilder/python/CaloClusterMaker.py +++ b/reconstruction/calorimeter/CaloClusterBuilder/python/CaloClusterMaker.py @@ -15,6 +15,7 @@ def __init__( self, name, EtaWindow : float=flags.EtaWindow, PhiWindow : float=flags.PhiWindow, MinCenterEnergy : float=flags.MinCenterEnergy, + doForwardMoments : bool=flags.doForwardMoments, OutputLevel : str=0, HistogramPath : str="Expert/Clusters", ): @@ -27,6 +28,7 @@ def __init__( self, name, self.setProperty( "EtaWindow" , EtaWindow ) self.setProperty( "PhiWindow" , PhiWindow ) self.setProperty( "MinCenterEnergy" , MinCenterEnergy ) + self.setProperty( "DoForwardMoments" , doForwardMoments ) self.setProperty( "OutputLevel" , OutputLevel ) self.setProperty( "HistogramPath" , HistogramPath ) diff --git a/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.cxx b/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.cxx index e5cf3740..93b95b96 100644 --- a/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.cxx +++ b/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.cxx @@ -26,6 +26,7 @@ CaloClusterMaker::CaloClusterMaker( std::string name ) : // Algorithm configuration declareProperty( "EtaWindow" , m_etaWindow=0.4 ); declareProperty( "PhiWindow" , m_phiWindow=0.4 ); + declareProperty( "DoForwardMoments", m_doForwardMoments = false ); declareProperty( "OutputLevel" , m_outputLevel=1 ); declareProperty( "HistogramPath" , m_histPath="Clusters" ); declareProperty( "MinCenterEnergy", m_minCenterEnergy=15*GeV ); @@ -46,6 +47,7 @@ StatusCode CaloClusterMaker::initialize() CHECK_INIT(); //setMsgLevel(m_outputLevel); m_showerShapes = new ShowerShapes( "ShowerShapes" ); + m_showerShapes->setForwardMoments(m_doForwardMoments); return StatusCode::SUCCESS; } diff --git a/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.h b/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.h index 6356e51d..3908252f 100644 --- a/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.h +++ b/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.h @@ -57,6 +57,7 @@ class CaloClusterMaker : public Gaugi::Algorithm float m_etaWindow; float m_phiWindow; + bool m_doForwardMoments; std::string m_histPath; // Shower shaper calculator diff --git a/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.cxx b/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.cxx index f025e1ba..40e2e66f 100644 --- a/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.cxx +++ b/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.cxx @@ -56,13 +56,6 @@ StatusCode ShowerShapes::execute( SG::EventContext &/*ctx*/, Gaugi::EDM *edm ) c float weta2 = calculateWeta2(clus, 3, 5); - std::vector axis = calculateShowerAxis(clus); - float secondR = calculateSecondR(clus, axis); - float lambdaCenter = calculateLambdaCenter(clus, axis); - float secondLambda = calculateSecondLambda(clus, axis); - float fracMax = calculateFracMax(clus, axis); - float lateralMom = calculateLateralMom(clus, axis); - float longitudinalMom = calculateLongitudinalMom(clus, axis); float etot = e0+e1+e2+e3+ehad1+ehad2+ehad3; @@ -102,13 +95,21 @@ StatusCode ShowerShapes::execute( SG::EventContext &/*ctx*/, Gaugi::EDM *edm ) c // Only EM energy since this is a eletromagnetic cluster clus->setEt( clus->eta() != 0.0 ? (e0+e1+e2+e3)/cosh(fabs(clus->eta())) : 0.0 ); clus->setE(e0+e1+e2+e3); - // clus->setSecondR(secondR); - - // clus->setLambdaCenter(lambdaCenter); - // clus->setSecondLambda(secondLambda); - // clus->setFracMax(fracMax); - // clus->setLateralMom(lateralMom); - // clus->setLongitudinalMom(longitudinalMom); + if(m_doForwardMoments){ + std::vector axis = calculateShowerAxis(clus); + float secondR = calculateSecondR(clus, axis); + float lambdaCenter = calculateLambdaCenter(clus, axis); + float secondLambda = calculateSecondLambda(clus, axis); + float fracMax = calculateFracMax(clus, axis); + float lateralMom = calculateLateralMom(clus, axis); + float longitudinalMom = calculateLongitudinalMom(clus, axis); + clus->setSecondR(secondR); + clus->setLambdaCenter(lambdaCenter); + clus->setSecondLambda(secondLambda); + clus->setFracMax(fracMax); + clus->setLateralMom(lateralMom); + clus->setLongitudinalMom(longitudinalMom); + } return StatusCode::SUCCESS; } diff --git a/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.h b/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.h index 650c7f1d..cde2f461 100644 --- a/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.h +++ b/reconstruction/calorimeter/CaloClusterBuilder/src/ShowerShapes.h @@ -20,21 +20,24 @@ class ShowerShapes : public Gaugi::AlgTool virtual StatusCode initialize() override; virtual StatusCode finalize() override; - virtual StatusCode execute( SG::EventContext &ctx, Gaugi::EDM * ) const override; + virtual StatusCode execute( SG::EventContext &ctx, Gaugi::EDM *) const override; + void setForwardMoments(bool doForward){m_doForwardMoments = doForward;} private: float calculateWeta2( xAOD::CaloCluster * , unsigned eta_ncell=3, unsigned phi_ncell=5 ) const; float sumEnergyEM( xAOD::CaloCluster *, int sampling, unsigned eta_ncell=1000, unsigned phi_ncell=1000 ) const; float sumEnergyHAD( xAOD::CaloCluster *, int sampling, unsigned eta_ncell=1000, unsigned phi_ncell=1000 ) const; - std::vector calculateShowerAxis(xAOD::CaloCluster *) const; - float calculateSecondR (xAOD::CaloCluster *, std::vector) const; + float calculateSecondR (xAOD::CaloCluster *, std::vector) const; float calculateSecondLambda (xAOD::CaloCluster *, std::vector) const; float calculateLambdaCenter (xAOD::CaloCluster *, std::vector) const; float calculateFracMax(xAOD::CaloCluster *, std::vector) const; - float calculateLateralMom(xAOD::CaloCluster *, std::vector) const; - float calculateLongitudinalMom(xAOD::CaloCluster *, std::vector) const; + float calculateLateralMom(xAOD::CaloCluster *, std::vector) const; + float calculateLongitudinalMom(xAOD::CaloCluster *, std::vector) const; + std::vector calculateShowerAxis(xAOD::CaloCluster *) const; + + bool m_doForwardMoments; }; From 002c2070e9527f01e7d853c43cacd6a90034421b Mon Sep 17 00:00:00 2001 From: Juan Lieber Marin Date: Thu, 16 May 2024 13:07:38 -0300 Subject: [PATCH 3/3] configure hypo tool and new Electron class --- CMakeLists.txt | 2 + events/Particle/CMakeLists.txt | 15 +++++ events/Particle/Particle/Electron.h | 48 +++++++++++++++ events/Particle/Particle/ElectronContainer.h | 11 ++++ events/Particle/Particle/ElectronConverter.h | 38 ++++++++++++ events/Particle/python/__init__.py | 4 ++ events/Particle/src/Electron.cxx | 11 ++++ events/Particle/src/ElectronConverter.cxx | 38 ++++++++++++ events/Particle/src/LinkDef.h | 16 +++++ .../egamma/CaloCutBasedHypo/CMakeLists.txt | 1 + .../python/CaloCutBasedHypoTool.py | 26 +++++++- .../CaloCutBasedHypo/python/CaloCutMaps.py | 24 ++++++++ .../src/CaloCutBasedHypoTool.cxx | 59 ++++++++++++++++++- .../src/CaloCutBasedHypoTool.h | 13 +++- .../src/CaloClusterMaker.cxx | 14 ++--- .../io/RootStreamBuilder/CMakeLists.txt | 1 + .../python/RootStreamAODMaker.py | 3 + .../python/RootStreamKeys.py | 1 + .../src/RootStreamAODMaker.cxx | 31 +++++++++- .../src/RootStreamAODMaker.h | 3 + scripts/reco_trf.py | 7 ++- 21 files changed, 349 insertions(+), 17 deletions(-) create mode 100644 events/Particle/CMakeLists.txt create mode 100644 events/Particle/Particle/Electron.h create mode 100644 events/Particle/Particle/ElectronContainer.h create mode 100644 events/Particle/Particle/ElectronConverter.h create mode 100644 events/Particle/python/__init__.py create mode 100644 events/Particle/src/Electron.cxx create mode 100644 events/Particle/src/ElectronConverter.cxx create mode 100644 events/Particle/src/LinkDef.h create mode 100644 physics/egamma/CaloCutBasedHypo/python/CaloCutMaps.py diff --git a/CMakeLists.txt b/CMakeLists.txt index dd71ccdd..944d913a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ add_subdirectory( events/CaloCluster ) add_subdirectory( events/EventInfo ) add_subdirectory( events/TruthParticle ) add_subdirectory( events/CaloRings ) +add_subdirectory( events/Particle) # reconstruction package add_subdirectory( reconstruction/calorimeter/CaloCellBuilder ) @@ -100,6 +101,7 @@ add_library(lorenzetti SHARED $ $ $ + $ $ $ $ diff --git a/events/Particle/CMakeLists.txt b/events/Particle/CMakeLists.txt new file mode 100644 index 00000000..a5ce3223 --- /dev/null +++ b/events/Particle/CMakeLists.txt @@ -0,0 +1,15 @@ + +file(GLOB SOURCES src/*.cxx ) +file(GLOB_RECURSE HEADERS Particle/*.h) + +include_directories(${CMAKE_SOURCE_DIR} ${ROOT_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../core/GaugiKernel) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../core/G4Kernel) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../CaloCell) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../CaloCluster) + +ROOT_GENERATE_DICTIONARY(ParticleDict ${HEADERS} LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/src/LinkDef.h MODULE Particle) + +add_library(Particle OBJECT ${SOURCES} ParticleDict.cxx) +install(FILES ${HEADERS} DESTINATION Particle) +gaugi_install_python_modules( ${CMAKE_CURRENT_SOURCE_DIR}/python Particle) diff --git a/events/Particle/Particle/Electron.h b/events/Particle/Particle/Electron.h new file mode 100644 index 00000000..ce7feb92 --- /dev/null +++ b/events/Particle/Particle/Electron.h @@ -0,0 +1,48 @@ +#ifndef Electron_h +#define Electron_h + +#include "CaloCluster/CaloCluster.h" +#include "CaloCell/CaloCell.h" +#include "GaugiKernel/EDM.h" +#include "GaugiKernel/macros.h" +#include + +namespace xAOD{ + + class Electron: public Gaugi::EDM + { + public: + + /*! Contructor */ + Electron(); + /*! Contructor */ + /*! Destructor */ + ~Electron()=default; + + /*! The eta center of the cluster given by the simulation (RoI) */ + PRIMITIVE_SETTER_AND_GETTER( float, m_eta, setEta, eta ); + /*! The phi center of the cluster given by the simulation (RoI) */ + PRIMITIVE_SETTER_AND_GETTER( float, m_phi, setPhi, phi ); + /*! set/get energy */ + PRIMITIVE_SETTER_AND_GETTER( float, m_e, setE, e ); + /*! set/get transverse energy */ + PRIMITIVE_SETTER_AND_GETTER( float, m_et, setEt, et ); + + void setDecisions (std::vector decisions ){ for (auto dec : decisions) m_decisions.push_back(dec); } + std::vector getDecisions() const {return m_decisions;} + + void setCaloCluster( const xAOD::CaloCluster *clus ){ m_caloCluster=clus; }; + const xAOD::CaloCluster* caloCluster() const { return m_caloCluster; }; + + private: + float m_e; + float m_et; + float m_eta; + float m_phi; + + std::vector m_decisions; + + const xAOD::CaloCluster *m_caloCluster; + }; +} +#endif \ No newline at end of file diff --git a/events/Particle/Particle/ElectronContainer.h b/events/Particle/Particle/ElectronContainer.h new file mode 100644 index 00000000..65dbcdbb --- /dev/null +++ b/events/Particle/Particle/ElectronContainer.h @@ -0,0 +1,11 @@ +#ifndef ElectronContainer_h +#define ElectronContainer_h + +/** simulator includes **/ +#include "Particle/Electron.h" +#include "GaugiKernel/DataVector.h" + +namespace xAOD{ + typedef SG::DataVector ElectronContainer; +} +#endif diff --git a/events/Particle/Particle/ElectronConverter.h b/events/Particle/Particle/ElectronConverter.h new file mode 100644 index 00000000..29751449 --- /dev/null +++ b/events/Particle/Particle/ElectronConverter.h @@ -0,0 +1,38 @@ +#ifndef ElectronConverter_h +#define ElectronConverter_h + +/** simulator includes **/ +#include "Particle/Electron.h" +#include "CaloCluster/CaloClusterConverter.h" + +namespace xAOD{ + + struct Electron_t{ + int cluster_link; + float e; + float et; + float eta; + float phi; + std::vector decisions; + }; + + class ElectronConverter{ + + public: + ElectronConverter()=default; + ~ElectronConverter()=default; + + // convert a class object into a struct + bool convert( const Electron *, Electron_t & , cluster_links_t &) ; + bool convert( const Electron_t &electron_t, Electron *&electron ); + + private: + + }; + + + +} +#endif + + diff --git a/events/Particle/python/__init__.py b/events/Particle/python/__init__.py new file mode 100644 index 00000000..a92295dd --- /dev/null +++ b/events/Particle/python/__init__.py @@ -0,0 +1,4 @@ + +__all__ = [] + + diff --git a/events/Particle/src/Electron.cxx b/events/Particle/src/Electron.cxx new file mode 100644 index 00000000..2dabe23b --- /dev/null +++ b/events/Particle/src/Electron.cxx @@ -0,0 +1,11 @@ +#include "Particle/Electron.h" +#include "G4Kernel/CaloPhiRange.h" + +using namespace xAOD; + + +Electron::Electron(): + EDM(), + m_caloCluster(nullptr) +{} + diff --git a/events/Particle/src/ElectronConverter.cxx b/events/Particle/src/ElectronConverter.cxx new file mode 100644 index 00000000..136c7028 --- /dev/null +++ b/events/Particle/src/ElectronConverter.cxx @@ -0,0 +1,38 @@ + +#include "Particle/ElectronConverter.h" +//#include "G4Kernel/macros.h" + +#include +using namespace xAOD; +using namespace std; + + +bool ElectronConverter::convert( const Electron *electron, Electron_t &electron_t, cluster_links_t &cluster_links ) +{ + if(electron){ + + electron_t.cluster_link = cluster_links[electron->caloCluster()]; + electron_t.eta = electron->eta(); + electron_t.phi = electron->phi(); + electron_t.et = electron->et(); + electron_t.e = electron->e(); + for (auto dec : electron->getDecisions() ) electron_t.decisions.push_back(dec); + return true; + } + return false; +} + + +bool ElectronConverter::convert( const Electron_t &electron_t, Electron *&electron) +{ + + electron = new xAOD::Electron(); + electron->setEta(electron_t.eta); + electron->setPhi(electron_t.phi); + electron->setEt(electron_t.et); + electron->setE(electron_t.e); + electron->setDecisions(electron_t.decisions); + + return true; + +} \ No newline at end of file diff --git a/events/Particle/src/LinkDef.h b/events/Particle/src/LinkDef.h new file mode 100644 index 00000000..777589ec --- /dev/null +++ b/events/Particle/src/LinkDef.h @@ -0,0 +1,16 @@ + + +#include "Particle/ElectronConverter.h" + +#ifdef __CINT__ + + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ nestedclass; +#pragma link C++ struct xAOD::Electron_t+; +#pragma link C++ class std::vector< xAOD::Electron_t >+; + + +#endif diff --git a/physics/egamma/CaloCutBasedHypo/CMakeLists.txt b/physics/egamma/CaloCutBasedHypo/CMakeLists.txt index aedd79c0..e2e86155 100644 --- a/physics/egamma/CaloCutBasedHypo/CMakeLists.txt +++ b/physics/egamma/CaloCutBasedHypo/CMakeLists.txt @@ -3,6 +3,7 @@ file(GLOB SOURCES src/*.cxx) file(GLOB_RECURSE HEADERS src/CaloCutBasedHypo.h ) include_directories(${CMAKE_SOURCE_DIR} ${ROOT_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/Particle) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/CaloCluster) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/CaloCell) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/CaloRings) diff --git a/physics/egamma/CaloCutBasedHypo/python/CaloCutBasedHypoTool.py b/physics/egamma/CaloCutBasedHypo/python/CaloCutBasedHypoTool.py index 820fb942..b02468d0 100644 --- a/physics/egamma/CaloCutBasedHypo/python/CaloCutBasedHypoTool.py +++ b/physics/egamma/CaloCutBasedHypo/python/CaloCutBasedHypoTool.py @@ -8,17 +8,39 @@ class CaloCutBasedHypoTool( Cpp ): def __init__( self, name, + InputClusterKey : str, + OutputElectronKey: str, OutputLevel : str=0, + TightCuts : list=[], + MediumCuts : list=[], + LooseCuts : list=[], + VLooseCuts : list=[], ): Cpp.__init__(self, ROOT.CaloCutBasedHypoTool(name) ) + self.setProperty( "InputClusterKey" , InputClusterKey ) + self.setProperty( "OutputElectronKey" , OutputElectronKey) + self.setProperty( "OutputLevel" , OutputLevel ) + self.setProperty( "TightCuts" , TightCuts ) + self.setProperty( "MediumCuts" , MediumCuts ) + self.setProperty( "LooseCuts" , LooseCuts ) + self.setProperty( "VLooseCuts" , VLooseCuts ) + def CaloCutBasedHypoCfg( name : str, + InputClusterKey : str, + OutputElectronKey: str, OutputLevel : int=0, - ): + from .CaloCutMaps import CutBasedIsEM hypo = CaloCutBasedHypoTool( "CaloCutBasedHypoTool", - OutputLevel = OutputLevel) + InputClusterKey = InputClusterKey, + OutputElectronKey = OutputElectronKey, + TightCuts = CutBasedIsEM().getCuts('tight'), + MediumCuts = CutBasedIsEM().getCuts('medium'), + LooseCuts = CutBasedIsEM().getCuts('loose'), + VLooseCuts = CutBasedIsEM().getCuts('vloose'), + OutputLevel = OutputLevel) return hypo diff --git a/physics/egamma/CaloCutBasedHypo/python/CaloCutMaps.py b/physics/egamma/CaloCutBasedHypo/python/CaloCutMaps.py new file mode 100644 index 00000000..daf643a2 --- /dev/null +++ b/physics/egamma/CaloCutBasedHypo/python/CaloCutMaps.py @@ -0,0 +1,24 @@ +__all__ = ['CutBasedIsEM'] + +class CutBasedIsEM: + def __init__(self): + + self.etHadCut = {'loose':[0.1218], + 'medium':[0.0270375], + 'tight':[0.0270375], + 'vloose': [0.157]} + + self.rEtaCut={'loose':[0.57], + 'medium':[0.814625], + 'tight':[0.83125], + 'vloose':[0.752]} + + self.eRatioCut = {'loose':[0.47], + 'medium':[0.57], + 'tight':[0.65], + 'vloose':[0.52]} + + def getCuts(self,workingPoint): + return [self.etHadCut[workingPoint], + self.rEtaCut[workingPoint], + self.eRatioCut[workingPoint],] \ No newline at end of file diff --git a/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.cxx b/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.cxx index a4b12e0d..02679f5e 100644 --- a/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.cxx +++ b/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.cxx @@ -18,7 +18,13 @@ CaloCutBasedHypoTool::CaloCutBasedHypoTool( std::string name ) : IMsgService(name), Algorithm() { - declareProperty( "OutputLevel" , m_outputLevel=1 ); + declareProperty( "InputClusterKey", m_clusterKey="Clusters" ); + declareProperty( "OutputElectronKey", m_electronKey="Electrons" ); + declareProperty( "OutputLevel" , m_outputLevel=1 ); + declareProperty( "TightCuts", m_tightCuts ); + declareProperty( "MediumCuts", m_mediumCuts ); + declareProperty( "LooseCuts", m_looseCuts ); + declareProperty( "VLooseCuts", m_vlooseCuts ); } //!===================================================================== @@ -31,6 +37,7 @@ CaloCutBasedHypoTool::~CaloCutBasedHypoTool() StatusCode CaloCutBasedHypoTool::initialize() { + CHECK_INIT(); return StatusCode::SUCCESS; } @@ -59,7 +66,6 @@ StatusCode CaloCutBasedHypoTool::execute( EventContext &/*ctx*/, const G4Step * StatusCode CaloCutBasedHypoTool::execute( EventContext &ctx, int /*evt*/ ) const { - MSG_INFO("running hypo code"); return post_execute(ctx); } @@ -74,6 +80,27 @@ StatusCode CaloCutBasedHypoTool::finalize() StatusCode CaloCutBasedHypoTool::post_execute( EventContext &ctx ) const { + SG::WriteHandle electron(m_electronKey, ctx); + electron.record( std::unique_ptr(new xAOD::ElectronContainer()) ); + + SG::ReadHandle clusters(m_clusterKey, ctx); + + for( const auto* clus : **clusters.ptr()){ + auto el = new xAOD::Electron(); + std::vector decisions; + decisions.push_back(computeDecision(clus,"tight")); + decisions.push_back(computeDecision(clus,"medium")); + decisions.push_back(computeDecision(clus,"loose")); + decisions.push_back(computeDecision(clus,"vloose")); + el->setDecisions(decisions); + el->setEta(clus->eta()); + el->setPhi(clus->phi()); + el->setEt(clus->et()); + el->setE(clus->e()); + el->setCaloCluster( clus ); + electron->push_back( el ); + + } return StatusCode::SUCCESS; } @@ -86,6 +113,34 @@ StatusCode CaloCutBasedHypoTool::fillHistograms(EventContext &ctx ) const //!===================================================================== +bool CaloCutBasedHypoTool::computeDecision(const xAOD::CaloCluster* cluster, std::string workingPoint) const{ + if (workingPoint == "tight"){ + if (cluster->rhad() > m_tightCuts[0]) return false; + if (cluster->reta() < m_tightCuts[1]) return false; + if (cluster->eratio() < m_tightCuts[2]) return false; + return true; + } + if (workingPoint == "medium"){ + if (cluster->rhad() > m_mediumCuts[0]) return false; + if (cluster->reta() < m_mediumCuts[1]) return false; + if (cluster->eratio() < m_mediumCuts[2]) return false; + return true; + } + if (workingPoint == "loose"){ + if (cluster->rhad() > m_looseCuts[0]) return false; + if (cluster->reta() < m_looseCuts[1]) return false; + if (cluster->eratio() < m_looseCuts[2]) return false; + return true; + } + if (workingPoint == "vloose"){ + if (cluster->rhad() > m_vlooseCuts[0]) return false; + if (cluster->reta() < m_vlooseCuts[1]) return false; + if (cluster->eratio() < m_vlooseCuts[2]) return false; + return true; + } + MSG_DEBUG("No working point adressed. Rejecting by default"); + return false; +} diff --git a/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.h b/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.h index 1c832332..f0ce10e3 100644 --- a/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.h +++ b/physics/egamma/CaloCutBasedHypo/src/CaloCutBasedHypoTool.h @@ -7,6 +7,8 @@ #include "GaugiKernel/Algorithm.h" #include "CaloCell/CaloCellContainer.h" #include "CaloCluster/CaloClusterContainer.h" +#include "Particle/Electron.h" +#include "Particle/ElectronContainer.h" @@ -37,11 +39,18 @@ class CaloCutBasedHypoTool : public Gaugi::Algorithm virtual StatusCode finalize() override; + bool computeDecision(const xAOD::CaloCluster* cluster, std::string workingPoint) const; private: - - + + std::string m_clusterKey; + std::string m_electronKey; + int m_outputLevel; + std::vector m_tightCuts; + std::vector m_mediumCuts; + std::vector m_looseCuts; + std::vector m_vlooseCuts; }; diff --git a/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.cxx b/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.cxx index 93b95b96..d26c2a37 100644 --- a/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.cxx +++ b/reconstruction/calorimeter/CaloClusterBuilder/src/CaloClusterMaker.cxx @@ -24,13 +24,13 @@ CaloClusterMaker::CaloClusterMaker( std::string name ) : // Key outputs declareProperty( "OutputClusterKey" , m_clusterKey="Clusters" ); // Algorithm configuration - declareProperty( "EtaWindow" , m_etaWindow=0.4 ); - declareProperty( "PhiWindow" , m_phiWindow=0.4 ); - declareProperty( "DoForwardMoments", m_doForwardMoments = false ); - declareProperty( "OutputLevel" , m_outputLevel=1 ); - declareProperty( "HistogramPath" , m_histPath="Clusters" ); - declareProperty( "MinCenterEnergy", m_minCenterEnergy=15*GeV ); - declareProperty( "OutputLevel" , m_outputLevel=1 ); + declareProperty( "EtaWindow" , m_etaWindow=0.4 ); + declareProperty( "PhiWindow" , m_phiWindow=0.4 ); + declareProperty( "DoForwardMoments" , m_doForwardMoments = false ); + declareProperty( "OutputLevel" , m_outputLevel=1 ); + declareProperty( "HistogramPath" , m_histPath="Clusters" ); + declareProperty( "MinCenterEnergy" , m_minCenterEnergy=15*GeV ); + declareProperty( "OutputLevel" , m_outputLevel=1 ); } //!===================================================================== diff --git a/reconstruction/io/RootStreamBuilder/CMakeLists.txt b/reconstruction/io/RootStreamBuilder/CMakeLists.txt index f9b62c9e..744cf2b3 100644 --- a/reconstruction/io/RootStreamBuilder/CMakeLists.txt +++ b/reconstruction/io/RootStreamBuilder/CMakeLists.txt @@ -3,6 +3,7 @@ file(GLOB SOURCES src/*.cxx) file(GLOB_RECURSE HEADERS src/RootStreamMaker.h ) include_directories(${CMAKE_SOURCE_DIR} ${ROOT_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/Particle) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/CaloCluster) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/CaloCell) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../events/CaloHit) diff --git a/reconstruction/io/RootStreamBuilder/python/RootStreamAODMaker.py b/reconstruction/io/RootStreamBuilder/python/RootStreamAODMaker.py index 10c599c2..5227ffe1 100644 --- a/reconstruction/io/RootStreamBuilder/python/RootStreamAODMaker.py +++ b/reconstruction/io/RootStreamBuilder/python/RootStreamAODMaker.py @@ -14,12 +14,14 @@ def __init__( self, name, InputClusterKey : str, InputRingerKey : str, InputSeedsKey : str, + InputElectronKey : str, OutputEventKey : str=None, OutputTruthKey : str=None, OutputCellsKey : str=None, OutputClusterKey : str=None, OutputRingerKey : str=None, OutputSeedsKey : str=None, + OutputElectronKey: str=None, OutputLevel : int=0, NtupleName : str="CollectionTree", DumpCells : bool=flags.DumpCells, @@ -39,6 +41,7 @@ def __init__( self, name, self.setProperty( "OutputClusterKey", OutputClusterKey if OutputClusterKey else InputClusterKey ) self.setProperty( "OutputRingerKey" , OutputRingerKey if OutputRingerKey else InputRingerKey ) self.setProperty( "OutputSeedsKey" , OutputSeedsKey if OutputSeedsKey else InputSeedsKey ) + self.setProperty( "OutputElectronKey", OutputElectronKey if OutputElectronKey else InputElectronKey) self.setProperty( "OutputLevel" , OutputLevel ) self.setProperty( "NtupleName" , NtupleName ) diff --git a/reconstruction/io/RootStreamBuilder/python/RootStreamKeys.py b/reconstruction/io/RootStreamBuilder/python/RootStreamKeys.py index e563f8af..419d289a 100644 --- a/reconstruction/io/RootStreamBuilder/python/RootStreamKeys.py +++ b/reconstruction/io/RootStreamBuilder/python/RootStreamKeys.py @@ -18,6 +18,7 @@ # CaloRingsBuilder "Rings", "TruthRings", + "Electrons", ] def recordable( key ): diff --git a/reconstruction/io/RootStreamBuilder/src/RootStreamAODMaker.cxx b/reconstruction/io/RootStreamBuilder/src/RootStreamAODMaker.cxx index 7ec5956d..6fb456f2 100644 --- a/reconstruction/io/RootStreamBuilder/src/RootStreamAODMaker.cxx +++ b/reconstruction/io/RootStreamBuilder/src/RootStreamAODMaker.cxx @@ -3,6 +3,7 @@ #include "CaloRings/CaloRingsContainer.h" #include "EventInfo/EventInfoContainer.h" #include "TruthParticle/TruthParticleContainer.h" +#include "Particle/ElectronContainer.h" #include "CaloCell/CaloCellConverter.h" #include "CaloCell/CaloDetDescriptorConverter.h" @@ -11,6 +12,7 @@ #include "EventInfo/EventInfoConverter.h" #include "EventInfo/EventSeedConverter.h" #include "TruthParticle/TruthParticleConverter.h" +#include "Particle/ElectronConverter.h" #include "TTree.h" #include "RootStreamAODMaker.h" #include "GaugiKernel/EDM.h" @@ -31,6 +33,7 @@ RootStreamAODMaker::RootStreamAODMaker( std::string name ) : declareProperty( "InputCellsKey" , m_inputCellsKey="Cells" ); declareProperty( "InputClusterKey" , m_inputClusterKey="Clusters" ); declareProperty( "InputRingerKey" , m_inputRingerKey="Rings" ); + declareProperty( "InputElectronKey" , m_inputElectronKey="Electrons" ); declareProperty( "OutputEventKey" , m_outputEventKey="EventInfo" ); declareProperty( "OutputSeedsKey" , m_outputSeedsKey="Seeds" ); @@ -38,6 +41,7 @@ RootStreamAODMaker::RootStreamAODMaker( std::string name ) : declareProperty( "OutputCellsKey" , m_outputCellsKey="Cells" ); declareProperty( "OutputClusterKey" , m_outputClusterKey="Clusters" ); declareProperty( "OutputRingerKey" , m_outputRingerKey="Rings" ); + declareProperty( "OutputElectronKey" , m_outputElectronKey="Electrons" ); declareProperty( "OutputLevel" , m_outputLevel=1 ); declareProperty( "NtupleName" , m_ntupleName="physics" ); @@ -71,6 +75,7 @@ StatusCode RootStreamAODMaker::bookHistograms( SG::EventContext &ctx ) const std::vector container_event; std::vector container_seeds; std::vector container_truth; + std::vector container_electron; store->cd(); TTree *tree = new TTree(m_ntupleName.c_str(), ""); @@ -80,6 +85,7 @@ StatusCode RootStreamAODMaker::bookHistograms( SG::EventContext &ctx ) const tree->Branch( ("TruthParticleContainer_" + m_outputTruthKey).c_str() , &container_truth ); tree->Branch( ("CaloRingsContainer_" + m_outputRingerKey).c_str() , &container_rings ); tree->Branch( ("CaloClusterContainer_" + m_outputClusterKey).c_str() , &container_clus ); + tree->Branch( ("ElectronContainer_" + m_outputElectronKey).c_str() , &container_electron ); if(m_dumpCells){ tree->Branch( ("CaloCellContainer_" + m_outputCellsKey).c_str() , &container_cells ); tree->Branch( ("CaloDetDescriptorContainer_" + m_outputCellsKey).c_str() , &container_descriptor ); @@ -169,14 +175,16 @@ StatusCode RootStreamAODMaker::serialize( EventContext &ctx ) const std::vector *container_event = nullptr; std::vector *container_seeds = nullptr; std::vector *container_truth = nullptr; + std::vector *container_electron = nullptr; MSG_DEBUG( "Link all branches..." ); InitBranch( tree, ("EventInfoContainer_" + m_outputEventKey).c_str() , &container_event ); InitBranch( tree, ("EventSeedContainer_" + m_outputSeedsKey).c_str() , &container_seeds ); InitBranch( tree, ("TruthParticleContainer_" + m_outputTruthKey).c_str() , &container_truth ); - InitBranch( tree, ("CaloRingsContainer_" + m_outputRingerKey).c_str() , &container_rings ); + InitBranch( tree, ("CaloRingsContainer_" + m_outputRingerKey).c_str() , &container_rings ); InitBranch( tree, ("CaloClusterContainer_" + m_outputClusterKey).c_str() , &container_clus ); + InitBranch( tree, ("ElectronContainer_" + m_outputElectronKey).c_str() , &container_electron ); if(m_dumpCells){ InitBranch( tree, ("CaloCellContainer_" + m_outputCellsKey).c_str() , &container_cells ); InitBranch( tree, ("CaloDetDescriptorContainer_" + m_outputCellsKey).c_str() , &container_descriptor ); @@ -240,7 +248,7 @@ StatusCode RootStreamAODMaker::serialize( EventContext &ctx ) const {// serialize cluster - + MSG_DEBUG("Serialize Cluster..."); SG::ReadHandle container( m_inputClusterKey, ctx ); if( !container.isValid() ) @@ -298,6 +306,7 @@ StatusCode RootStreamAODMaker::serialize( EventContext &ctx ) const {// serialize rings + MSG_DEBUG("Serialize Rings..."); SG::ReadHandle container( m_inputRingerKey, ctx ); if( !container.isValid() ) @@ -316,6 +325,23 @@ StatusCode RootStreamAODMaker::serialize( EventContext &ctx ) const } + { + MSG_DEBUG("Serialize Electrons..."); + SG::ReadHandle container( m_inputElectronKey, ctx ); + if (!container.isValid() ) + { + MSG_WARNING("It's not possible to read the xAOD::ElectronContainer using this key " << m_inputElectronKey); + return StatusCode::SUCCESS; + } + + for (const auto electron : **container.ptr() ){ + xAOD::Electron_t electron_t; + xAOD::ElectronConverter cnv; + cnv.convert(electron, electron_t, cluster_links); + container_electron->push_back(electron_t); + } + } + tree->Fill(); @@ -329,6 +355,7 @@ StatusCode RootStreamAODMaker::serialize( EventContext &ctx ) const delete container_event ; delete container_truth ; delete container_seeds ; + delete container_electron ; return StatusCode::SUCCESS; diff --git a/reconstruction/io/RootStreamBuilder/src/RootStreamAODMaker.h b/reconstruction/io/RootStreamBuilder/src/RootStreamAODMaker.h index 857cda6a..aed273b2 100644 --- a/reconstruction/io/RootStreamBuilder/src/RootStreamAODMaker.h +++ b/reconstruction/io/RootStreamBuilder/src/RootStreamAODMaker.h @@ -6,6 +6,7 @@ #include "EventInfo/EventSeed.h" #include "CaloRings/CaloRings.h" #include "CaloCluster/CaloCluster.h" +#include "Particle/Electron.h" #include "TruthParticle/TruthParticle.h" #include "GaugiKernel/StatusCode.h" @@ -57,6 +58,7 @@ class RootStreamAODMaker : public Gaugi::Algorithm std::string m_inputClusterKey; std::string m_inputRingerKey; std::string m_inputTruthKey; + std::string m_inputElectronKey; std::string m_outputCellsKey; std::string m_outputEventKey; @@ -64,6 +66,7 @@ class RootStreamAODMaker : public Gaugi::Algorithm std::string m_outputClusterKey; std::string m_outputRingerKey; std::string m_outputTruthKey; + std::string m_outputElectronKey; bool m_dumpCells; int m_outputLevel; diff --git a/scripts/reco_trf.py b/scripts/reco_trf.py index 9a9a50e1..5396d08f 100755 --- a/scripts/reco_trf.py +++ b/scripts/reco_trf.py @@ -91,7 +91,9 @@ from CaloCutBasedHypo import CaloCutBasedHypoCfg hypo = CaloCutBasedHypoCfg( "CaloCutBasedHypo", - OutputLevel = outputLevel) + InputClusterKey = recordable("Clusters"), + OutputElectronKey = recordable("Electrons"), + OutputLevel = outputLevel) from RootStreamBuilder import RootStreamAODMaker @@ -102,6 +104,7 @@ InputCellsKey = recordable("Cells"), InputClusterKey = recordable("Clusters"), InputRingerKey = recordable("Rings"), + InputElectronKey = recordable("Electrons"), OutputLevel = outputLevel) # sequence @@ -112,7 +115,7 @@ acc.run(args.numberOfEvents) - del acc + # del acc sys.exit(0) except Exception as e: