ATLAS Offline Software
Loading...
Searching...
No Matches
JetROIRetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <string>
8
9#include "CLHEP/Units/SystemOfUnits.h"
10
12
15
16namespace JiveXML {
17
18 //--------------------------------------------------------------------------
19
20 JetROIRetriever::JetROIRetriever(const std::string& type, const std::string& name, const IInterface* parent):
21 AthAlgTool(type, name, parent),
22 m_typeName("JetROI")
23 {
24
25 declareInterface<IDataRetriever>(this);
26 declareProperty("readJEM", m_readJEM=false,"If 'true' reads low-level ROI data from L1Calo hardware. False by default");
27 // this could be used to mask the lower 4 of the possible 8 multiplicities
28 // to be implemented if necessary
29 declareProperty("maskLowerThresholds", m_maskLowerThresholds=false);
30 }
31
32 //--------------------------------------------------------------------------
33
34 StatusCode JetROIRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
35
36 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " retrieving" <<
37 ( m_readJEM ? " from JEMRoIs (ACR) " : " JetROI (LVL1_ROI) ") << endmsg;
38
41 DataVect energy;
42 DataVect roiWord;
43 DataVect thrPattern;
44
45 if (!m_readJEM){ // 'normal' mode: Use Offline EmTauROI object
46
47 const LVL1_ROI * roi;
48
49 // L1JetObject -not- available
50 m_sgKey = "LVL1_ROI";
51 if ( evtStore()->retrieve(roi,m_sgKey).isFailure() ) {
52 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No LVL1_ROI found in SG for Level-1 JetROI" << endmsg;
53 return StatusCode::SUCCESS;
54 }
55
56 // Access as in: PhysicsAnalysis/AnalysisCommon/AnalysisTest/ReadTrigg
57 // Tested with: AODTriggerRead_topOptions.py
58
59 LVL1_ROI::jets_type::const_iterator itJET = (roi->getJetROIs()).begin();
60 LVL1_ROI::jets_type::const_iterator itJETe = (roi->getJetROIs()).end();
61
62 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "JetROIs from LVL1_ROI retrieved from StoreGate with size: "<< (roi->getJetROIs()).size() <<endmsg;
63
64 for (; itJET != itJETe; ++itJET)
65 {
66 phi.push_back(DataType( itJET->getPhi()));
67 eta.push_back(DataType( itJET->getEta()));
68
69// info from Alan Watson: pT is getET8x8();
70// energy.push_back(DataType( itJET->pt()/1000. ));
72 energy.push_back(DataType( itJET->getET4x4()/1000. ));
73
74 roiWord.push_back(DataType( itJET->getROIWord()));
75 thrPattern.push_back(DataType( itJET->getThrPattern()));
76 }
77
78 }else{ // readJEM mode: decode bits from JEM into eta,phi, for ACR data from SFI
79
80 const DataVector<LVL1::JEMRoI>* jemRoICollection = 0;
81 LVL1::JEPRoIDecoder decoder;
82 // L1JetObject -not- available
83 m_sgKey = "JEMRoIs";
84 if ( evtStore()->retrieve(jemRoICollection, m_sgKey).isFailure() ) {
85 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No DataVector<LVL1::JEMRoI> found with key JEMRoIs" << endmsg;
86 return StatusCode::SUCCESS;
87 }
88 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "DataVector<LVL1::JEMRoI> retrieved from StoreGate with size: "<< jemRoICollection->size() <<endmsg;
89
90 DataVector<LVL1::JEMRoI>::const_iterator roi_it = jemRoICollection->begin();
91 DataVector<LVL1::JEMRoI>::const_iterator roi_end = jemRoICollection->end();
92
93 for(;roi_it!=roi_end;++roi_it) {
94 const LVL1::JEMRoI* roi = (*roi_it);
95
96 // different coordinates in phi, correct for this:
97 auto fixphi = [] (double phi)
98 {
99 if (phi > M_PI) return phi - 2*M_PI;
100 return phi;
101 };
102
103 const LVL1::CoordinateRange coord(decoder.coordinate(roi->roiWord()));
104 const double roiEta = coord.eta();
105 const double roiPhi = fixphi (coord.phi());
106
107 phi.push_back(DataType( roiPhi ));
108 eta.push_back(DataType( roiEta ));
109
110 // info from Alan Watson: energy would need to be decoded
111 // with jet elements. This will only be implemented if necessary
112 // jpt 19Mar09
113 energy.push_back(DataType( 1 ) ); //placeholder
114
115 roiWord.push_back(DataType( roi->roiWord() ));
116 thrPattern.push_back(DataType( roi->hits() ));
117 }
118 }//end if readJEM
119
120 DataMap myDataMap;
121 const auto nPhi = phi.size() ;
122 myDataMap["energy"] = energy;
123 myDataMap["phi"] = std::move(phi);
124 myDataMap["eta"] = std::move(eta);
125 myDataMap["energy"] = std::move(energy);
126 myDataMap["roiWord"] = std::move(roiWord);
127 myDataMap["thrPattern"] = std::move(thrPattern);
128
129 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << ": "<< nPhi
130 << " from: " << m_sgKey << endmsg;
131
132 //forward data to formating tool
133 return FormatTool->AddToEvent(dataTypeName(), m_sgKey, &myDataMap);
134 }
135}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
double coord
Type of coordination system.
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)
ServiceHandle< StoreGateSvc > & evtStore()
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual std::string dataTypeName() const
Return the name of the data type.
JetROIRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
const std::string m_typeName
The data type that is generated by this retriever.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
CoordinateRange class declaration.
uint32_t roiWord() const
Return packed RoI word.
int hits() const
Return Jet hit map (8 bits Main or 4 bits Forward)
Definition JEMRoI.cxx:64
A level 1 calorimeter trigger conversion service: returns the Coordinate represented by a RoI word.
Top level AOD object storing LVL1 RoIs.
Definition LVL1_ROI.h:43
const jets_type & getJetROIs() const
Get all the jet RoIs in the event.
Definition LVL1_ROI.h:67
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58