5#include "GaudiKernel/SystemOfUnits.h"
22 return StatusCode::FAILURE;
30 ATH_MSG_ERROR(
"Trying to configure hypo with no pT bins. This is probably a configuration mistake.");
31 return StatusCode::FAILURE;
34 for(
size_t j=0; j<
m_ptBins.size(); j++){
38 return StatusCode::FAILURE;
41 for (std::vector<float>::size_type i=0; i<
m_bins[j];++i) {
57 if(
m_doSA)
m_type = xAOD::Muon::TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle;
58 else m_type = xAOD::Muon::TrackParticleType::CombinedTrackParticle;
60 return StatusCode::SUCCESS;
65 std::vector<float> fexPt, fexEta, fexPhi, selPt, selEta, selPhi;
72 auto monitorIt =
Monitored::Group(
m_monTool, muonPtMon, muonEtaMon, muonPhiMon, muonPtSelMon, muonEtaSelMon, muonPhiSelMon);
77 ATH_MSG_DEBUG(
"Accept property is set: taking all the events");
88 if (muon->primaryTrackParticle()) {
93 ATH_MSG_DEBUG(
"Retrieved Track track with abs pt "<< (*tr).pt()/Gaudi::Units::GeV <<
" GeV ");
95 fexPt.push_back(tr->
pt()/Gaudi::Units::GeV);
96 fexEta.push_back(tr->
eta());
97 fexPhi.push_back(tr->
phi());
99 float absEta = std::abs(tr->
eta());
101 for (std::vector<float>::size_type k=0; k<
m_bins[cutIndex]; ++k) {
104 if (std::abs(tr->
pt())/Gaudi::Units::GeV > (
threshold/Gaudi::Units::GeV)){
110 uint8_t nGoodPrcLayers=0;
112 ATH_MSG_DEBUG(
"No numberOfGoodPrecisionLayers variable found; not passing hypo");
115 if(std::abs(muon->eta()) > 1.3) {
117 if(nGoodPrcLayers < 2){
118 ATH_MSG_DEBUG(
"Muon has less than two GoodPrecisionLayers; not passing hypo (requrement loosend according to absence of NSW)");
122 if(nGoodPrcLayers < 3){
123 ATH_MSG_DEBUG(
"Muon has less than three GoodPrecisionLayers; not passing hypo");
127 }
else if (std::abs(muon->eta()) > 1.05) {
128 if(nGoodPrcLayers < 3){
129 ATH_MSG_DEBUG(
"Muon has less than three GoodPrecisionLayers; not passing hypo");
140 selPt.push_back(tr->
pt()/Gaudi::Units::GeV);
141 selEta.push_back(tr->
eta());
142 selPhi.push_back(tr->
phi());
145 ATH_MSG_DEBUG(
" REGTEST muon pt is " << tr->
pt()/Gaudi::Units::GeV <<
" GeV "
146 <<
" with Charge " << tr->
charge()
147 <<
" and threshold cut is " <<
threshold/Gaudi::Units::GeV <<
" GeV"
148 <<
" so hypothesis is " << (
result?
"true":
"false"));
150 ATH_MSG_DEBUG(
" REGTEST muon pt is " << tr->
pt()/Gaudi::Units::GeV <<
" GeV "
151 <<
" with Charge " << tr->
charge()
152 <<
" and with d0 " << tr->
d0()
153 <<
" the threshold cut is " <<
threshold/Gaudi::Units::GeV <<
" GeV"
154 <<
" and d0min cut is " <<
m_d0min<<
" mm"
155 <<
" so hypothesis is " << (
result?
"true":
"false"));
163 bool passCut =
false;
164 const xAOD::TrackParticle* idtrack = muon->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
165 const xAOD::TrackParticle* metrack = muon->trackParticle( xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle );
166 float mePt = -999999., idPt = -999999.;
168 float reducedChi2 = -10, qOverPsignif = -10;
170 if(idtrack && metrack) {
171 mePt = metrack->
pt();
172 idPt = idtrack->
pt();
173 float meP = 1.0 / ( sin(metrack->
theta()) / mePt);
174 float idP = 1.0 / ( sin(idtrack->
theta()) / idPt);
176 reducedChi2 = muon->primaryTrackParticle()->chiSquared()/muon->primaryTrackParticle()->numberDoF();
178 if(std::abs(reducedChi2) < 8.0 && !
m_muonSelTool->isBadMuon(*muon) && qOverPsignif<7.0 && muon->author()==xAOD::Muon::MuidCo) passCut =
true;
185 size_t numTrigger =
m_ptBins.size();
186 size_t numMuon=toolInput.size();
195 return StatusCode::SUCCESS;
198 for (
uint i=0; i<toolInput.size(); i++){
199 auto& tool = toolInput.at(i);
201 bool overlap =
false;
203 for(
uint j=i+1; j<toolInput.size();j++){
204 auto& tool2 = toolInput.at(j);
206 if(tool2.muon->p4()==tool.muon->p4()) overlap=
true;
209 if(overlap)
continue;
218 return StatusCode::SUCCESS;
222 bool passingNscan=
false;
223 for(
size_t cutIndex=0; cutIndex <
m_ptBins.size(); ++cutIndex) {
224 size_t elementIndex{0};
225 for(
auto& tool : toolInput){
228 if(
m_nscan && cutIndex==0 && (!passingNscan)){
231 unsigned int nInCone=0;
232 float muonR = sqrt(
pow(tool.muon->eta(),2) +
pow(tool.muon->phi(),2));
234 for (
auto& tooltmp : toolInput){
235 ATH_MSG_DEBUG(
">>Testing Muon with pt: "<<tooltmp.muon->pt()/Gaudi::Units::GeV <<
"GeV, eta: "
236 << tooltmp.muon->eta() <<
", phi: " << tooltmp.muon->phi());
237 if (tooltmp.muon->p4() == tool.muon->p4()) {
240 deta = std::abs(tooltmp.muon->eta()-tool.muon->eta());
241 dphi =
getdphi(tooltmp.muon->phi(),tool.muon->phi());
242 if(deta<coneCheck && dphi<coneCheck){
255 ATH_MSG_DEBUG(
"Passes narrow-scan selection Index["<<elementIndex<<
"]");
257 }
else ATH_MSG_DEBUG(
"Does not pass narrow-scan selection Index["<<elementIndex<<
"]");
260 passingSelection[cutIndex].push_back(elementIndex);
269 if (
m_nscan &&(!passingNscan)){
270 ATH_MSG_DEBUG(
"Narrow-scan is required and no muons passed, all muons will be rejected ");
271 return StatusCode::SUCCESS;
274 if(passingSelection[cutIndex].
empty()){
275 ATH_MSG_DEBUG(
"No muons passed the selection "<<cutIndex<<
" rejecting...");
276 return StatusCode::SUCCESS;
279 std::set<size_t> passingIndices;
282 std::set<const xAOD::Muon*> setOfMuons;
283 for (
auto index : comb){
284 setOfMuons.insert(toolInput[
index].muon);
286 return setOfMuons.size()==comb.size();
294 if(passingIndices.empty()){
296 return StatusCode::SUCCESS;
298 for(
auto i : passingIndices){
302 return StatusCode::SUCCESS;
305 float dphi = phi1-phi2;
306 if(dphi > TMath::Pi()) dphi -= TMath::TwoPi();
307 if(dphi < -1*TMath::Pi()) dphi += TMath::TwoPi();
#define ATH_CHECK
Evaluate an expression and check for errors.
Header file to be included by clients of the Monitored infrastructure.
static const Attributes_t empty
constexpr int pow(int base, int exp) noexcept
bool msgLvl(const MSG::Level lvl) const
Group of local monitoring quantities and retain correlation when filling histograms
float theta() const
Returns the parameter, which has range 0 to .
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
const ParametersCovMatrix_t definingParametersCovMatrix() const
Returns the 5x5 symmetric matrix containing the defining parameters covariance matrix.
float d0() const
Returns the parameter.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
float charge() const
Returns the charge.
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.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
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.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Muon_v1 Muon
Reference the current persistent version:
@ numberOfGoodPrecisionLayers
layers with at least 3 hits that are not deweighted [uint8_t]