CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
CosmicTrackingParticleSelector Class Reference

#include <CosmicTrackingParticleSelector.h>

Public Types

typedef TrackingParticleCollection collection
 
typedef container::const_iterator const_iterator
 
typedef std::vector< const TrackingParticle * > container
 

Public Member Functions

const_iterator begin () const
 
 CosmicTrackingParticleSelector ()
 
 CosmicTrackingParticleSelector (double ptMin, double minRapidity, double maxRapidity, double tip, double lip, int minHit, bool chargedOnly, const std::vector< int > &pdgId=std::vector< int >())
 
 CosmicTrackingParticleSelector (const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
 
const_iterator end () const
 
void initEvent (edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
 
bool operator() (const TrackingParticleRef tpr, const reco::BeamSpot *bs, const edm::Event &iEvent, const edm::EventSetup &iSetup) const
 
void select (const edm::Handle< collection > &c, const edm::Event &event, const edm::EventSetup &setup)
 
size_t size () const
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamSpotToken_
 
bool chargedOnly_
 
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordglobalTrackingGeomToken_
 
double lip_
 
double maxRapidity_
 
int minHit_
 
double minRapidity_
 
std::vector< int > pdgId_
 
double ptMin_
 
container selected_
 
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationListsimHitsTPAssoc
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordtheMFToken_
 
double tip_
 

Detailed Description

Definition at line 39 of file CosmicTrackingParticleSelector.h.

Member Typedef Documentation

◆ collection

Definition at line 41 of file CosmicTrackingParticleSelector.h.

◆ const_iterator

typedef container::const_iterator CosmicTrackingParticleSelector::const_iterator

Definition at line 43 of file CosmicTrackingParticleSelector.h.

◆ container

Definition at line 42 of file CosmicTrackingParticleSelector.h.

Constructor & Destructor Documentation

◆ CosmicTrackingParticleSelector() [1/3]

CosmicTrackingParticleSelector::CosmicTrackingParticleSelector ( )
inline

Definition at line 45 of file CosmicTrackingParticleSelector.h.

45 {}

◆ CosmicTrackingParticleSelector() [2/3]

CosmicTrackingParticleSelector::CosmicTrackingParticleSelector ( double  ptMin,
double  minRapidity,
double  maxRapidity,
double  tip,
double  lip,
int  minHit,
bool  chargedOnly,
const std::vector< int > &  pdgId = std::vector<int>() 
)
inline

Definition at line 47 of file CosmicTrackingParticleSelector.h.

55  : ptMin_(ptMin),
58  tip_(tip),
59  lip_(lip),
60  minHit_(minHit),
62  pdgId_(pdgId) {}
constexpr float ptMin

◆ CosmicTrackingParticleSelector() [3/3]

CosmicTrackingParticleSelector::CosmicTrackingParticleSelector ( const edm::ParameterSet cfg,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 64 of file CosmicTrackingParticleSelector.h.

65  : ptMin_(cfg.getParameter<double>("ptMin")),
66  minRapidity_(cfg.getParameter<double>("minRapidity")),
67  maxRapidity_(cfg.getParameter<double>("maxRapidity")),
68  tip_(cfg.getParameter<double>("tip")),
69  lip_(cfg.getParameter<double>("lip")),
70  minHit_(cfg.getParameter<int>("minHit")),
71  chargedOnly_(cfg.getParameter<bool>("chargedOnly")),
72  pdgId_(cfg.getParameter<std::vector<int> >("pdgId")),
73  beamSpotToken_(iC.consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))),
75  theMFToken_(iC.esConsumes()) {}
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theMFToken_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > globalTrackingGeomToken_

Member Function Documentation

◆ begin()

const_iterator CosmicTrackingParticleSelector::begin ( void  ) const
inline

Definition at line 87 of file CosmicTrackingParticleSelector.h.

References selected_.

◆ end()

const_iterator CosmicTrackingParticleSelector::end ( void  ) const
inline

◆ initEvent()

void CosmicTrackingParticleSelector::initEvent ( edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList simHitsTPAssocToSet) const
inline

Definition at line 90 of file CosmicTrackingParticleSelector.h.

References simHitsTPAssoc.

Referenced by MultiTrackValidator::dqmAnalyze().

90  {
91  simHitsTPAssoc = simHitsTPAssocToSet;
92  }
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc

◆ operator()()

bool CosmicTrackingParticleSelector::operator() ( const TrackingParticleRef  tpr,
const reco::BeamSpot bs,
const edm::Event iEvent,
const edm::EventSetup iSetup 
) const
inline

Definition at line 95 of file CosmicTrackingParticleSelector.h.

References cms::cuda::bs, chargedOnly_, PV3DBase< T, PVType, FrameType >::eta(), newFWLiteAna::found, edm::EventSetup::getData(), edm::EventSetup::getHandle(), globalTrackingGeomToken_, runTauDisplay::gp, GlobalTrackingGeometry::idToDet(), cuy::ii, TrajectoryStateClosestToBeamLine::isValid(), edm::HandleBase::isValid(), lip_, maxRapidity_, minHit_, minRapidity_, FreeTrajectoryState::momentum(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::perp2(), FreeTrajectoryState::position(), ptMin_, CosmicsPD_Skims::radius, FastTimerService_cff::range, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), mathSSE::sqrt(), GeomDet::surface(), theMFToken_, tip_, Surface::toGlobal(), TrajectoryStateClosestToBeamLine::trackStateAtPCA(), bphysicsOniaDQM_cfi::vertex, and PV3DBase< T, PVType, FrameType >::z().

98  {
99  if (chargedOnly_ && tpr->charge() == 0)
100  return false; //select only if charge!=0
101  //bool testId = false;
102  //unsigned int idSize = pdgId_.size();
103  //if (idSize==0) testId = true;
104  //else for (unsigned int it=0;it!=idSize;++it){
105  //if (tpr->pdgId()==pdgId_[it]) testId = true;
106  //}
107 
109 
110  GlobalVector finalGV(0, 0, 0);
111  GlobalPoint finalGP(0, 0, 0);
112  GlobalVector momentum(0, 0, 0); //At the PCA
113  GlobalPoint vertex(0, 0, 0); //At the PCA
114  double radius(9999);
115  bool found(false);
116 
117  int ii = 0;
118  DetId::Detector det;
119  int subdet;
120 
121  edm::LogVerbatim("CosmicTrackingParticleSelector")
122  << "TOT Number of PSimHits = " << tpr->numberOfHits()
123  << ", Number of Tracker PSimHits = " << tpr->numberOfTrackerHits() << "\n";
124 
125  if (simHitsTPAssoc.isValid() == 0) {
126  edm::LogError("CosmicTrackingParticleSelector") << "Invalid handle!";
127  return false;
128  }
129  std::pair<TrackingParticleRef, TrackPSimHitRef> clusterTPpairWithDummyTP(
130  tpr, TrackPSimHitRef()); //SimHit is dummy: for simHitTPAssociationListGreater
131  // sorting only the cluster is needed
132  auto range = std::equal_range(simHitsTPAssoc->begin(),
133  simHitsTPAssoc->end(),
134  clusterTPpairWithDummyTP,
136  for (auto ip = range.first; ip != range.second; ++ip) {
137  TrackPSimHitRef it = ip->second;
138  ++ii;
139  const GeomDet* tmpDet = theGeometry->idToDet(DetId(it->detUnitId()));
140  if (!tmpDet) {
141  edm::LogVerbatim("CosmicTrackingParticleSelector")
142  << "***WARNING: PSimHit " << ii << ", no GeomDet for: " << it->detUnitId() << ". Skipping it.";
143  continue;
144  } else {
145  det = DetId(it->detUnitId()).det();
146  subdet = DetId(it->detUnitId()).subdetId();
147  }
148 
149  LocalVector lv = it->momentumAtEntry();
150  Local3DPoint lp = it->localPosition();
151  GlobalVector gv = tmpDet->surface().toGlobal(lv);
152  GlobalPoint gp = tmpDet->surface().toGlobal(lp);
153  edm::LogVerbatim("CosmicTrackingParticleSelector")
154  << "PSimHit " << ii << ", Detector = " << det << ", subdet = " << subdet << "\t Radius = " << gp.perp()
155  << ", z = " << gp.z() << "\t pt = " << gv.perp() << ", pz = " << gv.z();
156  edm::LogVerbatim("CosmicTrackingParticleSelector")
157  << "\t trackId = " << it->trackId() << ", particleType = " << it->particleType()
158  << ", processType = " << it->processType();
159 
160  // discard hits related to low energy debris from the primary particle
161  if (it->processType() != 0)
162  continue;
163 
164  if (gp.perp() < radius) {
165  found = true;
166  radius = gp.perp();
167  finalGV = gv;
168  finalGP = gp;
169  }
170  }
171  edm::LogVerbatim("CosmicTrackingParticleSelector")
172  << "\n"
173  << "FINAL State at InnerMost Hit: Radius = " << finalGP.perp() << ", z = " << finalGP.z()
174  << ", pt = " << finalGV.perp() << ", pz = " << finalGV.z();
175 
176  if (!found)
177  return false;
178  else {
179  FreeTrajectoryState ftsAtProduction(finalGP, finalGV, TrackCharge(tpr->charge()), &iSetup.getData(theMFToken_));
180  TSCBLBuilderNoMaterial tscblBuilder;
181  //as in TrackProducerAlgorithm
182  TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction, *bs);
183  if (!tsAtClosestApproach.isValid()) {
184  edm::LogVerbatim("CosmicTrackingParticleSelector")
185  << "*** WARNING in CosmicTrackingParticleSelector: tsAtClosestApproach is not valid."
186  << "\n";
187  return false;
188  } else {
189  momentum = tsAtClosestApproach.trackStateAtPCA().momentum();
190  vertex = tsAtClosestApproach.trackStateAtPCA().position();
191 
192  edm::LogVerbatim("CosmicTrackingParticleSelector")
193  << "FINAL State extrapolated at PCA: Radius = " << vertex.perp() << ", z = " << vertex.z()
194  << ", pt = " << momentum.perp() << ", pz = " << momentum.z() << "\n";
195 
196  return (tpr->numberOfTrackerLayers() >= minHit_ && sqrt(momentum.perp2()) >= ptMin_ &&
197  momentum.eta() >= minRapidity_ && momentum.eta() <= maxRapidity_ && sqrt(vertex.perp2()) <= tip_ &&
198  fabs(vertex.z()) <= lip_);
199  }
200  }
201  }
Log< level::Info, true > LogVerbatim
T perp() const
Definition: PV3DBase.h:69
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theMFToken_
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
T z() const
Definition: PV3DBase.h:61
Log< level::Error, false > LogError
const GeomDet * idToDet(DetId) const override
GlobalPoint position() const
int TrackCharge
Definition: TrackCharge.h:4
T sqrt(T t)
Definition: SSEVec.h:19
GlobalVector momentum() const
bool getData(T &iHolder) const
Definition: EventSetup.h:122
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
ii
Definition: cuy.py:589
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
Definition: DetId.h:17
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > globalTrackingGeomToken_
Detector
Definition: DetId.h:24
bool isValid() const
Definition: HandleBase.h:70
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef

◆ select()

void CosmicTrackingParticleSelector::select ( const edm::Handle< collection > &  c,
const edm::Event event,
const edm::EventSetup setup 
)
inline

Definition at line 77 of file CosmicTrackingParticleSelector.h.

References pwdgSkimBPark_cfi::beamSpot, beamSpotToken_, c, edmPickEvents::event, selected_, and singleTopDQM_cfi::setup.

77  {
78  selected_.clear();
80  event.getByToken(beamSpotToken_, beamSpot);
81  for (TrackingParticleCollection::const_iterator itp = c->begin(); itp != c->end(); ++itp)
82  if (operator()(TrackingParticleRef(c, itp - c->begin()), beamSpot.product(), event, setup)) {
83  selected_.push_back(&*itp);
84  }
85  }
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
edm::Ref< TrackingParticleCollection > TrackingParticleRef

◆ size()

size_t CosmicTrackingParticleSelector::size ( void  ) const
inline

Member Data Documentation

◆ beamSpotToken_

edm::EDGetTokenT<reco::BeamSpot> CosmicTrackingParticleSelector::beamSpotToken_
private

Definition at line 215 of file CosmicTrackingParticleSelector.h.

Referenced by select().

◆ chargedOnly_

bool CosmicTrackingParticleSelector::chargedOnly_
private

Definition at line 212 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

◆ globalTrackingGeomToken_

edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> CosmicTrackingParticleSelector::globalTrackingGeomToken_
private

Definition at line 216 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

◆ lip_

double CosmicTrackingParticleSelector::lip_
private

Definition at line 210 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

◆ maxRapidity_

double CosmicTrackingParticleSelector::maxRapidity_
private

Definition at line 208 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

◆ minHit_

int CosmicTrackingParticleSelector::minHit_
private

Definition at line 211 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

◆ minRapidity_

double CosmicTrackingParticleSelector::minRapidity_
private

Definition at line 207 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

◆ pdgId_

std::vector<int> CosmicTrackingParticleSelector::pdgId_
private

Definition at line 213 of file CosmicTrackingParticleSelector.h.

◆ ptMin_

double CosmicTrackingParticleSelector::ptMin_
private

Definition at line 206 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

◆ selected_

container CosmicTrackingParticleSelector::selected_
private

Definition at line 214 of file CosmicTrackingParticleSelector.h.

Referenced by begin(), end(), select(), and size().

◆ simHitsTPAssoc

edm::Handle<SimHitTPAssociationProducer::SimHitTPAssociationList> CosmicTrackingParticleSelector::simHitsTPAssoc
mutableprivate

Definition at line 219 of file CosmicTrackingParticleSelector.h.

Referenced by initEvent(), and operator()().

◆ theMFToken_

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> CosmicTrackingParticleSelector::theMFToken_
private

Definition at line 217 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

◆ tip_

double CosmicTrackingParticleSelector::tip_
private

Definition at line 209 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().