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),
24  m_phiRPCDigis(inphiRPCDigis){
25  // m_phiDTDigis=inphiDTDigis;
26  // m_phiRPCDigis=inphiRPCDigis;
27  };
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 39 of file DTRPCBxCorrection.cc.

References nano_mu_digi_cff::bx, L1MuDTChambPhDigi::BxCnt(), L1MuDTChambPhDigi::bxNum(), L1MuTMChambPhContainer::chPhiSegm(), L1MuDTChambPhDigi::code(), dumpMFGeometry_cfg::delta, deltaPhi(), HLT_2023v12_cff::distance, flipBit(), L1MuDTChambPhContainer::getContainer(), m_DphiWindow, m_l1ttma_out, m_phiDTDigis, m_phiRPCDigis, m_QualityLimit, 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().

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

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

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

192  {
193  int delta_phi = abs(dt_phi - rpc2dt_phi);
194  return delta_phi;
195 }
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 205 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().

205  {
206  int size = 0;
207  const std::vector<L1MuDTChambPhDigi>* vInCon = inCon.getContainer();
208  for (auto& i : *vInCon) {
209  if (bx == i.bxNum() && i.code() != 7 && i.whNum() == wh && i.scNum() == sec && i.stNum() == st)
210  size++;
211  }
212 
213  return size;
214 }
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 216 of file DTRPCBxCorrection.cc.

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

216  {
217  int size = 0;
218  const std::vector<L1MuDTChambPhDigi>* vInCon = inCon.getContainer();
219  for (auto& i : *vInCon) {
220  if (bx == i.bxNum() && i.code() != 7 && i.whNum() == wh && i.scNum() == sec && i.stNum() == st)
221  size++;
222  }
223 
224  return size;
225 }
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 197 of file DTRPCBxCorrection.cc.

Referenced by BxCorrection().

197  {
198  if (inv < 0)
199  return -1;
200  if (inv > 0)
201  return 1;
202  return 0;
203 }

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().