ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::BPhysBGammaFinder Class Reference

#include <BPhysBGammaFinder.h>

Inheritance diagram for DerivationFramework::BPhysBGammaFinder:
Collaboration diagram for DerivationFramework::BPhysBGammaFinder:

Public Member Functions

 BPhysBGammaFinder (const std::string &t, const std::string &n, const IInterface *p)
StatusCode initialize () override
StatusCode finalize () override
virtual StatusCode addBranches (const EventContext &ctx) const override
TVector3 trackMomentum (const xAOD::Vertex &vxCandidate, int trkIndex) const

Private Attributes

SG::ReadHandleKeyArray< xAOD::VertexContainerm_BVertexCollectionsToCheck
SG::ReadDecorHandleKeyArray< xAOD::VertexContainerm_passFlagsToCheck
ToolHandle< Trk::V0Toolsm_v0Tools
ToolHandle< Trk::IVertexFitterm_vertexFitter
ToolHandle< InDet::VertexPointEstimatorm_vertexEstimator
SG::ReadHandleKey< xAOD::TrackParticleContainerm_inputTrackParticleContainerName
SG::ReadHandleKey< xAOD::TrackParticleContainerm_inputLowPtTrackContainerName
SG::WriteHandleKey< xAOD::VertexContainerm_conversionContainerName
float m_maxDeltaQ
float m_Chi2Cut
float m_maxGammaMass

Detailed Description

Definition at line 46 of file BPhysBGammaFinder.h.

Constructor & Destructor Documentation

◆ BPhysBGammaFinder()

DerivationFramework::BPhysBGammaFinder::BPhysBGammaFinder ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 22 of file BPhysBGammaFinder.cxx.

23 : base_class(t,n,p),
24 m_v0Tools("Trk::V0Tools"),
25 m_vertexFitter("Trk::TrkVKalVrtFitter", this),
26 m_vertexEstimator("InDet::VertexPointEstimator", this),
27 m_inputTrackParticleContainerName("InDetTrackParticles"),
28 m_inputLowPtTrackContainerName("LowPtRoITrackParticles"),
29 m_conversionContainerName("BPhysConversionCandidates"),
30 m_maxDeltaQ(700.0),
31 m_Chi2Cut(20.0),
32 m_maxGammaMass(100.0) {
33
34
35 // Declare user-defined properties
36 declareProperty("BVertexContainers", m_BVertexCollectionsToCheck);
37 declareProperty("PassFlagsToCheck", m_passFlagsToCheck);
38 declareProperty("V0Tools", m_v0Tools);
39 declareProperty("VertexFitterTool", m_vertexFitter);
40 declareProperty("VertexEstimator", m_vertexEstimator);
41 declareProperty("InputTrackParticleContainerName", m_inputTrackParticleContainerName);
42 declareProperty("InputLowPtTrackContainerName", m_inputLowPtTrackContainerName);
43 declareProperty("ConversionContainerName", m_conversionContainerName);
44 declareProperty("MaxDeltaQ", m_maxDeltaQ = 700.0); // Maximum mass difference between di-muon+conversion and di-muon
45 declareProperty("Chi2Cut", m_Chi2Cut = 20.0);
46 declareProperty("MaxGammaMass", m_maxGammaMass = 100.0);
47}
SG::WriteHandleKey< xAOD::VertexContainer > m_conversionContainerName
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_BVertexCollectionsToCheck
SG::ReadDecorHandleKeyArray< xAOD::VertexContainer > m_passFlagsToCheck
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputLowPtTrackContainerName
ToolHandle< Trk::IVertexFitter > m_vertexFitter
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTrackParticleContainerName
ToolHandle< InDet::VertexPointEstimator > m_vertexEstimator

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::BPhysBGammaFinder::addBranches ( const EventContext & ctx) const
overridevirtual

Definition at line 70 of file BPhysBGammaFinder.cxx.

