From 02f8db91d828fc505fce4a971dc9a68655887deb Mon Sep 17 00:00:00 2001 From: ktaniguc <guchiwo7@gmail.com> Date: Tue, 10 Nov 2020 15:02:18 +0900 Subject: [PATCH] make MuFast reentrant (ver2) --- .../TrigL2MuonSA/RpcDataPreparator.h | 1 + .../TrigL2MuonSA/src/MuFastDataPreparator.cxx | 9 ++- .../TrigL2MuonSA/src/RpcDataPreparator.cxx | 5 +- .../TrigL2MuonSA/src/RpcPatFinder.cxx | 81 +++++++++---------- .../TrigL2MuonSA/src/RpcPatFinder.h | 50 ++++++++---- .../TrigL2MuonSA/src/RpcRoadDefiner.cxx | 25 +++--- .../TrigL2MuonSA/src/RpcRoadDefiner.h | 21 ++--- 7 files changed, 111 insertions(+), 81 deletions(-) diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/TrigL2MuonSA/RpcDataPreparator.h b/Trigger/TrigAlgorithms/TrigL2MuonSA/TrigL2MuonSA/RpcDataPreparator.h index 8859ec8d763a..cd110eaf8d52 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/TrigL2MuonSA/RpcDataPreparator.h +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/TrigL2MuonSA/RpcDataPreparator.h @@ -53,6 +53,7 @@ class RpcDataPreparator: public AthAlgTool StatusCode prepareData(const TrigRoiDescriptor* p_roids, unsigned int roiWord, TrigL2MuonSA::RpcHits& rpcHits, + TrigL2MuonSA::RpcLayerHits& rpcLayerHits, ToolHandle<RpcPatFinder>* rpcPatFinder); bool isFakeRoi() { return m_isFakeRoi; } diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastDataPreparator.cxx b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastDataPreparator.cxx index d963f8605498..cff3a1859580 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastDataPreparator.cxx +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastDataPreparator.cxx @@ -184,16 +184,20 @@ StatusCode TrigL2MuonSA::MuFastDataPreparator::prepareData(const LVL1::RecMuonRo ATH_MSG_DEBUG("RoI eta/phi=" << p_roi->eta() << "/" << p_roi->phi()); StatusCode sc = StatusCode::SUCCESS; + + //Storing rpc hits by each layers and eta/phi strip for creating road + //RpcLayerHits class is defined in RpcPatFinder.h + TrigL2MuonSA::RpcLayerHits rpcLayerHits; + rpcLayerHits.clear(); if(m_use_rpc && !insideOut) { - m_rpcPatFinder->clear(); - m_rpcDataPreparator->setMultiMuonTrigger(m_doMultiMuon); unsigned int roiWord = p_roi->roiWord(); sc = m_rpcDataPreparator->prepareData(p_roids, roiWord, rpcHits, + rpcLayerHits, &m_rpcPatFinder); // check if the RoI is fake and se the flag @@ -223,6 +227,7 @@ StatusCode TrigL2MuonSA::MuFastDataPreparator::prepareData(const LVL1::RecMuonRo insideOut, muonRoad, rpcHits, + rpcLayerHits, &m_rpcPatFinder, rpcFitResult, roiEtaMinLow, diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcDataPreparator.cxx b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcDataPreparator.cxx index 77bc3e8b0d15..605e44f10483 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcDataPreparator.cxx +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcDataPreparator.cxx @@ -84,6 +84,7 @@ void TrigL2MuonSA::RpcDataPreparator::setMultiMuonTrigger( const bool multiMuonT StatusCode TrigL2MuonSA::RpcDataPreparator::prepareData(const TrigRoiDescriptor* p_roids, unsigned int roiWord, TrigL2MuonSA::RpcHits& rpcHits, + TrigL2MuonSA::RpcLayerHits& rpcLayerHits, ToolHandle<RpcPatFinder>* rpcPatFinder) { // RPC data extraction referring TrigMuonEFStandaloneTrackTool and MuonHoughPatternFinderTool @@ -293,10 +294,10 @@ StatusCode TrigL2MuonSA::RpcDataPreparator::prepareData(const TrigRoiDescriptor* if (m_use_RoIBasedDataAccess) { if ( deta<deta_thr && dphi<dphi_thr) - (*rpcPatFinder)->addHit(stationName, stationEta, measuresPhi, gasGap, doubletR, hitx, hity, hitz); + (*rpcPatFinder)->addHit(stationName, stationEta, measuresPhi, gasGap, doubletR, hitx, hity, hitz, rpcLayerHits); } else { if ( deta<0.15 && dphi<0.1) - (*rpcPatFinder)->addHit(stationName, stationEta, measuresPhi, gasGap, doubletR, hitx, hity, hitz); + (*rpcPatFinder)->addHit(stationName, stationEta, measuresPhi, gasGap, doubletR, hitx, hity, hitz, rpcLayerHits); } } } diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcPatFinder.cxx b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcPatFinder.cxx index 0912ffd9edb2..28ac5c63d053 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcPatFinder.cxx +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcPatFinder.cxx @@ -25,20 +25,6 @@ TrigL2MuonSA::RpcPatFinder::RpcPatFinder(const std::string& type, // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- -void TrigL2MuonSA::RpcPatFinder::clear() { - std::list<double> z; - z.clear(); - m_hits_in_layer_eta.assign(8,z); - m_hits_in_layer_phi.assign(8,z); - std::vector<double> zz; - zz.clear(); - m_hits_in_layer_R.assign(8,zz); - m_hits_in_layer_Z.assign(8,zz); -} - -// -------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------- - void TrigL2MuonSA::RpcPatFinder::addHit(std::string stationName, int stationEta, bool measuresPhi, @@ -46,7 +32,8 @@ void TrigL2MuonSA::RpcPatFinder::addHit(std::string stationName, unsigned int doubletR, double gPosX, double gPosY, - double gPosZ ){ + double gPosZ, + TrigL2MuonSA::RpcLayerHits& rpcLayerHits ) const{ int ilay=0; // BO @@ -65,31 +52,37 @@ void TrigL2MuonSA::RpcPatFinder::addHit(std::string stationName, // if eta measurement then save Z/R R = calibR(stationName,R, Phi); double x=gPosZ/R; - m_hits_in_layer_eta.at(ilay).push_back(x); - m_hits_in_layer_R.at(ilay).push_back(R);//mod! - m_hits_in_layer_Z.at(ilay).push_back(gPosZ);//mod! + rpcLayerHits.hits_in_layer_eta.at(ilay).push_back(x); + rpcLayerHits.hits_in_layer_R.at(ilay).push_back(R);//mod! + rpcLayerHits.hits_in_layer_Z.at(ilay).push_back(gPosZ);//mod! }else{ // if phi measurement then save phi - m_hits_in_layer_phi.at(ilay).push_back(Phi); + rpcLayerHits.hits_in_layer_phi.at(ilay).push_back(Phi); } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- -bool TrigL2MuonSA::RpcPatFinder::findPatternPhi(double &phi_middle, double &phi_outer, unsigned int &pattern){ +bool TrigL2MuonSA::RpcPatFinder::findPatternPhi(double &phi_middle, + double &phi_outer, + unsigned int &pattern, + const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const{ double result_dMO; bool found=false; - if (patfinder(true, pattern, phi_middle,phi_outer, result_dMO)>=2) found=true; + if (patfinder(true, pattern, phi_middle,phi_outer, result_dMO, rpcLayerHits)>=2) found=true; return found; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- -bool TrigL2MuonSA::RpcPatFinder::findPatternEta(double aw[], double bw[], unsigned int & pattern){ +bool TrigL2MuonSA::RpcPatFinder::findPatternEta(double aw[], + double bw[], + unsigned int & pattern, + const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const{ double result_delta[3]={9999,9999,9999}; bool found=false; - if( patfinder_forEta(false, pattern, aw, bw, result_delta)>=2) found=true; + if( patfinder_forEta(false, pattern, aw, bw, result_delta, rpcLayerHits)>=2) found=true; return found; } // -------------------------------------------------------------------------------- @@ -99,10 +92,11 @@ int TrigL2MuonSA::RpcPatFinder::patfinder_forEta(bool iphi, unsigned int &result_pat, double result_aw[], double result_bw[], - double result_dist[]){ + double result_dist[], + const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const { - std::vector<std::list<double>> * rpc_x; - rpc_x = &m_hits_in_layer_eta; + const std::vector<std::list<double>> * rpc_x; + rpc_x = &rpcLayerHits.hits_in_layer_eta; int layer_end; if(rpc_x->at(6).size()+rpc_x->at(7).size() >0) layer_end = 7;//special "feet" towers @@ -120,7 +114,7 @@ int TrigL2MuonSA::RpcPatFinder::patfinder_forEta(bool iphi, for(int i=0; i<8; i++) index[i]=0; // Loop on hits of start layer, for each hit try a new pattern - for (std::list<double>::iterator i_start=rpc_x->at(l_start).begin(); i_start!=rpc_x->at(l_start).end(); i_start++){ + for (std::list<double>::const_iterator i_start=rpc_x->at(l_start).begin(); i_start!=rpc_x->at(l_start).end(); i_start++){ int n_hits=1; unsigned int pat=(1<<l_start); // bit pattern of hit layers double dMO=9999; // disstance middle-outer station @@ -140,7 +134,7 @@ int TrigL2MuonSA::RpcPatFinder::patfinder_forEta(bool iphi, double x_layer=0; double delta_layer=999; // loop on hits of test layer and picks the one with smaller distance from current_x - for (std::list<double>::iterator i_test=rpc_x->at(l_test).begin(); i_test!=rpc_x->at(l_test).end(); i_test++){ + for (std::list<double>::const_iterator i_test=rpc_x->at(l_test).begin(); i_test!=rpc_x->at(l_test).end(); i_test++){ double delta=-1; // check if within the road if (deltaOK(l_current,l_test,current_x,*i_test,iphi,delta)){ @@ -191,7 +185,7 @@ int TrigL2MuonSA::RpcPatFinder::patfinder_forEta(bool iphi, }//for l_start if (n_max>=2) { - abcal(result_pat, result_index, result_aw, result_bw); + abcal(result_pat, result_index, result_aw, result_bw, rpcLayerHits); ATH_MSG_DEBUG("patfinder: BEST pat= " << (std::bitset<8>)result_pat <<" dMM= "<<result_dist[1] <<" dMO= "<<result_dist[2]); @@ -207,15 +201,16 @@ int TrigL2MuonSA::RpcPatFinder::patfinder(bool iphi, unsigned int &result_pat, double &result_x, double &result_x1, - double &result_dMO){ + double &result_dMO, + const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const{ const int N_layers=8; - std::vector<std::list<double>> * rpc_x; + const std::vector<std::list<double>> * rpc_x; if (iphi){ - rpc_x = &m_hits_in_layer_phi; + rpc_x = &rpcLayerHits.hits_in_layer_phi; } else { - rpc_x = &m_hits_in_layer_eta; + rpc_x = &rpcLayerHits.hits_in_layer_eta; } int l_start_max=2; //max layer of first hit @@ -233,7 +228,7 @@ int TrigL2MuonSA::RpcPatFinder::patfinder(bool iphi, // Loop on start layer for (int l_start=0; l_start<=l_start_max; l_start++){ // Loop on hits of start layer, for each hit try a new pattern - for (std::list<double>::iterator i_start=rpc_x->at(l_start).begin(); i_start!=rpc_x->at(l_start).end(); i_start++){ + for (std::list<double>::const_iterator i_start=rpc_x->at(l_start).begin(); i_start!=rpc_x->at(l_start).end(); i_start++){ int n_hits=1; unsigned int pat=(1<<l_start); // bit pattern of hit layers double dMO=9999; // disstance middle-outer station @@ -251,7 +246,7 @@ int TrigL2MuonSA::RpcPatFinder::patfinder(bool iphi, double x_layer=0; double delta_layer=999; // loop on hits of test layer and picks the one with smaller distance from current_x - for (std::list<double>::iterator i_test=rpc_x->at(l_test).begin(); i_test!=rpc_x->at(l_test).end(); i_test++){ + for (std::list<double>::const_iterator i_test=rpc_x->at(l_test).begin(); i_test!=rpc_x->at(l_test).end(); i_test++){ double delta=-1; // check if within the road if (deltaOK(l_current,l_test,current_x,*i_test,iphi,delta)){ @@ -311,7 +306,7 @@ int TrigL2MuonSA::RpcPatFinder::patfinder(bool iphi, // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- -bool TrigL2MuonSA::RpcPatFinder::deltaOK(int l1, int l2, double x1, double x2, int isphi, double &delta){ +bool TrigL2MuonSA::RpcPatFinder::deltaOK(int l1, int l2, double x1, double x2, int isphi, double &delta) const{ // ROAD tuned for ~20 GeV @@ -413,13 +408,17 @@ double TrigL2MuonSA::RpcPatFinder::calibR(std::string stationName, double R, dou // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- -void TrigL2MuonSA::RpcPatFinder::abcal(unsigned int result_pat, size_t index[], double aw[], double bw[]){ +void TrigL2MuonSA::RpcPatFinder::abcal(unsigned int result_pat, + size_t index[], + double aw[], + double bw[], + const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const{ const float ZERO_LIMIT = 1.e-5; - std::vector<std::vector<double> > * rpc_R; - std::vector<std::vector<double> > * rpc_Z; - rpc_R = &m_hits_in_layer_R; - rpc_Z = &m_hits_in_layer_Z; + const std::vector<std::vector<double> > * rpc_R; + const std::vector<std::vector<double> > * rpc_Z; + rpc_R = &rpcLayerHits.hits_in_layer_R; + rpc_Z = &rpcLayerHits.hits_in_layer_Z; double R[8]={0,0,0,0,0,0,0,0}; double Z[8]={0,0,0,0,0,0,0,0}; unsigned int bit=1; diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcPatFinder.h b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcPatFinder.h index 68982e7c1cfd..bc431ef6b1db 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcPatFinder.h +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcPatFinder.h @@ -16,6 +16,27 @@ namespace TrigL2MuonSA { // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- +struct RpcLayerHits +{ + std::vector<std::list<double>> hits_in_layer_eta; + std::vector<std::list<double>> hits_in_layer_phi; + std::vector<std::vector<double>> hits_in_layer_Z; + std::vector<std::vector<double>> hits_in_layer_R; + void clear() { + std::list<double> z; + z.clear(); + hits_in_layer_eta.assign(8,z); + hits_in_layer_phi.assign(8,z); + std::vector<double> zz; + zz.clear(); + hits_in_layer_R.assign(8,zz); + hits_in_layer_Z.assign(8,zz); + } +}; + +// -------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------- + class RpcPatFinder: public AthAlgTool { @@ -24,41 +45,42 @@ class RpcPatFinder: public AthAlgTool RpcPatFinder(const std::string& type, const std::string& name, - const IInterface* parent); + const IInterface* parent); public: - void clear(); void addHit(std::string stationName, int stationEta, bool measuresPhi, unsigned int gasGap, unsigned int doubletR, - double gPosX, double gPosY, double gPosZ); - bool findPatternEta(double aw[], double bw[], unsigned int &pattern); - bool findPatternPhi(double &phi_middle, double &phi_outer, unsigned int &pattern); + double gPosX, double gPosY, double gPosZ, + TrigL2MuonSA::RpcLayerHits& rpcLayerHits) const; + bool findPatternEta(double aw[], double bw[], unsigned int &pattern, const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const; + bool findPatternPhi(double &phi_middle, double &phi_outer, unsigned int &pattern, const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const; private: - std::vector<std::list<double>> m_hits_in_layer_eta; - std::vector<std::list<double>> m_hits_in_layer_phi; - std::vector<std::vector<double>> m_hits_in_layer_Z; - std::vector<std::vector<double>> m_hits_in_layer_R; - int patfinder(bool iphi, unsigned int &result_pat, double &result_x, double &result_x1, - double &result_dMO); + double &result_dMO, + const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const; int patfinder_forEta(bool iphi, unsigned int &result_pat, double result_aw[], double result_bw[], - double result_dist[]); + double result_dist[], + const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const; - bool deltaOK(int l1, int l2, double x1, double x2, int isphi, double &delta); + bool deltaOK(int l1, int l2, double x1, double x2, int isphi, double &delta) const; double calibR(std::string stationName, double R, double Phi) const; - void abcal(unsigned int result_pat, size_t index[], double aw[], double bw[]); + void abcal(unsigned int result_pat, + size_t index[], + double aw[], + double bw[], + const TrigL2MuonSA::RpcLayerHits rpcLayerHits) const; }; } diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcRoadDefiner.cxx b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcRoadDefiner.cxx index 45e271dd9a88..5741838c0e37 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcRoadDefiner.cxx +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcRoadDefiner.cxx @@ -31,16 +31,17 @@ StatusCode TrigL2MuonSA::RpcRoadDefiner::initialize() // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- -StatusCode TrigL2MuonSA::RpcRoadDefiner::defineRoad(const LVL1::RecMuonRoI* p_roi, - const bool insideOut, - TrigL2MuonSA::MuonRoad& muonRoad, - TrigL2MuonSA::RpcHits& /*rpcHits*/, - ToolHandle<RpcPatFinder>* rpcPatFinder, - TrigL2MuonSA::RpcFitResult& rpcFitResult, - double roiEtaMinLow, - double roiEtaMaxLow, - double roiEtaMinHigh, - double roiEtaMaxHigh) const +StatusCode TrigL2MuonSA::RpcRoadDefiner::defineRoad(const LVL1::RecMuonRoI* p_roi, + const bool insideOut, + TrigL2MuonSA::MuonRoad& muonRoad, + TrigL2MuonSA::RpcHits& /*rpcHits*/, + const TrigL2MuonSA::RpcLayerHits& rpcLayerHits, + ToolHandle<RpcPatFinder>* rpcPatFinder, + TrigL2MuonSA::RpcFitResult& rpcFitResult, + double roiEtaMinLow, + double roiEtaMaxLow, + double roiEtaMinHigh, + double roiEtaMaxHigh) const { const double ZERO_LIMIT = 1e-5; @@ -52,7 +53,7 @@ StatusCode TrigL2MuonSA::RpcRoadDefiner::defineRoad(const LVL1::RecMuonRoI* double aw[3]={0.,0.,0.}; double bw[3]={0.,0.,0.}; unsigned int rpc_pattern; - if ( (*rpcPatFinder)->findPatternEta(aw, bw, rpc_pattern) ) { + if ( (*rpcPatFinder)->findPatternEta(aw, bw, rpc_pattern, rpcLayerHits) ) { rpcFitResult.isSuccess = true; rpcFitResult.offset_inner = bw[0]; rpcFitResult.offset_middle = bw[1]; @@ -71,7 +72,7 @@ StatusCode TrigL2MuonSA::RpcRoadDefiner::defineRoad(const LVL1::RecMuonRoI* double phi_middle; double phi_outer; unsigned int phi_pattern; - if ( (*rpcPatFinder)->findPatternPhi(phi_middle, phi_outer, phi_pattern)) { + if ( (*rpcPatFinder)->findPatternPhi(phi_middle, phi_outer, phi_pattern, rpcLayerHits)) { rpcFitResult.phi = phi_middle; rpcFitResult.phi_middle = phi_middle; rpcFitResult.phi_outer = phi_outer; diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcRoadDefiner.h b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcRoadDefiner.h index 3c21dc00fc7f..895a783c3e88 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcRoadDefiner.h +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/RpcRoadDefiner.h @@ -38,16 +38,17 @@ class RpcRoadDefiner: public AthAlgTool virtual StatusCode initialize() override; public: - StatusCode defineRoad(const LVL1::RecMuonRoI* p_roi, - const bool insideOut, - TrigL2MuonSA::MuonRoad& muonRoad, - TrigL2MuonSA::RpcHits& rpcHits, - ToolHandle<RpcPatFinder>* rpcPatFinder, - TrigL2MuonSA::RpcFitResult& rpcFitResult, - double roiEtaMinLow, - double roiEtaMaxLow, - double roiEtaMinHigh, - double roiEtaMaxHigh) const; + StatusCode defineRoad(const LVL1::RecMuonRoI* p_roi, + const bool insideOut, + TrigL2MuonSA::MuonRoad& muonRoad, + TrigL2MuonSA::RpcHits& rpcHits, + const TrigL2MuonSA::RpcLayerHits& rpcLayerHits, + ToolHandle<RpcPatFinder>* rpcPatFinder, + TrigL2MuonSA::RpcFitResult& rpcFitResult, + double roiEtaMinLow, + double roiEtaMaxLow, + double roiEtaMinHigh, + double roiEtaMaxHigh) const; void setMdtGeometry(const ServiceHandle<IRegSelSvc>& regionSelector){ m_regionSelector = regionSelector; }; void setRoadWidthForFailure(double rWidth_RPC_Failed){ m_rWidth_RPC_Failed = rWidth_RPC_Failed; }; -- GitLab