Skip to content
Snippets Groups Projects
Commit 6beff46e authored by Riccardo Longo's avatar Riccardo Longo
Browse files

New Class HIJetConstituentModifier in HIJetRec

parent 36c98866
7 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!34733Resolve ATLASRECTS-5475, MT protection for HIEventShapeMap,!33702HIClusterSubtraction re-structuring for MT compatibility (ATLASRECT 5493)
// This file is -*- C++ -*-
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef HIJETREC_HIJETCONSTITUENTMODIFIER_H
#define HIJETREC_HIJETCONSTITUENTMODIFIER_H
///////////////////////////////////////////////////////
/// \class HIJetConstituentModifier
/// \author R.Longo - riccardo.longo@cern.ch
/// \date May 2020
///
/// Tool to subtract final HIEventShape from constituents
/// on the fly (w/o modifying clusters)
///////////////////////////////////////////////////////
#include "JetRec/JetModifierBase.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
class HIJetConstituentModifier : public JetModifierBase {
ASG_TOOL_CLASS(HIJetConstituentModifier, IJetModifier);
public:
// Constructor from tool name.
HIJetConstituentModifier(const std::string& myname);
virtual StatusCode initialize() override;
// Inherited method to modify a jet.
virtual int modifyJet(xAOD::Jet& jet) const;
private:
/// \brief Name of input cluster container
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clusterKey { this, "ClusterKey", "ClusterKey", "Name of the input Cluster Container"};
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "HIJetRec/HIJetConstituentModifier.h"
#include "HIJetRec/HIJetRecDefs.h"
#include "xAODJet/JetConstituentVector.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "xAODBase/IParticle.h"
#include "xAODBase/IParticleContainer.h"
#include "JetRec/JetModifierBase.h"
#include "StoreGate/ReadHandle.h"
HIJetConstituentModifier::HIJetConstituentModifier(const std::string& myname): JetModifierBase(myname)
{
}
StatusCode HIJetConstituentModifier::initialize(){
ATH_CHECK( m_clusterKey.initialize() );
return StatusCode::SUCCESS;
}
int HIJetConstituentModifier::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());
}
/// The accessor for the cluster element links
static SG::AuxElement::Accessor< std::vector< ElementLink< xAOD::IParticleContainer > > >
constituentAcc( "constituentLinks" );
static SG::AuxElement::Accessor< std::vector< float> >
constituentWeightAcc( "constituentWeights" );
if( constituentAcc.isAvailable(jet) ) constituentAcc( jet ).resize(0);
if( constituentWeightAcc.isAvailable(jet) ) constituentWeightAcc( jet ).resize(0);
//save unsubtracted kinematics as moment if they don’t exist already...
jet.setJetP4(HIJetRec::unsubtractedJetState(),jet.jetP4());
xAOD::IParticle::FourMom_t subtrP4;
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();
for(auto index : cluster_indices)
{
auto cl=ccl->at(index);
jet.addConstituent(cl);
subtrP4=cl->p4(HIJetRec::subtractedClusterState());
}
jet4vec.SetCoordinates(subtrP4.Pt(),subtrP4.Eta(),subtrP4.Phi(),subtrP4.M());
jet.setJetP4(jet4vec);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment