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());
77 if (temp.isValid()) tsos = updatorHandle->
update(temp, **it);
84 for (vector<CSCRecHit2D>::iterator it = CSCrh.begin(); it != CSCrh.end(); ++it) {
85 tmprecHits.push_back(theMuonRecHitBuilder->build(&*it));
88 for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) {
89 const CSCLayer* cscLayer = cscGeom->layer((*it)->det()->geographicalId());
100 if (selector < 0 || selector > 2)
throw cms::Exception(
"NotAvailable") <<
"DYT selector: wrong option!" << endl;
104 DYTselector = selector;
113 doUpdateOfKFStates = upState;
117 if (thr.size() == 2) {
118 for (
unsigned int i = 0;
i < thr.size();
i++)
119 if (thr[
i] >= 0) Thrs.push_back(thr[
i]);
123 throw cms::Exception(
"NotAvailable") <<
"WARNING: wrong size for the threshold vector!\nExpected size: 2\n Found size: " << thr.size();
137 dtApeMap = thrManager->GetDTApeMap();
138 cscApeMap = thrManager->GetCSCApeMap();
141 vector<TrajectoryMeasurement> muonMeasurements = traj.
measurements();
143 for (vector<TrajectoryMeasurement>::const_iterator imT = muonMeasurements.begin(); imT != muonMeasurements.end(); imT++ ) {
144 if ( !(*imT).recHit()->isValid() )
continue;
147 result.push_back((*imT).recHit());
148 if (!(*imT).forwardPredictedState().isValid())
continue;
149 if ((*imT).forwardPredictedState().globalPosition().mag() >
169 map<int, vector<DetId> > compatibleIds;
170 map<int, vector<DTRecSegment4D> > dtSegMap;
171 map<int, vector<CSCSegment> > cscSegMap;
172 int incompConLay = 0;
176 compatibleDets(currentState, compatibleIds);
179 fillSegmentMaps(compatibleIds, dtSegMap, cscSegMap);
182 if (useDBforThr) preliminaryFit(compatibleIds, dtSegMap, cscSegMap);
185 for (map<
int, vector<DetId> >::iterator it=compatibleIds.begin(); it!=compatibleIds.end(); ++it) {
186 int stLayer = stationfromDet(it->second.front());
189 double bestDTEstimator =
MAX_THR;
190 double bestCSCEstimator =
MAX_THR;
191 vector<DTRecSegment4D> dtSegs = dtSegMap[it->first];
192 vector<CSCSegment> cscSegs = cscSegMap[it->first];
196 testDTstation(currentState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer);
200 testCSCstation(currentState, cscSegs, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
203 bool chosenLayer = chooseLayers(incompConLay, bestDTEstimator, bestDTSeg, tsosDTlayer, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
204 fillDYTInfos(stLayer, chosenLayer, incompConLay, bestDTEstimator, bestCSCEstimator, bestDTSeg, bestCSCSeg);
226 double const &bestDTEstimator,
double const &bestCSCEstimator,
231 if (bestDTEstimator <= bestCSCEstimator) {
232 estimatorMap[st] = bestDTEstimator;
234 idChamberMap[st] = id;
237 idChamberMap[st] = id;
238 estimatorMap[st] = bestCSCEstimator;
240 usedStationMap[st] =
true;
243 estimatorMap[st] = -1;
244 usedStationMap[st] =
false;
253 vector<const DetLayer *> navLayers;
254 navLayers = navigation->compatibleLayers(*(currentState.freeState()),
alongMomentum);
255 unsigned int ilayerCorrected = 0;
256 for (
unsigned int ilayer=0; ilayer<navLayers.size(); ilayer++ ) {
261 vector<DetLayer::DetWithState> comps = navLayers[ilayer]->compatibleDets(currentState, *propagatorCompatibleDet, *theEstimator);
264 if (comps.size() > 0) {
265 for (
unsigned int icomp=0; icomp<comps.size(); icomp++ ) {
266 DetId id(comps[icomp].
first->geographicalId().rawId());
267 detMap[ilayerCorrected].push_back(
id);
271 if (theEstimator)
delete theEstimator;
277 map<
int, vector<DTRecSegment4D> > &dtSegMap,
278 map<
int, vector<CSCSegment> > &cscSegMap) {
279 for (map<
int, vector<DetId> >::iterator it=compatibleIds.begin(); it!=compatibleIds.end(); ++it) {
280 vector<DetId> ids = compatibleIds[it->first];
281 for (
unsigned j = 0;
j < ids.size();
j++) {
284 vector<CSCSegment>
tmp = getSegs->getCSCSegmentsInChamber(ch);
285 for (
unsigned int k = 0;
k < tmp.size();
k++) cscSegMap[it->first].push_back(tmp[
k]);
289 vector<DTRecSegment4D>
tmp = getSegs->getDTSegmentsInChamber(ch);
290 for (
unsigned int k = 0;
k < tmp.size();
k++) dtSegMap[it->first].push_back(tmp[
k]);
300 if (segments.size() == 0)
return;
301 for (
unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) {
303 if (!
propagator->propagate(startingState, theG->idToDet(chamber)->
surface()).isValid())
continue;
304 tsosdt =
propagator->propagate(startingState, theG->idToDet(chamber)->
surface());
311 if (estimator >= bestEstimator)
continue;
313 bestSeg = segments[iSeg];
321 if (segments.size() == 0)
return;
322 for (
unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) {
323 CSCDetId chamber(segments[iSeg].cscDetId());
324 if (!
propagator->propagate(startingState, theG->idToDet(chamber)->
surface()).isValid())
continue;
325 tsoscsc =
propagator->propagate(startingState, theG->idToDet(chamber)->
surface());
332 if (estimator >= bestEstimator)
continue;
334 bestSeg = segments[iSeg];
341 result.push_back(theMuonRecHitBuilder->build(&bestDTSeg));
342 if (doUpdateOfKFStates) updateWithDThits(currentState, bestDTSeg);
343 else currentState = tsosDT;
349 result.push_back(theMuonRecHitBuilder->build(&bestCSCSeg));
350 if (doUpdateOfKFStates) updateWithCSChits(currentState, bestCSCSeg);
351 else currentState = tsosCSC;
357 map<
int, vector<CSCSegment> > cscSegMap) {
358 for (map<
int, vector<DetId> >::iterator it=compatibleIds.begin(); it!=compatibleIds.end(); ++it) {
361 double bestDTEstimator =
MAX_THR;
362 double bestCSCEstimator =
MAX_THR;
364 vector<DTRecSegment4D> dtSegs = dtSegMap[it->first];
365 vector<CSCSegment> cscSegs = cscSegMap[it->first];
369 testDTstation(prelFitState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer);
373 testCSCstation(prelFitState, cscSegs, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
376 if (bestDTEstimator ==
MAX_THR && bestCSCEstimator ==
MAX_THR)
continue;
377 if (bestDTEstimator <= bestCSCEstimator) {
379 if (bestDTEstimator >= initThr)
continue;
380 prelFitMeas.push_back(theMuonRecHitBuilder->build(&bestDTSeg));
381 prelFitState = updatorHandle->update(tsosDTlayer, *theMuonRecHitBuilder->build(&bestDTSeg));
384 if (bestCSCEstimator >= initThr)
continue;
385 prelFitMeas.push_back(theMuonRecHitBuilder->build(&bestCSCSeg));
386 prelFitState = updatorHandle->update(tsosCSClayer, *theMuonRecHitBuilder->build(&bestCSCSeg));
389 if (!prelFitMeas.empty()) prelFitMeas.pop_back();
390 for (
auto imrh = prelFitMeas.rbegin(); imrh != prelFitMeas.rend(); ++imrh) {
391 DetId id = (*imrh)->geographicalId();
393 if (tmp.
isValid()) prelFitState = tmp;
396 muonETAest = prelFitState.globalMomentum().eta();
404 if (bestDTEstimator ==
MAX_THR && bestCSCEstimator ==
MAX_THR)
return false;
405 if (bestDTEstimator <= bestCSCEstimator) {
407 if (useDBforThr) getThresholdFromDB(initThr,
DetId(bestDTSeg.
chamberId()));
409 if (DYTselector == 0 || (DYTselector == 1 && bestDTEstimator < initThr) ||
410 (DYTselector == 2 && incompLayers < 2 && bestDTEstimator < initThr)) {
411 useSegment(bestDTSeg, tsosDT);
416 if (useDBforThr) getThresholdFromDB(initThr,
DetId(bestCSCSeg.
cscDetId()));
417 else getThresholdFromCFG(initThr,
DetId(bestCSCSeg.
cscDetId()));
418 if (DYTselector == 0 || (DYTselector == 1 && bestCSCEstimator < initThr) ||
419 (DYTselector == 2 && incompLayers < 2 && bestCSCEstimator < initThr)) {
420 useSegment(bestCSCSeg, tsosCSC);
430 vector<DYTThrObject::DytThrStruct> thrvector = dytThresholds->thrsVec;
431 for (vector<DYTThrObject::DytThrStruct>::const_iterator it = thrvector.begin(); it != thrvector.end(); it++) {
438 correctThrByPtAndEta(thr);
470 for(j=n-1; j>=
i; --
j)
471 if(recHits[j-1]->globalPosition().
mag() > recHits[j]->globalPosition().
mag())
swap (recHits[j-1],recHits[j]);
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
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())
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)
void testCSCstation(TrajectoryStateOnSurface &, std::vector< CSCSegment > const &, double &, CSCSegment &, TrajectoryStateOnSurface &)
const bool isValidThdDB()
TransientTrackingRecHit::ConstRecHitContainer filter(const Trajectory &)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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.
Detector det() const
get the detector field from this detid
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 &)