CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DTRPCBxCorrection Class Reference

#include <DTRPCBxCorrection.h>

Public Member Functions

 DTRPCBxCorrection (L1MuDTChambPhContainer, L1MuDTChambPhContainer)
 
L1MuDTChambPhContainer getDTContainer ()
 Return Output PhContainer. More...
 
void run (const L1TTwinMuxParams &)
 
 ~DTRPCBxCorrection ()
 

Static Public Member Functions

static int deltaPhi (int dt_phi, int rpc_strip)
 
static int nRPCHits (L1MuTMChambPhContainer inCon, int bx, int wh, int sec, int st)
 
static int nRPCHits (L1MuDTChambPhContainer inCon, int bx, int wh, int sec, int st)
 

Private Member Functions

void BxCorrection (int track_seg)
 
int flipBit (int inv)
 
int sign (float)
 

Private Attributes

int m_DphiWindow
 
L1MuDTChambPhContainer m_dt_tsshifted
 
std::vector< L1MuDTChambPhDigim_l1ttma_out
 
L1MuDTChambPhContainer m_phiDTDigis
 
L1MuDTChambPhContainer m_phiRPCDigis
 
int m_QualityLimit
 

Detailed Description

Definition at line 24 of file DTRPCBxCorrection.h.

Constructor & Destructor Documentation

◆ DTRPCBxCorrection()

DTRPCBxCorrection::DTRPCBxCorrection ( L1MuDTChambPhContainer  inphiDTDigis,
L1MuDTChambPhContainer  inphiRPCDigis 
)

Definition at line 22 of file DTRPCBxCorrection.cc.

23  : m_phiDTDigis(inphiDTDigis), m_phiRPCDigis(inphiRPCDigis) {}
L1MuDTChambPhContainer m_phiRPCDigis
L1MuDTChambPhContainer m_phiDTDigis

◆ ~DTRPCBxCorrection()

DTRPCBxCorrection::~DTRPCBxCorrection ( )
inline

Definition at line 27 of file DTRPCBxCorrection.h.

27 {}

Member Function Documentation

◆ BxCorrection()

void DTRPCBxCorrection::BxCorrection ( int  track_seg)
private

Concatanate all vectors in one

Shift primitives if vector>0

XXX: Source of discrepancies in order to send as second TS the two prims must come from different halves of the station this information does not exist in data 'simulate' this information by requiring different sign in phis and dphi>100
if there is no shift then put the original primitive

Definition at line 35 of file DTRPCBxCorrection.cc.

References nano_mu_digi_cff::bx, L1MuDTChambPhDigi::BxCnt(), L1MuDTChambPhDigi::bxNum(), L1MuTMChambPhContainer::chPhiSegm(), L1MuDTChambPhDigi::code(), dumpMFGeometry_cfg::delta, deltaPhi(), HLT_2024v14_cff::distance, upgradeWorkflowComponents::dups, flipBit(), L1MuDTChambPhContainer::getContainer(), m_DphiWindow, m_l1ttma_out, m_phiDTDigis, m_phiRPCDigis, m_QualityLimit, TrackingDataMCValidation_Standalone_cff::nhits, nRPCHits(), L1MuDTChambPhDigi::phi(), L1MuDTChambPhDigi::phiB(), L1MuDTChambPhDigi::scNum(), nano_mu_digi_cff::sector, L1MuTMChambPhContainer::setContainer(), sign(), relativeConstraints::station, L1MuDTChambPhDigi::stNum(), L1MuDTChambPhDigi::Ts2Tag(), makeMuonMisalignmentScenario::wheel, and L1MuDTChambPhDigi::whNum().

Referenced by run().

