CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
CosmicParametersDefinerForTP Class Reference

#include <CosmicParametersDefinerForTP.h>

Inheritance diagram for CosmicParametersDefinerForTP:
ParametersDefinerForTP

Public Member Functions

std::unique_ptr
< ParametersDefinerForTP
clone () const override
 
 CosmicParametersDefinerForTP ()
 
void initEvent (edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) override
 
virtual TrackingParticle::Vector momentum (const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
 
virtual TrackingParticle::Vector momentum (const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vertex, const LorentzVector &lv) const override
 
virtual TrackingParticle::Point vertex (const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
 
virtual TrackingParticle::Point vertex (const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vertex, const LorentzVector &lv) const override
 
virtual ~CosmicParametersDefinerForTP ()
 
- Public Member Functions inherited from ParametersDefinerForTP
virtual TrackingParticle::Vector momentum (const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Candidate &tp) const
 
 ParametersDefinerForTP ()
 
 ParametersDefinerForTP (const edm::ParameterSet &iConfig)
 
virtual TrackingParticle::Point vertex (const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Candidate &tp) const
 
virtual ~ParametersDefinerForTP ()
 

Private Attributes

edm::Handle
< SimHitTPAssociationProducer::SimHitTPAssociationList
simHitsTPAssoc
 

Additional Inherited Members

- Public Types inherited from ParametersDefinerForTP
typedef int Charge
 electric charge type More...
 
typedef math::XYZTLorentzVectorD LorentzVector
 Lorentz vector. More...
 
typedef math::XYZPointD Point
 point in the space More...
 
- Public Attributes inherited from ParametersDefinerForTP
edm::InputTag beamSpotInputTag_
 

Detailed Description

Author
Boris Mangano (UCSD) 5/7/2009

Definition at line 13 of file CosmicParametersDefinerForTP.h.

Constructor & Destructor Documentation

CosmicParametersDefinerForTP::CosmicParametersDefinerForTP ( )
inline

Definition at line 16 of file CosmicParametersDefinerForTP.h.

Referenced by clone().

16 {};
virtual CosmicParametersDefinerForTP::~CosmicParametersDefinerForTP ( )
inlinevirtual

Definition at line 17 of file CosmicParametersDefinerForTP.h.

17 {};

Member Function Documentation

std::unique_ptr<ParametersDefinerForTP> CosmicParametersDefinerForTP::clone ( void  ) const
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 36 of file CosmicParametersDefinerForTP.h.

References CosmicParametersDefinerForTP().

36 { return std::unique_ptr<CosmicParametersDefinerForTP>( new CosmicParametersDefinerForTP(*this)); }
void CosmicParametersDefinerForTP::initEvent ( edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList simHitsTPAssocToSet)
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 32 of file CosmicParametersDefinerForTP.h.

References simHitsTPAssoc.

32  {
33  simHitsTPAssoc = simHitsTPAssocToSet;
34  }
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
TrackingParticle::Vector CosmicParametersDefinerForTP::momentum ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const TrackingParticleRef tpr 
) const
overridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 23 of file CosmicParametersDefinerForTP.cc.

References newFWLiteAna::found, edm::EventSetup::get(), edm::Event::getByLabel(), TrajectoryStateClosestToBeamLine::isValid(), edm::HandleBase::isValid(), FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::perp(), CosmicsPD_Skims::radius, dt_dqm_sourceclient_common_cff::reco, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), GeomDet::surface(), Surface::toGlobal(), patCandidatesForDimuonsSequences_cff::tracker, TrajectoryStateClosestToBeamLine::trackStateAtPCA(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

23  {
24  // to add a new implementation for cosmic. For the moment, it is just as for the base class:
25  using namespace edm;
26  using namespace std;
27  using namespace reco;
28 
30  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
31 
33  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
34 
36  iEvent.getByLabel(InputTag("offlineBeamSpot"),bs);
37 
38  // cout<<"TrackingParticle pdgId = "<<tpr->pdgId()<<endl;
39  // cout<<"with tpr->vertex(): ("<<tpr->vertex().x()<<", "<<tpr->vertex().y()<<", "<<tpr->vertex().z()<<")"<<endl;
40  // cout<<"with tpr->momentum(): ("<<tpr->momentum().x()<<", "<<tpr->momentum().y()<<", "<<tpr->momentum().z()<<")"<<endl;
41 
42  GlobalVector finalGV;
43  GlobalPoint finalGP;
44  double radius(9999);
45  bool found(0);
47 
48  if (simHitsTPAssoc.isValid()==0) {
49  LogError("TrackAssociation") << "Invalid handle!";
50  return momentum;
51  }
52  std::pair<TrackingParticleRef, TrackPSimHitRef> clusterTPpairWithDummyTP(tpr,TrackPSimHitRef());//SimHit is dummy: for simHitTPAssociationListGreater
53  // sorting only the cluster is needed
54  auto range = std::equal_range(simHitsTPAssoc->begin(), simHitsTPAssoc->end(),
56  for(auto ip = range.first; ip != range.second; ++ip) {
57  TrackPSimHitRef it = ip->second;
58  const GeomDet* tmpDet = tracker->idToDet( DetId(it->detUnitId()) ) ;
59  LocalVector lv = it->momentumAtEntry();
60  Local3DPoint lp = it->localPosition ();
61  GlobalVector gv = tmpDet->surface().toGlobal( lv );
62  GlobalPoint gp = tmpDet->surface().toGlobal( lp );
63  if(gp.perp()<radius){
64  found=true;
65  radius = gp.perp();
66  finalGV = gv;
67  finalGP = gp;
68  }
69  }
70 
71  //cout<<"found = "<<found<<endl;
72  // cout<<"Closest Hit Position: ("<<finalGP.x()<<", "<<finalGP.y()<<", "<<finalGP.z()<<")"<<endl;
73  //cout<<"Momentum at Closest Hit to BL: ("<<finalGV.x()<<", "<<finalGV.y()<<", "<<finalGV.z()<<")"<<endl;
74 
75  if(found)
76  {
77  FreeTrajectoryState ftsAtProduction(finalGP,finalGV,TrackCharge(tpr->charge()),theMF.product());
78  TSCBLBuilderNoMaterial tscblBuilder;
79  TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction,*bs);//as in TrackProducerAlgorithm
80  if(tsAtClosestApproach.isValid()){
81  GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum();
82  momentum = TrackingParticle::Vector(p.x(), p.y(), p.z());
83  }
84  return momentum;
85  }
86  return momentum;
87 }
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)
virtual TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
T y() const
Definition: PV3DBase.h:63
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
int TrackCharge
Definition: TrackCharge.h:4
T z() const
Definition: PV3DBase.h:64
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
GlobalVector momentum() const
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef
math::XYZVectorD Vector
point in the space
T x() const
Definition: PV3DBase.h:62
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
virtual TrackingParticle::Vector CosmicParametersDefinerForTP::momentum ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const Charge  ch,
const Point vertex,
const LorentzVector lv 
) const
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 22 of file CosmicParametersDefinerForTP.h.

