ATLAS Offline Software
JetROIRetriever.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <string>
8 
9 #include "CLHEP/Units/SystemOfUnits.h"
10 
12 
14 #include "TrigT1CaloEvent/JEMRoI.h"
15 
16 namespace JiveXML {
17 
18  //--------------------------------------------------------------------------
19 
20  JetROIRetriever::JetROIRetriever(const std::string& type, const std::string& name, const IInterface* 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 
39  DataVect phi;
40  DataVect eta;
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;
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  myDataMap["energy"] = energy;
122  myDataMap["phi"] = phi;
123  myDataMap["eta"] = eta;
124  myDataMap["energy"] = energy;
125  myDataMap["roiWord"] = roiWord;
126  myDataMap["thrPattern"] = thrPattern;
127 
128  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << ": "<< phi.size()
129  << " from: " << m_sgKey << endmsg;
130 
131  //forward data to formating tool
132  return FormatTool->AddToEvent(dataTypeName(), m_sgKey, &myDataMap);
133  }
134 }
HLTSeedingRoIToolDefs::roiPhi
constexpr float roiPhi(const AnyRoIPointer &roi)
Definition: HLTSeedingRoIToolDefs.h:167
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
python.LArCondContChannels.decoder
decoder
def channelSelection(self, channelList, groupType): if groupType == self.SingleGroup: pass elif group...
Definition: LArCondContChannels.py:618
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LVL1::JEPRoIDecoder
A level 1 calorimeter trigger conversion service: returns the Coordinate represented by a RoI word.
Definition: JEPRoIDecoder.h:33
JetROIRetriever.h
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
JiveXML::JetROIRetriever::JetROIRetriever
JetROIRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: JetROIRetriever.cxx:20
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
M_PI
#define M_PI
Definition: ActiveFraction.h:11
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
xAOD::roiEta
setTeId setLumiBlock setRoiId setRoiSubsystem setRoiNumber roiEta
Definition: L2StandAloneMuon_v2.cxx:343
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
JiveXML::JetROIRetriever::m_maskLowerThresholds
bool m_maskLowerThresholds
Definition: JetROIRetriever.h:52
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
xAOD::roiWord
roiWord
Definition: TrigMissingET_v1.cxx:36
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
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
LVL1::CoordinateRange
CoordinateRange class declaration.
Definition: CoordinateRange.h:36
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
LVL1::JEMRoI::hits
int hits() const
Return Jet hit map (8 bits Main or 4 bits Forward)
Definition: JEMRoI.cxx:64
JiveXML::JetROIRetriever::m_sgKey
std::string m_sgKey
Definition: JetROIRetriever.h:53
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LVL1_ROI.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
DataVector< LVL1::JEMRoI >
JEPRoIDecoder.h
LVL1_ROI
Top level AOD object storing LVL1 RoIs.
Definition: LVL1_ROI.h:43
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
JEMRoI.h
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::thrPattern
thrPattern
Definition: EmTauRoI_v2.cxx:60
JiveXML::JetROIRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: JetROIRetriever.h:44
JiveXML::JetROIRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: JetROIRetriever.cxx:34
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
JiveXML::JetROIRetriever::m_readJEM
bool m_readJEM
Definition: JetROIRetriever.h:51
LVL1::JEMRoI
JEM RoI data.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:19
AthAlgTool
Definition: AthAlgTool.h:26
LVL1::JEMRoI::roiWord
uint32_t roiWord() const
Return packed RoI word.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:117
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.