CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CalibrationTrackSelectorFromDetIdList Class Referencefinal

#include <Calibration/TkAlCaRecoProducers/plugins/CalibrationTrackSelectorFromDetIdList.cc>

Inheritance diagram for CalibrationTrackSelectorFromDetIdList:
edm::stream::EDProducer<>

Public Member Functions

 CalibrationTrackSelectorFromDetIdList (const edm::ParameterSet &)
 
 ~CalibrationTrackSelectorFromDetIdList () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void beginRun (edm::Run const &run, const edm::EventSetup &) override
 
TrackCandidate makeCandidate (const reco::Track &tk, std::vector< std::unique_ptr< TrackingRecHit > >::iterator hitsBegin, std::vector< std::unique_ptr< TrackingRecHit > >::iterator hitsEnd)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< DetIdSelectordetidsels_
 
edm::EDGetTokenT< reco::TrackCollectionm_label
 
bool m_verbose
 
edm::ESHandle< TrackerGeometrytheGeometry
 
edm::ESHandle< MagneticFieldtheMagField
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: Selects tracks that have at leaast one valid hit on a given set of Tracker DetIds

Definition at line 40 of file CalibrationTrackSelectorFromDetIdList.cc.

Constructor & Destructor Documentation

CalibrationTrackSelectorFromDetIdList::CalibrationTrackSelectorFromDetIdList ( const edm::ParameterSet iConfig)
explicit

Definition at line 59 of file CalibrationTrackSelectorFromDetIdList.cc.

References detidsels_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_label, m_verbose, and corrVsCorr::selection.

59  : detidsels_() {
60 
61  std::vector<edm::ParameterSet> selconfigs = iConfig.getParameter<std::vector<edm::ParameterSet> >("selections");
62 
63  for(std::vector<edm::ParameterSet>::const_iterator selconfig=selconfigs.begin();selconfig!=selconfigs.end();++selconfig) {
64  DetIdSelector selection(*selconfig);
65  detidsels_.push_back(selection);
66  }
67 
68  m_verbose = iConfig.getUntrackedParameter<bool>("verbose");
69  m_label = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("Input"));
70  produces<TrackCandidateCollection>();
71 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
selection
main part
Definition: corrVsCorr.py:98
edm::EDGetTokenT< reco::TrackCollection > m_label
CalibrationTrackSelectorFromDetIdList::~CalibrationTrackSelectorFromDetIdList ( )
override

Definition at line 74 of file CalibrationTrackSelectorFromDetIdList.cc.

74 {}

Member Function Documentation

