79 theCosmicFlag(par.getParameter<
bool>(
"PropDirForCosmics")),
80 theDTRecHitLabel(par.getParameter<
InputTag>(
"DTRecSegmentLabel")),
81 theCSCRecHitLabel(par.getParameter<
InputTag>(
"CSCRecSegmentLabel")),
82 theGEMRecHitLabel(par.getParameter<
InputTag>(
"GEMRecHitLabel")),
83 theME0RecHitLabel(par.getParameter<
InputTag>(
"ME0RecHitLabel")),
96 string refitDirectionName = par.
getParameter<
string>(
"RefitDirection");
102 <<
"Wrong refit direction chosen in TrackTransformer ParameterSet" 104 <<
"Possible choices are:" 106 <<
"RefitDirection = insideOut or RefitDirection = outsideIn";
128 if (par.
existsAs<
double>(
"RescaleErrorFactor")) {
194 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
203 if ((*hit)->isValid()) {
205 allRecHitsTemp.push_back((**hit).cloneForFit(*tkbuilder->geometry()->idToDet( (**hit).geographicalId() ) ) );
206 else if ((*hit)->geographicalId().det() ==
DetId::Muon) {
207 if ((*hit)->geographicalId().subdetId() == 3 && !
theRPCInTheFit) {
214 vector<Trajectory> refitted =
refit(globalTrack,
track,allRecHitsTemp,theMuonHitsOption, tTopo);
233 vector<int> stationHits(4,0);
234 map<DetId, int> hitMap;
241 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
249 vector <Trajectory> outputTraj;
251 if ((theMuonHitsOption == 1) || (theMuonHitsOption == 3) || (theMuonHitsOption == 4) ) {
253 vector <Trajectory> globalTraj =
transform(globalTrack, track, allRecHits);
255 if (globalTraj.empty()) {
257 return vector<Trajectory>();
261 << globalTraj.front().lastMeasurement().updatedState().freeState()->parameters() << endl;
263 if (theMuonHitsOption == 1 )
264 outputTraj.push_back(globalTraj.front());
266 if (theMuonHitsOption == 3 ) {
270 outputTraj =
transform(globalTrack, track, selectedRecHits);
273 if (theMuonHitsOption == 4 ) {
289 DYTRecHits = dytRefit.
filter(globalTraj.front());
291 if ((DYTRecHits.size() > 1) && (DYTRecHits.front()->globalPosition().mag() > DYTRecHits.back()->globalPosition().mag()))
293 outputTraj =
transform(globalTrack, track, DYTRecHits);
296 }
else if (theMuonHitsOption == 2 ) {
298 outputTraj =
transform(globalTrack, track, fmsRecHits);
302 if (!outputTraj.empty()) {
303 LogTrace(
theCategory) <<
"Refitted pt: " << outputTraj.front().firstMeasurement().updatedState().globalParameters().momentum().perp() << endl;
307 return vector<Trajectory>();
318 map<DetId, int> &hitMap)
const {
325 for (ConstRecHitContainer::const_iterator imrh = all.begin(); imrh != all.end(); imrh++ ) {
327 if ( (*imrh !=
nullptr ) && !(*imrh)->isValid() )
continue;
332 DetId id = (*imrh)->geographicalId();
342 if ((*imrh)->dimension()>1) {
343 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
344 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
345 if ((*hit2d)->dimension()>1) {
346 std::vector <const TrackingRecHit*> hits1d = (*hit2d)->recHits();
347 for (std::vector <const TrackingRecHit*>::const_iterator hit1d = hits1d.begin(); hit1d!= hits1d.end(); hit1d++) {
348 DetId id1 = (*hit1d)->geographicalId();
354 double rhitDistance = fabs(ir->localPosition().x()-(**hit1d).localPosition().x());
355 if ( rhitDistance < coneSize ) layerHits++;
357 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits <<
" SL: " << lid.superLayer() << endl;
359 if (layerHits>detRecHits) detRecHits=layerHits;
366 double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
367 if ( rhitDistance < coneSize ) detRecHits++;
369 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
381 double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
382 if ( rhitDistance < coneSize ) detRecHits++;
384 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
392 if ((*imrh)->recHits().size()>1) {
393 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
394 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
395 DetId id1 = (*hit2d)->geographicalId();
403 double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).
mag();
404 if ( rhitDistance < coneSize ) layerHits++;
406 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits << endl;
408 if (layerHits>detRecHits) detRecHits=layerHits;
415 double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).
mag();
416 if ( rhitDistance < coneSize ) detRecHits++;
418 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
426 if ((*imrh)->recHits().size()>1) {
427 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
428 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
429 DetId id1 = (*hit2d)->geographicalId();
437 double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).
mag();
438 if ( rhitDistance < coneSize ) layerHits++;
440 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits << endl;
442 if (layerHits>detRecHits) detRecHits=layerHits;
449 double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).
mag();
450 if ( rhitDistance < coneSize ) detRecHits++;
452 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
460 if ((*imrh)->recHits().size()>1) {
461 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
462 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
463 DetId id1 = (*hit2d)->geographicalId();
471 double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).
mag();
472 if ( rhitDistance < coneSize ) layerHits++;
474 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits << endl;
476 if (layerHits>detRecHits) detRecHits=layerHits;
483 double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).
mag();
484 if ( rhitDistance < coneSize ) detRecHits++;
486 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
495 map<DetId,int>::iterator imap=hitMap.find(chamberId);
496 if (imap!=hitMap.end()) {
497 if (detRecHits>imap->second) imap->second=detRecHits;
498 }
else hitMap[chamberId]=detRecHits;
502 for (map<DetId,int>::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ )
503 LogTrace(
theCategory) <<
" Station " << imap->first.rawId() <<
": " << imap->second <<endl;
508 if ( (all.size() > 1) &&
509 ( all.front()->globalPosition().mag() >
510 all.back()->globalPosition().mag() ) ) {
524 LogTrace(
theCategory) <<
" GlobalMuonRefitter::getFirstHits\nall rechits length:" << all.size() << endl;
527 int station_to_keep = 999;
528 vector<int> stations;
529 for (ConstRecHitContainer::const_iterator ihit = all.begin(); ihit != all.end(); ++ihit) {
533 DetId id = (*ihit)->geographicalId();
534 unsigned raw_id =
id.
rawId();
535 if (!(*ihit)->isValid()) station = -1;
538 switch (
id.subdetId()) {
549 if (use_it && station > 0 && station < station_to_keep) station_to_keep =
station;
550 stations.push_back(station);
551 LogTrace(
theCategory) <<
"rawId: " << raw_id <<
" station = " << station <<
" station_to_keep is now " << station_to_keep;
554 if (station_to_keep <= 0 || station_to_keep > 4 || stations.size() != all.size())
555 LogInfo(
theCategory) <<
"failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = " 556 << station_to_keep <<
" stations.size " << stations.size() <<
" all.size " << all.size();
558 for (
unsigned i = 0;
i < stations.size(); ++
i)
559 if (stations[
i] >= 0 && stations[
i] <= station_to_keep) first.push_back(all[
i]);
571 const map<DetId, int> &hitMap)
const {
574 const double globalChi2Cut = 200.0;
576 vector<TrajectoryMeasurement> muonMeasurements = traj.
measurements();
579 for (std::vector<TrajectoryMeasurement>::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) {
581 if ( !(*im).recHit()->isValid() )
continue;
582 if ( (*im).recHit()->det()->geographicalId().det() !=
DetId::Muon ) {
584 muonRecHits.push_back((*im).recHit());
595 if ( (*immrh).isDT() ) {
602 else if ( (*immrh).isCSC() ) {
609 else if ( (*immrh).isGEM() ) {
616 else if ( (*immrh).isME0() ) {
623 else if ( (*immrh).isRPC() ) {
631 double chi2ndf = (*im).estimate()/(*im).recHit()->dimension();
634 map<DetId,int>::const_iterator imap=hitMap.find(chamberId);
635 if ( imap!=hitMap.end() )
636 if (imap->second>threshold) keep =
false;
638 if ( (keep || (chi2ndf<chi2Cut)) && (chi2ndf<globalChi2Cut) ) {
639 muonRecHits.push_back((*im).recHit());
642 <<
"Skip hit: " <<
id.rawId() <<
" chi2=" 643 << chi2ndf <<
" ( threshold: " << chi2Cut <<
") Det: " 644 << imap->second << endl;
649 reverse(muonRecHits.begin(),muonRecHits.end());
660 for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
661 if ( !(*ir)->isValid() ) {
669 <<
"r = " <<
sqrt(pos.
x() * pos.
x() + pos.
y() * pos.
y())
670 <<
" z = " << pos.
z()
671 <<
" dimension = " << (*ir)->dimension()
672 <<
" det = " << (*ir)->det()->geographicalId().det()
673 <<
" subdet = " << (*ir)->det()->subDetector()
674 <<
" raw id = " << (*ir)->det()->geographicalId().rawId();
686 if (!recHits.empty()){
687 ConstRecHitContainer::const_iterator frontHit = recHits.begin();
688 ConstRecHitContainer::const_iterator backHit = recHits.end() - 1;
689 while( !(*frontHit)->isValid() && frontHit != backHit) {frontHit++;}
690 while( !(*backHit)->isValid() && backHit != frontHit) {backHit--;}
692 double rFirst = (*frontHit)->globalPosition().mag();
693 double rLast = (*backHit) ->globalPosition().mag();
696 else if(rFirst > rLast)
return outsideIn;
716 LogTrace(
theCategory) <<
"GlobalMuonRefitter::transform: " << recHitsForReFit.size() <<
" hits:";
719 if(recHitsForReFit.size() < 2)
return vector<Trajectory>();
736 unsigned int innerId;
747 inner_is_first =
true;
754 inner_is_first =
false;
758 <<
" globalPosition is " << firstTSOS.globalPosition()
759 <<
" innerId is " << innerId;
761 if(!firstTSOS.isValid()){
763 return vector<Trajectory>();
785 PropagationDirection propDir_last = (lastTSOS .globalPosition().basicVector().dot(lastTSOS .globalMomentum().basicVector()) > 0) ?
alongMomentum : oppositeToMomentum;
786 LogTrace(
theCategory) <<
"propDir_first " << propDir_first <<
", propdir_last " << propDir_last
787 <<
" : they " << (propDir_first == propDir_last ?
"agree" :
"disagree");
790 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator it = recHitsForReFit.begin(); it != recHitsForReFit.end(); ++it) {
791 if ((*it)->globalPosition().y() > 0) ++y_count;
806 <<
"; based on geometrically-outermost TSOS, propDir is " << propDir <<
": " 807 << (propDir == propDir_ycount ?
"agrees" :
"disagrees")
808 <<
" with ycount determination";
810 if (propDir_first != propDir_last) {
812 propDir = propDir_ycount;
818 if(recHitsForReFit.front()->geographicalId() !=
DetId(innerId)){
821 <<
" to first rechit with surface pos " << recHitsForReFit.front()->det()->surface().toGlobal(
LocalPoint(0,0,0));
823 if(!firstTSOS.isValid()){
825 return vector<Trajectory>();
832 << firstTSOS.globalPosition() <<
" p=" 833 << firstTSOS.globalMomentum() <<
" = " 834 << firstTSOS.globalMomentum().mag() << endl;
837 <<
" nHits= " << seed.
nHits()
843 << recHitsForReFit.size() << endl;
847 if(trajectories.empty()){
849 return vector<Trajectory>();
862 ConstRecHitContainer::const_iterator it = hits.begin();
863 for (; it!=hits.end(); it++) {
865 DetId id = (*it)->geographicalId();
929 results.push_back(*it);
std::string theMuonRecHitBuilderName
double p() const
momentum vector magnitude
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void printHits(const ConstRecHitContainer &) const
print all RecHits of a trajectory
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle< DTRecHitCollection > theDTRecHits
void setProd(const edm::Handle< DTRecSegment4DCollection > &DTSegProd, const edm::Handle< CSCSegmentCollection > &CSCSegProd)
std::pair< const_iterator, const_iterator > range
iterator range
Point3DBase< Scalar, LocalTag > LocalPoint
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
const MuonServiceProxy * theService
unsigned int tibLayer(const DetId &id) const
RefitDirection theRefitDirection
edm::ESHandle< TransientTrackingRecHitBuilder > theTrackerRecHitBuilder
edm::Handle< CSCSegmentCollection > CSCSegments
ME0DetId chamberId() const
Return the corresponding ChamberId (mask layers)
std::string thePropagatorName
LocalPoint position() const
Local x and y position coordinates.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
unsigned int pxfDisk(const DetId &id) const
std::string theFitterName
constexpr uint32_t rawId() const
get the raw id
edm::Handle< GEMRecHitCollection > theGEMRecHits
def setup(process, global_tag, zero_tesla=False)
GlobalPoint globalPosition() const
void setServices(const edm::EventSetup &)
set the services needed by the TrackTransformer
unsigned int tidWheel(const DetId &id) const
void CopyFrom(const DYTInfo &)
copy from another DYTInfo
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
edm::EDGetTokenT< CSCSegmentCollection > CSCSegmentsToken
std::unique_ptr< TrajectoryFitter > theFitter
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
edm::Handle< ME0SegmentCollection > theME0RecHits
void checkMuonHits(const reco::Track &, ConstRecHitContainer &, std::map< DetId, int > &) const
check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit ...
TrajectoryStateOnSurface innermostMeasurementState() const
std::vector< int > theDYTthrs
GEMDetId chamberId() const
Return the corresponding ChamberId.
void getFirstHits(const reco::Track &, ConstRecHitContainer &, ConstRecHitContainer &) const
get the RecHits in the tracker and the first muon chamber with hits
const edm::Event * theEvent
void setRecoEta(double eta)
C::const_iterator const_iterator
constant access iterator type
DataContainer const & measurements() const
virtual std::unique_ptr< TrajectoryFitter > clone() const =0
double eta() const
pseudorapidity of momentum vector
edm::Handle< DTRecSegment4DCollection > all4DSegments
ConstRecHitContainer selectMuonHits(const Trajectory &, const std::map< DetId, int > &) const
select muon hits compatible with trajectory; check hits in chambers with showers
ConstRecHitContainer getRidOfSelectStationHits(const ConstRecHitContainer &hits, const TrackerTopology *tTopo) const
double theRescaleErrorFactor
double pt() const
track transverse momentum
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
int station() const
Station id : the station is the pair of chambers at same disk.
edm::EDGetTokenT< ME0SegmentCollection > theME0RecHitToken
CSCDetId chamberId() const
edm::ParameterSet theDYTthrsParameters
edm::Handle< CSCRecHit2DCollection > theCSCRecHits
int theTrackerSkipSection
RefitDirection checkRecHitsOrdering(const ConstRecHitContainer &) const
LocalVector momentum() const
Momentum vector in the local frame.
edm::EDGetTokenT< DTRecHitCollection > theDTRecHitToken
edm::EDGetTokenT< CSCRecHit2DCollection > theCSCRecHitToken
TrajectoryStateOnSurface outermostMeasurementState() const
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
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
edm::InputTag theDTRecHitLabel
std::vector< ConstRecHitPointer > ConstRecHitContainer
unsigned int pxbLayer(const DetId &id) const
edm::InputTag theGEMRecHitLabel
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
void setThrsMap(const edm::ParameterSet &)
void setParThrsMode(bool dytParThrsMode)
edm::InputTag theME0RecHitLabel
PTrajectoryStateOnDet const & startingState() const
GlobalMuonRefitter(const edm::ParameterSet &, const MuonServiceProxy *, edm::ConsumesCollector &)
constructor with Parameter Set and MuonServiceProxy
edm::EDGetTokenT< DTRecSegment4DCollection > all4DSegmentsToken
reco::DYTInfo getDYTInfo()
unsigned int nHits() const
GlobalVector globalMomentum() const
virtual ~GlobalMuonRefitter()
destructor
DetId geographicalId() const
unsigned long long theCacheId_TRH
int station() const
Return the station number.
std::string theTrackerRecHitBuilderName
const BasicVectorType & basicVector() const
unsigned int tecWheel(const DetId &id) const
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
T const * product() const
void setThr(const std::vector< int > &)
std::vector< Trajectory > refit(const reco::Track &globalTrack, const int theMuonHitsOption, const TrackerTopology *tTopo) const
build combined trajectory from sta Track and tracker RecHits
const LocalTrajectoryParameters & parameters() const
void setUpdateState(bool)
unsigned int tobLayer(const DetId &id) const
edm::InputTag theCSCRecHitLabel
edm::EDGetTokenT< GEMRecHitCollection > theGEMRecHitToken
std::vector< Trajectory > transform(const reco::Track &newTrack, const reco::TransientTrack track, const TransientTrackingRecHit::ConstRecHitContainer &recHitsForReFit) const
refit the track with a new set of RecHits
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.