ATLAS Offline Software
FeatureCollectAthena.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef XAOD_ANALYSIS // Full Athena only
6 
7 
10 
13 
15 
16 namespace Trig{
17  namespace FeatureAccessImpl {
18  // returns TrigPassBits object appropriate for given object
19  // if there is none returns 0 pointer
20  // not this is not templated function, can be changed anytime needed
21  const TrigPassBits* getBits(size_t sz, const HLT::TriggerElement* te, const std::string& /*label*/, const HLT::NavigationCore* navigation ) {
22  if (!sz)
23  return 0;
24 
25  const TrigPassBits* bits(0);
26 
27  if ( navigation->getFeature(te, bits, "passbits" ) ){
28  // We have to apply (vague) verification if there are any bits and that they match the feature container
29  // this is if there are any bits,
30  // if so that they come from the same TE
31  // if so that they match by size
32 
33  if ( bits && sz == bits->size() )
34  return bits; // they are good and can be used
35  }
36  return 0; // bits recording was problematic (Navigation will complain bitterly, no need to handle it here).
37  }
38 
39  const TrigPassFlags* getFlags(size_t size, const HLT::TriggerElement* te, const std::string& label, const HLT::NavigationCore* navigation ) {
40  if(size==0) return 0;
41 
42  const TrigPassFlags* flags(0);
43  if(navigation->getFeature(te, flags, label) && flags && flags->size()==size)
44  return flags;
45 
46  return 0;
47  }
48 
49  // L1 specific access ( objects not in the navigation, we need to pick them from different container in SG)
50  template<class T>
51  void l1collect(const HLT::TriggerElement* te, std::vector<Trig::Feature<T> >& data, unsigned int condition,
52  const std::vector<T>& (LVL1_ROI::*method)() const,
53  const HLT::TrigNavStructure* navstructure) {
54 
55  auto navigation = dynamic_cast<const HLT::NavigationCore*>(navstructure);
56 
57  // first we need to collect RoI descriptors
58  std::vector<Trig::Feature<TrigRoiDescriptor> > rois;
59  collect<TrigRoiDescriptor>(te, rois, "initialRoI", condition, "", navigation);
60 
61  const LVL1_ROI* lvl1(0);
62 
63  if ( !navigation || navigation->getAccessProxy()->retrieve(lvl1, "LVL1_ROI").isFailure() || lvl1 == 0 ) {
64  return;
65  }
66 
67  for(const Trig::Feature<TrigRoiDescriptor>& roi : rois) {
68  for(const T& specific : (lvl1->*(method))() ) {
69  if (specific.getROIWord() == roi.cptr()->roiWord()) {
70  data.push_back( Trig::Feature<T>( &specific, roi.te(), "") );
71  break;
72  }
73  }
74  }
75  }
76 
77  template<>
78  void collect<Muon_ROI>(const HLT::TriggerElement* te, std::vector<Trig::Feature<Muon_ROI> >& data, const std::string&, unsigned int condition, const std::string&, const HLT::TrigNavStructure* navigation) {
79  l1collect<Muon_ROI>(te, data, condition, &LVL1_ROI::getMuonROIs, navigation);
80  }
81 
82  template<>
83  void collect<EmTau_ROI>(const HLT::TriggerElement* te, std::vector<Trig::Feature<EmTau_ROI> >& data, const std::string&, unsigned int condition, const std::string&, const HLT::TrigNavStructure* navigation) {
84  l1collect<EmTau_ROI>(te, data, condition, &LVL1_ROI::getEmTauROIs, navigation);
85  }
86 
87  template<>
88  void collect<Jet_ROI>(const HLT::TriggerElement* te, std::vector<Trig::Feature<Jet_ROI> >& data, const std::string&, unsigned int condition, const std::string&, const HLT::TrigNavStructure* navigation) {
89  l1collect<Jet_ROI>(te, data, condition, &LVL1_ROI::getJetROIs, navigation);
90  }
91 
92  template<typename ROI,typename ROICONTAINER>
93  void xAODcollect(const HLT::TriggerElement* te, std::vector<Trig::Feature<ROI> >& data, unsigned int condition, const HLT::TrigNavStructure* navstructure, const std::string& sgkey){
94  // first we need to collect RoI descriptors
95 
96  auto navigation = dynamic_cast<const HLT::NavigationCore*>(navstructure);
97 
98 
99  std::vector<Trig::Feature<TrigRoiDescriptor> > rois;
100  collect<TrigRoiDescriptor>(te, rois, "initialRoI", condition, "", navigation);
101 
102  //get all EmTau RoIs
103  const ROICONTAINER* cont;
104  if (!navigation || navigation->getAccessProxy()->retrieve(cont,sgkey).isFailure()) {
105  REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR,"Feature.cxx:xAODcollect") << "failed retrieving RoI container" << endmsg;
106 
107  REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR,"Feature.cxx:xAODcollect") << "\n" << (navigation ? navigation->getAccessProxy()->dump() : "") << endmsg;
108 
109 
110  return;
111  }
112 
113  typename ROICONTAINER::const_iterator emtauit;
114  //ROI* found(0);
115  for(const auto& it : rois){
116  for(emtauit=cont->begin();emtauit!=cont->end();++emtauit){
117  if((*emtauit)->roiWord() == it.cptr()->roiWord()){
118  data.push_back( Trig::Feature<ROI>(*emtauit, it.te(), "") );
119  break;
120  }
121  }
122  }
123  }
124 
125  template<>
126  void collect<xAOD::EmTauRoI>(const HLT::TriggerElement* te, std::vector<Trig::Feature<xAOD::EmTauRoI> >& data, const std::string&, unsigned int condition, const std::string&, const HLT::TrigNavStructure* navigation) {
127  xAODcollect<xAOD::EmTauRoI,xAOD::EmTauRoIContainer>(te, data, condition, navigation,"LVL1EmTauRoIs");
128  }
129 
130  template<>
131  void collect<xAOD::MuonRoI>(const HLT::TriggerElement* te, std::vector<Trig::Feature<xAOD::MuonRoI> >& data, const std::string&, unsigned int condition, const std::string&, const HLT::TrigNavStructure* navigation) {
132  xAODcollect<xAOD::MuonRoI,xAOD::MuonRoIContainer>(te, data, condition, navigation,"LVL1MuonRoIs");
133  }
134 
135  template<>
136  void collect<xAOD::JetRoI>(const HLT::TriggerElement* te, std::vector<Trig::Feature<xAOD::JetRoI> >& data, const std::string&, unsigned int condition, const std::string&, const HLT::TrigNavStructure* navigation) {
137  xAODcollect<xAOD::JetRoI,xAOD::JetRoIContainer>(te, data, condition, navigation,"LVL1JetRoIs");
138  }
139 
140 
141  template<>
143  return TrigPassFlags();
144  }
145  template<>
147  return TrigPassFlags();
148  }
149  template<>
151  return TrigPassFlags();
152  }
153  } // EOF namespace FeatureAccessImpl
154 } // EOF namespace Trig
155 #endif // full Athena env
RunTileTBRec.method
method
Definition: RunTileTBRec.py:73
LVL1_ROI::getMuonROIs
const muons_type & getMuonROIs() const
Get all the muon RoIs in the event.
Definition: LVL1_ROI.h:63
common.sgkey
def sgkey(tool)
Definition: common.py:1028
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
Trig::Feature
Definition: Feature.h:112
fitman.sz
sz
Definition: fitman.py:527
AthCheckMacros.h
Trig
The common trigger namespace for trigger analysis tools.
Definition: LArCellMonAlg.h:33
Trig::FeatureAccessImpl::getBits
const TrigPassBits * getBits(size_t sz, const HLT::TriggerElement *te, const std::string &, const HLT::NavigationCore *navigation)
Definition: FeatureCollectAthena.cxx:21
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
TrigPassBits::size
unsigned int size() const
gets size of the bits array
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/TrigPassBits.h:44
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LArG4GenerateShowerLib.condition
condition
Definition: LArG4GenerateShowerLib.py:19
Trig::FeatureAccessImpl::collect< Muon_ROI >
void collect< Muon_ROI >(const HLT::TriggerElement *te, std::vector< Trig::Feature< Muon_ROI > > &data, const std::string &, unsigned int condition, const std::string &, const HLT::TrigNavStructure *navigation)
Definition: FeatureCollectAthena.cxx:78
HLT::TrigNavStructure
Definition: TrigNavStructure.h:40
Trig::FeatureAccessImpl::collect< EmTau_ROI >
void collect< EmTau_ROI >(const HLT::TriggerElement *te, std::vector< Trig::Feature< EmTau_ROI > > &data, const std::string &, unsigned int condition, const std::string &, const HLT::TrigNavStructure *navigation)
Definition: FeatureCollectAthena.cxx:83
Trig::FeatureAccessImpl::getFlags
const TrigPassFlags * getFlags(size_t size, const HLT::TriggerElement *te, const std::string &label, const HLT::NavigationCore *navigation)
Definition: FeatureCollectAthena.cxx:39
HLT::NavigationCore::getFeature
bool getFeature(const TriggerElement *te, const T *&features, const std::string &label="", std::string &sourcelabel=::HLT::TrigNavStructure::m_unspecifiedLabel) const
LVL1_ROI::getJetROIs
const jets_type & getJetROIs() const
Get all the jet RoIs in the event.
Definition: LVL1_ROI.h:67
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
HLT::NavigationCore
The NavigationCore class, adds on top of the TrigNavStructure the EDM read-only handling.
Definition: NavigationCore.h:96
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
HLT::TriggerElement
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:27
LVL1_ROI
Top level AOD object storing LVL1 RoIs.
Definition: LVL1_ROI.h:43
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:345
TrigPassBits
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/TrigPassBits.h:17
Trig::FeatureAccessImpl::l1collect
void l1collect(const HLT::TriggerElement *te, std::vector< Trig::Feature< T > > &data, unsigned int condition, const std::vector< T > &(LVL1_ROI::*method)() const, const HLT::TrigNavStructure *navstructure)
Definition: FeatureCollectAthena.cxx:51
Trig::FeatureAccessImpl::collect< Jet_ROI >
void collect< Jet_ROI >(const HLT::TriggerElement *te, std::vector< Trig::Feature< Jet_ROI > > &data, const std::string &, unsigned int condition, const std::string &, const HLT::TrigNavStructure *navigation)
Definition: FeatureCollectAthena.cxx:88
TriggerTest.rois
rois
Definition: TriggerTest.py:23
TrigPassFlags
A Flag is an ordered collection of bits (vector<bool>) that can hold additional (boolean) information...
Definition: TrigPassFlags.h:29
Trig::FeatureAccessImpl::xAODcollect
void xAODcollect(const HLT::TriggerElement *te, std::vector< Trig::Feature< ROI > > &data, unsigned int condition, const HLT::TrigNavStructure *navstructure, const std::string &sgkey)
Definition: FeatureCollectAthena.cxx:93
TrigRoiDescriptor.h
LVL1_ROI::getEmTauROIs
const emtaus_type & getEmTauROIs() const
Get all the em/tau RoIs in the event.
Definition: LVL1_ROI.h:65
AccessProxy.h
FeatureCollectAthena.h
TrigRoiDescriptorCollection.h