29 const std::string&
name,
33 , m_trackFitter(
"Trk::GlobalChi2Fitter/InDetTrackFitter")
34 , m_inputMuonCollection(
"MuidMuonCollection")
35 , m_inputTracksCollection(
"Tracks")
37 , m_nCBMuonsHasEXandID(0)
38 , m_nCBMuonsPassSelection(0)
39 , m_nCBMuonsFailedRefit(0)
40 , m_nCBMuonsSucRefit(0)
55 , m_ptID_constrained{}
56 , m_IDEta_constrained{}
57 , m_IDPhi_constrained{}
58 , m_charge_constrained{}
76 declareInterface<ITrackCollectionProvider>(
this);
78 declareProperty(
"TrackFitter", m_trackFitter );
79 declareProperty(
"InputMuonCollection", m_inputMuonCollection );
80 declareProperty(
"InputTracksCollection", m_inputTracksCollection );
81 declareProperty(
"RunOutlierRemoval", m_runOutlierRemoval =
true );
82 declareProperty(
"MaxRetrievalErrors", m_maxRetrievalErrors = 10 );
83 declareProperty(
"UseMSConstraintTrkOnly", m_useMSConstraintTrkOnly =
true );
84 declareProperty(
"DoTree", m_doTree =
true );
85 declareProperty(
"MinPt", m_minPt = 15.0 );
86 declareProperty(
"MinPIXHits", m_minPIXHits = 1 );
87 declareProperty(
"MinSCTHits", m_minSCTHits = 6 );
88 declareProperty(
"MinTRTHits", m_minTRTHits = 0 );
89 declareProperty(
"MaxIDd0", m_maxIDd0 = 500. );
90 declareProperty(
"MaxIDz0", m_maxIDz0 = 500. );
91 declareProperty(
"MinIDPt", m_minIDPt = 10 );
92 declareProperty(
"MDTHits", m_minMDTHits = 15 );
93 declareProperty(
"MinRPCPhiHits", m_minRPCPhiHits = 0 );
94 declareProperty(
"MinTGCPhiHits", m_minTGCPhiHits = 0 );
95 declareProperty(
"MaxMSd0", m_maxMSd0 = 500. );
96 declareProperty(
"MaxMSz0", m_maxMSz0 = 500. );
97 declareProperty(
"MinMSPt", m_minMSPt = 0 );
98 declareProperty(
"MaxNumberOfSectors", m_maxNumberOfSectors = 1 );
99 declareProperty(
"MinNumberOfPhiLayers", m_minNumberOfPhiLayers = 2 );
100 declareProperty(
"MinStationLayers", m_minStationLayers = 3 );
117 return StatusCode::SUCCESS;
137 m_tree =
new TTree(
"MSMomentumConstraint",
"MSMomentumConstraint");
245 success =
m_tree->Write();
247 return success>0 ? StatusCode::SUCCESS : StatusCode::FAILURE;
255 return StatusCode::SUCCESS;
261 const Trk::Perigee* IDTrkMeasuredPerigee =
dynamic_cast<const Trk::Perigee*
>(& (
it->inDetTrackParticle()->definingParameters()));
262 if(!IDTrkMeasuredPerigee){
263 ATH_MSG_DEBUG(
"NO inDetTrackParticle or no IDTrkMeasuredPerigee");
267 const Trk::Perigee* METrkMeasuredPerigee =
dynamic_cast<const Trk::Perigee*
>(&(
it->muonExtrapolatedTrackParticle()->definingParameters()));
268 if(!METrkMeasuredPerigee){
269 ATH_MSG_DEBUG(
"NO muonExtrapolatedTrackParticle or no METrkMeasuredPerigee");
273 const double pt = fabs(
it->pt())/1000.;
274 const double eta = fabs(
it->eta());
279 (eta > 0.8 && eta < 1.2) ){
280 ATH_MSG_DEBUG(
" this combinedMuon not pass basic pt and eta cuts --- pt: "<<
pt <<
" eta: " << eta);
284 const int nPixHits =
it->numberOfPixelHits();
294 const double idQoverPatIP = IDTrkMeasuredPerigee->parameters()[
Trk::qOverP] * 1000.;
295 const double idz0atIP = IDTrkMeasuredPerigee->parameters()[
Trk::z0];
296 const double idd0atIP = IDTrkMeasuredPerigee->parameters()[
Trk::d0];
297 double ptIDatIP = 0.;
298 if ( idQoverPatIP != 0 ) ptIDatIP = fabs(1.0/idQoverPatIP)*
sin(IDTrkMeasuredPerigee->parameters()[
Trk::theta]);
309 ATH_MSG_DEBUG(
"this combined muon not pass ID cuts --- nPixHits: " << nPixHits <<
" nSCTHits: " <<
nSCTHits <<
310 "nTRTHits: " <<
nTRTHits <<
" idd0atIP: " << idd0atIP <<
" idz0atIP: " << idz0atIP <<
" ptIDatIP: " << ptIDatIP );
316 const int nMDTHits =
it->numberOfMDTHits();
317 const int nRPCPhiHits =
it->numberOfRPCPhiHits();
318 const int nTGCPhiHits =
it->numberOfTGCPhiHits();
320 const double msQoverPatIP = METrkMeasuredPerigee->parameters()[
Trk::qOverP] * 1000.;
321 const double msz0atIP = METrkMeasuredPerigee->parameters()[
Trk::z0];
322 const double msd0atIP = METrkMeasuredPerigee->parameters()[
Trk::d0];
324 double ptMSatIP = 0.;
325 if ( msQoverPatIP != 0 ) ptMSatIP = fabs(1.0/msQoverPatIP)*
sin(METrkMeasuredPerigee->parameters()[
Trk::theta]);
338 ATH_MSG_DEBUG(
"this combined muon not pass MS cuts --- nMDTHits: " << nMDTHits <<
" nRPCPhiHits: " << nRPCPhiHits <<
339 " nTGCPhiHits: " << nTGCPhiHits <<
" msd0atIP: " << msd0atIP <<
340 " msz0atIP: " << msz0atIP <<
" pMSatIP:" << ptMSatIP);
349 if (aTrackParticle) aTrack = aTrackParticle->
originalTrack();
351 if (aTrack && aTrack !=
it->inDetTrkTrack()) {
356 std::vector<const Muon::MuonSegment*> segments;
357 unsigned int nSeg =
it->numberOfSegments();
358 segments.reserve(nSeg);
359 for(
unsigned int si=0; si<nSeg; ++si ){
361 if( seg ) segments.push_back(seg);
367 const int sectors =
summary.sectors.size();
368 const int phiLayers =
summary.phiLayers.size();
369 const int stationLayers =
summary.stationLayers.size();
376 ATH_MSG_DEBUG(
"this combined muon not pass muonHitSummary cuts --- sectors: "<< sectors <<
" phiLayers: "<< phiLayers <<
" stationLayers: " << stationLayers);
381 m_pID =
it->inDetTrackParticle()->p();
382 m_pMS =
it->muonExtrapolatedTrackParticle()->p();
383 m_ptID =
it->inDetTrackParticle()->pt();
384 m_ptMS =
it->muonExtrapolatedTrackParticle()->pt();
385 m_charge =
it->inDetTrackParticle()->charge();
388 m_IDEta =
it->inDetTrackParticle()->eta();
390 m_IDPhi =
it->inDetTrackParticle()->phi();
414 originalTracks =
nullptr;
419 ATH_MSG_WARNING(
"One probability is that you are not running on ESD/DESD ");
423 originalTracks =
nullptr;
431 return StatusCode::SUCCESS;
439 int goodQualityCombinedMuon = 0;
441 for ( ; combinedTrackIt != combinedTrackItE; ++combinedTrackIt ) {
444 if (
muon->isCombinedMuon() &&
muon->hasMuonExtrapolatedTrackParticle() &&
muon->hasInDetTrackParticle() ){
447 ATH_MSG_DEBUG(
"have good quality combined Muons of the event: " << ++goodQualityCombinedMuon);
449 const Trk::Perigee* METrkMeasuredPerigee =
dynamic_cast<const Trk::Perigee*
>(&(
muon->muonExtrapolatedTrackParticle()->definingParameters()));
450 if(!METrkMeasuredPerigee){
451 ATH_MSG_DEBUG(
"NO muonExtrapolatedTrackParticle or no METrkMeasuredPerigee");
462 if(!IDTrkMeasuredPerigee){
463 ATH_MSG_DEBUG(
"NO inDetTrackParticle or no IDTrkMeasuredPerigee");
469 std::vector<Trk::DefinedParameter> parFromMSVec;
470 parFromMSVec.push_back( qOverPFromMS) ;
475 auto pmot = std::make_unique<Trk::PseudoMeasurementOnTrack>(
478 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
479 trackStateOnSurfaces->reserve(
muon->inDetTrackParticle()->originalTrack()->trackStateOnSurfaces()->size() + 1);
482 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
type;
485 const Perigee* IDPerigeeParameters =
muon->inDetTrackParticle()->originalTrack()->perigeeParameters();
487 auto IDPerigeeParametersClone =
488 (IDPerigeeParameters)
489 ? std::make_unique<Perigee>(*IDPerigeeParameters)
492 if(IDPerigeeParameters && IDPerigeeParametersClone ){
493 trackStateOnSurfaces->push_back(
new const Trk::TrackStateOnSurface(std::move(pmot), std::move(IDPerigeeParametersClone),
nullptr,
type));
495 for ( ;
sb !=
muon->inDetTrackParticle()->originalTrack()->trackStateOnSurfaces()->end(); ++
sb) trackStateOnSurfaces->push_back((**sb).clone());
498 muon->inDetTrackParticle()->originalTrack()->info(),
499 std::move(trackStateOnSurfaces),
506 if(!MSConstraintFittedTrack){
511 ATH_MSG_WARNING(
"Try to push the originalIDTrack into the trackCollection");
513 if(IDOriginalTrackClone){
517 "IDOriginalTrackClone parameters --- pt: "
518 << fabs(1. / (aMeasPerClone->parameters()[
Trk::qOverP])) *
520 <<
" d0: " << aMeasPerClone->parameters()[
Trk::d0]);
523 if(!IDOriginalTrackClone){
540 delete MSConstraintFittedTrackClone;
551 ATH_MSG_WARNING(
"failed in IDPerigeeParameters or IDPerigeeParametersClone !");
559 ATH_MSG_WARNING(
"problem with recording MSMomentumConstraintTracks to StoreGate!");
560 return StatusCode::SUCCESS;
569 return StatusCode::SUCCESS;
577 *
m_logStream<<
"*************************************************************"<<std::endl;
578 *
m_logStream<<
"****** MSConstraintTracksProvider Summary ******"<<std::endl;