71 theCosmicFlag(par.getParameter<bool>(
"PropDirForCosmics")),
72 theDTRecHitLabel(par.getParameter<
InputTag>(
"DTRecSegmentLabel")),
73 theCSCRecHitLabel(par.getParameter<
InputTag>(
"CSCRecSegmentLabel")),
84 string refitDirectionName = par.
getParameter<
string>(
"RefitDirection");
90 <<
"Wrong refit direction chosen in TrackTransformer ParameterSet"
92 <<
"Possible choices are:"
94 <<
"RefitDirection = insideOut or RefitDirection = outsideIn";
110 if (par.
existsAs<
double>(
"RescaleErrorFactor")) {
159 const int theMuonHitsOption,
161 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
168 if ((*hit)->isValid()) {
171 else if ((*hit)->geographicalId().det() ==
DetId::Muon) {
172 if ((*hit)->geographicalId().subdetId() == 3 && !
theRPCInTheFit) {
179 vector<Trajectory> refitted =
refit(globalTrack,track,allRecHitsTemp,theMuonHitsOption, tTopo);
189 const int theMuonHitsOption,
198 vector<int> stationHits(4,0);
199 map<DetId, int> hitMap;
206 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
214 vector <Trajectory> outputTraj;
216 if ((theMuonHitsOption == 1) || (theMuonHitsOption == 3) || (theMuonHitsOption == 4) ) {
218 vector <Trajectory> globalTraj =
transform(globalTrack, track, allRecHits);
220 if (!globalTraj.size()) {
222 return vector<Trajectory>();
226 << globalTraj.front().lastMeasurement().updatedState().freeState()->parameters() << endl;
228 if (theMuonHitsOption == 1 )
229 outputTraj.push_back(globalTraj.front());
231 if (theMuonHitsOption == 3 ) {
235 outputTraj =
transform(globalTrack, track, selectedRecHits);
238 if (theMuonHitsOption == 4 ) {
243 DYTRecHits = dytRefit.
filter(globalTraj.front());
245 if ((DYTRecHits.size() > 1) && (DYTRecHits.front()->globalPosition().mag() > DYTRecHits.back()->globalPosition().mag()))
247 outputTraj =
transform(globalTrack, track, DYTRecHits);
250 }
else if (theMuonHitsOption == 2 ) {
252 outputTraj =
transform(globalTrack, track, fmsRecHits);
256 if (outputTraj.size()) {
257 LogTrace(
theCategory) <<
"Refitted pt: " << outputTraj.front().firstMeasurement().updatedState().globalParameters().momentum().perp() << endl;
261 return vector<Trajectory>();
272 map<DetId, int> &hitMap)
const {
276 float coneSize = 20.0;
279 for (ConstRecHitContainer::const_iterator imrh = all.begin(); imrh != all.end(); imrh++ ) {
281 if ( (*imrh != 0 ) && !(*imrh)->isValid() )
continue;
286 DetId id = (*imrh)->geographicalId();
296 if ((*imrh)->recHits().size()>1) {
297 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
298 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
299 if ((*imrh)->recHits().size()>1) {
300 std::vector <const TrackingRecHit*> hits1d = (*hit2d)->recHits();
301 for (std::vector <const TrackingRecHit*>::const_iterator hit1d = hits1d.begin(); hit1d!= hits1d.end(); hit1d++) {
302 DetId id1 = (*hit1d)->geographicalId();
308 double rhitDistance = fabs(ir->localPosition().x()-(**hit1d).localPosition().x());
309 if ( rhitDistance < coneSize ) layerHits++;
311 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits <<
" SL: " << lid.superLayer() << endl;
313 if (layerHits>detRecHits) detRecHits=layerHits;
325 double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
326 if ( rhitDistance < coneSize ) detRecHits++;
328 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
336 if ((*imrh)->recHits().size()>1) {
337 std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
338 for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
339 DetId id1 = (*hit2d)->geographicalId();
347 double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).
mag();
348 if ( rhitDistance < coneSize ) layerHits++;
350 <<
" Distance: " << rhitDistance <<
" recHits: " << layerHits << endl;
352 if (layerHits>detRecHits) detRecHits=layerHits;
359 double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).
mag();
360 if ( rhitDistance < coneSize ) detRecHits++;
362 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
371 map<DetId,int>::iterator imap=hitMap.find(chamberId);
372 if (imap!=hitMap.end()) {
373 if (detRecHits>imap->second) imap->second=detRecHits;
374 }
else hitMap[chamberId]=detRecHits;
378 for (map<DetId,int>::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ )
379 LogTrace(
theCategory) <<
" Station " << imap->first.rawId() <<
": " << imap->second <<endl;
384 if ( (all.size() > 1) &&
385 ( all.front()->globalPosition().mag() >
386 all.back()->globalPosition().mag() ) ) {
400 LogTrace(
theCategory) <<
" GlobalMuonRefitter::getFirstHits\nall rechits length:" << all.size() << endl;
403 int station_to_keep = 999;
405 for (ConstRecHitContainer::const_iterator ihit = all.begin(); ihit != all.end(); ++ihit) {
409 DetId id = (*ihit)->geographicalId();
410 unsigned raw_id =
id.
rawId();
411 if (!(*ihit)->isValid()) station = -1;
414 switch (
id.subdetId()) {
422 if (use_it && station > 0 && station < station_to_keep) station_to_keep =
station;
423 stations.push_back(station);
425 LogTrace(
theCategory) <<
"rawId: " << raw_id <<
" station = " << station <<
" station_to_keep is now " << station_to_keep;
428 if (station_to_keep <= 0 || station_to_keep > 4 || stations.size() != all.size())
429 LogInfo(
theCategory) <<
"failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = "
430 << station_to_keep <<
" stations.size " << stations.size() <<
" all.size " << all.size();
432 for (
unsigned i = 0;
i < stations.size(); ++
i)
433 if (stations[
i] >= 0 && stations[
i] <= station_to_keep) first.push_back(all[
i]);
445 const map<DetId, int> &hitMap)
const {
448 const double globalChi2Cut = 200.0;
450 vector<TrajectoryMeasurement> muonMeasurements = traj.
measurements();
453 for (std::vector<TrajectoryMeasurement>::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) {
455 if ( !(*im).recHit()->isValid() )
continue;
456 if ( (*im).recHit()->det()->geographicalId().det() !=
DetId::Muon ) {
458 muonRecHits.push_back((*im).recHit());
463 DetId id = immrh->geographicalId();
466 double chi2Cut = 0.0;
469 if ( (*immrh).isDT() ) {
476 else if ( (*immrh).isCSC() ) {
483 else if ( (*immrh).isRPC() ) {
491 double chi2ndf = (*im).estimate()/(*im).recHit()->dimension();
494 map<DetId,int>::const_iterator imap=hitMap.find(chamberId);
495 if ( imap!=hitMap.end() )
496 if (imap->second>threshold) keep =
false;
498 if ( (keep || (chi2ndf<chi2Cut)) && (chi2ndf<globalChi2Cut) ) {
499 muonRecHits.push_back((*im).recHit());
502 <<
"Skip hit: " <<
id.rawId() <<
" chi2="
503 << chi2ndf <<
" ( threshold: " << chi2Cut <<
") Det: "
504 << imap->second << endl;
509 reverse(muonRecHits.begin(),muonRecHits.end());
520 for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
521 if ( !(*ir)->isValid() ) {
529 <<
"r = " <<
sqrt(pos.
x() * pos.
x() + pos.
y() * pos.
y())
530 <<
" z = " << pos.
z()
531 <<
" dimension = " << (*ir)->dimension()
532 <<
" det = " << (*ir)->det()->geographicalId().det()
533 <<
" subdet = " << (*ir)->det()->subDetector()
534 <<
" raw id = " << (*ir)->det()->geographicalId().rawId();
546 if (!recHits.empty()){
547 ConstRecHitContainer::const_iterator frontHit = recHits.begin();
548 ConstRecHitContainer::const_iterator backHit = recHits.end() - 1;
549 while( !(*frontHit)->isValid() && frontHit != backHit) {frontHit++;}
550 while( !(*backHit)->isValid() && backHit != frontHit) {backHit--;}
552 double rFirst = (*frontHit)->globalPosition().mag();
553 double rLast = (*backHit) ->globalPosition().mag();
556 else if(rFirst > rLast)
return outsideIn;
576 LogTrace(
theCategory) <<
"GlobalMuonRefitter::transform: " << recHitsForReFit.size() <<
" hits:";
579 if(recHitsForReFit.size() < 2)
return vector<Trajectory>();
589 if(
theRefitDirection != recHitsOrder) reverse(recHitsForReFit.begin(),recHitsForReFit.end());
596 unsigned int innerId;
607 inner_is_first =
true;
614 inner_is_first =
false;
618 <<
" globalPosition is " << firstTSOS.globalPosition()
619 <<
" innerId is " << innerId;
621 if(!firstTSOS.isValid()){
623 return vector<Trajectory>();
647 PropagationDirection propDir_last = (lastTSOS .globalPosition().basicVector().dot(lastTSOS .globalMomentum().basicVector()) > 0) ?
alongMomentum : oppositeToMomentum;
648 LogTrace(
theCategory) <<
"propDir_first " << propDir_first <<
", propdir_last " << propDir_last
649 <<
" : they " << (propDir_first == propDir_last ?
"agree" :
"disagree");
652 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator it = recHitsForReFit.begin(); it != recHitsForReFit.end(); ++it) {
653 if ((*it)->globalPosition().y() > 0) ++y_count;
668 <<
"; based on geometrically-outermost TSOS, propDir is " << propDir <<
": "
669 << (propDir == propDir_ycount ?
"agrees" :
"disagrees")
670 <<
" with ycount determination";
672 if (propDir_first != propDir_last) {
674 propDir = propDir_ycount;
680 if(recHitsForReFit.front()->geographicalId() !=
DetId(innerId)){
683 <<
" to first rechit with surface pos " << recHitsForReFit.front()->det()->surface().toGlobal(
LocalPoint(0,0,0));
685 if(!firstTSOS.isValid()){
687 return vector<Trajectory>();
708 vector<Trajectory> trajectories =
theFitter->fit(seed,recHitsForReFit,firstTSOS);
710 if(trajectories.empty()){
712 return vector<Trajectory>();
726 ConstRecHitContainer::const_iterator it = hits.begin();
727 for (; it!=hits.end(); it++) {
729 DetId id = (*it)->geographicalId();
787 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 tibLayer(const DetId &id) const
RefitDirection theRefitDirection
edm::ESHandle< TransientTrackingRecHitBuilder > theTrackerRecHitBuilder
std::string thePropagatorName
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
unsigned int pxfDisk(const DetId &id) const
std::string theFitterName
GlobalPoint globalPosition() const
void setServices(const edm::EventSetup &)
set the services needed by the TrackTransformer
unsigned int tidWheel(const DetId &id) const
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
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
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
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.
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
edm::InputTag theDTRecHitLabel
unsigned int pxbLayer(const DetId &id) const
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
void setThr(int, int, int)
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 tecWheel(const DetId &id) 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="")
std::vector< Trajectory > refit(const reco::Track &globalTrack, const int theMuonHitsOption, const TrackerTopology *tTopo) const
build combined trajectory from sta Track and tracker RecHits
unsigned int tobLayer(const DetId &id) const
edm::InputTag theCSCRecHitLabel
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.