ATLAS Offline Software
Loading...
Searching...
No Matches
Analysis::JpsiFinder Class Reference

#include <JpsiFinder.h>

Inheritance diagram for Analysis::JpsiFinder:
Collaboration diagram for Analysis::JpsiFinder:

Public Member Functions

 JpsiFinder (const std::string &t, const std::string &n, const IInterface *p)
 ~JpsiFinder ()
virtual StatusCode initialize () override
virtual StatusCode performSearch (const EventContext &ctx, xAOD::VertexContainer &vxContainer) const override
std::vector< JpsiCandidategetPairs (const std::vector< const xAOD::TrackParticle * > &) const
std::vector< JpsiCandidategetPairs (const std::vector< const xAOD::Muon * > &) const
std::vector< JpsiCandidategetPairs2Colls (const std::vector< const xAOD::TrackParticle * > &, const std::vector< const xAOD::Muon * > &, bool) const
double getInvariantMass (const JpsiCandidate &, std::span< const double >) const
std::vector< JpsiCandidateselectCharges (const std::vector< JpsiCandidate > &) const
std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &, const xAOD::TrackParticleContainer *importedTrackCollection) const
bool passesMCPCuts (const xAOD::Muon *) const
bool isContainedIn (const xAOD::TrackParticle *, const xAOD::TrackParticleContainer *) const

Private Attributes

bool m_mumu
bool m_mutrk
bool m_trktrk
bool m_allMuons
bool m_combOnly
bool m_atLeastOneComb
bool m_useCombMeasurement
bool m_diMuons
double m_trk1M
double m_trk2M
double m_thresholdPt
double m_higherPt
double m_trkThresholdPt
double m_invMassUpper
double m_invMassLower
double m_collAngleTheta
double m_collAnglePhi
double m_Chi2Cut
bool m_oppChOnly
bool m_sameChOnly
bool m_allChCombs
SG::ReadHandleKey< xAOD::MuonContainerm_muonCollectionKey {this, "muonCollectionKey", "Muons"}
SG::ReadHandleKey< xAOD::TrackParticleContainerm_TrkParticleCollection {this, "TrackParticleCollection", "InDetTrackParticles" }
SG::ReadHandleKeyArray< xAOD::TrackParticleContainerm_MuonTrackKeys {this, "MuonTrackKeys", {}}
PublicToolHandle< Trk::IVertexFitterm_iVertexFitter {this, "TrkVertexFitterTool", "Trk::TrkVKalVrtFitter"}
PublicToolHandle< Trk::ITrackSelectorToolm_trkSelector {this, "TrackSelectorTool", "InDet::TrackSelectorTool"}
PublicToolHandle< InDet::VertexPointEstimatorm_vertexEstimator {this, "VertexPointEstimator", "InDet::VertexPointEstimator"}
std::shared_ptr< GenDatam_gendata {nullptr}
bool m_mcpCuts
bool m_doTagAndProbe
bool m_forceTagAndProbe

Detailed Description

Definition at line 48 of file JpsiFinder.h.

Constructor & Destructor Documentation

◆ JpsiFinder()

Analysis::JpsiFinder::JpsiFinder ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 95 of file JpsiFinder.cxx.

95 : base_class(t,n,p),
96 m_mumu(true),
97 m_mutrk(false),
98 m_trktrk(false),
99 m_allMuons(false),
100 m_combOnly(false),
101 m_atLeastOneComb(true),
103 m_diMuons(true),
106 m_thresholdPt(0.0),
107 m_higherPt(0.0),
108 m_trkThresholdPt(0.0),
109 m_invMassUpper(100000.0),
110 m_invMassLower(0.0),
111 m_collAngleTheta(0.0),
112 m_collAnglePhi(0.0),
113 m_Chi2Cut(50.),
114 m_oppChOnly(true),
115 m_sameChOnly(false),
116 m_allChCombs(false),
117 m_mcpCuts(true),
118 m_doTagAndProbe(false),
119 m_forceTagAndProbe(false) //forcing T&P method for any charge combinations
120
121 {
122 declareProperty("muAndMu",m_mumu);
123 declareProperty("muAndTrack",m_mutrk);
124 declareProperty("TrackAndTrack",m_trktrk);
125 declareProperty("allMuons",m_allMuons);
126 declareProperty("combOnly",m_combOnly);
127 declareProperty("atLeastOneComb",m_atLeastOneComb);
128 declareProperty("useCombinedMeasurement",m_useCombMeasurement);
129 declareProperty("assumeDiMuons",m_diMuons);
130 declareProperty("track1Mass",m_trk1M);
131 declareProperty("track2Mass",m_trk2M);
132 declareProperty("muonThresholdPt",m_thresholdPt);
133 declareProperty("higherPt",m_higherPt);
134 declareProperty("trackThresholdPt",m_trkThresholdPt);
135 declareProperty("invMassUpper",m_invMassUpper);
136 declareProperty("invMassLower",m_invMassLower);
137 declareProperty("collAngleTheta",m_collAngleTheta);
138 declareProperty("collAnglePhi",m_collAnglePhi);
139 declareProperty("Chi2Cut",m_Chi2Cut);
140 declareProperty("oppChargesOnly",m_oppChOnly);
141 declareProperty("sameChargesOnly",m_sameChOnly);
142 declareProperty("allChargeCombinations",m_allChCombs);
143 declareProperty("useMCPCuts",m_mcpCuts);
144 declareProperty("doTagAndProbe",m_doTagAndProbe);
145 declareProperty("forceTagAndProbe",m_forceTagAndProbe);
146 }
constexpr double muonMassInMeV
the mass of the muon (in MeV)

