diff --git a/Calorimeter/CaloEvent/CaloEvent/CaloCellContainer.h b/Calorimeter/CaloEvent/CaloEvent/CaloCellContainer.h index 567abb83da5a9f9d54dadcee93b8d51dedcf62e5..3adbd33280bbc29246a8b867b1a56ed930e3e475 100644 --- a/Calorimeter/CaloEvent/CaloEvent/CaloCellContainer.h +++ b/Calorimeter/CaloEvent/CaloEvent/CaloCellContainer.h @@ -63,6 +63,7 @@ class CaloCellContainer : public DataVector<CaloCell> friend class CaloCellContainerFinalizerTool; friend class CaloCompactCellTool; friend class FullCaloCellContMaker; + friend class EmptyCellBuilderTool; public: @@ -213,6 +214,7 @@ time this method of findCellVector is used */ /** @brief If @ flag is true, then the container size equals the maximum hash. * Only CaloCellContainerFinalizer tool is allowed to set this. + * Now, set this in EmptyCellBuilderTool as it is always true. */ void setHasTotalSize(const bool); diff --git a/Simulation/FastShower/FastCaloSim/CMakeLists.txt b/Simulation/FastShower/FastCaloSim/CMakeLists.txt index 1d727ea72394b787da1d491e9af12e9c8f5ffa5c..e8da8b3bd1a93648232f65afbceda3ace80ad106 100644 --- a/Simulation/FastShower/FastCaloSim/CMakeLists.txt +++ b/Simulation/FastShower/FastCaloSim/CMakeLists.txt @@ -64,6 +64,7 @@ atlas_add_root_dictionary( FastCaloSimLib EXTERNAL_PACKAGES ROOT HepPDT CLHEP HepMC Eigen ) atlas_add_library( FastCaloSimLib + src/CaloCellContainerFCSFinalizerTool.cxx src/AddNoiseCellBuilderTool.cxx src/BasicCellBuilderTool.cxx src/EmptyCellBuilderTool.cxx diff --git a/Simulation/FastShower/FastCaloSim/FastCaloSim/CaloCellContainerFCSFinalizerTool.h b/Simulation/FastShower/FastCaloSim/FastCaloSim/CaloCellContainerFCSFinalizerTool.h new file mode 100644 index 0000000000000000000000000000000000000000..e5cfecc4f49d855c7d4b61db09bc8fac2644a04a --- /dev/null +++ b/Simulation/FastShower/FastCaloSim/FastCaloSim/CaloCellContainerFCSFinalizerTool.h @@ -0,0 +1,37 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + + +#ifndef CALOCELLCONTAINERFCSFINALIZERTOOL_H +#define CALOCELLCONTAINERFCSFINALIZERTOOL_H + +#include "AthenaBaseComps/AthAlgTool.h" + +#include "CaloInterface/ICaloCellMakerTool.h" +#include "CaloInterface/ICaloConstCellMakerTool.h" + +class CaloCellContainerFCSFinalizerTool + : public extends<AthAlgTool, ICaloCellMakerTool, ICaloConstCellMakerTool> +{ +public: + CaloCellContainerFCSFinalizerTool(const std::string& type, + const std::string& name, + const IInterface* parent) ; + + + // update theCellContainer + virtual StatusCode process (CaloCellContainer* theCellContainer, + const EventContext& ctx) const override; + virtual StatusCode process (CaloConstCellContainer* theCellContainer, + const EventContext& ctx) const override; + +private: + template <class CONTAINER> + StatusCode doProcess (CONTAINER* theCellContainer) const; +}; + +#endif + diff --git a/Simulation/FastShower/FastCaloSim/src/CaloCellContainerFCSFinalizerTool.cxx b/Simulation/FastShower/FastCaloSim/src/CaloCellContainerFCSFinalizerTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2a9507522c5624c6dbad3c2a2a79b6c7b5e3c0d8 --- /dev/null +++ b/Simulation/FastShower/FastCaloSim/src/CaloCellContainerFCSFinalizerTool.cxx @@ -0,0 +1,72 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: CaloCellContainerFCSFinalizerTool +PACKAGE: athena/Simulation/FastShower/FastCaloSim + +AUTHORS: David Rousseau (modified by Xiaozhong Huang) +CREATED: Jan 25,2019 + +PURPOSE: Apply necessary finalising operation to CaloCellContainer + Remove any checks since the CaloCellContainer is complete + and ordered from the beginning +********************************************************************/ + +#include "FastCaloSim/CaloCellContainerFCSFinalizerTool.h" + +#include "GaudiKernel/Service.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/Property.h" +#include "GaudiKernel/ListItem.h" + +#include "StoreGate/StoreGateSvc.h" + + +#include "CaloEvent/CaloCellContainer.h" +#include "CaloEvent/CaloConstCellContainer.h" +#include "CaloDetDescr/CaloDetDescrManager.h" +#include "CaloIdentifier/CaloCell_ID.h" + + +///////////////////////////////////////////////////////////////////// +// CONSTRUCTOR: +///////////////////////////////////////////////////////////////////// + +CaloCellContainerFCSFinalizerTool::CaloCellContainerFCSFinalizerTool( + const std::string& type, + const std::string& name, + const IInterface* parent) + :base_class(type, name, parent) +{ +} + + +template <class CONTAINER> +StatusCode CaloCellContainerFCSFinalizerTool::doProcess(CONTAINER* theCont ) const +{ + + theCont->updateCaloIterators(); + + return StatusCode::SUCCESS; +} + + +StatusCode +CaloCellContainerFCSFinalizerTool::process (CaloCellContainer * theCont, + const EventContext& /*ctx*/) const +{ + CHECK( doProcess (theCont) ); + return StatusCode::SUCCESS; +} + + +StatusCode +CaloCellContainerFCSFinalizerTool::process (CaloConstCellContainer * theCont, + const EventContext& /*ctx*/) const +{ + // Container will automatically be locked when recorded. + return doProcess (theCont); +} diff --git a/Simulation/FastShower/FastCaloSim/src/EmptyCellBuilderTool.cxx b/Simulation/FastShower/FastCaloSim/src/EmptyCellBuilderTool.cxx index 44d894db31e943f195b558dde2c98496bd3bb142..095d86fcb9f80d77c23c2a53b620418b4a30830b 100755 --- a/Simulation/FastShower/FastCaloSim/src/EmptyCellBuilderTool.cxx +++ b/Simulation/FastShower/FastCaloSim/src/EmptyCellBuilderTool.cxx @@ -121,7 +121,42 @@ void EmptyCellBuilderTool::create_empty_calo(const EventContext& ctx, } log << MSG::DEBUG << ncreate<<" cells created, "<<nfound<<" cells already found: size="<<theCellContainer->size()<<" e="<<E_tot<<" ; et="<<Et_tot<<". Now initialize and order calo..." << endmsg; - theCellContainer->order(); + + // check whether has max hash id size + const CaloCell_ID * theCaloCCIDM = m_caloDDM->getCaloCell_ID() ; + unsigned int hashMax=theCaloCCIDM->calo_cell_hash_max(); + if (theCellContainer->size()<hashMax) { + ATH_MSG_DEBUG("CaloCellContainer size " << theCellContainer->size() << " smaller than hashMax: " << hashMax); + } + else if (theCellContainer->size()==hashMax) { + ATH_MSG_DEBUG("CaloCellContainer size " << theCellContainer->size() << " correspond to hashMax : " << hashMax); + theCellContainer->setHasTotalSize(true); + } + else { + ATH_MSG_WARNING("CaloCellContainer size " << theCellContainer->size() + << " larger than hashMax ! Too many cells ! " << hashMax); + + } + + // check whether in order and complete + if (theCellContainer->checkOrderedAndComplete()){ + ATH_MSG_DEBUG("CaloCellContainer ordered and complete"); + theCellContainer->setIsOrderedAndComplete(true); + theCellContainer->setIsOrdered(true); + } else { + ATH_MSG_DEBUG("CaloCellContainer not ordered or incomplete"); + theCellContainer->setIsOrderedAndComplete(false); + // check whether in order + if (theCellContainer->checkOrdered()){ + ATH_MSG_DEBUG("CaloCellContainer ordered"); + theCellContainer->setIsOrdered(true); + } else { + ATH_MSG_DEBUG("CaloCellContainer not ordered"); + theCellContainer->setIsOrdered(false); + } + } + + if (!theCellContainer->isOrdered()) theCellContainer->order(); #if FastCaloSim_project_release_v1 == 12 #else diff --git a/Simulation/FastShower/FastCaloSim/src/components/FastCaloSim_entries.cxx b/Simulation/FastShower/FastCaloSim/src/components/FastCaloSim_entries.cxx index 777746598016a4af86f0a38cabd872cb86151c0f..01ab2c3c2b9a8be5e8554a0897957de67794e902 100644 --- a/Simulation/FastShower/FastCaloSim/src/components/FastCaloSim_entries.cxx +++ b/Simulation/FastShower/FastCaloSim/src/components/FastCaloSim_entries.cxx @@ -2,6 +2,7 @@ #include "FastCaloSim/EmptyCellBuilderTool.h" #include "FastCaloSim/AddNoiseCellBuilderTool.h" #include "FastCaloSim/FSStoregateClean.h" +#include "FastCaloSim/CaloCellContainerFCSFinalizerTool.h" //#include "FastCaloSim/FSRedoCBNT.h" //#include "FastCaloSim/CBNTAA_DetailedCellInfo.h" @@ -11,5 +12,6 @@ DECLARE_COMPONENT( FastCaloSim::FSStoregateClean ) DECLARE_COMPONENT( FastShowerCellBuilderTool ) DECLARE_COMPONENT( EmptyCellBuilderTool ) DECLARE_COMPONENT( AddNoiseCellBuilderTool ) +DECLARE_COMPONENT( CaloCellContainerFCSFinalizerTool ) //DECLARE_COMPONENT( CBNTAA_DetailedCellInfo ) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/AdditionalConfig.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/AdditionalConfig.py index 99b8dd896dbf67d99e49cf5416407dd2f7870b5d..7f6dfb730a4ae47e2ee7a87ed876c9fefb50a7d5 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/AdditionalConfig.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/AdditionalConfig.py @@ -860,6 +860,10 @@ def getCaloCellContainerFinalizerTool(name="ISF_CaloCellContainerFinalizerTool", from CaloRec.CaloRecConf import CaloCellContainerFinalizerTool return CaloCellContainerFinalizerTool(name, **kwargs ) +def getCaloCellContainerFCSFinalizerTool(name="ISF_CaloCellContainerFCSFinalizerTool", **kwargs): + from FastCaloSim.FastCaloSimConf import CaloCellContainerFCSFinalizerTool + return CaloCellContainerFCSFinalizerTool(name, **kwargs ) + def getFastHitConvAlg(name="ISF_FastHitConvAlg", **kwargs): from ISF_FastCaloSimServices.ISF_FastCaloSimJobProperties import ISF_FastCaloSimFlags kwargs.setdefault("CaloCellsInputName" , ISF_FastCaloSimFlags.CaloCellsName() ) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfig.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfig.py index 5c476d2d9a0f9fb1da5610053fbdefc4d33c3142..2cfc640f05f499f1d3961aa8759a748d1673d3e4 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfig.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfig.py @@ -27,7 +27,7 @@ def getLegacyAFIIFastCaloSimSvc(name="ISF_LegacyAFIIFastCaloSimSvc", **kwargs): def getFastHitConvAlgFastCaloSimSvc(name="ISF_FastHitConvAlgFastCaloSimSvc",**kwargs): kwargs.setdefault("CaloCellMakerTools_release", [ #'ISF_AddNoiseCellBuilderTool', - 'ISF_CaloCellContainerFinalizerTool' + 'ISF_CaloCellContainerFCSFinalizerTool' ] ) # setup FastCaloSim hit converter and add it to the alg sequence: # -> creates HITS from reco cells @@ -57,7 +57,7 @@ def getFastCaloSimPileupOTSvc(name="ISF_FastCaloSimPileupOTSvc", **kwargs): kwargs.setdefault("CaloCellMakerTools_setup" , [ 'ISF_EmptyCellBuilderTool' ] ) kwargs.setdefault("CaloCellMakerTools_simulate" , [ 'ISF_FastShowerCellBuilderTool' ]) kwargs.setdefault("CaloCellMakerTools_release" , [ #'ISF_AddNoiseCellBuilderTool', - 'ISF_CaloCellContainerFinalizerTool', + 'ISF_CaloCellContainerFCSFinalizerTool', 'ISF_FastHitConvertTool' ]) kwargs.setdefault("Extrapolator" , 'ISF_NITimedExtrapolator') # register the FastCaloSim random number streams @@ -72,7 +72,7 @@ def getFastCaloSimSvcV2(name="ISF_FastCaloSimSvcV2", **kwargs): kwargs.setdefault("CaloCellsOutputName" , ISF_FastCaloSimFlags.CaloCellsName() ) kwargs.setdefault("CaloCellMakerTools_setup" , [ 'ISF_EmptyCellBuilderTool' ] ) - kwargs.setdefault("CaloCellMakerTools_release" , [ 'ISF_CaloCellContainerFinalizerTool', + kwargs.setdefault("CaloCellMakerTools_release" , [ 'ISF_CaloCellContainerFCSFinalizerTool', 'ISF_FastHitConvertTool' ]) kwargs.setdefault("ParamsInputFilename" , ISF_FastCaloSimFlags.ParamsInputFilename()) kwargs.setdefault("ParamsInputObject" , 'SelPDGID') diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfigDb.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfigDb.py index ef876dd16d2e6f4cc8808d7fa1b58b639d5df4c6..a7300b00f6d72f513689a8d11607e05dc7b55905 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfigDb.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/python/ISF_FastCaloSimServicesConfigDb.py @@ -19,6 +19,7 @@ addTool("ISF_FastCaloSimServices.AdditionalConfig.getPileupFastShowerCellBuilder addTool("ISF_FastCaloSimServices.AdditionalConfig.getCaloNoiseTool", "ISF_FCS_CaloNoiseTool") addTool("ISF_FastCaloSimServices.AdditionalConfig.getAddNoiseCellBuilderTool", "ISF_AddNoiseCellBuilderTool") addTool("ISF_FastCaloSimServices.AdditionalConfig.getCaloCellContainerFinalizerTool", "ISF_CaloCellContainerFinalizerTool") +addTool("ISF_FastCaloSimServices.AdditionalConfig.getCaloCellContainerFCSFinalizerTool", "ISF_CaloCellContainerFCSFinalizerTool") addTool("ISF_FastCaloSimServices.AdditionalConfig.getFastHitConvertTool", "ISF_FastHitConvertTool") addTool("ISF_FastCaloSimServices.AdditionalConfig.getFastCaloTool", "ISF_FastCaloTool")