CMS 3D CMS Logo

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

#include <MuonPathCorFitter.h>

Inheritance diagram for MuonPathCorFitter:
MuonPathFitter MuonPathAnalyzer

Public Member Functions

void finish () override
 
void initialise (const edm::EventSetup &iEventSetup) override
 
 MuonPathCorFitter (const edm::ParameterSet &pset, edm::ConsumesCollector &iC, std::shared_ptr< GlobalCoordsObtainer > &globalcoordsobtainer)
 
void run (edm::Event &iEvent, const edm::EventSetup &iEventSetup, MuonPathPtrs &inMpath, std::vector< cmsdt::metaPrimitive > &metaPrimitives) override
 
void run (edm::Event &iEvent, const edm::EventSetup &iEventSetup, MuonPathPtrs &inMpath, std::vector< lat_vector > &lateralities, std::vector< cmsdt::metaPrimitive > &metaPrimitives) override
 
void run (edm::Event &iEvent, const edm::EventSetup &iEventSetup, std::vector< cmsdt::metaPrimitive > &inMPaths, std::vector< cmsdt::metaPrimitive > &outMPaths) override
 
void run (edm::Event &iEvent, const edm::EventSetup &iEventSetup, MuonPathPtrs &inMpath, MuonPathPtrs &outMPath) override
 
 ~MuonPathCorFitter () override
 
- Public Member Functions inherited from MuonPathFitter
fit_common_out_t fit (fit_common_in_t fit_common_in, int XI_WIDTH, int COEFF_WIDTH_T0, int COEFF_WIDTH_POSITION, int COEFF_WIDTH_SLOPE, int PRECISSION_T0, int PRECISSION_POSITION, int PRECISSION_SLOPE, int PROD_RESIZE_T0, int PROD_RESIZE_POSITION, int PROD_RESIZE_SLOPE, int MAX_DRIFT_TDC, int sl)
 
int get_rom_addr (MuonPathPtr &inMPath, latcomb lats)
 
bool hasPosRF (int wh, int sec)
 
 MuonPathFitter (const edm::ParameterSet &pset, edm::ConsumesCollector &iC, std::shared_ptr< GlobalCoordsObtainer > &globalcoordsobtainer)
 
coeffs_t RomDataConvert (std::vector< int > slv, short COEFF_WIDTH_T0, short COEFF_WIDTH_POSITION, short COEFF_WIDTH_SLOPE, short LOLY, short HILY)
 
void setChi2Th (double chi2Th)
 
void setTanPhiTh (double tanPhiTh)
 
 ~MuonPathFitter () override
 