◆ ~JpsiFinder()

Analysis::JpsiFinder::~JpsiFinder ( )

Definition at line 148 of file JpsiFinder.cxx.

148{ }

Member Function Documentation

◆ fit()

std::unique_ptr< xAOD::Vertex > Analysis::JpsiFinder::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & inputTracks,
const xAOD::TrackParticleContainer * importedTrackCollection ) const

Definition at line 400 of file JpsiFinder.cxx.

402 {
403
404
405 const Trk::Perigee& aPerigee1 = inputTracks[0]->perigeeParameters();
406 const Trk::Perigee& aPerigee2 = inputTracks[1]->perigeeParameters();
407 int sflag = 0;
408 int errorcode = 0;
409 Amg::Vector3D startingPoint = m_vertexEstimator->getCirclesIntersectionPoint(&aPerigee1,&aPerigee2,sflag,errorcode);
410 if (errorcode != 0) {startingPoint(0) = 0.0; startingPoint(1) = 0.0; startingPoint(2) = 0.0;}
411
412 auto myVxCandidate = m_iVertexFitter->fit(ctx, inputTracks, startingPoint);
413
414 // Added by ASC
415 if(myVxCandidate != 0){
416 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
417 for(unsigned int i=0; i< myVxCandidate->trackParticleLinks().size(); i++)
418 {
419 ElementLink<DataVector<xAOD::TrackParticle> > mylink=myVxCandidate->trackParticleLinks()[i]; //makes a copy (non-const)
420 mylink.setStorableObject(*importedTrackCollection, true);
421 newLinkVector.push_back( std::move(mylink) );
422 }
423 myVxCandidate->clearTracks();
424 myVxCandidate->setTrackParticleLinks( newLinkVector );
425 }
426
427
428 return myVxCandidate;
429
430 } // End of fit method
size_t size() const
Number of registered mappings.
PublicToolHandle< InDet::VertexPointEstimator > m_vertexEstimator
Definition JpsiFinder.h:96
PublicToolHandle< Trk::IVertexFitter > m_iVertexFitter
Definition JpsiFinder.h:94
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee

◆ getInvariantMass()

double Analysis::JpsiFinder::getInvariantMass ( const JpsiCandidate & jpsiIn,
std::span< const double > massHypotheses ) const

Definition at line 542 of file JpsiFinder.cxx.

542 {
543
544 // construct 4-vectors from track perigee parameters using given mass hypotheses.
545 // NOTE: in new data model (xAOD) the defining parameters are expressed as perigee parameters w.r.t. the beamspot
546 // NOTE2: TrackParticle::p4() method already returns TLorentzVector, however, we want to enforce our own mass hypothesis
547 auto mu1 = jpsiIn.trackParticle1->genvecP4();
548 auto mu2 = jpsiIn.trackParticle2->genvecP4();
549 mu1.SetM(massHypotheses[0]);
550 mu2.SetM(massHypotheses[1]);
551
552 return (mu1+mu2).M();
553
554 }

◆ getPairs() [1/2]

std::vector< JpsiCandidate > Analysis::JpsiFinder::getPairs ( const std::vector< const xAOD::Muon * > & ) const

◆ getPairs() [2/2]

std::vector< JpsiCandidate > Analysis::JpsiFinder::getPairs ( const std::vector< const xAOD::TrackParticle * > & TracksIn) const

Definition at line 439 of file JpsiFinder.cxx.

439 {
440
441 std::vector<JpsiCandidate> myPairs;
442 JpsiCandidate pair;
443 std::vector<const xAOD::TrackParticle*>::const_iterator outerItr;
444 std::vector<const xAOD::TrackParticle*>::const_iterator innerItr;
445
446 if(TracksIn.size()>=2){
447 myPairs.reserve((TracksIn.size() * (TracksIn.size() - 1)) / 2);
448 for(outerItr=TracksIn.begin();outerItr<TracksIn.end();++outerItr){
449 for(innerItr=(outerItr+1);innerItr!=TracksIn.end();++innerItr){
450 pair.trackParticle1 = *innerItr;
451 pair.trackParticle2 = *outerItr;
452 pair.pairType = TRKTRK;
453 myPairs.push_back(pair);
454 }
455 }
456 }
457
458 return(myPairs);
459 }

