CMS 3D CMS Logo

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

#include <TrackMaker.h>

Public Member Functions

void SetVars (HWW &, const edm::Event &, const edm::EventSetup &)
 
 TrackMaker (const edm::ParameterSet &, edm::ConsumesCollector)
 

Public Attributes

edm::EDGetTokenT< edm::View
< reco::Track > > 
TrackCollection_
 

Detailed Description

Definition at line 8 of file TrackMaker.h.

Constructor & Destructor Documentation

TrackMaker::TrackMaker ( const edm::ParameterSet iConfig,
edm::ConsumesCollector  iCollector 
)

Definition at line 17 of file TrackMaker.cc.

References edm::ConsumesCollector::consumes(), edm::ParameterSet::getParameter(), and TrackCollection_.

17  {
18 
19  TrackCollection_ = iCollector.consumes<edm::View<reco::Track> >(iConfig.getParameter<edm::InputTag>("trackInputTag"));
20 
21 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::Track > > TrackCollection_
Definition: TrackMaker.h:15

Member Function Documentation

void TrackMaker::SetVars ( HWW hww,
const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 23 of file TrackMaker.cc.

References alongMomentum, AnalyticalPropagator_cfi::AnalyticalPropagator, Reference_intrackfit_cff::barrel, Plane::build(), newFWLiteAna::build, edm::EventSetup::get(), edm::Event::getByToken(), reco::HitPattern::getHitPattern(), i, gen::k, HWW::Load_trks_charge(), HWW::Load_trks_chi2(), HWW::Load_trks_d0(), HWW::Load_trks_d0Err(), HWW::Load_trks_d0phiCov(), HWW::Load_trks_etaErr(), HWW::Load_trks_ndof(), HWW::Load_trks_nlayers(), HWW::Load_trks_phiErr(), HWW::Load_trks_qualityMask(), HWW::Load_trks_trk_p4(), HWW::Load_trks_valid_pixelhits(), HWW::Load_trks_vertex_p4(), HWW::Load_trks_z0(), HWW::Load_trks_z0Err(), M_PI, NULL, reco::HitPattern::numberOfValidPixelHits(), listBenchmarks::pattern, reco::HitPattern::pixelHitFilter(), CosmicsPD_Skims::radius, mathSSE::sqrt(), reco::HitPattern::stripHitFilter(), TrackCollection_, HWW::trks_charge(), HWW::trks_chi2(), HWW::trks_d0(), HWW::trks_d0Err(), HWW::trks_d0phiCov(), HWW::trks_etaErr(), HWW::trks_ndof(), HWW::trks_nlayers(), HWW::trks_phiErr(), HWW::trks_qualityMask(), HWW::trks_trk_p4(), HWW::trks_valid_pixelhits(), HWW::trks_vertex_p4(), HWW::trks_z0(), HWW::trks_z0Err(), and reco::HitPattern::validHitFilter().

Referenced by HWWAnalyzer::analyze().

23  {
24 
25  using namespace edm;
26 
27  hww.Load_trks_trk_p4();
28  hww.Load_trks_vertex_p4();
29  hww.Load_trks_d0();
30  hww.Load_trks_chi2();
31  hww.Load_trks_ndof();
32  hww.Load_trks_z0();
33  hww.Load_trks_d0Err();
34  hww.Load_trks_z0Err();
35  hww.Load_trks_etaErr();
36  hww.Load_trks_phiErr();
37  hww.Load_trks_d0phiCov();
38  hww.Load_trks_charge();
41  hww.Load_trks_nlayers();
42 
43 
45  // Get Tracks //
47 
49  iEvent.getByToken(TrackCollection_, track_h);
50  if( !track_h.isValid() ) {
51  LogInfo("OutputInfo") << " failed to retrieve track collection";
52  LogInfo("OutputInfo") << " TrackMaker cannot continue...!";
53  return;
54  }
55 
57  // Get B Field //
59 
60  ESHandle<MagneticField> theMagField;
61  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
62  if( !theMagField.isValid() ) {
63  LogInfo("OutputInfo") << " failed to retrieve the magnetic field";
64  LogInfo("OutputInfo") << " TrackMaker cannot continue...!";
65  return;
66  }
67  const MagneticField* bf = theMagField.product();
68 
70  // Get Tracker Geometry //
72 
74  iSetup.get<TrackerDigiGeometryRecord>().get(theG);
75 
77  // Loop over Tracks //
79 
80  View<reco::Track>::const_iterator tracks_end = track_h->end();
81  unsigned int iTIndex=-1;
82  for (View<reco::Track>::const_iterator i = track_h->begin(); i != tracks_end; ++i) {
83 
84  iTIndex++;
85 
86  hww.trks_trk_p4() .push_back( LorentzVector( i->px(), i->py(), i->pz(), i->p() ) );
87  hww.trks_vertex_p4() .push_back( LorentzVector(i->vx(),i->vy(), i->vz(), 0.) );
88  hww.trks_d0() .push_back( i->d0() );
89  hww.trks_chi2() .push_back( i->chi2() );
90  hww.trks_ndof() .push_back( i->ndof() );
91  hww.trks_z0() .push_back( i->dz() );
92  hww.trks_d0Err() .push_back( i->d0Error() );
93  hww.trks_z0Err() .push_back( i->dzError() );
94  hww.trks_etaErr() .push_back( i->etaError() );
95  hww.trks_phiErr() .push_back( i->phiError() );
96  hww.trks_d0phiCov() .push_back( -i->covariance(TrackBase::i_phi, TrackBase::i_dxy) );
97  hww.trks_charge() .push_back( i->charge() );
98  hww.trks_qualityMask() .push_back( i->qualityMask() );
99 
100  GlobalPoint tpVertex ( i->vx(), i->vy(), i->vz() );
101  GlobalVector tpMomentum ( i->px(), i->py(), i->pz() );
102  int tpCharge ( i->charge() );
103 
104  FreeTrajectoryState fts ( tpVertex, tpMomentum, tpCharge, bf);
105 
106  const float zdist = 314.;
107  const float radius = 130.;
108  const float corner = 1.479;
109 
112  Cylinder::CylinderPointer barrel = Cylinder::build( Cylinder::PositionType (0, 0, 0), Cylinder::RotationType (), radius);
115 
116  if( i->eta() < -corner ) {
117  tsos = myAP.propagate( fts, *lendcap);
118  }
119  else if( fabs(i->eta()) < corner ) {
120  tsos = myAP.propagate( fts, *barrel);
121  }
122  else if( i->eta() > corner ) {
123  tsos = myAP.propagate( fts, *rendcap);
124  }
125 
126  const reco::HitPattern& pattern = i->hitPattern();
127  hww.trks_valid_pixelhits() .push_back(pattern.numberOfValidPixelHits());
128 
129  if(i->extra().isAvailable()) {
130  bool valid_hit = false;
131  uint32_t hit_pattern;
132  int i_layer = 1;
133  bool pixel_hit = false;
134  bool strip_hit = false;
135 
136 
138  typedef Ref<edmNew::DetSetVector<SiPixelCluster>, SiPixelCluster > pixel_ClusterRef;
139 
140 
141  for(trackingRecHit_iterator ihit = i->recHitsBegin(); ihit != i->recHitsEnd(); ++ihit){
142  if(i_layer > 1) break;
143  int k = ihit-i->recHitsBegin();
144  hit_pattern = pattern.getHitPattern(k);
145  valid_hit = pattern.validHitFilter(hit_pattern);
146  pixel_hit = pattern.pixelHitFilter(hit_pattern);
147  strip_hit = pattern.stripHitFilter(hit_pattern);
148  if(!valid_hit) continue;
149  if(pixel_hit){
150  const SiPixelRecHit *pixel_hit_cast = dynamic_cast<const SiPixelRecHit*>(&(**ihit));
151  if (pixel_hit_cast == NULL){
152  LogInfo("OutputInfo") << " pixel_hit_cast is NULL, TrackMaker quitting";
153  return;
154  }
155  if(i_layer == 1){
156  i_layer++;
157 
158  }
159  }
160  else if (strip_hit){
161  const SiStripRecHit1D *strip_hit_cast = dynamic_cast<const SiStripRecHit1D*>(&(**ihit));
162  const SiStripRecHit2D *strip2d_hit_cast = dynamic_cast<const SiStripRecHit2D*>(&(**ihit));
163  ClusterRef cluster;
164  if(strip_hit_cast == NULL) {
165  if(strip2d_hit_cast == NULL) {
166  LogInfo("OutputInfo") << " strip2d_hit_cast is NULL, TrackMaker quitting";
167  return;
168  }
169  cluster = strip2d_hit_cast->cluster();
170  }
171  else {
172  cluster = strip_hit_cast->cluster();
173  }
174  int cluster_size = (int)cluster->amplitudes().size();
175  int cluster_charge = 0;
176  double cluster_weight_size = 0.0;
177  int max_strip_i = std::max_element(cluster->amplitudes().begin(),cluster->amplitudes().end())-cluster->amplitudes().begin();
178  for(int istrip = 0; istrip < cluster_size; istrip++){
179  cluster_charge += (int)cluster->amplitudes().at(istrip);
180  cluster_weight_size += (istrip-max_strip_i)*(istrip-max_strip_i)*(cluster->amplitudes().at(istrip));
181  }
182  cluster_weight_size = sqrt(cluster_weight_size/cluster_charge);
183  if(i_layer == 1){
184  i_layer++;
185  }
186  }
187  }
188  }
189 
190  hww.trks_nlayers() .push_back( i->hitPattern().trackerLayersWithMeasurement() );
191 
192  } // End loop on tracks
193 
194 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
std::vector< float > & trks_phiErr()
Definition: HWW.cc:83
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
std::vector< int > & trks_valid_pixelhits()
Definition: HWW.cc:63
void Load_trks_d0phiCov()
Definition: HWW.cc:860
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::vector< LorentzVector > & trks_vertex_p4()
Definition: HWW.cc:43
std::vector< LorentzVector > & trks_trk_p4()
Definition: HWW.cc:39
void Load_trks_etaErr()
Definition: HWW.cc:851
#define NULL
Definition: scimark2.h:8
void Load_trks_qualityMask()
Definition: HWW.cc:863
std::vector< float > & trks_d0()
Definition: HWW.cc:55
void Load_trks_trk_p4()
Definition: HWW.cc:824
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:30
std::vector< float > & trks_chi2()
Definition: HWW.cc:47
std::vector< float > & trks_z0Err()
Definition: HWW.cc:71
std::vector< float > & trks_z0()
Definition: HWW.cc:67
void Load_trks_charge()
Definition: HWW.cc:866
T sqrt(T t)
Definition: SSEVec.h:48
static PlanePointer build(Args &&...args)
Definition: Plane.h:36
void Load_trks_z0()
Definition: HWW.cc:845
static bool pixelHitFilter(uint32_t pattern)
Definition: HitPattern.h:419
edm::EDGetTokenT< edm::View< reco::Track > > TrackCollection_
Definition: TrackMaker.h:15
std::vector< float > & trks_ndof()
Definition: HWW.cc:51
void Load_trks_d0()
Definition: HWW.cc:836
void Load_trks_chi2()
Definition: HWW.cc:830
static bool validHitFilter(uint32_t pattern)
Definition: HitPattern.h:564
#define M_PI
std::vector< int > & trks_qualityMask()
Definition: HWW.cc:91
int k[5][pyjets_maxn]
void Load_trks_vertex_p4()
Definition: HWW.cc:827
std::vector< float > & trks_d0phiCov()
Definition: HWW.cc:87
std::vector< float > & trks_etaErr()
Definition: HWW.cc:75
void Load_trks_phiErr()
Definition: HWW.cc:857
void Load_trks_ndof()
Definition: HWW.cc:833
void Load_trks_nlayers()
Definition: HWW.cc:839
const T & get() const
Definition: EventSetup.h:55
Pixel cluster – collection of neighboring pixels above threshold.
void Load_trks_valid_pixelhits()
Definition: HWW.cc:842
static bool stripHitFilter(uint32_t pattern)
Definition: HitPattern.h:441
std::vector< float > & trks_d0Err()
Definition: HWW.cc:79
int numberOfValidPixelHits() const
Definition: HitPattern.h:601
void Load_trks_z0Err()
Definition: HWW.cc:848
std::vector< int > & trks_nlayers()
Definition: HWW.cc:59
void Load_trks_d0Err()
Definition: HWW.cc:854
uint32_t getHitPattern(int position) const
Definition: HitPattern.cc:142
std::vector< int > & trks_charge()
Definition: HWW.cc:95
math::PtEtaPhiELorentzVectorF LorentzVector
Pixel Reconstructed Hit.

Member Data Documentation

edm::EDGetTokenT<edm::View<reco::Track> > TrackMaker::TrackCollection_

Definition at line 15 of file TrackMaker.h.

Referenced by SetVars(), and TrackMaker().