CMS 3D CMS Logo

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

#include <MuonPathAssociator.h>

Public Member Functions

void finish ()
 
void initialise (const edm::EventSetup &iEventSetup)
 
bool isNotAPrimo (cmsdt::metaPrimitive first, cmsdt::metaPrimitive second)
 
 MuonPathAssociator (const edm::ParameterSet &pset, edm::ConsumesCollector &iC, std::shared_ptr< GlobalCoordsObtainer > &globalcoordsobtainer)
 
void printmPC (cmsdt::metaPrimitive mP)
 
void removeSharingFits (std::vector< cmsdt::metaPrimitive > &chamberMPaths, std::vector< cmsdt::metaPrimitive > &allMPaths)
 
void removeSharingHits (std::vector< cmsdt::metaPrimitive > &firstMPaths, std::vector< cmsdt::metaPrimitive > &secondMPaths, std::vector< cmsdt::metaPrimitive > &allMPaths)
 
void run (edm::Event &iEvent, const edm::EventSetup &iEventSetup, edm::Handle< DTDigiCollection > digis, std::vector< cmsdt::metaPrimitive > &inMPaths, std::vector< cmsdt::metaPrimitive > &outMPaths)
 
bool shareFit (cmsdt::metaPrimitive first, cmsdt::metaPrimitive second)
 
 ~MuonPathAssociator ()
 

Public Attributes

DTGeometry const * dtGeo_
 
edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomH_
 

Private Member Functions

void correlateMPaths (edm::Handle< DTDigiCollection > digis, std::vector< cmsdt::metaPrimitive > &inMPaths, std::vector< cmsdt::metaPrimitive > &outMPaths)
 
bool hasPosRF (int wh, int sec)
 

Private Attributes

bool allow_confirmation_
 
double chi2corTh_
 
bool clean_chi2_correlation_
 
double dBX_correlate_TP_
 
const bool debug_
 
double dT0_correlate_TP_
 
double dTanPsi_correlate_TP_
 
std::shared_ptr< GlobalCoordsObtainerglobalcoordsobtainer_
 
double minx_match_2digis_
 
edm::FileInPath shift_filename_
 
std::map< int, float > shiftinfo_
 
bool useBX_correlation_
 

Detailed Description

Definition at line 35 of file MuonPathAssociator.h.

Constructor & Destructor Documentation

◆ MuonPathAssociator()

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

Definition at line 13 of file MuonPathAssociator.cc.

References edm::BeginRun, debug_, dtGeomH_, edm::ConsumesCollector::esConsumes(), Exception, edm::FileInPath::fullPath(), globalcoordsobtainer_, LogDebug, muonDTDigis_cfi::pset, nano_mu_digi_cff::rawId, edm::shift, shift_filename_, and shiftinfo_.

16  : debug_(pset.getUntrackedParameter<bool>("debug")),
17  clean_chi2_correlation_(pset.getParameter<bool>("clean_chi2_correlation")),
18  useBX_correlation_(pset.getParameter<bool>("useBX_correlation")),
19  allow_confirmation_(pset.getParameter<bool>("allow_confirmation")),
20  dT0_correlate_TP_(pset.getParameter<double>("dT0_correlate_TP")),
21  dBX_correlate_TP_(pset.getParameter<int>("dBX_correlate_TP")),
22  dTanPsi_correlate_TP_(pset.getParameter<double>("dTanPsi_correlate_TP")),
23  minx_match_2digis_(pset.getParameter<double>("minx_match_2digis")),
24  chi2corTh_(pset.getParameter<double>("chi2corTh")) {
25  // Obtention of parameters
26 
27  if (debug_)
28  LogDebug("MuonPathAssociator") << "MuonPathAssociator: constructor";
29 
30  //shift
31  int rawId;
32  shift_filename_ = pset.getParameter<edm::FileInPath>("shift_filename");
33  std::ifstream ifin3(shift_filename_.fullPath());
34  double shift;
35  if (ifin3.fail()) {
36  throw cms::Exception("Missing Input File")
37  << "MuonPathAnalyzerPerSL::MuonPathAnalyzerPerSL() - Cannot find " << shift_filename_.fullPath();
38  }
39  while (ifin3.good()) {
40  ifin3 >> rawId >> shift;
42  }
43 
45  globalcoordsobtainer_ = globalcoordsobtainer;
46 }
std::map< int, float > shiftinfo_
edm::FileInPath shift_filename_
std::shared_ptr< GlobalCoordsObtainer > globalcoordsobtainer_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH_
static unsigned int const shift
const std::string & fullPath() const
Definition: FileInPath.cc:144
#define LogDebug(id)

◆ ~MuonPathAssociator()

MuonPathAssociator::~MuonPathAssociator ( )

Definition at line 48 of file MuonPathAssociator.cc.

References debug_, and LogDebug.

48  {
49  if (debug_)
50  LogDebug("MuonPathAssociator") << "MuonPathAssociator: destructor";
51 }
#define LogDebug(id)

Member Function Documentation

◆ correlateMPaths()

void MuonPathAssociator::correlateMPaths ( edm::Handle< DTDigiCollection digis,
std::vector< cmsdt::metaPrimitive > &  inMPaths,
std::vector< cmsdt::metaPrimitive > &  outMPaths 
)
private

Definition at line 81 of file MuonPathAssociator.cc.

References funct::abs(), allow_confirmation_, cmsdt::CELL_HEIGHT, cmsdt::CELL_LENGTH, cmsdt::CELL_SEMILENGTH, cmsdt::CH_CENTER_TO_MID_SL_X2, DTGeometry::chamber(), isoTrack_cff::chi2, chi2corTh_, IntegrityClient_cfi::ChId, cmsdt::CHIGHQ, clean_chi2_correlation_, cmsdt::CLOWQ, dBX_correlate_TP_, debug_, cmsdt::DRIFT_SPEED, cmsdt::DRIFT_SPEED_X4, dT0_correlate_TP_, dTanPsi_correlate_TP_, dtGeo_, globalcoordsobtainer_, hasPosRF(), cmsdt::HIGHHIGHQ, cmsdt::HIGHLOWQ, cmsdt::HIGHQ, mps_fire::i, cmsdt::INCREASED_RES_POS, cmsdt::INCREASED_RES_POS_POW, cmsdt::INCREASED_RES_SLOPE_POW, createfilelist::int, isNotAPrimo(), DTLayerId::layer(), cmsdt::LHC_CLK_FREQ, LogDebug, cmsdt::LOWLOWQ, cmsdt::LOWQ, minx_match_2digis_, NUM_LAYERS, cmsdt::NUM_LAYERS_2SL, convertSQLiteXML::ok, or, phi, PV3DBase< T, PVType, FrameType >::phi(), cmsdt::PHI_CONV, funct::pow(), printmPC(), quality, DetId::rawId(), removeSharingFits(), removeSharingHits(), edm::second(), DTChamberId::sector(), edm::shift, shiftinfo_, Validation_hcalonly_cfi::sign, DTChamberId::station(), DTSuperLayerId::superLayer(), suppress, GeomDet::toGlobal(), useBX_correlation_, cmsdt::VERT_PHI1_PHI3, cmsdt::VERT_PHI1_PHI3_INV, DTChamberId::wheel(), cmsdt::X_POS_L3, cmsdt::X_POS_L4, z, and cmsdt::Z_SHIFT_MB4.

Referenced by run().

