5#include "GaudiKernel/SystemOfUnits.h"
20 const std::string & name,
21 const IInterface* parent )
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) {
57 sprintf(buf1,
"%f5.2",
m_ptBins[j][i]);
58 sprintf(buf2,
"%f5.2",
m_ptBins[j][i+1]);
60 <<
": with Pt Threshold of " << (
m_ptThresholds[j][i])/Gaudi::Units::GeV
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)
220 if ( std::abs(pMuon->pt()) > (
threshold/Gaudi::Units::GeV)){
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"
233 <<
" and threshold cut is " <<
threshold/Gaudi::Units::GeV <<
" 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 = 1e-6;
254 for(
int i=0;i<8;++i)
if(fabs(i*step-
phi)<=Dphi)
256 Dphi=fabs(i*step-
phi);
257 sign = (fabs(Dphi) > ZEROLIMIT) ? (i*step-
phi)/fabs(i*step-
phi) : 0;
262 for(
int i=1;i<8;++i)
if(fabs(i*step+offs-
phi)<=Dphi)
264 Dphi=fabs(i*step+offs-
phi);
265 sign = (fabs(Dphi) > ZEROLIMIT) ? (i*step+offs-
phi)/fabs(i*step+offs-
phi) : 0;
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 ) {
399 input.emplace_back(&i);
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++){
446 bool overlapped =
isOverlap((*input[i]).muFast, (*input[j]).muFast);
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 = 1e-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 = 1e-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) ) {
571 double absEta = (fabs(mf1->
pt()) > fabs(mf2->
pt())) ? fabs(mf1->
etaMS()) : fabs(mf2->
etaMS());
572 unsigned int iThres=0;
573 for(
unsigned int i=0; i<(
m_etaBinsEC.size()-1); i++) {
585 bool sameSign =
false;
587 sameSign = ((mf1->
pt()*mf2->
pt()) > 0) ? true :
false;
592 bool dRisClose =
false;
597 const double monitor_limit = 1e-4;
598 double dr_mon = (dr>=monitor_limit) ? dr : monitor_limit;
599 mufastDRLog10 = log10(dr_mon);
602 if( dr < dRThres ) dRisClose =
true;
603 ATH_MSG_DEBUG(
" ...-> dR=" << dr <<
" : dRisClose=" << dRisClose );
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;
618 ATH_MSG_DEBUG(
" ...-> mass=" << mass <<
" : massIsClose=" << massIsClose );
622 bool overlap =
false;
640 const double deta = eta1 - eta2;
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++) {
700 ATH_MSG_DEBUG(
"++ i=" << i <<
": result=" << mufastResult[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;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Header file to be included by clients of the Monitored infrastructure.
static const Attributes_t empty
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
int sAddress() const
Get the station address of the muon.
float etaMS() const
Get the eta at muon spectrometer.
float phiMS() const
Get the phi at muon spectrometer.
virtual double pt() const
The transverse momentum ( ) of the particle.
T deltaPhi(T phiA, T phiB)
Return difference phiA - phiB in range [-pi, pi].
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
void elementsInUniqueCombinations(const Index2DVec &indices, std::set< size_t > &participants, const std::function< bool(const Index1DVec &)> &filter)
std::vector< Index1DVec > Index2DVec
std::vector< size_t > Index1DVec
Unique combinations for case when one can not repeat the index (i.e.
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
ECRegions whichECRegion(const float eta, const float phi)
L2StandAloneMuon_v2 L2StandAloneMuon
Define the latest version of the muon SA class.
Helper for azimuthal angle calculations.