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, 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;
41  shiftinfo_[rawId] = shift;
42  }
43 
45  globalcoordsobtainer_ = globalcoordsobtainer;
46 }
std::string fullPath() const
Definition: FileInPath.cc:161
std::map< int, float > shiftinfo_
edm::FileInPath shift_filename_
std::shared_ptr< GlobalCoordsObtainer > globalcoordsobtainer_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH_
static unsigned int const shift
#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(), hltPixelTracks_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(), 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 = 0) {
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  matched_digis++;
416  }
417  best_wire = (*digiIt).wire();
418  best_tdc = (*digiIt).time();
419  best_layer = dtLId.layer();
420  best_lat = lat;
421 
422  } else if ((std::abs(x_inSL3 - x_wire) >= minx) && (std::abs(x_inSL3 - x_wire) < min2x)) {
423  // same layer than the stored in best, no hit added
424  if (dtLId.layer() == best_layer)
425  continue;
426  // different layer than the stored in next, hit added. This approach in somewhat
427  // buggy, as we could have stored as next LayerX -> LayerY -> LayerX, and this should
428  // count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
429  // makes no difference
430  matched_digis++;
431  // whether the layer is the same for this hit and the stored in next, we substitute
432  // the one stored and modify the min distance
433  min2x = std::abs(x_inSL3 - x_wire);
434  next_wire = (*digiIt).wire();
435  next_tdc = (*digiIt).time();
436  next_layer = dtLId.layer();
437  next_lat = lat;
438  }
439  }
440  }
441  if (matched_digis >= 2 and best_layer != -1 and next_layer != -1) {
442  int new_quality = CHIGHQ;
443  if (SL1metaPrimitive->quality == LOWQ)
444  new_quality = CLOWQ;
445 
446  int wi1 = -1;
447  int tdc1 = -1;
448  int lat1 = -1;
449  int wi2 = -1;
450  int tdc2 = -1;
451  int lat2 = -1;
452  int wi3 = -1;
453  int tdc3 = -1;
454  int lat3 = -1;
455  int wi4 = -1;
456  int tdc4 = -1;
457  int lat4 = -1;
458 
459  if (next_layer == 1) {
460  wi1 = next_wire;
461  tdc1 = next_tdc;
462  lat1 = next_lat;
463  }
464  if (next_layer == 2) {
465  wi2 = next_wire;
466  tdc2 = next_tdc;
467  lat2 = next_lat;
468  }
469  if (next_layer == 3) {
470  wi3 = next_wire;
471  tdc3 = next_tdc;
472  lat3 = next_lat;
473  }
474  if (next_layer == 4) {
475  wi4 = next_wire;
476  tdc4 = next_tdc;
477  lat4 = next_lat;
478  }
479 
480  if (best_layer == 1) {
481  wi1 = best_wire;
482  tdc1 = best_tdc;
483  lat1 = best_lat;
484  }
485  if (best_layer == 2) {
486  wi2 = best_wire;
487  tdc2 = best_tdc;
488  lat2 = best_lat;
489  }
490  if (best_layer == 3) {
491  wi3 = best_wire;
492  tdc3 = best_tdc;
493  lat3 = best_lat;
494  }
495  if (best_layer == 4) {
496  wi4 = best_wire;
497  tdc4 = best_tdc;
498  lat4 = best_lat;
499  }
500 
502  outMPaths.emplace_back(metaPrimitive({ChId.rawId(),
503  SL1metaPrimitive->t0,
504  SL1metaPrimitive->x,
505  SL1metaPrimitive->tanPhi,
506  SL1metaPrimitive->phi,
507  SL1metaPrimitive->phiB,
508  SL1metaPrimitive->phi_cmssw,
509  SL1metaPrimitive->phiB_cmssw,
510  SL1metaPrimitive->chi2,
511  new_quality,
512  SL1metaPrimitive->wi1,
513  SL1metaPrimitive->tdc1,
514  SL1metaPrimitive->lat1,
515  SL1metaPrimitive->wi2,
516  SL1metaPrimitive->tdc2,
517  SL1metaPrimitive->lat2,
518  SL1metaPrimitive->wi3,
519  SL1metaPrimitive->tdc3,
520  SL1metaPrimitive->lat3,
521  SL1metaPrimitive->wi4,
522  SL1metaPrimitive->tdc4,
523  SL1metaPrimitive->lat4,
524  wi1,
525  tdc1,
526  lat1,
527  wi2,
528  tdc2,
529  lat2,
530  wi3,
531  tdc3,
532  lat3,
533  wi4,
534  tdc4,
535  lat4,
536  -1}));
537  else
538  confirmedMetaPrimitives.emplace_back(metaPrimitive({ChId.rawId(),
539  SL1metaPrimitive->t0,
540  SL1metaPrimitive->x,
541  SL1metaPrimitive->tanPhi,
542  SL1metaPrimitive->phi,
543  SL1metaPrimitive->phiB,
544  SL1metaPrimitive->phi_cmssw,
545  SL1metaPrimitive->phiB_cmssw,
546  SL1metaPrimitive->chi2,
547  new_quality,
548  SL1metaPrimitive->wi1,
549  SL1metaPrimitive->tdc1,
550  SL1metaPrimitive->lat1,
551  SL1metaPrimitive->wi2,
552  SL1metaPrimitive->tdc2,
553  SL1metaPrimitive->lat2,
554  SL1metaPrimitive->wi3,
555  SL1metaPrimitive->tdc3,
556  SL1metaPrimitive->lat3,
557  SL1metaPrimitive->wi4,
558  SL1metaPrimitive->tdc4,
559  SL1metaPrimitive->lat4,
560  wi1,
561  tdc1,
562  lat1,
563  wi2,
564  tdc2,
565  lat2,
566  wi3,
567  tdc3,
568  lat3,
569  wi4,
570  tdc4,
571  lat4,
572  -1}));
573  useFitSL1[sl1] = true;
574  at_least_one_SL1_confirmation = true;
575  }
576  }
577  }
578 
579  //finish SL1-SL3
580 
581  //SL3-SL1
582  sl3 = 0;
583  for (auto SL3metaPrimitive = SL3metaPrimitives.begin(); SL3metaPrimitive != SL3metaPrimitives.end();
584  ++SL3metaPrimitive, sl3++) {
585  if (useFitSL3[sl3])
586  continue;
587  if ((at_least_one_correlation == false || clean_chi2_correlation_) &&
588  allow_confirmation_) { //no correlation was found, trying with pairs of two digis in the other SL
589 
590  int matched_digis = 0;
591  double minx = minx_match_2digis_;
592  double min2x = minx_match_2digis_;
593  int best_tdc = -1;
594  int next_tdc = -1;
595  int best_wire = -1;
596  int next_wire = -1;
597  int best_layer = -1;
598  int next_layer = -1;
599  int best_lat = -1;
600  int next_lat = -1;
601  int lat = -1;
602 
603  for (const auto &dtLayerId_It : *dtdigis) {
604  const DTLayerId dtLId = dtLayerId_It.first;
605  // creating a new DTSuperLayerId object to compare with the required SL id
606  const DTSuperLayerId dtSLId(dtLId.wheel(), dtLId.station(), dtLId.sector(), dtLId.superLayer());
607  if (dtSLId.rawId() != sl1Id.rawId())
608  continue;
609  double l_shift = 0;
610  if (dtLId.layer() == 4)
611  l_shift = X_POS_L4;
612  if (dtLId.layer() == 3)
613  l_shift = X_POS_L3;
614  if (dtLId.layer() == 2)
615  l_shift = -1 * X_POS_L3;
616  if (dtLId.layer() == 1)
617  l_shift = -1 * X_POS_L4;
618  double x_inSL1 = SL3metaPrimitive->x + SL3metaPrimitive->tanPhi * (VERT_PHI1_PHI3 - l_shift);
619  for (auto digiIt = (dtLayerId_It.second).first; digiIt != (dtLayerId_It.second).second; ++digiIt) {
620  DTWireId wireId(dtLId, (*digiIt).wire());
621  if ((*digiIt).time() < SL3metaPrimitive->t0)
622  continue;
623  double x_wire =
624  shiftinfo_[wireId.rawId()] + ((*digiIt).time() - SL3metaPrimitive->t0) * DRIFT_SPEED / 10.;
625  double x_wire_left =
626  shiftinfo_[wireId.rawId()] - ((*digiIt).time() - SL3metaPrimitive->t0) * DRIFT_SPEED / 10.;
627  lat = 1;
628  if (std::abs(x_inSL1 - x_wire) > std::abs(x_inSL1 - x_wire_left)) {
629  x_wire = x_wire_left; //choose the closest laterality
630  lat = 0;
631  }
632  if (std::abs(x_inSL1 - x_wire) < minx) {
633  // different layer than the stored in best, hit added, matched_digis++;. This approach in somewhat
634  // buggy, as we could have stored as best LayerX -> LayerY -> LayerX, and this should
635  // count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
636  // makes no difference
637  if (dtLId.layer() != best_layer) {
638  minx = std::abs(x_inSL1 - x_wire);
639  next_wire = best_wire;
640  next_tdc = best_tdc;
641  next_layer = best_layer;
642  next_lat = best_lat;
643  matched_digis++;
644  }
645  best_wire = (*digiIt).wire();
646  best_tdc = (*digiIt).time();
647  best_layer = dtLId.layer();
648  best_lat = lat;
649  } else if ((std::abs(x_inSL1 - x_wire) >= minx) && (std::abs(x_inSL1 - x_wire) < min2x)) {
650  // same layer than the stored in best, no hit added
651  if (dtLId.layer() == best_layer)
652  continue;
653  // different layer than the stored in next, hit added. This approach in somewhat
654  // buggy, as we could have stored as next LayerX -> LayerY -> LayerX, and this should
655  // count only as 2 hits. However, as we confirm with at least 2 hits, having 2 or more
656  // makes no difference
657  matched_digis++;
658  // whether the layer is the same for this hit and the stored in next, we substitute
659  // the one stored and modify the min distance
660  min2x = std::abs(x_inSL1 - x_wire);
661  next_wire = (*digiIt).wire();
662  next_tdc = (*digiIt).time();
663  next_layer = dtLId.layer();
664  next_lat = lat;
665  }
666  }
667  }
668  if (matched_digis >= 2 and best_layer != -1 and next_layer != -1) {
669  int new_quality = CHIGHQ;
670  if (SL3metaPrimitive->quality == LOWQ)
671  new_quality = CLOWQ;
672 
673  int wi1 = -1;
674  int tdc1 = -1;
675  int lat1 = -1;
676  int wi2 = -1;
677  int tdc2 = -1;
678  int lat2 = -1;
679  int wi3 = -1;
680  int tdc3 = -1;
681  int lat3 = -1;
682  int wi4 = -1;
683  int tdc4 = -1;
684  int lat4 = -1;
685 
686  if (next_layer == 1) {
687  wi1 = next_wire;
688  tdc1 = next_tdc;
689  lat1 = next_lat;
690  }
691  if (next_layer == 2) {
692  wi2 = next_wire;
693  tdc2 = next_tdc;
694  lat2 = next_lat;
695  }
696  if (next_layer == 3) {
697  wi3 = next_wire;
698  tdc3 = next_tdc;
699  lat3 = next_lat;
700  }
701  if (next_layer == 4) {
702  wi4 = next_wire;
703  tdc4 = next_tdc;
704  lat4 = next_lat;
705  }
706 
707  if (best_layer == 1) {
708  wi1 = best_wire;
709  tdc1 = best_tdc;
710  lat1 = best_lat;
711  }
712  if (best_layer == 2) {
713  wi2 = best_wire;
714  tdc2 = best_tdc;
715  lat2 = best_lat;
716  }
717  if (best_layer == 3) {
718  wi3 = best_wire;
719  tdc3 = best_tdc;
720  lat3 = best_lat;
721  }
722  if (best_layer == 4) {
723  wi4 = best_wire;
724  tdc4 = best_tdc;
725  lat4 = best_lat;
726  }
727 
729  outMPaths.push_back(metaPrimitive({ChId.rawId(),
730  SL3metaPrimitive->t0,
731  SL3metaPrimitive->x,
732  SL3metaPrimitive->tanPhi,
733  SL3metaPrimitive->phi,
734  SL3metaPrimitive->phiB,
735  SL3metaPrimitive->phi_cmssw,
736  SL3metaPrimitive->phiB_cmssw,
737  SL3metaPrimitive->chi2,
738  new_quality,
739  wi1,
740  tdc1,
741  lat1,
742  wi2,
743  tdc2,
744  lat2,
745  wi3,
746  tdc3,
747  lat3,
748  wi4,
749  tdc4,
750  lat4,
751  SL3metaPrimitive->wi1,
752  SL3metaPrimitive->tdc1,
753  SL3metaPrimitive->lat1,
754  SL3metaPrimitive->wi2,
755  SL3metaPrimitive->tdc2,
756  SL3metaPrimitive->lat2,
757  SL3metaPrimitive->wi3,
758  SL3metaPrimitive->tdc3,
759  SL3metaPrimitive->lat3,
760  SL3metaPrimitive->wi4,
761  SL3metaPrimitive->tdc4,
762  SL3metaPrimitive->lat4,
763  -1}));
764  else
765  confirmedMetaPrimitives.push_back(metaPrimitive({ChId.rawId(),
766  SL3metaPrimitive->t0,
767  SL3metaPrimitive->x,
768  SL3metaPrimitive->tanPhi,
769  SL3metaPrimitive->phi,
770  SL3metaPrimitive->phiB,
771  SL3metaPrimitive->phi_cmssw,
772  SL3metaPrimitive->phiB_cmssw,
773  SL3metaPrimitive->chi2,
774  new_quality,
775  wi1,
776  tdc1,
777  lat1,
778  wi2,
779  tdc2,
780  lat2,
781  wi3,
782  tdc3,
783  lat3,
784  wi4,
785  tdc4,
786  lat4,
787  SL3metaPrimitive->wi1,
788  SL3metaPrimitive->tdc1,
789  SL3metaPrimitive->lat1,
790  SL3metaPrimitive->wi2,
791  SL3metaPrimitive->tdc2,
792  SL3metaPrimitive->lat2,
793  SL3metaPrimitive->wi3,
794  SL3metaPrimitive->tdc3,
795  SL3metaPrimitive->lat3,
796  SL3metaPrimitive->wi4,
797  SL3metaPrimitive->tdc4,
798  SL3metaPrimitive->lat4,
799  -1}));
800  useFitSL3[sl3] = true;
801  at_least_one_SL3_confirmation = true;
802  }
803  }
804  }
805  // Start correlation cleaning
807  if (debug_)
808  LogDebug("MuonPathAssociator") << "Pushing back correlated MPs to the MPs collection";
809  removeSharingFits(chamberMetaPrimitives, outMPaths);
810  }
812  if (debug_)
813  LogDebug("MuonPathAssociator") << "Pushing back confirmed MPs to the complete vector";
814  removeSharingHits(confirmedMetaPrimitives, chamberMetaPrimitives, outMPaths);
815  }
816 
817  //finish SL3-SL1
818  if (at_least_one_correlation == false || clean_chi2_correlation_) {
819  if (debug_ && !at_least_one_correlation)
820  LogDebug("MuonPathAssociator")
821  << "correlation we found zero correlations, adding both collections as they are to the outMPaths";
822  if (debug_)
823  LogDebug("MuonPathAssociator")
824  << "correlation sizes:" << SL1metaPrimitives.size() << " " << SL3metaPrimitives.size();
825  if (at_least_one_SL1_confirmation == false || clean_chi2_correlation_) {
826  sl1 = 0;
827  for (auto SL1metaPrimitive = SL1metaPrimitives.begin(); SL1metaPrimitive != SL1metaPrimitives.end();
828  ++SL1metaPrimitive, sl1++) {
829  if (useFitSL1[sl1])
830  continue;
831 
832  DTSuperLayerId SLId(SL1metaPrimitive->rawId);
833  DTChamberId(SLId.wheel(), SLId.station(), SLId.sector());
834  metaPrimitive newSL1metaPrimitive = {ChId.rawId(),
835  SL1metaPrimitive->t0,
836  SL1metaPrimitive->x,
837  SL1metaPrimitive->tanPhi,
838  SL1metaPrimitive->phi,
839  SL1metaPrimitive->phiB,
840  SL1metaPrimitive->phi_cmssw,
841  SL1metaPrimitive->phiB_cmssw,
842  SL1metaPrimitive->chi2,
843  SL1metaPrimitive->quality,
844  SL1metaPrimitive->wi1,
845  SL1metaPrimitive->tdc1,
846  SL1metaPrimitive->lat1,
847  SL1metaPrimitive->wi2,
848  SL1metaPrimitive->tdc2,
849  SL1metaPrimitive->lat2,
850  SL1metaPrimitive->wi3,
851  SL1metaPrimitive->tdc3,
852  SL1metaPrimitive->lat3,
853  SL1metaPrimitive->wi4,
854  SL1metaPrimitive->tdc4,
855  SL1metaPrimitive->lat4,
856  -1,
857  -1,
858  -1,
859  -1,
860  -1,
861  -1,
862  -1,
863  -1,
864  -1,
865  -1,
866  -1,
867  -1,
868  -1};
869 
870  bool ok = true;
871  for (auto &metaPrimitive : chamberMetaPrimitives) {
872  if (!isNotAPrimo(newSL1metaPrimitive, metaPrimitive)) {
873  ok = false;
874  break;
875  }
876  }
877  if (!ok)
878  continue;
879 
881  outMPaths.push_back(newSL1metaPrimitive);
882  else
883  normalMetaPrimitives.push_back(newSL1metaPrimitive);
884  }
885  }
886  if (at_least_one_SL3_confirmation == false || clean_chi2_correlation_) {
887  sl3 = 0;
888  for (auto SL3metaPrimitive = SL3metaPrimitives.begin(); SL3metaPrimitive != SL3metaPrimitives.end();
889  ++SL3metaPrimitive, sl3++) {
890  if (useFitSL3[sl3])
891  continue;
892  DTSuperLayerId SLId(SL3metaPrimitive->rawId);
893  DTChamberId(SLId.wheel(), SLId.station(), SLId.sector());
894  metaPrimitive newSL3metaPrimitive = {ChId.rawId(),
895  SL3metaPrimitive->t0,
896  SL3metaPrimitive->x,
897  SL3metaPrimitive->tanPhi,
898  SL3metaPrimitive->phi,
899  SL3metaPrimitive->phiB,
900  SL3metaPrimitive->phi_cmssw,
901  SL3metaPrimitive->phiB_cmssw,
902  SL3metaPrimitive->chi2,
903  SL3metaPrimitive->quality,
904  -1,
905  -1,
906  -1,
907  -1,
908  -1,
909  -1,
910  -1,
911  -1,
912  -1,
913  -1,
914  -1,
915  -1,
916  SL3metaPrimitive->wi1,
917  SL3metaPrimitive->tdc1,
918  SL3metaPrimitive->lat1,
919  SL3metaPrimitive->wi2,
920  SL3metaPrimitive->tdc2,
921  SL3metaPrimitive->lat2,
922  SL3metaPrimitive->wi3,
923  SL3metaPrimitive->tdc3,
924  SL3metaPrimitive->lat3,
925  SL3metaPrimitive->wi4,
926  SL3metaPrimitive->tdc4,
927  SL3metaPrimitive->lat4,
928  -1};
929 
931  outMPaths.push_back(newSL3metaPrimitive);
932  else
933  normalMetaPrimitives.push_back(newSL3metaPrimitive);
934  }
935  }
936  }
937 
938  SL1metaPrimitives.clear();
939  SL1metaPrimitives.erase(SL1metaPrimitives.begin(), SL1metaPrimitives.end());
940  SL3metaPrimitives.clear();
941  SL3metaPrimitives.erase(SL3metaPrimitives.begin(), SL3metaPrimitives.end());
942 
943  vector<metaPrimitive> auxMetaPrimitives;
945  if (debug_)
946  LogDebug("MuonPathAssociator") << "Pushing back normal MPs to the auxiliar vector";
947  removeSharingHits(normalMetaPrimitives, confirmedMetaPrimitives, auxMetaPrimitives);
948  }
950  if (debug_)
951  LogDebug("MuonPathAssociator") << "Pushing back normal MPs to the MPs collection";
952  removeSharingHits(auxMetaPrimitives, chamberMetaPrimitives, outMPaths);
953  }
954  }
955  }
956  }
957 
958  //eta TP we do not correlate with other superlayer in the same chamber so we forward them all
959  std::vector<metaPrimitive> SL2metaPrimitives;
960 
961  for (int wh = -2; wh <= 2; wh++) {
962  for (int st = 1; st <= 4; st++) {
963  for (int se = 1; se <= 14; se++) {
964  if (se >= 13 && st != 4)
965  continue;
966 
967  DTChamberId ChId(wh, st, se);
968  DTSuperLayerId sl2Id(wh, st, se, 2);
969 
970  //filterSL2 etaTP
971  for (auto metaprimitiveIt = inMPaths.begin(); metaprimitiveIt != inMPaths.end(); ++metaprimitiveIt)
972  if (metaprimitiveIt->rawId == sl2Id.rawId()) {
973  SL2metaPrimitives.push_back(*metaprimitiveIt);
974  if (debug_)
975  printmPC(*metaprimitiveIt);
976  outMPaths.push_back(*metaprimitiveIt);
977  }
978  }
979  }
980  }
981 
982  LogDebug("MuonPathAssociator") << "\t etaTP: added " << SL2metaPrimitives.size() << "to outMPaths" << std::endl;
983 
984  SL2metaPrimitives.clear();
985  SL2metaPrimitives.erase(SL2metaPrimitives.begin(), SL2metaPrimitives.end());
986 }
bool isNotAPrimo(cmsdt::metaPrimitive first, cmsdt::metaPrimitive second)
int station() const
Return the station number.
Definition: DTChamberId.h:42
constexpr int CH_CENTER_TO_MID_SL_X2
Definition: constants.h:200
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
int superLayer() const
Return the superlayer number.
constexpr int DRIFT_SPEED_X4
Definition: constants.h:191
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
std::map< int, float > shiftinfo_
constexpr int VERT_PHI1_PHI3_INV
Definition: constants.h:197
std::map< std::string, int, std::less< std::string > > psi
std::shared_ptr< GlobalCoordsObtainer > globalcoordsobtainer_
constexpr int CELL_LENGTH
Definition: constants.h:186
constexpr int CELL_SEMILENGTH
Definition: constants.h:187
U second(std::pair< T, U > const &p)
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:277
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:258
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr int CELL_HEIGHT
Definition: constants.h:184
constexpr double X_POS_L4
Definition: constants.h:261
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:255
constexpr int NUM_LAYERS_2SL
Definition: constants.h:254
constexpr float VERT_PHI1_PHI3
Definition: constants.h:194
constexpr int LHC_CLK_FREQ
Definition: constants.h:176
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
bool hasPosRF(int wh, int sec)
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
int sector() const
Definition: DTChamberId.h:49
static unsigned int const shift
DTGeometry const * dtGeo_
constexpr int INCREASED_RES_POS_POW
Definition: constants.h:276
void removeSharingFits(std::vector< cmsdt::metaPrimitive > &chamberMPaths, std::vector< cmsdt::metaPrimitive > &allMPaths)
string quality
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:189
constexpr double X_POS_L3
Definition: constants.h:260
#define LogDebug(id)
constexpr int INCREASED_RES_POS
Definition: constants.h:272

