168 {
170
171
172
175 if(!ehandle.isValid()){
177 return StatusCode::SUCCESS;;
178 }else{
179 importedElectronCollection = ehandle.cptr();
181 }
183
184
187 if(!thandle.isValid()){
189 return StatusCode::SUCCESS;;
190 } else {
191 importedTrackCollection = thandle.cptr();
192 }
193
194
195 typedef std::vector<const xAOD::TrackParticle*>
TrackBag;
196 typedef std::vector<const xAOD::Electron*> ElectronBag;
197
198
203 for (trkCItr=importedTrackCollection->begin(); trkCItr!=importedTrackCollection->end(); ++trkCItr) {
207 theIDTracksAfterSelection.push_back(TP);
208 }
209 if (theIDTracksAfterSelection.size() == 0) return StatusCode::SUCCESS;;
210 ATH_MSG_DEBUG(
"Number of tracks after ID track selection: " << theIDTracksAfterSelection.size());
211 }
212
213
214 ElectronBag theElectronsAfterSelection;
217 for (elItr=importedElectronCollection->
begin(); elItr!=importedElectronCollection->
end(); ++elItr) {
218 if ( *elItr == NULL ) continue;
219 if (!(*elItr)->trackParticleLink().isValid()) continue;
222 SG::ReadDecorHandle<xAOD::ElectronContainer, ElementLink<xAOD::TrackParticleContainer>>
224 const ElementLink<xAOD::TrackParticleContainer>& refittedTrackLink = refittedTrackParticleLink(*(*elItr));
225 if (!refittedTrackLink.
isValid())
continue;
226 elTrk = *refittedTrackLink;
227 } else {
228 if (!(*elItr)->trackParticleLink().isValid()) continue;
229 elTrk = (*elItr)->trackParticleLink().cachedElement();
230 }
231
232 if ( elTrk==NULL) continue;
235
237 theElectronsAfterSelection.push_back(*elItr);
238 }
239 if (theElectronsAfterSelection.size() == 0) return StatusCode::SUCCESS;;
240 ATH_MSG_DEBUG(
"Number of electrons after selection: " << theElectronsAfterSelection.size());
241 }
242
243
244 std::vector<JpsiEECandidate> jpsiCandidates;
245 if (
m_elel) jpsiCandidates =
getPairs(theElectronsAfterSelection);
248
249 ATH_MSG_DEBUG(
"Number of pairs with ee from a B decay: " << jpsiCandidates.size() );
250
251
252 std::vector<JpsiEECandidate>::iterator jpsiItr;
253
254
255
256
257
258
259
261 for (jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
262 (*jpsiItr).collection1 = importedTrackCollection;
263 (*jpsiItr).collection2 = importedTrackCollection;
264 }
265 }
266
268 for (jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
271 SG::ReadDecorHandle<xAOD::ElectronContainer, ElementLink<xAOD::TrackParticleContainer>>
273 const ElementLink<xAOD::TrackParticleContainer>& refittedTrackLink1 = refittedTrackParticleLink(*((*jpsiItr).el1));
274 const ElementLink<xAOD::TrackParticleContainer>& refittedTrackLink2 = refittedTrackParticleLink(*((*jpsiItr).el2));
275 (*jpsiItr).trackParticle1 = *refittedTrackLink1;
276 (*jpsiItr).trackParticle2 = *refittedTrackLink2;
277 } else {
278 (*jpsiItr).trackParticle1 = (*jpsiItr).el1->trackParticleLink().cachedElement();
279 (*jpsiItr).trackParticle2 = (*jpsiItr).el2->trackParticleLink().cachedElement();
280 }
281 (*jpsiItr).collection1 = importedTrackCollection;
282 (*jpsiItr).collection2 = importedTrackCollection;
283 } else {
284 ATH_MSG_WARNING(
"Not setup for non-track electron measurements yet....");
285 }
286 }
287 }
288
289
290
293 std::vector<int> listToDelete;
294 std::vector<int>::reverse_iterator ii;
295 for(jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end();++jpsiItr,++index) {
296 if( (fabs((*jpsiItr).trackParticle1->pt()) <
m_higherPt) && (fabs((*jpsiItr).trackParticle2->pt()) <
m_higherPt) ) listToDelete.push_back(index);
297 }
298 for (ii=listToDelete.rbegin(); ii!=listToDelete.rend(); ++ii) {
299 jpsiCandidates.erase(jpsiCandidates.begin() + (*ii) );
300 }
301 ATH_MSG_DEBUG(
"Number of candidates after higherPt cut: " << jpsiCandidates.size() );
302 }
303
304
305 std::vector<JpsiEECandidate> sortedJpsiEECandidates;
309 ATH_MSG_DEBUG(
"Number of candidates after charge selection: " << sortedJpsiEECandidates.size() );
310
311
314 std::vector<int> listToDelete;
315 std::vector<int>::reverse_iterator ii;
316 for(jpsiItr=sortedJpsiEECandidates.begin(); jpsiItr!=sortedJpsiEECandidates.end();++jpsiItr,++index) {
317 double deltatheta = fabs( (*jpsiItr).trackParticle1->theta() - (*jpsiItr).trackParticle2->theta() );
318
319 double deltaphi = std::abs(
xAOD::P4Helpers::deltaPhi((*jpsiItr).trackParticle1->phi0() , (*jpsiItr).trackParticle2->phi0()));
320
322 }
323 for (ii=listToDelete.rbegin(); ii!=listToDelete.rend(); ++ii) {
324 sortedJpsiEECandidates.erase(sortedJpsiEECandidates.begin() + (*ii) );
325 }
326 ATH_MSG_DEBUG(
"Number of collimated candidates: " << sortedJpsiEECandidates.size() );
327 }
328
329
330 std::vector<double> trkMasses;
335 std::vector<int> listToDelete;
336 std::vector<int>::reverse_iterator ii;
337 for(jpsiItr=sortedJpsiEECandidates.begin(); jpsiItr!=sortedJpsiEECandidates.end(); ++jpsiItr,++index) {
339
341 listToDelete.push_back(index);
342 }
343 }
344 for (ii=listToDelete.rbegin(); ii!=listToDelete.rend(); ++ii) {
345 sortedJpsiEECandidates.erase(sortedJpsiEECandidates.begin() + (*ii) );
346 }
347 ATH_MSG_DEBUG(
"Number of candidates passing invariant mass selection: " << sortedJpsiEECandidates.size() );
348 }
349
350 if (sortedJpsiEECandidates.size() == 0) return StatusCode::SUCCESS;;
351
352
353 int itritn = 0;
354 for(jpsiItr=sortedJpsiEECandidates.begin(); jpsiItr!=sortedJpsiEECandidates.end(); ++jpsiItr) {
356 std::vector<const xAOD::TrackParticle*> theTracks; theTracks.clear();
357 theTracks.push_back((*jpsiItr).trackParticle1);
358 theTracks.push_back((*jpsiItr).trackParticle2);
359 ATH_MSG_DEBUG(
"theTracks size (should be two!) " << theTracks.size() <<
" being vertexed with tracks " << importedTrackCollection);
360 std::unique_ptr<xAOD::Vertex> myVxCandidate{
fit(theTracks,importedTrackCollection)};
361 if (myVxCandidate != 0) {
362
363 double chi2 = myVxCandidate->chiSquared();
366
367 xAOD::BPhysHelper jpsiHelper(myVxCandidate.get());
368 jpsiHelper.setRefTrks();
370 std::vector<const xAOD::Electron*> theStoredElectrons;
371 theStoredElectrons.push_back((*jpsiItr).el1);
372 if (
m_elel) theStoredElectrons.push_back((*jpsiItr).el2);
373 jpsiHelper.setElectrons(theStoredElectrons,importedElectronCollection);
374 }
375
376 vxContainer.
push_back(std::move(myVxCandidate));
377 }
378 } else {
380
381
382
383 }
384 }
386
387 return StatusCode::SUCCESS;;
388 }
bool passesEgammaCuts(const xAOD::Electron *) const
std::vector< JpsiEECandidate > getPairs(const std::vector< const xAOD::TrackParticle * > &) const
std::vector< JpsiEECandidate > selectCharges(const std::vector< JpsiEECandidate > &, const std::string &) const
xAOD::Vertex * fit(const std::vector< const xAOD::TrackParticle * > &, const xAOD::TrackParticleContainer *importedTrackCollection) 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
Test to see if the link can be dereferenced.
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".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".