CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackMaker.cc
Go to the documentation of this file.
11 
13 using std::vector;
14 using reco::Track;
15 using reco::TrackBase;
16 
18 
19  TrackCollection_ = iCollector.consumes<edm::View<reco::Track> >(iConfig.getParameter<edm::InputTag>("trackInputTag"));
20 
21 }
22 
23 void TrackMaker::SetVars(HWW& hww, const edm::Event& iEvent, const edm::EventSetup& iSetup){
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 
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  for(trackingRecHit_iterator ihit = i->recHitsBegin(); ihit != i->recHitsEnd(); ++ihit){
141  if(i_layer > 1) break;
142  int k = ihit-i->recHitsBegin();
143  hit_pattern = pattern.getHitPattern(reco::HitPattern::TRACK_HITS, k);
144  valid_hit = pattern.validHitFilter(hit_pattern);
145  pixel_hit = pattern.pixelHitFilter(hit_pattern);
146  strip_hit = pattern.stripHitFilter(hit_pattern);
147  if(!valid_hit) continue;
148  if(pixel_hit){
149  const SiPixelRecHit *pixel_hit_cast = dynamic_cast<const SiPixelRecHit*>(&(**ihit));
150  if (pixel_hit_cast == NULL){
151  LogInfo("OutputInfo") << " pixel_hit_cast is NULL, TrackMaker quitting";
152  return;
153  }
154  if(i_layer == 1){
155  i_layer++;
156  }
157  }
158  else if (strip_hit){
159  const SiStripRecHit1D *strip_hit_cast = dynamic_cast<const SiStripRecHit1D*>(&(**ihit));
160  const SiStripRecHit2D *strip2d_hit_cast = dynamic_cast<const SiStripRecHit2D*>(&(**ihit));
161  ClusterRef cluster;
162  if(strip_hit_cast == NULL) {
163  if(strip2d_hit_cast == NULL) {
164  LogInfo("OutputInfo") << " strip2d_hit_cast is NULL, TrackMaker quitting";
165  return;
166  }
167  cluster = strip2d_hit_cast->cluster();
168  }
169  else {
170  cluster = strip_hit_cast->cluster();
171  }
172  int cluster_size = (int)cluster->amplitudes().size();
173  int cluster_charge = 0;
174  double cluster_weight_size = 0.0;
175  int max_strip_i = std::max_element(cluster->amplitudes().begin(),cluster->amplitudes().end())-cluster->amplitudes().begin();
176  for(int istrip = 0; istrip < cluster_size; istrip++){
177  cluster_charge += (int)cluster->amplitudes()[istrip];
178  cluster_weight_size += (istrip-max_strip_i)*(istrip-max_strip_i)*(cluster->amplitudes()[istrip]);
179  }
180  cluster_weight_size = sqrt(cluster_weight_size/cluster_charge);
181  if(i_layer == 1){
182  i_layer++;
183  }
184  }
185  }
186  }
187 
188  hww.trks_nlayers() .push_back( i->hitPattern().trackerLayersWithMeasurement() );
189 
190  } // End loop on tracks
191 
192 }
ClusterRef cluster() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< float > & trks_phiErr()
Definition: HWW.cc:83
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
static bool pixelHitFilter(uint16_t pattern)
Definition: HitPattern.h:505
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:449
TrackMaker(const edm::ParameterSet &, edm::ConsumesCollector)
Definition: TrackMaker.cc:17
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
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:698
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
Definition: Cylinder.h:51
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
int iEvent
Definition: GenABIO.cc:230
void Load_trks_charge()
Definition: HWW.cc:866
T sqrt(T t)
Definition: SSEVec.h:48
void Load_trks_z0()
Definition: HWW.cc:845
static bool stripHitFilter(uint16_t pattern)
Definition: HitPattern.h:536
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
ClusterRef cluster() const
#define M_PI
std::vector< int > & trks_qualityMask()
Definition: HWW.cc:91
Definition: HWW.h:12
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.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
void Load_trks_valid_pixelhits()
Definition: HWW.cc:842
std::vector< float > & trks_d0Err()
Definition: HWW.cc:79
int numberOfValidPixelHits() const
Definition: HitPattern.h:749
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: TrackMaker.cc:23
void Load_trks_z0Err()
Definition: HWW.cc:848
std::vector< int > & trks_nlayers()
Definition: HWW.cc:59
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
void Load_trks_d0Err()
Definition: HWW.cc:854
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:456
std::vector< int > & trks_charge()
Definition: HWW.cc:95
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
math::PtEtaPhiELorentzVectorF LorentzVector
Our base class.
Definition: SiPixelRecHit.h:23