ATLAS Offline Software
JetHistoSelectSort.cxx
Go to the documentation of this file.
1 #include <list>
5 
6 
7 JetHistoSelectSort::JetHistoSelectSort( const std::string& type, const std::string & name ,const IInterface* parent):
9  , m_jetFillerTools(this)
10  , m_selectTool(this)
11  , m_eventSelTool(this)
12  , m_sortVar(this)
13 
14 {
15  declareInterface<IJetHistoFiller>(this);
16 
17  declareProperty("FillerTools",m_jetFillerTools);
18  declareProperty("Selector",m_selectTool);
19  declareProperty("EventSelector",m_eventSelTool);
20  declareProperty("SortVariable",m_sortVar);
21 }
22 
23 
25  ATH_MSG_INFO(" initialize " );
26 
27  ATH_CHECK(m_jetFillerTools.retrieve() );
28 
29  ATH_MSG_INFO( " Scheduled Histo fillers/selectors : ");
30  for(const auto& t: m_jetFillerTools){
31  ATH_MSG_INFO( "--> "<< t->name() );
32  }
33 
34 
35  if(m_selectTool.isEnabled()){
36  ATH_CHECK(m_selectTool.retrieve());
37  ATH_MSG_INFO( " Selecting with "<< m_selectTool->name() );
38  }
39  if(m_inverseJetSel){
40  ATH_MSG_DEBUG( " inverse Jet Selection will be applied" );
41  }
42 
43  if(m_eventSelTool.isEnabled()){
44  ATH_CHECK(m_eventSelTool.retrieve());
45  ATH_MSG_INFO( " Selecting with "<< m_eventSelTool->name() );
46  }
47 
48  if( m_sortVar.isEnabled() ){
49  ATH_CHECK(m_sortVar.retrieve());
50  ATH_MSG_INFO( "Sorting on var =("<< m_sortVar->describe() << ")");
51  }
52 
53  return StatusCode::SUCCESS;
54 }
55 
56 
57 StatusCode JetHistoSelectSort::processJetContainer(const JetMonitoringAlg& parentAlg, const xAOD::JetContainer & jets, const EventContext& ctx) const {
58 
59 
60  // fill a temporary list of pointer
61  std::list<const xAOD::Jet*> tmpList;
62 
63  // do sort if needed
64  if(m_sortVar.isEnabled() ){
65  auto sort = [this] (const xAOD::Jet * j1, const xAOD::Jet * j2) {return m_sortVar->value(*j1) > m_sortVar->value(*j2); } ;
66  tmpList.sort( sort );
67  }
68 
69  if(m_selIndex>-1){
70  if( (int) jets.size( ) > m_selIndex) { tmpList.push_back( jets[m_selIndex]); }
71  }else {
72  for(const xAOD::Jet* jet : jets ) tmpList.push_back(jet);
73  }
74 
75  // select if needed
76  if(m_selectTool.isEnabled()){
77  if (m_inverseJetSel) {
78  auto sel = [this] (const xAOD::Jet * j) {return m_selectTool->keep(*j) ; } ;
79  tmpList.remove_if( sel );
80  }
81  else {
82  auto sel = [this] (const xAOD::Jet * j) {return ! m_selectTool->keep(*j) ; } ;
83  tmpList.remove_if( sel );
84  }
85  }
86 
87  if(m_eventSelTool.isEnabled()){
88  auto eventInfo = parentAlg.GetEventInfo(ctx);
89  if ( ! m_eventSelTool->keep(*eventInfo, jets) ) tmpList.clear();
90  }
91 
92 
94  for(const xAOD::Jet* jet : tmpList ) tmpCont.push_back(jet);
95  const xAOD::JetContainer * filteredCont = tmpCont.asDataVector();
96 
97  for(const auto& t: m_jetFillerTools){
98  ATH_CHECK(t->processJetContainer(parentAlg, *filteredCont, ctx));
99  }
100 
101 
102  return StatusCode::SUCCESS;
103 }
104 
JetHistoSelectSort::m_eventSelTool
ToolHandle< IJetEventSelector > m_eventSelTool
Definition: JetHistoSelectSort.h:35
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JetHistoSelectSort::JetHistoSelectSort
JetHistoSelectSort(const std::string &type, const std::string &name, const IInterface *parent)
Definition: JetHistoSelectSort.cxx:7
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
JetHistoSelectSort::m_sortVar
ToolHandle< IJetHistoVarTool > m_sortVar
Definition: JetHistoSelectSort.h:38
JetHistoSelectSort::m_jetFillerTools
ToolHandleArray< IJetHistoFiller > m_jetFillerTools
Definition: JetHistoSelectSort.h:32
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
JetHistoSelectSort.h
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
doubleTestComp.j1
j1
Definition: doubleTestComp.py:21
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
sel
sel
Definition: SUSYToolsTester.cxx:92
test_pyathena.parent
parent
Definition: test_pyathena.py:15
JetHistoSelectSort::initialize
virtual StatusCode initialize()
Definition: JetHistoSelectSort.cxx:24
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
JetHistoSelectSort::m_inverseJetSel
Gaudi::Property< bool > m_inverseJetSel
Definition: JetHistoSelectSort.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
JetMonitoringAlg
Definition: JetMonitoringAlg.h:26
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetHistoSelectSort::m_selIndex
Gaudi::Property< int > m_selIndex
Definition: JetHistoSelectSort.h:37
JetMonitoringAlg.h
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
JetHistoSelectSort::m_selectTool
ToolHandle< IJetSelector > m_selectTool
Definition: JetHistoSelectSort.h:34
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
AthAlgTool
Definition: AthAlgTool.h:26
doubleTestComp.j2
j2
Definition: doubleTestComp.py:22
JetHistoSelectSort::processJetContainer
virtual StatusCode processJetContainer(const JetMonitoringAlg &parentAlg, const xAOD::JetContainer &jets, const EventContext &ctx) const
Definition: JetHistoSelectSort.cxx:57