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());
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) {
260 estimatorMap[st] = bestDTEstimator;
262 idChamberMap[st] =
id;
265 idChamberMap[st] =
id;
266 estimatorMap[st] = bestCSCEstimator;
268 usedStationMap[st] =
true;
271 estimatorMap[st] = -1;
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++) {
337 if (!
propagator->propagate(startingState, theG->idToDet(chamber)->
surface()).isValid())
339 tsosdt =
propagator->propagate(startingState, theG->idToDet(chamber)->
surface());
347 if (estimator >= bestEstimator)
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++) {
364 if (!
propagator->propagate(startingState, theG->idToDet(chamber)->
surface()).isValid())
366 tsoscsc =
propagator->propagate(startingState, theG->idToDet(chamber)->
surface());
374 if (estimator >= bestEstimator)
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();
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)
565 if (recHits[j - 1]->globalPosition().
mag() > recHits[j]->globalPosition().
mag())
566 swap(recHits[j - 1], recHits[j]);
T getParameter(std::string const &) const
CSCDetId cscDetId() const
ConstRecHitPointer const & recHit() const
void sort(ConstRecHitContainer &)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
void useSegment(DTRecSegment4D const &, TrajectoryStateOnSurface const &)
GlobalPoint globalPosition() const
void getThresholdFromDB(double &, DetId const &)
virtual DTChamberId chamberId() const
The (specific) DetId of the chamber on which the segment resides.
void updateWithCSChits(TrajectoryStateOnSurface &, CSCSegment const &)
void testDTstation(TrajectoryStateOnSurface &, std::vector< DTRecSegment4D > const &, double &, DTRecSegment4D &, TrajectoryStateOnSurface &)
const Plane & surface() const
The nominal surface of the GeomDet.
void swap(Association< C > &lhs, Association< C > &rhs)
void preliminaryFit(std::map< int, std::vector< DetId >>, std::map< int, std::vector< DTRecSegment4D >>, std::map< int, std::vector< CSCSegment >>)
DataContainer const & measurements() const
const SurfaceType & surface() const
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
void compatibleDets(TrajectoryStateOnSurface &, std::map< int, std::vector< DetId >> &)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
void correctThrByPAndEta(double &)
void testCSCstation(TrajectoryStateOnSurface &, std::vector< CSCSegment > const &, double &, CSCSegment &, TrajectoryStateOnSurface &)
const bool isValidThdDB()
TransientTrackingRecHit::ConstRecHitContainer filter(const Trajectory &)
void fillSegmentMaps(std::map< int, std::vector< DetId >> &, std::map< int, std::vector< DTRecSegment4D >> &, std::map< int, std::vector< CSCSegment >> &)
const std::vector< CSCRecHit2D > & specificRecHits() const
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
std::vector< ConstRecHitPointer > ConstRecHitContainer
void setThrsMap(const edm::ParameterSet &)
DynamicTruncation(const edm::Event &, const MuonServiceProxy &)
void update(TrajectoryStateOnSurface &, ConstRecHitPointer)
void fillDYTInfos(int const &, bool const &, int &, double const &, double const &, DTRecSegment4D const &, CSCSegment const &)
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
GlobalVector globalMomentum() const
bool chooseLayers(int &, double const &, DTRecSegment4D const &, TrajectoryStateOnSurface const &, double const &, CSCSegment const &, TrajectoryStateOnSurface const &)
int stationfromDet(DetId const &)
DetId geographicalId() const
static const std::map< etaRegion, std::string > etaRegionStr
int station() const
Return the station number.
T first(std::pair< T, U > const &p)
void updateWithDThits(TrajectoryStateOnSurface &, DTRecSegment4D const &)
void setThr(const std::vector< int > &)
Power< A, B >::type pow(const A &a, const B &b)
void setUpdateState(bool)
void getThresholdFromCFG(double &, DetId const &)
constexpr Detector det() const
get the detector field from this detid