39 propagator = theService.propagator(
"SmartPropagatorAny");
40 propagatorPF = theService.propagator(
"SmartPropagatorAny");
41 propagatorCompatibleDet = theService.propagator(
"SmartPropagatorAny");
42 theG = theService.trackingGeometry();
52 if (useDBforThr) dytThresholds = thrManager->getInitialThresholds();
53 doUpdateOfKFStates =
true;
64 if (temp.
isValid()) tsos = updatorHandle->
update(tsos, *rechit);
69 vector<const TrackingRecHit*> DTrh = bestDTSeg.
recHits();
70 for (vector<const TrackingRecHit*>::iterator it = DTrh.begin(); it != DTrh.end(); it++) {
71 tmprecHits.push_back(theMuonRecHitBuilder->build(*it));
74 for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) {
75 DTLayerId layid((*it)->det()->geographicalId());
79 if (tempTsos.
isValid() ) tsos = tempTsos;
87 for (vector<CSCRecHit2D>::iterator it = CSCrh.begin(); it != CSCrh.end(); ++it) {
88 tmprecHits.push_back(theMuonRecHitBuilder->build(&*it));
91 for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) {
92 const CSCLayer* cscLayer = cscGeom->layer((*it)->det()->geographicalId());
96 if (tempTsos.
isValid() ) tsos = tempTsos;
106 if (selector < 0 || selector > 2)
throw cms::Exception(
"NotAvailable") <<
"DYT selector: wrong option!" << endl;
119 doUpdateOfKFStates = upState;
123 if (thr.size() == 2) {
124 for (
unsigned int i = 0;
i < thr.size();
i++)
125 if (thr[
i] >= 0) Thrs.push_back(thr[
i]);
129 throw cms::Exception(
"NotAvailable") <<
"WARNING: wrong size for the threshold vector!\nExpected size: 2\n Found size: " << thr.size();
143 dtApeMap = thrManager->GetDTApeMap();
144 cscApeMap = thrManager->GetCSCApeMap();
147 vector<TrajectoryMeasurement> muonMeasurements = traj.
measurements();
149 for (vector<TrajectoryMeasurement>::const_iterator imT = muonMeasurements.begin(); imT != muonMeasurements.end(); imT++ ) {
150 if ( !(*imT).recHit()->isValid() )
continue;
153 result.push_back((*imT).recHit());
154 if (!(*imT).forwardPredictedState().isValid())
continue;
155 if ((*imT).forwardPredictedState().globalPosition().mag() >
175 map<int, vector<DetId> > compatibleIds;
176 map<int, vector<DTRecSegment4D> > dtSegMap;
177 map<int, vector<CSCSegment> > cscSegMap;
178 int incompConLay = 0;
182 compatibleDets(currentState, compatibleIds);
185 fillSegmentMaps(compatibleIds, dtSegMap, cscSegMap);
188 if (useDBforThr) preliminaryFit(compatibleIds, dtSegMap, cscSegMap);
191 for (
map<
int, vector<DetId> >::iterator it=compatibleIds.begin(); it!=compatibleIds.end(); ++it) {
192 int stLayer = stationfromDet(it->second.front());
195 double bestDTEstimator =
MAX_THR;
196 double bestCSCEstimator =
MAX_THR;
197 vector<DTRecSegment4D> dtSegs = dtSegMap[it->first];
198 vector<CSCSegment> cscSegs = cscSegMap[it->first];
202 testDTstation(currentState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer);
206 testCSCstation(currentState, cscSegs, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
209 bool chosenLayer = chooseLayers(incompConLay, bestDTEstimator, bestDTSeg, tsosDTlayer, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
210 fillDYTInfos(stLayer, chosenLayer, incompConLay, bestDTEstimator, bestCSCEstimator, bestDTSeg, bestCSCSeg);
232 double const &bestDTEstimator,
double const &bestCSCEstimator,
237 if (bestDTEstimator <= bestCSCEstimator) {
238 estimatorMap[st] = bestDTEstimator;
240 idChamberMap[st] =
id;
243 idChamberMap[st] =
id;
244 estimatorMap[st] = bestCSCEstimator;
246 usedStationMap[st] =
true;
249 estimatorMap[st] = -1;
250 usedStationMap[st] =
false;
259 vector<const DetLayer *> navLayers;
260 navLayers = navigation->compatibleLayers(*(currentState.freeState()),
alongMomentum);
261 unsigned int ilayerCorrected = 0;
262 for (
unsigned int ilayer=0; ilayer<navLayers.size(); ilayer++ ) {
267 vector<DetLayer::DetWithState> comps = navLayers[ilayer]->compatibleDets(currentState, *propagatorCompatibleDet, *theEstimator);
270 if (!comps.empty()) {
271 for (
unsigned int icomp=0; icomp<comps.size(); icomp++ ) {
273 detMap[ilayerCorrected].push_back(
id);
277 if (theEstimator)
delete theEstimator;
283 map<
int, vector<DTRecSegment4D> > &dtSegMap,
284 map<
int, vector<CSCSegment> > &cscSegMap) {
285 for (
map<
int, vector<DetId> >::iterator it=compatibleIds.begin(); it!=compatibleIds.end(); ++it) {
286 vector<DetId> ids = compatibleIds[it->first];
287 for (
unsigned j = 0; j < ids.size(); j++) {
290 vector<CSCSegment>
tmp = getSegs->getCSCSegmentsInChamber(ch);
291 for (
unsigned int k = 0;
k < tmp.size();
k++) cscSegMap[it->first].push_back(tmp[
k]);
295 vector<DTRecSegment4D>
tmp = getSegs->getDTSegmentsInChamber(ch);
296 for (
unsigned int k = 0;
k < tmp.size();
k++) dtSegMap[it->first].push_back(tmp[
k]);
306 if (segments.empty())
return;
307 for (
unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) {
309 if (!
propagator->propagate(startingState, theG->idToDet(chamber)->
surface()).isValid())
continue;
310 tsosdt =
propagator->propagate(startingState, theG->idToDet(chamber)->
surface());
317 if (estimator >= bestEstimator)
continue;
319 bestSeg = segments[iSeg];
327 if (segments.empty())
return;
328 for (
unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) {
330 if (!
propagator->propagate(startingState, theG->idToDet(chamber)->
surface()).isValid())
continue;
331 tsoscsc =
propagator->propagate(startingState, theG->idToDet(chamber)->
surface());
338 if (estimator >= bestEstimator)
continue;
340 bestSeg = segments[iSeg];
347 result.push_back(theMuonRecHitBuilder->build(&bestDTSeg));
348 if (doUpdateOfKFStates) updateWithDThits(currentState, bestDTSeg);
349 else currentState = tsosDT;
355 result.push_back(theMuonRecHitBuilder->build(&bestCSCSeg));
356 if (doUpdateOfKFStates) updateWithCSChits(currentState, bestCSCSeg);
357 else currentState = tsosCSC;
363 map<
int, vector<CSCSegment> > cscSegMap) {
364 for (
map<
int, vector<DetId> >::iterator it=compatibleIds.begin(); it!=compatibleIds.end(); ++it) {
367 double bestDTEstimator =
MAX_THR;
368 double bestCSCEstimator =
MAX_THR;
370 vector<DTRecSegment4D> dtSegs = dtSegMap[it->first];
371 vector<CSCSegment> cscSegs = cscSegMap[it->first];
375 testDTstation(prelFitState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer);
379 testCSCstation(prelFitState, cscSegs, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
382 if (bestDTEstimator ==
MAX_THR && bestCSCEstimator ==
MAX_THR)
continue;
383 if (bestDTEstimator <= bestCSCEstimator) {
385 if (bestDTEstimator >= initThr)
continue;
386 prelFitMeas.push_back(theMuonRecHitBuilder->build(&bestDTSeg));
387 auto aSegRH = prelFitMeas.back();
388 auto uRes = updatorHandle->update(tsosDTlayer, *aSegRH);
392 prelFitMeas.pop_back();
396 if (bestCSCEstimator >= initThr)
continue;
397 prelFitMeas.push_back(theMuonRecHitBuilder->build(&bestCSCSeg));
398 auto aSegRH = prelFitMeas.back();
399 auto uRes = updatorHandle->update(tsosCSClayer, *aSegRH);
403 prelFitMeas.pop_back();
407 if (!prelFitMeas.empty()) prelFitMeas.pop_back();
408 for (
auto imrh = prelFitMeas.rbegin(); imrh != prelFitMeas.rend(); ++imrh) {
409 DetId id = (*imrh)->geographicalId();
411 if (tmp.
isValid()) prelFitState = tmp;
414 muonETAest = prelFitState.globalMomentum().eta();
422 if (bestDTEstimator ==
MAX_THR && bestCSCEstimator ==
MAX_THR)
return false;
423 if (bestDTEstimator <= bestCSCEstimator) {
425 if (useDBforThr) getThresholdFromDB(initThr,
DetId(bestDTSeg.
chamberId()));
428 (
DYTselector == 2 && incompLayers < 2 && bestDTEstimator < initThr)) {
429 useSegment(bestDTSeg, tsosDT);
434 if (useDBforThr) getThresholdFromDB(initThr,
DetId(bestCSCSeg.
cscDetId()));
435 else getThresholdFromCFG(initThr,
DetId(bestCSCSeg.
cscDetId()));
437 (
DYTselector == 2 && incompLayers < 2 && bestCSCEstimator < initThr)) {
438 useSegment(bestCSCSeg, tsosCSC);
448 vector<DYTThrObject::DytThrStruct> thrvector = dytThresholds->thrsVec;
449 for (vector<DYTThrObject::DytThrStruct>::const_iterator it = thrvector.begin(); it != thrvector.end(); it++) {
456 correctThrByPtAndEta(thr);
488 for(j=n-1; j>=
i; --j)
489 if(recHits[j-1]->globalPosition().
mag() > recHits[j]->globalPosition().
mag())
swap (recHits[j-1],recHits[j]);
void compatibleDets(TrajectoryStateOnSurface &, std::map< int, std::vector< DetId > > &)
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 fillSegmentMaps(std::map< int, std::vector< DetId > > &, std::map< int, std::vector< DTRecSegment4D > > &, std::map< int, std::vector< CSCSegment > > &)
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)
DataContainer const & measurements() const
void correctThrByPtAndEta(double &)
const SurfaceType & surface() const
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void testCSCstation(TrajectoryStateOnSurface &, std::vector< CSCSegment > const &, double &, CSCSegment &, TrajectoryStateOnSurface &)
const bool isValidThdDB()
TransientTrackingRecHit::ConstRecHitContainer filter(const Trajectory &)
const std::vector< CSCRecHit2D > & specificRecHits() const
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
std::vector< ConstRecHitPointer > ConstRecHitContainer
void preliminaryFit(std::map< int, std::vector< DetId > >, std::map< int, std::vector< DTRecSegment4D > >, std::map< int, std::vector< CSCSegment > >)
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
std::vector< std::vector< double > > tmp
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
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 > &)
void setUpdateState(bool)
void getThresholdFromCFG(double &, DetId const &)
constexpr Detector det() const
get the detector field from this detid