CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_
 
double lip_
 
double maxRapidity_
 
int minHit_
 
double minRapidity_
 
std::vector< int > pdgId_
 
double ptMin_
 
container selected_
 
edm::Handle
< SimHitTPAssociationProducer::SimHitTPAssociationList
simHitsTPAssoc
 
double tip_
 

Detailed Description

Definition at line 39 of file CosmicTrackingParticleSelector.h.

Member Typedef Documentation

Definition at line 42 of file CosmicTrackingParticleSelector.h.

typedef container::const_iterator CosmicTrackingParticleSelector::const_iterator

Definition at line 44 of file CosmicTrackingParticleSelector.h.

Definition at line 43 of file CosmicTrackingParticleSelector.h.

Constructor & Destructor Documentation

CosmicTrackingParticleSelector::CosmicTrackingParticleSelector ( )
inline

Definition at line 46 of file CosmicTrackingParticleSelector.h.

46 {}
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 48 of file CosmicTrackingParticleSelector.h.

50  :
52  tip_( tip ), lip_( lip ), minHit_( minHit ), chargedOnly_(chargedOnly), pdgId_( pdgId ) { }
CosmicTrackingParticleSelector::CosmicTrackingParticleSelector ( const edm::ParameterSet cfg,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 55 of file CosmicTrackingParticleSelector.h.

55  :
56  ptMin_(cfg.getParameter<double>("ptMin")),
57  minRapidity_(cfg.getParameter<double>("minRapidity")),
58  maxRapidity_(cfg.getParameter<double>("maxRapidity")),
59  tip_(cfg.getParameter<double>("tip")),
60  lip_(cfg.getParameter<double>("lip")),
61  minHit_(cfg.getParameter<int>("minHit")),
62  chargedOnly_(cfg.getParameter<bool>("chargedOnly")),
63  pdgId_(cfg.getParameter<std::vector<int> >("pdgId")),
64  beamSpotToken_(iC.consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))) { }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_

Member Function Documentation

const_iterator CosmicTrackingParticleSelector::begin ( void  ) const
inline

Definition at line 78 of file CosmicTrackingParticleSelector.h.

References selected_.

78 { return selected_.begin(); }
const_iterator CosmicTrackingParticleSelector::end ( void  ) const
inline
void CosmicTrackingParticleSelector::initEvent ( edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList simHitsTPAssocToSet) const
inline

Definition at line 81 of file CosmicTrackingParticleSelector.h.

References simHitsTPAssoc.

Referenced by MultiTrackValidator::analyze().

81  {
82  simHitsTPAssoc = simHitsTPAssocToSet;
83  }
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
bool CosmicTrackingParticleSelector::operator() ( const TrackingParticleRef  tpr,
const reco::BeamSpot bs,
const edm::Event iEvent,
const edm::EventSetup iSetup 
) const
inline

Definition at line 86 of file CosmicTrackingParticleSelector.h.

References chargedOnly_, PV3DBase< T, PVType, FrameType >::eta(), newFWLiteAna::found, edm::EventSetup::get(), 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(), edm::ESHandle< class >::product(), ptMin_, CosmicsPD_Skims::radius, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), mathSSE::sqrt(), GeomDet::surface(), tip_, Surface::toGlobal(), patCandidatesForDimuonsSequences_cff::tracker, TrajectoryStateClosestToBeamLine::trackStateAtPCA(), and PV3DBase< T, PVType, FrameType >::z().

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

Definition at line 67 of file CosmicTrackingParticleSelector.h.

References SiPixelRawToDigiRegional_cfi::beamSpot, beamSpotToken_, event(), edm::Handle< T >::product(), selected_, and HcalObjRepresent::setup().

Referenced by Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Views.LineDecayView.LineDecayContainer::mousePressEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), and Vispa.Views.AbstractView.AbstractView::restoreSelection().

67  {
68  selected_.clear();
70  event.getByToken(beamSpotToken_, beamSpot);
71  for( TrackingParticleCollection::const_iterator itp = c->begin();
72  itp != c->end(); ++ itp )
73  if ( operator()(TrackingParticleRef(c,itp-c->begin()),beamSpot.product(),event,setup) ) {
74  selected_.push_back( & * itp );
75  }
76  }
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
T const * product() const
Definition: Handle.h:81
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
edm::Ref< TrackingParticleCollection > TrackingParticleRef
size_t CosmicTrackingParticleSelector::size ( void  ) const
inline

Definition at line 194 of file CosmicTrackingParticleSelector.h.

References selected_.

194 { return selected_.size(); }

Member Data Documentation

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

Definition at line 207 of file CosmicTrackingParticleSelector.h.

Referenced by select().

bool CosmicTrackingParticleSelector::chargedOnly_
private

Definition at line 204 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

double CosmicTrackingParticleSelector::lip_
private

Definition at line 202 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

double CosmicTrackingParticleSelector::maxRapidity_
private

Definition at line 200 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

int CosmicTrackingParticleSelector::minHit_
private

Definition at line 203 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

double CosmicTrackingParticleSelector::minRapidity_
private

Definition at line 199 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

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

Definition at line 205 of file CosmicTrackingParticleSelector.h.

double CosmicTrackingParticleSelector::ptMin_
private

Definition at line 198 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().

container CosmicTrackingParticleSelector::selected_
private

Definition at line 206 of file CosmicTrackingParticleSelector.h.

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

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

Definition at line 209 of file CosmicTrackingParticleSelector.h.

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

double CosmicTrackingParticleSelector::tip_
private

Definition at line 201 of file CosmicTrackingParticleSelector.h.

Referenced by operator()().