83  {
84  if (debug_)
85  LogDebug("MuonPathAssociator") << "starting correlation";
86 
87  for (int wh = -2; wh <= 2; wh++) { //wheel num: -2, -1, 0, +1, +2
88  for (int st = 1; st <= 4; st++) { //station num (MB): 1, 2, 3, 4
89  for (int se = 1; se <= 14; se++) { //sector number: 1-12, special sectors 13, 14 to account for bigger MB4s
90  if (se >= 13 && st != 4)
91  continue;
92 
93  DTChamberId ChId(wh, st, se);
94  DTSuperLayerId sl1Id(wh, st, se, 1);
95  DTSuperLayerId sl3Id(wh, st, se, 3);
96 
97  //filterSL1
98  std::vector<metaPrimitive> SL1metaPrimitives;
99  for (const auto &metaprimitiveIt : inMPaths) {
100  if (metaprimitiveIt.rawId == sl1Id.rawId())
101  SL1metaPrimitives.push_back(metaprimitiveIt);
102  }
103 
104  //filterSL3
105  std::vector<metaPrimitive> SL3metaPrimitives;
106  for (const auto &metaprimitiveIt : inMPaths) {
107  if (metaprimitiveIt.rawId == sl3Id.rawId())
108  SL3metaPrimitives.push_back(metaprimitiveIt);
109  }
110 
111  if (SL1metaPrimitives.empty() and SL3metaPrimitives.empty())
112  continue;
113 
114  if (debug_)
115  LogDebug("MuonPathAssociator") << "correlating " << SL1metaPrimitives.size() << " metaPrim in SL1 and "
116  << SL3metaPrimitives.size() << " in SL3 for " << sl3Id;
117 
118  bool at_least_one_correlation = false;
119  bool at_least_one_SL1_confirmation = false;
120  bool at_least_one_SL3_confirmation = false;
121 
122  bool useFitSL1[SL1metaPrimitives.size()];
123  for (unsigned int i = 0; i < SL1metaPrimitives.size(); i++)
124  useFitSL1[i] = false;
125  bool useFitSL3[SL3metaPrimitives.size()];
126  for (unsigned int i = 0; i < SL3metaPrimitives.size(); i++)
127  useFitSL3[i] = false;
128 
129  //SL1-SL3
130  vector<metaPrimitive> chamberMetaPrimitives;
131  vector<metaPrimitive> confirmedMetaPrimitives;
132  vector<metaPrimitive> normalMetaPrimitives;
133  int sl1 = 0;
134  int sl3 = 0;
135  for (auto SL1metaPrimitive = SL1metaPrimitives.begin(); SL1metaPrimitive != SL1metaPrimitives.end();
136  ++SL1metaPrimitive, sl1++, sl3 = -1) {
138  at_least_one_correlation = false;
139  for (auto SL3metaPrimitive = SL3metaPrimitives.begin(); SL3metaPrimitive != SL3metaPrimitives.end();
140  ++SL3metaPrimitive, sl3++) {
141  if (std::abs(SL1metaPrimitive->tanPhi - SL3metaPrimitive->tanPhi) > dTanPsi_correlate_TP_)
142  continue; //TanPsi match, SliceTest only
143  if (useBX_correlation_) {
144  if (abs(round(SL1metaPrimitive->t0 / (float)LHC_CLK_FREQ) -
145  round(SL3metaPrimitive->t0 / (float)LHC_CLK_FREQ)) > dBX_correlate_TP_)
146  continue; //BX match
147  } else {
148  if (std::abs(SL1metaPrimitive->t0 - SL3metaPrimitive->t0) >= dT0_correlate_TP_)
149  continue; //time match
150  }
151  long int PosSL1 = (int)round(INCREASED_RES_POS_POW * 10 * SL1metaPrimitive->x);
152  long int PosSL3 = (int)round(INCREASED_RES_POS_POW * 10 * SL3metaPrimitive->x);
153  double NewSlope = -999.;
154 
155  long int pos = (PosSL3 + PosSL1) / 2;
156  // FW always rounds down (e.g 29.5 -> 29, -29.5 -> -30). For negative numbers, we don't do the same.
157  // Let's fix it (this also happens for the slope)
158  if (((PosSL3 + PosSL1) % 2 != 0) && (pos < 0)) {
159  pos--;
160  }
161 
162  long int difPos_mm_x4 = PosSL3 - PosSL1;
163  long int tanPsi_x4096_x128 = (difPos_mm_x4)*VERT_PHI1_PHI3_INV;
164  long int tanpsi = tanPsi_x4096_x128 / ((long int)pow(2, 5 + INCREASED_RES_POS));
165  if (tanpsi < 0 && tanPsi_x4096_x128 % ((long int)pow(2, 5 + INCREASED_RES_POS)) != 0)
166  tanpsi--;
167  NewSlope = -tanpsi / (double)INCREASED_RES_SLOPE_POW;
168  double MeanT0 = (SL1metaPrimitive->t0 + SL3metaPrimitive->t0) / 2;
169  double MeanPos = (PosSL3 + PosSL1) / (2. * INCREASED_RES_POS_POW * 10);
170 
171  DTSuperLayerId SLId1(SL1metaPrimitive->rawId);
172  DTSuperLayerId SLId3(SL3metaPrimitive->rawId);
173  DTWireId wireId1(SLId1, 2, 1);
174  DTWireId wireId3(SLId3, 2, 1);
175 
176  int shift_sl1 = int(round(shiftinfo_[wireId1.rawId()] * INCREASED_RES_POS_POW * 10));
177  int shift_sl3 = int(round(shiftinfo_[wireId3.rawId()] * INCREASED_RES_POS_POW * 10));
178  if (shift_sl1 < shift_sl3) {
179  pos -= shift_sl1;
180  } else
181  pos -= shift_sl3;
182 
183  int wi[8], tdc[8], lat[8];
184  wi[0] = SL1metaPrimitive->wi1;
185  tdc[0] = SL1metaPrimitive->tdc1;
186  lat[0] = SL1metaPrimitive->lat1;
187  wi[1] = SL1metaPrimitive->wi2;
188  tdc[1] = SL1metaPrimitive->tdc2;
189  lat[1] = SL1metaPrimitive->lat2;
190  wi[2] = SL1metaPrimitive->wi3;
191  tdc[2] = SL1metaPrimitive->tdc3;
192  lat[2] = SL1metaPrimitive->lat3;
193  wi[3] = SL1metaPrimitive->wi4;
194  tdc[3] = SL1metaPrimitive->tdc4;
195  lat[3] = SL1metaPrimitive->lat4;
196  wi[4] = SL3metaPrimitive->wi1;
197  tdc[4] = SL3metaPrimitive->tdc1;
198  lat[4] = SL3metaPrimitive->lat1;
199  wi[5] = SL3metaPrimitive->wi2;
200  tdc[5] = SL3metaPrimitive->tdc2;
201  lat[5] = SL3metaPrimitive->lat2;
202  wi[6] = SL3metaPrimitive->wi3;
203  tdc[6] = SL3metaPrimitive->tdc3;
204  lat[6] = SL3metaPrimitive->lat3;
205  wi[7] = SL3metaPrimitive->wi4;
206  tdc[7] = SL3metaPrimitive->tdc4;
207  lat[7] = SL3metaPrimitive->lat4;
208 
209  long int chi2 = 0;
210 
211  long int Z_FACTOR_CORR[8] = {-6, -2, 2, 6, -6, -2, 2, 6};
212 
213  for (int i = 0; i < 8; i++) {
214  int sign = 2 * (i / 4) - 1;
215  Z_FACTOR_CORR[i] = Z_FACTOR_CORR[i] * CELL_HEIGHT + CH_CENTER_TO_MID_SL_X2 * sign;
216  }
217  long int sum_A, sum_B;
218  for (int i = 0; i < NUM_LAYERS_2SL; i++) {
219  long int shift, slTime;
220  if (i / NUM_LAYERS == 0) { // layers 0 - 3 -> SL1
221  shift = shift_sl1;
222  slTime = SL1metaPrimitive->t0;
223  } else { // layers 4 - 7 -> SL3
224  shift = shift_sl3;
225  slTime = SL3metaPrimitive->t0;
226  }
227  if (wi[i] != -1) {
228  long int drift_dist_um_x4 = DRIFT_SPEED_X4 * (((long int)tdc[i]) - slTime);
229  long int wireHorizPos_x4 =
230  (CELL_LENGTH * wi[i] + ((i + 1) % 2) * CELL_SEMILENGTH) * INCREASED_RES_POS_POW;
231  long int pos_mm_x4;
232 
233  if (lat[i] == 0) {
234  pos_mm_x4 = wireHorizPos_x4 - (drift_dist_um_x4 >> 10);
235  } else {
236  pos_mm_x4 = wireHorizPos_x4 + (drift_dist_um_x4 >> 10);
237  }
238  sum_A = shift + pos_mm_x4 - (long int)round(MeanPos * 10 * INCREASED_RES_POS_POW);
239  sum_A = sum_A << (14 - INCREASED_RES_POS);
240  sum_B = Z_FACTOR_CORR[i] * (long int)round(-NewSlope * INCREASED_RES_SLOPE_POW);
241  chi2 += ((sum_A - sum_B) * (sum_A - sum_B)) >> 2;
242  }
243  }
244 
245  double newChi2 = (double)(chi2 >> INCREASED_RES_POS_POW) / (1024. * 100.);
246 
247  if (newChi2 > chi2corTh_)
248  continue;
249 
250  // Fill the used vectors
251  useFitSL1[sl1] = true;
252  useFitSL3[sl3] = true;
253 
254  int quality = 0;
255  if (SL3metaPrimitive->quality == LOWQ and SL1metaPrimitive->quality == LOWQ)
256  quality = LOWLOWQ;
257 
258  if ((SL3metaPrimitive->quality == HIGHQ && SL1metaPrimitive->quality == LOWQ) or
259  (SL1metaPrimitive->quality == HIGHQ && SL3metaPrimitive->quality == LOWQ))
260  quality = HIGHLOWQ;
261 
262  if (SL3metaPrimitive->quality == HIGHQ && SL1metaPrimitive->quality == HIGHQ)
263  quality = HIGHHIGHQ;
264 
265  double phi = -999.;
266  double phiB = -999.;
267  double phi_cmssw = -999.;
268  double phiB_cmssw = -999.;
269  double z = 0;
270  if (ChId.station() >= 3)
271  z = Z_SHIFT_MB4;
272  GlobalPoint jm_x_cmssw_global = dtGeo_->chamber(ChId)->toGlobal(
273  LocalPoint(MeanPos, 0., z)); //Jm_x is already extrapolated to the middle of the SL
274  int thisec = ChId.sector();
275  if (se == 13)
276  thisec = 4;
277  if (se == 14)
278  thisec = 10;
279  phi_cmssw = jm_x_cmssw_global.phi() - PHI_CONV * (thisec - 1);
280  double psi = atan(NewSlope);
281  phiB_cmssw = hasPosRF(ChId.wheel(), ChId.sector()) ? psi - phi_cmssw : -psi - phi_cmssw;
282 
283  auto global_coords = globalcoordsobtainer_->get_global_coordinates(ChId.rawId(), 0, pos, tanpsi);
284  phi = global_coords[0];
285  phiB = global_coords[1];
286 
288  outMPaths.emplace_back(ChId.rawId(),
289  MeanT0,
290  MeanPos,
291  NewSlope,
292  phi,
293  phiB,
294  phi_cmssw,
295  phiB_cmssw,
296  newChi2,
297  quality,
298  SL1metaPrimitive->wi1,
299  SL1metaPrimitive->tdc1,
300  SL1metaPrimitive->lat1,
301  SL1metaPrimitive->wi2,
302  SL1metaPrimitive->tdc2,
303  SL1metaPrimitive->lat2,
304  SL1metaPrimitive->wi3,
305  SL1metaPrimitive->tdc3,
306  SL1metaPrimitive->lat3,
307  SL1metaPrimitive->wi4,
308  SL1metaPrimitive->tdc4,
309  SL1metaPrimitive->lat4,
310  SL3metaPrimitive->wi1,
311  SL3metaPrimitive->tdc1,
312  SL3metaPrimitive->lat1,
313  SL3metaPrimitive->wi2,
314  SL3metaPrimitive->tdc2,
315  SL3metaPrimitive->lat2,
316  SL3metaPrimitive->wi3,
317  SL3metaPrimitive->tdc3,
318  SL3metaPrimitive->lat3,
319  SL3metaPrimitive->wi4,
320  SL3metaPrimitive->tdc4,
321  SL3metaPrimitive->lat4);
322  else
323  chamberMetaPrimitives.emplace_back(ChId.rawId(),
324  MeanT0,
325  MeanPos,
326  NewSlope,
327  phi,
328  phiB,
329  phi_cmssw,
330  phiB_cmssw,
331  newChi2,
332  quality,
333  SL1metaPrimitive->wi1,
334  SL1metaPrimitive->tdc1,
335  SL1metaPrimitive->lat1,
336  SL1metaPrimitive->wi2,
337  SL1metaPrimitive->tdc2,
338  SL1metaPrimitive->lat2,
339  SL1metaPrimitive->wi3,
340  SL1metaPrimitive->tdc3,
341  SL1metaPrimitive->lat3,
342  SL1metaPrimitive->wi4,
343  SL1metaPrimitive->tdc4,
344  SL1metaPrimitive->lat4,
345  SL3metaPrimitive->wi1,
346  SL3metaPrimitive->tdc1,
347  SL3metaPrimitive->lat1,
348  SL3metaPrimitive->wi2,
349  SL3metaPrimitive->tdc2,
350  SL3metaPrimitive->lat2,
351  SL3metaPrimitive->wi3,
352  SL3metaPrimitive->tdc3,
353  SL3metaPrimitive->lat3,
354  SL3metaPrimitive->wi4,
355  SL3metaPrimitive->tdc4,
356  SL3metaPrimitive->lat4);
357 
358  at_least_one_correlation = true;
359  }
360 
361  if (at_least_one_correlation == false &&
362  allow_confirmation_ == true) { //no correlation was found, trying with pairs of two digis in the other SL
363  int matched_digis = 0;
364  double minx = minx_match_2digis_;
365  double min2x = minx_match_2digis_;
366  int best_tdc = -1;
367  int next_tdc = -1;
368  int best_wire = -1;
369  int next_wire = -1;
370  int best_layer = -1;
371  int next_layer = -1;
372  int best_lat = -1;
373  int next_lat = -1;
374  int lat = -1;
375  for (const auto &dtLayerId_It : *dtdigis) {
376  const DTLayerId dtLId = dtLayerId_It.first;
377  // creating a new DTSuperLayerId object to compare with the required SL id
378  const DTSuperLayerId dtSLId(dtLId.wheel(), dtLId.station(), dtLId.sector(), dtLId.superLayer());
379  if (dtSLId.rawId() != sl3Id.rawId())
380  continue;
381  double l_shift = 0;
382  if (dtLId.layer() == 4)
383  l_shift = X_POS_L4;
384  else if (dtLId.layer() == 3)
385  l_shift = X_POS_L3;
386  else if (dtLId.layer() == 2)
387  l_shift = -1 * X_POS_L3;
388  else if (dtLId.layer() == 1)
389  l_shift = -1 * X_POS_L4;
390  double x_inSL3 = SL1metaPrimitive->x - SL1metaPrimitive->tanPhi * (VERT_PHI1_PHI3 + l_shift);
391  for (auto digiIt = (dtLayerId_It.second).first; digiIt != (dtLayerId_It.second).second; ++digiIt) {
392  DTWireId wireId(dtLId, (*digiIt).wire());
393  if ((*digiIt).time() < SL1metaPrimitive->t0)
394  continue;
395  double x_wire =
396  shiftinfo_[wireId.rawId()] + ((*digiIt).time() - SL1metaPrimitive->t0) * DRIFT_SPEED / 10.;
397  double x_wire_left =
398  shiftinfo_[wireId.rawId()] - ((*digiIt).time() - SL1metaPrimitive->t0) * DRIFT_SPEED / 10.;
399  lat = 1;
400  if (std::abs(x_inSL3 - x_wire) > std::abs(x_inSL3 - x_wire_left)) {
401  x_wire = x_wire_left; //choose the closest laterality
402  lat = 0;
403  }
404  if (std::abs(x_inSL3 - x_wire) < minx) {
405  // different layer than the stored in best, hit added, matched_digis++;. This approach in somewhat
406  // buggy, as we could have stored as best LayerX -> LayerY -> LayerX, and this should
407  // count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
408  // makes no difference
409  if (dtLId.layer() != best_layer) {
410  minx = std::abs(x_inSL3 - x_wire);
411  next_wire = best_wire;
412  next_tdc = best_tdc;
413  next_layer = best_layer;
414  next_lat = best_lat;
415 
416  best_wire = (*digiIt).wire();
417  best_tdc = (*digiIt).time();
418  best_layer = dtLId.layer();
419  best_lat = lat;
420  matched_digis++;
421  } else if (dtLId.layer() ==
422  best_layer) { // same layer than stored, just substituting the hit, no matched_digis++;
423  best_wire = (*digiIt).wire();
424  best_tdc = (*digiIt).time();
425  best_layer = dtLId.layer();
426  best_lat = lat;
427  }
428  } else if ((std::abs(x_inSL3 - x_wire) >= minx) && (std::abs(x_inSL3 - x_wire) < min2x)) {
429  // same layer than the stored in best, no hit added
430  if (dtLId.layer() == best_layer)
431  continue;
432  // different layer than the stored in next, hit added. This approach in somewhat
433  // buggy, as we could have stored as next LayerX -> LayerY -> LayerX, and this should
434  // count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
435  // makes no difference
436  else if (dtLId.layer() != next_layer)
437  matched_digis++;
438  // whether the layer is the same for this hit and the stored in next, we substitute
439  // the one stored and modify the min distance
440  min2x = std::abs(x_inSL3 - x_wire);
441  next_wire = (*digiIt).wire();
442  next_tdc = (*digiIt).time();
443  next_layer = dtLId.layer();
444  next_lat = lat;
445  }
446  }
447  }
448  if (matched_digis >= 2 and best_layer != -1 and next_layer != -1) {
449  int new_quality = CHIGHQ;
450  if (SL1metaPrimitive->quality == LOWQ)
451  new_quality = CLOWQ;
452 
453  int wi1 = -1;
454  int tdc1 = -1;
455  int lat1 = -1;
456  int wi2 = -1;
457  int tdc2 = -1;
458  int lat2 = -1;
459  int wi3 = -1;
460  int tdc3 = -1;
461  int lat3 = -1;
462  int wi4 = -1;
463  int tdc4 = -1;
464  int lat4 = -1;
465 
466  if (next_layer == 1) {
467  wi1 = next_wire;
468  tdc1 = next_tdc;
469  lat1 = next_lat;
470  }
471  if (next_layer == 2) {
472  wi2 = next_wire;
473  tdc2 = next_tdc;
474  lat2 = next_lat;
475  }
476  if (next_layer == 3) {
477  wi3 = next_wire;
478  tdc3 = next_tdc;
479  lat3 = next_lat;
480  }
481  if (next_layer == 4) {
482  wi4 = next_wire;
483  tdc4 = next_tdc;
484  lat4 = next_lat;
485  }
486 
487  if (best_layer == 1) {
488  wi1 = best_wire;
489  tdc1 = best_tdc;
490  lat1 = best_lat;
491  }
492  if (best_layer == 2) {
493  wi2 = best_wire;
494  tdc2 = best_tdc;
495  lat2 = best_lat;
496  }
497  if (best_layer == 3) {
498  wi3 = best_wire;
499  tdc3 = best_tdc;
500  lat3 = best_lat;
501  }
502  if (best_layer == 4) {
503  wi4 = best_wire;
504  tdc4 = best_tdc;
505  lat4 = best_lat;
506  }
507 
509  outMPaths.emplace_back(metaPrimitive({ChId.rawId(),
510  SL1metaPrimitive->t0,
511  SL1metaPrimitive->x,
512  SL1metaPrimitive->tanPhi,
513  SL1metaPrimitive->phi,
514  SL1metaPrimitive->phiB,
515  SL1metaPrimitive->phi_cmssw,
516  SL1metaPrimitive->phiB_cmssw,
517  SL1metaPrimitive->chi2,
518  new_quality,
519  SL1metaPrimitive->wi1,
520  SL1metaPrimitive->tdc1,
521  SL1metaPrimitive->lat1,
522  SL1metaPrimitive->wi2,
523  SL1metaPrimitive->tdc2,
524  SL1metaPrimitive->lat2,
525  SL1metaPrimitive->wi3,
526  SL1metaPrimitive->tdc3,
527  SL1metaPrimitive->lat3,
528  SL1metaPrimitive->wi4,
529  SL1metaPrimitive->tdc4,
530  SL1metaPrimitive->lat4,
531  wi1,
532  tdc1,
533  lat1,
534  wi2,
535  tdc2,
536  lat2,
537  wi3,
538  tdc3,
539  lat3,
540  wi4,
541  tdc4,
542  lat4,
543  -1}));
544  else
545  confirmedMetaPrimitives.emplace_back(metaPrimitive({ChId.rawId(),
546  SL1metaPrimitive->t0,
547  SL1metaPrimitive->x,
548  SL1metaPrimitive->tanPhi,
549  SL1metaPrimitive->phi,
550  SL1metaPrimitive->phiB,
551  SL1metaPrimitive->phi_cmssw,
552  SL1metaPrimitive->phiB_cmssw,
553  SL1metaPrimitive->chi2,
554  new_quality,
555  SL1metaPrimitive->wi1,
556  SL1metaPrimitive->tdc1,
557  SL1metaPrimitive->lat1,
558  SL1metaPrimitive->wi2,
559  SL1metaPrimitive->tdc2,
560  SL1metaPrimitive->lat2,
561  SL1metaPrimitive->wi3,
562  SL1metaPrimitive->tdc3,
563  SL1metaPrimitive->lat3,
564  SL1metaPrimitive->wi4,
565  SL1metaPrimitive->tdc4,
566  SL1metaPrimitive->lat4,
567  wi1,
568  tdc1,
569  lat1,
570  wi2,
571  tdc2,
572  lat2,
573  wi3,
574  tdc3,
575  lat3,
576  wi4,
577  tdc4,
578  lat4,
579  -1}));
580  useFitSL1[sl1] = true;
581  at_least_one_SL1_confirmation = true;
582  }
583  }
584  }
585 
586  //finish SL1-SL3
587 
588  //SL3-SL1
589  sl3 = 0;
590  for (auto SL3metaPrimitive = SL3metaPrimitives.begin(); SL3metaPrimitive != SL3metaPrimitives.end();
591  ++SL3metaPrimitive, sl3++) {
592  [[clang::suppress]] if (useFitSL3[sl3])
593  continue;
594  if ((at_least_one_correlation == false || clean_chi2_correlation_) &&
595  allow_confirmation_) { //no correlation was found, trying with pairs of two digis in the other SL
596 
597  int matched_digis = 0;
598  double minx = minx_match_2digis_;
599  double min2x = minx_match_2digis_;
600  int best_tdc = -1;
601  int next_tdc = -1;
602  int best_wire = -1;
603  int next_wire = -1;
604  int best_layer = -1;
605  int next_layer = -1;
606  int best_lat = -1;
607  int next_lat = -1;
608  int lat = -1;
609 
610  for (const auto &dtLayerId_It : *dtdigis) {
611  const DTLayerId dtLId = dtLayerId_It.first;
612  // creating a new DTSuperLayerId object to compare with the required SL id
613  const DTSuperLayerId dtSLId(dtLId.wheel(), dtLId.station(), dtLId.sector(), dtLId.superLayer());
614  if (dtSLId.rawId() != sl1Id.rawId())
615  continue;
616  double l_shift = 0;
617  if (dtLId.layer() == 4)
618  l_shift = X_POS_L4;
619  if (dtLId.layer() == 3)
620  l_shift = X_POS_L3;
621  if (dtLId.layer() == 2)
622  l_shift = -1 * X_POS_L3;
623  if (dtLId.layer() == 1)
624  l_shift = -1 * X_POS_L4;
625  double x_inSL1 = SL3metaPrimitive->x + SL3metaPrimitive->tanPhi * (VERT_PHI1_PHI3 - l_shift);
626  for (auto digiIt = (dtLayerId_It.second).first; digiIt != (dtLayerId_It.second).second; ++digiIt) {
627  DTWireId wireId(dtLId, (*digiIt).wire());
628  if ((*digiIt).time() < SL3metaPrimitive->t0)
629  continue;
630  double x_wire =
631  shiftinfo_[wireId.rawId()] + ((*digiIt).time() - SL3metaPrimitive->t0) * DRIFT_SPEED / 10.;
632  double x_wire_left =
633  shiftinfo_[wireId.rawId()] - ((*digiIt).time() - SL3metaPrimitive->t0) * DRIFT_SPEED / 10.;
634  lat = 1;
635  if (std::abs(x_inSL1 - x_wire) > std::abs(x_inSL1 - x_wire_left)) {
636  x_wire = x_wire_left; //choose the closest laterality
637  lat = 0;
638  }
639  if (std::abs(x_inSL1 - x_wire) < minx) {
640  // different layer than the stored in best, hit added, matched_digis++;. This approach in somewhat
641  // buggy, as we could have stored as best LayerX -> LayerY -> LayerX, and this should
642  // count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
643  // makes no difference
644  if (dtLId.layer() != best_layer) {
645  minx = std::abs(x_inSL1 - x_wire);
646  next_wire = best_wire;
647  next_tdc = best_tdc;
648  next_layer = best_layer;
649  next_lat = best_lat;
650 
651  best_wire = (*digiIt).wire();
652  best_tdc = (*digiIt).time();
653  best_layer = dtLId.layer();
654  best_lat = lat;
655  matched_digis++;
656  } else if (dtLId.layer() ==
657  best_layer) { // same layer than stored, just substituting the hit, no matched_digis++;
658  best_wire = (*digiIt).wire();
659  best_tdc = (*digiIt).time();
660  best_layer = dtLId.layer();
661  best_lat = lat;
662  }
663  } else if ((std::abs(x_inSL1 - x_wire) >= minx) && (std::abs(x_inSL1 - x_wire) < min2x)) {
664  // same layer than the stored in best, no hit added
665  if (dtLId.layer() == best_layer)
666  continue;
667  // different layer than the stored in next, hit added. This approach in somewhat
668  // buggy, as we could have stored as next LayerX -> LayerY -> LayerX, and this should
669  // count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
670  // makes no difference
671  else if (dtLId.layer() != next_layer)
672  matched_digis++;
673  // whether the layer is the same for this hit and the stored in next, we substitute
674  // the one stored and modify the min distance
675  min2x = std::abs(x_inSL1 - x_wire);
676  next_wire = (*digiIt).wire();
677  next_tdc = (*digiIt).time();
678  next_layer = dtLId.layer();
679  next_lat = lat;
680  }
681  }
682  }
683  if (matched_digis >= 2 and best_layer != -1 and next_layer != -1) {
684  int new_quality = CHIGHQ;
685  if (SL3metaPrimitive->quality == LOWQ)
686  new_quality = CLOWQ;
687 
688  int wi1 = -1;
689  int tdc1 = -1;
690  int lat1 = -1;
691  int wi2 = -1;
692  int tdc2 = -1;
693  int lat2 = -1;
694  int wi3 = -1;
695  int tdc3 = -1;
696  int lat3 = -1;
697  int wi4 = -1;
698  int tdc4 = -1;
699  int lat4 = -1;
700 
701  if (next_layer == 1) {
702  wi1 = next_wire;
703  tdc1 = next_tdc;
704  lat1 = next_lat;
705  }
706  if (next_layer == 2) {
707  wi2 = next_wire;
708  tdc2 = next_tdc;
709  lat2 = next_lat;
710  }
711  if (next_layer == 3) {
712  wi3 = next_wire;
713  tdc3 = next_tdc;
714  lat3 = next_lat;
715  }
716  if (next_layer == 4) {
717  wi4 = next_wire;
718  tdc4 = next_tdc;
719  lat4 = next_lat;
720  }
721 
722  if (best_layer == 1) {
723  wi1 = best_wire;
724  tdc1 = best_tdc;
725  lat1 = best_lat;
726  }
727  if (best_layer == 2) {
728  wi2 = best_wire;
729  tdc2 = best_tdc;
730  lat2 = best_lat;
731  }
732  if (best_layer == 3) {
733  wi3 = best_wire;
734  tdc3 = best_tdc;
735  lat3 = best_lat;
736  }
737  if (best_layer == 4) {
738  wi4 = best_wire;
739  tdc4 = best_tdc;
740  lat4 = best_lat;
741  }
742 
744  outMPaths.push_back(metaPrimitive({ChId.rawId(),
745  SL3metaPrimitive->t0,
746  SL3metaPrimitive->x,
747  SL3metaPrimitive->tanPhi,
748  SL3metaPrimitive->phi,
749  SL3metaPrimitive->phiB,
750  SL3metaPrimitive->phi_cmssw,
751  SL3metaPrimitive->phiB_cmssw,
752  SL3metaPrimitive->chi2,
753  new_quality,
754  wi1,
755  tdc1,
756  lat1,
757  wi2,
758  tdc2,
759  lat2,
760  wi3,
761  tdc3,
762  lat3,
763  wi4,
764  tdc4,
765  lat4,
766  SL3metaPrimitive->wi1,
767  SL3metaPrimitive->tdc1,
768  SL3metaPrimitive->lat1,
769  SL3metaPrimitive->wi2,
770  SL3metaPrimitive->tdc2,
771  SL3metaPrimitive->lat2,
772  SL3metaPrimitive->wi3,
773  SL3metaPrimitive->tdc3,
774  SL3metaPrimitive->lat3,
775  SL3metaPrimitive->wi4,
776  SL3metaPrimitive->tdc4,
777  SL3metaPrimitive->lat4,
778  -1}));
779  else
780  confirmedMetaPrimitives.push_back(metaPrimitive({ChId.rawId(),
781  SL3metaPrimitive->t0,
782  SL3metaPrimitive->x,
783  SL3metaPrimitive->tanPhi,
784  SL3metaPrimitive->phi,
785  SL3metaPrimitive->phiB,
786  SL3metaPrimitive->phi_cmssw,
787  SL3metaPrimitive->phiB_cmssw,
788  SL3metaPrimitive->chi2,
789  new_quality,
790  wi1,
791  tdc1,
792  lat1,
793  wi2,
794  tdc2,
795  lat2,
796  wi3,
797  tdc3,
798  lat3,
799  wi4,
800  tdc4,
801  lat4,
802  SL3metaPrimitive->wi1,
803  SL3metaPrimitive->tdc1,
804  SL3metaPrimitive->lat1,
805  SL3metaPrimitive->wi2,
806  SL3metaPrimitive->tdc2,
807  SL3metaPrimitive->lat2,
808  SL3metaPrimitive->wi3,
809  SL3metaPrimitive->tdc3,
810  SL3metaPrimitive->lat3,
811  SL3metaPrimitive->wi4,
812  SL3metaPrimitive->tdc4,
813  SL3metaPrimitive->lat4,
814  -1}));
815  useFitSL3[sl3] = true;
816  at_least_one_SL3_confirmation = true;
817  }
818  }
819  }
820  // Start correlation cleaning
822  if (debug_)
823  LogDebug("MuonPathAssociator") << "Pushing back correlated MPs to the MPs collection";
824  removeSharingFits(chamberMetaPrimitives, outMPaths);
825  }
827  if (debug_)
828  LogDebug("MuonPathAssociator") << "Pushing back confirmed MPs to the complete vector";
829  removeSharingHits(confirmedMetaPrimitives, chamberMetaPrimitives, outMPaths);
830  }
831 
832  //finish SL3-SL1
833  if (at_least_one_correlation == false || clean_chi2_correlation_) {
834  if (debug_ && !at_least_one_correlation)
835  LogDebug("MuonPathAssociator")
836  << "correlation we found zero correlations, adding both collections as they are to the outMPaths";
837  if (debug_)
838  LogDebug("MuonPathAssociator")
839  << "correlation sizes:" << SL1metaPrimitives.size() << " " << SL3metaPrimitives.size();
840  if (at_least_one_SL1_confirmation == false || clean_chi2_correlation_) {
841  sl1 = 0;
842  for (auto SL1metaPrimitive = SL1metaPrimitives.begin(); SL1metaPrimitive != SL1metaPrimitives.end();
843  ++SL1metaPrimitive, sl1++) {
844  [[clang::suppress]] if (useFitSL1[sl1])
845  continue;
846 
847  DTSuperLayerId SLId(SL1metaPrimitive->rawId);
848  DTChamberId(SLId.wheel(), SLId.station(), SLId.sector());
849  metaPrimitive newSL1metaPrimitive = {ChId.rawId(),
850  SL1metaPrimitive->t0,
851  SL1metaPrimitive->x,
852  SL1metaPrimitive->tanPhi,
853  SL1metaPrimitive->phi,
854  SL1metaPrimitive->phiB,
855  SL1metaPrimitive->phi_cmssw,
856  SL1metaPrimitive->phiB_cmssw,
857  SL1metaPrimitive->chi2,
858  SL1metaPrimitive->quality,
859  SL1metaPrimitive->wi1,
860  SL1metaPrimitive->tdc1,
861  SL1metaPrimitive->lat1,
862  SL1metaPrimitive->wi2,
863  SL1metaPrimitive->tdc2,
864  SL1metaPrimitive->lat2,
865  SL1metaPrimitive->wi3,
866  SL1metaPrimitive->tdc3,
867  SL1metaPrimitive->lat3,
868  SL1metaPrimitive->wi4,
869  SL1metaPrimitive->tdc4,
870  SL1metaPrimitive->lat4,
871  -1,
872  -1,
873  -1,
874  -1,
875  -1,
876  -1,
877  -1,
878  -1,
879  -1,
880  -1,
881  -1,
882  -1,
883  -1};
884 
885  bool ok = true;
886  for (auto &metaPrimitive : chamberMetaPrimitives) {
887  if (!isNotAPrimo(newSL1metaPrimitive, metaPrimitive)) {
888  ok = false;
889  break;
890  }
891  }
892  if (!ok)
893  continue;
894 
896  outMPaths.push_back(newSL1metaPrimitive);
897  else
898  normalMetaPrimitives.push_back(newSL1metaPrimitive);
899  }
900  }
901  if (at_least_one_SL3_confirmation == false || clean_chi2_correlation_) {
902  sl3 = 0;
903  for (auto SL3metaPrimitive = SL3metaPrimitives.begin(); SL3metaPrimitive != SL3metaPrimitives.end();
904  ++SL3metaPrimitive, sl3++) {
905  [[clang::suppress]] if (useFitSL3[sl3])
906  continue;
907  DTSuperLayerId SLId(SL3metaPrimitive->rawId);
908  DTChamberId(SLId.wheel(), SLId.station(), SLId.sector());
909  metaPrimitive newSL3metaPrimitive = {ChId.rawId(),
910  SL3metaPrimitive->t0,
911  SL3metaPrimitive->x,
912  SL3metaPrimitive->tanPhi,
913  SL3metaPrimitive->phi,
914  SL3metaPrimitive->phiB,
915  SL3metaPrimitive->phi_cmssw,
916  SL3metaPrimitive->phiB_cmssw,
917  SL3metaPrimitive->chi2,
918  SL3metaPrimitive->quality,
919  -1,
920  -1,
921  -1,
922  -1,
923  -1,
924  -1,
925  -1,
926  -1,
927  -1,
928  -1,
929  -1,
930  -1,
931  SL3metaPrimitive->wi1,
932  SL3metaPrimitive->tdc1,
933  SL3metaPrimitive->lat1,
934  SL3metaPrimitive->wi2,
935  SL3metaPrimitive->tdc2,
936  SL3metaPrimitive->lat2,
937  SL3metaPrimitive->wi3,
938  SL3metaPrimitive->tdc3,
939  SL3metaPrimitive->lat3,
940  SL3metaPrimitive->wi4,
941  SL3metaPrimitive->tdc4,
942  SL3metaPrimitive->lat4,
943  -1};
944 
946  outMPaths.push_back(newSL3metaPrimitive);
947  else
948  normalMetaPrimitives.push_back(newSL3metaPrimitive);
949  }
950  }
951  }
952 
953  SL1metaPrimitives.clear();
954  SL1metaPrimitives.erase(SL1metaPrimitives.begin(), SL1metaPrimitives.end());
955  SL3metaPrimitives.clear();
956  SL3metaPrimitives.erase(SL3metaPrimitives.begin(), SL3metaPrimitives.end());
957 
958  vector<metaPrimitive> auxMetaPrimitives;
960  if (debug_)
961  LogDebug("MuonPathAssociator") << "Pushing back normal MPs to the auxiliar vector";
962  removeSharingHits(normalMetaPrimitives, confirmedMetaPrimitives, auxMetaPrimitives);
963  }
965  if (debug_)
966  LogDebug("MuonPathAssociator") << "Pushing back normal MPs to the MPs collection";
967  removeSharingHits(auxMetaPrimitives, chamberMetaPrimitives, outMPaths);
968  }
969  }
970  }
971  }
972 
973  //eta TP we do not correlate with other superlayer in the same chamber so we forward them all
974  std::vector<metaPrimitive> SL2metaPrimitives;
975 
976  for (int wh = -2; wh <= 2; wh++) {
977  for (int st = 1; st <= 4; st++) {
978  for (int se = 1; se <= 14; se++) {
979  if (se >= 13 && st != 4)
980  continue;
981 
982  DTChamberId ChId(wh, st, se);
983  DTSuperLayerId sl2Id(wh, st, se, 2);
984 
985  //filterSL2 etaTP
986  for (auto metaprimitiveIt = inMPaths.begin(); metaprimitiveIt != inMPaths.end(); ++metaprimitiveIt)
987  if (metaprimitiveIt->rawId == sl2Id.rawId()) {
988  SL2metaPrimitives.push_back(*metaprimitiveIt);
989  if (debug_)
990  printmPC(*metaprimitiveIt);
991  outMPaths.push_back(*metaprimitiveIt);
992  }
993  }
994  }
995  }
996 
997  LogDebug("MuonPathAssociator") << "\t etaTP: added " << SL2metaPrimitives.size() << "to outMPaths" << std::endl;
998 
999  SL2metaPrimitives.clear();
1000  SL2metaPrimitives.erase(SL2metaPrimitives.begin(), SL2metaPrimitives.end());
1001 }
bool isNotAPrimo(cmsdt::metaPrimitive first, cmsdt::metaPrimitive second)
int station() const
Return the station number.
Definition: DTChamberId.h:45
constexpr int CH_CENTER_TO_MID_SL_X2
Definition: constants.h:330
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
int superLayer() const
Return the superlayer number.
constexpr int DRIFT_SPEED_X4
Definition: constants.h:318
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
std::map< int, float > shiftinfo_
constexpr int VERT_PHI1_PHI3_INV
Definition: constants.h:327
std::map< std::string, int, std::less< std::string > > psi
std::shared_ptr< GlobalCoordsObtainer > globalcoordsobtainer_
constexpr int CELL_LENGTH
Definition: constants.h:313
constexpr int CELL_SEMILENGTH
Definition: constants.h:314
U second(std::pair< T, U > const &p)
string quality
void removeSharingHits(std::vector< cmsdt::metaPrimitive > &firstMPaths, std::vector< cmsdt::metaPrimitive > &secondMPaths, std::vector< cmsdt::metaPrimitive > &allMPaths)
constexpr int INCREASED_RES_SLOPE_POW
Definition: constants.h:416
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 float Z_SHIFT_MB4
Definition: constants.h:397
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr int CELL_HEIGHT
Definition: constants.h:311
constexpr double X_POS_L4
Definition: constants.h:400
void printmPC(cmsdt::metaPrimitive mP)
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 NUM_LAYERS_2SL
Definition: constants.h:393
constexpr float VERT_PHI1_PHI3
Definition: constants.h:324
constexpr int LHC_CLK_FREQ
Definition: constants.h:222
int layer() const
Return the layer number.
Definition: DTLayerId.h:45
bool hasPosRF(int wh, int sec)
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:42
int sector() const
Definition: DTChamberId.h:52
static unsigned int const shift
DTGeometry const * dtGeo_
constexpr int INCREASED_RES_POS_POW
Definition: constants.h:415
void removeSharingFits(std::vector< cmsdt::metaPrimitive > &chamberMPaths, std::vector< cmsdt::metaPrimitive > &allMPaths)
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
constexpr float DRIFT_SPEED
Definition: constants.h:316
constexpr double X_POS_L3
Definition: constants.h:399
#define LogDebug(id)
constexpr int INCREASED_RES_POS
Definition: constants.h:411

