78 theCosmicFlag(par.getParameter<
bool>(
"PropDirForCosmics")),
79 theDTRecHitLabel(par.getParameter<
InputTag>(
"DTRecSegmentLabel")),
80 theCSCRecHitLabel(par.getParameter<
InputTag>(
"CSCRecSegmentLabel")),
81 theGEMRecHitLabel(par.getParameter<
InputTag>(
"GEMRecHitLabel")),
82 theME0RecHitLabel(par.getParameter<
InputTag>(
"ME0RecHitLabel")),
95 string refitDirectionName = par.
getParameter<
string>(
"RefitDirection");
101 <<
"Wrong refit direction chosen in TrackTransformer ParameterSet" 103 <<
"Possible choices are:" 105 <<
"RefitDirection = insideOut or RefitDirection = outsideIn";
125 if (par.
existsAs<
double>(
"RescaleErrorFactor")) {
191 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
200 if ((*hit)->isValid()) {
202 allRecHitsTemp.push_back((**hit).cloneForFit(*tkbuilder->geometry()->idToDet( (**hit).geographicalId() ) ) );
203 else if ((*hit)->geographicalId().det() ==
DetId::Muon) {
204 if ((*hit)->geographicalId().subdetId() == 3 && !
theRPCInTheFit) {
211 vector<Trajectory> refitted =
refit(globalTrack,
track,allRecHitsTemp,theMuonHitsOption, tTopo);
230 vector<int> stationHits(4,0);
231 map<DetId, int> hitMap;
238 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
246 vector <Trajectory> outputTraj;
248 if ((theMuonHitsOption == 1) || (theMuonHitsOption == 3) || (theMuonHitsOption == 4) ) {
250 vector <Trajectory> globalTraj =
transform(globalTrack, track, allRecHits);
252 if (globalTraj.empty()) {
254 return vector<Trajectory>();
258 << globalTraj.front().lastMeasurement().updatedState().freeState()->parameters() << endl;
260 if (theMuonHitsOption == 1 )
261 outputTraj.push_back(globalTraj.front());
263 if (theMuonHitsOption == 3 ) {
267 outputTraj =
transform(globalTrack, track, selectedRecHits);
270 if (theMuonHitsOption == 4 ) {
280 DYTRecHits = dytRefit.
filter(globalTraj.front());
282 if ((DYTRecHits.size() > 1) && (DYTRecHits.front()->globalPosition().mag() > DYTRecHits.back()->globalPosition().mag()))
284 outputTraj =
transform(globalTrack, track, DYTRecHits);
287 }
else if (theMuonHitsOption == 2 ) {
289 outputTraj =
transform(globalTrack, track, fmsRecHits);
293 if (!outputTraj.empty()) {
294 LogTrace(
theCategory) <<
"Refitted pt: " << outputTraj.front().firstMeasurement().updatedState().globalParameters().momentum().perp() << endl;
298 return vector<Trajectory>();
309 map<DetId, int> &hitMap)
const {
316 for (ConstRecHitContainer::const_iterator imrh = all.begin(); imrh != all.end(); imrh++ ) {
318 if ( (*imrh !=
nullptr ) && !(*imrh)->isValid() )
continue;
323 DetId id = (*imrh)->geographicalId();
333 if ((*imrh)->dimension()>1) {
334 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
335 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
336 if ((*hit2d)->dimension()>1) {
337 std::vector <const TrackingRecHit*> hits1d = (*hit2d)->recHits();
338 for (std::vector <const TrackingRecHit*>::const_iterator hit1d = hits1d.begin(); hit1d!= hits1d.end(); hit1d++) {
339 DetId id1 = (*hit1d)->geographicalId();
345 double rhitDistance = fabs(ir->localPosition().x()-(**hit1d).localPosition().x());
346 if ( rhitDistance < coneSize ) layerHits++;
348 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits <<
" SL: " << lid.superLayer() << endl;
350 if (layerHits>detRecHits) detRecHits=layerHits;
357 double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
358 if ( rhitDistance < coneSize ) detRecHits++;
360 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
372 double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
373 if ( rhitDistance < coneSize ) detRecHits++;
375 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
383 if ((*imrh)->recHits().size()>1) {
384 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
385 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
386 DetId id1 = (*hit2d)->geographicalId();
394 double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).
mag();
395 if ( rhitDistance < coneSize ) layerHits++;
397 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits << endl;
399 if (layerHits>detRecHits) detRecHits=layerHits;
406 double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).
mag();
407 if ( rhitDistance < coneSize ) detRecHits++;
409 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
417 if ((*imrh)->recHits().size()>1) {
418 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
419 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
420 DetId id1 = (*hit2d)->geographicalId();
428 double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).
mag();
429 if ( rhitDistance < coneSize ) layerHits++;
431 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits << endl;
433 if (layerHits>detRecHits) detRecHits=layerHits;
440 double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).
mag();
441 if ( rhitDistance < coneSize ) detRecHits++;
443 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
451 if ((*imrh)->recHits().size()>1) {
452 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
453 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
454 DetId id1 = (*hit2d)->geographicalId();
462 double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).
mag();
463 if ( rhitDistance < coneSize ) layerHits++;
465 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits << endl;
467 if (layerHits>detRecHits) detRecHits=layerHits;
474 double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).
mag();
475 if ( rhitDistance < coneSize ) detRecHits++;
477 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
486 map<DetId,int>::iterator imap=hitMap.find(chamberId);
487 if (imap!=hitMap.end()) {
488 if (detRecHits>imap->second) imap->second=detRecHits;
489 }
else hitMap[chamberId]=detRecHits;
493 for (map<DetId,int>::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ )
494 LogTrace(
theCategory) <<
" Station " << imap->first.rawId() <<
": " << imap->second <<endl;
499 if ( (all.size() > 1) &&
500 ( all.front()->globalPosition().mag() >
501 all.back()->globalPosition().mag() ) ) {
515 LogTrace(
theCategory) <<
" GlobalMuonRefitter::getFirstHits\nall rechits length:" << all.size() << endl;
518 int station_to_keep = 999;
519 vector<int> stations;
520 for (ConstRecHitContainer::const_iterator ihit = all.begin(); ihit != all.end(); ++ihit) {
524 DetId id = (*ihit)->geographicalId();
525 unsigned raw_id =
id.
rawId();
526 if (!(*ihit)->isValid()) station = -1;
529 switch (
id.subdetId()) {
540 if (use_it && station > 0 && station < station_to_keep) station_to_keep =
station;
541 stations.push_back(station);
542 LogTrace(
theCategory) <<
"rawId: " << raw_id <<
" station = " << station <<
" station_to_keep is now " << station_to_keep;
545 if (station_to_keep <= 0 || station_to_keep > 4 || stations.size() != all.size())
546 LogInfo(
theCategory) <<
"failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = " 547 << station_to_keep <<
" stations.size " << stations.size() <<
" all.size " << all.size();
549 for (
unsigned i = 0;
i < stations.size(); ++
i)
550 if (stations[
i] >= 0 && stations[
i] <= station_to_keep) first.push_back(all[
i]);
562 const map<DetId, int> &hitMap)
const {
565 const double globalChi2Cut = 200.0;
567 vector<TrajectoryMeasurement> muonMeasurements = traj.
measurements();
570 for (std::vector<TrajectoryMeasurement>::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) {
572 if ( !(*im).recHit()->isValid() )
continue;
573 if ( (*im).recHit()->det()->geographicalId().det() !=
DetId::Muon ) {
575 muonRecHits.push_back((*im).recHit());
586 if ( (*immrh).isDT() ) {
593 else if ( (*immrh).isCSC() ) {
600 else if ( (*immrh).isGEM() ) {
607 else if ( (*immrh).isME0() ) {
614 else if ( (*immrh).isRPC() ) {
622 double chi2ndf = (*im).estimate()/(*im).recHit()->dimension();
625 map<DetId,int>::const_iterator imap=hitMap.find(chamberId);
626 if ( imap!=hitMap.end() )
627 if (imap->second>threshold) keep =
false;
629 if ( (keep || (chi2ndf<chi2Cut)) && (chi2ndf<globalChi2Cut) ) {
630 muonRecHits.push_back((*im).recHit());
633 <<
"Skip hit: " <<
id.rawId() <<
" chi2=" 634 << chi2ndf <<
" ( threshold: " << chi2Cut <<
") Det: " 635 << imap->second << endl;
640 reverse(muonRecHits.begin(),muonRecHits.end());
651 for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
652 if ( !(*ir)->isValid() ) {
660 <<
"r = " <<
sqrt(pos.
x() * pos.
x() + pos.
y() * pos.
y())
661 <<
" z = " << pos.
z()
662 <<
" dimension = " << (*ir)->dimension()
663 <<
" det = " << (*ir)->det()->geographicalId().det()
664 <<
" subdet = " << (*ir)->det()->subDetector()
665 <<
" raw id = " << (*ir)->det()->geographicalId().rawId();
677 if (!recHits.empty()){
678 ConstRecHitContainer::const_iterator frontHit = recHits.begin();
679 ConstRecHitContainer::const_iterator backHit = recHits.end() - 1;
680 while( !(*frontHit)->isValid() && frontHit != backHit) {frontHit++;}
681 while( !(*backHit)->isValid() && backHit != frontHit) {backHit--;}
683 double rFirst = (*frontHit)->globalPosition().mag();
684 double rLast = (*backHit) ->globalPosition().mag();
687 else if(rFirst > rLast)
return outsideIn;
707 LogTrace(
theCategory) <<
"GlobalMuonRefitter::transform: " << recHitsForReFit.size() <<
" hits:";
710 if(recHitsForReFit.size() < 2)
return vector<Trajectory>();
727 unsigned int innerId;
738 inner_is_first =
true;
745 inner_is_first =
false;
749 <<
" globalPosition is " << firstTSOS.globalPosition()
750 <<
" innerId is " << innerId;
752 if(!firstTSOS.isValid()){
754 return vector<Trajectory>();
776 PropagationDirection propDir_last = (lastTSOS .globalPosition().basicVector().dot(lastTSOS .globalMomentum().basicVector()) > 0) ?
alongMomentum : oppositeToMomentum;
777 LogTrace(
theCategory) <<
"propDir_first " << propDir_first <<
", propdir_last " << propDir_last
778 <<
" : they " << (propDir_first == propDir_last ?
"agree" :
"disagree");
781 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator it = recHitsForReFit.begin(); it != recHitsForReFit.end(); ++it) {
782 if ((*it)->globalPosition().y() > 0) ++y_count;
797 <<
"; based on geometrically-outermost TSOS, propDir is " << propDir <<
": " 798 << (propDir == propDir_ycount ?
"agrees" :
"disagrees")
799 <<
" with ycount determination";
801 if (propDir_first != propDir_last) {
803 propDir = propDir_ycount;
809 if(recHitsForReFit.front()->geographicalId() !=
DetId(innerId)){
812 <<
" to first rechit with surface pos " << recHitsForReFit.front()->det()->surface().toGlobal(
LocalPoint(0,0,0));
814 if(!firstTSOS.isValid()){
816 return vector<Trajectory>();
839 if(trajectories.empty()){
841 return vector<Trajectory>();
854 ConstRecHitContainer::const_iterator it = hits.begin();
855 for (; it!=hits.end(); it++) {
857 DetId id = (*it)->geographicalId();
921 results.push_back(*it);
std::string theMuonRecHitBuilderName
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
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
unsigned int pxfDisk(const DetId &id) const
std::string theFitterName
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
uint32_t rawId() const
get the raw id
DataContainer const & measurements() const
virtual std::unique_ptr< TrajectoryFitter > clone() const =0
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::Handle< CSCRecHit2DCollection > theCSCRecHits
int theTrackerSkipSection
RefitDirection checkRecHitsOrdering(const ConstRecHitContainer &) const
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
edm::InputTag theME0RecHitLabel
GlobalMuonRefitter(const edm::ParameterSet &, const MuonServiceProxy *, edm::ConsumesCollector &)
constructor with Parameter Set and MuonServiceProxy
edm::EDGetTokenT< DTRecSegment4DCollection > all4DSegmentsToken
reco::DYTInfo getDYTInfo()
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
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.