◆ 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:151
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH_
DTGeometry const * dtGeo_
#define LogDebug(id)

◆ isNotAPrimo()

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

Definition at line 1085 of file MuonPathAssociator.cc.

References first, and edm::second().

Referenced by correlateMPaths(), and removeSharingHits().

1085  {
1086  int hitsSL1 = (first.wi1 != -1) + (first.wi2 != -1) + (first.wi3 != -1) + (first.wi4 != -1);
1087  int hitsSL3 = (first.wi5 != -1) + (first.wi6 != -1) + (first.wi7 != -1) + (first.wi8 != -1);
1088 
1089  bool lay1 = (first.wi1 == second.wi1) && (first.tdc1 = second.tdc1) && (first.wi1 != -1);
1090  bool lay2 = (first.wi2 == second.wi2) && (first.tdc2 = second.tdc2) && (first.wi2 != -1);
1091  bool lay3 = (first.wi3 == second.wi3) && (first.tdc3 = second.tdc3) && (first.wi3 != -1);
1092  bool lay4 = (first.wi4 == second.wi4) && (first.tdc4 = second.tdc4) && (first.wi4 != -1);
1093  bool lay5 = (first.wi5 == second.wi5) && (first.tdc5 = second.tdc5) && (first.wi5 != -1);
1094  bool lay6 = (first.wi6 == second.wi6) && (first.tdc6 = second.tdc6) && (first.wi6 != -1);
1095  bool lay7 = (first.wi7 == second.wi7) && (first.tdc7 = second.tdc7) && (first.wi7 != -1);
1096  bool lay8 = (first.wi8 == second.wi8) && (first.tdc8 = second.tdc8) && (first.wi8 != -1);
1097 
1098  return (((!lay1 && !lay2 && !lay3 && !lay4) || hitsSL1 < 3) && ((!lay5 && !lay6 && !lay7 && !lay8) || hitsSL3 < 3));
1099 }
U second(std::pair< T, U > const &p)