◆ finish()

void MuonPathAssociator::finish ( )

Definition at line 76 of file MuonPathAssociator.cc.

References debug_, and LogDebug.

Referenced by progressbar.ProgressBar::__next__().

76  {
77  if (debug_)
78  LogDebug("MuonPathAssociator") << "MuonPathAssociator: finish";
79 };
#define LogDebug(id)

◆ hasPosRF()

bool MuonPathAssociator::hasPosRF ( int  wh,
int  sec 
)
inlineprivate

Definition at line 74 of file MuonPathAssociator.h.

References fileinputsource_cfi::sec.

Referenced by correlateMPaths().

74 { return wh > 0 || (wh == 0 && sec % 4 > 1); }

◆ initialise()

void MuonPathAssociator::initialise ( const edm::EventSetup iEventSetup)

Definition at line 56 of file MuonPathAssociator.cc.

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

56  {
57  if (debug_)
58  LogDebug("MuonPathAssociator") << "MuonPathAssociator::initialiase";
59 
60  auto geom = iEventSetup.getHandle(dtGeomH_);
61  dtGeo_ = &(*geom);
62 }
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH_
DTGeometry const * dtGeo_
#define LogDebug(id)

◆ isNotAPrimo()

bool MuonPathAssociator::isNotAPrimo ( cmsdt::metaPrimitive  first,
cmsdt::metaPrimitive  second 
)

