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");
88 
89  ATH_MSG_INFO("TrigSpacePointConversionTool initialized ");
90 
91  return sc;
92 }
93 
95 
97  return sc;
98 }
99 
100 
102  std::vector<TrigSiSpacePointBase>& output, int& nPix, int& nSct, const EventContext& ctx, std::map<Identifier, std::vector<long int> > *clustermap) const {
103 
104  output.clear();
105 
106  const SpacePointContainer* pixelSpacePointsContainer = nullptr;
107  if (m_usePixelSpacePoints) {
109  ATH_CHECK(pixHandle.isValid());
110  pixelSpacePointsContainer = pixHandle.ptr();
111  }
112  const SpacePointContainer* sctSpacePointsContainer = nullptr;
113  if (m_useSctSpacePoints) {
115  ATH_CHECK(sctHandle.isValid());
116  sctSpacePointsContainer = sctHandle.ptr();
117  }
118 
119  std::vector<IdentifierHash> listOfPixIds;
120  std::vector<IdentifierHash> listOfSctIds;
121 
122  // m_regionSelector->DetHashIDList(PIXEL, internalRoI, listOfPixIds);
123  // m_regionSelector->DetHashIDList(SCT, internalRoI, listOfSctIds);
124 
125  m_regsel_pix->HashIDList( internalRoI, listOfPixIds );
126  m_regsel_sct->HashIDList( internalRoI, listOfSctIds );
127 
128 
129  int offsets[3];
130 
131  offsets[0] = m_layerNumberTool->offsetEndcapPixels();
132  offsets[1] = m_layerNumberTool->offsetBarrelSCT();
133  offsets[2] = m_layerNumberTool->offsetEndcapSCT();
134 
136 
137  //filter spacepoints to reject those beyound internalRoI boundaries
138 
139  nPix = 0;
140  nSct = 0;
141  if ( clustermap!=nullptr ) {
142 
143  ATH_MSG_DEBUG("LRT Mode: clustermap supplied and being used to remove spacepoints from clusters already on tracks");
144  // In LRT mode a cluster map is supplied to enable removal of clusters on tracks.
145  FTF::RoI_Filter filter(output, lc, &internalRoI, m_filter_phi, clustermap);
147 
148  if(m_useNewScheme) {
149  if (m_usePixelSpacePoints) nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds, m_layerNumberTool->pixelLayers());
150  if (m_useSctSpacePoints) nSct=selector.select(*sctSpacePointsContainer,listOfSctIds, m_layerNumberTool->sctLayers());
151  }
152  else {
153  if (m_usePixelSpacePoints) nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds);
154  if (m_useSctSpacePoints) nSct=selector.select(*sctSpacePointsContainer,listOfSctIds);
155  }
156 
157 
158  } else {
159  FTF::RoI_Filter filter(output, lc, &internalRoI, m_filter_phi);
161 
162  if(m_useNewScheme) {
163  if (m_usePixelSpacePoints) nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds, m_layerNumberTool->pixelLayers());
164  if (m_useSctSpacePoints) nSct=selector.select(*sctSpacePointsContainer,listOfSctIds, m_layerNumberTool->sctLayers());
165  }
166  else {
167  if (m_usePixelSpacePoints) nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds);
168  if (m_useSctSpacePoints) nSct=selector.select(*sctSpacePointsContainer,listOfSctIds);
169  }
170  }
172  else transformSpacePoints(output, ctx);
173 
174  ATH_MSG_DEBUG("Returning "<<nPix<< " Pixel Spacepoints and "<<nSct<< " SCT SpacePoints");
175  return StatusCode::SUCCESS;
176 }
177 
178 
179 void TrigSpacePointConversionTool::shiftSpacePoints(std::vector<TrigSiSpacePointBase>& output, const EventContext& ctx) const {
180 
182  const Amg::Vector3D &vertex = beamSpotHandle->beamPos();
183  double shift_x = vertex.x() - beamSpotHandle->beamTilt(0)*vertex.z();
184  double shift_y = vertex.y() - beamSpotHandle->beamTilt(1)*vertex.z();
185 
186  std::for_each(output.begin(), output.end(), FTF::SpacePointShifter(shift_x, shift_y));
187 
188 }
189 
190 
191 void TrigSpacePointConversionTool::transformSpacePoints(std::vector<TrigSiSpacePointBase>& output, const EventContext& ctx) const {
192 
194  const Amg::Vector3D &origin = beamSpotHandle->beamPos();
195  double tx = tan(beamSpotHandle->beamTilt(0));
196  double ty = tan(beamSpotHandle->beamTilt(1));
197 
198  double phi = atan2(ty,tx);
199  double theta = acos(1.0/sqrt(1.0+tx*tx+ty*ty));
200  double sint = sin(theta);
201  double cost = cos(theta);
202  double sinp = sin(phi);
203  double cosp = cos(phi);
204 
205  std::array<float, 4> xtrf{}, ytrf{}, ztrf{};
206 
207  xtrf[0] = float(origin.x());
208  xtrf[1] = float(cost*cosp*cosp+sinp*sinp);
209  xtrf[2] = float(cost*sinp*cosp-sinp*cosp);
210  xtrf[3] =-float(sint*cosp);
211 
212  ytrf[0] = float(origin.y());
213  ytrf[1] = float(cost*cosp*sinp-sinp*cosp);
214  ytrf[2] = float(cost*sinp*sinp+cosp*cosp);
215  ytrf[3] =-float(sint*sinp);
216 
217  ztrf[0] = float(origin.z());
218  ztrf[1] = float(sint*cosp);
219  ztrf[2] = float(sint*sinp);
220  ztrf[3] = float(cost);
221 
222  std::for_each(output.begin(), output.end(), FTF::SpacePointTransform(xtrf, ytrf, ztrf));
223 
224 }
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:53
TrigSpacePointConversionTool::transformSpacePoints
void transformSpacePoints(std::vector< TrigSiSpacePointBase > &, const EventContext &) const
Definition: TrigSpacePointConversionTool.cxx:191
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...
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
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:179
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:71
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
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
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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:101
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:94
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