◆ printmPC()

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

Definition at line 1101 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().

1101  {
1102  DTChamberId ChId(mP.rawId);
1103  LogDebug("MuonPathAssociator") << ChId << "\t"
1104  << " " << setw(2) << left << mP.wi1 << " " << setw(2) << left << mP.wi2 << " "
1105  << setw(2) << left << mP.wi3 << " " << setw(2) << left << mP.wi4 << " " << setw(2)
1106  << left << mP.wi5 << " " << setw(2) << left << mP.wi6 << " " << setw(2) << left
1107  << mP.wi7 << " " << setw(2) << left << mP.wi8 << " " << setw(5) << left << mP.tdc1
1108  << " " << setw(5) << left << mP.tdc2 << " " << setw(5) << left << mP.tdc3 << " "
1109  << setw(5) << left << mP.tdc4 << " " << setw(5) << left << mP.tdc5 << " " << setw(5)
1110  << left << mP.tdc6 << " " << setw(5) << left << mP.tdc7 << " " << setw(5) << left
1111  << mP.tdc8 << " " << setw(2) << left << mP.lat1 << " " << setw(2) << left << mP.lat2
1112  << " " << setw(2) << left << mP.lat3 << " " << setw(2) << left << mP.lat4 << " "
1113  << setw(2) << left << mP.lat5 << " " << setw(2) << left << mP.lat6 << " " << setw(2)
1114  << left << mP.lat7 << " " << setw(2) << left << mP.lat8 << " " << setw(10) << right
1115  << mP.x << " " << setw(9) << left << mP.tanPhi << " " << setw(5) << left << mP.t0
1116  << " " << setw(13) << left << mP.chi2 << " \n";
1117 }
#define LogDebug(id)

