5 #include "GaudiKernel/SystemOfUnits.h"
20 const std::string &
name,
47 for (
size_t j=0; j<
m_ptBins.size(); ++j) {
51 return StatusCode::SUCCESS;
54 for (std::vector<float>::size_type
i=0;
i<
m_bins[j];++
i) {
84 return StatusCode::FAILURE;
98 return StatusCode::FAILURE;
114 return StatusCode::SUCCESS;
134 xatStation, yatStation, zatStation,
139 auto roiDescriptor =
input.roi;
141 <<
", Eta = " << roiDescriptor->eta()
142 <<
", Phi = " << roiDescriptor->phi());
148 ATH_MSG_DEBUG(
"Accept property is set: taking all the events");
152 ATH_MSG_DEBUG(
"Accept property not set: applying selection!");
156 auto pMuon =
input.muFast;
160 ATH_MSG_ERROR(
"Retrieval of L2StandAloneMuon from vector failed");
165 fexPt = (pMuon->pt())? pMuon->pt() : -9999.;
166 fexEta = (pMuon->etaMS())? pMuon->etaMS() : -9999.;
167 fexPhi = (pMuon->etaMS())? pMuon->phiMS() : -9999.;
168 fexPtFL = (pMuon->pt())? pMuon->pt() : -9999.;
170 if( pMuon->etaMS() ) {
171 float localPhi =
getLocalPhi(pMuon->etaMS(),pMuon->phiMS(),pMuon->rMS());
172 float radius = pMuon->rMS()/
cos(fabs(localPhi));
173 float DirZ = (pMuon->dirZMS())? pMuon->dirZMS() : .000001;
174 float DirF = (pMuon->dirPhiMS())? pMuon->dirPhiMS() : .000001;
175 xatStation =
radius *
cos(pMuon->phiMS());
176 yatStation =
radius *
sin(pMuon->phiMS());
177 zatStation = pMuon->zMS();
178 float xb = xatStation - yatStation/DirF;
179 float de = xatStation -
xb;
180 float ds = sqrt(yatStation*yatStation+de*de);
182 zatBeam = zatStation -
ds*DirZ;
199 float absEta = fabs(fexEta);
200 for (std::vector<float>::size_type
i=0;
i<
m_bins[0]; ++
i)
223 if((fabs(xatBeam)<
m_RPV) && (fabs(zatBeam)<
m_ZPV))
230 if (
result ) fexPtFL = -9999.;
232 ATH_MSG_DEBUG(
"REGTEST: Muon pt is " << pMuon->pt() <<
" GeV"
234 <<
" so hypothesis is " << (
result?
"true":
"false"));
244 if(
phi<0.)
phi += 2*3.14159265;
245 float step = 0.78539816;
246 float offs = 0.39269908;
249 float Dphi = 999999.;
251 const float ZEROLIMIT = 1
e-6;
262 for(
int i=1;
i<8;++
i)
if(fabs(
i*
step+offs-
phi)<=Dphi)
280 size_t numTrigger =
m_ptBins.size();
281 size_t numMuon = toolInput.size();
282 ATH_MSG_DEBUG(
"Retrieved from TrigMufastHypoAlg and Running TrigMufastHypoTool for selections.");
284 if ( numTrigger == 1 ) {
298 return StatusCode::SUCCESS;
304 for (
auto&
i: toolInput ) {
318 return StatusCode::SUCCESS;
326 for (
size_t cutIndex=0; cutIndex <
m_ptBins.size(); ++cutIndex ) {
327 size_t elementIndex{ 0 };
328 for (
auto&
i: toolInput ) {
340 passingSelection[cutIndex].push_back( elementIndex );
351 if ( passingSelection[cutIndex].
empty() ) {
352 ATH_MSG_DEBUG(
"No object passed selection " << cutIndex <<
" rejecting" );
353 return StatusCode::SUCCESS;
357 std::set<size_t> passingIndices;
360 std::set<const xAOD::L2StandAloneMuon*> setOfClusters;
361 for (
auto index: comb ) {
362 setOfClusters.insert( toolInput[
index].muFast );
364 return setOfClusters.size() == comb.size();
373 if ( passingIndices.empty() ) {
375 return StatusCode::SUCCESS;
378 for (
auto idx: passingIndices ) {
380 <<
" with pT = " << toolInput[
idx].muFast->pt() <<
"GeV" );
384 return StatusCode::SUCCESS;
394 std::vector<TrigMufastHypoTool::MuonClusterInfo*>
input;
396 for (
auto&
i: toolInput ) {
403 size_t numMuon =
input.size();
409 ATH_MSG_DEBUG(
"No positive previous hypo decision. Not need overlap removal." );
410 mufastNrActiveEVs = numMuon;
411 mufastNrAllEVs = numMuon;
412 return StatusCode::SUCCESS;
414 else if ( numMuon == 1 ) {
416 ATH_MSG_DEBUG(
"no overlap Removal necessary. exitting with all EventViews active." );
417 mufastNrActiveEVs = numMuon;
418 mufastNrAllEVs = numMuon;
419 return StatusCode::SUCCESS;
422 mufastNrAllEVs = numMuon;
424 return StatusCode::SUCCESS;
428 return StatusCode::SUCCESS;
436 size_t numMuon =
input.size();
438 std::vector<unsigned int> mufastResult;
440 bool errorWhenIdentifyingOverlap =
false;
442 for(
i=0;
i<numMuon;
i++) {mufastResult.emplace_back(
i); }
443 for(
i=0;
i<numMuon-1;
i++){
444 for(j=
i+1; j<numMuon; j++){
449 if( mufastResult[
i] == mufastResult[j] ) {
450 ATH_MSG_DEBUG(
"inconsistentency in muFast overlap removal for more than two objects" );
451 ATH_MSG_DEBUG(
"two objects are judged as different but both were already marked as identical by someone else as: " );
452 ATH_MSG_DEBUG(
"i/j/result[i]/result[j]=" <<
i <<
" / " << j <<
" / " << mufastResult[
i] <<
" / " << mufastResult[j] );
456 errorWhenIdentifyingOverlap =
true;
460 if( (mufastResult[j] != j && mufastResult[
i] != mufastResult[j]) || (mufastResult[j] == j && mufastResult[
i] !=
i) ){
461 ATH_MSG_DEBUG(
"inconsistentency in muFast overlap removal for more than two objects" );
462 ATH_MSG_DEBUG(
"two objects are judged as overlap but only either was already marked as overlap to someone else: " );
463 ATH_MSG_DEBUG(
"i/j/result[i]/result[j]=" <<
i <<
" / " << j <<
" / " << mufastResult[
i] <<
" / " << mufastResult[j] );
467 errorWhenIdentifyingOverlap =
true;
470 if( mufastResult[
i] ==
i ) {
471 ATH_MSG_DEBUG(
" i is not yet marked as overlap. so, it is a newly found overlap" );
475 ATH_MSG_DEBUG(
" both i/j already marked as overlap by: mufastResult[i]=" << mufastResult[
i] );
482 if( errorWhenIdentifyingOverlap ) {
483 ATH_MSG_WARNING(
"error when resolving overlap. exitting with all EVs active..." );
486 mufastNrActiveEVs = numMuon;
488 return StatusCode::SUCCESS;
491 unsigned int n_uniqueMuon = 0;
492 for(
i=0;
i<numMuon;
i++) {
494 if( mufastResult[
i] !=
i ) {
ATH_MSG_DEBUG(
" overlap to j=" << mufastResult[
i] ); }
501 ATH_MSG_DEBUG(
"nr of unique Muons after muFast overlap removal=" << n_uniqueMuon );
503 if( numMuon != n_uniqueMuon ){
506 ATH_MSG_DEBUG(
"no overlap identified. exitting with all EventViews active" );
509 mufastNrActiveEVs = n_uniqueMuon;
512 return StatusCode::SUCCESS;
534 const double ZERO_LIMIT_FOR_ETAPHI = 1
e-4;
535 if( (fabs(mf1->
etaMS()) <ZERO_LIMIT_FOR_ETAPHI && fabs(mf1->
phiMS()) < ZERO_LIMIT_FOR_ETAPHI) ||
536 (fabs(mf2->
etaMS()) <ZERO_LIMIT_FOR_ETAPHI && fabs(mf2->
phiMS()) < ZERO_LIMIT_FOR_ETAPHI) ) {
537 ATH_MSG_DEBUG(
" ...-> (eta,phi) info not available (rec at (eta,phi)=(0,0))" );
538 ATH_MSG_DEBUG(
" ...-> but dR of invMass check is required. cannot judge overlap -> return with false" );
543 const double ZERO_LIMIT_FOR_PT = 1
e-4;
544 if( (fabs(mf1->
pt()) <ZERO_LIMIT_FOR_PT) || (fabs(mf2->
pt()) < ZERO_LIMIT_FOR_PT) ) {
545 ATH_MSG_DEBUG(
" ...-> pT info not available (rec at pT=0)" );
546 ATH_MSG_DEBUG(
" ...-> but same sign or invMass check is required. cannot judge overlap -> return with false" );
552 double dRThres = 9999;
553 double massThres = 9999;
555 const int SADDRESS_EC = -1;
556 bool isBarrel1 = (mf1->
sAddress() != SADDRESS_EC ) ?
true :
false;
557 bool isBarrel2 = (mf2->
sAddress() != SADDRESS_EC ) ?
true :
false;
559 if( isBarrel1 && isBarrel2 ) {
564 else if( (isBarrel1 && ! isBarrel2) || (!isBarrel1 && isBarrel2) ) {
572 unsigned int iThres=0;
585 bool sameSign =
false;
587 sameSign = ((mf1->
pt()*mf2->
pt()) > 0) ? true :
false;
592 bool dRisClose =
false;
597 const double monitor_limit = 1
e-4;
598 double dr_mon = (
dr>=monitor_limit) ?
dr : monitor_limit;
599 mufastDRLog10 = log10(dr_mon);
602 if(
dr < dRThres ) dRisClose =
true;
607 const double TRACK_MASS = 0;
608 bool massIsClose =
false;
613 double mass_mon = (
mass>=monitor_limit) ?
mass : monitor_limit;
614 mufastMassLog10 = log10(mass_mon);
617 if(
mass < massThres ) massIsClose =
true;
622 bool overlap =
false;
642 return std::sqrt(deta*deta + dphi*dphi);
649 double m2,
double pt2,
double eta2,
double phi2)
const
653 double theta1 = 2*atan2((
double)
exp(-
eta1),1.);
654 double theta2 = 2*atan2((
double)
exp(-
eta2),1.);
656 double fpt1 = fabs(pt1);
657 double fpt2 = fabs(pt2);
659 double px1 = fpt1*
cos(phi1);
660 double py1 = fpt1*
sin(phi1);
661 double pz1 = fpt1/
tan(theta1);
662 double e1 = sqrt(px1*px1+py1*py1+pz1*pz1+
m1*
m1);
664 double px2 = fpt2*
cos(phi2);
665 double py2 = fpt2*
sin(phi2);
666 double pz2 = fpt2/
tan(theta2);
667 double e2 = sqrt(px2*px2+py2*py2+pz2*pz2+
m2*
m2);
669 double pxsum = px1 + px2;
670 double pysum = py1 + py2;
671 double pzsum = pz1 + pz2;
672 double esum =
e1 +
e2;
675 double mass2 = esum*esum - pxsum*pxsum - pysum*pysum - pzsum*pzsum;
686 size_t numMuon =
input.size();
696 mufastOverlappedPt, mufastOverlappedEta, mufastOverlappedPhi);
698 ATH_MSG_DEBUG(
"--- choose best among overlaps & disable EVs (muFast based) ---" );
699 for(
i=0;
i<numMuon;
i++) {
701 if( mufastResult[
i] !=
i ) {
702 ATH_MSG_DEBUG(
" overlap to some one. already the best one was chosen. skip." );
705 std::vector<unsigned int> others;
706 for(j=0; j<numMuon; j++) {
707 if( mufastResult[j] == mufastResult[
i] ) others.emplace_back(j);
709 if( others.size() == 1 ) {
716 unsigned int best_ev = 0;
719 for(
k=0;
k<others.size();
k++) {
724 float ptMf = fabs(
mf->pt());
725 float ptRoI =
mf->roiThreshold();
726 ATH_MSG_DEBUG(
" ev/PtRoI/ptMf="<< j <<
"/" << ptRoI <<
"/" << ptMf);
727 if( (ptRoI-maxPtRoI) > 0.1 ) {
732 else if( fabs(ptRoI-maxPtRoI) < 0.1 ) {
733 if( ptMf > maxPtMf ) {
740 ATH_MSG_DEBUG(
" best is: best_ev/maxPtRoI/maxPtMf=" << best_ev <<
" / " << maxPtRoI <<
" / " << maxPtMf );
742 for(
k=0;
k<others.size();
k++) {
745 ATH_MSG_DEBUG(
" EventView( j=" << j <<
" ) is not active" );
751 ++mufastNrOverlapped;
752 mufastOverlappedPt =
mf->pt();
753 mufastOverlappedEta =
mf->etaMS();
754 mufastOverlappedPhi =
mf->phiMS();
762 mufastNrActiveEVs = numMuon - mufastNrOverlapped;
764 return StatusCode::SUCCESS;