35  {
36  L1MuTMChambPhContainer m_phiDTDigis_tm;
37  //std::shared_ptr<L1MuTMChambPhContainer> m_phiDTDigis_tm (new L1MuTMChambPhContainer);
38  const std::vector<L1MuDTChambPhDigi>* phiChambVectorDT;
39  phiChambVectorDT = m_phiDTDigis.getContainer();
40  m_phiDTDigis_tm.setContainer(*phiChambVectorDT);
41  L1MuTMChambPhContainer m_phiRPCDigis_tm;
42  //std::shared_ptr<L1MuTMChambPhContainer> m_phiRPCDigis_tm (new L1MuTMChambPhContainer);
43  const std::vector<L1MuDTChambPhDigi>* phiChambVectorRPC;
44  phiChambVectorRPC = m_phiRPCDigis.getContainer();
45  m_phiRPCDigis_tm.setContainer(*phiChambVectorRPC);
46 
47  int ibx_dtm = 0, fbx_dtm = 0;
48  int ibx_dtp = 0, fbx_dtp = 0;
49 
50  for (int wheel = -2; wheel <= 2; wheel++) {
51  for (int sector = 0; sector < 12; sector++) {
52  for (int station = 1; station <= 4; station++) {
53  bool shifted[7] = {false, false, false, false, false, false, false};
54  bool dups[7] = {false, false, false, false, false, false, false};
55  bool secondTs[7] = {false, false, false, false, false, false, false};
56  L1MuTMChambPhContainer shiftedPhiDTDigis;
57  L1MuDTChambPhDigi* dtts_sh2nd = nullptr;
58  for (int bx = 3; bx >= -3; bx--) {
59  vector<int> delta_m, delta_p, delta_0;
60  for (int rpcbx = bx - 1; rpcbx <= bx + 1; rpcbx++) {
61  L1MuDTChambPhDigi* dtts = nullptr;
62  L1MuDTChambPhDigi* rpcts1 = nullptr;
63  dtts = m_phiDTDigis_tm.chPhiSegm(wheel, station, sector, bx, track_seg);
64 
65  if (!dtts)
66  continue;
67  int nhits = nRPCHits(m_phiRPCDigis_tm, rpcbx, wheel, sector, station);
68  for (int hit = 0; hit < nhits; hit++) {
69  rpcts1 = m_phiRPCDigis_tm.chPhiSegm(wheel, station, sector, rpcbx, hit);
70  //Store in vectors the dphi of matched dt/rpc
71  if (rpcts1 && dtts && dtts->code() < m_QualityLimit &&
72  deltaPhi(dtts->phi(), rpcts1->phi()) < m_DphiWindow) {
73  if ((dtts->bxNum() - rpcbx) == -1) {
74  delta_m.push_back(deltaPhi(dtts->phi(), rpcts1->phi()));
75  ibx_dtm = dtts->bxNum();
76  fbx_dtm = rpcbx;
77  }
78  if ((dtts->bxNum() - rpcbx) == 0) {
79  delta_0.push_back(deltaPhi(dtts->phi(), rpcts1->phi()));
80  }
81  if ((dtts->bxNum() - rpcbx) == 1) {
82  delta_p.push_back(deltaPhi(dtts->phi(), rpcts1->phi()));
83  ibx_dtp = dtts->bxNum();
84  fbx_dtp = rpcbx;
85  }
86  } //end if dtts and quality
87  }
88  } //end of rpc bx and dtts, rpcts1, dttsnew go out of scope
89 
91  vector<int> delta;
92  delta.insert(delta.end(), delta_0.begin(), delta_0.end());
93  delta.insert(delta.end(), delta_p.begin(), delta_p.end());
94  delta.insert(delta.end(), delta_m.begin(), delta_m.end());
96  if (!delta.empty()) {
97  L1MuDTChambPhDigi* dtts = nullptr;
98  L1MuDTChambPhDigi* dttsnew = nullptr;
99  L1MuDTChambPhDigi* dtts_sh = nullptr;
100  std::vector<L1MuDTChambPhDigi> l1ttma_outsh;
101  //Find the pair the min dphi(rpc,dt)
102  unsigned int min_index = std::distance(delta.begin(), std::min_element(delta.begin(), delta.end())) + 0;
103  int init_bx = 0, final_bx = 0;
104 
105  if (((delta_0.size() <= min_index) && (min_index < (delta_0.size() + delta_p.size())) &&
106  !delta_p.empty())) {
107  init_bx = ibx_dtp;
108  final_bx = fbx_dtp;
109  } else if ((delta_0.size() + delta_p.size()) <= min_index && !delta_m.empty()) {
110  init_bx = ibx_dtm;
111  final_bx = fbx_dtm;
112  } else
113  continue;
114  //Primitve to be shifted in place of dttsnew
115  dtts = m_phiDTDigis_tm.chPhiSegm(wheel, station, sector, init_bx, track_seg);
116  dttsnew = m_phiDTDigis_tm.chPhiSegm(wheel, station, sector, final_bx, track_seg);
117  bool shift_1 = false;
118  if (dtts && dtts->code() < m_QualityLimit && (!dttsnew || shifted[final_bx + 3] || dups[final_bx + 3])) {
119  dtts_sh = new L1MuDTChambPhDigi(final_bx,
120  dtts->whNum(),
121  dtts->scNum(),
122  dtts->stNum(),
123  dtts->phi(),
124  dtts->phiB(),
125  dtts->code(),
126  dtts->Ts2Tag(),
127  dtts->BxCnt(),
128  1);
129  l1ttma_outsh.push_back(*dtts_sh);
130  shifted[init_bx + 3] = true;
131  shift_1 = true;
132  }
133  if (dtts && dtts->code() < m_QualityLimit && dttsnew)
134  dups[init_bx + 3] = true;
135 
136  //dtts exists and qual lt m_QualityLimit and dttsnew exists and the previous (shift_1) prim was not shifted and there is empty space in second TS
137  if (dtts && dtts->code() < m_QualityLimit && dttsnew && !shift_1 &&
138  !m_phiDTDigis_tm.chPhiSegm(wheel, station, sector, final_bx, flipBit(track_seg))) {
143  if (sign(dtts->phi()) != sign(dttsnew->phi()) && deltaPhi(-(dtts->phi()), dttsnew->phi()) > 100) {
144  dtts_sh2nd = new L1MuDTChambPhDigi(final_bx,
145  dtts->whNum(),
146  dtts->scNum(),
147  dtts->stNum(),
148  dtts->phi(),
149  dtts->phiB(),
150  dtts->code(),
151  flipBit(track_seg),
152  dtts->BxCnt(),
153  1);
154  secondTs[final_bx + 3] = true;
155  dups[init_bx + 3] = false;
156  shifted[init_bx + 3] = true;
157  }
158  }
159  shiftedPhiDTDigis.setContainer(l1ttma_outsh);
160  }
161  } //end of bx
162 
163  for (int bx = -3; bx <= 3; bx++) {
164  L1MuDTChambPhDigi* dtts = nullptr;
165  if (secondTs[bx + 3])
166  if (dtts_sh2nd) {
167  m_l1ttma_out.push_back(*dtts_sh2nd);
168  }
169  dtts = shiftedPhiDTDigis.chPhiSegm(wheel, station, sector, bx, track_seg);
170  if (dtts) {
171  m_l1ttma_out.push_back(*dtts);
172  continue;
173  }
174  if (dups[bx + 3])
175  continue;
177  dtts = m_phiDTDigis_tm.chPhiSegm(wheel, station, sector, bx, track_seg);
178  if (!shifted[bx + 3] && dtts) {
179  m_l1ttma_out.push_back(*dtts);
180  }
181  }
182 
183  } //end of station
184  } //end of sc
185  } //end of wheel
186 }
L1MuDTChambPhDigi * chPhiSegm(int wheel, int stat, int sect, int bx, int ts2tag)
void setContainer(const Phi_Container &inputSegments)
std::vector< L1MuDTChambPhDigi > m_l1ttma_out
int flipBit(int inv)
L1MuDTChambPhContainer m_phiRPCDigis
Phi_Container const * getContainer() const
static int deltaPhi(int dt_phi, int rpc_strip)
static int nRPCHits(L1MuTMChambPhContainer inCon, int bx, int wh, int sec, int st)
L1MuDTChambPhContainer m_phiDTDigis

