From 889109448082a20d738d995fd9d5bcf2cf2f4daf Mon Sep 17 00:00:00 2001
From: Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
Date: Tue, 26 May 2020 09:36:14 +0200
Subject: [PATCH] Updated the xAODCaloEvent package's dictionary generation.

Made sure that all potentially useful/necessary types are generated
in an organised fashion, using the helper code from xAODCore.

Removed code not necessary with modern ROOT versions.

Declared the typedef names to the generated ROOT dictionary.

Moved the pure STL types to the xAODCoreSTLDict dictionary. At the
same time fixed the comment in xAODCoreSTLDict.h about the meaning
of "3" in std::bitset<3>.
---
 Event/xAOD/xAODCaloEvent/CMakeLists.txt       |  55 +++----
 .../xAODCaloEvent/xAODCaloEvent/selection.xml | 141 +++++++-----------
 .../xAODCaloEvent/xAODCaloEventDict.h         |  69 ++-------
 .../xAOD/xAODCore/xAODCore/xAODCoreSTLDict.h  |   2 +-
 4 files changed, 88 insertions(+), 179 deletions(-)

diff --git a/Event/xAOD/xAODCaloEvent/CMakeLists.txt b/Event/xAOD/xAODCaloEvent/CMakeLists.txt
index 231c2f98588..6bcb2e19799 100644
--- a/Event/xAOD/xAODCaloEvent/CMakeLists.txt
+++ b/Event/xAOD/xAODCaloEvent/CMakeLists.txt
@@ -1,57 +1,38 @@
-# $Id: CMakeLists.txt 774010 2016-09-20 07:09:26Z krasznaa $
-################################################################################
-# Package: xAODCaloEvent
-################################################################################
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
-# Declare the package name:
+# Declare the package name.
 atlas_subdir( xAODCaloEvent )
 
-# Extra dependencies, based on what environment we're in:
+# Extra dependencies and sources, based on what environment we're in.
+set( extra_libs )
+set( extra_sources )
 if( NOT XAOD_ANALYSIS AND NOT SIMULATIONBASE AND NOT GENERATIONBASE )
-   set( extra_deps Calorimeter/CaloEvent )
    set( extra_libs CaloEvent )
