38 propagator = theService.propagator(
"SmartPropagatorAny");
39 propagatorPF = theService.propagator(
"SmartPropagatorAny");
40 propagatorCompatibleDet = theService.propagator(
"SmartPropagatorAny");
41 theG = theService.trackingGeometry();
51 if (useDBforThr) dytThresholds = thrManager->getInitialThresholds();
52 doUpdateOfKFStates =
true;
63 if (temp.
isValid()) tsos = updatorHandle->
update(tsos, *rechit);
68 vector<const TrackingRecHit*> DTrh = bestDTSeg.
recHits();
69 for (vector<const TrackingRecHit*>::iterator it = DTrh.begin(); it != DTrh.end(); it++) {
70 tmprecHits.push_back(theMuonRecHitBuilder->build(*it));
73 for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) {
74 DTLayerId layid((*it)->det()->geographicalId());
76 if (temp.isValid()) tsos = updatorHandle->
update(temp, **it);
83 for (vector<CSCRecHit2D>::iterator it = CSCrh.begin(); it != CSCrh.end(); ++it) {
84 tmprecHits.push_back(theMuonRecHitBuilder->build(&*it));
87 for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) {
88 const CSCLayer* cscLayer = cscGeom->layer((*it)->det()->geographicalId());
99 if (selector < 0 || selector > 2)
throw cms::Exception(
"NotAvailable") <<
"DYT selector: wrong option!" << endl;
103 DYTselector = selector;
112 doUpdateOfKFStates = upState;
116 if (thr.size() == 2) {
117 for (
unsigned int i = 0;
i < thr.size();
i++)
118 if (thr[
i] >= 0) Thrs.push_back(thr[
i]);
122 throw cms::Exception(
"NotAvailable") <<
"WARNING: wrong size for the threshold vector!\nExpected size: 2\n Found size: " << thr.size();
136 dtApeMap = thrManager->GetDTApeMap();
137 cscApeMap = thrManager->GetCSCApeMap();
140 vector<TrajectoryMeasurement> muonMeasurements = traj.
measurements();
142 for (vector<TrajectoryMeasurement>::const_iterator imT = muonMeasurements.begin(); imT != muonMeasurements.end(); imT++ ) {
143 if ( !(*imT).recHit()->isValid() )
continue;
146 result.push_back((*imT).recHit());
147 if (!(*imT).forwardPredictedState().isValid())
continue;
148 if ((*imT).forwardPredictedState().globalPosition().mag() >
168 map<int, vector<DetId> > compatibleIds;
169 map<int, vector<DTRecSegment4D> > dtSegMap;
170 map<int, vector<CSCSegment> > cscSegMap;
171 int incompConLay = 0;
175 compatibleDets(currentState, compatibleIds);
178 fillSegmentMaps(compatibleIds, dtSegMap, cscSegMap);
181 if (useDBforThr) preliminaryFit(compatibleIds, dtSegMap, cscSegMap);
184 for (
map<
int, vector<DetId> >::iterator it=compatibleIds.begin(); it!=compatibleIds.end(); ++it) {
185 int stLayer = stationfromDet(it->second.front());
188 double bestDTEstimator =
MAX_THR;
189 double bestCSCEstimator =
MAX_THR;
190 vector<DTRecSegment4D> dtSegs = dtSegMap[it->first];
191 vector<CSCSegment> cscSegs = cscSegMap[it->first];
195 testDTstation(currentState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer);
199 testCSCstation(currentState, cscSegs, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
202 bool chosenLayer = chooseLayers(incompConLay, bestDTEstimator, bestDTSeg, tsosDTlayer, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
203 fillDYTInfos(stLayer, chosenLayer, incompConLay, bestDTEstimator, bestCSCEstimator, bestDTSeg, bestCSCSeg);
225 double const &bestDTEstimator,
double const &bestCSCEstimator,
230 if (bestDTEstimator <= bestCSCEstimator) {
231 estimatorMap[st] = bestDTEstimator;
233 idChamberMap[st] = id;
236 idChamberMap[st] = id;
237 estimatorMap[st] = bestCSCEstimator;
239 usedStationMap[st] =
true;
242 estimatorMap[st] = -1;
243 usedStationMap[st] =
false;
252 vector<const DetLayer *> navLayers;
253 navLayers = navigation->compatibleLayers(*(currentState.freeState()),
alongMomentum);
254 unsigned int ilayerCorrected = 0;
255 for (
unsigned int ilayer=0; ilayer<navLayers.size(); ilayer++ ) {
260 vector<DetLayer::DetWithState> comps = navLayers[ilayer]->compatibleDets(currentState, *propagatorCompatibleDet, *theEstimator);
263 if (comps.size() > 0) {
264 for (
unsigned int icomp=0; icomp<comps.size(); icomp++ ) {
265 DetId id(comps[icomp].
first->geographicalId().rawId());
266 detMap[ilayerCorrected].push_back(
id);
270 if (theEstimator)
delete theEstimator;
276 map<
int, vector<DTRecSegment4D> > &dtSegMap,
277 map<
int, vector<CSCSegment> > &cscSegMap) {
278 for (
map<
int, vector<DetId> >::iterator it=compatibleIds.begin(); it!=compatibleIds.end(); ++it) {
279 vector<DetId> ids = compatibleIds[it->first];
280 for (
unsigned j = 0;
j < ids.size();
j++) {
283 vector<CSCSegment>
tmp = getSegs->getCSCSegmentsInChamber(ch);
284 for (
unsigned int k = 0;
k < tmp.size();
k++) cscSegMap[it->first].push_back(tmp[
k]);
288 vector<DTRecSegment4D>
tmp = getSegs->getDTSegmentsInChamber(ch);
289 for (
unsigned int k = 0;
k < tmp.size();
k++) dtSegMap[it->first].push_back(tmp[
k]);
299 if (segments.size() == 0)
return;
300 for (
unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) {
302 if (!propagator->propagate(startingState, theG->idToDet(chamber)->
surface()).isValid())
continue;
303 tsosdt = propagator->propagate(startingState, theG->idToDet(chamber)->
surface());
308 double estimator = estim.
value();
310 if (estimator >= bestEstimator)
continue;
311 bestEstimator = estimator;
312 bestSeg = segments[iSeg];
320 if (segments.size() == 0)
return;
321 for (
unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) {
322 CSCDetId chamber(segments[iSeg].cscDetId());
323 if (!propagator->propagate(startingState, theG->idToDet(chamber)->
surface()).isValid())
continue;
324 tsoscsc = propagator->propagate(startingState, theG->idToDet(chamber)->
surface());
329 double estimator = estim.
value();
331 if (estimator >= bestEstimator)
continue;
332 bestEstimator = estimator;
333 bestSeg = segments[iSeg];
340 result.push_back(theMuonRecHitBuilder->build(&bestDTSeg));
341 if (doUpdateOfKFStates) updateWithDThits(currentState, bestDTSeg);
342 else currentState = tsosDT;
348 result.push_back(theMuonRecHitBuilder->build(&bestCSCSeg));
349 if (doUpdateOfKFStates) updateWithCSChits(currentState, bestCSCSeg);
350 else currentState = tsosCSC;
356 map<
int, vector<CSCSegment> > cscSegMap) {
357 for (
map<
int, vector<DetId> >::iterator it=compatibleIds.begin(); it!=compatibleIds.end(); ++it) {
360 double bestDTEstimator =
MAX_THR;
361 double bestCSCEstimator =
MAX_THR;
363 vector<DTRecSegment4D> dtSegs = dtSegMap[it->first];
364 vector<CSCSegment> cscSegs = cscSegMap[it->first];
368 testDTstation(prelFitState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer);
372 testCSCstation(prelFitState, cscSegs, bestCSCEstimator, bestCSCSeg, tsosCSClayer);
375 if (bestDTEstimator ==
MAX_THR && bestCSCEstimator ==
MAX_THR)
continue;
376 if (bestDTEstimator <= bestCSCEstimator) {
378 if (bestDTEstimator >= initThr)
continue;
379 prelFitMeas.push_back(theMuonRecHitBuilder->build(&bestDTSeg));
380 prelFitState = updatorHandle->update(tsosDTlayer, *theMuonRecHitBuilder->build(&bestDTSeg));
383 if (bestCSCEstimator >= initThr)
continue;
384 prelFitMeas.push_back(theMuonRecHitBuilder->build(&bestCSCSeg));
385 prelFitState = updatorHandle->update(tsosCSClayer, *theMuonRecHitBuilder->build(&bestCSCSeg));
388 prelFitMeas.pop_back();
389 for (ConstRecHitContainer::const_iterator imrh = prelFitMeas.end(); imrh != prelFitMeas.begin(); imrh-- ) {
390 DetId id = (*imrh)->geographicalId();
392 if (tmp.
isValid()) prelFitState = tmp;
395 muonETAest = prelFitState.globalMomentum().eta();
403 if (bestDTEstimator ==
MAX_THR && bestCSCEstimator ==
MAX_THR)
return false;
404 if (bestDTEstimator <= bestCSCEstimator) {
406 if (useDBforThr) getThresholdFromDB(initThr,
DetId(bestDTSeg.
chamberId()));
408 if (DYTselector == 0 || (DYTselector == 1 && bestDTEstimator < initThr) ||
409 (DYTselector == 2 && incompLayers < 2 && bestDTEstimator < initThr)) {
410 useSegment(bestDTSeg, tsosDT);
415 if (useDBforThr) getThresholdFromDB(initThr,
DetId(bestCSCSeg.
cscDetId()));
416 else getThresholdFromCFG(initThr,
DetId(bestCSCSeg.
cscDetId()));
417 if (DYTselector == 0 || (DYTselector == 1 && bestCSCEstimator < initThr) ||
418 (DYTselector == 2 && incompLayers < 2 && bestCSCEstimator < initThr)) {
419 useSegment(bestCSCSeg, tsosCSC);
429 vector<DYTThrObject::DytThrStruct> thrvector = dytThresholds->thrsVec;
430 for (vector<DYTThrObject::DytThrStruct>::const_iterator it = thrvector.begin(); it != thrvector.end(); it++) {
437 correctThrByPtAndEta(thr);
469 for(j=n-1; j>=
i; --
j)
470 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
tuple Chi2MeasurementEstimator
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 &)