161 {
163
164
165
168 if(!ehandle.isValid()){
170 return StatusCode::SUCCESS;;
171 }else{
172 importedElectronCollection = ehandle.cptr();
174 }
176
177
180 if(!thandle.isValid()){
182 return StatusCode::SUCCESS;;
183 } else {
184 importedTrackCollection = thandle.cptr();
185 }
186
187
188 typedef std::vector<const xAOD::TrackParticle*>
TrackBag;
189 typedef std::vector<const xAOD::Electron*> ElectronBag;
190
191
196 for (trkCItr=importedTrackCollection->begin(); trkCItr!=importedTrackCollection->end(); ++trkCItr) {
200 theIDTracksAfterSelection.push_back(TP);
201 }
202 if (theIDTracksAfterSelection.size() == 0) return StatusCode::SUCCESS;;
203 ATH_MSG_DEBUG(
"Number of tracks after ID track selection: " << theIDTracksAfterSelection.size());
204 }
205
206
207 ElectronBag theElectronsAfterSelection;
210 for (elItr=importedElectronCollection->
begin(); elItr!=importedElectronCollection->
end(); ++elItr) {
211 if ( *elItr == NULL ) continue;
212 if (!(*elItr)->trackParticleLink().isValid()) continue;
215 SG::ReadDecorHandle<xAOD::ElectronContainer, ElementLink<xAOD::TrackParticleContainer>>
217 const ElementLink<xAOD::TrackParticleContainer>& refittedTrackLink = refittedTrackParticleLink(*(*elItr));
218 if (!refittedTrackLink.
isValid())
continue;
219 elTrk = *refittedTrackLink;
220 } else {
221 if (!(*elItr)->trackParticleLink().isValid()) continue;
222 elTrk = (*elItr)->trackParticleLink().cachedElement();
223 }
224
225 if ( elTrk==NULL) continue;
228
230 theElectronsAfterSelection.push_back(*elItr);
231 }
232 if (theElectronsAfterSelection.size() == 0) return StatusCode::SUCCESS;;
233 ATH_MSG_DEBUG(
"Number of electrons after selection: " << theElectronsAfterSelection.size());
234 }
235
236
237 std::vector<JpsiEECandidate> jpsiCandidates;
238 if (
m_elel) jpsiCandidates =
getPairs(theElectronsAfterSelection);
241
242 ATH_MSG_DEBUG(
"Number of pairs with ee from a B decay: " << jpsiCandidates.size() );
243
244
245 std::vector<JpsiEECandidate>::iterator jpsiItr;
246
247
248
249
250
251
252
254 for (jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
255 (*jpsiItr).collection1 = importedTrackCollection;
256 (*jpsiItr).collection2 = importedTrackCollection;
257 }
258 }
259
261 for (jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
264 SG::ReadDecorHandle<xAOD::ElectronContainer, ElementLink<xAOD::TrackParticleContainer>>
266 const ElementLink<xAOD::TrackParticleContainer>& refittedTrackLink1 = refittedTrackParticleLink(*((*jpsiItr).el1));
267 const ElementLink<xAOD::TrackParticleContainer>& refittedTrackLink2 = refittedTrackParticleLink(*((*jpsiItr).el2));
268 (*jpsiItr).trackParticle1 = *refittedTrackLink1;
269 (*jpsiItr).trackParticle2 = *refittedTrackLink2;
270 } else {
271 (*jpsiItr).trackParticle1 = (*jpsiItr).el1->trackParticleLink().cachedElement();
272 (*jpsiItr).trackParticle2 = (*jpsiItr).el2->trackParticleLink().cachedElement();
273 }
274 (*jpsiItr).collection1 = importedTrackCollection;
275 (*jpsiItr).collection2 = importedTrackCollection;
276 } else {
277 ATH_MSG_WARNING(
"Not setup for non-track electron measurements yet....");
278 }
279 }
280 }
281
282
283
286 std::vector<int> listToDelete;
287 std::vector<int>::reverse_iterator ii;
288 for(jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end();++jpsiItr,++index) {
289 if( (fabs((*jpsiItr).trackParticle1->pt()) <
m_higherPt) && (fabs((*jpsiItr).trackParticle2->pt()) <
m_higherPt) ) listToDelete.push_back(index);
290 }
291 for (ii=listToDelete.rbegin(); ii!=listToDelete.rend(); ++ii) {
292 jpsiCandidates.erase(jpsiCandidates.begin() + (*ii) );
293 }
294 ATH_MSG_DEBUG(
"Number of candidates after higherPt cut: " << jpsiCandidates.size() );
295 }
296
297
298 std::vector<JpsiEECandidate> sortedJpsiEECandidates;
302 ATH_MSG_DEBUG(
"Number of candidates after charge selection: " << sortedJpsiEECandidates.size() );
303
304
307 std::vector<int> listToDelete;
308 std::vector<int>::reverse_iterator ii;
309 for(jpsiItr=sortedJpsiEECandidates.begin(); jpsiItr!=sortedJpsiEECandidates.end();++jpsiItr,++index) {
310 double deltatheta = fabs( (*jpsiItr).trackParticle1->theta() - (*jpsiItr).trackParticle2->theta() );
311
312 double deltaphi = std::abs(
xAOD::P4Helpers::deltaPhi((*jpsiItr).trackParticle1->phi0() , (*jpsiItr).trackParticle2->phi0()));
313
315 }
316 for (ii=listToDelete.rbegin(); ii!=listToDelete.rend(); ++ii) {
317 sortedJpsiEECandidates.erase(sortedJpsiEECandidates.begin() + (*ii) );
318 }
319 ATH_MSG_DEBUG(
"Number of collimated candidates: " << sortedJpsiEECandidates.size() );
320 }
321
322
323 std::vector<double> trkMasses;
328 std::vector<int> listToDelete;
329 std::vector<int>::reverse_iterator ii;
330 for(jpsiItr=sortedJpsiEECandidates.begin(); jpsiItr!=sortedJpsiEECandidates.end(); ++jpsiItr,++index) {
332
334 listToDelete.push_back(index);
335 }
336 }
337 for (ii=listToDelete.rbegin(); ii!=listToDelete.rend(); ++ii) {
338 sortedJpsiEECandidates.erase(sortedJpsiEECandidates.begin() + (*ii) );
339 }
340 ATH_MSG_DEBUG(
"Number of candidates passing invariant mass selection: " << sortedJpsiEECandidates.size() );
341 }
342
343 if (sortedJpsiEECandidates.size() == 0) return StatusCode::SUCCESS;;
344
345
346 int itritn = 0;
347 for(jpsiItr=sortedJpsiEECandidates.begin(); jpsiItr!=sortedJpsiEECandidates.end(); ++jpsiItr) {
349 std::vector<const xAOD::TrackParticle*> theTracks; theTracks.clear();
350 theTracks.push_back((*jpsiItr).trackParticle1);
351 theTracks.push_back((*jpsiItr).trackParticle2);
352 ATH_MSG_DEBUG(
"theTracks size (should be two!) " << theTracks.size() <<
" being vertexed with tracks " << importedTrackCollection);
353 std::unique_ptr<xAOD::Vertex> myVxCandidate{
fit(ctx, theTracks,importedTrackCollection)};
354 if (myVxCandidate != 0) {
355
356 double chi2 = myVxCandidate->chiSquared();
359
360 xAOD::BPhysHelper jpsiHelper(myVxCandidate.get());
361 jpsiHelper.setRefTrks();
363 std::vector<const xAOD::Electron*> theStoredElectrons;
364 theStoredElectrons.push_back((*jpsiItr).el1);
365 if (
m_elel) theStoredElectrons.push_back((*jpsiItr).el2);
366 jpsiHelper.setElectrons(theStoredElectrons,importedElectronCollection);
367 }
368
369 vxContainer.
push_back(std::move(myVxCandidate));
370 }
371 } else {
373
374
375
376 }
377 }
379
380 return StatusCode::SUCCESS;;
381 }
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".