ATLAS Offline Software
Loading...
Searching...
No Matches
L1Muon::L1MM::MMT_Diamond Class Reference

Diamond Road algorithm of the MM trigger processor: builds the roads of one MM station (createRoads) and finds the coincidences among its hits (findDiamonds). More...

#include <MMT_Diamond.h>

Inheritance diagram for L1Muon::L1MM::MMT_Diamond:
Collaboration diagram for L1Muon::L1MM::MMT_Diamond:

Public Member Functions

 MMT_Diamond (const int diamXthreshold, const bool uv, const int diamUVthreshold, const int roadSize, const int olapEtaUp, const int olapEtaDown, const int olapStereoUp, const int olapStereoDown)
 ~MMT_Diamond ()=default
void createRoads (std::vector< MMT_Road > &roads, const bool isLarge, const bool isEta1) const
void findDiamonds (std::vector< MMT_Hit > &hits, std::vector< MMT_Road > &roads, std::vector< slope_t > &diamondSlopes, const int sectorPhi, const double tanStereoAngle) const
double phiShift (const int n, const double phi, const SideType side) const
int getRoadSize () const
unsigned int getXthreshold () const
unsigned int getUVthreshold () const
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

bool m_uvflag {}
int m_roadSize {}
int m_roadSizeUpX {}
int m_roadSizeDownX {}
int m_roadSizeUpUV {}
int m_roadSizeDownUV {}
int m_xthr {}
int m_uvthr {}
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels).
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging).

Detailed Description

Diamond Road algorithm of the MM trigger processor: builds the roads of one MM station (createRoads) and finds the coincidences among its hits (findDiamonds).

Copy of the Run 3 NSWL1::MMT_Diamond (Trigger/TrigT1/TrigT1NSWSimTools), logic unchanged.

Definition at line 51 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

Constructor & Destructor Documentation

◆ MMT_Diamond()

MMT_Diamond::MMT_Diamond ( const int diamXthreshold,
const bool uv,
const int diamUVthreshold,
const int roadSize,
const int olapEtaUp,
const int olapEtaDown,
const int olapStereoUp,
const int olapStereoDown )

◆ ~MMT_Diamond()

L1Muon::L1MM::MMT_Diamond::~MMT_Diamond ( )
default

Member Function Documentation

◆ createRoads()

void MMT_Diamond::createRoads ( std::vector< MMT_Road > & roads,
const bool isLarge,
const bool isEta1 ) const

Definition at line 31 of file Muon/L1MuonNSW/src/MMT_Diamond.cxx.

31 {
32 const char sec = (isLarge) ? 'L' : 'S';
33 /*
34 * This computation is done as follows: 1024 X roads, from 8192 strips in total (5120 for |eta|==1 and 3072 for |eta|==2)
35 * MML: for i in [0,8] -> i*6 UV roads. Then: (1024-9)*6*9 UV roads
36 * MMS: for i in [0,6] -> i*6 UV roads. Then: (1024-7)*6*7 UV roads
37 */
38 const unsigned int vecRoads = 35000;
39 roads.reserve(vecRoads);
40 const int nroad = kStripsPerLayer/m_roadSize;
41 for (int i = 0; i < nroad; ++i) {
42 const int div = kStripsEta1/m_roadSize;
43 if((isEta1 && i>div) || (!isEta1 && i<=div)) continue;
45
46 /*
47 * The computation of "nuv" is:
48 * B = (1./std::tan(1.5/180.*M_PI));
49 * nuv = std::round( par->getlWidth() / (B * 0.4 * 2.)/this->getRoadSize() );
50 * As getlWidth() has to deal with the full wedge, only two (fixed by construction) integer values are allowed, according to small (7) or large (9) wedge
51 */
52 if(m_uvflag) {
53 const int nuv = (isLarge) ? 9 : 7;
54 for (int uv = 1; uv <= nuv; uv++) {
55 if (i-uv < 0) continue;
56 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i+uv, i-uv);
57 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i-uv, i+uv);
58 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i+uv-1, i-uv);
59 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i-uv, i+uv-1);
60 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i-uv+1, i+uv);
61 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i+uv, i-uv+1);
62 }
63 }
64 }
65}
constexpr int kStripsEta1
Nominal strips of one layer of the |stationEta| = 1 module (5120).
constexpr int kStripsPerLayer
Nominal strips of one sector layer, both modules (8192).

◆ findDiamonds()

void MMT_Diamond::findDiamonds ( std::vector< MMT_Hit > & hits,
std::vector< MMT_Road > & roads,
std::vector< slope_t > & diamondSlopes,
const int sectorPhi,
const double tanStereoAngle ) const

Definition at line 67 of file Muon/L1MuonNSW/src/MMT_Diamond.cxx.