Definition at line 1100 of file MuonPathAssociator.cc.

References dqmdumpme::first, and edm::second().

Referenced by correlateMPaths(), and removeSharingHits().

1100  {
1101  int hitsSL1 = (first.wi1 != -1) + (first.wi2 != -1) + (first.wi3 != -1) + (first.wi4 != -1);
1102  int hitsSL3 = (first.wi5 != -1) + (first.wi6 != -1) + (first.wi7 != -1) + (first.wi8 != -1);
1103 
1104  bool lay1 = (first.wi1 == second.wi1) && (first.tdc1 = second.tdc1) && (first.wi1 != -1);
1105  bool lay2 = (first.wi2 == second.wi2) && (first.tdc2 = second.tdc2) && (first.wi2 != -1);
1106  bool lay3 = (first.wi3 == second.wi3) && (first.tdc3 = second.tdc3) && (first.wi3 != -1);
1107  bool lay4 = (first.wi4 == second.wi4) && (first.tdc4 = second.tdc4) && (first.wi4 != -1);
1108  bool lay5 = (first.wi5 == second.wi5) && (first.tdc5 = second.tdc5) && (first.wi5 != -1);
1109  bool lay6 = (first.wi6 == second.wi6) && (first.tdc6 = second.tdc6) && (first.wi6 != -1);
1110  bool lay7 = (first.wi7 == second.wi7) && (first.tdc7 = second.tdc7) && (first.wi7 != -1);
1111  bool lay8 = (first.wi8 == second.wi8) && (first.tdc8 = second.tdc8) && (first.wi8 != -1);
1112 
1113  return (((!lay1 && !lay2 && !lay3 && !lay4) || hitsSL1 < 3) && ((!lay5 && !lay6 && !lay7 && !lay8) || hitsSL3 < 3));
1114 }
U second(std::pair< T, U > const &p)