◆ getPairs2Colls()

std::vector< JpsiCandidate > Analysis::JpsiFinder::getPairs2Colls ( const std::vector< const xAOD::TrackParticle * > & tracks,
const std::vector< const xAOD::Muon * > & muons,
bool tagAndProbe ) const

Definition at line 498 of file JpsiFinder.cxx.

498 {
499
500 std::vector<JpsiCandidate> myPairs;
501 JpsiCandidate pair;
502
503 // Unless user is running in tag and probe mode, remove tracks which are also identified as muons
504 std::vector<const xAOD::TrackParticle*> tracksToKeep;
505 if (!tagAndProbe) {
506 if(tracks.size()>=1 && muons.size()>=1){
507 for (const xAOD::TrackParticle* trk : tracks) {
508 if (std::find_if(muons.begin(), muons.end(),
509 [trk](const xAOD::Muon* mu) {
510 return mu->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle) == trk;
511 }) == muons.end()) {
512 tracksToKeep.push_back(trk);
513 }
514 }
515 }
516 } else {tracksToKeep = tracks;}
517
518 if(tracksToKeep.size()>=1 && muons.size()>=1){
519 for (const xAOD::TrackParticle* trk : tracksToKeep) {
520 for (const xAOD::Muon* mu : muons) {
521 pair.muon1 = mu;
522 // Muon track 1st
523 pair.trackParticle1 = mu->trackParticle( xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle );
524 pair.trackParticle2 = trk;
525 pair.pairType = MUTRK;
526 myPairs.push_back(pair);
527 }
528 }
529 }
530
531 return(myPairs);
532 }
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Muon_v1 Muon
Reference the current persistent version:

◆ initialize()

StatusCode Analysis::JpsiFinder::initialize ( )
overridevirtual

Definition at line 27 of file JpsiFinder.cxx.

27 {
28
29 // retrieving vertex Fitter
30 ATH_CHECK(m_iVertexFitter.retrieve());
31
32 // Get the track selector tool from ToolSvc
33 ATH_CHECK(m_trkSelector.retrieve());
34
35 // Get the vertex point estimator tool from ToolSvc
36 ATH_CHECK(m_vertexEstimator.retrieve());
37
38
39 ATH_CHECK(m_muonCollectionKey.initialize());
41 ATH_CHECK(m_MuonTrackKeys.initialize(m_MuonTrackKeys.size() != 0));
42 m_gendata = std::make_shared<GenData>();
43
44 if (m_diMuons) {
45 const double muMass = m_gendata->particleMass(MC::MUON).value_or(ParticleConstants::muonMassInMeV);
48 }
49
50 if (m_doTagAndProbe) ATH_MSG_WARNING("You have requested tag and probe mode. Duplicate mu+trk pairs WILL be allowed, charge ordering WILL NOT be done. Tag track will be first in each candidate");
51
52
53// // Check that the user's settings are sensible
54 bool illogicalOptions(false);
55 if ( (m_mumu && m_mutrk) || (m_mumu && m_trktrk) || (m_mutrk && m_trktrk) ) {
56 ATH_MSG_WARNING("You are requesting incompatible combinations of muons and tracks in the pairs. JpsiCandidates will be EMPTY!");
57 illogicalOptions=true;
58 };
60 ATH_MSG_WARNING("You are requesting Tag and Probe analysis but have not requested mu+trk mode. This is impossible. JpsiCandidates will be EMPTY!");
61 illogicalOptions=true;
62 };
63 if ( (m_mutrk || m_trktrk ) && m_useCombMeasurement ) {
64 ATH_MSG_WARNING("You are requesting a combined muon measurement to be used with pairs involving non-muon tracks. Not permitted. JpsiCandidates will be EMPTY!");
65 illogicalOptions=true;
66 };
68 ATH_MSG_WARNING("You are requesting incompatible combinations of combined muons non-combined muons in the pairs. JpsiCandidates will be EMPTY!");
69 illogicalOptions=true;
70 };
72 ATH_MSG_WARNING("You are requesting at least one muon to be combined in a tag and probe analysis. This doesn't make sense. JpsiCandidates will be EMPTY!");
73 illogicalOptions=true;
74 };
76 ATH_MSG_WARNING("You are requesting incompatible combinations of charges in the pairs. JpsiCandidates will be EMPTY!");
77 illogicalOptions=true;
78 };
80 if (!m_forceTagAndProbe){ //if m_forceTagAndProbe=TRUE then T&P will work with any charge combinations
81 ATH_MSG_WARNING("You are requesting same-sign or all-sign combinations in a tag and probe analysis. This doesn't make sense. JpsiCandidates will be EMPTY!");
82 illogicalOptions=true;
83 }
84 }
85 if (illogicalOptions) return StatusCode::FAILURE;;
86
87
88 ATH_MSG_DEBUG("Initialize successful");
89
90 return StatusCode::SUCCESS;
91
92 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_MuonTrackKeys
Definition JpsiFinder.h:93
PublicToolHandle< Trk::ITrackSelectorTool > m_trkSelector
Definition JpsiFinder.h:95
std::shared_ptr< GenData > m_gendata
Definition JpsiFinder.h:97
SG::ReadHandleKey< xAOD::MuonContainer > m_muonCollectionKey
Definition JpsiFinder.h:91
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkParticleCollection
Definition JpsiFinder.h:92
constexpr double muMass
static const int MUON

