ATLAS Offline Software
Loading...
Searching...
No Matches
MMT_Diamond Class Reference

#include <MMT_Diamond.h>

Inheritance diagram for MMT_Diamond:
Collaboration diagram for 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< std::shared_ptr< MMT_Hit > > &hits, std::vector< MMT_Road > &roads, std::vector< slope_t > &diamondSlopes, const int sectorPhi) const
double phiShift (const int n, const double phi, const char 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

Definition at line 37 of file 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 )

Definition at line 18 of file MMT_Diamond.cxx.

19 : AthMessaging(Athena::getMessageSvc(), "MMT_Diamond") {
20 m_xthr = diamXthreshold;
21 m_uvthr = diamUVthreshold;
22 m_uvflag = uv;
23 m_roadSize = roadSize;
24 m_roadSizeUpX = olapEtaUp;
25 m_roadSizeDownX = olapEtaDown;
26 m_roadSizeUpUV = olapStereoUp;
27 m_roadSizeDownUV = olapStereoDown;
28}
AthMessaging()
Default constructor:
int m_roadSizeDownUV
Definition MMT_Diamond.h:53
int m_roadSizeUpUV
Definition MMT_Diamond.h:53
int m_roadSizeDownX
Definition MMT_Diamond.h:53
int m_roadSizeUpX
Definition MMT_Diamond.h:53
IMessageSvc * getMessageSvc(bool quiet=false)

◆ ~MMT_Diamond()

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 30 of file MMT_Diamond.cxx.

30 {
31 const char sec = (isLarge) ? 'L' : 'S';
32 /*
33 * This computation is done as follows: 1024 X roads, from 8192 strips in total (5120 for |eta|==1 and 3072 for |eta|==2)
34 * MML: for i in [0,8] -> i*6 UV roads. Then: (1024-9)*6*9 UV roads
35 * MMS: for i in [0,6] -> i*6 UV roads. Then: (1024-7)*6*7 UV roads
36 */
37 const unsigned int vecRoads = 35000;
38 roads.reserve(vecRoads);
39 const int nroad = 8192/m_roadSize;
40 for (int i = 0; i < nroad; ++i) {
41 const int div = 5120/m_roadSize;
42 if((isEta1 && i>div) || (!isEta1 && i<=div)) continue;
44
45 /*
46 * The computation of "nuv" is:
47 * B = (1./std::tan(1.5/180.*M_PI));
48 * nuv = std::round( par->getlWidth() / (B * 0.4 * 2.)/this->getRoadSize() );
49 * 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
50 */
51 if(m_uvflag) {
52 const int nuv = (isLarge) ? 9 : 7;
53 for (int uv = 1; uv <= nuv; uv++) {
54 if (i-uv < 0) continue;
55 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i+uv, i-uv);
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-1, i-uv);
58 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i-uv, i+uv-1);
59 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i-uv+1, i+uv);
60 roads.emplace_back(sec, m_roadSize, m_roadSizeUpX, m_roadSizeDownX, m_roadSizeUpUV, m_roadSizeDownUV, m_xthr, m_uvthr, i, i+uv, i-uv+1);
61 }
62 }
63 }
64}

◆ findDiamonds()

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

Definition at line 66 of file MMT_Diamond.cxx.

