77 theCosmicFlag(par.getParameter<bool>(
"PropDirForCosmics")),
78 theDTRecHitLabel(par.getParameter<
InputTag>(
"DTRecSegmentLabel")),
79 theCSCRecHitLabel(par.getParameter<
InputTag>(
"CSCRecSegmentLabel")),
90 string refitDirectionName = par.
getParameter<
string>(
"RefitDirection");
96 <<
"Wrong refit direction chosen in TrackTransformer ParameterSet"
98 <<
"Possible choices are:"
100 <<
"RefitDirection = insideOut or RefitDirection = outsideIn";
116 if (par.
existsAs<
double>(
"RescaleErrorFactor")) {
165 const int theMuonHitsOption)
const {
166 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
173 if ((*hit)->isValid()) {
176 else if ((*hit)->geographicalId().det() ==
DetId::Muon) {
177 if ((*hit)->geographicalId().subdetId() == 3 && !
theRPCInTheFit) {
184 vector<Trajectory> refitted =
refit(globalTrack,track,allRecHitsTemp,theMuonHitsOption);
194 const int theMuonHitsOption)
const {
202 vector<int> stationHits(4,0);
203 map<DetId, int> hitMap;
210 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
218 vector <Trajectory> outputTraj;
220 if ((theMuonHitsOption == 1) || (theMuonHitsOption == 3) || (theMuonHitsOption == 4) ) {
222 vector <Trajectory> globalTraj =
transform(globalTrack, track, allRecHits);
224 if (!globalTraj.size()) {
226 return vector<Trajectory>();
230 << globalTraj.front().lastMeasurement().updatedState().freeState()->parameters() << endl;
232 if (theMuonHitsOption == 1 )
233 outputTraj.push_back(globalTraj.front());
235 if (theMuonHitsOption == 3 ) {
239 outputTraj =
transform(globalTrack, track, selectedRecHits);
242 if (theMuonHitsOption == 4 ) {
247 DYTRecHits = dytRefit.
filter(globalTraj.front());
249 if ((DYTRecHits.size() > 1) && (DYTRecHits.front()->globalPosition().mag() > DYTRecHits.back()->globalPosition().mag()))
251 outputTraj =
transform(globalTrack, track, DYTRecHits);
254 }
else if (theMuonHitsOption == 2 ) {
256 outputTraj =
transform(globalTrack, track, fmsRecHits);
260 if (outputTraj.size()) {
261 LogTrace(
theCategory) <<
"Refitted pt: " << outputTraj.front().firstMeasurement().updatedState().globalParameters().momentum().perp() << endl;
265 return vector<Trajectory>();
276 map<DetId, int> &hitMap)
const {
280 float coneSize = 20.0;
283 for (ConstRecHitContainer::const_iterator imrh = all.begin(); imrh != all.end(); imrh++ ) {
285 if ( (*imrh != 0 ) && !(*imrh)->isValid() )
continue;
290 DetId id = (*imrh)->geographicalId();
300 if ((*imrh)->recHits().size()>1) {
301 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
302 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
303 if ((*imrh)->recHits().size()>1) {
304 std::vector <const TrackingRecHit*> hits1d = (*hit2d)->recHits();
305 for (std::vector <const TrackingRecHit*>::const_iterator hit1d = hits1d.begin(); hit1d!= hits1d.end(); hit1d++) {
306 DetId id1 = (*hit1d)->geographicalId();
312 double rhitDistance = fabs(ir->localPosition().x()-(**hit1d).localPosition().x());
313 if ( rhitDistance < coneSize ) layerHits++;
315 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits <<
" SL: " << lid.superLayer() << endl;
317 if (layerHits>detRecHits) detRecHits=layerHits;
329 double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
330 if ( rhitDistance < coneSize ) detRecHits++;
332 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
340 if ((*imrh)->recHits().size()>1) {
341 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
342 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
343 DetId id1 = (*hit2d)->geographicalId();
351 double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).
mag();
352 if ( rhitDistance < coneSize ) layerHits++;
354 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits << endl;
356 if (layerHits>detRecHits) detRecHits=layerHits;
363 double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).
mag();
364 if ( rhitDistance < coneSize ) detRecHits++;
366 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
375 map<DetId,int>::iterator imap=hitMap.find(chamberId);
376 if (imap!=hitMap.end()) {
377 if (detRecHits>imap->second) imap->second=detRecHits;
378 }
else hitMap[chamberId]=detRecHits;
382 for (map<DetId,int>::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ )
383 LogTrace(
theCategory) <<
" Station " << imap->first.rawId() <<
": " << imap->second <<endl;
388 if ( (all.size() > 1) &&
389 ( all.front()->globalPosition().mag() >
390 all.back()->globalPosition().mag() ) ) {
404 LogTrace(
theCategory) <<
" GlobalMuonRefitter::getFirstHits\nall rechits length:" << all.size() << endl;
407 int station_to_keep = 999;
409 for (ConstRecHitContainer::const_iterator ihit = all.begin(); ihit != all.end(); ++ihit) {
413 DetId id = (*ihit)->geographicalId();
414 unsigned raw_id =
id.
rawId();
415 if (!(*ihit)->isValid()) station = -1;
418 switch (
id.subdetId()) {
426 if (use_it && station > 0 && station < station_to_keep) station_to_keep =
station;
427 stations.push_back(station);
429 LogTrace(
theCategory) <<
"rawId: " << raw_id <<
" station = " << station <<
" station_to_keep is now " << station_to_keep;
432 if (station_to_keep <= 0 || station_to_keep > 4 || stations.size() != all.size())
433 LogInfo(
theCategory) <<
"failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = "
434 << station_to_keep <<
" stations.size " << stations.size() <<
" all.size " << all.size();
436 for (
unsigned i = 0;
i < stations.size(); ++
i)
437 if (stations[
i] >= 0 && stations[
i] <= station_to_keep) first.push_back(all[
i]);
449 const map<DetId, int> &hitMap)
const {
452 const double globalChi2Cut = 200.0;
454 vector<TrajectoryMeasurement> muonMeasurements = traj.
measurements();
457 for (std::vector<TrajectoryMeasurement>::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) {
459 if ( !(*im).recHit()->isValid() )
continue;
460 if ( (*im).recHit()->det()->geographicalId().det() !=
DetId::Muon ) {
462 muonRecHits.push_back((*im).recHit());
467 DetId id = immrh->geographicalId();
470 double chi2Cut = 0.0;
473 if ( (*immrh).isDT() ) {
480 else if ( (*immrh).isCSC() ) {
487 else if ( (*immrh).isRPC() ) {
495 double chi2ndf = (*im).estimate()/(*im).recHit()->dimension();
498 map<DetId,int>::const_iterator imap=hitMap.find(chamberId);
499 if ( imap!=hitMap.end() )
500 if (imap->second>threshold) keep =
false;
502 if ( (keep || (chi2ndf<chi2Cut)) && (chi2ndf<globalChi2Cut) ) {
503 muonRecHits.push_back((*im).recHit());
506 <<
"Skip hit: " <<
id.rawId() <<
" chi2="
507 << chi2ndf <<
" ( threshold: " << chi2Cut <<
") Det: "
508 << imap->second << endl;
513 reverse(muonRecHits.begin(),muonRecHits.end());
524 for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
525 if ( !(*ir)->isValid() ) {
533 <<
"r = " <<
sqrt(pos.
x() * pos.
x() + pos.
y() * pos.
y())
534 <<
" z = " << pos.
z()
535 <<
" dimension = " << (*ir)->dimension()
536 <<
" det = " << (*ir)->det()->geographicalId().det()
537 <<
" subdet = " << (*ir)->det()->subDetector()
538 <<
" raw id = " << (*ir)->det()->geographicalId().rawId();
550 if (!recHits.empty()){
551 ConstRecHitContainer::const_iterator frontHit = recHits.begin();
552 ConstRecHitContainer::const_iterator backHit = recHits.end() - 1;
553 while( !(*frontHit)->isValid() && frontHit != backHit) {frontHit++;}
554 while( !(*backHit)->isValid() && backHit != frontHit) {backHit--;}
556 double rFirst = (*frontHit)->globalPosition().mag();
557 double rLast = (*backHit) ->globalPosition().mag();
560 else if(rFirst > rLast)
return outsideIn;
579 LogTrace(
theCategory) <<
"GlobalMuonRefitter::transform: " << recHitsForReFit.size() <<
" hits:";
582 if(recHitsForReFit.size() < 2)
return vector<Trajectory>();
592 if(
theRefitDirection != recHitsOrder) reverse(recHitsForReFit.begin(),recHitsForReFit.end());
599 unsigned int innerId;
610 inner_is_first =
true;
617 inner_is_first =
false;
621 <<
" globalPosition is " << firstTSOS.globalPosition()
622 <<
" innerId is " << innerId;
624 if(!firstTSOS.isValid()){
626 return vector<Trajectory>();
650 PropagationDirection propDir_last = (lastTSOS .globalPosition().basicVector().dot(lastTSOS .globalMomentum().basicVector()) > 0) ?
alongMomentum : oppositeToMomentum;
651 LogTrace(
theCategory) <<
"propDir_first " << propDir_first <<
", propdir_last " << propDir_last
652 <<
" : they " << (propDir_first == propDir_last ?
"agree" :
"disagree");
655 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator it = recHitsForReFit.begin(); it != recHitsForReFit.end(); ++it) {
656 if ((*it)->globalPosition().y() > 0) ++y_count;
671 <<
"; based on geometrically-outermost TSOS, propDir is " << propDir <<
": "
672 << (propDir == propDir_ycount ?
"agrees" :
"disagrees")
673 <<
" with ycount determination";
675 if (propDir_first != propDir_last) {
677 propDir = propDir_ycount;
683 if(recHitsForReFit.front()->geographicalId() !=
DetId(innerId)){
686 <<
" to first rechit with surface pos " << recHitsForReFit.front()->det()->surface().toGlobal(
LocalPoint(0,0,0));
688 if(!firstTSOS.isValid()){
690 return vector<Trajectory>();
711 vector<Trajectory> trajectories =
theFitter->fit(seed,recHitsForReFit,firstTSOS);
713 if(trajectories.empty()){
715 return vector<Trajectory>();
728 ConstRecHitContainer::const_iterator it = hits.begin();
729 for (; it!=hits.end(); it++) {
731 DetId id = (*it)->geographicalId();
789 results.push_back(*it);
std::string theMuonRecHitBuilderName
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
std::pair< const_iterator, const_iterator > range
iterator range
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
const MuonServiceProxy * theService
unsigned int layer() const
layer id
RefitDirection theRefitDirection
edm::ESHandle< TransientTrackingRecHitBuilder > theTrackerRecHitBuilder
std::string thePropagatorName
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
std::vector< Trajectory > transform(const reco::Track &newTrack, const reco::TransientTrack track, TransientTrackingRecHit::ConstRecHitContainer recHitsForReFit) const
refit the track with a new set of RecHits
std::string theFitterName
GlobalPoint globalPosition() const
void setServices(const edm::EventSetup &)
set the services needed by the TrackTransformer
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
ConstRecHitContainer getRidOfSelectStationHits(ConstRecHitContainer hits) const
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
unsigned int layer() const
layer id
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
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
C::const_iterator const_iterator
constant access iterator type
DataContainer const & measurements() const
edm::ESHandle< TrajectoryFitter > theFitter
ConstRecHitContainer selectMuonHits(const Trajectory &, const std::map< DetId, int > &) const
select muon hits compatible with trajectory; check hits in chambers with showers
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.
CSCDetId chamberId() const
edm::Handle< CSCRecHit2DCollection > theCSCRecHits
int theTrackerSkipSection
RefitDirection checkRecHitsOrdering(const ConstRecHitContainer &) const
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
unsigned int disk() const
disk id
edm::InputTag theDTRecHitLabel
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
GlobalMuonRefitter(const edm::ParameterSet &, const MuonServiceProxy *)
constructor with Parameter Set and MuonServiceProxy
unsigned int wheel() const
wheel id
std::vector< Trajectory > refit(const reco::Track &globalTrack, const int theMuonHitsOption) const
build combined trajectory from sta Track and tracker RecHits
unsigned int layer() const
layer id
GlobalVector globalMomentum() const
virtual ~GlobalMuonRefitter()
destructor
unsigned long long theCacheId_TRH
int station() const
Return the station number.
std::string theTrackerRecHitBuilderName
const BasicVectorType & basicVector() const
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
edm::InputTag theCSCRecHitLabel
unsigned int wheel() const
wheel id
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.