◆ isContainedIn()

bool Analysis::JpsiFinder::isContainedIn ( const xAOD::TrackParticle * theTrack,
const xAOD::TrackParticleContainer * theCollection ) const

Definition at line 612 of file JpsiFinder.cxx.

612 {
613 return std::find(theCollection->begin(), theCollection->end(), theTrack) != theCollection->end();
614 }
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.

◆ passesMCPCuts()

bool Analysis::JpsiFinder::passesMCPCuts ( const xAOD::Muon * muon) const

Definition at line 602 of file JpsiFinder.cxx.

602 {
603
604 return muon->passesIDCuts();
605
606 }

◆ performSearch()

StatusCode Analysis::JpsiFinder::performSearch ( const EventContext & ctx,
xAOD::VertexContainer & vxContainer ) const
overridevirtual

Definition at line 153 of file JpsiFinder.cxx.

154 {
155 ATH_MSG_DEBUG( "JpsiFinder::performSearch" );
156
157 SG::ReadHandle<xAOD::MuonContainer> muonhandle(m_muonCollectionKey,ctx);
158 if(!muonhandle.isValid()){
159 ATH_MSG_ERROR("Could not retrieve " << m_muonCollectionKey.key());
160 return StatusCode::FAILURE;
161 }
162 // Get the muons from StoreGate
163 const xAOD::MuonContainer* importedMuonCollection = muonhandle.cptr();
164 ATH_MSG_DEBUG("Muon container size "<<importedMuonCollection->size());
165
166 // Get muon tracks if combined measurement requested
167 std::vector<const xAOD::TrackParticleContainer*> importedMuonTrackCollections;
169
170 for (SG::ReadHandle<xAOD::TrackParticleContainer>& handle: m_MuonTrackKeys.makeHandles(ctx)) {
171 if(!handle.isValid()){
172 ATH_MSG_WARNING("No muon TrackParticle collection with name " << handle.key() << " found in StoreGate!");
173 return StatusCode::FAILURE;
174 } else {
175 ATH_MSG_DEBUG("Found muon TrackParticle collection " << handle.key() << " in StoreGate!");
176 ATH_MSG_DEBUG("Muon TrackParticle container size "<< handle->size());
177 importedMuonTrackCollections.push_back(handle.cptr());
178 }
179 }
180 }
181
182 // Get ID tracks
183 SG::ReadHandle<xAOD::TrackParticleContainer> handle(m_TrkParticleCollection,ctx);
184 const xAOD::TrackParticleContainer* importedTrackCollection{nullptr};
185 if(!handle.isValid()){
186 ATH_MSG_WARNING("No TrackParticle collection with name " << handle.key() << " found in StoreGate!");
187 return StatusCode::FAILURE;
188 } else {
189 importedTrackCollection = handle.cptr();
190 ATH_MSG_DEBUG("Found TrackParticle collection " << handle.key() << " in StoreGate!");
191 }
192 ATH_MSG_DEBUG("ID TrackParticle container size "<< handle->size());
193
194 // Typedef for vectors of tracks and muons
195 typedef std::vector<const xAOD::TrackParticle*> TrackBag;
196 typedef std::vector<const xAOD::Muon*> MuonBag;
197
198 // Select the inner detector tracks
199 const xAOD::Vertex* vx = nullptr;
200 TrackBag theIDTracksAfterSelection;
201 if (m_trktrk || m_mutrk) {
203 for (trkCItr=importedTrackCollection->begin(); trkCItr!=importedTrackCollection->end(); ++trkCItr) {
204 const xAOD::TrackParticle* TP = (*trkCItr);
205 if ( fabs(TP->pt())<m_trkThresholdPt ) continue;
206 if ( !m_trkSelector->decision(*TP, vx) ) continue;
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 // Select the muons
214 MuonBag theMuonsAfterSelection;
215 if (m_mumu || m_mutrk) {
216 for (auto muItr=importedMuonCollection->begin(); muItr!=importedMuonCollection->end(); ++muItr) {
217 if ( *muItr == nullptr ) continue;
218 const xAOD::TrackParticle* muonTrk = (*muItr)->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
219 if ( muonTrk==NULL) continue;
220 if ( !m_trkSelector->decision(*muonTrk, vx) ) continue; // all ID tracks must pass basic tracking cuts
221 if ( fabs(muonTrk->pt())<m_thresholdPt ) continue; // higher pt cut if needed
222 if ( m_mcpCuts && !passesMCPCuts(*muItr)) continue; // MCP cuts
223 if ( m_combOnly && (*muItr)->muonType() != xAOD::Muon::MuonType::Combined ) continue; // require combined muons
224 if ( (*muItr)->muonType() == xAOD::Muon::MuonType::SiliconAssociatedForwardMuon && !m_useCombMeasurement) continue;
225 theMuonsAfterSelection.push_back(*muItr);
226 }
227 if (theMuonsAfterSelection.size() == 0) return StatusCode::SUCCESS;;
228 ATH_MSG_DEBUG("Number of muons after selection: " << theMuonsAfterSelection.size());
229 }
230
231 // Sort into pairs - end result will be a vector of JpsiCandidate structs
232 std::vector<JpsiCandidate> jpsiCandidates;
233 if (m_mumu) jpsiCandidates = getPairs(theMuonsAfterSelection);
234 if (m_trktrk) jpsiCandidates = getPairs(theIDTracksAfterSelection);
235 if (m_mutrk) jpsiCandidates = getPairs2Colls(theIDTracksAfterSelection,theMuonsAfterSelection,m_doTagAndProbe);
236
237
238 // (1) Enforce one combined muon
239 if (m_atLeastOneComb) {
240 std::vector<JpsiCandidate> selectCandidates;
241 for(auto &cand : jpsiCandidates) { if(cand.muonTypes!=TT) selectCandidates.push_back(cand); }
242 selectCandidates.swap(jpsiCandidates);
243 ATH_MSG_DEBUG("Number of candidates after requirement of at least 1 combined muon: " << jpsiCandidates.size() );
244 }
245
246 // (2) Establish track content for candidates
247 // and set the appropriate track collections for the combined muon tracks where appropriate (for saving to persistency later)
248
249 // mu+trk or trk+trk - always ID track collection
250 if (m_mutrk || m_trktrk) {
251 for (auto jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
252 (*jpsiItr).collection1 = importedTrackCollection;
253 (*jpsiItr).collection2 = importedTrackCollection;
254 }
255 }
256
257 if (m_mumu) {
258 using enum xAOD::Muon::TrackParticleType;
259 for (auto jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
261 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle(InnerDetectorTrackParticle);
262 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(InnerDetectorTrackParticle);
263 (*jpsiItr).collection1 = importedTrackCollection;
264 (*jpsiItr).collection2 = importedTrackCollection;
265 }
267 if (!(*jpsiItr).muon1->trackParticle(CombinedTrackParticle)) {
268 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle(InnerDetectorTrackParticle );
269 (*jpsiItr).collection1 = importedTrackCollection;
270 }
271
272 if (!(*jpsiItr).muon2->trackParticle(CombinedTrackParticle)) {
273 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(InnerDetectorTrackParticle );
274 (*jpsiItr).collection2 = importedTrackCollection;
275 }
276
277 if ((*jpsiItr).muon1->trackParticle(CombinedTrackParticle)) {
278 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle(CombinedTrackParticle);
279 bool foundCollection(false);
280 // Look for correct muon track container
281 for (auto muTrkCollItr=importedMuonTrackCollections.begin(); muTrkCollItr!=importedMuonTrackCollections.end(); ++muTrkCollItr) {
282 if (isContainedIn((*jpsiItr).trackParticle1,*muTrkCollItr)) { (*jpsiItr).collection1 = *muTrkCollItr; foundCollection=true; break;}
283 }
284 if (!foundCollection) { // didn't find the correct muon track container so go back to ID
285 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle( InnerDetectorTrackParticle );
286 (*jpsiItr).collection1 = importedTrackCollection;
287 ATH_MSG_WARNING("Muon track from muon of author " << (*jpsiItr).muon1->author() << " not found in muon track collections you have provided.");
288 ATH_MSG_WARNING("Defaulting to ID track collection - combined measurement will not be used");
289 }
290 }
291
292 if ((*jpsiItr).muon2->trackParticle(CombinedTrackParticle)) {
293 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(CombinedTrackParticle );
294 bool foundCollection(false);
295 // Look for correct muon track container
296 for (auto muTrkCollItr=importedMuonTrackCollections.begin(); muTrkCollItr!=importedMuonTrackCollections.end(); ++muTrkCollItr) {
297 if (isContainedIn((*jpsiItr).trackParticle2,*muTrkCollItr)) { (*jpsiItr).collection2 = *muTrkCollItr; foundCollection=true; break;}
298 }
299 if (!foundCollection) { // didn't find the correct muon track container so go back to ID
300 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(InnerDetectorTrackParticle);
301 (*jpsiItr).collection2 = importedTrackCollection;
302 ATH_MSG_WARNING("Muon track from muon of author " << (*jpsiItr).muon2->author() << " not found in muon track collections you have provided.");
303 ATH_MSG_WARNING("Defaulting to ID track collection - combined measurement will not be used");
304 }
305 }
306 } // combined measurement
307 } // iteration over candidates
308 }
309
310
311 // (3) Enforce higher track pt if requested
312 if (m_higherPt>0.0) {
313 std::vector<JpsiCandidate> selectCandidates;
314 for(auto& cand : jpsiCandidates){
315 bool reject = (fabs(cand.trackParticle1->pt()) < m_higherPt) && (fabs(cand.trackParticle2->pt()) < m_higherPt);
316 if(!reject) selectCandidates.push_back(cand);
317 }
318 selectCandidates.swap(jpsiCandidates);
319 ATH_MSG_DEBUG("Number of candidates after higherPt cut: " << jpsiCandidates.size() );
320 }
321
322 // (4) Select all opp/same charged track pairs
323 std::vector<JpsiCandidate> sortedJpsiCandidates;
324 sortedJpsiCandidates = selectCharges(jpsiCandidates);
325
326 ATH_MSG_DEBUG("Number of candidates after charge selection: " << sortedJpsiCandidates.size() );
327
328 // (5) Select for decay angle, if requested
329 if (m_collAnglePhi>0.0 && m_collAngleTheta>0.0) {
330 std::vector<JpsiCandidate> selectCandidates;
331 for(auto& cand : sortedJpsiCandidates){
332 double deltatheta = fabs( cand.trackParticle1->theta() - cand.trackParticle2->theta() );
333 double deltaphi = std::abs(xAOD::P4Helpers::deltaPhi(cand.trackParticle1->phi0() , cand.trackParticle2->phi0()));
334 bool reject = (deltatheta > m_collAngleTheta) || (deltaphi > m_collAnglePhi);
335 if(!reject) selectCandidates.push_back(cand);
336 }
337 sortedJpsiCandidates.swap(selectCandidates);
338 ATH_MSG_DEBUG("Number of collimated candidates: " << sortedJpsiCandidates.size() );
339 }
340
341 // (6) Select for invariant mass, if requested
342 std::array<double,2> trkMasses{m_trk1M, m_trk2M};
343 if ( (m_invMassLower > 0.0) || (m_invMassUpper > 0.0) ) {
344 std::vector<JpsiCandidate> selectCandidates;
345 for(auto& cand : sortedJpsiCandidates){
346 double invMass = getInvariantMass(cand,trkMasses);
347 bool reject = invMass < m_invMassLower || invMass > m_invMassUpper;
348 if(!reject) selectCandidates.push_back(cand);
349 }
350 selectCandidates.swap(sortedJpsiCandidates);
351 ATH_MSG_DEBUG("Number of candidates passing invariant mass selection: " << sortedJpsiCandidates.size() );
352 }
353
354 ATH_MSG_DEBUG("Number of pairs passing all selections and going to vertexing: " << sortedJpsiCandidates.size() );
355 if (sortedJpsiCandidates.size() == 0) return StatusCode::SUCCESS;;
356 std::vector<const xAOD::TrackParticle*> theTracks;
357 std::vector<const xAOD::Muon*> theStoredMuons;
358 // Fit each pair of tracks to a vertex
359 for(auto jpsiItr=sortedJpsiCandidates.begin(); jpsiItr!=sortedJpsiCandidates.end(); ++jpsiItr) {
360 theTracks.clear();
361 theTracks.push_back((*jpsiItr).trackParticle1);
362 theTracks.push_back((*jpsiItr).trackParticle2);
363 std::unique_ptr<xAOD::Vertex> myVxCandidate {fit(ctx, theTracks,importedTrackCollection)}; // This line actually does the fitting and object making
364 if (myVxCandidate) {
365 // Chi2 cut if requested
366 double chi2 = myVxCandidate->chiSquared();
367 ATH_MSG_DEBUG("chi2 is: " << chi2);
368 if (m_Chi2Cut <= 0.0 || chi2 <= m_Chi2Cut) {
369 // decorate the candidate with refitted tracks and muons via the BPhysHelper
370 xAOD::BPhysHelper jpsiHelper(myVxCandidate.get());
371 bool validtrk = jpsiHelper.setRefTrks();
372 if(!validtrk) ATH_MSG_WARNING("Problem setting tracks " << __FILE__ << ':' << __LINE__);
373 if (m_mumu || m_mutrk) {
374 theStoredMuons.clear();
375 theStoredMuons.push_back((*jpsiItr).muon1);
376 if (m_mumu) theStoredMuons.push_back((*jpsiItr).muon2);
377 bool valid = jpsiHelper.setMuons(theStoredMuons,importedMuonCollection);
378 if(!valid) ATH_MSG_WARNING("Problem setting muons " << __FILE__ << ':' << __LINE__);
379 }
380 // Retain the vertex
381 vxContainer.push_back(std::move(myVxCandidate));
382 }
383 } else { // fit failed
384 ATH_MSG_DEBUG("Fitter failed!");
385 // Don't try to delete the object, since we arrived here,
386 // because this pointer is null...
387 }
388 }
389 ATH_MSG_DEBUG("vxContainer size " << vxContainer.size());
390
391 return StatusCode::SUCCESS;;
392 }
#define ATH_MSG_ERROR(x)
std::vector< JpsiCandidate > getPairs(const std::vector< const xAOD::TrackParticle * > &) const
std::vector< JpsiCandidate > getPairs2Colls(const std::vector< const xAOD::TrackParticle * > &, const std::vector< const xAOD::Muon * > &, bool) const
bool passesMCPCuts(const xAOD::Muon *) const
std::vector< JpsiCandidate > selectCharges(const std::vector< JpsiCandidate > &) const
bool isContainedIn(const xAOD::TrackParticle *, const xAOD::TrackParticleContainer *) const
double getInvariantMass(const JpsiCandidate &, std::span< const double >) const
std::unique_ptr< xAOD::Vertex > fit(const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &, const xAOD::TrackParticleContainer *importedTrackCollection) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
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.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
double chi2(TH1 *h0, TH1 *h1)
virtual void handle(const Incident &inc)
Handle end of run incidents to save the metadata at that point.
std::vector< const xAOD::TrackParticle * > TrackBag
double invMass(const I4Momentum &pA, const I4Momentum &pB)
invariant mass from two I4momentum references
Definition P4Helpers.h:252
list valid
Definition calibdata.py:44
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".