68 {
69
70 // Comparison with lambda function (easier to implement)
71 std::ranges::sort(hits, [](const MMT_Hit& h1, const MMT_Hit& h2){ return h1.getBC() < h2.getBC(); });
72 const int bc_start = hits.front().getBC();
73 const int bc_end = hits.front().getBC() + 16;
74 ATH_MSG_DEBUG("Window Start: " << bc_start << " - Window End: " << bc_end);
75
76 // Hits of the current bunch crossing (non-owning, they point into hits, which is not modified below)
77 std::vector<const MMT_Hit*> hits_now;
78 std::vector< std::pair<int, float> > vmm_same;
79 std::vector< std::pair<int, int> > addc_same;
80 std::vector<int> to_erase;
81
82 // each road makes independent triggers, evaluated on each BC
83 unsigned int ibc = 0;
84 for (int bc = hits.front().getBC(); bc < bc_end; bc++) {
85 // Cleaning stuff
86 hits_now.clear();
87
88 for (unsigned int j = ibc; j < hits.size(); j++) {
89 if (hits[j].getBC() == bc) hits_now.push_back(&hits[j]);
90 else if (hits[j].getBC() > bc) {
91 ibc = j;
92 break;
93 }
94 }
95
96 // Simulate harware filters: ART hits + ADDC filter
97 for (unsigned int ib = 0; ib < kPlanes; ib++) { //loop on plane from 0 to 7
98 // VMM-ART-hit filter
99 for (int j = 0; j < kVMMsPerLayer; j++) {
100 vmm_same.clear();
101 unsigned int k = 0;
102 for (const auto &hit_pointer: hits_now) {
103 if (static_cast<unsigned int>(hit_pointer->getPlane()) != ib) continue;
104 if (hit_pointer->getVMM() == j){
105 vmm_same.push_back( std::make_pair(k, hit_pointer->getTime()) );
106 }
107 k++;
108 }
109 if (vmm_same.size() > 1) {
110 to_erase.clear();
111 std::ranges::sort(vmm_same, {}, &std::pair<int, float>::second);
112 for (auto pair: vmm_same) to_erase.push_back(pair.first);
113 // reverse and erase
114 std::sort(to_erase.rbegin(), to_erase.rend());
115 to_erase.pop_back(); //removes the hit with the earliest time
116 for (auto l : to_erase) {
117 hits_now.erase(hits_now.begin() + l);
118 }
119 }
120 }
121 // ADDC-like filter
122 for (int ia = 0; ia < kARTsPerLayer; ia++) { // From 0 to 3 (local index of the ART ASIC in the layer)
123 addc_same.clear();
124 for (unsigned int k = 0; k < hits_now.size(); k++) {
125 if (static_cast<unsigned int>(hits_now[k]->getPlane()) != ib) continue;
126 // the global strip index on the sector layer (getChannel returns the module's local strip index)
127 if (hits_now[k]->getART() == ia) addc_same.emplace_back(k, hits_now[k]->getGlobalStrip());
128 }
129
130 if (addc_same.size() > kMaxHitsPerART) {
131 // priority encode the hits by channel number; remember hits 8+
132 to_erase.clear();
133
134 std::ranges::sort(addc_same, {}, &std::pair<int, int>::second);
135 for (unsigned int it = kMaxHitsPerART; it < addc_same.size(); it++) to_erase.push_back(addc_same[it].first);
136
137 // reverse and erase
138 std::sort(to_erase.rbegin(), to_erase.rend());
139 for (auto l : to_erase) {
140 hits_now.erase(hits_now.begin() + l);
141 }
142 }
143 }
144 } // loop on plane for VMM and ART ASIC filter
145
146 for (auto &road : roads) {
147
148 if (!road.getHitVector().empty()) road.incrementAge(bc_wind);
149 if (!hits_now.empty()) road.addHits(hits_now);
150
151 if (road.checkCoincidences(bc_wind) && bc >= (bc_start - 1)) {
152
153 ATH_MSG_DEBUG("------------------------------------------------------------------");
154 ATH_MSG_DEBUG("Coincidence FOUND @BC: " << bc);
155 ATH_MSG_DEBUG("Road (x, u, v, count): (" << road.iRoadx() << ", " << road.iRoadu() << ", " << road.iRoadv() << ", " << road.countHits() << ")");
156 ATH_MSG_DEBUG("------------------------------------------------------------------");
157
158 std::vector<int> bcidVec;
159 for (const auto &hit: road.getHitVector()) {
160 bcidVec.push_back(hit.getBC());
161 }
162 std::ranges::sort(bcidVec);
163
164 // evaluating mode of the BCID of the hits in the diamond
165 // default setting in the firmware is the mode of the hits's bcid in the diamond
166 int bcidVal=bcidVec[0], bcidCount=1, modeCount=1, bcidMode=bcidVec[0];
167 for (unsigned int i=1; i<bcidVec.size(); i++){
168 if (bcidVec[i] == bcidVal){
169 bcidCount++;
170 } else {
171 bcidCount = 1;
172 bcidVal = bcidVec[i];
173 }
174 if (bcidCount > modeCount) {
175 modeCount = bcidCount;
176 bcidMode = bcidVal;
177 }
178 }
179
180 slope_t slope;
181 slope.BC = bcidMode;
182 slope.totalCount = road.countHits();
183 slope.iRoad = road.iRoadx();
184 slope.iRoadu = road.iRoadu();
185 slope.iRoadv = road.iRoadv();
186 slope.xCount = road.countXHits();
187 slope.uCount = road.countUHits();
188 slope.age = slope.BC - bc_start;
189 slope.mxl = road.mxl();
190 slope.my = road.avgSofXUV(LayerType::X); // defined as my in ATL-COM-UPGRADE-2015-033
191 slope.uavg = road.avgSofXUV(LayerType::U);
192 slope.vavg = road.avgSofXUV(LayerType::V);
193 slope.mx = (slope.uavg-slope.vavg)/(2.*tanStereoAngle);
194 const double theta = std::atan(std::hypot(slope.mx, slope.my));
195 slope.theta = (slope.my > 0.) ? theta : std::numbers::pi - theta;
196 slope.eta = Acts::AngleHelpers::etaFromTheta(slope.theta);
197 slope.dtheta = (slope.mxl - slope.my)/(1. + slope.mxl*slope.my);
198 slope.side = (slope.my > 0.) ? SideType::A : SideType::C;
199 // Local phi relative to the sector centre, in (-pi/2, pi/2) (my is never 0)
200 slope.phi = std::atan(slope.mx/slope.my);
201 slope.phiShf = phiShift(sectorPhi, slope.phi, slope.side);
202 slope.lowRes = road.evaluateLowRes();
203
204 diamondSlopes.push_back(slope);
205 }
206 }
207 }
208}
Scalar theta() const
theta method
#define ATH_MSG_DEBUG(x,...)
bool hit(const Container &ids, int pdgId)
#define pi
double phiShift(const int n, const double phi, const SideType side) const
struct color C
SideType
Detector side. The value is the sign of z, so that it can be used as a sign (e.g. Acts::copySign).
constexpr int kMaxHitsPerART
Hits that one ART ASIC can forward per bunch crossing.
constexpr int kARTsPerLayer
ART ASICs of one sector layer (2 ADDC cards x 2 ART ASICs).
constexpr int kVMMsPerLayer
VMMs of one sector layer (128).
constexpr int kPlanes
Planes of the MM octuplet (2 multilayers x 4 gas gaps).
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ getRoadSize()