66 {
67
68 // Comparison with lambda function (easier to implement)
69 std::ranges::sort(hits, [](const auto &h1, const auto &h2){ return h1->getBC() < h2->getBC(); });
70 const int bc_start = hits.front()->getBC();
71 const int bc_end = hits.front()->getBC() + 16;
72 ATH_MSG_DEBUG("Window Start: " << bc_start << " - Window End: " << bc_end);
73
74 std::vector<std::shared_ptr<MMT_Hit> > hits_now;
75 std::vector< std::pair<int, float> > vmm_same;
76 std::vector< std::pair<int, int> > addc_same;
77 std::vector<int> to_erase;
78
79 // each road makes independent triggers, evaluated on each BC
80 unsigned int ibc = 0;
81 for (int bc = hits.front()->getBC(); bc < bc_end; bc++) {
82 // Cleaning stuff
83 hits_now.clear();
84
85 for (unsigned int j = ibc; j < hits.size(); j++) {
86 if (hits[j]->getBC() == bc) hits_now.push_back(hits[j]);
87 else if (hits[j]->getBC() > bc) {
88 ibc = j;
89 break;
90 }
91 }
92
93 // Simulate harware filters: ART hits + ADDC filter
94 for (unsigned int ib = 0; ib < 8; ib++) { //loop on plane from 0 to 7
95 // VMM-ART-hit filter
96 for (int j = 0; j < n_vmm; j++) {
97 vmm_same.clear();
98 unsigned int k = 0;
99 for (const auto &hit_pointer: hits_now) {
100 if (static_cast<unsigned int>(hit_pointer->getPlane()) != ib) continue;
101 if (hit_pointer->getVMM() == j){
102 vmm_same.push_back( std::make_pair(k, hit_pointer->getTime()) );
103 }
104 k++;
105 }
106 if (vmm_same.size() > 1) {
107 to_erase.clear();
108 std::ranges::sort(vmm_same, {}, &std::pair<int, float>::second);
109 for (auto pair: vmm_same) to_erase.push_back(pair.first);
110 // reverse and erase
111 std::sort(to_erase.rbegin(), to_erase.rend());
112 to_erase.pop_back(); //removes the hit with the earliest time
113 for (auto l : to_erase) {
114 hits_now.erase(hits_now.begin() + l);
115 }
116 }
117 }
118 // ADDC-like filter
119 for (int ia = 0; ia < n_addc; ia++) { // From 0 to 3 (local index of the ART ASIC in the layer)
120 addc_same.clear();
121 for (unsigned int k = 0; k < hits_now.size(); k++) {
122 if ((unsigned int)(hits_now[k]->getPlane()) != ib) continue;
123 int istrip = (std::abs(hits_now[k]->getStationEta())-1) * (64*8*10) + hits_now[k]->getChannel(); //needed the global strip index on the sector layer (getChannel returns chamber's local strip index)
124 if (hits_now[k]->getART() == ia) addc_same.emplace_back(k, istrip);
125 }
126
127 if (addc_same.size() > 8) {
128 // priority encode the hits by channel number; remember hits 8+
129 to_erase.clear();
130
131 std::ranges::sort(addc_same, {}, &std::pair<int, int>::second);
132 for (unsigned int it = 8; it < addc_same.size(); it++) to_erase.push_back(addc_same[it].first);
133
134 // reverse and erase
135 std::sort(to_erase.rbegin(), to_erase.rend());
136 for (auto l : to_erase) {
137 hits_now.erase(hits_now.begin() + l);
138 }
139 }
140 }
141 } // loop on plane for VMM and ART ASIC filter
142
143 for (auto &road : roads) {
144
145 if (!road.getHitVector().empty()) road.incrementAge(bc_wind);
146 if (!hits_now.empty()) road.addHits(hits_now);
147
148 if (road.checkCoincidences(bc_wind) && bc >= (bc_start - 1)) {
149
150 ATH_MSG_DEBUG("------------------------------------------------------------------");
151 ATH_MSG_DEBUG("Coincidence FOUND @BC: " << bc);
152 ATH_MSG_DEBUG("Road (x, u, v, count): (" << road.iRoadx() << ", " << road.iRoadu() << ", " << road.iRoadv() << ", " << road.countHits() << ")");
153 ATH_MSG_DEBUG("------------------------------------------------------------------");
154
155 std::vector<int> bcidVec;
156 for (const auto &hit: road.getHitVector()) {
157 bcidVec.push_back(hit.getBC());
158 }
159 std::ranges::sort(bcidVec);
160
161 // evaluating mode of the BCID of the hits in the diamond
162 // default setting in the firmware is the mode of the hits's bcid in the diamond
163 int bcidVal=bcidVec[0], bcidCount=1, modeCount=1, bcidMode=bcidVec[0];
164 for (unsigned int i=1; i<bcidVec.size(); i++){
165 if (bcidVec[i] == bcidVal){
166 bcidCount++;
167 } else {
168 bcidCount = 1;
169 bcidVal = bcidVec[i];
170 }
171 if (bcidCount > modeCount) {
172 modeCount = bcidCount;
173 bcidMode = bcidVal;
174 }
175 }
176
177 slope_t slope;
178 slope.BC = bcidMode;
179 slope.totalCount = road.countHits();
180 slope.iRoad = road.iRoadx();
181 slope.iRoadu = road.iRoadu();
182 slope.iRoadv = road.iRoadv();
183 slope.xCount = road.countXHits();
184 slope.uCount = road.countUHits();
185 slope.age = slope.BC - bc_start;
186 slope.mxl = road.mxl();
187 slope.my = road.avgSofXUV('X'); // defined as my in ATL-COM-UPGRADE-2015-033
188 slope.uavg = road.avgSofXUV('U');
189 slope.vavg = road.avgSofXUV('V');
190 slope.mx = (slope.uavg-slope.vavg)/(2.*tan_stereo_angle);
191 const double theta = std::atan(std::sqrt(std::pow(slope.mx,2) + std::pow(slope.my,2)));
192 slope.theta = (slope.my > 0.) ? theta : M_PI - theta;
193 slope.eta = -1.*std::log(std::tan(slope.theta/2.));
194 slope.dtheta = (slope.mxl - slope.my)/(1. + slope.mxl*slope.my);
195 slope.side = (slope.my > 0.) ? 'A' : 'C';
196 slope.phi = std::atan(slope.mx/slope.my);
197 slope.phiShf = phiShift(sectorPhi, slope.phi, slope.side);
198 slope.lowRes = road.evaluateLowRes();
199
200 diamondSlopes.push_back(slope);
201 }
202 }
203 }
204}
#define M_PI
Scalar theta() const
theta method
#define ATH_MSG_DEBUG(x)
double phiShift(const int n, const double phi, const char side) const
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
unsigned int uCount
Definition MMT_Diamond.h:21
double my
Definition MMT_Diamond.h:24
double phi
Definition MMT_Diamond.h:31
double phiShf
Definition MMT_Diamond.h:32
double eta
Definition MMT_Diamond.h:29
int iRoadu
Definition MMT_Diamond.h:18
double mx
Definition MMT_Diamond.h:27
int iRoadv
Definition MMT_Diamond.h:19
double mxl
Definition MMT_Diamond.h:23
unsigned int totalCount
Definition MMT_Diamond.h:16
unsigned int xCount
Definition MMT_Diamond.h:20
double theta
Definition MMT_Diamond.h:28
double vavg
Definition MMT_Diamond.h:26
double dtheta
Definition MMT_Diamond.h:30
char side
Definition MMT_Diamond.h:33
bool lowRes
Definition MMT_Diamond.h:34
double uavg
Definition MMT_Diamond.h:25
int iRoad
Definition MMT_Diamond.h:17

