ATLAS Offline Software
METTriggerAugmentationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include <xAODTrigger/JetRoI.h>
11 #include <vector>
12 #include <string>
13 
14 #include <TFile.h>
15 
16 namespace DerivationFramework {
17 
19  const std::string& n,
20  const IInterface* p) :
21  AthAlgTool(t,n,p)
22  {
23  declareInterface<DerivationFramework::IAugmentationTool>(this);
24  declareProperty("OutputName", m_outputName = "LVL1EnergySumRoI_KF");
25  declareProperty("LUTFile", m_LUTFileName = "LUT_data15.root");
26  declareProperty("L1METName", m_L1METName = "LVL1EnergySumRoI");
27  declareProperty("L1JetName", m_L1JetName = "LVL1JetRoIs");
28  }
29 
31  {
32  std::string fullLUTFileName = PathResolver::find_file(m_LUTFileName, "DATAPATH");
33 
34  if (fullLUTFileName.empty() ) {
35  ATH_MSG_ERROR( "File " << m_LUTFileName << " not found!" );
36  return StatusCode::FAILURE;
37  }
38 
39  TFile* lutFile = TFile::Open(fullLUTFileName.c_str() );
40  if (lutFile->IsZombie() ) return StatusCode::FAILURE;
41 
42  TH2* lutFromFile(0);
43  lutFile->GetObject("LUT", lutFromFile);
44  if (!lutFromFile) {
45  ATH_MSG_ERROR( "LUT file doesn't contain a 'LUT' object!" );
46  return StatusCode::FAILURE;
47  }
48 
49  m_LUT.reset(dynamic_cast<TH2*>(lutFromFile->Clone() ) );
50  m_LUT->SetDirectory(0);
51  lutFile->Close();
52  return StatusCode::SUCCESS;
53  }
54 
56  {
57  return StatusCode::SUCCESS;
58  }
59 
60 
61 
63  {
64  ATH_MSG_DEBUG(" In L1KF_METMaker::makeKFMET()" );
65 
66  // if the output has already been written we don't need to do anything
67  if (evtStore()->contains<xAOD::EnergySumRoI>(m_outputName) ) return StatusCode::SUCCESS;
68 
69  const xAOD::EnergySumRoI* originalL1(0);
70  ATH_CHECK( evtStore()->retrieve(originalL1, m_L1METName) );
71 
72  const xAOD::JetRoIContainer* l1Jets(0);
73  ATH_CHECK( evtStore()->retrieve(l1Jets, m_L1JetName) );
74 
77 
78  ATH_MSG_DEBUG( "Setting the store" );
79  // set the store
80  l1_kf->setStore(l1_kfAux);
81 
82  ATH_MSG_DEBUG( "Making deep copy" );
83  // copy across the info
84  *l1_kf = *originalL1;
85 
86  ATH_MSG_DEBUG( "Building KF MET" );
87  float KFMETx = l1_kf->exMiss();
88  float KFMETy = l1_kf->eyMiss();
89  float KFSumEt = l1_kf->energyT();
90 
91  for (const auto jet : *l1Jets) {
92  int etaBin = m_LUT->GetXaxis()->FindBin( fabs( jet->eta() ) );
93  int ptBin = m_LUT->GetYaxis()->FindBin( log2( jet->et8x8() / 1000.) );
94  if (ptBin==0) ptBin=1;
95  float KFweight = m_LUT->GetBinContent(etaBin, ptBin);
96  float jetContribution = jet->et8x8() * KFweight;
97 
98  KFMETx -= jetContribution * cos( jet->phi() );
99  KFMETy -= jetContribution * sin( jet->phi() );
100  KFSumEt += jetContribution;
101  }
102  l1_kf->setEnergyX(-KFMETx);
103  l1_kf->setEnergyY(-KFMETy);
104  l1_kf->setEnergyT(KFSumEt);
105 
106  ATH_MSG_DEBUG( "Built KF MET" );
107  ATH_CHECK( evtStore()->record(l1_kf, m_outputName) );
108  ATH_CHECK( evtStore()->record(l1_kfAux, m_outputName+"Aux.") );
109  return StatusCode::SUCCESS;
110  }
111 }
DerivationFramework::METTriggerAugmentationTool::m_LUT
std::unique_ptr< TH2 > m_LUT
Definition: METTriggerAugmentationTool.h:29
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DerivationFramework::METTriggerAugmentationTool::m_outputName
std::string m_outputName
Definition: METTriggerAugmentationTool.h:25
DerivationFramework::METTriggerAugmentationTool::finalize
virtual StatusCode finalize()
Definition: METTriggerAugmentationTool.cxx:55
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
xAOD::EnergySumRoI_v2::setEnergyX
void setEnergyX(float value)
Set the total energy deposited in the X direction.
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAOD::EnergySumRoI_v2::energyT
float energyT() const
The deposited total transverse energy.
DerivationFramework::METTriggerAugmentationTool::initialize
virtual StatusCode initialize()
Definition: METTriggerAugmentationTool.cxx:30
EnergySumRoIAuxInfo.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
DerivationFramework::METTriggerAugmentationTool::m_L1METName
std::string m_L1METName
Definition: METTriggerAugmentationTool.h:27
xAOD::EnergySumRoIAuxInfo
EnergySumRoIAuxInfo_v2 EnergySumRoIAuxInfo
Declare the most recent version of the energy-sum auxiliary info.
Definition: EnergySumRoIAuxInfo.h:17
xAOD::EnergySumRoIAuxInfo_v2
Auxiliary store for an EnergySum RoI object.
Definition: EnergySumRoIAuxInfo_v2.h:34
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::AuxElement::setStore
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
Definition: AuxElement.cxx:221
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
JetRoIContainer.h
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
TH2
Definition: rootspy.cxx:373
xAOD::EnergySumRoI_v2::setEnergyY
void setEnergyY(float value)
Set the total energy deposited in the Y direction.
PathResolver.h
DerivationFramework::METTriggerAugmentationTool::METTriggerAugmentationTool
METTriggerAugmentationTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: METTriggerAugmentationTool.cxx:18
xAOD::EnergySumRoI_v2::setEnergyT
void setEnergyT(float value)
Set the deposited total transverse energy.
METTriggerAugmentationTool.h
xAOD::EnergySumRoI_v2::exMiss
float exMiss() const
The missing energy in the X direction.
Definition: EnergySumRoI_v2.h:131
JetRoI.h
DerivationFramework::METTriggerAugmentationTool::m_LUTFileName
std::string m_LUTFileName
Definition: METTriggerAugmentationTool.h:26
xAOD::EnergySumRoI
EnergySumRoI_v2 EnergySumRoI
Definition: EnergySumRoI.h:16
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
AthAlgTool
Definition: AthAlgTool.h:26
xAOD::EnergySumRoI_v2::eyMiss
float eyMiss() const
The missing energy in the Y direction.
Definition: EnergySumRoI_v2.h:141
DerivationFramework::METTriggerAugmentationTool::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition: METTriggerAugmentationTool.cxx:62
xAOD::EnergySumRoI_v2
Class describing a LVL1 energy-sum "RoI".
Definition: EnergySumRoI_v2.h:35
DerivationFramework::METTriggerAugmentationTool::m_L1JetName
std::string m_L1JetName
Definition: METTriggerAugmentationTool.h:28
EnergySumRoI.h