- Public Member Functions inherited from MuonPathAnalyzer
 MuonPathAnalyzer (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
virtual ~MuonPathAnalyzer ()
 

Public Attributes

edm::FileInPath both_sl_filename_
 
- Public Attributes inherited from MuonPathFitter
double chi2Th_
 
const bool debug_
 
DTGeometry const * dtGeo_
 
edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomH
 
std::shared_ptr< GlobalCoordsObtainerglobalcoordsobtainer_
 
int max_drift_tdc = -1
 
edm::FileInPath maxdrift_filename_
 
int maxdriftinfo_ [5][4][14]
 
edm::FileInPath shift_filename_
 
std::map< int, float > shiftinfo_
 
double tanPhiTh_
 

Private Member Functions

void analyze (mp_group mp, std::vector< cmsdt::metaPrimitive > &metaPrimitives)
 
bool canCorrelate (cmsdt::metaPrimitive mp_sl1, cmsdt::metaPrimitive mp_sl3)
 
void fillLuts ()
 
int get_rom_addr (mp_group mps, std::vector< int > missing_hits)
 

Private Attributes

int dT0_correlate_TP_
 
std::vector< std::vector< int > > lut_2sl
 

Detailed Description

Definition at line 25 of file MuonPathCorFitter.h.

Constructor & Destructor Documentation

◆ MuonPathCorFitter()

MuonPathCorFitter::MuonPathCorFitter ( const edm::ParameterSet pset,
edm::ConsumesCollector iC,
std::shared_ptr< GlobalCoordsObtainer > &  globalcoordsobtainer 
)

Definition at line 11 of file MuonPathCorFitter.cc.

References both_sl_filename_, MuonPathFitter::debug_, fillLuts(), LogDebug, muonDTDigis_cfi::pset, MuonPathFitter::setChi2Th(), and MuonPathFitter::setTanPhiTh().

14  : MuonPathFitter(pset, iC, globalcoordsobtainer), dT0_correlate_TP_(pset.getParameter<double>("dT0_correlate_TP")) {
15  if (debug_)
16  LogDebug("MuonPathCorFitter") << "MuonPathCorFitter: constructor";
17 
18  // LUTs
19  both_sl_filename_ = pset.getParameter<edm::FileInPath>("lut_2sl");
20 
21  fillLuts();
22 
23  setChi2Th(pset.getParameter<double>("chi2corTh"));
24  setTanPhiTh(pset.getParameter<double>("dTanPsi_correlate_TP"));
25 }
void setChi2Th(double chi2Th)
void setTanPhiTh(double tanPhiTh)
MuonPathFitter(const edm::ParameterSet &pset, edm::ConsumesCollector &iC, std::shared_ptr< GlobalCoordsObtainer > &globalcoordsobtainer)
edm::FileInPath both_sl_filename_
const bool debug_
#define LogDebug(id)

◆ ~MuonPathCorFitter()

MuonPathCorFitter::~MuonPathCorFitter ( )
override

Definition at line 27 of file MuonPathCorFitter.cc.

References MuonPathFitter::debug_, and LogDebug.

27  {
28  if (debug_)
29  LogDebug("MuonPathCorFitter") << "MuonPathCorFitter: destructor";
30 }
const bool debug_
#define LogDebug(id)

Member Function Documentation

◆ analyze()

void MuonPathCorFitter::analyze ( mp_group  mp,
std::vector< cmsdt::metaPrimitive > &  metaPrimitives 
)
private

Definition at line 176 of file MuonPathCorFitter.cc.

References funct::abs(), cmsdt::CELL_LENGTH, cmsdt::CELL_SEMIHEIGHT, cmsdt::CELL_SEMILENGTH, DTGeometry::chamber(), IntegrityClient_cfi::ChId, fit_common_in_t::coarse_bctr, fit_common_in_t::coarse_wirepos, cmsdt::COEFF_WIDTH_COR_POSITION, cmsdt::COEFF_WIDTH_COR_SLOPE, cmsdt::COEFF_WIDTH_COR_T0, fit_common_in_t::coeffs, MuonPathFitter::dtGeo_, MuonPathFitter::fit(), nano_mu_digi_cff::float, get_rom_addr(), MuonPathFitter::globalcoordsobtainer_, MuonPathFitter::hasPosRF(), fit_common_in_t::hits, fit_common_in_t::hits_valid, mps_fire::i, cmsdt::INCREASED_RES_POS_POW, cmsdt::INCREASED_RES_SLOPE_POW, createfilelist::int, fit_common_in_t::lateralities, cmsdt::LHC_CLK_FREQ, lut_2sl, MuonPathFitter::max_drift_tdc, NUM_LAYERS, or, phi, PV3DBase< T, PVType, FrameType >::phi(), cmsdt::PHI_CONV, funct::pow(), cmsdt::PRECISSION_COR_POSITION, cmsdt::PRECISSION_COR_SLOPE, cmsdt::PRECISSION_COR_T0, cmsdt::PROD_RESIZE_COR_POSITION, cmsdt::PROD_RESIZE_COR_SLOPE, cmsdt::PROD_RESIZE_COR_T0, quality, DetId::rawId(), nano_mu_digi_cff::rawId, MuonPathFitter::RomDataConvert(), DTChamberId::sector(), MuonPathFitter::shiftinfo_, cmsdt::SL1_CELLS_OFFSET, slope, DTChamberId::station(), MuonPathFitter::tanPhiTh_, cmsdt::TIME_TO_TDC_COUNTS, GeomDet::toGlobal(), DTChamberId::wheel(), cmsdt::WIDTH_COARSED_TIME, cmsdt::WIDTH_FULL_TIME, nano_mu_digi_cff::wire, cmsdt::WIREPOS_NORM_LSB_IGNORED, cmsdt::WIREPOS_WIDTH, pfClustersFromHGC3DClusters_cfi::wp, cmsdt::XI_COR_WIDTH, z, and cmsdt::Z_SHIFT_MB4.

Referenced by run().

176  {
177  //FIXME
178  DTSuperLayerId MuonPathSLId(mp[0].rawId); // SL1
179 
180  DTChamberId ChId(MuonPathSLId.wheel(), MuonPathSLId.station(), MuonPathSLId.sector());
181 
182  DTSuperLayerId MuonPathSL1Id(ChId.wheel(), ChId.station(), ChId.sector(), 1);
183  DTSuperLayerId MuonPathSL3Id(ChId.wheel(), ChId.station(), ChId.sector(), 3);
184  DTWireId wireIdSL1(MuonPathSL1Id, 2, 1);
185  DTWireId wireIdSL3(MuonPathSL3Id, 2, 1);
186  auto sl_shift_cm = shiftinfo_[wireIdSL1.rawId()] - shiftinfo_[wireIdSL3.rawId()];
187 
188  fit_common_in_t fit_common_in;
189 
190  // 8-element vectors, for the 8 layers. As here we are fitting one SL only, we leave the other SL values as dummy ones
191  fit_common_in.hits = {};
192  fit_common_in.hits_valid = {};
193  short quality = 0;
194  if (mp[0].quality >= 3 && mp[1].quality >= 3)
195  quality = 8;
196  else if ((mp[0].quality >= 3 && mp[1].quality < 3) || (mp[0].quality < 3 && mp[1].quality >= 3))
197  quality = 7;
198  else
199  quality = 6;
200 
201  std::vector<int> missing_layers;
202 
203  for (int isl = 0; isl < 2; isl++) {
204  int wire[4], tdc[4];
205  if (isl != 1) {
206  wire[0] = mp[isl].wi1;
207  tdc[0] = mp[isl].tdc1;
208  wire[1] = mp[isl].wi2;
209  tdc[1] = mp[isl].tdc2;
210  wire[2] = mp[isl].wi3;
211  tdc[2] = mp[isl].tdc3;
212  wire[3] = mp[isl].wi4;
213  tdc[3] = mp[isl].tdc4;
214  } else {
215  wire[0] = mp[isl].wi5;
216  tdc[0] = mp[isl].tdc5;
217  wire[1] = mp[isl].wi6;
218  tdc[1] = mp[isl].tdc6;
219  wire[2] = mp[isl].wi7;
220  tdc[2] = mp[isl].tdc7;
221  wire[3] = mp[isl].wi8;
222  tdc[3] = mp[isl].tdc8;
223  }
224 
225  for (int i = 0; i < NUM_LAYERS; i++) {
226  if (wire[i] != -1) {
227  // Include both valid and non-valid hits. Non-valid values can be whatever, leaving all as -1 to make debugging easier.
228  auto ti = tdc[i];
229  if (ti != -1)
230  ti = (int)round(((float)TIME_TO_TDC_COUNTS / (float)LHC_CLK_FREQ) * ti);
231  auto wi = wire[i];
232  auto ly = i;
233 
234  int wp_semicells = (wi - SL1_CELLS_OFFSET) * 2 + 1;
235  if (ly % 2 == 1)
236  wp_semicells -= 1;
237  if (isl == 1) // SL3
238  wp_semicells -= (int)round((sl_shift_cm * 10) / CELL_SEMILENGTH);
239  float wp_tdc = wp_semicells * max_drift_tdc;
240  int wp = (int)((long int)(round(wp_tdc * std::pow(2, WIREPOS_WIDTH))) / (int)std::pow(2, WIREPOS_WIDTH));
241 
242  // wp in tdc counts (still in floating point)
243  fit_common_in.hits.push_back({ti, wi, ly, wp});
244  // fill valids as well
245  fit_common_in.hits_valid.push_back(1);
246  } else {
247  missing_layers.push_back(isl * NUM_LAYERS + i);
248  fit_common_in.hits.push_back({-1, -1, -1, -1});
249  fit_common_in.hits_valid.push_back(0);
250  }
251  }
252  }
253 
254  int smallest_time = 999999, tmp_coarse_wirepos_1 = -1, tmp_coarse_wirepos_3 = -1;
255  // coarse_bctr is the 12 MSB of the smallest tdc
256  for (int isl = 0; isl < 2; isl++) {
257  for (size_t i = 0; i < NUM_LAYERS; i++) {
258  if (fit_common_in.hits_valid[NUM_LAYERS * isl + i] == 0)
259  continue;
260  else if (fit_common_in.hits[NUM_LAYERS * isl + i].ti < smallest_time)
261  smallest_time = fit_common_in.hits[NUM_LAYERS * isl + i].ti;
262  }
263  }
264  if (fit_common_in.hits_valid[NUM_LAYERS * 0 + 0] == 1)
265  tmp_coarse_wirepos_1 = fit_common_in.hits[NUM_LAYERS * 0 + 0].wp;
266  else
267  tmp_coarse_wirepos_1 = fit_common_in.hits[NUM_LAYERS * 0 + 1].wp;
268  if (fit_common_in.hits_valid[NUM_LAYERS * 1 + 3] == 1)
269  tmp_coarse_wirepos_3 = fit_common_in.hits[NUM_LAYERS * 1 + 3].wp;
270  else
271  tmp_coarse_wirepos_3 = fit_common_in.hits[NUM_LAYERS * 1 + 2].wp;
272 
273  tmp_coarse_wirepos_1 = tmp_coarse_wirepos_1 >> WIREPOS_NORM_LSB_IGNORED;
274  tmp_coarse_wirepos_3 = tmp_coarse_wirepos_3 >> WIREPOS_NORM_LSB_IGNORED;
275 
276  fit_common_in.coarse_bctr = smallest_time >> (WIDTH_FULL_TIME - WIDTH_COARSED_TIME);
277  fit_common_in.coarse_wirepos = (tmp_coarse_wirepos_1 + tmp_coarse_wirepos_3) >> 1;
278 
279  fit_common_in.lateralities.clear();
280 
281  auto rom_addr = get_rom_addr(mp, missing_layers);
282 
283  coeffs_t coeffs =
285 
286  // Filling lateralities
287  for (int isl = 0; isl < 2; isl++) {
288  int lat[4];
289  if (isl != 1) {
290  lat[0] = mp[isl].lat1;
291  lat[1] = mp[isl].lat2;
292  lat[2] = mp[isl].lat3;
293  lat[3] = mp[isl].lat4;
294  } else {
295  lat[0] = mp[isl].lat5;
296  lat[1] = mp[isl].lat6;
297  lat[2] = mp[isl].lat7;
298  lat[3] = mp[isl].lat8;
299  }
300 
301  for (size_t i = 0; i < NUM_LAYERS; i++) {
302  fit_common_in.lateralities.push_back(lat[i]);
303  }
304  }
305 
306  fit_common_in.coeffs = coeffs;
307 
308  auto fit_common_out = fit(fit_common_in,
309  XI_COR_WIDTH,
320  0);
321 
322  if (fit_common_out.valid_fit == 1) {
323  float t0_f = ((float)fit_common_out.t0) * (float)LHC_CLK_FREQ / (float)TIME_TO_TDC_COUNTS;
324  float slope_f = -fit_common_out.slope * ((float)CELL_SEMILENGTH / max_drift_tdc) * (1) / (CELL_SEMIHEIGHT * 16.);
325  if (std::abs(slope_f) > tanPhiTh_)
326  return;
327 
328  DTWireId wireId(MuonPathSLId, 2, 1);
329  float pos_ch_f = (float)(fit_common_out.position) * ((float)CELL_SEMILENGTH / (float)max_drift_tdc) / 10;
330  pos_ch_f += (SL1_CELLS_OFFSET * CELL_LENGTH) / 10.;
331  pos_ch_f += shiftinfo_[wireId.rawId()];
332 
333  float chi2_f = fit_common_out.chi2 * std::pow(((float)CELL_SEMILENGTH / (float)max_drift_tdc), 2) / 100;
334 
335  // obtention of global coordinates using luts
336  int pos = (int)(10 * (pos_ch_f - shiftinfo_[wireId.rawId()]) * INCREASED_RES_POS_POW);
337  int slope = (int)(-slope_f * INCREASED_RES_SLOPE_POW);
338  auto global_coords = globalcoordsobtainer_->get_global_coordinates(ChId.rawId(), 0, pos, slope);
339  float phi = global_coords[0];
340  float phiB = global_coords[1];
341 
342  // obtention of global coordinates using cmssw geometry
343  double z = 0;
344  if (ChId.station() == 3 or ChId.station() == 4) {
345  z += Z_SHIFT_MB4;
346  }
347  GlobalPoint jm_x_cmssw_global = dtGeo_->chamber(ChId)->toGlobal(LocalPoint(pos_ch_f, 0., z));
348  int thisec = ChId.sector();
349  if (thisec == 13)
350  thisec = 4;
351  if (thisec == 14)
352  thisec = 10;
353  float phi_cmssw = jm_x_cmssw_global.phi() - PHI_CONV * (thisec - 1);
354  float psi = atan(slope_f);
355  float phiB_cmssw = hasPosRF(ChId.wheel(), ChId.sector()) ? psi - phi_cmssw : -psi - phi_cmssw;
356  metaPrimitives.emplace_back(metaPrimitive({MuonPathSLId.rawId(),
357  t0_f,
358  (double)fit_common_out.position,
359  (double)fit_common_out.slope,
360  phi,
361  phiB,
362  phi_cmssw,
363  phiB_cmssw,
364  chi2_f,
365  quality,
366  mp[0].wi1,
367  mp[0].tdc1,
368  mp[0].lat1,
369  mp[0].wi2,
370  mp[0].tdc2,
371  mp[0].lat2,
372  mp[0].wi3,
373  mp[0].tdc3,
374  mp[0].lat3,
375  mp[0].wi4,
376  mp[0].tdc4,
377  mp[0].lat4,
378  mp[1].wi5,
379  mp[1].tdc5,
380  mp[1].lat5,
381  mp[1].wi6,
382  mp[1].tdc6,
383  mp[1].lat6,
384  mp[1].wi7,
385  mp[1].tdc7,
386  mp[1].lat7,
387  mp[1].wi8,
388  mp[1].tdc8,
389  mp[1].lat8,
390  -1}));
391  }
392  return;
393 }
std::vector< int > lateralities
std::vector< SLhitP > hits
constexpr int COEFF_WIDTH_COR_T0
Definition: constants.h:279
constexpr int PROD_RESIZE_COR_SLOPE
Definition: constants.h:289
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
constexpr int PRECISSION_COR_SLOPE
Definition: constants.h:285
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
static const double slope[3]
constexpr int PROD_RESIZE_COR_POSITION
Definition: constants.h:288
constexpr int WIDTH_COARSED_TIME
Definition: constants.h:252
constexpr int WIREPOS_WIDTH
Definition: constants.h:257
std::map< std::string, int, std::less< std::string > > psi
std::map< int, float > shiftinfo_
constexpr int CELL_LENGTH
Definition: constants.h:313
constexpr int COEFF_WIDTH_COR_SLOPE
Definition: constants.h:281
constexpr int CELL_SEMILENGTH
Definition: constants.h:314
string quality
int get_rom_addr(mp_group mps, std::vector< int > missing_hits)
constexpr int INCREASED_RES_SLOPE_POW
Definition: constants.h:416
bool hasPosRF(int wh, int sec)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
constexpr int SL1_CELLS_OFFSET
Definition: constants.h:247
constexpr float Z_SHIFT_MB4
Definition: constants.h:397
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr int WIDTH_FULL_TIME
Definition: constants.h:251
constexpr int PRECISSION_COR_T0
Definition: constants.h:283
std::shared_ptr< GlobalCoordsObtainer > globalcoordsobtainer_
coeffs_t RomDataConvert(std::vector< int > slv, short COEFF_WIDTH_T0, short COEFF_WIDTH_POSITION, short COEFF_WIDTH_SLOPE, short LOLY, short HILY)
constexpr float CELL_SEMIHEIGHT
Definition: constants.h:312
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
constexpr double PHI_CONV
Definition: constants.h:394
constexpr int TIME_TO_TDC_COUNTS
Definition: constants.h:235
constexpr int PROD_RESIZE_COR_T0
Definition: constants.h:287
constexpr int LHC_CLK_FREQ
Definition: constants.h:222
constexpr int XI_COR_WIDTH
Definition: constants.h:277
constexpr int PRECISSION_COR_POSITION
Definition: constants.h:284
constexpr int COEFF_WIDTH_COR_POSITION
Definition: constants.h:280
DTGeometry const * dtGeo_
constexpr int INCREASED_RES_POS_POW
Definition: constants.h:415
constexpr int WIREPOS_NORM_LSB_IGNORED
Definition: constants.h:258
fit_common_out_t fit(fit_common_in_t fit_common_in, int XI_WIDTH, int COEFF_WIDTH_T0, int COEFF_WIDTH_POSITION, int COEFF_WIDTH_SLOPE, int PRECISSION_T0, int PRECISSION_POSITION, int PRECISSION_SLOPE, int PROD_RESIZE_T0, int PROD_RESIZE_POSITION, int PROD_RESIZE_SLOPE, int MAX_DRIFT_TDC, int sl)
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
std::vector< std::vector< int > > lut_2sl
std::vector< int > hits_valid

◆ canCorrelate()

bool MuonPathCorFitter::canCorrelate ( cmsdt::metaPrimitive  mp_sl1,
cmsdt::metaPrimitive  mp_sl3 
)
private

Definition at line 143 of file MuonPathCorFitter.cc.

References funct::abs(), dT0_correlate_TP_, createfilelist::int, cmsdt::metaPrimitive::t0, cmsdt::metaPrimitive::tanPhi, cmsdt::WIDTH_POS_SLOPE_CORR, and cmsdt::metaPrimitive::x.

Referenced by run().

143  {
144  // moving position from SL RF to chamber RF
145  float pos_ch_sl1_f = mp_sl1.x;
146  float pos_ch_sl3_f = mp_sl3.x;
147 
148  // translating into tdc counts
149  int pos_ch_sl1 = int(pos_ch_sl1_f);
150  int pos_ch_sl3 = int(pos_ch_sl3_f);
151 
152  int slope_sl1 = (int)mp_sl1.tanPhi;
153  int slope_sl3 = (int)mp_sl3.tanPhi;
154 
155  if (abs((slope_sl1 >> WIDTH_POS_SLOPE_CORR) - (slope_sl3 >> WIDTH_POS_SLOPE_CORR)) > 1)
156  return false;
157 
158  if (abs((pos_ch_sl1 >> WIDTH_POS_SLOPE_CORR) - (pos_ch_sl3 >> WIDTH_POS_SLOPE_CORR)) > 1)
159  return false;
160 
161  if (abs(mp_sl1.t0 - mp_sl3.t0) > dT0_correlate_TP_)
162  return false;
163 
164  return true;
165 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr int WIDTH_POS_SLOPE_CORR
Definition: constants.h:259

◆ fillLuts()

void MuonPathCorFitter::fillLuts ( )
private

Definition at line 395 of file MuonPathCorFitter.cc.

References both_sl_filename_, edm::FileInPath::fullPath(), mps_fire::i, mps_splice::line, lut_2sl, groupFilesInBlocks::reverse, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by MuonPathCorFitter().

395  {
396  std::ifstream ifin2sl(both_sl_filename_.fullPath());
398  while (ifin2sl.good()) {
399  ifin2sl >> line;
400 
401  std::vector<int> myNumbers;
402  for (size_t i = 0; i < line.size(); i++) {
403  // This converts the char into an int and pushes it into vec
404  myNumbers.push_back(line[i] - '0'); // The digits will be in the same order as before
405  }
406  std::reverse(myNumbers.begin(), myNumbers.end());
407  lut_2sl.push_back(myNumbers);
408  }
409 
410  return;
411 }
std::string fullPath() const
Definition: FileInPath.cc:161
edm::FileInPath both_sl_filename_
std::vector< std::vector< int > > lut_2sl

◆ finish()

void MuonPathCorFitter::finish ( )
overridevirtual

Reimplemented from MuonPathAnalyzer.

Definition at line 167 of file MuonPathCorFitter.cc.

References MuonPathFitter::debug_, and LogDebug.

Referenced by progressbar.ProgressBar::__next__().

167  {
168  if (debug_)
169  LogDebug("MuonPathCorFitter") << "MuonPathCorFitter: finish";
170 };
const bool debug_
#define LogDebug(id)

◆ get_rom_addr()

int MuonPathCorFitter::get_rom_addr ( mp_group  mps,
std::vector< int >  missing_hits 
)
private

Definition at line 413 of file MuonPathCorFitter.cc.

References mps_fire::i, createfilelist::int, NUM_LAYERS, groupFilesInBlocks::reverse, and vhdl_unsigned_to_int().

Referenced by analyze().

413  {
414  std::vector<int> lats = {
415  mps[0].lat1, mps[0].lat2, mps[0].lat3, mps[0].lat4, mps[1].lat5, mps[1].lat6, mps[1].lat7, mps[1].lat8};
416 
417  std::vector<int> rom_addr;
418  if (missing_hits.size() == 1)
419  rom_addr.push_back(1);
420  else
421  rom_addr.push_back(0);
422 
423  if (missing_hits.size() == 1) { // 7 layers fit
424  if (missing_hits[0] < 4)
425  rom_addr.push_back(0); // First SL has 4 hits (1) or 3 (0)
426  else
427  rom_addr.push_back(1);
428  if (missing_hits[0] % 4 == 0) {
429  rom_addr.push_back(0);
430  rom_addr.push_back(0);
431  } else if (missing_hits[0] % 4 == 1) {
432  rom_addr.push_back(0);
433  rom_addr.push_back(1);
434  } else if (missing_hits[0] % 4 == 2) {
435  rom_addr.push_back(1);
436  rom_addr.push_back(0);
437  } else { // missing_hits[0] == 3
438  rom_addr.push_back(1);
439  rom_addr.push_back(1);
440  }
441  for (size_t ilat = 0; ilat < lats.size(); ilat++) {
442  if ((int)ilat == missing_hits[0]) // only applies to 3-hit, as in 4-hit missL=-1
443  continue;
444  auto lat = lats[ilat];
445  if (lat == -1)
446  lat = 0;
447  rom_addr.push_back(lat);
448  }
449 
450  } else if (missing_hits.empty()) { // 8 layers fit
451  for (size_t ilat = 0; ilat < lats.size(); ilat++) {
452  auto lat = lats[ilat];
453  if (lat == -1)
454  lat = 0;
455  rom_addr.push_back(lat);
456  }
457  auto lat = lats[NUM_LAYERS + 3];
458  if (lat == -1)
459  lat = 0;
460  rom_addr.push_back(lat);
461  rom_addr.push_back(lat);
462 
463  } else { // 6 layers fit
464  for (int i = missing_hits.size() - 1; i >= 0; i--) {
465  if (missing_hits[i] % 4 == 0) {
466  rom_addr.push_back(0);
467  rom_addr.push_back(0);
468  } else if (missing_hits[i] % 4 == 1) {
469  rom_addr.push_back(0);
470  rom_addr.push_back(1);
471  } else if (missing_hits[i] % 4 == 2) {
472  rom_addr.push_back(1);
473  rom_addr.push_back(0);
474  } else { // missing_hits[i] % 4 == 3
475  rom_addr.push_back(1);
476  rom_addr.push_back(1);
477  }
478  }
479  for (size_t ilat = 0; ilat < lats.size(); ilat++) {
480  if ((int)ilat == missing_hits[0] || (int)ilat == missing_hits[1]) // only applies to 3-hit, as in 4-hit missL=-1
481  continue;
482  auto lat = lats[ilat];
483  if (lat == -1)
484  lat = 0;
485  rom_addr.push_back(lat);
486  }
487  }
488  std::reverse(rom_addr.begin(), rom_addr.end());
489  return vhdl_unsigned_to_int(rom_addr);
490 }
int vhdl_unsigned_to_int(std::vector< int > v)

◆ initialise()

void MuonPathCorFitter::initialise ( const edm::EventSetup iEventSetup)
overridevirtual

Reimplemented from MuonPathAnalyzer.

Definition at line 35 of file MuonPathCorFitter.cc.

References MuonPathFitter::debug_, MuonPathFitter::dtGeo_, MuonPathFitter::dtGeomH, relativeConstraints::geom, edm::EventSetup::getHandle(), and LogDebug.

35  {
36  if (debug_)
37  LogDebug("MuonPathCorFitter") << "MuonPathCorFitter::initialiase";
38 
39  auto geom = iEventSetup.getHandle(dtGeomH);
40  dtGeo_ = &(*geom);
41 }
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
DTGeometry const * dtGeo_
const bool debug_
#define LogDebug(id)

◆ run() [1/4]

void MuonPathCorFitter::run ( edm::Event iEvent,
const edm::EventSetup iEventSetup,
MuonPathPtrs inMpath,
std::vector< cmsdt::metaPrimitive > &  metaPrimitives 
)
inlineoverridevirtual

Implements MuonPathAnalyzer.

Definition at line 35 of file MuonPathCorFitter.h.

38  {};

◆ run() [2/4]

void MuonPathCorFitter::run ( edm::Event iEvent,
const edm::EventSetup iEventSetup,
MuonPathPtrs inMpath,
std::vector< lat_vector > &  lateralities,
std::vector< cmsdt::metaPrimitive > &  metaPrimitives 
)
inlineoverridevirtual

Implements MuonPathAnalyzer.

Definition at line 39 of file MuonPathCorFitter.h.

43  {};

◆ run() [3/4]

void MuonPathCorFitter::run ( edm::Event iEvent,
const edm::EventSetup iEventSetup,
std::vector< cmsdt::metaPrimitive > &  inMPaths,
std::vector< cmsdt::metaPrimitive > &  outMPaths 
)
overridevirtual

Implements MuonPathAnalyzer.

Definition at line 43 of file MuonPathCorFitter.cc.

References funct::abs(), analyze(), L1TStage2uGTEmulatorClient_cff::BX, nano_mu_digi_cff::bx, bxSort(), canCorrelate(), IntegrityClient_cfi::ChId, MuonPathFitter::debug_, mps_fire::i, LogDebug, cmsdt::MAX_BX_FOR_COR, MuonPathFitter::max_drift_tdc, cmsdt::MAX_PRIM_FOR_COR, cmsdt::MAX_PRIM_PER_BX_FOR_COR, MuonPathFitter::maxdriftinfo_, push_back(), DTChamberId::sector(), DTChamberId::station(), and DTChamberId::wheel().

46  {
47  if (debug_)
48  LogDebug("MuonPathCorFitter") << "MuonPathCorFitter: run";
49  if (!inMPaths.empty()) {
50  int dum_sl_rawid = inMPaths[0].rawId;
51  DTSuperLayerId dumSlId(dum_sl_rawid);
52  DTChamberId ChId(dumSlId.wheel(), dumSlId.station(), dumSlId.sector());
53  max_drift_tdc = maxdriftinfo_[dumSlId.wheel() + 2][dumSlId.station() - 1][dumSlId.sector() - 1];
54  DTSuperLayerId sl1Id(ChId.rawId(), 1);
55  DTSuperLayerId sl3Id(ChId.rawId(), 3);
56 
57  std::map<int, std::vector<metaPrimitive>> SL1metaPrimitivesPerBX;
58  std::map<int, std::vector<metaPrimitive>> SL3metaPrimitivesPerBX;
59  for (const auto& metaprimitiveIt : inMPaths) {
60  int BX = metaprimitiveIt.t0 / 25;
61  if (metaprimitiveIt.rawId == sl1Id.rawId())
62  SL1metaPrimitivesPerBX[BX].push_back(metaprimitiveIt);
63  else if (metaprimitiveIt.rawId == sl3Id.rawId())
64  SL3metaPrimitivesPerBX[BX].push_back(metaprimitiveIt);
65  }
66 
67  std::vector<bx_sl_vector> bxs_to_consider;
68  bxs_to_consider.reserve(SL1metaPrimitivesPerBX.size());
69  for (auto& prims_sl1 : SL1metaPrimitivesPerBX)
70  bxs_to_consider.push_back(bx_sl_vector({prims_sl1.first, prims_sl1.second, 1}));
71 
72  for (auto& prims_sl3 : SL3metaPrimitivesPerBX)
73  bxs_to_consider.push_back(bx_sl_vector({prims_sl3.first, prims_sl3.second, 3}));
74 
75  std::stable_sort(bxs_to_consider.begin(), bxs_to_consider.end(), bxSort);
76 
77  std::vector<mp_group> mps_q8;
78  std::vector<mp_group> mps_q7;
79  std::vector<mp_group> mps_q6;
80 
81  for (size_t ibx = 1; ibx < bxs_to_consider.size(); ibx++) {
82  for (size_t ibx2 = 0; ibx2 < ibx; ibx2++) {
83  if (bxs_to_consider[ibx].sl != bxs_to_consider[ibx2].sl &&
84  (abs(bxs_to_consider[ibx].bx - bxs_to_consider[ibx2].bx)) <= MAX_BX_FOR_COR) {
85  int isl1 = 0;
86  for (auto& prim1 : bxs_to_consider[ibx].mps) {
87  if (isl1 >= MAX_PRIM_PER_BX_FOR_COR)
88  break;
89  int isl2 = 0;
90  for (auto& prim2 : bxs_to_consider[ibx2].mps) {
91  if (isl2 >= MAX_PRIM_PER_BX_FOR_COR)
92  break;
93  if (bxs_to_consider[ibx].sl == 1) {
94  if (!canCorrelate(prim1, prim2)) {
95  continue;
96  }
97  if (prim1.quality >= 3 && prim2.quality >= 3)
98  mps_q8.push_back(mp_group({prim1, prim2}));
99  else if ((prim1.quality >= 3 && prim2.quality < 3) || (prim1.quality < 3 && prim2.quality >= 3))
100  mps_q7.push_back(mp_group({prim1, prim2}));
101  else
102  mps_q6.push_back(mp_group({prim1, prim2}));
103  } else {
104  if (!canCorrelate(prim2, prim1)) {
105  continue;
106  }
107  if (prim2.quality >= 3 && prim1.quality >= 3)
108  mps_q8.push_back(mp_group({prim2, prim1}));
109  else if ((prim2.quality >= 3 && prim1.quality < 3) || (prim2.quality < 3 && prim1.quality >= 3))
110  mps_q7.push_back(mp_group({prim2, prim1}));
111  else
112  mps_q6.push_back(mp_group({prim2, prim1}));
113  }
114  isl2++;
115  }
116  isl1++;
117  }
118  }
119  } // looping over the 0 -> N-1 BX groups
120  } // looping over the 1 -> N BX groups
121  int iq = 0;
122  for (size_t i = 0; i < mps_q8.size(); i++) {
123  if (iq >= MAX_PRIM_FOR_COR)
124  break;
125  analyze(mps_q8[i], outMPaths);
126  iq += 1;
127  }
128  for (size_t i = 0; i < mps_q7.size(); i++) {
129  if (iq >= MAX_PRIM_FOR_COR)
130  break;
131  analyze(mps_q7[i], outMPaths);
132  iq += 1;
133  }
134  for (size_t i = 0; i < mps_q6.size(); i++) {
135  if (iq >= MAX_PRIM_FOR_COR)
136  break;
137  analyze(mps_q6[i], outMPaths);
138  iq += 1;
139  }
140  }
141 }
int maxdriftinfo_[5][4][14]
void analyze(mp_group mp, std::vector< cmsdt::metaPrimitive > &metaPrimitives)
std::vector< cmsdt::metaPrimitive > mp_group
constexpr int MAX_BX_FOR_COR
Definition: constants.h:333
bool canCorrelate(cmsdt::metaPrimitive mp_sl1, cmsdt::metaPrimitive mp_sl3)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr int MAX_PRIM_PER_BX_FOR_COR
Definition: constants.h:336
bool bxSort(const cmsdt::bx_sl_vector &vA, const cmsdt::bx_sl_vector &vB)
constexpr int MAX_PRIM_FOR_COR
Definition: constants.h:339
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
const bool debug_
#define LogDebug(id)

◆ run() [4/4]

void MuonPathCorFitter::run ( edm::Event iEvent,
const edm::EventSetup iEventSetup,
MuonPathPtrs inMpath,
MuonPathPtrs outMPath 
)
inlineoverridevirtual

Implements MuonPathAnalyzer.

Definition at line 48 of file MuonPathCorFitter.h.

51  {};

Member Data Documentation

◆ both_sl_filename_

edm::FileInPath MuonPathCorFitter::both_sl_filename_

Definition at line 58 of file MuonPathCorFitter.h.

Referenced by fillLuts(), and MuonPathCorFitter().

◆ dT0_correlate_TP_

int MuonPathCorFitter::dT0_correlate_TP_
private

Definition at line 68 of file MuonPathCorFitter.h.

Referenced by canCorrelate().

◆ lut_2sl

std::vector<std::vector<int> > MuonPathCorFitter::lut_2sl
private

Definition at line 71 of file MuonPathCorFitter.h.

Referenced by analyze(), and fillLuts().