70 {
71
72 std::vector<const xAOD::Vertex*> BVertices;
73 std::vector<const xAOD::TrackParticle*> BVertexTracks;
74
75
76 // Output conversion container
77 std::unique_ptr<xAOD::VertexContainer> conversionContainer(new xAOD::VertexContainer());
78 std::unique_ptr<xAOD::VertexAuxContainer> conversionAuxContainer(new xAOD::VertexAuxContainer());
79 conversionContainer->setStore(conversionAuxContainer.get());
80
81 // Retrieve track particles from StoreGate
82 SG::ReadHandle<xAOD::TrackParticleContainer> inputTrackParticles{m_inputTrackParticleContainerName, ctx};
83 ATH_MSG_DEBUG( "Track particle container size " << inputTrackParticles->size() );
84
85 std::vector<const xAOD::TrackParticle*> trackPair(2);
86
87 static const SG::Decorator< std::vector< VertexLink > > BGammaLinks( "BGammaLinks" );
88
89 auto flaghandles = m_passFlagsToCheck.makeHandles(ctx);
90 // Retrieve vertex containers
91 for (SG::ReadHandle<xAOD::VertexContainer>& BVtxContainer : m_BVertexCollectionsToCheck.makeHandles(ctx)) {
92 if (!BVtxContainer.isValid()) { // replaces the CHECK
93 ATH_MSG_ERROR("Failed to retrieve VertexContainer " << BVtxContainer.key());
94 return StatusCode::FAILURE; // or ATH_CHECK if you prefer the macro style
95 }
96
97 ATH_MSG_DEBUG( "Vertex Container (" << BVtxContainer.key() << ") contains " << BVtxContainer->size() << " vertices" );
98
99
100 for (const xAOD::Vertex* vertex : *BVtxContainer) {
101 auto &vect = BGammaLinks(*vertex) = std::vector< VertexLink >();
102
103 bool passedHypothesis = false;
104 BVertexTracks.clear();
105
106 for (const auto &flag : flaghandles) {
107 bool pass = flag(*vertex);
108 if (pass) passedHypothesis = true;
109 }
110
111 if (!passedHypothesis) continue;
112 xAOD::BPhysHypoHelper Bc("Bc", vertex);
113
114 // link to Bc+ vertex
115 std::vector<const xAOD::Vertex*> precedingVertices(1, vertex);
116
117 // Collect up B-vertex tracks
118 for (size_t i = 0; i < vertex->nTrackParticles(); ++i) BVertexTracks.push_back(vertex->trackParticle(i));
119
120 // Track Selection
121 // Track1 Loop
122 for (xAOD::TrackParticleContainer::const_iterator tpIt1 = inputTrackParticles->begin(); tpIt1 != inputTrackParticles->end(); ++tpIt1) {
123 trackPair[0] = *tpIt1;
124
125 auto itr1 = std::find(BVertexTracks.begin(), BVertexTracks.end(), trackPair[0]);
126 if (itr1 != BVertexTracks.end()) continue;
127
128 const Trk::Perigee& trackPerigee1 = trackPair[0]->perigeeParameters();
129
130 // Track2 Loop
131 for (xAOD::TrackParticleContainer::const_iterator tpIt2 = tpIt1 + 1; tpIt2 != inputTrackParticles->end(); ++tpIt2) {
132 trackPair[1] = *tpIt2;
133 if (trackPair[0] == trackPair[1]) continue;
134
135 auto itr2 = std::find(BVertexTracks.begin(), BVertexTracks.end(), trackPair[1]);
136 if (itr2 != BVertexTracks.end()) continue;
137
138 const Trk::Perigee& trackPerigee2 = trackPair[1]->perigeeParameters();
139
140 // Track pair selection
141 TLorentzVector e1, e2, gamma_m, BcStar;
142 e1.SetPtEtaPhiM(trackPair[0]->pt(), trackPair[0]->eta(), trackPair[0]->phi(), Trk::electron);
143 e2.SetPtEtaPhiM(trackPair[1]->pt(), trackPair[1]->eta(), trackPair[1]->phi(), Trk::electron);
144
145 gamma_m = e1 + e2;
146 if (gamma_m.M() > m_maxGammaMass) continue;
147
148 TLorentzVector mu1 = Bc.refTrk(0, Trk::muon);
149 TLorentzVector mu2 = Bc.refTrk(1, Trk::muon);
150 TLorentzVector mu3 = Bc.refTrk(2, Trk::muon);
151
152 BcStar = mu1 + mu2 + mu3 + e1 + e2;
153 double Q = BcStar.M() - Bc.mass() - 2 * Trk::electron;
154 if (Q > m_maxDeltaQ) continue;
155
156 // Estimate starting point + cuts on compatiblity of tracks
157 int sflag = 0;
158 int errorcode = 0;
159 Amg::Vector3D startingPoint = m_vertexEstimator->getCirclesIntersectionPoint(&trackPerigee1, &trackPerigee2, sflag, errorcode);
160 if (errorcode != 0) startingPoint = Amg::Vector3D::Zero(3);
161
162 std::vector<float> RefTrackPx, RefTrackPy, RefTrackPz, RefTrackE;
163 std::vector<float> OrigTrackPx, OrigTrackPy, OrigTrackPz, OrigTrackE;
164
165
166 // Do the vertex fit
167 auto convVertexCandidate = m_vertexFitter->fit(ctx, trackPair, startingPoint);
168
169 // Check for successful fit
170 if (convVertexCandidate) {
171 if (convVertexCandidate->chiSquared() / convVertexCandidate->numberDoF() > m_Chi2Cut) continue;
172
173 xAOD::BPhysHelper Photon(convVertexCandidate.get());
174 // set link to the parent Bc+ vertex
175 Photon.setPrecedingVertices(precedingVertices, BVtxContainer.cptr());
176
177 // Parameters at vertex
178 convVertexCandidate->clearTracks();
179 ElementLink<xAOD::TrackParticleContainer> newLink1;
180 newLink1.setElement(*tpIt1);
181 newLink1.setStorableObject(*inputTrackParticles);
182 ElementLink<xAOD::TrackParticleContainer> newLink2;
183 newLink2.setElement(*tpIt2);
184 newLink2.setStorableObject(*inputTrackParticles);
185 convVertexCandidate->addTrackAtVertex(newLink1);
186 convVertexCandidate->addTrackAtVertex(newLink2);
187
188 std::vector<Amg::Vector3D> positionList;
189
190 //Get photon momentum 3-vector
191 Amg::Vector3D momentum = m_v0Tools->V0Momentum(convVertexCandidate.get());
192
193 TLorentzVector photon, electron1, electron2, ph;
194 electron1.SetVectM( trackMomentum( *convVertexCandidate, 0 ), Trk::electron );
195 electron2.SetVectM( trackMomentum( *convVertexCandidate, 1 ), Trk::electron );
196 photon = electron1 + electron2;
197 ph.SetXYZM(momentum.x(), momentum.y(), momentum.z(), 0.);
198
199 // Use to keep track of which dimuon(s) gave a chi_c/b candidate
200 static const SG::Accessor<std::vector<float> > RefTrackPxAcc("RefTrackPx");
201 static const SG::Accessor<std::vector<float> > RefTrackPyAcc("RefTrackPy");
202 static const SG::Accessor<std::vector<float> > RefTrackPzAcc("RefTrackPz");
203 std::vector<float> B_Px = RefTrackPxAcc(*vertex);
204 std::vector<float> B_Py = RefTrackPyAcc(*vertex);
205 std::vector<float> B_Pz = RefTrackPzAcc(*vertex);
206
207 TLorentzVector muon1, muon2, muon3;
208 muon1.SetXYZM(B_Px.at(0), B_Py.at(0), B_Pz.at(0), Trk::muon);
209 muon2.SetXYZM(B_Px.at(1), B_Py.at(1), B_Pz.at(1), Trk::muon);
210 muon3.SetXYZM(B_Px.at(2), B_Py.at(2), B_Pz.at(2), Trk::muon);
211
212 TLorentzVector B_m = muon1 + muon2 + muon3;
213
214 const double deltaQ = (B_m + photon).M() - Bc.mass() - 2 * Trk::electron;
215 const double mass = photon.M();
216
217 RefTrackPx.push_back(trackMomentum(*convVertexCandidate, 0).Px());
218 RefTrackPx.push_back(trackMomentum(*convVertexCandidate, 1).Px());
219
220 RefTrackPy.push_back(trackMomentum(*convVertexCandidate, 0).Py());
221 RefTrackPy.push_back(trackMomentum(*convVertexCandidate, 1).Py());
222
223 RefTrackPz.push_back(trackMomentum(*convVertexCandidate, 0).Pz());
224 RefTrackPz.push_back(trackMomentum(*convVertexCandidate, 1).Pz());
225
226 for (size_t i = 0; i < B_Px.size(); i++) {
227 RefTrackPx.push_back(B_Px.at(i));
228 RefTrackPy.push_back(B_Py.at(i));
229 RefTrackPz.push_back(B_Pz.at(i));
230 }
231
232 RefTrackE.push_back(electron1.E());
233 RefTrackE.push_back(electron2.E());
234 RefTrackE.push_back(muon1.E());
235 RefTrackE.push_back(muon2.E());
236 RefTrackE.push_back(muon3.E());
237
238 OrigTrackPx.push_back(e1.Px());
239 OrigTrackPx.push_back(e2.Px());
240
241 OrigTrackPy.push_back(e1.Py());
242 OrigTrackPy.push_back(e2.Py());
243
244 OrigTrackPz.push_back(e1.Pz());
245 OrigTrackPz.push_back(e2.Pz());
246
247 OrigTrackE.push_back(e1.E());
248 OrigTrackE.push_back(e2.E());
249
250
251 ATH_MSG_DEBUG( "pt = " << photon.Pt() << " ph " << ph.Pt() << " mass " << photon.M() << " px size " << RefTrackPx.size() );
252 ATH_MSG_DEBUG( "Candidate DeltaM = " << (B_m + photon).M() << " MeV DiMuon " << " ( Mass = " << B_m.M() << " MeV )");
253
254 // Decorate selected conversions
255 ATH_MSG_DEBUG( "Decorating conversion vertices" );
256
257 static const SG::Accessor<float> pxAcc("px");
258 static const SG::Accessor<float> pyAcc("py");
259 static const SG::Accessor<float> pzAcc("pz");
260 pxAcc(*convVertexCandidate) = momentum.x();
261 pyAcc(*convVertexCandidate) = momentum.y();
262 pzAcc(*convVertexCandidate) = momentum.z();
263
264 static const SG::Accessor<float> deltaQAcc("deltaQ");
265 static const SG::Accessor<float> gamma_massAcc("gamma_mass");
266 static const SG::Accessor< std::vector<float> > RefTrackEAcc("RefTrackE");
267 deltaQAcc(*convVertexCandidate) = deltaQ;
268 gamma_massAcc(*convVertexCandidate) = mass;
269 RefTrackPxAcc(*convVertexCandidate) = RefTrackPx;
270 RefTrackPyAcc(*convVertexCandidate) = RefTrackPy;
271 RefTrackPzAcc(*convVertexCandidate) = RefTrackPz;
272 RefTrackEAcc(*convVertexCandidate) = RefTrackE;
273
274 static const SG::Accessor< std::vector<float> > OrigTrackPxAcc("OrigTrackPx");
275 static const SG::Accessor< std::vector<float> > OrigTrackPyAcc("OrigTrackPy");
276 static const SG::Accessor< std::vector<float> > OrigTrackPzAcc("OrigTrackPz");
277 static const SG::Accessor< std::vector<float> > OrigTrackEAcc("OrigTrackE");
278 OrigTrackPxAcc(*convVertexCandidate) = OrigTrackPx;
279 OrigTrackPyAcc(*convVertexCandidate) = OrigTrackPy;
280 OrigTrackPzAcc(*convVertexCandidate) = OrigTrackPz;
281 OrigTrackEAcc(*convVertexCandidate) = OrigTrackE;
282
283 static const SG::Accessor<Char_t> passed_GammaAcc("passed_Gamma");
284 passed_GammaAcc(*convVertexCandidate) = true; // Used in event skimming
285
286
287 // add cross-link to the original Bc+ vertex
288 VertexLink BGammaLink;
289 BGammaLink.setElement(convVertexCandidate.get());
290 BGammaLink.setStorableObject(*conversionContainer);
291 conversionContainer->push_back( std::move(convVertexCandidate) );
292 vect.push_back(std::move(BGammaLink));
293 }
294 else {
295 ATH_MSG_DEBUG( "Vertex Fit Failed" );
296 }
297
298 } // end of Track2 Loop
299 } // end of Track1 Loop
300
301 } // end of Bc loop
302
303 } // end of vertex container loop
304
305 SG::WriteHandle<xAOD::VertexContainer> wh(m_conversionContainerName, ctx);
306 ATH_CHECK( wh.record(std::move(conversionContainer), std::move(conversionAuxContainer)) );
307
308 return StatusCode::SUCCESS;
309}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
TVector3 trackMomentum(const xAOD::Vertex &vxCandidate, int trkIndex) const
Eigen::Matrix< double, 3, 1 > Vector3D
ElementLink< xAOD::VertexContainer > VertexLink
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:573
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
double e1(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 1st sampling
bool flag
Definition master.py:29
str wh
Definition parseDir.py:45
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
Photon_v1 Photon
Definition of the current "egamma version".

◆ finalize()

StatusCode DerivationFramework::BPhysBGammaFinder::finalize ( )
override

Definition at line 65 of file BPhysBGammaFinder.cxx.

65 {
66 return StatusCode::SUCCESS;
67}

◆ initialize()

StatusCode DerivationFramework::BPhysBGammaFinder::initialize ( )
override

Definition at line 50 of file BPhysBGammaFinder.cxx.

50 {
51
52 ATH_MSG_DEBUG("in initialize()");
53
54 ATH_CHECK( m_v0Tools.retrieve() );
55 ATH_CHECK( m_vertexFitter.retrieve() );
56 ATH_CHECK( m_vertexEstimator.retrieve() );
61 return StatusCode::SUCCESS;
62}

◆ trackMomentum()

TVector3 DerivationFramework::BPhysBGammaFinder::trackMomentum ( const xAOD::Vertex & vxCandidate,
int trkIndex ) const

Definition at line 313 of file BPhysBGammaFinder.cxx.

313 {
314
315 double px = 0.;
316 double py = 0.;
317 double pz = 0.;
318 const Trk::TrackParameters* aPerigee = vxCandidate.vxTrackAtVertex()[trkIndex].perigeeAtVertex();
319 px = aPerigee->momentum()[Trk::px];
320 py = aPerigee->momentum()[Trk::py];
321 pz = aPerigee->momentum()[Trk::pz];
322
323 return TVector3(px,py,pz);
324}
const Amg::Vector3D & momentum() const
Access method for the momentum.
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
@ pz
global momentum (cartesian)
Definition ParamDefs.h:61
@ px
Definition ParamDefs.h:59
@ py
Definition ParamDefs.h:60
ParametersBase< TrackParametersDim, Charged > TrackParameters

Member Data Documentation

◆ m_BVertexCollectionsToCheck

SG::ReadHandleKeyArray<xAOD::VertexContainer> DerivationFramework::BPhysBGammaFinder::m_BVertexCollectionsToCheck
private

Definition at line 60 of file BPhysBGammaFinder.h.

◆ m_Chi2Cut

float DerivationFramework::BPhysBGammaFinder::m_Chi2Cut
private

Definition at line 72 of file BPhysBGammaFinder.h.

◆ m_conversionContainerName

SG::WriteHandleKey<xAOD::VertexContainer> DerivationFramework::BPhysBGammaFinder::m_conversionContainerName
private

Definition at line 69 of file BPhysBGammaFinder.h.

◆ m_inputLowPtTrackContainerName

SG::ReadHandleKey<xAOD::TrackParticleContainer> DerivationFramework::BPhysBGammaFinder::m_inputLowPtTrackContainerName
private

Definition at line 68 of file BPhysBGammaFinder.h.

◆ m_inputTrackParticleContainerName

SG::ReadHandleKey<xAOD::TrackParticleContainer> DerivationFramework::BPhysBGammaFinder::m_inputTrackParticleContainerName
private

Definition at line 67 of file BPhysBGammaFinder.h.

◆ m_maxDeltaQ

float DerivationFramework::BPhysBGammaFinder::m_maxDeltaQ
private

Definition at line 71 of file BPhysBGammaFinder.h.

◆ m_maxGammaMass

float DerivationFramework::BPhysBGammaFinder::m_maxGammaMass
private

Definition at line 73 of file BPhysBGammaFinder.h.

◆ m_passFlagsToCheck

SG::ReadDecorHandleKeyArray<xAOD::VertexContainer> DerivationFramework::BPhysBGammaFinder::m_passFlagsToCheck
private

Definition at line 61 of file BPhysBGammaFinder.h.

◆ m_v0Tools

ToolHandle<Trk::V0Tools> DerivationFramework::BPhysBGammaFinder::m_v0Tools
private

Definition at line 63 of file BPhysBGammaFinder.h.

◆ m_vertexEstimator

ToolHandle<InDet::VertexPointEstimator> DerivationFramework::BPhysBGammaFinder::m_vertexEstimator
private

Definition at line 65 of file BPhysBGammaFinder.h.

◆ m_vertexFitter

ToolHandle<Trk::IVertexFitter> DerivationFramework::BPhysBGammaFinder::m_vertexFitter
private

Definition at line 64 of file BPhysBGammaFinder.h.


The documentation for this class was generated from the following files: