#include <MuonSelector.h>
Definition at line 28 of file MuonSelector.h.
Definition at line 30 of file MuonSelector.h.
helper::MuonCollectionStoreManager::MuonCollectionStoreManager | ( | const edm::Handle< reco::MuonCollection > & | ) |
Definition at line 18 of file MuonSelector.cc.
: selMuons_( new reco::MuonCollection ), selTracks_( new reco::TrackCollection ), selTracksExtras_( new reco::TrackExtraCollection ), selTracksHits_( new TrackingRecHitCollection ), selGlobalMuonTracks_( new reco::TrackCollection ), selGlobalMuonTracksExtras_( new reco::TrackExtraCollection ), selGlobalMuonTracksHits_( new TrackingRecHitCollection ), selStandAloneTracks_( new reco::TrackCollection ), selStandAloneTracksExtras_( new reco::TrackExtraCollection ), selStandAloneTracksHits_( new TrackingRecHitCollection ), selStripClusters_( new edmNew::DetSetVector<SiStripCluster> ), selPixelClusters_( new edmNew::DetSetVector<SiPixelCluster> ), rMuons_(), rTracks_(), rTrackExtras_(), rHits_(), rGBTracks_(), rGBTrackExtras_(), rGBHits_(), rSATracks_(), rSATrackExtras_(), rSAHits_(), clusterStorer_(), id_(0), igbd_(0), isad_(0), idx_(0), igbdx_(0), isadx_(0), hidx_(0), higbdx_(0), hisadx_(0), cloneClusters_ (true) { }
void helper::MuonCollectionStoreManager::cloneAndStore | ( | const I & | begin, |
const I & | end, | ||
edm::Event & | evt | ||
) |
Method to clone tracks, track extras and their hits and clusters. typename I = this is an interator over a Muon collection, **I needs to dereference into a Muon.
Definition at line 112 of file MuonSelector.h.
References helper::ClusterStorer::clear(), clusterStorer_, end, hidx_, higbdx_, hisadx_, Exhume::I, i, id_, idx_, igbd_, igbdx_, isad_, isadx_, helper::ClusterStorer::processAllClusters(), processMuon(), dt_offlineAnalysis_common_cff::reco, rGBHits_, rGBTrackExtras_, rGBTracks_, rHits_, rMuons_, rSAHits_, rSATrackExtras_, rSATracks_, rTrackExtras_, rTracks_, selPixelClusters_, and selStripClusters_.
{ using namespace reco; rHits_ = evt.template getRefBeforePut<TrackingRecHitCollection>("TrackerOnly"); rGBHits_ = evt.template getRefBeforePut<TrackingRecHitCollection>("GlobalMuon"); rSAHits_ = evt.template getRefBeforePut<TrackingRecHitCollection>("StandAlone"); rTrackExtras_ = evt.template getRefBeforePut<TrackExtraCollection>("TrackerOnly"); rGBTrackExtras_ = evt.template getRefBeforePut<TrackExtraCollection>("GlobalMuon"); rSATrackExtras_ = evt.template getRefBeforePut<TrackExtraCollection>("StandAlone"); rTracks_ = evt.template getRefBeforePut<TrackCollection>("TrackerOnly"); rGBTracks_ = evt.template getRefBeforePut<TrackCollection>("GlobalMuon"); rSATracks_ = evt.template getRefBeforePut<TrackCollection>("StandAlone"); rMuons_ = evt.template getRefBeforePut<MuonCollection>("SelectedMuons"); //--- New: save clusters too edm::RefProd<edmNew::DetSetVector<SiStripCluster> > rStripClusters = evt.template getRefBeforePut<edmNew::DetSetVector<SiStripCluster> >(); edm::RefProd<edmNew::DetSetVector<SiPixelCluster> > rPixelClusters = evt.template getRefBeforePut<edmNew::DetSetVector<SiPixelCluster> >(); id_=0; igbd_=0; isad_=0; idx_ = 0; igbdx_=0; isadx_=0; hidx_=0; higbdx_=0; hisadx_=0; clusterStorer_.clear(); for( I i = begin; i != end; ++ i ) { const Muon & mu = * * i; //--- Clone this track, and store references aside processMuon( mu ); } //--- Clone the clusters and fixup refs clusterStorer_.processAllClusters(*selPixelClusters_, rPixelClusters, *selStripClusters_, rStripClusters); }
bool helper::MuonCollectionStoreManager::cloneClusters | ( | ) | [inline] |
Use these to turn off/on the cloning of clusters. The default is to clone them. To not clone (and save space in a quick local job, do: setCloneClusters(false);
Definition at line 40 of file MuonSelector.h.
References cloneClusters_.
Referenced by processMuon(), and put().
{return cloneClusters_ ; }
bool helper::MuonCollectionStoreManager::clusterRefsOK | ( | const reco::Track & | track | ) | const [private] |
Check if all references to silicon strip/pixel clusters are available.
Definition at line 153 of file MuonSelector.cc.
References SiStripRecHit2D::cluster(), DetId::det(), TrackingRecHit::geographicalId(), TrackingRecHit::isValid(), SiStripMatchedRecHit2D::monoHit(), ProjectedSiStripRecHit2D::originalHit(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), SiStripMatchedRecHit2D::stereoHit(), and align::Tracker.
Referenced by processMuon().
{ for (trackingRecHit_iterator hitIt = track.recHitsBegin(); hitIt != track.recHitsEnd(); ++hitIt) { const TrackingRecHit &hit = **hitIt; if (!hit.isValid() || hit.geographicalId().det() != DetId::Tracker) continue; // So we are in the tracker - now check hit types and availability of cluster refs: const std::type_info &hit_type = typeid(hit); if (hit_type == typeid(SiPixelRecHit)) { if (!static_cast<const SiPixelRecHit &>(hit).cluster().isAvailable()) return false; } else if (hit_type == typeid(SiStripRecHit2D)) { if (!static_cast<const SiStripRecHit2D &>(hit).cluster().isAvailable()) return false; } else if (hit_type == typeid(SiStripRecHit1D)) { if (!static_cast<const SiStripRecHit1D &>(hit).cluster().isAvailable()) return false; } else if (hit_type == typeid(SiStripMatchedRecHit2D)) { const SiStripMatchedRecHit2D &mHit = static_cast<const SiStripMatchedRecHit2D &>(hit); if (!mHit.monoHit()->cluster().isAvailable()) return false; if (!mHit.stereoHit()->cluster().isAvailable()) return false; } else if (hit_type == typeid(ProjectedSiStripRecHit2D)) { const ProjectedSiStripRecHit2D &pHit = static_cast<const ProjectedSiStripRecHit2D &>(hit); if (!pHit.originalHit().cluster().isAvailable()) return false; } else { // std::cout << "| It is a " << hit_type.name() << " hit !?" << std::endl; // Do nothing. We might end up here for FastSim hits. } // end 'switch' on hit type } // No tracker hit with bad cluster found, so all fine: return true; }
void helper::MuonCollectionStoreManager::processMuon | ( | const reco::Muon & | mu | ) | [private] |
Process a single muon.
Definition at line 49 of file MuonSelector.cc.
References reco::TrackExtraBase::add(), helper::ClusterStorer::addCluster(), cloneClusters(), clusterRefsOK(), clusterStorer_, reco::Muon::combinedMuon(), reco::Muon::globalTrack(), hidx_, higbdx_, hisadx_, id_, idx_, igbd_, igbdx_, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), reco::Muon::innerTrack(), isad_, isadx_, edm::Ref< C, T, F >::isNonnull(), TrackingRecHit::isValid(), reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), rGBHits_, rGBTrackExtras_, rGBTracks_, rHits_, rSAHits_, rSATrackExtras_, rSATracks_, rTrackExtras_, rTracks_, reco::Track::seedDirection(), selGlobalMuonTracks_, selGlobalMuonTracksExtras_, selGlobalMuonTracksHits_, selMuons_, selStandAloneTracks_, selStandAloneTracksExtras_, selStandAloneTracksHits_, selTracks_, selTracksExtras_, selTracksHits_, reco::Track::setExtra(), reco::Muon::standAloneMuon(), reco::Muon::track(), and align::Tracker.
Referenced by cloneAndStore().
{ if (this->cloneClusters() && ( (mu.globalTrack().isNonnull() && !this->clusterRefsOK(*mu.globalTrack())) || (mu.innerTrack() .isNonnull() && !this->clusterRefsOK(*mu.innerTrack() )) // || (mu.outerTrack(). isNonnull() && !this->clusterRefsOK(*mu.outerTrack() )) )) { // outer track is muon only and has no strip clusters... // At least until CMSSW_2_1_8, global muon track reconstruction assigns wrong hits in // case of a track from iterative tracking. These hits are fetched from Trajectories // instead of from Tracks and therefore reference temporary cluster collections. // As a hack we skip these muons here - they can anyway not be refitted. edm::LogError("BadRef") << "@SUB=MuonCollectionStoreManager::processMuon" << "Skip muon: One of its tracks references " << "non-available clusters!"; return; } selMuons_->push_back( Muon( mu ) ); // only tracker Muon Track selMuons_->back().setInnerTrack( TrackRef( rTracks_, id_ ++ ) ); TrackRef trkRef = mu.track(); if(trkRef.isNonnull()){ selTracks_->push_back(Track( *trkRef) ); Track & trk= selTracks_->back(); selTracksExtras_->push_back( TrackExtra( trk.outerPosition(), trk.outerMomentum(), trk.outerOk(), trk.innerPosition(), trk.innerMomentum(), trk.innerOk(), trk.outerStateCovariance(), trk.outerDetId(), trk.innerStateCovariance(), trk.innerDetId(), trk.seedDirection() ) ); TrackExtra & tx = selTracksExtras_->back(); for( trackingRecHit_iterator hit = trk.recHitsBegin(); hit != trk.recHitsEnd(); ++ hit, ++ hidx_) { selTracksHits_->push_back( (*hit)->clone() ); TrackingRecHit * newHit = & (selTracksHits_->back()); tx.add( TrackingRecHitRef( rHits_, hidx_ ) ); if (cloneClusters() && newHit->isValid() && ((*hit)->geographicalId().det() == DetId::Tracker)) { clusterStorer_.addCluster( *selTracksHits_, hidx_ ); } } // end of for loop over tracking rec hits on this track trk.setExtra( TrackExtraRef( rTrackExtras_, idx_ ++ ) ); }// TO trkRef.isNonnull // global Muon Track selMuons_->back().setGlobalTrack( TrackRef( rGBTracks_, igbd_ ++ ) ); trkRef = mu.combinedMuon(); if(trkRef.isNonnull()){ selGlobalMuonTracks_->push_back(Track( *trkRef) ); Track & trk = selGlobalMuonTracks_->back(); selGlobalMuonTracksExtras_->push_back( TrackExtra( trk.outerPosition(), trk.outerMomentum(), trk.outerOk(), trk.innerPosition(), trk.innerMomentum(), trk.innerOk(), trk.outerStateCovariance(), trk.outerDetId(), trk.innerStateCovariance(), trk.innerDetId(), trk.seedDirection() ) ); TrackExtra & tx = selGlobalMuonTracksExtras_->back(); for( trackingRecHit_iterator hit = trk.recHitsBegin(); hit != trk.recHitsEnd(); ++ hit, ++ higbdx_) { selGlobalMuonTracksHits_->push_back( (*hit)->clone() ); TrackingRecHit * newHit = & (selGlobalMuonTracksHits_->back()); tx.add( TrackingRecHitRef( rGBHits_, higbdx_ ) ); if (cloneClusters() && newHit->isValid() && ((*hit)->geographicalId().det() == DetId::Tracker)) { clusterStorer_.addCluster( *selGlobalMuonTracksHits_, higbdx_ ); } } trk.setExtra( TrackExtraRef( rGBTrackExtras_, igbdx_ ++ ) ); } // GB trkRef.isNonnull() // stand alone Muon Track selMuons_->back().setOuterTrack( TrackRef( rSATracks_, isad_ ++ ) ); trkRef = mu.standAloneMuon(); if(trkRef.isNonnull()){ selStandAloneTracks_->push_back(Track( *trkRef) ); Track & trk = selStandAloneTracks_->back(); selStandAloneTracksExtras_->push_back( TrackExtra( trk.outerPosition(), trk.outerMomentum(), trk.outerOk(), trk.innerPosition(), trk.innerMomentum(), trk.innerOk(), trk.outerStateCovariance(), trk.outerDetId(), trk.innerStateCovariance(), trk.innerDetId(), trk.seedDirection() ) ); TrackExtra & tx = selStandAloneTracksExtras_->back(); for( trackingRecHit_iterator hit = trk.recHitsBegin(); hit != trk.recHitsEnd(); ++ hit ) { selStandAloneTracksHits_->push_back( (*hit)->clone() ); tx.add( TrackingRecHitRef( rSAHits_, hisadx_ ++ ) ); } trk.setExtra( TrackExtraRef( rSATrackExtras_, isadx_ ++ ) ); } // SA trkRef.isNonnull() }// end of track, and function
edm::OrphanHandle< reco::MuonCollection > helper::MuonCollectionStoreManager::put | ( | edm::Event & | evt | ) |
Put tracks, track extras and hits+clusters into the event.
Put Muons, tracks, track extras and hits+clusters into the event.
Definition at line 190 of file MuonSelector.cc.
References cloneClusters(), h, edm::Event::put(), selGlobalMuonTracks_, selGlobalMuonTracksExtras_, selGlobalMuonTracksHits_, selMuons_, selPixelClusters_, selStandAloneTracks_, selStandAloneTracksExtras_, selStandAloneTracksHits_, selStripClusters_, selTracks_, selTracksExtras_, and selTracksHits_.
{ edm::OrphanHandle<reco::MuonCollection> h; h = evt.put( selMuons_ , "SelectedMuons"); evt.put( selTracks_ , "TrackerOnly"); evt.put( selTracksExtras_ , "TrackerOnly"); evt.put( selTracksHits_ ,"TrackerOnly"); evt.put( selGlobalMuonTracks_,"GlobalMuon" ); evt.put( selGlobalMuonTracksExtras_ ,"GlobalMuon"); evt.put( selGlobalMuonTracksHits_,"GlobalMuon" ); evt.put( selStandAloneTracks_ ,"StandAlone"); evt.put( selStandAloneTracksExtras_ ,"StandAlone"); evt.put( selStandAloneTracksHits_ ,"StandAlone"); if (cloneClusters()) { evt.put( selStripClusters_ ); evt.put( selPixelClusters_ ); } return h; }
void helper::MuonCollectionStoreManager::setCloneClusters | ( | bool | w | ) | [inline] |
size_t helper::MuonCollectionStoreManager::size | ( | void | ) | const [inline] |
Get the size.
Definition at line 51 of file MuonSelector.h.
References selMuons_.
{ return selMuons_->size(); }
bool helper::MuonCollectionStoreManager::cloneClusters_ [private] |
Clone clusters, or not? Default: true.
Definition at line 98 of file MuonSelector.h.
Referenced by cloneClusters(), and setCloneClusters().
Helper to treat copies of selected clusters and make the hits refer to the output cluster collections:
Definition at line 92 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
size_t helper::MuonCollectionStoreManager::hidx_ [private] |
Definition at line 95 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
size_t helper::MuonCollectionStoreManager::higbdx_ [private] |
Definition at line 95 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
size_t helper::MuonCollectionStoreManager::hisadx_ [private] |
Definition at line 95 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
size_t helper::MuonCollectionStoreManager::id_ [private] |
Definition at line 95 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
size_t helper::MuonCollectionStoreManager::idx_ [private] |
Definition at line 95 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
size_t helper::MuonCollectionStoreManager::igbd_ [private] |
Definition at line 95 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
size_t helper::MuonCollectionStoreManager::igbdx_ [private] |
Definition at line 95 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
size_t helper::MuonCollectionStoreManager::isad_ [private] |
Definition at line 95 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
size_t helper::MuonCollectionStoreManager::isadx_ [private] |
Definition at line 95 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
Definition at line 84 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
Definition at line 83 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
Definition at line 82 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
Definition at line 80 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
Definition at line 77 of file MuonSelector.h.
Referenced by cloneAndStore().
Definition at line 88 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
Definition at line 87 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
Definition at line 86 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
Definition at line 79 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
Definition at line 78 of file MuonSelector.h.
Referenced by cloneAndStore(), and processMuon().
std::auto_ptr<reco::TrackCollection> helper::MuonCollectionStoreManager::selGlobalMuonTracks_ [private] |
Definition at line 68 of file MuonSelector.h.
Referenced by processMuon(), and put().
std::auto_ptr<reco::TrackExtraCollection> helper::MuonCollectionStoreManager::selGlobalMuonTracksExtras_ [private] |
Definition at line 69 of file MuonSelector.h.
Referenced by processMuon(), and put().
std::auto_ptr<TrackingRecHitCollection> helper::MuonCollectionStoreManager::selGlobalMuonTracksHits_ [private] |
Definition at line 70 of file MuonSelector.h.
Referenced by processMuon(), and put().
std::auto_ptr<reco::MuonCollection> helper::MuonCollectionStoreManager::selMuons_ [private] |
Definition at line 64 of file MuonSelector.h.
Referenced by processMuon(), put(), and size().
std::auto_ptr< edmNew::DetSetVector<SiPixelCluster> > helper::MuonCollectionStoreManager::selPixelClusters_ [private] |
Definition at line 75 of file MuonSelector.h.
Referenced by cloneAndStore(), and put().
std::auto_ptr<reco::TrackCollection> helper::MuonCollectionStoreManager::selStandAloneTracks_ [private] |
Definition at line 71 of file MuonSelector.h.
Referenced by processMuon(), and put().
std::auto_ptr<reco::TrackExtraCollection> helper::MuonCollectionStoreManager::selStandAloneTracksExtras_ [private] |
Definition at line 72 of file MuonSelector.h.
Referenced by processMuon(), and put().
std::auto_ptr<TrackingRecHitCollection> helper::MuonCollectionStoreManager::selStandAloneTracksHits_ [private] |
Definition at line 73 of file MuonSelector.h.
Referenced by processMuon(), and put().
std::auto_ptr< edmNew::DetSetVector<SiStripCluster> > helper::MuonCollectionStoreManager::selStripClusters_ [private] |
Definition at line 74 of file MuonSelector.h.
Referenced by cloneAndStore(), and put().
std::auto_ptr<reco::TrackCollection> helper::MuonCollectionStoreManager::selTracks_ [private] |
Definition at line 65 of file MuonSelector.h.
Referenced by processMuon(), and put().
std::auto_ptr<reco::TrackExtraCollection> helper::MuonCollectionStoreManager::selTracksExtras_ [private] |
Definition at line 66 of file MuonSelector.h.
Referenced by processMuon(), and put().
std::auto_ptr<TrackingRecHitCollection> helper::MuonCollectionStoreManager::selTracksHits_ [private] |
Definition at line 67 of file MuonSelector.h.
Referenced by processMuon(), and put().