CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
CalibrationTrackSelectorFromDetIdList Class Referencefinal
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

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

Private Attributes

std::vector< DetIdSelectordetidsels_
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
geometryToken_
 
edm::EDGetTokenT
< reco::TrackCollection
m_label
 
bool m_verbose
 
const edm::ESGetToken
< MagneticField,
IdealMagneticFieldRecord
magFieldToken_
 
edm::ESHandle< TrackerGeometrytheGeometry
 
edm::ESHandle< MagneticFieldtheMagField
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

CalibrationTrackSelectorFromDetIdList.cc Calibration/TkAlCaRecoProducers/plugins/CalibrationTrackSelectorFromDetIdList.cc Description: Selects tracks that have at leaast one valid hit on a given set of Tracker DetIds

Definition at line 44 of file CalibrationTrackSelectorFromDetIdList.cc.

Constructor & Destructor Documentation

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

Definition at line 67 of file CalibrationTrackSelectorFromDetIdList.cc.

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

68  : geometryToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>()),
69  magFieldToken_(esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()),
70  detidsels_() {
71  std::vector<edm::ParameterSet> selconfigs = iConfig.getParameter<std::vector<edm::ParameterSet>>("selections");
72 
73  for (std::vector<edm::ParameterSet>::const_iterator selconfig = selconfigs.begin(); selconfig != selconfigs.end();
74  ++selconfig) {
75  DetIdSelector selection(*selconfig);
76  detidsels_.push_back(selection);
77  }
78 
79  m_verbose = iConfig.getUntrackedParameter<bool>("verbose");
80  m_label = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("Input"));
81  produces<TrackCandidateCollection>();
82 }
T getUntrackedParameter(std::string const &, T const &) const
selection
main part
Definition: corrVsCorr.py:100
edm::EDGetTokenT< reco::TrackCollection > m_label
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geometryToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
CalibrationTrackSelectorFromDetIdList::~CalibrationTrackSelectorFromDetIdList ( )
override

Definition at line 84 of file CalibrationTrackSelectorFromDetIdList.cc.

84 {}

Member Function Documentation

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

Definition at line 161 of file CalibrationTrackSelectorFromDetIdList.cc.

References detidsels_, geometryToken_, edm::EventSetup::getHandle(), LogDebug, m_verbose, magFieldToken_, edm::ESHandle< class >::product(), theGeometry, and theMagField.

161  {
164 
165  if (m_verbose) {
166  for (const auto &detidsel : detidsels_) {
167  auto theDetIds = theGeometry.product()->detIds();
168  for (const auto &theDet : theDetIds) {
169  if (detidsel.isSelected(theDet)) {
170  LogDebug("CalibrationTrackSelectorFromDetIdList") << "detid: " << theDet.rawId() << " is taken" << std::endl;
171  }
172  }
173  }
174  }
175 }
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geometryToken_
T const * product() const
Definition: ESHandle.h:86
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
#define LogDebug(id)
TrackCandidate CalibrationTrackSelectorFromDetIdList::makeCandidate ( const reco::Track tk,
std::vector< const TrackingRecHit * >::iterator  hitsBegin,
std::vector< const TrackingRecHit * >::iterator  hitsEnd 
)
private

Definition at line 129 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(), fileCollector::seed, reco::Track::seedDirection(), reco::Track::seedRef(), theGeometry, and theMagField.

Referenced by produce().

132  {
135  if (pdir == anyDirection)
136  throw cms::Exception("UnimplementedFeature") << "Cannot work with tracks that have 'anyDirecton' \n";
137 
138  if ((pdir == alongMomentum) == ((tk.outerPosition() - tk.innerPosition()).Dot(tk.momentum()) >= 0)) {
139  // use inner state
140  TrajectoryStateOnSurface originalTsosIn(
142  state = trajectoryStateTransform::persistentState(originalTsosIn, DetId(tk.innerDetId()));
143  } else {
144  // use outer state
145  TrajectoryStateOnSurface originalTsosOut(
147  state = trajectoryStateTransform::persistentState(originalTsosOut, DetId(tk.outerDetId()));
148  }
151  ownHits.reserve(hitsEnd - hitsBegin);
152  for (; hitsBegin != hitsEnd; ++hitsBegin) {
153  ownHits.push_back((*hitsBegin)->clone());
154  }
155 
156  TrackCandidate cand(ownHits, seed, state, tk.seedRef());
157 
158  return cand;
159 }
const edm::RefToBase< TrajectorySeed > & seedRef() const
Definition: Track.h:155
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:664
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
void push_back(D *&d)
Definition: OwnVector.h:326
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:79
Definition: DetId.h:17
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:148
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
void reserve(size_t)
Definition: OwnVector.h:320
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 91 of file CalibrationTrackSelectorFromDetIdList.cc.

References detidsels_, edm::Event::getByToken(), LogDebug, m_label, makeCandidate(), eostools::move(), convertSQLitetoXML_cfg::output, edm::Event::put(), DetId::rawId(), and tracks.

91  {
92  using namespace edm;
93  using namespace std;
94 
95  edm::Handle<std::vector<reco::Track>> trackCollectionHandle;
96  iEvent.getByToken(m_label, trackCollectionHandle);
97  auto const &tracks = *trackCollectionHandle;
98 
99  auto output = std::make_unique<TrackCandidateCollection>();
100 
101  // loop on tracks
102  for (auto &trk : tracks) {
103  std::vector<const TrackingRecHit *> hits;
104 
105  bool saveTrack(false);
106 
107  for (auto const &hit : trk.recHits()) {
108  DetId detid = hit->geographicalId();
109 
110  for (const auto &detidsel : detidsels_) {
111  if (detidsel.isSelected(detid)) {
112  LogDebug("CalibrationTrackSelectorFromDetIdList") << "Selected by selection " << detid.rawId();
113  saveTrack = true;
114  break;
115  }
116  }
117 
118  // here there will be the selection
119  hits.emplace_back(hit);
120  }
121 
122  if (saveTrack) {
123  output->push_back(makeCandidate(trk, hits.begin(), hits.end()));
124  }
125  }
126  iEvent.put(std::move(output));
127 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::EDGetTokenT< reco::TrackCollection > m_label
auto const & tracks
cannot be loose
TrackCandidate makeCandidate(const reco::Track &tk, std::vector< const TrackingRecHit * >::iterator hitsBegin, std::vector< const TrackingRecHit * >::iterator hitsEnd)
def move
Definition: eostools.py:511
Definition: DetId.h:17
#define LogDebug(id)

Member Data Documentation

std::vector<DetIdSelector> CalibrationTrackSelectorFromDetIdList::detidsels_
private
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> CalibrationTrackSelectorFromDetIdList::geometryToken_
private

Definition at line 57 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun().

edm::EDGetTokenT<reco::TrackCollection> CalibrationTrackSelectorFromDetIdList::m_label
private
bool CalibrationTrackSelectorFromDetIdList::m_verbose
private
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> CalibrationTrackSelectorFromDetIdList::magFieldToken_
private

Definition at line 58 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun().

edm::ESHandle<TrackerGeometry> CalibrationTrackSelectorFromDetIdList::theGeometry
private

Definition at line 63 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun(), and makeCandidate().

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

Definition at line 64 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun(), and makeCandidate().