◆ getRoadSize()

int MMT_Diamond::getRoadSize ( ) const
inline

Definition at line 47 of file MMT_Diamond.h.

47{ return m_roadSize; }

◆ getUVthreshold()

unsigned int MMT_Diamond::getUVthreshold ( ) const
inline

Definition at line 49 of file MMT_Diamond.h.

49{ return m_uvthr; }

◆ getXthreshold()

unsigned int MMT_Diamond::getXthreshold ( ) const
inline

Definition at line 48 of file MMT_Diamond.h.

48{ 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.

◆ 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 char side ) const

Definition at line 206 of file MMT_Diamond.cxx.

206 {
207 double Phi = (side == 'A') ? -phi : phi;
208 double shift = (n > 8) ? (16-n)*M_PI/8. : n*M_PI/8.;
209 if (n < 8) return (Phi + shift);
210 else if (n == 8) return (Phi + ((Phi > 0.) ? -1. : 1.)*shift);
211 else return (Phi - shift);
212}
Scalar phi() const
phi method
@ Phi
Definition RPCdef.h:8

◆ 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 MMT_Diamond::m_roadSize {}
private

Definition at line 53 of file MMT_Diamond.h.

◆ m_roadSizeDownUV

int MMT_Diamond::m_roadSizeDownUV {}
private

Definition at line 53 of file MMT_Diamond.h.

◆ m_roadSizeDownX

int MMT_Diamond::m_roadSizeDownX {}
private

Definition at line 53 of file MMT_Diamond.h.

◆ m_roadSizeUpUV

int MMT_Diamond::m_roadSizeUpUV {}
private

Definition at line 53 of file MMT_Diamond.h.

◆ m_roadSizeUpX

int MMT_Diamond::m_roadSizeUpX {}
private

Definition at line 53 of file MMT_Diamond.h.

◆ m_uvflag

bool MMT_Diamond::m_uvflag {}
private

Definition at line 52 of file MMT_Diamond.h.

52{};

◆ m_uvthr

int MMT_Diamond::m_uvthr {}
private

Definition at line 54 of file MMT_Diamond.h.

54{}, m_uvthr{};

◆ m_xthr

int MMT_Diamond::m_xthr {}
private

Definition at line 54 of file MMT_Diamond.h.

54{}, m_uvthr{};

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