◆ selectCharges()

std::vector< JpsiCandidate > Analysis::JpsiFinder::selectCharges ( const std::vector< JpsiCandidate > & jpsisIn) const

Definition at line 562 of file JpsiFinder.cxx.

562 {
563
564 bool opposite(false),same(false),all(false);
565 opposite=m_oppChOnly;
568
569 JpsiCandidate tmpJpsi;
570 std::vector<JpsiCandidate> jpsis;
571 double qOverP1=0.;
572 double qOverP2=0.;
573 for(auto jpsiItr=jpsisIn.cbegin();jpsiItr!=jpsisIn.cend();jpsiItr++){
574 bool oppCh(false),sameCh(false);
575 tmpJpsi = *jpsiItr;
576 qOverP1=(*jpsiItr).trackParticle1->qOverP();
577 qOverP2=(*jpsiItr).trackParticle2->qOverP();
578 if(qOverP1*qOverP2<0.0) oppCh=true; // product charge < 0
579 if(qOverP1*qOverP2>0.0) sameCh=true; // product charge > 0
580 // +ve should be first so swap
581 // Don't do it for tag and probe analyses (because tag muon must not change position)
582 if (oppCh && qOverP1<0.0 && !m_doTagAndProbe && !m_mutrk) {
583 tmpJpsi.trackParticle1 = (*jpsiItr).trackParticle2;
584 tmpJpsi.trackParticle2 = (*jpsiItr).trackParticle1;
585 tmpJpsi.muon1 = (*jpsiItr).muon2;
586 tmpJpsi.muon2 = (*jpsiItr).muon1;
587 tmpJpsi.collection1 = (*jpsiItr).collection2;
588 tmpJpsi.collection2 = (*jpsiItr).collection1;
589 }
590 if (oppCh && (opposite || all) ) jpsis.push_back(tmpJpsi);
591 if (sameCh && (same || all) ) jpsis.push_back(tmpJpsi);
592
593 } // end of for loop
594
595 return(jpsis);
596 }

