ATLAS Offline Software
EmTauROIRetriever.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 
13 #include "TrigT1CaloEvent/CPMRoI.h"
15 
16 namespace JiveXML {
17 
18  //--------------------------------------------------------------------------
19 
20  EmTauROIRetriever::EmTauROIRetriever(const std::string& type, const std::string& name, const IInterface* parent):
22  m_typeName("EmTauROI")
23  {
24 
25  declareInterface<IDataRetriever>(this);
26  declareProperty("readCPM", m_readCPM=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 EmTauROIRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
35 
36  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " retrieving" <<
37  ( m_readCPM ? " from CPMRoIs (ACR) " : " EmTauROI (LVL1_ROI) ") << endmsg;
38 
39  DataVect phi;
40  DataVect eta;
42  DataVect energyEM;
43  DataVect energyTAU;
46 
47  if (!m_readCPM){ // 'normal' mode: Use Offline EmTauROI object
48 
49  const LVL1_ROI * roi;
50 
51  // L1JetObject -not- available
52  m_sgKey = "LVL1_ROI";
53  if ( evtStore()->retrieve(roi,m_sgKey).isFailure() ) {
54  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No LVL1_ROI found in SG for Level-1 JetROI" << endmsg;
55  return StatusCode::SUCCESS;
56  }
57 
58  // Access as in: PhysicsAnalysis/AnalysisCommon/AnalysisTest/ReadTrigger
59  // Tested with: AODTriggerRead_topOptions.py
60  // class read:
61  // PhysicsAnalysis/AnalysisTrigger/AnalysisTriggerEvent/EmTau_ROI.h
62  LVL1_ROI::emtaus_type::const_iterator itEM = (roi->getEmTauROIs()).begin();
63  LVL1_ROI::emtaus_type::const_iterator itEMe = (roi->getEmTauROIs()).end();
64 
65  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "JetROIs from LVL1_ROI retrieved from StoreGate with size: "<< (roi->getJetROIs()).size() <<endmsg;
66 
67  for (; itEM != itEMe; ++itEM)
68  {
69  phi.push_back(DataType( itEM->getPhi()));
70  eta.push_back(DataType( itEM->getEta()));
76  energy.push_back(DataType( itEM->getTauClus() /CLHEP::GeV ));
77  // Seperate EM and TAU, useful to experts:
78  energyEM.push_back(DataType( itEM->getEMClus() / CLHEP::GeV ));
79  energyTAU.push_back(DataType( itEM->getTauClus() /CLHEP::GeV ));
80  roiWord.push_back(DataType( itEM->getROIWord()));
81  thrPattern.push_back(DataType( itEM->getThrPattern()));
82  }
83 
84  }else{ // readCPM mode: decode bits from CPM into eta,phi, for ACR data from SFI
85 
86  const DataVector<LVL1::CPMRoI>* cpmRoICollection = 0;
88  // L1JetObject -not- available
89  m_sgKey = "CPMRoIs";
90  if ( evtStore()->retrieve(cpmRoICollection, m_sgKey).isFailure() ) {
91  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No DataVector<LVL1::CPMRoI> found with key CPMRoIs" << endmsg;
92  return StatusCode::SUCCESS;
93  }
94  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "DataVector<LVL1::CPMRoI> retrieved from StoreGate with size: "<< cpmRoICollection->size() <<endmsg;
95 
96  DataVector<LVL1::CPMRoI>::const_iterator roi_it = cpmRoICollection->begin();
97  DataVector<LVL1::CPMRoI>::const_iterator roi_end = cpmRoICollection->end();
98 
99  for(;roi_it!=roi_end;++roi_it) {
100  const LVL1::CPMRoI* roi = (*roi_it);
101 
102  // different coordinates in phi, correct for this:
103  auto fixphi = [] (double phi)
104  {
105  if (phi > M_PI) return phi - 2*M_PI;
106  return phi;
107  };
108 
109  const LVL1::CoordinateRange coord(decoder.coordinate(roi->roiWord()));
110  const double roiEta = coord.eta();
111  const double roiPhi = fixphi (coord.phi());
112 
113  phi.push_back(DataType( roiPhi ));
114  eta.push_back(DataType( roiEta ));
115 
116  // info from Alan Watson: energy would need to be decoded
117  // with jet elements. This will only be implemented if necessary
118  // jpt 19Mar09
119  energy.push_back(DataType( 1 ) ); //placeholder
120  energyEM.push_back(DataType( 1 ) ); //placeholder
121  energyTAU.push_back(DataType( 1 ) ); //placeholder
122 
123  roiWord.push_back(DataType( roi->roiWord() ));
124  thrPattern.push_back(DataType( roi->hits() ));
125  }
126  }//end if readCPM
127 
128  DataMap myDataMap;
129  myDataMap["energy"] = energy;
130  myDataMap["phi"] = phi;
131  myDataMap["eta"] = eta;
132  myDataMap["energy"] = energy;
133  myDataMap["energyEM"] = energyEM;
134  myDataMap["energyTAU"] = energyTAU;
135  myDataMap["roiWord"] = roiWord;
136  myDataMap["thrPattern"] = thrPattern;
137 
138  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << ": "<< phi.size()
139  << " from: " << m_sgKey << endmsg;
140 
141  //forward data to formating tool
142  return FormatTool->AddToEvent(dataTypeName(), m_sgKey, &myDataMap);
143  }
144 }
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
HLTSeedingRoIToolDefs::roiPhi
constexpr float roiPhi(const AnyRoIPointer &roi)
Definition: HLTSeedingRoIToolDefs.h:167
JiveXML::EmTauROIRetriever::m_maskLowerThresholds
bool m_maskLowerThresholds
Definition: EmTauROIRetriever.h:51
python.LArCondContChannels.decoder
decoder
def channelSelection(self, channelList, groupType): if groupType == self.SingleGroup: pass elif group...
Definition: LArCondContChannels.py:618
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JiveXML::EmTauROIRetriever::EmTauROIRetriever
EmTauROIRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: EmTauROIRetriever.cxx:20
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
JiveXML::EmTauROIRetriever::m_readCPM
bool m_readCPM
Definition: EmTauROIRetriever.h:50
CPRoIDecoder.h
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
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
JiveXML::EmTauROIRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: EmTauROIRetriever.cxx:34
xAOD::roiEta
setTeId setLumiBlock setRoiId setRoiSubsystem setRoiNumber roiEta
Definition: L2StandAloneMuon_v2.cxx:343
LVL1::CPMRoI::hits
int hits() const
Return hit thresholds map.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:101
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
JiveXML::EmTauROIRetriever::m_sgKey
std::string m_sgKey
Definition: EmTauROIRetriever.h:52
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
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
LVL1::CPMRoI
CPM RoI data.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:20
test_pyathena.parent
parent
Definition: test_pyathena.py:15
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
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:22
LVL1::CPMRoI::roiWord
uint32_t roiWord() const
Return packed RoI word.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMRoI.h:111
JiveXML::EmTauROIRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: EmTauROIRetriever.h:43
CPMRoI.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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.
LVL1::CPRoIDecoder
A level 1 calorimeter trigger conversion service: returns the Coordinate represented by a RoI word.
Definition: CPRoIDecoder.h:37
xAOD::thrPattern
thrPattern
Definition: EmTauRoI_v2.cxx:60
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
EmTauROIRetriever.h
LVL1_ROI::getEmTauROIs
const emtaus_type & getEmTauROIs() const
Get all the em/tau RoIs in the event.
Definition: LVL1_ROI.h:65
AthAlgTool
Definition: AthAlgTool.h:26
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.