ATLAS Offline Software
TrigSpacePointConversionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
14 
16 
18 
20 
21 
22 
24  const std::string& n,
25  const IInterface* p ) :
26  AthAlgTool(t,n,p)
27 {
28  declareInterface< ITrigSpacePointConversionTool >( this );
29 
30  declareProperty( "DoPhiFiltering", m_filter_phi = true );
31  declareProperty( "UseBeamTilt", m_useBeamTilt = true );
32  declareProperty( "UseNewLayerScheme", m_useNewScheme = false );
33  declareProperty( "PixelSP_ContainerName", m_pixelSpacePointsContainerKey = std::string("PixelTrigSpacePoints"));
34  declareProperty( "SCT_SP_ContainerName", m_sctSpacePointsContainerKey = "SCT_TrigSpacePoints" );
35  declareProperty( "UsePixelSpacePoints", m_usePixelSpacePoints = true );
36  declareProperty( "UseSctSpacePoints", m_useSctSpacePoints = true );
37 }
38 
40 
42 
43  ATH_MSG_INFO("In initialize...");
44 
45  // sc = serviceLocator()->service( m_regionSelectorName, m_regionSelector);
46  // if ( sc.isFailure() ) {
47  // ATH_MSG_FATAL("Unable to retrieve RegionSelector Service " << m_regionSelectorName);
48  // return sc;
49  // }
50 
51  ATH_CHECK(m_regsel_pix.retrieve());
52  ATH_CHECK(m_regsel_sct.retrieve());
53 
54  sc=m_layerNumberTool.retrieve();
55  if(sc.isFailure()) {
56  ATH_MSG_ERROR("Could not retrieve "<<m_layerNumberTool);
57  return sc;
58  }
59 
60  sc = detStore()->retrieve(m_atlasId, "AtlasID");
61  if (sc.isFailure()) {
62  ATH_MSG_FATAL("Could not get ATLAS ID helper");
63  return sc;
64  }
65 
66  sc = detStore()->retrieve(m_pixelId, "PixelID");
67  if (sc.isFailure()) {
68  ATH_MSG_FATAL("Could not get Pixel ID helper");
69  return sc;
70  }
71 
72  sc = detStore()->retrieve(m_sctId, "SCT_ID");
73  if (sc.isFailure()) {
74  ATH_MSG_FATAL("Could not get SCT ID helper");
75  return sc;
76  }
77 
79 
81  ATH_MSG_FATAL("Both usePixelSpacePoints and useSctSpacePoints set to False. At least one needs to be True");
82  return StatusCode::FAILURE;
83  }
84  if (!m_useSctSpacePoints) ATH_MSG_INFO("Only converting Pixel spacepoints => PPP seeds only");
85  if (!m_usePixelSpacePoints) ATH_MSG_INFO("Only converting SCT spacepoints => SSS seeds only");
86  if (m_usePixelSpacePoints && m_useSctSpacePoints) ATH_MSG_INFO("Converting SCT and Pixel spacepoints");
89 
90  ATH_MSG_INFO("TrigSpacePointConversionTool initialized ");
91 
92  return sc;
93 }
94 
96 
98  return sc;
99 }
100 
101 
103  std::vector<TrigSiSpacePointBase>& output, int& nPix, int& nSct, const EventContext& ctx, std::map<Identifier, std::vector<long int> > *clustermap) const {
104 
105  output.clear();
106 
107  const SpacePointContainer* pixelSpacePointsContainer = nullptr;
108  if (m_usePixelSpacePoints) {
110  ATH_CHECK(pixHandle.isValid());
111  pixelSpacePointsContainer = pixHandle.ptr();
112  }
113  const SpacePointContainer* sctSpacePointsContainer = nullptr;
114  if (m_useSctSpacePoints) {
116  ATH_CHECK(sctHandle.isValid());
117  sctSpacePointsContainer = sctHandle.ptr();
118  }
119 
120  std::vector<IdentifierHash> listOfPixIds;
121  std::vector<IdentifierHash> listOfSctIds;
122 
123  m_regsel_pix->lookup(ctx)->HashIDList( internalRoI, listOfPixIds );
124  m_regsel_sct->lookup(ctx)->HashIDList( internalRoI, listOfSctIds );
125 
126 
127  int offsets[3];
128 
129  offsets[0] = m_layerNumberTool->offsetEndcapPixels();
130  offsets[1] = m_layerNumberTool->offsetBarrelSCT();
131  offsets[2] = m_layerNumberTool->offsetEndcapSCT();
132 
134 
135  //filter spacepoints to reject those beyound internalRoI boundaries
136 
137  nPix = 0;
138  nSct = 0;
139  if ( clustermap!=nullptr ) {
140 
141  ATH_MSG_DEBUG("LRT Mode: clustermap supplied and being used to remove spacepoints from clusters already on tracks");
142  // In LRT mode a cluster map is supplied to enable removal of clusters on tracks.
143  FTF::RoI_Filter filter(output, lc, &internalRoI, m_filter_phi, clustermap);
145 
146  if(m_useNewScheme) {
147  if (m_usePixelSpacePoints) nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds, m_layerNumberTool->pixelLayers());
148  if (m_useSctSpacePoints) nSct=selector.select(*sctSpacePointsContainer,listOfSctIds, m_layerNumberTool->sctLayers());
149  }
150  else {
151  if (m_usePixelSpacePoints) nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds);
152  if (m_useSctSpacePoints) nSct=selector.select(*sctSpacePointsContainer,listOfSctIds);
153  }
154 
155 
156  } else {
157  FTF::RoI_Filter filter(output, lc, &internalRoI, m_filter_phi);
159 
160  if(m_useNewScheme) {
161  if (m_usePixelSpacePoints) nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds, m_layerNumberTool->pixelLayers());
162  if (m_useSctSpacePoints) nSct=selector.select(*sctSpacePointsContainer,listOfSctIds, m_layerNumberTool->sctLayers());
163  }
164  else {
165  if (m_usePixelSpacePoints) nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds);
166  if (m_useSctSpacePoints) nSct=selector.select(*sctSpacePointsContainer,listOfSctIds);
167  }
168  }
170  else transformSpacePoints(output, ctx);
171 
172  ATH_MSG_DEBUG("Returning "<<nPix<< " Pixel Spacepoints and "<<nSct<< " SCT SpacePoints");
173  return StatusCode::SUCCESS;
174 }
175 
176 
177 void TrigSpacePointConversionTool::shiftSpacePoints(std::vector<TrigSiSpacePointBase>& output, const EventContext& ctx) const {
178 
180  const Amg::Vector3D &vertex = beamSpotHandle->beamPos();
181  double shift_x = vertex.x() - beamSpotHandle->beamTilt(0)*vertex.z();
182  double shift_y = vertex.y() - beamSpotHandle->beamTilt(1)*vertex.z();
183 
184  std::for_each(output.begin(), output.end(), FTF::SpacePointShifter(shift_x, shift_y));
185 
186 }
187 
188 
189 void TrigSpacePointConversionTool::transformSpacePoints(std::vector<TrigSiSpacePointBase>& output, const EventContext& ctx) const {
190 
192  const Amg::Vector3D &origin = beamSpotHandle->beamPos();
193  double tx = tan(beamSpotHandle->beamTilt(0));
194  double ty = tan(beamSpotHandle->beamTilt(1));
195 
196  double phi = atan2(ty,tx);
197  double theta = acos(1.0/sqrt(1.0+tx*tx+ty*ty));
198  double sint = sin(theta);
199  double cost = cos(theta);
200  double sinp = sin(phi);
201  double cosp = cos(phi);
202 
203  std::array<float, 4> xtrf{}, ytrf{}, ztrf{};
204 
205  xtrf[0] = float(origin.x());
206  xtrf[1] = float(cost*cosp*cosp+sinp*sinp);
207  xtrf[2] = float(cost*sinp*cosp-sinp*cosp);
208  xtrf[3] =-float(sint*cosp);
209 
210  ytrf[0] = float(origin.y());
211  ytrf[1] = float(cost*cosp*sinp-sinp*cosp);
212  ytrf[2] = float(cost*sinp*sinp+cosp*cosp);
213  ytrf[3] =-float(sint*sinp);
214 
215  ztrf[0] = float(origin.z());
216  ztrf[1] = float(sint*cosp);
217  ztrf[2] = float(sint*sinp);
218  ztrf[3] = float(cost);
219 
220  std::for_each(output.begin(), output.end(), FTF::SpacePointTransform(xtrf, ytrf, ztrf));
221 
222 }
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
IRegSelTool.h
cost
int cost(std::vector< std::string > &files, node &n, const std::string &directory="", bool deleteref=false, bool relocate=false)
Definition: hcg.cxx:921
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
TrigSpacePointConversionTool::transformSpacePoints
void transformSpacePoints(std::vector< TrigSiSpacePointBase > &, const EventContext &) const
Definition: TrigSpacePointConversionTool.cxx:189
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TrigSpacePointConversionTool::m_sctSpacePointsContainerKey
SG::ReadHandleKey< SpacePointContainer > m_sctSpacePointsContainerKey
Definition: TrigSpacePointConversionTool.h:54
SG::ReadHandle< SpacePointContainer >
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
initialize
void initialize()
Definition: run_EoverP.cxx:894
TrigSpacePointConversionTool::shiftSpacePoints
void shiftSpacePoints(std::vector< TrigSiSpacePointBase > &, const EventContext &) const
Definition: TrigSpacePointConversionTool.cxx:177
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
ITrigL2LayerNumberTool.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
python.LumiCalcHtml.lc
lc
Definition: LumiCalcHtml.py:579
TrigSpacePointConversionTool::m_pixelSpacePointsContainerKey
SG::ReadHandleKey< SpacePointContainer > m_pixelSpacePointsContainerKey
Definition: TrigSpacePointConversionTool.h:55
SpacePointContainer.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
TrigSpacePointConversionTool::TrigSpacePointConversionTool
TrigSpacePointConversionTool(const std::string &, const std::string &, const IInterface *)
Definition: TrigSpacePointConversionTool.cxx:23
FTF::RoI_Filter
Definition: SpacePointConversionUtils.h:125
FTF::LayerCalculator
Definition: SpacePointConversionUtils.h:29
covarianceTool.filter
filter
Definition: covarianceTool.py:514
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
SpacePointCollection.h
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TrigSpacePointConversionTool::m_pixelId
const PixelID * m_pixelId
Definition: TrigSpacePointConversionTool.h:49
SpacePointConversionUtils.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigSiSpacePointBase.h
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SpacePoint.h
IRoiDescriptor
Describes the API of the Region of Ineterest geometry.
Definition: IRoiDescriptor.h:23
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrigSpacePointConversionTool::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition: TrigSpacePointConversionTool.h:51
TrigSpacePointConversionTool::m_filter_phi
bool m_filter_phi
Definition: TrigSpacePointConversionTool.h:57
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FTF::SpacePointShifter
Definition: SpacePointConversionUtils.h:200
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrigSpacePointConversionTool::m_layerNumberTool
ToolHandle< ITrigL2LayerNumberTool > m_layerNumberTool
Definition: TrigSpacePointConversionTool.h:45
merge.output
output
Definition: merge.py:17
TrigSpacePointConversionTool::m_regsel_pix
ToolHandle< IRegSelTool > m_regsel_pix
new region selector tools
Definition: TrigSpacePointConversionTool.h:67
FTF::SpacePointTransform
Definition: SpacePointConversionUtils.h:217
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
SG::ReadHandle::ptr
const_pointer_type ptr()
Dereference the pointer.
TrigSpacePointConversionTool::m_regsel_sct
ToolHandle< IRegSelTool > m_regsel_sct
Definition: TrigSpacePointConversionTool.h:68
TrigSpacePointConversionTool::m_atlasId
const AtlasDetectorID * m_atlasId
Definition: TrigSpacePointConversionTool.h:47
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
TrigSpacePointConversionTool::getSpacePoints
virtual StatusCode getSpacePoints(const IRoiDescriptor &, std::vector< TrigSiSpacePointBase > &, int &, int &, const EventContext &ctx, std::map< Identifier, std::vector< long int > > *clustermap=nullptr) const override final
Definition: TrigSpacePointConversionTool.cxx:102
python.selector.AtlRunQuerySelectorLhcOlc.selector
selector
Definition: AtlRunQuerySelectorLhcOlc.py:611
FTF::SpacePointSelector
Definition: SpacePointConversionUtils.h:161
TrigSpacePointConversionTool::m_usePixelSpacePoints
bool m_usePixelSpacePoints
Definition: TrigSpacePointConversionTool.h:60
TrigSpacePointConversionTool::initialize
StatusCode initialize() override
Definition: TrigSpacePointConversionTool.cxx:39
SpacePointContainer
Definition: Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePointContainer.h:29
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
TrigSpacePointConversionTool::m_useBeamTilt
bool m_useBeamTilt
Definition: TrigSpacePointConversionTool.h:58
AthAlgTool
Definition: AthAlgTool.h:26
TrigSpacePointConversionTool::m_useNewScheme
bool m_useNewScheme
Definition: TrigSpacePointConversionTool.h:59
TrigSpacePointConversionTool::finalize
StatusCode finalize() override
Definition: TrigSpacePointConversionTool.cxx:95
TrigSpacePointConversionTool::m_useSctSpacePoints
bool m_useSctSpacePoints
Definition: TrigSpacePointConversionTool.h:61
TileDCSDataPlotter.tx
tx
Definition: TileDCSDataPlotter.py:878
readCCLHist.float
float
Definition: readCCLHist.py:83
TrigSpacePointConversionTool.h
TrigSpacePointConversionTool::m_sctId
const SCT_ID * m_sctId
Definition: TrigSpacePointConversionTool.h:48
Identifier
Definition: IdentifierFieldParser.cxx:14