Member Data Documentation

◆ m_allChCombs

bool Analysis::JpsiFinder::m_allChCombs
private

Definition at line 90 of file JpsiFinder.h.

◆ m_allMuons

bool Analysis::JpsiFinder::m_allMuons
private

Definition at line 73 of file JpsiFinder.h.

◆ m_atLeastOneComb

bool Analysis::JpsiFinder::m_atLeastOneComb
private

Definition at line 75 of file JpsiFinder.h.

◆ m_Chi2Cut

double Analysis::JpsiFinder::m_Chi2Cut
private

Definition at line 87 of file JpsiFinder.h.

◆ m_collAnglePhi

double Analysis::JpsiFinder::m_collAnglePhi
private

Definition at line 86 of file JpsiFinder.h.

◆ m_collAngleTheta

double Analysis::JpsiFinder::m_collAngleTheta
private

Definition at line 85 of file JpsiFinder.h.

◆ m_combOnly

bool Analysis::JpsiFinder::m_combOnly
private

Definition at line 74 of file JpsiFinder.h.

◆ m_diMuons

bool Analysis::JpsiFinder::m_diMuons
private

Definition at line 77 of file JpsiFinder.h.

◆ m_doTagAndProbe

bool Analysis::JpsiFinder::m_doTagAndProbe
private

