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";
155 const int theMuonHitsOption)
const {
156 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
163 if ((*hit)->isValid()) {
166 else if ((*hit)->geographicalId().det() ==
DetId::Muon) {
167 if ((*hit)->geographicalId().subdetId() == 3 && !
theRPCInTheFit) {
174 vector<Trajectory> refitted =
refit(globalTrack,track,allRecHitsTemp,theMuonHitsOption);
184 const int theMuonHitsOption)
const {
192 vector<int> stationHits(4,0);
199 LogTrace(
theCategory) <<
" *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
208 vector <Trajectory> outputTraj;
210 if ((theMuonHitsOption == 1) || (theMuonHitsOption == 3) || (theMuonHitsOption == 4) ) {
212 vector <Trajectory> globalTraj =
transform(globalTrack, track, allRecHits);
214 if (!globalTraj.size()) {
216 return vector<Trajectory>();
220 << globalTraj.front().lastMeasurement().updatedState().freeState()->parameters() << endl;
222 if (theMuonHitsOption == 1 )
223 outputTraj.push_back(globalTraj.front());
225 if (theMuonHitsOption == 3 ) {
229 outputTraj =
transform(globalTrack, track, selectedRecHits);
232 if (theMuonHitsOption == 4 ) {
238 DYTRecHits = dytRefit.
filter(globalTraj.front());
239 if ((DYTRecHits.size() > 1) && (DYTRecHits.front()->globalPosition().mag() > DYTRecHits.back()->globalPosition().mag()))
241 outputTraj =
transform(globalTrack, track, DYTRecHits);
244 }
else if (theMuonHitsOption == 2 ) {
246 outputTraj =
transform(globalTrack, track, fmsRecHits);
250 if (outputTraj.size()) {
251 LogTrace(
theCategory) <<
"Refitted pt: " << outputTraj.front().firstMeasurement().updatedState().globalParameters().momentum().perp() << endl;
255 return vector<Trajectory>();
266 std::vector<int>& hits)
const {
270 float coneSize = 20.0;
272 for (
int i=0;
i<4;
i++ ) hits[
i]=dethits[
i]=0;
275 for (ConstRecHitContainer::const_iterator imrh = all.begin(); imrh != all.end(); imrh++ ) {
277 if ( (*imrh != 0 ) && !(*imrh)->isValid() )
continue;
283 DetId id = (*imrh)->geographicalId();
297 double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
298 if ( rhitDistance < coneSize ) detRecHits++;
300 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
312 double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).
mag();
313 if ( rhitDistance < coneSize ) detRecHits++;
315 <<
" Distance: " << rhitDistance <<
" recHits: " << detRecHits << endl;
323 if ( (station > 0) && (station < 5) ) {
324 if ( detRecHits > hits[station-1] ) hits[station-1] = detRecHits;
329 for (
int i = 0;
i < 4;
i++ )
335 if ( (all.size() > 1) &&
336 ( all.front()->globalPosition().mag() >
337 all.back()->globalPosition().mag() ) ) {
351 LogTrace(
theCategory) <<
" GlobalMuonRefitter::getFirstHits\nall rechits length:" << all.size() << endl;
354 int station_to_keep = 999;
356 for (ConstRecHitContainer::const_iterator ihit = all.begin(); ihit != all.end(); ++ihit) {
360 DetId id = (*ihit)->geographicalId();
361 unsigned raw_id =
id.
rawId();
362 if (!(*ihit)->isValid()) station = -1;
365 switch (
id.subdetId()) {
373 if (use_it && station > 0 && station < station_to_keep) station_to_keep =
station;
374 stations.push_back(station);
376 LogTrace(
theCategory) <<
"rawId: " << raw_id <<
" station = " << station <<
" station_to_keep is now " << station_to_keep;
379 if (station_to_keep <= 0 || station_to_keep > 4 || stations.size() != all.size())
380 LogInfo(
theCategory) <<
"failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = "
381 << station_to_keep <<
" stations.size " << stations.size() <<
" all.size " << all.size();
383 for (
unsigned i = 0;
i < stations.size(); ++
i)
384 if (stations[
i] >= 0 && stations[
i] <= station_to_keep) first.push_back(all[
i]);
396 const std::vector<int>& hits)
const {
399 const double globalChi2Cut = 200.0;
401 vector<TrajectoryMeasurement> muonMeasurements = traj.
measurements();
404 for (std::vector<TrajectoryMeasurement>::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) {
406 if ( !(*im).recHit()->isValid() )
continue;
407 if ( (*im).recHit()->det()->geographicalId().det() !=
DetId::Muon ) {
409 muonRecHits.push_back((*im).recHit());
414 DetId id = immrh->geographicalId();
417 double chi2Cut = 0.0;
420 if ( (*immrh).isDT() ) {
427 else if ( (*immrh).isCSC() ) {
434 else if ( (*immrh).isRPC() ) {
443 double chi2ndf = (*im).estimate()/(*im).recHit()->dimension();
446 if ( (station>0) && (station<5) ) {
447 if (hits[station-1]>threshold) keep =
false;
450 if ( (keep || (chi2ndf<chi2Cut)) && (chi2ndf<globalChi2Cut) ) {
451 muonRecHits.push_back((*im).recHit());
454 <<
"Skip hit: " <<
id.det() <<
" " << station <<
", "
455 << chi2ndf <<
" (" << chi2Cut <<
" chi2 threshold) "
456 << hits[station-1] << endl;
461 reverse(muonRecHits.begin(),muonRecHits.end());
472 for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
473 if ( !(*ir)->isValid() ) {
481 <<
"r = " <<
sqrt(pos.
x() * pos.
x() + pos.
y() * pos.
y())
482 <<
" z = " << pos.
z()
483 <<
" dimension = " << (*ir)->dimension()
484 <<
" det = " << (*ir)->det()->geographicalId().det()
485 <<
" subdet = " << (*ir)->det()->subDetector()
486 <<
" raw id = " << (*ir)->det()->geographicalId().rawId();
498 if (!recHits.empty()){
499 ConstRecHitContainer::const_iterator frontHit = recHits.begin();
500 ConstRecHitContainer::const_iterator backHit = recHits.end() - 1;
501 while( !(*frontHit)->isValid() && frontHit != backHit) {frontHit++;}
502 while( !(*backHit)->isValid() && backHit != frontHit) {backHit--;}
504 double rFirst = (*frontHit)->globalPosition().mag();
505 double rLast = (*backHit) ->globalPosition().mag();
508 else if(rFirst > rLast)
return outsideIn;
527 LogTrace(
theCategory) <<
"GlobalMuonRefitter::transform: " << recHitsForReFit.size() <<
" hits:";
530 if(recHitsForReFit.size() < 2)
return vector<Trajectory>();
540 if(
theRefitDirection != recHitsOrder) reverse(recHitsForReFit.begin(),recHitsForReFit.end());
547 unsigned int innerId, outerId;
558 inner_is_first =
true;
565 inner_is_first =
false;
569 <<
" globalPosition is " << firstTSOS.globalPosition()
570 <<
" innerId is " << innerId;
572 if(!firstTSOS.isValid()){
574 return vector<Trajectory>();
577 firstTSOS.rescaleError(1000.);
598 PropagationDirection propDir_last = (lastTSOS .globalPosition().basicVector().dot(lastTSOS .globalMomentum().basicVector()) > 0) ?
alongMomentum : oppositeToMomentum;
599 LogTrace(
theCategory) <<
"propDir_first " << propDir_first <<
", propdir_last " << propDir_last
600 <<
" : they " << (propDir_first == propDir_last ?
"agree" :
"disagree");
603 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator it = recHitsForReFit.begin(); it != recHitsForReFit.end(); ++it) {
604 if ((*it)->globalPosition().y() > 0) ++y_count;
619 <<
"; based on geometrically-outermost TSOS, propDir is " << propDir <<
": "
620 << (propDir == propDir_ycount ?
"agrees" :
"disagrees")
621 <<
" with ycount determination";
623 if (propDir_first != propDir_last) {
625 propDir = propDir_ycount;
631 if(recHitsForReFit.front()->geographicalId() !=
DetId(innerId)){
634 <<
" to first rechit with surface pos " << recHitsForReFit.front()->det()->surface().toGlobal(
LocalPoint(0,0,0));
636 if(!firstTSOS.isValid()){
638 return vector<Trajectory>();
659 vector<Trajectory> trajectories =
theFitter->fit(seed,recHitsForReFit,firstTSOS);
661 if(trajectories.empty()){
663 return vector<Trajectory>();
676 ConstRecHitContainer::const_iterator it = hits.begin();
677 for (; it!=hits.end(); it++) {
679 DetId id = (*it)->geographicalId();
737 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
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
TrajectoryStateOnSurface innermostMeasurementState() const
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
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.
edm::Handle< CSCRecHit2DCollection > theCSCRecHits
int theTrackerSkipSection
RefitDirection checkRecHitsOrdering(const ConstRecHitContainer &) const
TrajectoryStateOnSurface outermostMeasurementState() const
void checkMuonHits(const reco::Track &, ConstRecHitContainer &, std::vector< int > &) const
check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit ...
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
ConstRecHitContainer selectMuonHits(const Trajectory &, const std::vector< int > &) const
select muon hits compatible with trajectory; check hits in chambers with showers
unsigned long long theCacheId_TRH
int station() const
Return the station number.
int wheel() const
Return the wheel 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
const double par[8 *NPar][4]
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.