diff --git a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h index 1bc630385bc2d9259251add781e4326f2f69c68a..caaf9db446a949ff7727cf50d7136f8030a60e5e 100644 --- a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h +++ b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h @@ -28,6 +28,7 @@ class TGCRPhiCoincidenceMap; class TGCEIFICoincidenceMap; class TGCTileMuCoincidenceMap; class TGCNSWCoincidenceMap; +class TGCGoodMF; class TGCDatabaseManager : public AthMessaging { @@ -50,6 +51,7 @@ class TGCDatabaseManager : public AthMessaging const TGCEIFICoincidenceMap* getEIFICoincidenceMap(int sideId) const; const TGCTileMuCoincidenceMap* getTileMuCoincidenceMap() const; std::shared_ptr<TGCNSWCoincidenceMap> getNSWCoincidenceMap(int sideId, int octantId, int moduleId) const; + TGCGoodMF* getGoodMFMap() const; TGCConnectionInPP* getConnectionInPP(TGCPatchPanel* patchPanel) const; void addConnectionInPP(const TGCPatchPanel* patchPanel, const TGCConnectionInPP* connectionInPP); @@ -71,6 +73,7 @@ class TGCDatabaseManager : public AthMessaging std::array<std::array<std::array<std::shared_ptr<TGCNSWCoincidenceMap>, NumberOfModuleInBW>, NumberOfOctant>, NumberOfSide> m_mapNSW; TGCConnectionPPToSL* m_PPToSL[NumberOfRegionType]; TGCConnectionASDToPP* m_ASDToPP[NumberOfRegionType][NumberOfPatchPanelType][TotalNumForwardBackwardType]; + TGCGoodMF* m_mapGoodMF; std::map<PatchPanelIDs, std::pair<const TGCConnectionInPP, PatchPanelPointers> > m_patchPanelToConnectionInPP; @@ -101,6 +104,12 @@ std::shared_ptr<TGCNSWCoincidenceMap> TGCDatabaseManager::getNSWCoincidenceMap(i return m_mapNSW[sideId][octantId][moduleId]; } +inline +TGCGoodMF* TGCDatabaseManager::getGoodMFMap() const +{ + return m_mapGoodMF; +} + inline const TGCConnectionPPToSL* TGCDatabaseManager::getConnectionPPToSL(TGCRegionType type) const { diff --git a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCGoodMF.h b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCGoodMF.h new file mode 100644 index 0000000000000000000000000000000000000000..22a89103a88e19a0fd5e978b611924d75a5f6290 --- /dev/null +++ b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCGoodMF.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +// ==================================================================== +/* + TGCGoodMF.h +*/ +// ==================================================================== +#ifndef TGCGoodMF_h +#define TGCGoodMF_h + +#include "GaudiKernel/ToolHandle.h" +#include "StoreGate/ReadCondHandleKey.h" + +#include "AthenaKernel/MsgStreamMember.h" +#include "GaudiKernel/MsgStream.h" + +#include <map> + +namespace LVL1TGCTrigger { + +class TGCArguments; + +// ==================================================================== +// +// class definition +// +// ==================================================================== + +class TGCGoodMF { +public: + TGCGoodMF(TGCArguments*); + ~TGCGoodMF(); + + TGCGoodMF(const TGCGoodMF& right); + const TGCGoodMF& operator=(const TGCGoodMF& right); + + bool test_GoodMF(int moduleId, int sscId, int subsector) const; + bool readBadMFList(); + + TGCArguments* tgcArgs() const; + +private: + std::map<int, std::map<int,int> > m_mapisgoodMF; //Number of moduleId + TGCArguments* m_tgcArgs; + +}; + +inline +TGCArguments* TGCGoodMF::tgcArgs() const { + return m_tgcArgs; +} + +} //end of namespace bracket + +#endif // TGCGoodMF_h diff --git a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSector.h b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSector.h index c70d46e97670e04a74758ad16cf1299036614086..cf31717118ecf3da18abbf52f8edb0e44b0f1ca6 100644 --- a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSector.h +++ b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSector.h @@ -31,6 +31,7 @@ #include "TrigT1TGC/TGCSectorLogic.h" #include "TrigT1TGC/TGCTMDB.h" #include "TrigT1TGC/TGCNSW.h" +#include "TrigT1TGC/TGCGoodMF.h" namespace LVL1TGCTrigger { @@ -94,6 +95,7 @@ private: const TGCEIFICoincidenceMap* mapI=0); void setTileMuMap(const TGCTileMuCoincidenceMap* map); void setNSWMap(std::shared_ptr<const TGCNSWCoincidenceMap> mapNSW); + void setGoodMFMap(const TGCGoodMF* mapGoodMF); void connectPPToSB(const TGCConnectionPPToSB* connection); void connectSBToHPB(const TGCConnectionSBToHPB* connection); void connectHPBToSL(const TGCConnectionHPBToSL* connection); diff --git a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSectorLogic.h b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSectorLogic.h index 54a8d15c3a26793c60238029f579f4cb813e88ce..c919c9c0ffd22ffb167464e8837eb4ef95bb4ef8 100644 --- a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSectorLogic.h +++ b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCSectorLogic.h @@ -38,6 +38,7 @@ class TGCHighPtChipOut; class TGCTMDB; class TGCNSW; class TGCNSWCoincidenceMap; +class TGCGoodMF; //for Run3 class TGCTrackSelectorOut; @@ -78,6 +79,7 @@ public: const TGCTileMuCoincidenceMap* mapTM); void setNSWMap(std::shared_ptr<const TGCNSW> nsw, std::shared_ptr<const TGCNSWCoincidenceMap> mapNSW); + void setGoodMFMap(const TGCGoodMF* mapGoodMF); void showResult(TGCSLSelectorOut* out); TGCSectorLogic(TGCArguments*, TGCRegionType regionIn, int id); @@ -118,6 +120,7 @@ private: int m_sideId, m_octantId; TGCRegionType m_region; int m_NumberOfWireHighPtBoard; + bool m_useGoodMF; TGCSSCController m_SSCController; TGCRPhiCoincidenceMatrix m_matrix; @@ -126,6 +129,7 @@ private: const TGCTMDB* m_pTMDB; std::shared_ptr<const TGCNSW> m_nsw; std::shared_ptr<const TGCNSWCoincidenceMap> m_mapNSW; + const TGCGoodMF* m_mapGoodMF; // for Run2 TGCSLPreSelector m_preSelector; diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx index 753eabd811cf6673a90133af868e227453f9c61b..1f773af7e55703cd2e9552b2a3a8dda196dc2b3e 100644 --- a/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx +++ b/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx @@ -8,6 +8,7 @@ #include "TrigT1TGC/TGCEIFICoincidenceMap.h" #include "TrigT1TGC/TGCTileMuCoincidenceMap.h" #include "TrigT1TGC/TGCNSWCoincidenceMap.h" +#include "TrigT1TGC/TGCGoodMF.h" #include "TrigT1TGC/TGCConnectionASDToPP.h" #include "TrigT1TGC/TGCConnectionInPP.h" #include "TrigT1TGC/TGCPatchPanel.h" @@ -167,7 +168,10 @@ TGCDatabaseManager::TGCDatabaseManager(TGCArguments* tgcargs, } } - } + } + if(tgcArgs()->useRun3Config()){ + m_mapGoodMF = new TGCGoodMF(tgcArgs()); + } } void TGCDatabaseManager::deleteConnectionPPToSL() diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCGoodMF.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCGoodMF.cxx new file mode 100644 index 0000000000000000000000000000000000000000..145e646fef8f9e7a1141ee11715bb26f58d3684a --- /dev/null +++ b/Trigger/TrigT1/TrigT1TGC/src/TGCGoodMF.cxx @@ -0,0 +1,125 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +// ==================================================================== +/* + TGCGoodMF.cc +*/ +// ==================================================================== + +#include "TrigT1TGC/TGCGoodMF.h" +#include "PathResolver/PathResolver.h" + +#include "MuonCondInterface/ITGCTriggerDbTool.h" + +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/IMessageSvc.h" + +#include "TrigT1TGC/TGCArguments.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +#include <iomanip> + +namespace LVL1TGCTrigger { + +// ==================================================================== +// +// class description +// +// ==================================================================== + +TGCGoodMF::TGCGoodMF(TGCArguments* tgcargs) + :m_tgcArgs(tgcargs) +{ + if(tgcArgs()->useRun3Config()){ + this->readBadMFList(); + } +} + +TGCGoodMF::~TGCGoodMF() +{ +} + +TGCGoodMF::TGCGoodMF(const TGCGoodMF& right) +{ + m_tgcArgs=right.m_tgcArgs; + if(tgcArgs()->useRun3Config()){ + this->readBadMFList(); + } +} + +const TGCGoodMF& TGCGoodMF::operator=(const TGCGoodMF& right) +{ + if(this != &right){ + m_tgcArgs=right.m_tgcArgs; + if(tgcArgs()->useRun3Config()){ + this->readBadMFList(); + } + } + + return *this; +} + +bool TGCGoodMF::readBadMFList() +{ + //initialize + std::string buf; + std::string fullName, tag; char delimiter = '\n'; + std::string fn = "HotRoI.v1.db"; + + fullName = PathResolver::find_file( fn.c_str(), "DATAPATH" ); + int mod,maxssc; + std::ifstream file(fullName.c_str(),std::ios::in); + while(getline(file,buf,delimiter)) { + std::istringstream header(buf); + header>>tag; + if(tag == "#"){ // read header part. + header>>mod>>maxssc; + + // get BadMF list + getline(file,buf,delimiter); + std::istringstream cont(buf); + std::map<int,int> mapssc; // <SSCId,badMFId> + int badMFId; + for(int i=0; i<=maxssc; i++) { + cont>>badMFId; + if(badMFId < 0) continue; + mapssc[i] = badMFId; + } + m_mapisgoodMF[mod] = mapssc; // <ModuleId,<~>> + } + } + return true; +} + +bool TGCGoodMF::test_GoodMF(int moduleId,int sscId,int RoI) const +{ + std::map<int, std::map<int, int> >::const_iterator itModule=m_mapisgoodMF.find(moduleId); + if (itModule==m_mapisgoodMF.end()) return true; + + std::map<int, int> mapssc = itModule->second; + std::map<int, int>::const_iterator itSSC=mapssc.find(sscId); + if (itSSC==mapssc.end()) return true; + + int badMFId = itSSC->second; + if (badMFId==0){ return true; } + + enum {N_RoIofSSC=8}; + std::bitset<N_RoIofSSC> bs(badMFId); + + int RoIId; + if(RoI%N_RoIofSSC >= 4){ RoIId = RoI%N_RoIofSSC-4; } + else{ RoIId = RoI%N_RoIofSSC+4; } + + if(bs[RoIId]){return false;} + else return true; +} + + +} //end of namespace bracket diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCRPhiCoincidenceMatrix.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCRPhiCoincidenceMatrix.cxx index eacfe21ae7dc235bc098354b504e73adf9bd3017..b52714bd86b90db5cb60f6d59295fdf68ef9d258 100644 --- a/Trigger/TrigT1/TrigT1TGC/src/TGCRPhiCoincidenceMatrix.cxx +++ b/Trigger/TrigT1/TrigT1TGC/src/TGCRPhiCoincidenceMatrix.cxx @@ -73,7 +73,6 @@ TGCRPhiCoincidenceOut* TGCRPhiCoincidenceMatrix::doCoincidence() int ptOut = -99; int chargeOut = 2; int CoincidenceTypeOut=-1; - bool isgoodMFOut=false; if(m_sectorLogic->getRegion()==Endcap){ subsector = 4*(2*m_SSCId+m_r-1)+m_phi[j]; @@ -90,7 +89,6 @@ TGCRPhiCoincidenceOut* TGCRPhiCoincidenceMatrix::doCoincidence() subsector,type,m_dR,m_dPhi[j]); // this function will be implemented. ptOut = std::abs(pt); chargeOut = pt<0 ? 0:1; - //isgoodMFOut : will be set. CoincidenceTypeOut=(type==0); } @@ -119,7 +117,6 @@ TGCRPhiCoincidenceOut* TGCRPhiCoincidenceMatrix::doCoincidence() out->setRoI(subsector); out->setCharge(chargeOut); out->setCoincidenceType(CoincidenceTypeOut); - out->setGoodMFFlag(isgoodMFOut); j0 = j; } } diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCSector.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCSector.cxx index f21a634ca83e2199c4c595d9bd7e812fcc43e5e6..0cdeb71c77ba3da16c26d9f4cb84e1ba92c37e5d 100644 --- a/Trigger/TrigT1/TrigT1TGC/src/TGCSector.cxx +++ b/Trigger/TrigT1/TrigT1TGC/src/TGCSector.cxx @@ -147,6 +147,9 @@ TGCSector::TGCSector(TGCArguments* tgcargs) std::shared_ptr<const TGCNSWCoincidenceMap> mapNSW = db->getNSWCoincidenceMap(m_sideId, m_octantId,m_moduleId); setNSWMap(mapNSW); + const TGCGoodMF* mapGoodMF = db->getGoodMFMap(); + setGoodMFMap(mapGoodMF); + } // set connection between boards; @@ -306,7 +309,10 @@ void TGCSector::setNSWMap(std::shared_ptr<const TGCNSWCoincidenceMap> mapNSW) if (m_SL) m_SL->setNSWMap(m_NSW, mapNSW); } - +void TGCSector::setGoodMFMap(const TGCGoodMF* mapGoodMF) +{ + if (m_SL) m_SL->setGoodMFMap(mapGoodMF); +} void TGCSector::connectPPToSB(const TGCConnectionPPToSB* connection) diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCSectorLogic.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCSectorLogic.cxx index 16655c5b6738c01059c09cd2458eb21712a79e77..3528a552a21691b36e7a42eab4a61382c02e5060 100644 --- a/Trigger/TrigT1/TrigT1TGC/src/TGCSectorLogic.cxx +++ b/Trigger/TrigT1/TrigT1TGC/src/TGCSectorLogic.cxx @@ -13,6 +13,7 @@ #include "TrigT1TGC/TGCNSW.h" #include "TrigT1TGC/NSWTrigOut.h" #include "TrigT1TGC/TGCNSWCoincidenceMap.h" +#include "TrigT1TGC/TGCGoodMF.h" #include "StoreGate/ReadCondHandle.h" #include "MuonCondSvc/TGCTriggerData.h" @@ -46,6 +47,7 @@ namespace LVL1TGCTrigger { m_stripHighPtChipOut(0), m_useEIFI(false), m_useTileMu(false), + m_useGoodMF(false), m_tgcArgs(tgcargs) { m_sideId = (idIn/NumberOfModule)/NumberOfOctant; @@ -111,6 +113,12 @@ void TGCSectorLogic::setTileMuMap(const TGCTMDB* tmdb, if( m_nsw == 0 || m_mapNSW == 0){tgcArgs()->set_USE_NSW(false);} } +void TGCSectorLogic::setGoodMFMap(const TGCGoodMF* mapGoodMF) +{ + m_mapGoodMF = mapGoodMF; + if (m_mapGoodMF !=0){m_useGoodMF = true;} + else{m_useGoodMF = false;} +} void TGCSectorLogic::setWireHighPtBoard(int port, TGCHighPtBoard* highPtBoard) { @@ -192,6 +200,17 @@ void TGCSectorLogic::clockIn(const SG::ReadCondHandleKey<TGCTriggerData> readCon } } } + + if(tgcArgs()->useRun3Config()){ + if(coincidenceOut){ + if (m_useGoodMF){ + bool isgoodMF; + isgoodMF = m_mapGoodMF->test_GoodMF(m_moduleId,SSCid,coincidenceOut->getRoI()); + coincidenceOut->setGoodMFFlag(isgoodMF); + } + } + } + //////////////////////////////////////////// // do coincidence with Inner Tracklet of EIFI and/or TileMu