Definition at line 99 of file JpsiFinder.h.

◆ m_forceTagAndProbe

bool Analysis::JpsiFinder::m_forceTagAndProbe
private

Definition at line 100 of file JpsiFinder.h.

◆ m_gendata

std::shared_ptr<GenData> Analysis::JpsiFinder::m_gendata {nullptr}
private

Definition at line 97 of file JpsiFinder.h.

97{nullptr};

◆ m_higherPt

double Analysis::JpsiFinder::m_higherPt
private

Definition at line 81 of file JpsiFinder.h.

◆ m_invMassLower

double Analysis::JpsiFinder::m_invMassLower
private

Definition at line 84 of file JpsiFinder.h.

◆ m_invMassUpper

double Analysis::JpsiFinder::m_invMassUpper
private

Definition at line 83 of file JpsiFinder.h.

◆ m_iVertexFitter

PublicToolHandle< Trk::IVertexFitter > Analysis::JpsiFinder::m_iVertexFitter {this, "TrkVertexFitterTool", "Trk::TrkVKalVrtFitter"}
private

Definition at line 94 of file JpsiFinder.h.

94{this, "TrkVertexFitterTool", "Trk::TrkVKalVrtFitter"};

◆ m_mcpCuts

bool Analysis::JpsiFinder::m_mcpCuts
private