◆ deltaPhi()

int DTRPCBxCorrection::deltaPhi ( int  dt_phi,
int  rpc_strip 
)
static

Definition at line 188 of file DTRPCBxCorrection.cc.

References funct::abs(), and HLT_2024v14_cff::delta_phi.

Referenced by BxCorrection(), and DTLowQMatching::Matching().

188  {
189  int delta_phi = abs(dt_phi - rpc2dt_phi);
190  return delta_phi;
191 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ flipBit()

int DTRPCBxCorrection::flipBit ( int  inv)
inlineprivate

Definition at line 40 of file DTRPCBxCorrection.h.

Referenced by BxCorrection().

40 { return (inv ^ 1); };

◆ getDTContainer()

L1MuDTChambPhContainer DTRPCBxCorrection::getDTContainer ( )
inline

Return Output PhContainer.

Definition at line 32 of file DTRPCBxCorrection.h.

References m_dt_tsshifted.

32 { return m_dt_tsshifted; }
L1MuDTChambPhContainer m_dt_tsshifted

◆ nRPCHits() [1/2]

int DTRPCBxCorrection::nRPCHits ( L1MuTMChambPhContainer  inCon,
int  bx,
int  wh,
int  sec,
int  st 
)
static

Definition at line 201 of file DTRPCBxCorrection.cc.

References nano_mu_digi_cff::bx, L1MuTMChambPhContainer::getContainer(), mps_fire::i, fileinputsource_cfi::sec, and findQualityFiles::size.

Referenced by BxCorrection(), DTLowQMatching::Matching(), and IOPrinter::run().

201  {
202  int size = 0;
203  const std::vector<L1MuDTChambPhDigi>* vInCon = inCon.getContainer();
204  for (auto& i : *vInCon) {
205  if (bx == i.bxNum() && i.code() != 7 && i.whNum() == wh && i.scNum() == sec && i.stNum() == st)
206  size++;
207  }
208 
209  return size;
210 }
size
Write out results.
Phi_Container const * getContainer() const

◆ nRPCHits() [2/2]

int DTRPCBxCorrection::nRPCHits ( L1MuDTChambPhContainer  inCon,
int  bx,
int  wh,
int  sec,
int  st 
)
static

Definition at line 212 of file DTRPCBxCorrection.cc.

References nano_mu_digi_cff::bx, L1MuDTChambPhContainer::getContainer(), mps_fire::i, fileinputsource_cfi::sec, and findQualityFiles::size.

212  {
213  int size = 0;
214  const std::vector<L1MuDTChambPhDigi>* vInCon = inCon.getContainer();
215  for (auto& i : *vInCon) {
216  if (bx == i.bxNum() && i.code() != 7 && i.whNum() == wh && i.scNum() == sec && i.stNum() == st)
217  size++;
218  }
219 
220  return size;
221 }
size
Write out results.
Phi_Container const * getContainer() const

◆ run()

void DTRPCBxCorrection::run ( const L1TTwinMuxParams tmParams)

◆ sign()

int DTRPCBxCorrection::sign ( float  inv)
private

Definition at line 193 of file DTRPCBxCorrection.cc.

Referenced by BxCorrection().

193  {
194  if (inv < 0)
195  return -1;
196  if (inv > 0)
197  return 1;
198  return 0;
199 }

Member Data Documentation

◆ m_DphiWindow

int DTRPCBxCorrection::m_DphiWindow
private

Definition at line 52 of file DTRPCBxCorrection.h.

Referenced by BxCorrection(), and run().

◆ m_dt_tsshifted

L1MuDTChambPhContainer DTRPCBxCorrection::m_dt_tsshifted
private

Definition at line 47 of file DTRPCBxCorrection.h.

Referenced by getDTContainer(), and run().

◆ m_l1ttma_out

std::vector<L1MuDTChambPhDigi> DTRPCBxCorrection::m_l1ttma_out
private

Definition at line 49 of file DTRPCBxCorrection.h.

Referenced by BxCorrection(), and run().

◆ m_phiDTDigis

L1MuDTChambPhContainer DTRPCBxCorrection::m_phiDTDigis
private

Definition at line 45 of file DTRPCBxCorrection.h.

Referenced by BxCorrection().

◆ m_phiRPCDigis

L1MuDTChambPhContainer DTRPCBxCorrection::m_phiRPCDigis
private

Definition at line 46 of file DTRPCBxCorrection.h.

Referenced by BxCorrection().

◆ m_QualityLimit

int DTRPCBxCorrection::m_QualityLimit
private

Definition at line 51 of file DTRPCBxCorrection.h.

Referenced by BxCorrection(), and run().