◆ printmPC()

void MuonPathAssociator::printmPC ( cmsdt::metaPrimitive  mP)

Definition at line 1116 of file MuonPathAssociator.cc.

References cmsdt::metaPrimitive::chi2, IntegrityClient_cfi::ChId, cmsdt::metaPrimitive::lat1, cmsdt::metaPrimitive::lat2, cmsdt::metaPrimitive::lat3, cmsdt::metaPrimitive::lat4, cmsdt::metaPrimitive::lat5, cmsdt::metaPrimitive::lat6, cmsdt::metaPrimitive::lat7, cmsdt::metaPrimitive::lat8, LogDebug, cmsdt::metaPrimitive::rawId, cmsdt::metaPrimitive::t0, cmsdt::metaPrimitive::tanPhi, cmsdt::metaPrimitive::tdc1, cmsdt::metaPrimitive::tdc2, cmsdt::metaPrimitive::tdc3, cmsdt::metaPrimitive::tdc4, cmsdt::metaPrimitive::tdc5, cmsdt::metaPrimitive::tdc6, cmsdt::metaPrimitive::tdc7, cmsdt::metaPrimitive::tdc8, cmsdt::metaPrimitive::wi1, cmsdt::metaPrimitive::wi2, cmsdt::metaPrimitive::wi3, cmsdt::metaPrimitive::wi4, cmsdt::metaPrimitive::wi5, cmsdt::metaPrimitive::wi6, cmsdt::metaPrimitive::wi7, cmsdt::metaPrimitive::wi8, and cmsdt::metaPrimitive::x.