Definition at line 98 of file JpsiFinder.h.

◆ m_mumu

bool Analysis::JpsiFinder::m_mumu
private

Definition at line 70 of file JpsiFinder.h.

◆ m_muonCollectionKey

SG::ReadHandleKey<xAOD::MuonContainer> Analysis::JpsiFinder::m_muonCollectionKey {this, "muonCollectionKey", "Muons"}
private

Definition at line 91 of file JpsiFinder.h.

91{this, "muonCollectionKey", "Muons"};

◆ m_MuonTrackKeys

SG::ReadHandleKeyArray<xAOD::TrackParticleContainer> Analysis::JpsiFinder::m_MuonTrackKeys {this, "MuonTrackKeys", {}}
private

Definition at line 93 of file JpsiFinder.h.

93{this, "MuonTrackKeys", {}};

◆ m_mutrk

bool Analysis::JpsiFinder::m_mutrk
private

Definition at line 71 of file JpsiFinder.h.

◆ m_oppChOnly

bool Analysis::JpsiFinder::m_oppChOnly
private

Definition at line 88 of file JpsiFinder.h.

◆ m_sameChOnly

bool Analysis::JpsiFinder::m_sameChOnly
private

Definition at line 89 of file JpsiFinder.h.

◆ m_thresholdPt

double Analysis::JpsiFinder::m_thresholdPt
private

Definition at line 80 of file JpsiFinder.h.

◆ m_trk1M

double Analysis::JpsiFinder::m_trk1M
private

Definition at line 78 of file JpsiFinder.h.

◆ m_trk2M

double Analysis::JpsiFinder::m_trk2M
private

Definition at line 79 of file JpsiFinder.h.

◆ m_TrkParticleCollection

SG::ReadHandleKey<xAOD::TrackParticleContainer> Analysis::JpsiFinder::m_TrkParticleCollection {this, "TrackParticleCollection", "InDetTrackParticles" }
private

Definition at line 92 of file JpsiFinder.h.

92{this, "TrackParticleCollection", "InDetTrackParticles" };

◆ m_trkSelector

PublicToolHandle< Trk::ITrackSelectorTool > Analysis::JpsiFinder::m_trkSelector {this, "TrackSelectorTool", "InDet::TrackSelectorTool"}
private

Definition at line 95 of file JpsiFinder.h.

95{this, "TrackSelectorTool", "InDet::TrackSelectorTool"};

◆ m_trkThresholdPt

double Analysis::JpsiFinder::m_trkThresholdPt
private

Definition at line 82 of file JpsiFinder.h.

◆ m_trktrk

bool Analysis::JpsiFinder::m_trktrk
private

Definition at line 72 of file JpsiFinder.h.

◆ m_useCombMeasurement

bool Analysis::JpsiFinder::m_useCombMeasurement
private

Definition at line 76 of file JpsiFinder.h.

◆ m_vertexEstimator

PublicToolHandle< InDet::VertexPointEstimator > Analysis::JpsiFinder::m_vertexEstimator {this, "VertexPointEstimator", "InDet::VertexPointEstimator"}
private

Definition at line 96 of file JpsiFinder.h.

96{this, "VertexPointEstimator", "InDet::VertexPointEstimator"};

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