158 {
160
161
162
165 if(!ehandle.isValid()){
167 return StatusCode::SUCCESS;;
168 }else{
169 importedElectronCollection = ehandle.cptr();
171 }
173
174
177 if(!thandle.isValid()){
179 return StatusCode::SUCCESS;;
180 } else {
181 importedTrackCollection = thandle.cptr();
182 }
183
184
185 typedef std::vector<const xAOD::TrackParticle*>
TrackBag;
186 typedef std::vector<const xAOD::Electron*> ElectronBag;
187
188
193 for (trkCItr=importedTrackCollection->begin(); trkCItr!=importedTrackCollection->end(); ++trkCItr) {
197 theIDTracksAfterSelection.push_back(TP);
198 }
199 if (theIDTracksAfterSelection.size() == 0) return StatusCode::SUCCESS;;
200 ATH_MSG_DEBUG(
"Number of tracks after ID track selection: " << theIDTracksAfterSelection.size());
201 }
202
203
204 ElectronBag theElectronsAfterSelection;
207 for (elItr=importedElectronCollection->
begin(); elItr!=importedElectronCollection->
end(); ++elItr) {
208 if ( *elItr == NULL ) continue;
209 if (!(*elItr)->trackParticleLink().isValid()) continue;
212 SG::ReadDecorHandle<xAOD::ElectronContainer, ElementLink<xAOD::TrackParticleContainer>>
214 const ElementLink<xAOD::TrackParticleContainer>& refittedTrackLink = refittedTrackParticleLink(*(*elItr));
215 if (!refittedTrackLink.
isValid())
continue;
216 elTrk = *refittedTrackLink;
217 } else {
218 if (!(*elItr)->trackParticleLink().isValid()) continue;
219 elTrk = (*elItr)->trackParticleLink().cachedElement();
220 }
221
222 if ( elTrk==NULL) continue;
225
227 theElectronsAfterSelection.push_back(*elItr);
228 }
229 if (theElectronsAfterSelection.size() == 0) return StatusCode::SUCCESS;;
230 ATH_MSG_DEBUG(
"Number of electrons after selection: " << theElectronsAfterSelection.size());
231 }
232
233
234 std::vector<JpsiEECandidate> jpsiCandidates;
235 if (
m_elel) jpsiCandidates =
getPairs(theElectronsAfterSelection);
238
239 ATH_MSG_DEBUG(
"Number of pairs with ee from a B decay: " << jpsiCandidates.size() );
240
241
242 std::vector<JpsiEECandidate>::iterator jpsiItr;
243
244
245
246
247
248
249
251 for (jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
252 (*jpsiItr).collection1 = importedTrackCollection;
253 (*jpsiItr).collection2 = importedTrackCollection;
254 }
255 }
256
258 for (jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
261 SG::ReadDecorHandle<xAOD::ElectronContainer, ElementLink<xAOD::TrackParticleContainer>>
263 const ElementLink<xAOD::TrackParticleContainer>& refittedTrackLink1 = refittedTrackParticleLink(*((*jpsiItr).el1));
264 const ElementLink<xAOD::TrackParticleContainer>& refittedTrackLink2 = refittedTrackParticleLink(*((*jpsiItr).el2));
265 (*jpsiItr).trackParticle1 = *refittedTrackLink1;
266 (*jpsiItr).trackParticle2 = *refittedTrackLink2;
267 } else {
268 (*jpsiItr).trackParticle1 = (*jpsiItr).el1->trackParticleLink().cachedElement();
269 (*jpsiItr).trackParticle2 = (*jpsiItr).el2->trackParticleLink().cachedElement();
270 }
271 (*jpsiItr).collection1 = importedTrackCollection;
272 (*jpsiItr).collection2 = importedTrackCollection;
273 } else {
274 ATH_MSG_WARNING(
"Not setup for non-track electron measurements yet....");
275 }
276 }
277 }
278
279
280
283 std::vector<int> listToDelete;
284 std::vector<int>::reverse_iterator ii;
285 for(jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end();++jpsiItr,++index) {
286 if( (fabs((*jpsiItr).trackParticle1->pt()) <
m_higherPt) && (fabs((*jpsiItr).trackParticle2->pt()) <
m_higherPt) ) listToDelete.push_back(index);
287 }
288 for (ii=listToDelete.rbegin(); ii!=listToDelete.rend(); ++ii) {
289 jpsiCandidates.erase(jpsiCandidates.begin() + (*ii) );
290 }
291 ATH_MSG_DEBUG(
"Number of candidates after higherPt cut: " << jpsiCandidates.size() );
292 }
293
294
295 std::vector<JpsiEECandidate> sortedJpsiEECandidates;
299 ATH_MSG_DEBUG(
"Number of candidates after charge selection: " << sortedJpsiEECandidates.size() );
300
301
304 std::vector<int> listToDelete;
305 std::vector<int>::reverse_iterator ii;
306 for(jpsiItr=sortedJpsiEECandidates.begin(); jpsiItr!=sortedJpsiEECandidates.end();++jpsiItr,++index) {
307 double deltatheta = fabs( (*jpsiItr).trackParticle1->theta() - (*jpsiItr).trackParticle2->theta() );
308
309 double deltaphi = std::abs(
xAOD::P4Helpers::deltaPhi((*jpsiItr).trackParticle1->phi0() , (*jpsiItr).trackParticle2->phi0()));
310
312 }
313 for (ii=listToDelete.rbegin(); ii!=listToDelete.rend(); ++ii) {
314 sortedJpsiEECandidates.erase(sortedJpsiEECandidates.begin() + (*ii) );
315 }
316 ATH_MSG_DEBUG(
"Number of collimated candidates: " << sortedJpsiEECandidates.size() );
317 }
318
319
320 std::vector<double> trkMasses;
325 std::vector<int> listToDelete;
326 std::vector<int>::reverse_iterator ii;
327 for(jpsiItr=sortedJpsiEECandidates.begin(); jpsiItr!=sortedJpsiEECandidates.end(); ++jpsiItr,++index) {
329
331 listToDelete.push_back(index);
332 }
333 }
334 for (ii=listToDelete.rbegin(); ii!=listToDelete.rend(); ++ii) {
335 sortedJpsiEECandidates.erase(sortedJpsiEECandidates.begin() + (*ii) );
336 }
337 ATH_MSG_DEBUG(
"Number of candidates passing invariant mass selection: " << sortedJpsiEECandidates.size() );
338 }
339
340 if (sortedJpsiEECandidates.size() == 0) return StatusCode::SUCCESS;;
341
342
343 int itritn = 0;
344 for(jpsiItr=sortedJpsiEECandidates.begin(); jpsiItr!=sortedJpsiEECandidates.end(); ++jpsiItr) {
346 std::vector<const xAOD::TrackParticle*> theTracks; theTracks.clear();
347 theTracks.push_back((*jpsiItr).trackParticle1);
348 theTracks.push_back((*jpsiItr).trackParticle2);
349 ATH_MSG_DEBUG(
"theTracks size (should be two!) " << theTracks.size() <<
" being vertexed with tracks " << importedTrackCollection);
350 std::unique_ptr<xAOD::Vertex> myVxCandidate{
fit(ctx, theTracks,importedTrackCollection)};
351 if (myVxCandidate != 0) {
352
353 double chi2 = myVxCandidate->chiSquared();
356
357 xAOD::BPhysHelper jpsiHelper(myVxCandidate.get());
358 jpsiHelper.setRefTrks();
360 std::vector<const xAOD::Electron*> theStoredElectrons;
361 theStoredElectrons.push_back((*jpsiItr).el1);
362 if (
m_elel) theStoredElectrons.push_back((*jpsiItr).el2);
363 jpsiHelper.setElectrons(theStoredElectrons,importedElectronCollection);
364 }
365
366 vxContainer.
push_back(std::move(myVxCandidate));
367 }
368 } else {
370
371
372
373 }
374 }
376
377 return StatusCode::SUCCESS;;
378 }
bool passesEgammaCuts(const xAOD::Electron *) const
std::vector< JpsiEECandidate > getPairs(const std::vector< const xAOD::TrackParticle * > &) const
std::unique_ptr< xAOD::Vertex > fit(const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &, const xAOD::TrackParticleContainer *importedTrackCollection) const
std::vector< JpsiEECandidate > selectCharges(const std::vector< JpsiEECandidate > &, const std::string &) const
double getInvariantMass(const JpsiEECandidate &, const std::vector< double > &) const
std::vector< JpsiEECandidate > getPairs2Colls(const std::vector< const xAOD::TrackParticle * > &, const std::vector< const xAOD::Electron * > &, bool) const
DataModel_detail::const_iterator< DataVector > const_iterator
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool isValid() const
Check if the element can be found.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
double chi2(TH1 *h0, TH1 *h1)
std::vector< const xAOD::TrackParticle * > TrackBag
double invMass(const I4Momentum &pA, const I4Momentum &pB)
invariant mass from two I4momentum references
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".