Referenced by correlateMPaths(), removeSharingFits(), and removeSharingHits().

1116  {
1117  DTChamberId ChId(mP.rawId);
1118  LogDebug("MuonPathAssociator") << ChId << "\t"
1119  << " " << setw(2) << left << mP.wi1 << " " << setw(2) << left << mP.wi2 << " "
1120  << setw(2) << left << mP.wi3 << " " << setw(2) << left << mP.wi4 << " " << setw(2)
1121  << left << mP.wi5 << " " << setw(2) << left << mP.wi6 << " " << setw(2) << left
1122  << mP.wi7 << " " << setw(2) << left << mP.wi8 << " " << setw(5) << left << mP.tdc1
1123  << " " << setw(5) << left << mP.tdc2 << " " << setw(5) << left << mP.tdc3 << " "
1124  << setw(5) << left << mP.tdc4 << " " << setw(5) << left << mP.tdc5 << " " << setw(5)
1125  << left << mP.tdc6 << " " << setw(5) << left << mP.tdc7 << " " << setw(5) << left
1126  << mP.tdc8 << " " << setw(2) << left << mP.lat1 << " " << setw(2) << left << mP.lat2
1127  << " " << setw(2) << left << mP.lat3 << " " << setw(2) << left << mP.lat4 << " "
1128  << setw(2) << left << mP.lat5 << " " << setw(2) << left << mP.lat6 << " " << setw(2)
1129  << left << mP.lat7 << " " << setw(2) << left << mP.lat8 << " " << setw(10) << right
1130  << mP.x << " " << setw(9) << left << mP.tanPhi << " " << setw(5) << left << mP.t0
1131  << " " << setw(13) << left << mP.chi2 << " \n";
1132 }
#define LogDebug(id)

