ATLAS Offline Software
Loading...
Searching...
No Matches
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
41 StatusCode sc = AthAlgTool::initialize();
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
78 ATH_CHECK(m_beamSpotKey.initialize());
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
97 StatusCode sc = AthAlgTool::finalize();
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;
110 ATH_CHECK(pixHandle.isValid());
111 pixelSpacePointsContainer = pixHandle.ptr();
112 }
113 const SpacePointContainer* sctSpacePointsContainer = nullptr;
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 }
169 if(!m_useBeamTilt) shiftSpacePoints(output, ctx);
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
177void 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
189void 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}
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
static Double_t sc
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
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)
const ServiceHandle< StoreGateSvc > & detStore() const
Describes the API of the Region of Ineterest geometry.
const_pointer_type ptr()
Dereference the pointer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandleKey< SpacePointContainer > m_sctSpacePointsContainerKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
ToolHandle< ITrigL2LayerNumberTool > m_layerNumberTool
void shiftSpacePoints(std::vector< TrigSiSpacePointBase > &, const EventContext &) const
void transformSpacePoints(std::vector< TrigSiSpacePointBase > &, const EventContext &) const
ToolHandle< IRegSelTool > m_regsel_pix
new region selector tools
TrigSpacePointConversionTool(const std::string &, const std::string &, const IInterface *)
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
SG::ReadHandleKey< SpacePointContainer > m_pixelSpacePointsContainerKey
int cost(std::vector< std::string > &files, node &n, const std::string &directory="", bool deleteref=false, bool relocate=false)
Definition hcg.cxx:922
Eigen::Matrix< double, 3, 1 > Vector3D