CMS 3D CMS Logo

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, TrackerDigiGeometryRecordgeometryToken_
 
edm::EDGetTokenT< reco::TrackCollectionm_label
 
bool m_verbose
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagFieldToken_
 
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::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 getParameter(std::string const &) const
Definition: ParameterSet.h:303
selection
main part
Definition: corrVsCorr.py:100
edm::EDGetTokenT< reco::TrackCollection > m_label
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geometryToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_

◆ ~CalibrationTrackSelectorFromDetIdList()

CalibrationTrackSelectorFromDetIdList::~CalibrationTrackSelectorFromDetIdList ( )
override

Definition at line 84 of file CalibrationTrackSelectorFromDetIdList.cc.

84 {}

Member Function Documentation

◆ beginRun()

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

Definition at line 161 of file CalibrationTrackSelectorFromDetIdList.cc.

References TrackerGeometry::detIds(), detidsels_, geometryToken_, edm::EventSetup::getHandle(), LogDebug, m_verbose, magFieldToken_, edm::ESHandle< T >::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 DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
T const * product() const
Definition: ESHandle.h:86
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geometryToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
#define LogDebug(id)

◆ makeCandidate()

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(
143  } else {
144  // use outer state
145  TrajectoryStateOnSurface originalTsosOut(
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 math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
const edm::RefToBase< TrajectorySeed > & seedRef() const
Definition: Track.h:155
PropagationDirection
void push_back(D *&d)
Definition: OwnVector.h:326
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
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 outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:79
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:664
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
void reserve(size_t)
Definition: OwnVector.h:320
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)

◆ produce()

void CalibrationTrackSelectorFromDetIdList::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 91 of file CalibrationTrackSelectorFromDetIdList.cc.

References detidsels_, hfClusterShapes_cfi::hits, iEvent, LogDebug, m_label, makeCandidate(), eostools::move(), convertSQLitetoXML_cfg::output, DetId::rawId(), and pwdgSkimBPark_cfi::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 }
TrackCandidate makeCandidate(const reco::Track &tk, std::vector< const TrackingRecHit *>::iterator hitsBegin, std::vector< const TrackingRecHit *>::iterator hitsEnd)
edm::EDGetTokenT< reco::TrackCollection > m_label
int iEvent
Definition: GenABIO.cc:224
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HLT enums.
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ detidsels_

std::vector<DetIdSelector> CalibrationTrackSelectorFromDetIdList::detidsels_
private

◆ geometryToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> CalibrationTrackSelectorFromDetIdList::geometryToken_
private

Definition at line 57 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun().

◆ m_label

edm::EDGetTokenT<reco::TrackCollection> CalibrationTrackSelectorFromDetIdList::m_label
private

◆ m_verbose

bool CalibrationTrackSelectorFromDetIdList::m_verbose
private

◆ magFieldToken_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> CalibrationTrackSelectorFromDetIdList::magFieldToken_
private

Definition at line 58 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun().

◆ theGeometry

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

Definition at line 63 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun(), and makeCandidate().

◆ theMagField

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

Definition at line 64 of file CalibrationTrackSelectorFromDetIdList.cc.

Referenced by beginRun(), and makeCandidate().