◆ removeSharingFits()

void MuonPathAssociator::removeSharingFits ( std::vector< cmsdt::metaPrimitive > &  chamberMPaths,
std::vector< cmsdt::metaPrimitive > &  allMPaths 
)

Definition at line 1003 of file MuonPathAssociator.cc.

References debug_, dqmdumpme::first, mps_fire::i, dqmiolumiharvest::j, LogDebug, printmPC(), edm::second(), shareFit(), suppress, and DMR_cfg::useFit.

Referenced by correlateMPaths().

1003  {
1004  bool useFit[chamberMPaths.size()];
1005  for (unsigned int i = 0; i < chamberMPaths.size(); i++) {
1006  useFit[i] = true;
1007  }
1008  for (unsigned int i = 0; i < chamberMPaths.size(); i++) {
1009  if (debug_)
1010  LogDebug("MuonPathAssociator") << "Looking at prim" << i;
1011  [[clang::suppress]] if (!useFit[i])
1012  continue;
1013  for (unsigned int j = i + 1; j < chamberMPaths.size(); j++) {
1014  if (debug_)
1015  LogDebug("MuonPathAssociator") << "Comparing with prim " << j;
1016  [[clang::suppress]] if (!useFit[j])
1017  continue;
1018  metaPrimitive first = chamberMPaths[i];
1019  metaPrimitive second = chamberMPaths[j];
1020  if (shareFit(first, second)) {
1021  if (first.quality > second.quality)
1022  useFit[j] = false;
1023  else if (first.quality < second.quality)
1024  useFit[i] = false;
1025  else {
1026  if (first.chi2 < second.chi2)
1027  useFit[j] = false;
1028  else {
1029  useFit[i] = false;
1030  break;
1031  }
1032  }
1033  }
1034  }
1035  if (useFit[i]) {
1036  if (debug_)
1037  printmPC(chamberMPaths[i]);
1038  allMPaths.push_back(chamberMPaths[i]);
1039  }
1040  }
1041  if (debug_)
1042  LogDebug("MuonPathAssociator") << "---Swapping chamber---";
1043 }
U second(std::pair< T, U > const &p)
void printmPC(cmsdt::metaPrimitive mP)
bool shareFit(cmsdt::metaPrimitive first, cmsdt::metaPrimitive second)
#define LogDebug(id)