◆ removeSharingFits()

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

Definition at line 988 of file MuonPathAssociator.cc.

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

Referenced by correlateMPaths().

988  {
989  bool useFit[chamberMPaths.size()];
990  for (unsigned int i = 0; i < chamberMPaths.size(); i++) {
991  useFit[i] = true;
992  }
993  for (unsigned int i = 0; i < chamberMPaths.size(); i++) {
994  if (debug_)
995  LogDebug("MuonPathAssociator") << "Looking at prim" << i;
996  if (!useFit[i])
997  continue;
998  for (unsigned int j = i + 1; j < chamberMPaths.size(); j++) {
999  if (debug_)
1000  LogDebug("MuonPathAssociator") << "Comparing with prim " << j;
1001  if (!useFit[j])
1002  continue;
1003  metaPrimitive first = chamberMPaths[i];
1004  metaPrimitive second = chamberMPaths[j];
1005  if (shareFit(first, second)) {
1006  if (first.quality > second.quality)
1007  useFit[j] = false;
1008  else if (first.quality < second.quality)
1009  useFit[i] = false;
1010  else {
1011  if (first.chi2 < second.chi2)
1012  useFit[j] = false;
1013  else {
1014  useFit[i] = false;
1015  break;
1016  }
1017  }
1018  }
1019  }
1020  if (useFit[i]) {
1021  if (debug_)
1022  printmPC(chamberMPaths[i]);
1023  allMPaths.push_back(chamberMPaths[i]);
1024  }
1025  }
1026  if (debug_)
1027  LogDebug("MuonPathAssociator") << "---Swapping chamber---";
1028 }
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 1030 of file MuonPathAssociator.cc.

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