23  {
24  return TrackingParticle::Vector();
25  }
math::XYZVectorD Vector
point in the space
TrackingParticle::Point CosmicParametersDefinerForTP::vertex ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const TrackingParticleRef tpr 
) const
overridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 89 of file CosmicParametersDefinerForTP.cc.

References newFWLiteAna::found, edm::EventSetup::get(), edm::Event::getByLabel(), TrajectoryStateClosestToBeamLine::isValid(), edm::HandleBase::isValid(), PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), CosmicsPD_Skims::radius, dt_dqm_sourceclient_common_cff::reco, simHitsTPAssoc, SimHitTPAssociationProducer::simHitTPAssociationListGreater(), GeomDet::surface(), Surface::toGlobal(), patCandidatesForDimuonsSequences_cff::tracker, TrajectoryStateClosestToBeamLine::trackStateAtPCA(), findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by Tau.Tau::dxy(), and Tau.Tau::dz().

89  {
90 
91  using namespace edm;
92  using namespace std;
93  using namespace reco;
94 
96  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
97 
99  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
100 
102  iEvent.getByLabel(InputTag("offlineBeamSpot"),bs);
103 
104  GlobalVector finalGV;
105  GlobalPoint finalGP;
106  double radius(9999);
107  bool found(0);
109 
110  if (simHitsTPAssoc.isValid()==0) {
111  LogError("TrackAssociation") << "Invalid handle!";
112  return vertex;
113  }
114  std::pair<TrackingParticleRef, TrackPSimHitRef> clusterTPpairWithDummyTP(tpr,TrackPSimHitRef());//SimHit is dummy: for simHitTPAssociationListGreater
115  // sorting only the cluster is needed
116  auto range = std::equal_range(simHitsTPAssoc->begin(), simHitsTPAssoc->end(),
118  for(auto ip = range.first; ip != range.second; ++ip) {
119  TrackPSimHitRef it = ip->second;
120  const GeomDet* tmpDet = tracker->idToDet( DetId(it->detUnitId()) ) ;
121  LocalVector lv = it->momentumAtEntry();
122  Local3DPoint lp = it->localPosition ();
123  GlobalVector gv = tmpDet->surface().toGlobal( lv );
124  GlobalPoint gp = tmpDet->surface().toGlobal( lp );
125  if(gp.perp()<radius){
126  found=true;
127  radius = gp.perp();
128  finalGV = gv;
129  finalGP = gp;
130  }
131  }
132  if(found)
133  {
134  FreeTrajectoryState ftsAtProduction(finalGP,finalGV,TrackCharge(tpr->charge()),theMF.product());
135  TSCBLBuilderNoMaterial tscblBuilder;
136  TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction,*bs);//as in TrackProducerAlgorithm
137  if(tsAtClosestApproach.isValid()){
138  GlobalPoint v = tsAtClosestApproach.trackStateAtPCA().position();
139  vertex = TrackingParticle::Point(v.x()-bs->x0(),v.y()-bs->y0(),v.z()-bs->z0());
140  }
141  return vertex;
142  }
143  return vertex;
144 }
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)
T y() const
Definition: PV3DBase.h:63
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
math::XYZPointD Point
point in the space
int TrackCharge
Definition: TrackCharge.h:4
T z() const
Definition: PV3DBase.h:64
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
Definition: DetId.h:18
GlobalPoint position() const
const T & get() const
Definition: EventSetup.h:55
virtual TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrackingParticleRef &tpr) const override
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef
T x() const
Definition: PV3DBase.h:62
edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssoc
virtual TrackingParticle::Point CosmicParametersDefinerForTP::vertex ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const Charge  ch,
const Point vertex,
const LorentzVector lv 
) const
inlineoverridevirtual

Reimplemented from ParametersDefinerForTP.

Definition at line 27 of file CosmicParametersDefinerForTP.h.

Referenced by Tau.Tau::dxy(), and Tau.Tau::dz().

28  {
29  return TrackingParticle::Point();
30  }
math::XYZPointD Point
point in the space

Member Data Documentation

edm::Handle<SimHitTPAssociationProducer::SimHitTPAssociationList> CosmicParametersDefinerForTP::simHitsTPAssoc
private

Definition at line 38 of file CosmicParametersDefinerForTP.h.

Referenced by initEvent(), momentum(), and vertex().