diff --git a/Reconstruction/HeavyIonRec/HIJetRec/Root/HIJetConstituentModifierTool.cxx b/Reconstruction/HeavyIonRec/HIJetRec/Root/HIJetConstituentModifierTool.cxx index 450333afab08cd654eb2bec9c26aec464de97de4..8eef344c300e815e100b4428073597dd8d4ff8fd 100644 --- a/Reconstruction/HeavyIonRec/HIJetRec/Root/HIJetConstituentModifierTool.cxx +++ b/Reconstruction/HeavyIonRec/HIJetRec/Root/HIJetConstituentModifierTool.cxx @@ -18,8 +18,9 @@ HIJetConstituentModifierTool::HIJetConstituentModifierTool(const std::string& my StatusCode HIJetConstituentModifierTool::initialize(){ + ATH_MSG_INFO("Initializing HIJetConstituentModifierTool"); //Shallow copy key automatically built from the cluster key - m_clusterKey = m_clusterKey.key() + ".shallowCopy"; + //m_clusterKey += ".shallowCopy"; ATH_CHECK( m_clusterKey.initialize() ); return StatusCode::SUCCESS; @@ -30,7 +31,6 @@ int HIJetConstituentModifierTool::modifyJet(xAOD::Jet& jet) const { const xAOD::JetConstituentVector constituents = jet.getConstituents(); std::vector<size_t> cluster_indices; cluster_indices.reserve(constituents.size()); - for (auto citer = constituents.begin(); citer != constituents.end(); ++citer) { cluster_indices.push_back(citer->rawConstituent()->index()); @@ -52,14 +52,14 @@ int HIJetConstituentModifierTool::modifyJet(xAOD::Jet& jet) const { xAOD::JetFourMom_t jet4vec; //need to add usual safety checks on cluster container access SG::ReadHandle<xAOD::CaloClusterContainer> readHandleSubtractedClusters ( m_clusterKey ); - const xAOD::CaloClusterContainer* ccl=readHandleSubtractedClusters.cptr(); + + const xAOD::CaloClusterContainer* ccl=readHandleSubtractedClusters.get(); + for(auto index : cluster_indices) { auto cl=ccl->at(index); jet.addConstituent(cl); - ATH_MSG_INFO("Cluster Pt(): " << cl->p4(HIJetRec::subtractedClusterState()).Pt()); - subtrP4=cl->p4(HIJetRec::subtractedClusterState()); - ATH_MSG_INFO("SubtrP4 Pt(): " << subtrP4.Pt()); + subtrP4+=cl->p4(HIJetRec::subtractedClusterState()); } jet4vec.SetCoordinates(subtrP4.Pt(),subtrP4.Eta(),subtrP4.Phi(),subtrP4.M()); jet.setJetP4(jet4vec); diff --git a/Reconstruction/HeavyIonRec/HIJetRec/python/HIJetRecUtils.py b/Reconstruction/HeavyIonRec/HIJetRec/python/HIJetRecUtils.py index 9a780a90caa22ea337acae8b344c4296d177060b..f66d4797aca09fc38dd7d892bd4440858735ae01 100644 --- a/Reconstruction/HeavyIonRec/HIJetRec/python/HIJetRecUtils.py +++ b/Reconstruction/HeavyIonRec/HIJetRec/python/HIJetRecUtils.py @@ -218,7 +218,8 @@ def GetConstituentsModifierTool(**kwargs) : if 'name' in kwargs.keys() : toolName = kwargs['name'] print ('Toolname ConstModif %s' % toolName) cmod=HIJetConstituentModifierTool(toolName) - cmod.ClusterKey=cluster_key + cmod.ClusterKey=cluster_key+'.shallowCopy' + jtm.add(cmod) return cmod def AddIteration(seed_container,shape_name, **kwargs) : diff --git a/Reconstruction/HeavyIonRec/HIJetRec/share/HIJetRec_jobOptions.py b/Reconstruction/HeavyIonRec/HIJetRec/share/HIJetRec_jobOptions.py index 3978413969cce150d3564716ac82a90a0c63912c..763dadf76376fb4dd815a85ee60e213372b95eed 100644 --- a/Reconstruction/HeavyIonRec/HIJetRec/share/HIJetRec_jobOptions.py +++ b/Reconstruction/HeavyIonRec/HIJetRec/share/HIJetRec_jobOptions.py @@ -161,11 +161,6 @@ subtr1=MakeSubtractionTool(iter0.OutputEventShapeKey,moment_name="NoIteration",m #main subtractor subtr2=MakeSubtractionTool(HIJetFlags.IteratedEventShapeKey(),modulator=modulator1) -#put subtraction tool at the FRONT of the jet modifiers list -hi_tools=[subtr1,subtr2] -hi_tools+=GetFlowMomentTools(iter1.OutputEventShapeKey,iter1.ModulationEventShapeKey) - - #==========#==========#==========#==========#==========#========== #special addition for egamma #Downstream egamma jo will call SubtractedCellGetter, it assumes that the container pointed to by @@ -178,9 +173,15 @@ if not HIJetFlags.DoCellBasedSubtraction(): #HIJetFlags.IteratedEventShapeKey=iter_egamma.OutputEventShapeKey #Subtraction for egamma and to get layers -#ApplySubtractionToClusters(name="HIClusterSubtraction_egamma", event_shape_key=cell_level_shape_key, cluster_key=ClusterKey, modulator=modulator1, CalculateMoments=True, useClusters=False) +ApplySubtractionToClusters(name="HIClusterSubtraction_egamma", event_shape_key=cell_level_shape_key, cluster_key=ClusterKey, modulator=modulator1, CalculateMoments=True, useClusters=False) #Cluster subtraction for jets ApplySubtractionToClusters(event_shape_key=HIJetFlags.IteratedEventShapeKey(), update_only=True, cluster_key=ClusterKey, modulator=modulator1, CalculateMoments=False, useClusters=True) + +#put subtraction tool at the FRONT of the jet modifiers list +hi_tools=[subtr1,subtr2] +hi_tools+=GetFlowMomentTools(iter1.OutputEventShapeKey,iter1.ModulationEventShapeKey) +hi_tools+=[GetConstituentsModifierTool(name="HIJetConstituentModifierTool", cluster_key=ClusterKey)] + ### #subtracted algorithms #make main jets from unsubtr collections w/ same R, add modifiers for subtraction @@ -190,7 +191,6 @@ for k in jtm.jetrecs : in_name=k.OutputContainer out_name=in_name.replace("_%s" % unsubtr_suffix,"") #>slight tweak in case R=1.0 jets are requestd, add some substructure tools - hi_tools+=GetConstituentsModifierTool(name="HIJetConstituentModifierTool", cluster_key=ClusterKey) modifiers=GetHIModifierList(out_name,hi_tools) if '10HIJets' in k.name() : from JetSubStructureMomentTools.JetSubStructureMomentToolsConf import KtDeltaRTool diff --git a/Reconstruction/HeavyIonRec/HIJetRec/src/HIClusterSubtraction.cxx b/Reconstruction/HeavyIonRec/HIJetRec/src/HIClusterSubtraction.cxx index ff12cf95b8eaa6d2d2dd15f3ddd9349ff2203c7e..ec8ba1e6a244ac56340b1ce6157f9c969c7d9541 100644 --- a/Reconstruction/HeavyIonRec/HIJetRec/src/HIClusterSubtraction.cxx +++ b/Reconstruction/HeavyIonRec/HIJetRec/src/HIClusterSubtraction.cxx @@ -42,11 +42,8 @@ StatusCode HIClusterSubtraction::initialize() int HIClusterSubtraction::execute() const { - //const jet::cellset_t & badcells = badCellMap.cells() ; //retrieve UE - //From here on temporarily commented out code bc needs a dedicated treatment in MT to compile - //In rel 21 we were updating a non-const CaloCalusterContainer. That approach is no more acceptable in Athena MT ATH_MSG_WARNING("HIClusterSubtraction being rebuilt to work in MT - upgrade not yet over! "); const xAOD::HIEventShapeContainer* shape = 0; SG::ReadHandle<xAOD::HIEventShapeContainer> readHandleEvtShape ( m_eventShapeKey ); @@ -60,8 +57,6 @@ int HIClusterSubtraction::execute() const //New implementation: make a shallow copy of original HIClusters and apply subtraction to clusters in the new container SG::ReadHandle<xAOD::CaloClusterContainer> readHandleClusters ( m_inClusterKey ); - ATH_MSG_DEBUG("Shallow-copying HIClusters"); - std::pair<xAOD::CaloClusterContainer*,xAOD::ShallowAuxContainer*> shallowcopy = xAOD::shallowCopyContainer(*readHandleClusters); /// Set whether only the overriden parameters should be written out - default is true @@ -111,12 +106,14 @@ int HIClusterSubtraction::execute() const }//End loop over correction tools } - auto unique_first_copy = xAOD::prepareElementForShallowCopy(shallowcopy.first); - auto unique_second_copy = xAOD::prepareElementForShallowCopy(shallowcopy.second); - - xAOD::setOriginalObjectLink(*readHandleClusters, *unique_first_copy); +// Make sure that memory is managed safely + std::unique_ptr<xAOD::CaloClusterContainer> outClusters(shallowcopy.first); + std::unique_ptr<xAOD::ShallowAuxContainer> shallowAux(shallowcopy.second); - if(writeHandleShallowClusters.record ( std::move(unique_first_copy), std::move(unique_second_copy)).isFailure() ){ + // Connect the copied jets to their originals + xAOD::setOriginalObjectLink(*readHandleClusters, *outClusters); + + if(writeHandleShallowClusters.record ( std::move(outClusters), std::move(shallowAux)).isFailure() ){ ATH_MSG_ERROR("Unable to write Shallow Copy containers for event shape with key: " << m_outClusterKey.key()); return 1; } diff --git a/Reconstruction/HeavyIonRec/HIJetRec/src/HIClusterSubtraction.h b/Reconstruction/HeavyIonRec/HIJetRec/src/HIClusterSubtraction.h index 8bf18543505845d21b99122d59aa8b912f0d5c44..e2d5250e3244945e03679a448abe442ad5d39b4c 100644 --- a/Reconstruction/HeavyIonRec/HIJetRec/src/HIClusterSubtraction.h +++ b/Reconstruction/HeavyIonRec/HIJetRec/src/HIClusterSubtraction.h @@ -50,7 +50,7 @@ private: /// \brief Name of input cluster container SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inClusterKey { this, "ClusterKey", "ClusterKey", "Name of the input Cluster Container"}; /// |brief New writeHandleKey to store the shallow copy used for new CaloClusterTreatment - SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outClusterKey { this, "OutClusterKey", "ClusterKey", "Name of the input Cluster Container"}; + SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outClusterKey { this, "OutClusterKey", "OutClusterKey", "Name of the input Cluster Container"}; /// \brief Name of HIEventShapeContainer defining background SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_eventShapeKey { this, "EventShapeKey", "EventShapeKey", "Name of HIEventShapeContainer defining background"}; diff --git a/Reconstruction/HeavyIonRec/HIJetRec/src/HISubtractedCellMakerTool.cxx b/Reconstruction/HeavyIonRec/HIJetRec/src/HISubtractedCellMakerTool.cxx index 04b80f0cd74240e888feea240d998353f7be8699..d80316b06030c42a113ebc4173bda48b475a8569 100644 --- a/Reconstruction/HeavyIonRec/HIJetRec/src/HISubtractedCellMakerTool.cxx +++ b/Reconstruction/HeavyIonRec/HIJetRec/src/HISubtractedCellMakerTool.cxx @@ -56,13 +56,7 @@ StatusCode HISubtractedCellMakerTool::process (CaloCellContainer* theCells, return StatusCode::SUCCESS; } - // FIXME: m_modulatorTool->retrieveShape() is non-const. - // It should be made const in order to be able to safely call it from here. - // However, this method already needs updating to work in MT (and is checked - // above), so just use a const_cast for now to allow this to compile - // when ToolHandle restrictions are enabled. - - IHIUEModulatorTool* modtool_nc = const_cast<IHIUEModulatorTool*> (m_modulatorTool.get()); + auto modtool_nc = m_modulatorTool.get(); CHECK(modtool_nc->retrieveShape()); for(auto pCell : *theCells) @@ -76,8 +70,8 @@ StatusCode HISubtractedCellMakerTool::process (CaloCellContainer* theCells, { if( std::abs(eta) - HICaloRange::getRange().getRangeMax(sample) ) { - double fp_round=(eta > 0.) ? -5e-3 : 5e-3; - bin=index->getIndex(eta+fp_round,sample); + double fp_round=(eta > 0.) ? -5e-3 : 5e-3; + bin=index->getIndex(eta+fp_round,sample); } } diff --git a/Reconstruction/HeavyIonRec/HIJetRec/src/components/HIJetRec_entries.cxx b/Reconstruction/HeavyIonRec/HIJetRec/src/components/HIJetRec_entries.cxx index 1baa0ad506fb71ce84f1c730f2e82e0f3f46f93d..11e9f6706b7f0ab807e50443025f44aeeddcef36 100644 --- a/Reconstruction/HeavyIonRec/HIJetRec/src/components/HIJetRec_entries.cxx +++ b/Reconstruction/HeavyIonRec/HIJetRec/src/components/HIJetRec_entries.cxx @@ -20,10 +20,9 @@ DECLARE_COMPONENT( HIClusterMaker ) DECLARE_COMPONENT( HIJetCellSubtractorTool ) DECLARE_COMPONENT( HIClusterSubtraction ) DECLARE_COMPONENT( HISubtractedCellMakerTool ) -DECLARE_COMPONENT( HIJetConstituentModifierTool ) #endif - +DECLARE_COMPONENT( HIJetConstituentModifierTool ) DECLARE_COMPONENT( HIEventShapeJetIteration ) DECLARE_COMPONENT( HIJetConstituentSubtractionTool ) DECLARE_COMPONENT( HIJetClusterSubtractorTool )