Referenced by correlateMPaths().

1032  {
1033  for (auto &firstMP : firstMPaths) {
1034  if (debug_)
1035  LogDebug("MuonPathAssociator") << "----------------------------------";
1036  if (debug_)
1037  LogDebug("MuonPathAssociator") << "Turn for ";
1038  if (debug_)
1039  printmPC(firstMP);
1040  bool ok = true;
1041  for (auto &secondMP : secondMPaths) {
1042  if (debug_)
1043  LogDebug("MuonPathAssociator") << "Comparing with ";
1044  if (debug_)
1045  printmPC(secondMP);
1046  if (!isNotAPrimo(firstMP, secondMP)) {
1047  ok = false;
1048  break;
1049  }
1050  }
1051  if (ok) {
1052  allMPaths.push_back(firstMP);
1053  if (debug_)
1054  printmPC(firstMP);
1055  }
1056  if (debug_)
1057  LogDebug("MuonPathAssociator") << "----------------------------------";
1058  }
1059 }
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 1061 of file MuonPathAssociator.cc.

References first, and edm::second().

Referenced by removeSharingFits().

1061  {
1062  bool lay1 = (first.wi1 == second.wi1) && (first.tdc1 = second.tdc1);
1063  bool lay2 = (first.wi2 == second.wi2) && (first.tdc2 = second.tdc2);
1064  bool lay3 = (first.wi3 == second.wi3) && (first.tdc3 = second.tdc3);
1065  bool lay4 = (first.wi4 == second.wi4) && (first.tdc4 = second.tdc4);
1066  bool lay5 = (first.wi5 == second.wi5) && (first.tdc5 = second.tdc5);
1067  bool lay6 = (first.wi6 == second.wi6) && (first.tdc6 = second.tdc6);
1068  bool lay7 = (first.wi7 == second.wi7) && (first.tdc7 = second.tdc7);
1069  bool lay8 = (first.wi8 == second.wi8) && (first.tdc8 = second.tdc8);
1070 
1071  if (lay1 && lay2 && lay3 && lay4) {
1072  if (lay5 || lay6 || lay7 || lay8)
1073  return true;
1074  else
1075  return false;
1076  } else if (lay5 && lay6 && lay7 && lay8) {
1077  if (lay1 || lay2 || lay3 || lay4)
1078  return true;
1079  else
1080  return false;
1081  } else
1082  return false;
1083 }
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().