◆ removeSharingHits()

void MuonPathAssociator::removeSharingHits ( std::vector< cmsdt::metaPrimitive > &  firstMPaths,
std::vector< cmsdt::metaPrimitive > &  secondMPaths,
std::vector< cmsdt::metaPrimitive > &  allMPaths 
)

Definition at line 1045 of file MuonPathAssociator.cc.

References debug_, isNotAPrimo(), LogDebug, convertSQLiteXML::ok, and printmPC().

Referenced by correlateMPaths().

1047  {
1048  for (auto &firstMP : firstMPaths) {
1049  if (debug_)
1050  LogDebug("MuonPathAssociator") << "----------------------------------";
1051  if (debug_)
1052  LogDebug("MuonPathAssociator") << "Turn for ";
1053  if (debug_)
1054  printmPC(firstMP);
1055  bool ok = true;
1056  for (auto &secondMP : secondMPaths) {
1057  if (debug_)
1058  LogDebug("MuonPathAssociator") << "Comparing with ";
1059  if (debug_)
1060  printmPC(secondMP);
1061  if (!isNotAPrimo(firstMP, secondMP)) {
1062  ok = false;
1063  break;
1064  }
1065  }
1066  if (ok) {
1067  allMPaths.push_back(firstMP);
1068  if (debug_)
1069  printmPC(firstMP);
1070  }
1071  if (debug_)
1072  LogDebug("MuonPathAssociator") << "----------------------------------";
1073  }
1074 }
bool isNotAPrimo(cmsdt::metaPrimitive first, cmsdt::metaPrimitive second)
void printmPC(cmsdt::metaPrimitive mP)
#define LogDebug(id)

◆ run()

void MuonPathAssociator::run ( edm::Event iEvent,
const edm::EventSetup iEventSetup,
edm::Handle< DTDigiCollection digis,
std::vector< cmsdt::metaPrimitive > &  inMPaths,
std::vector< cmsdt::metaPrimitive > &  outMPaths 
)

Definition at line 64 of file MuonPathAssociator.cc.

References correlateMPaths(), and dT0_correlate_TP_.

68  {
70  correlateMPaths(digis, inMPaths, outMPaths);
71  else {
72  outMPaths.insert(outMPaths.end(), inMPaths.begin(), inMPaths.end());
73  }
74 }
void correlateMPaths(edm::Handle< DTDigiCollection > digis, std::vector< cmsdt::metaPrimitive > &inMPaths, std::vector< cmsdt::metaPrimitive > &outMPaths)

◆ shareFit()

bool MuonPathAssociator::shareFit ( cmsdt::metaPrimitive  first,
cmsdt::metaPrimitive  second 
)

Definition at line 1076 of file MuonPathAssociator.cc.

References dqmdumpme::first, and edm::second().

Referenced by removeSharingFits().

1076  {
1077  bool lay1 = (first.wi1 == second.wi1) && (first.tdc1 = second.tdc1);
1078  bool lay2 = (first.wi2 == second.wi2) && (first.tdc2 = second.tdc2);
1079  bool lay3 = (first.wi3 == second.wi3) && (first.tdc3 = second.tdc3);
1080  bool lay4 = (first.wi4 == second.wi4) && (first.tdc4 = second.tdc4);
1081  bool lay5 = (first.wi5 == second.wi5) && (first.tdc5 = second.tdc5);
1082  bool lay6 = (first.wi6 == second.wi6) && (first.tdc6 = second.tdc6);
1083  bool lay7 = (first.wi7 == second.wi7) && (first.tdc7 = second.tdc7);
1084  bool lay8 = (first.wi8 == second.wi8) && (first.tdc8 = second.tdc8);
1085 
1086  if (lay1 && lay2 && lay3 && lay4) {
1087  if (lay5 || lay6 || lay7 || lay8)
1088  return true;
1089  else
1090  return false;
1091  } else if (lay5 && lay6 && lay7 && lay8) {
1092  if (lay1 || lay2 || lay3 || lay4)
1093  return true;
1094  else
1095  return false;
1096  } else
1097  return false;
1098 }
U second(std::pair< T, U > const &p)

Member Data Documentation

◆ allow_confirmation_

bool MuonPathAssociator::allow_confirmation_
private

Definition at line 80 of file MuonPathAssociator.h.

Referenced by correlateMPaths().

◆ chi2corTh_

double MuonPathAssociator::chi2corTh_
private

Definition at line 85 of file MuonPathAssociator.h.

Referenced by correlateMPaths().

◆ clean_chi2_correlation_

bool MuonPathAssociator::clean_chi2_correlation_
private

Definition at line 78 of file MuonPathAssociator.h.

Referenced by correlateMPaths().

◆ dBX_correlate_TP_

double MuonPathAssociator::dBX_correlate_TP_
private

Definition at line 82 of file MuonPathAssociator.h.

Referenced by correlateMPaths().

◆ debug_

const bool MuonPathAssociator::debug_
private

◆ dT0_correlate_TP_

double MuonPathAssociator::dT0_correlate_TP_
private

Definition at line 81 of file MuonPathAssociator.h.

Referenced by correlateMPaths(), and run().

◆ dTanPsi_correlate_TP_

double MuonPathAssociator::dTanPsi_correlate_TP_
private

Definition at line 83 of file MuonPathAssociator.h.

Referenced by correlateMPaths().

◆ dtGeo_

DTGeometry const* MuonPathAssociator::dtGeo_

Definition at line 65 of file MuonPathAssociator.h.

Referenced by correlateMPaths(), and initialise().

◆ dtGeomH_

edm::ESGetToken<DTGeometry, MuonGeometryRecord> MuonPathAssociator::dtGeomH_

Definition at line 66 of file MuonPathAssociator.h.

Referenced by initialise(), and MuonPathAssociator().

◆ globalcoordsobtainer_

std::shared_ptr<GlobalCoordsObtainer> MuonPathAssociator::globalcoordsobtainer_
private

Definition at line 92 of file MuonPathAssociator.h.

Referenced by correlateMPaths(), and MuonPathAssociator().

◆ minx_match_2digis_

double MuonPathAssociator::minx_match_2digis_
private

Definition at line 84 of file MuonPathAssociator.h.

Referenced by correlateMPaths().

◆ shift_filename_

edm::FileInPath MuonPathAssociator::shift_filename_
private

Definition at line 88 of file MuonPathAssociator.h.

Referenced by MuonPathAssociator().

◆ shiftinfo_

std::map<int, float> MuonPathAssociator::shiftinfo_
private

Definition at line 89 of file MuonPathAssociator.h.

Referenced by correlateMPaths(), and MuonPathAssociator().

◆ useBX_correlation_

bool MuonPathAssociator::useBX_correlation_
private

Definition at line 79 of file MuonPathAssociator.h.

Referenced by correlateMPaths().