void CalibrationTrackSelectorFromDetIdList::beginRun ( edm::Run const &  run,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 150 of file CalibrationTrackSelectorFromDetIdList.cc.

References DEFINE_FWK_MODULE, TrackerGeometry::detIds(), detidsels_, edm::EventSetup::get(), LogDebug, m_verbose, edm::ESHandle< T >::product(), theGeometry, and theMagField.

150  {
153 
154  if(m_verbose){
155  for (const auto &detidsel : detidsels_){
156  auto theDetIds = theGeometry.product()->detIds();
157  for(const auto &theDet : theDetIds){
158  if(detidsel.isSelected(theDet)) {
159  LogDebug("CalibrationTrackSelectorFromDetIdList") << "detid: " << theDet.rawId() << " is taken" << std::endl;
160  }
161  }
162  }
163  }
164 
165 }
#define LogDebug(id)
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
T get() const
Definition: EventSetup.h:63
T const * product() const
Definition: ESHandle.h:86
TrackCandidate CalibrationTrackSelectorFromDetIdList::makeCandidate ( const reco::Track tk,
std::vector< std::unique_ptr< TrackingRecHit > >::iterator  hitsBegin,
std::vector< std::unique_ptr< TrackingRecHit > >::iterator  hitsEnd 
)
private

Definition at line 123 of file CalibrationTrackSelectorFromDetIdList.cc.

References alongMomentum, anyDirection, Exception, reco::Track::innerDetId(), reco::Track::innerPosition(), trajectoryStateTransform::innerStateOnSurface(), reco::TrackBase::momentum(), reco::Track::outerDetId(), reco::Track::outerPosition(), trajectoryStateTransform::outerStateOnSurface(), trajectoryStateTransform::persistentState(), edm::OwnVector< T, P >::push_back(), edm::OwnVector< T, P >::reserve(), SurveyInfoScenario_cff::seed, reco::Track::seedDirection(), reco::Track::seedRef(), theGeometry, and theMagField.

Referenced by produce().

123  {
124 
126  PTrajectoryStateOnDet state;
127  if ( pdir == anyDirection ) throw cms::Exception("UnimplementedFeature") << "Cannot work with tracks that have 'anyDirecton' \n";
128 
129  if ( (pdir == alongMomentum) == ( (tk.outerPosition()-tk.innerPosition()).Dot(tk.momentum()) >= 0 ) ) {
130  // use inner state
132  state = trajectoryStateTransform::persistentState( originalTsosIn, DetId(tk.innerDetId()) );
133  } else {
134  // use outer state
136  state = trajectoryStateTransform::persistentState( originalTsosOut, DetId(tk.outerDetId()) );
137  }
140  ownHits.reserve(hitsEnd - hitsBegin);
141  for ( ; hitsBegin != hitsEnd; ++hitsBegin) {
142  ownHits.push_back( hitsBegin->release() );
143  }
144 
145  TrackCandidate cand(ownHits, seed, state, tk.seedRef());
146 
147  return cand;
148 }
const edm::RefToBase< TrajectorySeed > & seedRef() const
Definition: Track.h:213
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
PropagationDirection
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:675
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
void push_back(D *&d)
Definition: OwnVector.h:290
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:94
Definition: DetId.h:18
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:204
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:99
void reserve(size_t)
Definition: OwnVector.h:284
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
void CalibrationTrackSelectorFromDetIdList::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 81 of file CalibrationTrackSelectorFromDetIdList.cc.

References TrackingRecHit::clone(), detidsels_, TrackingRecHit::geographicalId(), edm::Event::getByToken(), hfClusterShapes_cfi::hits, LogDebug, m_label, makeCandidate(), eostools::move(), convertSQLitetoXML_cfg::output, edm::Event::put(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), and l1t::tracks.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

81  {
82  using namespace edm;
83  using namespace std;
84 
86  iEvent.getByToken(m_label, tracks);
87  auto output = std::make_unique<TrackCandidateCollection>();
88 
89  // loop on tracks
90  for (std::vector<reco::Track>::const_iterator ittrk = tracks->begin(), edtrk = tracks->end(); ittrk != edtrk; ++ittrk) {
91  const reco::Track *trk = &(*ittrk);
92 
93  std::vector<std::unique_ptr<TrackingRecHit> > hits;
94 
95  bool saveTrack(false);
96 
97  for (trackingRecHit_iterator ith = trk->recHitsBegin(), edh = trk->recHitsEnd(); ith != edh; ++ith) {
98  const TrackingRecHit * hit = (*ith); // ith is an iterator on edm::Ref to rechit
99  DetId detid = hit->geographicalId();
100 
101  for (const auto &detidsel : detidsels_){
102  if(detidsel.isSelected(detid)) {
103  LogDebug("CalibrationTrackSelectorFromDetIdList") << "Selected by selection " << detid;
104  saveTrack=true;
105  break;
106  }
107  }
108 
109  // here there will be the selection
110  hits.emplace_back(hit->clone());
111 
112  }
113 
114  if(saveTrack){
115  output->push_back( makeCandidate ( *ittrk, hits.begin(), hits.end() ) );
116  }
117 
118  }
119  iEvent.put(std::move(output));
120 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::EDGetTokenT< reco::TrackCollection > m_label
TrackCandidate makeCandidate(const reco::Track &tk, std::vector< std::unique_ptr< TrackingRecHit > >::iterator hitsBegin, std::vector< std::unique_ptr< TrackingRecHit > >::iterator hitsEnd)
virtual TrackingRecHit * clone() const =0
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
Definition: DetId.h:18
HLT enums.
DetId geographicalId() const
def move(src, dest)
Definition: eostools.py:510
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109

Member Data Documentation

std::vector<DetIdSelector> CalibrationTrackSelectorFromDetIdList::detidsels_
private
edm::EDGetTokenT<reco::TrackCollection> CalibrationTrackSelectorFromDetIdList::m_label
private
bool CalibrationTrackSelectorFromDetIdList::m_verbose
private
edm::ESHandle<TrackerGeometry> CalibrationTrackSelectorFromDetIdList::theGeometry
private

Definition at line 54 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun(), and makeCandidate().

edm::ESHandle<MagneticField> CalibrationTrackSelectorFromDetIdList::theMagField
private

Definition at line 55 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun(), and makeCandidate().