ATLAS Offline Software
Loading...
Searching...
No Matches
TrackAnalysisStore.cxx
Go to the documentation of this file.
1
12
13#include "TrackAnalysisStore.h"
14
17
18#include "TrackParticleTraits.h"
19#include "TruthParticleTraits.h"
20#include "ElectronTraits.h"
21#include "MuonTraits.h"
22#include "TauJetTraits.h"
23#include "TrackView.h"
24
27
28#include "xAODVertexTraits.h"
29
30#include "VertexView.h"
31
32#include <algorithm>
33
34
35
39IDTPM2::TrackAnalysisStore::TrackAnalysisStore( const std::string& anaTag, const EventContext& context ) :
40 AthMessaging( "TrackAnalysisStore"+anaTag ),
41 m_context(context),
42 m_tdt(0),
43 m_roiIndex(0),
45{ }
46
48 const ToolHandle<Trig::TrigDecisionTool>* tdt, const EventContext& context ) :
49 AthMessaging( "TrackAnalysisStore"+anaTag ),
50 m_context(context),
51 m_tdt(tdt),
52 m_roiIndex(0),
54{ }
55
56
66StatusCode IDTPM2::TrackAnalysisStore::initialize() { return StatusCode::SUCCESS; }
67
68
69
71
75
76
85
86
87
91void IDTPM2::TrackAnalysisStore::fillView( const std::string& key, const ElementLink<TrigRoiDescriptorCollection>& roi_link, view_store_t& trackView ) {
92
94 std::pair<xAOD::TrackParticleContainer::const_iterator, xAOD::TrackParticleContainer::const_iterator> itrpair;
95
96 if ( fillRoi<xAOD::TrackParticleContainer>( itrpair, key, roi_link ).isSuccess() ) {
97 fillv( trackView, itrpair.first, itrpair.second );
98 }
99 else {
100 throw std::runtime_error( "iterator pair not retrieved FFS for key: "+key );
101 }
102
103}
104
105
109void IDTPM2::TrackAnalysisStore::fillView( const std::string& key, vtx_store_t& vertexView ) {
110 if ( fillView_internal<xAOD::VertexContainer, VertexView>( key, vertexView ) ) return;
111 if ( fillView_internal<xAOD::TruthVertexContainer, VertexView>( key, vertexView ) ) return;
112}
113
114
115
119void IDTPM2::TrackAnalysisStore::fillView( const std::string& key, const ElementLink<TrigRoiDescriptorCollection>& roi_link, vtx_store_t& vertexView ) {
120
122 std::pair<xAOD::VertexContainer::const_iterator, xAOD::VertexContainer::const_iterator> itrpair;
123
124 if ( fillRoi<xAOD::VertexContainer>( itrpair, key, roi_link ).isSuccess() ) {
125 fillv( vertexView, itrpair.first, itrpair.second );
126 }
127 else {
128 throw std::runtime_error( "iterator pair not retrieved FFS for key: "+key );
129 }
130
131}
132
133
134
135
136
140
143
144template<>
145bool IDTPM2::TrackAnalysisStore::isGoodOffline<xAOD::Electron>( const xAOD::Electron& elec, const std::string& quality, const std::string& ) {
146 // no additional selection - this can go into a specific selector probably ...
147 if ( quality.empty() ) return true;
148 return elec.passSelection(quality);
149}
150
151
152
153
156
157template<>
158bool IDTPM2::TrackAnalysisStore::isGoodOffline<xAOD::Muon>(const xAOD::Muon& muon, const std::string& quality, const std::string& ) {
159
160 if ( quality.empty() ) return true;
161
163 if ( muon.muonType() != xAOD::Muon::Combined ) return false;
164
165 bool good_muon = false;
166
169 if ( quality=="Tight" ) good_muon = (muon.quality()<=xAOD::Muon::Quality::Tight);
170 else if ( quality=="Medium" ) good_muon = (muon.quality()<=xAOD::Muon::Quality::Medium);
171 else if ( quality=="Loose" ) good_muon = (muon.quality()<=xAOD::Muon::Quality::Loose);
172 else if ( quality=="VeryLoose" ) good_muon = (muon.quality()<=xAOD::Muon::Quality::VeryLoose);
173 else good_muon = true;
174
176
177 return good_muon;
178}
179
180
181
183
184template<>
185bool IDTPM2::TrackAnalysisStore::isGoodOffline<xAOD::TauJet>( const xAOD::TauJet& tau, const std::string& quality, const std::string& prongs ) {
186
187 if ( quality.empty() && prongs.empty() ) return true;
188
189# ifndef XAODTAU_VERSIONS_TAUJET_V3_H
190 int Ntracks = tau.nTracks();
191# else
192 int Ntracks=0; tau.detail( xAOD::TauJetParameters::nChargedTracks, Ntracks );
193# endif
194
195 bool good_tau = false;
196
198 if ( quality == "Tight" ) good_tau = tau.isTau(xAOD::TauJetParameters::JetRNNSigTight);
199 else if ( quality == "Medium" ) good_tau = tau.isTau(xAOD::TauJetParameters::JetRNNSigMedium);
200 else if ( quality == "Loose" ) good_tau = tau.isTau(xAOD::TauJetParameters::JetRNNSigLoose);
201 else if ( quality == "JetRNNSigTight" ) good_tau = tau.isTau(xAOD::TauJetParameters::JetRNNSigTight); // so it doesn't confuse anyone
202 else if ( quality == "JetRNNSigMedium" ) good_tau = tau.isTau(xAOD::TauJetParameters::JetRNNSigMedium);
203 else if ( quality == "JetRNNSigLoose" ) good_tau = tau.isTau(xAOD::TauJetParameters::JetRNNSigLoose);
204 else good_tau = true;
205
206 // std::cout << "isGoodOffline: tau " << quality << "\t" << prongs << "\t(" << Ntracks << ") " << good_tau << std::endl;
207
212 if ( prongs.empty() ) return good_tau;
213 else if ( prongs=="1Prong" && Ntracks==1 ) return good_tau;
214 else if ( prongs=="2Prong" && Ntracks==2 ) return good_tau;
215 else if ( prongs=="3Prong" && Ntracks==3 ) return good_tau;
216
217 return false;
218
219}
220
221
223
226 if ( !m_beamkeys ) return;
227
229 if ( m_reftracks.empty() || !m_reftracks.front()->is<xAOD::TruthParticle>() ) return;
230
234
237 for ( size_t i=0 ; i<m_reftracks.size() ; i++ ) {
238
239 TruthView* tv = dynamic_cast<TruthView*>(m_reftracks[i].get());
240
241 if ( !tv ) throw std::runtime_error("not a TruthView");
242
243 const xAOD::TruthParticle* tp = tv->as<xAOD::TruthParticle>();
244
245 if ( std::fabs(tv->pt())<50 ) continue;
246
247 if ( !MC::isStable(tp) ) continue;
248
249 float charge = tp->charge();
250
252 if ( !tp->hasProdVtx() ) {
253 tv->add_z0(-999);
254 tv->add_d0(-999);
255 tv->add_phi(tp->phi());
256 continue;
257 }
258
261
262 double vx = tp->prodVtx()->x();
263 double vy = tp->prodVtx()->y();
264 double vz = tp->prodVtx()->z();
265
266 double bx = beamPosX(0);
267 double by = beamPosY(0);
268 double bz = beamPosZ(0);
269
270 double dx = vx - bx;
271 double dy = vy - by;
272 double dz = vz - bz;
273
274 double eta = tp->eta();
275 double phi = tp->phi();
276
277 double theta = 2*std::atan( std::exp( -eta ) );
278
279 double sinphi = std::sin(phi);
280 double cosphi = std::cos(phi);
281 double tantheta = std::tan(theta);
282
283 if ( charge==0 ) {
284
286
288 double z0 = dz - (dy*cosphi + dy*sinphi)/tantheta + bz;
289 double d0 = dy*cosphi - dx*sinphi;
290
291 tv->add_z0(z0);
292 tv->add_d0(d0);
293 tv->add_phi(tp->phi());
294
295 }
296 else {
297
299 // double z0_ = dz - (dy*cosphi + dy*sinphi)/tantheta + bz;
300 // double d0_ = dy*cosphi - dx*sinphi;
301
302 // helix approximation ...
303
304 int sign = ( charge<0 ? -1 : 1 );
305
306 const double B = 2;
307 const double c = 2.99792458;
308
309 double QR = -charge*std::fabs(tv->pt())*10/(B*c);
310
311 double nx = sign*sinphi;
312 double ny = -sign*cosphi;
313
314 double Cx = vx + QR*nx;
315 double Cy = vy + QR*ny;
316
317 double wx = Cx - beamPosX(0);
318 double wy = Cy - beamPosY(0);
319
320 double w = std::sqrt( wx*wx + wy*wy );
321
322 double d0 = w - std::fabs(QR);
323
324 double rvx = -QR*nx;
325 double rvy = -QR*ny;
326
327 double rpx = -std::fabs(QR)*wx/w;
328 double rpy = -std::fabs(QR)*wy/w;
329
330 double dphi = sign*std::atan2( rvx*rpy - rvy*rpx, rvx*rpx + rvy*rpy );
331
333 // double side = dx*wy - dy*wx;
334
335 double s = dphi*QR;
336
337 double z0 = dz - s/tantheta + bz;
338
339 double phi = tp->phi()-dphi;
340
341 tv->add_z0(z0);
342 tv->add_d0(d0);
343 tv->add_phi(phi);
344
345 }
346 }
347
348}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
double charge(const T &p)
Definition AtlasPID.h:1003
int sign(int a)
emacs: this is -*- c++ -*-
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
std::vector< ParentView > m_parents
std::vector< std::unique_ptr< VertexView > > vtx_store_t
const ToolHandle< Trig::TrigDecisionTool > * m_tdt
Actually, actually, we don;t even need this AT ALL, it serves no purpose since we can control everyth...
StatusCode fillRoi(std::pair< typename T::const_iterator, typename T::const_iterator > &itrpair, const std::string &key, const ElementLink< TrigRoiDescriptorCollection > &roi_link)
more rational generic Roi fill method
bool isGoodOffline(const T &, const std::string &, const std::string &="")=delete
to be over ridden by selection for actual EDM classes
bool fillView_internal(const std::string &key, std::vector< std::unique_ptr< U > > &outView)
templates for athena type track and vertex retrieval ...
TrackAnalysisStore(const std::string &anaTag, const EventContext &context)
Constructor.
void fillView(const std::string &key, view_store_t &trackView)
track fillers ...
StatusCode initialize()
initialize this should not actually be needed - we should be creating a new instance whenever this is...
const beam_key_t * m_beamkeys
enable / diable local truth decoration handling
const std::string & anaTag()
— Setter methods —
const EventContext & m_context
std::vector< std::unique_ptr< TrackView > > view_store_t
polymoprphic master store types
Handle class for reading a decoration on an object.
float pt() const
Definition TrackView.h:82
const T * as() const
Definition TrackView.h:142
a TrackView that can store a z0, d0, and phi because a TruthParticle doesn't have them
Definition TruthView.h:32
void add_z0(float z0)
Definition TruthView.h:52
void add_phi(float phi)
Definition TruthView.h:54
void add_d0(float d0)
Definition TruthView.h:53
bool passSelection(bool &value, const std::string &menu) const
Check if the egamma object pass a selection menu (using the name) If the menu decision is stored in t...
bool hasProdVtx() const
Check for a production vertex on this particle.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
double charge() const
Physical charge.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
float z() const
Vertex longitudinal distance along the beam line form the origin.
float y() const
Vertex y displacement.
float x() const
Vertex x displacement.
void fillv(std::vector< T > &t, Iterator first, Iterator last)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
TauJet_v3 TauJet
Definition of the current "tau version".
Definition TauJet.h:17
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
Definition Muon.h:13
Electron_v1 Electron
Definition of the current "egamma version".
Definition Electron.h:17