+   set( extra_sources src/*.cxx )
 endif()
 
-if (BUILDVP1LIGHT)
-    if( BUILDVP1LIGHT_DIST STREQUAL "ubuntu")
-        set( extra_libs ${extra_libs} GenVector )
-    endif()
-endif()
-
-# Declare the package's dependencies:
-atlas_depends_on_subdirs(
-   PUBLIC
-   Calorimeter/CaloGeoHelpers
-   Control/AthContainers
-   Control/CxxUtils
-   DetectorDescription/GeoPrimitives
-   Event/xAOD/xAODBase
-   Event/xAOD/xAODCore
-   Control/AthLinks
-   ${extra_deps} )
-
-# External dependencies:
-find_package( Eigen )
+# External dependencies.
 find_package( ROOT COMPONENTS Core GenVector )
-
-# Extra source(s), based on what environment we are in:
-if( NOT XAOD_ANALYSIS AND NOT SIMULATIONBASE AND NOT GENERATIONBASE )
-   set( extra_sources src/*.cxx )
-endif()
+find_package( xAODUtilities )
 
 # Component(s) in the package:
 atlas_add_library( xAODCaloEvent
    xAODCaloEvent/*.h xAODCaloEvent/versions/*.h Root/*.cxx ${extra_sources}
    PUBLIC_HEADERS xAODCaloEvent
-   INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS}
-   LINK_LIBRARIES ${EIGEN_LIBRARIES} ${ROOT_LIBRARIES} CaloGeoHelpers AthContainers
+   INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
+   LINK_LIBRARIES ${ROOT_LIBRARIES} CaloGeoHelpers AthContainers
    CxxUtils GeoPrimitives xAODBase xAODCore AthLinks ${extra_libs} )
 
+atlas_add_xaod_smart_pointer_dicts(
+   INPUT xAODCaloEvent/selection.xml
+   OUTPUT _selectionFile
+   CONTAINERS "xAOD::CaloClusterContainer_v1" "xAOD::CaloTowerContainer_v1" )
+
 atlas_add_dictionary( xAODCaloEventDict
    xAODCaloEvent/xAODCaloEventDict.h
-   xAODCaloEvent/selection.xml
-   LINK_LIBRARIES xAODCaloEvent
+   ${_selectionFile}
+   LINK_LIBRARIES xAODCore xAODCaloEvent
    EXTRA_FILES Root/dict/*.cxx )
 
-# Generate CLIDs for the library explicitly:
+# Generate CLIDs for the library explicitly.
 atlas_generate_cliddb( xAODCaloEvent )
diff --git a/Event/xAOD/xAODCaloEvent/xAODCaloEvent/selection.xml b/Event/xAOD/xAODCaloEvent/xAODCaloEvent/selection.xml
index 59d077c39fe..f0cabd38785 100644
--- a/Event/xAOD/xAODCaloEvent/xAODCaloEvent/selection.xml
+++ b/Event/xAOD/xAODCaloEvent/xAODCaloEvent/selection.xml
@@ -1,93 +1,58 @@
-<!-- $Id: selection.xml 706724 2015-11-09 14:16:39Z wlampl $ -->
+<!-- Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -->
 <lcgdict>
 
-  <!-- CaloCluster(Container> --> 
-
-  <class name="xAOD::CaloCluster_v1" >
-    <field name="m_signalState"  transient="true" />
-    <field name="m_cellLinks"    transient="true" />
-    <field name="m_recoStatus"    transient="true" />
-  </class>
-  <read sourceClass="xAOD::CaloCluster_v1" version="[1-]"
-        targetClass="xAOD::CaloCluster_v1" source="" target="m_signalState" >
-    <![CDATA[
-       m_signalState=xAOD::CaloCluster_v1::CALIBRATED;
-    ]]>
-  </read>
-  <read sourceClass="xAOD::CaloCluster_v1" version="[1-]"
-        targetClass="xAOD::CaloCluster_v1" source="" target="m_cellLinks" >
-    <![CDATA[
-       m_cellLinks=0;
-    ]]>
-  </read>
-  <class name="xAOD::CaloClusterContainer_v1"
-         id="24997BCA-3F6A-4530-8826-822EE9FC3C08" />
-  <typedef name="xAOD::CaloClusterContainer" />
-  <typedef name="xAOD::CaloCluster" />
-
-  <class name="xAOD::CaloClusterAuxContainer_v1"
-         id="CE498B3B-A32D-43A3-B9B3-C13D136BACFC" />
-
-  <class name="xAOD::CaloClusterAuxContainer_v2"
-         id="451393B0-69CD-11E4-A739-02163E00A64D" />
-  <typedef name="xAOD::CaloClusterAuxContainer" />
-
-  <!-- Link types pointing at clusters: -->
-  <class name="DataLink<xAOD::CaloClusterContainer_v1>" />
-  <class name="std::vector<DataLink<xAOD::CaloClusterContainer_v1> >" />
-
-  <class name="ElementLink<xAOD::CaloClusterContainer_v1>" />
-  <class name="std::vector<ElementLink<xAOD::CaloClusterContainer_v1> >" />
-  <class name="std::vector<std::vector<ElementLink<xAOD::CaloClusterContainer_v1> > >" />
-
-
-  <class name="xAOD::CaloClusterBadChannelData_v1" />
-  <class name="std::vector<xAOD::CaloClusterBadChannelData_v1>" />
-  <class name="std::vector< std::vector<xAOD::CaloClusterBadChannelData_v1> >" />
-  <typedef name="xAOD::CaloClusterBadChannelData" />
-  <typedef name="xAOD::CaloClusterBadChannelList" />
+   <!-- xAOD::CaloCluster interface type(s). -->
+   <class name="xAOD::CaloCluster_v1" >
+      <field name="m_signalState"  transient="true" />
+      <field name="m_cellLinks"    transient="true" />
+      <field name="m_recoStatus"   transient="true" />
+   </class>
+   <read sourceClass="xAOD::CaloCluster_v1" version="[1-]"
+         targetClass="xAOD::CaloCluster_v1" source="" target="m_signalState" >
+     <![CDATA[
+        m_signalState = xAOD::CaloCluster_v1::CALIBRATED;
+     ]]>
+   </read>
+   <read sourceClass="xAOD::CaloCluster_v1" version="[1-]"
+         targetClass="xAOD::CaloCluster_v1" source="" target="m_cellLinks" >
+     <![CDATA[
+        m_cellLinks = 0;
+     ]]>
+   </read>
+   <class name="xAOD::CaloClusterContainer_v1"
+          id="24997BCA-3F6A-4530-8826-822EE9FC3C08" />
+   <typedef name="xAOD::CaloCluster" />
+   <typedef name="xAOD::CaloClusterContainer" />
+
+   <!-- xAOD::CaloCluster auxiliary type(s). -->
+   <class name="xAOD::CaloClusterAuxContainer_v1"
+          id="CE498B3B-A32D-43A3-B9B3-C13D136BACFC" />
+   <class name="xAOD::CaloClusterAuxContainer_v2"
+          id="451393B0-69CD-11E4-A739-02163E00A64D" />
+   <typedef name="xAOD::CaloClusterAuxContainer" />
+
+   <!-- xAOD::CaloClusterBadChannelData type(s). -->
+   <class name="xAOD::CaloClusterBadChannelData_v1" />
+   <class name="std::vector<xAOD::CaloClusterBadChannelData_v1>" />
+   <class name="std::vector<std::vector<xAOD::CaloClusterBadChannelData_v1> >" />
+   <typedef name="xAOD::CaloClusterBadChannelData" />
+   <typedef name="xAOD::CaloClusterBadChannelList" />
   
-
-  <!-- CaloTower(Container) -->
-  <class name="xAOD::CaloTower_v1" >
-    <field name="v_fourmom" transient="true" />
-    <field name="m_eta" transient="true" />       
-    <field name="m_phi" transient="true" />
-    <field name="m_invcosheta" transient="true" />
-  </class>
-
-  <class name="xAOD::CaloTowerContainer_v1"
-	 id="EEA02A0F-98D3-464D-BAF1-1C944A700B8A" />
-  <typedef name="xAOD::CaloTowerContainer" />
-  <typedef name="xAOD::CaloTower" />
-
-  <class name="xAOD::CaloTowerAuxContainer_v1"
-	 id="CE74E4D1-D2F4-4CED-8191-EC26D8836575" />
-  <typedef name="xAOD::CaloTowerAuxContainer" />
-
-  <class name="xAOD::CaloTowerContainerBase_v1" />
-
-   <!-- Link types potentially pointing at Towers: -->
-  <class name="DataLink<xAOD::CaloTowerContainer_v1>" />
-  <class name="std::vector<DataLink<xAOD::CaloTowerContainer_v1> >" />
-
-  <class name="ElementLink<xAOD::CaloTowerContainer_v1>" />
-  <class name="std::vector<ElementLink<xAOD::CaloTowerContainer_v1> >" />
-  <class name="std::vector<std::vector<ElementLink<xAOD::CaloTowerContainer_v1> > >" />
-
-
-  <!-- Additional type(s) needed: -->
-  <class name="std::bitset<3>" />
-  <class name="xAOD::CaloVertexedClusterBase"/>
-  <class name="xAOD::CaloVertexedTopoCluster"/>
-  <class name="std::vector<std::vector<std::pair<unsigned int, double > > >"/>
-
-  <!-- Suppress the unwanted classes found by ROOT 6. -->
-  <!-- Hopefully we can remove these extra lines at one point... -->
-  <exclusion>
-    <class name="SG::IConstAuxStore" />
-    <class name="DataLink<SG::IConstAuxStore>" />
-    <class name="DataVector<xAOD::IParticle>" />
-  </exclusion>
+   <!-- xAOD::CaloTower interface type(s). -->
+   <class name="xAOD::CaloTower_v1" />
+   <class name="xAOD::CaloTowerContainerBase_v1" />
+   <class name="xAOD::CaloTowerContainer_v1"
+          id="EEA02A0F-98D3-464D-BAF1-1C944A700B8A" />
+   <typedef name="xAOD::CaloTower" />
+   <typedef name="xAOD::CaloTowerContainer" />
+
+   <!-- xAOD::CaloTower auxiliary type(s). -->
+   <class name="xAOD::CaloTowerAuxContainer_v1"
+          id="CE74E4D1-D2F4-4CED-8191-EC26D8836575" />
+   <typedef name="xAOD::CaloTowerAuxContainer" />
+
+   <!-- Additional type(s) used in reconstruction. -->
+   <class name="xAOD::CaloVertexedClusterBase" />
+   <class name="xAOD::CaloVertexedTopoCluster" />
 
 </lcgdict>
diff --git a/Event/xAOD/xAODCaloEvent/xAODCaloEvent/xAODCaloEventDict.h b/Event/xAOD/xAODCaloEvent/xAODCaloEvent/xAODCaloEventDict.h
index 7272a5c0b67..29d9afc6223 100644
--- a/Event/xAOD/xAODCaloEvent/xAODCaloEvent/xAODCaloEventDict.h
+++ b/Event/xAOD/xAODCaloEvent/xAODCaloEvent/xAODCaloEventDict.h
@@ -1,41 +1,19 @@
 // Dear emacs, this is -*- c++ -*-
-
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
-
-// $Id: xAODCaloEventDict.h 700669 2015-10-15 08:31:13Z wlampl $
 #ifndef XAODCALOEVENT_XAODCALOEVENTDICT_H
 #define XAODCALOEVENT_XAODCALOEVENTDICT_H
 
-// Needed to successfully generate the dictionary in standalone mode:
-#if defined(__GCCXML__) and not defined(EIGEN_DONT_VECTORIZE)
-#   define EIGEN_DONT_VECTORIZE
-#endif // __GCCXML__
-
-
-// System include(s):
-#include <vector>
-#include <bitset>
-
-// EDM include(s):
-#include "AthLinks/DataLink.h"
-#include "AthLinks/ElementLink.h"
-
 // Local include(s):
 #include "xAODCaloEvent/CaloCluster.h"
 #include "xAODCaloEvent/CaloClusterContainer.h"
+#include "xAODCaloEvent/CaloClusterAuxContainer.h"
 #include "xAODCaloEvent/versions/CaloCluster_v1.h"
 #include "xAODCaloEvent/versions/CaloClusterContainer_v1.h"
 #include "xAODCaloEvent/versions/CaloClusterAuxContainer_v1.h"
 #include "xAODCaloEvent/versions/CaloClusterAuxContainer_v2.h"
-#include "xAODCaloEvent/CaloClusterAuxContainer.h"
-#include "xAODCaloEvent/CaloVertexedClusterBase.h"
-#include "xAODCaloEvent/CaloVertexedTopoCluster.h"
-#include "xAODCaloEvent/CaloClusterBadChannelData.h"
 
-//#include "xAODCaloEvent/CaloTowerDescriptor.h"
-//#include "xAODCaloEvent/CaloTowerGrid.h"
 #include "xAODCaloEvent/CaloTower.h"
 #include "xAODCaloEvent/CaloTowerContainer.h"
 #include "xAODCaloEvent/CaloTowerAuxContainer.h"
@@ -43,38 +21,23 @@
 #include "xAODCaloEvent/versions/CaloTowerContainer_v1.h"
 #include "xAODCaloEvent/versions/CaloTowerAuxContainer_v1.h"
 
+#include "xAODCaloEvent/CaloClusterBadChannelData.h"
+#include "xAODCaloEvent/versions/CaloClusterBadChannelData_v1.h"
 
-namespace {
-   struct GCCXML_DUMMY_INSTANTIATION_XAODCALOEVENT {
-      // Container(s):
-      xAOD::CaloClusterContainer_v1 c1;
-      // Data link(s):
-      DataLink< xAOD::CaloClusterContainer_v1 > dl1;
-     std::vector< DataLink< xAOD::CaloClusterContainer_v1 > > dl2;
-      // Element link(s):
-      ElementLink< xAOD::CaloClusterContainer_v1 > el1;
-      std::vector< ElementLink< xAOD::CaloClusterContainer_v1 > > el2;
-      std::vector< std::vector< ElementLink< xAOD::CaloClusterContainer_v1 > > > el3;
-      // Additional type(s) needed:
-      std::bitset< 3 > type1; // Using 3 instead of CaloCluster::NSTATES...
-     std::vector<std::vector<std::pair<unsigned int, double > > > calHitDecoratorType;
-
-     //BadChannel lists 
-     xAOD::CaloClusterBadChannelData_v1 bcd;
-     std::vector<xAOD::CaloClusterBadChannelData_v1> vbcd;
-     std::vector<std::vector<xAOD::CaloClusterBadChannelData_v1> > vvbcd;
+#include "xAODCaloEvent/CaloVertexedClusterBase.h"
+#include "xAODCaloEvent/CaloVertexedTopoCluster.h"
 
-     // CaloTower containers
-     xAOD::CaloTowerContainer_v1 t1;
-     xAOD::CaloTowerContainerBase_v1 dvt;
-     // Data link(s)
-     DataLink< xAOD::CaloTowerContainer_v1 > tdl1;
-     std::vector< DataLink< xAOD::CaloTowerContainer_v1 > > tdl2;
-     // Element link(s)
-     ElementLink< xAOD::CaloTowerContainer_v1 > tel1;
-     std::vector< ElementLink< xAOD::CaloTowerContainer_v1 > > tel2;
-     std::vector< std::vector< ElementLink< xAOD::CaloTowerContainer_v1 > > > tel3;
+// EDM include(s).
+#include "xAODCore/tools/DictHelpers.h"
 
+// Instantiate all necessary types for the dictionary.
+namespace {
+   struct GCCXML_DUMMY_INSTANTIATION_XAODCALOEVENT {
+      // Local type(s).
+      XAOD_INSTANTIATE_NS_CONTAINER_TYPES( xAOD, CaloClusterContainer_v1 );
+      XAOD_INSTANTIATE_NS_CONTAINER_TYPES( xAOD, CaloTowerContainer_v1 );
+      std::vector< xAOD::CaloClusterBadChannelData_v1 > v1;
+      std::vector< std::vector< xAOD::CaloClusterBadChannelData_v1 > > v2;
    };
 }
 
diff --git a/Event/xAOD/xAODCore/xAODCore/xAODCoreSTLDict.h b/Event/xAOD/xAODCore/xAODCore/xAODCoreSTLDict.h
index 3e654d4acf8..a1decebaf91 100644
--- a/Event/xAOD/xAODCore/xAODCore/xAODCoreSTLDict.h
+++ b/Event/xAOD/xAODCore/xAODCore/xAODCoreSTLDict.h
@@ -64,7 +64,7 @@ namespace {
       std::map< std::string, std::vector< std::vector< float > > > stl_m4;
 
       // "Other" type(s).
-      std::bitset< 3 > stl_o1; // 3 == ? Something needed for xAODCaloEvent
+      std::bitset< 3 > stl_o1; // 3 == CaloCluster::NSTATES
       std::bitset< 11 > stl_o2; // 11 == xAOD::NumberOfTrackRecoInfo
       std::set< uint32_t > stl_o3;
    };
-- 
GitLab