ATLAS Offline Software
Loading...
Searching...
No Matches
JetHistoSelectSort.cxx
Go to the documentation of this file.
1#include <list>
5
6
7JetHistoSelectSort::JetHistoSelectSort( const std::string& type, const std::string & name ,const IInterface* parent):
8 AthAlgTool( type, name, 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 }
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
57StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
DataVector adapter that acts like it holds const pointers.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
Gaudi::Property< bool > m_inverseJetSel
virtual StatusCode initialize()
ToolHandle< IJetEventSelector > m_eventSelTool
ToolHandle< IJetSelector > m_selectTool
Gaudi::Property< int > m_selIndex
ToolHandle< IJetHistoVarTool > m_sortVar
JetHistoSelectSort(const std::string &type, const std::string &name, const IInterface *parent)
ToolHandleArray< IJetHistoFiller > m_jetFillerTools
virtual StatusCode processJetContainer(const JetMonitoringAlg &parentAlg, const xAOD::JetContainer &jets, const EventContext &ctx) const
A monitoring algorithm in charge of filling histogram for a JetContainer.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".