46 propagator = theService.propagator(
"SmartPropagatorAny");
47 propagatorPF = theService.propagator(
"SmartPropagatorAny");
48 propagatorCompatibleDet = theService.propagator(
"SmartPropagatorAny");
49 theG = theService.trackingGeometry();
60 dytThresholds = thrManager->getInitialThresholds();
62 doUpdateOfKFStates =
true;
63 useParametrizedThr =
false;
75 tsos = updatorHandle->
update(tsos, *rechit);
80 vector<const TrackingRecHit *> DTrh = bestDTSeg.
recHits();
81 for (vector<const TrackingRecHit *>::iterator it = DTrh.begin(); it != DTrh.end(); it++) {
82 tmprecHits.push_back(theMuonRecHitBuilder->build(*it));
85 for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) {
86 DTLayerId layid((*it)->det()->geographicalId());
99 for (vector<CSCRecHit2D>::iterator it = CSCrh.begin(); it != CSCrh.end(); ++it) {
100 tmprecHits.push_back(theMuonRecHitBuilder->build(&*it));
103 for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) {
104 const CSCLayer *cscLayer = cscGeom->layer((*it)->det()->geographicalId());
106 if (
temp.isValid()) {
118 if (selector < 0 || selector > 2)
119 throw cms::Exception(
"NotAvailable") <<
"DYT selector: wrong option!" << endl;
131 if (thr.size() == 2) {
132 for (
unsigned int i = 0;
i < thr.size();
i++)
134 Thrs.push_back(thr[
i]);
140 <<
"WARNING: wrong size for the threshold vector!\nExpected size: 2\n Found size: " << thr.size();
158 dtApeMap = thrManager->GetDTApeMap();
159 cscApeMap = thrManager->GetCSCApeMap();
162 vector<TrajectoryMeasurement> muonMeasurements = traj.
measurements();
164 for (vector<TrajectoryMeasurement>::const_iterator imT = muonMeasurements.begin(); imT != muonMeasurements.end();
166 if (!(*imT).recHit()->isValid())
170 result.push_back((*imT).recHit());
171 if (!(*imT).forwardPredictedState().isValid())
173 if ((*imT).forwardPredictedState().globalPosition().mag() >
193 map<int, vector<DetId> > compatibleIds;
194 map<int, vector<DTRecSegment4D> > dtSegMap;
195 map<int, vector<CSCSegment> > cscSegMap;
196 int incompConLay = 0;
200 compatibleDets(currentState, compatibleIds);
203 fillSegmentMaps(compatibleIds, dtSegMap, cscSegMap);
207 preliminaryFit(compatibleIds, dtSegMap, cscSegMap);
210 for (
map<
int, vector<DetId> >::iterator it = compatibleIds.begin(); it != compatibleIds.end(); ++it) {
211 int stLayer = stationfromDet(it->second.front());
214 double bestDTEstimator =
MAX_THR;
215 double bestCSCEstimator =
MAX_THR;
216 vector<DTRecSegment4D> dtSegs = dtSegMap[it->first];
217 vector<CSCSegment> cscSegs = cscSegMap[it->first];
221 testDTstation(currentState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer);
225 testCSCstation(currentState, cscSegs, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
229 chooseLayers(incompConLay, bestDTEstimator, bestDTSeg, tsosDTlayer, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
230 fillDYTInfos(stLayer, chosenLayer, incompConLay, bestDTEstimator, bestCSCEstimator, bestDTSeg, bestCSCSeg);
250 bool const &chosenLayer,
252 double const &bestDTEstimator,
253 double const &bestCSCEstimator,
259 if (bestDTEstimator <= bestCSCEstimator) {
262 idChamberMap[st] =
id;
265 idChamberMap[st] =
id;
268 usedStationMap[st] =
true;
272 usedStationMap[st] =
false;
280 vector<const DetLayer *> navLayers;
281 navLayers = navigation->compatibleLayers(*(currentState.freeState()),
alongMomentum);
282 unsigned int ilayerCorrected = 0;
283 for (
unsigned int ilayer = 0; ilayer < navLayers.size(); ilayer++) {
289 vector<DetLayer::DetWithState> comps =
290 navLayers[ilayer]->compatibleDets(currentState, *propagatorCompatibleDet, *theEstimator);
293 if (!comps.empty()) {
294 for (
unsigned int icomp = 0; icomp < comps.size(); icomp++) {
296 detMap[ilayerCorrected].push_back(
id);
306 map<
int, vector<DTRecSegment4D> > &dtSegMap,
307 map<
int, vector<CSCSegment> > &cscSegMap) {
308 for (
map<
int, vector<DetId> >::iterator it = compatibleIds.begin(); it != compatibleIds.end(); ++it) {
309 vector<DetId> ids = compatibleIds[it->first];
310 for (
unsigned j = 0;
j < ids.size();
j++) {
313 vector<CSCSegment>
tmp = getSegs->getCSCSegmentsInChamber(ch);
314 for (
unsigned int k = 0;
k <
tmp.size();
k++)
315 cscSegMap[it->first].push_back(
tmp[
k]);
319 vector<DTRecSegment4D>
tmp = getSegs->getDTSegmentsInChamber(ch);
320 for (
unsigned int k = 0;
k <
tmp.size();
k++)
321 dtSegMap[it->first].push_back(
tmp[
k]);
329 vector<DTRecSegment4D>
const &segments,
330 double &bestEstimator,
333 if (segments.empty())
335 for (
unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) {
350 bestSeg = segments[iSeg];
356 vector<CSCSegment>
const &segments,
357 double &bestEstimator,
360 if (segments.empty())
362 for (
unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) {
377 bestSeg = segments[iSeg];
383 result.push_back(theMuonRecHitBuilder->build(&bestDTSeg));
384 if (doUpdateOfKFStates)
385 updateWithDThits(currentState, bestDTSeg);
387 currentState = tsosDT;
392 result.push_back(theMuonRecHitBuilder->build(&bestCSCSeg));
393 if (doUpdateOfKFStates)
394 updateWithCSChits(currentState, bestCSCSeg);
396 currentState = tsosCSC;
401 map<
int, vector<DTRecSegment4D> > dtSegMap,
402 map<
int, vector<CSCSegment> > cscSegMap) {
403 for (
map<
int, vector<DetId> >::iterator it = compatibleIds.begin(); it != compatibleIds.end(); ++it) {
406 double bestDTEstimator =
MAX_THR;
407 double bestCSCEstimator =
MAX_THR;
409 vector<DTRecSegment4D> dtSegs = dtSegMap[it->first];
410 vector<CSCSegment> cscSegs = cscSegMap[it->first];
414 testDTstation(prelFitState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer);
418 testCSCstation(prelFitState, cscSegs, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
423 if (bestDTEstimator <= bestCSCEstimator) {
425 if (bestDTEstimator >= initThr)
427 prelFitMeas.push_back(theMuonRecHitBuilder->build(&bestDTSeg));
428 auto aSegRH = prelFitMeas.back();
429 auto uRes = updatorHandle->update(tsosDTlayer, *aSegRH);
430 if (uRes.isValid()) {
433 prelFitMeas.pop_back();
437 if (bestCSCEstimator >= initThr)
439 prelFitMeas.push_back(theMuonRecHitBuilder->build(&bestCSCSeg));
440 auto aSegRH = prelFitMeas.back();
441 auto uRes = updatorHandle->update(tsosCSClayer, *aSegRH);
442 if (uRes.isValid()) {
445 prelFitMeas.pop_back();
449 if (!prelFitMeas.empty())
450 prelFitMeas.pop_back();
451 for (
auto imrh = prelFitMeas.rbegin(); imrh != prelFitMeas.rend(); ++imrh) {
452 DetId id = (*imrh)->geographicalId();
457 muonPTest = prelFitState.globalMomentum().perp();
458 muonETAest = prelFitState.globalMomentum().eta();
463 double const &bestDTEstimator,
466 double const &bestCSCEstimator,
472 if (bestDTEstimator <= bestCSCEstimator) {
479 (
DYTselector == 2 && incompLayers < 2 && bestDTEstimator < initThr)) {
480 useSegment(bestDTSeg, tsosDT);
490 (
DYTselector == 2 && incompLayers < 2 && bestCSCEstimator < initThr)) {
491 useSegment(bestCSCSeg, tsosCSC);
500 vector<DYTThrObject::DytThrStruct> thrvector = dytThresholds->thrsVec;
501 for (vector<DYTThrObject::DytThrStruct>::const_iterator it = thrvector.begin(); it != thrvector.end(); it++) {
508 if (useParametrizedThr)
509 correctThrByPAndEta(thr);
514 auto parametricThreshold = [
this] {
518 return thr50 * (1 + p0 * p_reco +
std::pow(this->p_reco,
p1));
521 std::set<dyt_utils::etaRegion> regionsToExclude = {
524 if (!regionsToExclude.count(this->region))
525 thr = parametricThreshold();
535 else if (absEta <= 1.2)
537 else if (absEta <= 2.0)
539 else if (absEta <= 2.2)
541 else if (absEta <= 2.4)
554 if (useParametrizedThr)
555 correctThrByPAndEta(thr);
563 for (
i = 1;
i <
n; ++
i)
564 for (
j =
n - 1;
j >=
i; --
j)