int L1Muon::L1MM::MMT_Diamond::getRoadSize ( ) const
inline

Definition at line 62 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

62{ return m_roadSize; }

◆ getUVthreshold()

unsigned int L1Muon::L1MM::MMT_Diamond::getUVthreshold ( ) const
inline

Definition at line 64 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

64{ return m_uvthr; }

◆ getXthreshold()

unsigned int L1Muon::L1MM::MMT_Diamond::getXthreshold ( ) const
inline

Definition at line 63 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

63{ return m_xthr; }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
int outputLevel(const IMessageSvc *ims, const std::string &source)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels).
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 182 of file AthMessaging.h.

183{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 // If user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ phiShift()

double MMT_Diamond::phiShift ( const int n,
const double phi,
const SideType side ) const

Definition at line 210 of file Muon/L1MuonNSW/src/MMT_Diamond.cxx.

210 {
211 const double Phi = -Acts::copySign(phi, side); // local phi flipped on side A
212 double shift = (n > 8) ? (16-n)*std::numbers::pi/8. : n*std::numbers::pi/8.;
213 if (n < 8) return (Phi + shift);
214 else if (n == 8) return (Phi + ((Phi > 0.) ? -1. : 1.)*shift);
215 else return (Phi - shift);
216}
Scalar phi() const
phi method
@ Phi
Definition RPCdef.h:8
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the container.

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging).

Definition at line 141 of file AthMessaging.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels).

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_roadSize

int L1Muon::L1MM::MMT_Diamond::m_roadSize {}
private

Definition at line 68 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

68{};

◆ m_roadSizeDownUV

int L1Muon::L1MM::MMT_Diamond::m_roadSizeDownUV {}
private

Definition at line 72 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

72{};

◆ m_roadSizeDownX

int L1Muon::L1MM::MMT_Diamond::m_roadSizeDownX {}
private

Definition at line 70 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

70{};

◆ m_roadSizeUpUV

int L1Muon::L1MM::MMT_Diamond::m_roadSizeUpUV {}
private

Definition at line 71 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

71{};

◆ m_roadSizeUpX

int L1Muon::L1MM::MMT_Diamond::m_roadSizeUpX {}
private

Definition at line 69 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

69{};

◆ m_uvflag

bool L1Muon::L1MM::MMT_Diamond::m_uvflag {}
private

Definition at line 67 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

67{};

◆ m_uvthr

int L1Muon::L1MM::MMT_Diamond::m_uvthr {}
private

Definition at line 74 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

74{};

◆ m_xthr

int L1Muon::L1MM::MMT_Diamond::m_xthr {}
private

Definition at line 73 of file Muon/L1MuonNSW/src/MMT_Diamond.h.

73{};

The documentation for this class was generated from the following files: