diff --git a/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h b/Trigger/TrigT1/TrigT1TGC/TrigT1TGC/TGCDatabaseManager.h index 1bc630385bc2d9259251add781e4326f2f69c68a..b98575446bacf14191ba0d70b05cdd7611c6e4b2 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; + std::shared_ptr<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]; + std::shared_ptr<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 +std::shared_ptr<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..51b5de3e592c0ceed1050d64d05549689cfbf287 --- /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() = default; + + 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..80b0a5d7b076935fd5b2fb1e7b78070c82486498 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(std::shared_ptr<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..47b9110ef11dc8f6dafe40e23b13795bf975a313 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(std::shared_ptr<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{false}; 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; + std::shared_ptr<const TGCGoodMF> m_mapGoodMF; // for Run2 TGCSLPreSelector m_preSelector; @@ -148,7 +152,7 @@ private: // for inner trigger const TGCInnerTrackletSlot* m_innerTrackletSlots[TGCInnerTrackletSlotHolder::NUMBER_OF_SLOTS_PER_TRIGGER_SECTOR]; bool m_useEIFI; - bool m_useTileMu; + bool m_useTileMu{false}; TGCArguments* m_tgcArgs; }; diff --git a/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx b/Trigger/TrigT1/TrigT1TGC/src/TGCDatabaseManager.cxx index 753eabd811cf6673a90133af868e227453f9c61b..98d8e17dbb01d8d0e60c792043daeb74dbb55c31 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.reset(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..69ea3ccf14bbc94df959c4039e59db0b9b67c39b --- /dev/null +++ b/Trigger/TrigT1/TrigT1TGC/src/TGCGoodMF.cxx @@ -0,0 +1,119 @@ +/* + 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(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/HotRoI.v1.db"; + + fullName = PathResolver::FindCalibDirectory("dev")+fn; + 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 = m_mapisgoodMF[mod]; // mapssc = <SSCId,badMFId>, m_mapisgoodMF = <ModuleId,<~>> + int badMFId; + for(int i=0; i<=maxssc; i++) { + cont>>badMFId; + if(badMFId < 0) continue; + mapssc[i] = badMFId; + } + } + } + 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; + + const 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; } + + return !bs[RoIId]; +} + + +} //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..25d5317b0088b1e21afcaa4c301d80eb1020e775 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); + std::shared_ptr<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(std::shared_ptr<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..f0d9bcaeeb20b004a3027116df1ddb1e46f8baef 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" @@ -45,7 +46,6 @@ namespace LVL1TGCTrigger { m_stripHighPtBoard(0), m_stripHighPtChipOut(0), m_useEIFI(false), - m_useTileMu(false), m_tgcArgs(tgcargs) { m_sideId = (idIn/NumberOfModule)/NumberOfOctant; @@ -111,6 +111,11 @@ void TGCSectorLogic::setTileMuMap(const TGCTMDB* tmdb, if( m_nsw == 0 || m_mapNSW == 0){tgcArgs()->set_USE_NSW(false);} } +void TGCSectorLogic::setGoodMFMap(std::shared_ptr<const TGCGoodMF> mapGoodMF) +{ + m_mapGoodMF = mapGoodMF; + m_useGoodMF = m_mapGoodMF != nullptr; +} void TGCSectorLogic::setWireHighPtBoard(int port, TGCHighPtBoard* highPtBoard) { @@ -192,6 +197,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