CMS 3D CMS Logo

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

#include <TrackTransformerForCosmicMuons.h>

Inheritance diagram for TrackTransformerForCosmicMuons:
TrackTransformerBase

Public Member Functions

edm::ESHandle< TrajectoryFitterfitter (bool, int, float) const
 the refitter used to refit the reco::Track More...
 
TransientTrackingRecHit::ConstRecHitContainer getTransientRecHits (const reco::TransientTrack &track) const
 
const MagneticFieldmagneticField () const
 the magnetic field More...
 
void setServices (const edm::EventSetup &) override
 set the services needed by the TrackTransformer More...
 
bool SlopeSum (const TransientTrackingRecHit::ConstRecHitContainer &) const
 calculate the sum of slopes for the track More...
 
edm::ESHandle< TrajectorySmoothersmoother (bool, int, float) const
 the smoother used to smooth the trajectory which came from the refitting step More...
 
float SumDy (const TransientTrackingRecHit::ConstRecHitContainer &) const
 decide if the track should be reversed More...
 
edm::ESHandle
< GlobalTrackingGeometry
trackingGeometry () const
 the tracking geometry More...
 
 TrackTransformerForCosmicMuons (const edm::ParameterSet &, edm::ConsumesCollector)
 Constructor. More...
 
std::vector< Trajectorytransform (const reco::Track &) const override
 Convert a reco::Track into Trajectory. More...
 
 ~TrackTransformerForCosmicMuons () override
 Destructor. More...
 
- Public Member Functions inherited from TrackTransformerBase
 TrackTransformerBase ()
 Constructor. More...
 
virtual ~TrackTransformerBase ()
 Destructor. More...
 

Private Member Functions

edm::ESHandle< Propagatorpropagator (bool, int, float) const
 

Private Attributes

unsigned long long theCacheId_GTG
 
unsigned long long theCacheId_MG
 
unsigned long long theCacheId_TC
 
unsigned long long theCacheId_TRH
 
edm::ESHandle< TrajectoryFittertheFitterIO
 
edm::ESHandle< TrajectoryFittertheFitterOI
 
const edm::ESGetToken
< TrajectoryFitter,
TrajectoryFitter::Record
theIOFitterToken
 
const edm::ESGetToken
< Propagator,
TrackingComponentsRecord
theIOpropToken
 
const edm::ESGetToken
< TrajectorySmoother,
TrajectoryFitter::Record
theIOSmootherToken
 
const edm::ESGetToken
< MagneticField,
IdealMagneticFieldRecord
theMFToken
 
edm::ESHandle< MagneticFieldtheMGField
 
edm::ESHandle
< TransientTrackingRecHitBuilder
theMuonRecHitBuilder
 
std::string theMuonRecHitBuilderName
 
const edm::ESGetToken
< TransientTrackingRecHitBuilder,
TransientRecHitRecord
theMuonRecHitBuildToken
 
const edm::ESGetToken
< TrajectoryFitter,
TrajectoryFitter::Record
theOIFitterToken
 
const edm::ESGetToken
< Propagator,
TrackingComponentsRecord
theOIpropToken
 
const edm::ESGetToken
< TrajectorySmoother,
TrajectoryFitter::Record
theOISmootherToken
 
edm::ESHandle< PropagatorthePropagatorIO
 
edm::ESHandle< PropagatorthePropagatorOI
 
bool theRPCInTheFit
 
edm::ESHandle< TrajectorySmoothertheSmootherIO
 
edm::ESHandle< TrajectorySmoothertheSmootherOI
 
const edm::ESGetToken
< TransientTrackingRecHitBuilder,
TransientRecHitRecord
theTkRecHitBuildToken
 
edm::ESHandle
< TransientTrackingRecHitBuilder
theTrackerRecHitBuilder
 
std::string theTrackerRecHitBuilderName
 
edm::ESHandle
< GlobalTrackingGeometry
theTrackingGeometry
 
const edm::ESGetToken
< GlobalTrackingGeometry,
GlobalTrackingGeometryRecord
thGlobTrackGeoToken
 

Detailed Description

Definition at line 52 of file TrackTransformerForCosmicMuons.h.

Constructor & Destructor Documentation

TrackTransformerForCosmicMuons::TrackTransformerForCosmicMuons ( const edm::ParameterSet parameterSet,
edm::ConsumesCollector  iC 
)

Constructor.

Definition at line 34 of file TrackTransformerForCosmicMuons.cc.

References edm::ParameterSet::getParameter(), theCacheId_GTG, theCacheId_MG, theCacheId_TC, theCacheId_TRH, and theRPCInTheFit.

36  : theIOpropToken(iC.esConsumes(edm::ESInputTag("", "SmartPropagatorRK"))),
37  theOIpropToken(iC.esConsumes(edm::ESInputTag("", "SmartPropagatorRKOpposite"))),
39  theMFToken(iC.esConsumes()),
40  theIOFitterToken(iC.esConsumes(edm::ESInputTag("", "KFFitterForRefitInsideOut"))),
41  theOIFitterToken(iC.esConsumes(edm::ESInputTag("", "KFSmootherForRefitInsideOut"))),
42  theIOSmootherToken(iC.esConsumes(edm::ESInputTag("", "KFFitterForRefitOutsideIn"))),
43  theOISmootherToken(iC.esConsumes(edm::ESInputTag("", "KFSmootherForRefitOutsideIn"))),
45  iC.esConsumes(edm::ESInputTag("", parameterSet.getParameter<string>("TrackerRecHitBuilder")))),
47  iC.esConsumes(edm::ESInputTag("", parameterSet.getParameter<string>("MuonRecHitBuilder")))) {
48  theRPCInTheFit = parameterSet.getParameter<bool>("RefitRPCHits");
50 }
const edm::ESGetToken< Propagator, TrackingComponentsRecord > theIOpropToken
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theMFToken
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theTkRecHitBuildToken
const edm::ESGetToken< Propagator, TrackingComponentsRecord > theOIpropToken
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > theIOSmootherToken
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theMuonRecHitBuildToken
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theOIFitterToken
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > theOISmootherToken
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theIOFitterToken
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > thGlobTrackGeoToken
TrackTransformerForCosmicMuons::~TrackTransformerForCosmicMuons ( )
override

Destructor.

Definition at line 53 of file TrackTransformerForCosmicMuons.cc.

53 {}

Member Function Documentation

ESHandle< TrajectoryFitter > TrackTransformerForCosmicMuons::fitter ( bool  up,
int  quad,
float  sumy 
) const

the refitter used to refit the reco::Track

Definition at line 199 of file TrackTransformerForCosmicMuons.cc.

References theFitterIO, and theFitterOI.

Referenced by transform().

199  {
200  if (quad == 1) {
201  if (sumy < 0)
202  return theFitterOI;
203  else
204  return theFitterIO;
205  }
206  if (quad == 2) {
207  if (sumy < 0)
208  return theFitterOI;
209  else
210  return theFitterIO;
211  }
212  if (quad == 3) {
213  if (sumy > 0)
214  return theFitterOI;
215  else
216  return theFitterIO;
217  }
218  if (quad == 4) {
219  if (sumy > 0)
220  return theFitterOI;
221  else
222  return theFitterIO;
223  }
224 
225  if (up)
226  return theFitterOI;
227  else
228  return theFitterIO;
229 }
Definition: BitonicSort.h:7
edm::ESHandle< TrajectoryFitter > theFitterOI
edm::ESHandle< TrajectoryFitter > theFitterIO
TransientTrackingRecHit::ConstRecHitContainer TrackTransformerForCosmicMuons::getTransientRecHits ( const reco::TransientTrack track) const

if ( quad1 && slopeSum < 0) printout = true;

if ( quad3 && slopeSum > 0) printout = true; if ( quad4 && slopeSum < 0) printout = true;

Definition at line 98 of file TrackTransformerForCosmicMuons.cc.

References filterCSVwithJSON::copy, MuonSubdetId::CSC, CSCDetId, DetId::det(), MuonSubdetId::DT, LogTrace, DetId::Muon, reco::TransientTrack::recHitsBegin(), reco::TransientTrack::recHitsEnd(), MuonSubdetId::RPC, RPCDetId, SlopeSum(), DetId::subdetId(), theMuonRecHitBuilder, theRPCInTheFit, trackingGeometry(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

99  {
102 
103  bool printout = false;
104 
105  bool quad1 = false;
106  bool quad2 = false;
107  bool quad3 = false;
108  bool quad4 = false;
109 
110  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit)
111  if ((*hit)->isValid())
112  if ((*hit)->geographicalId().det() == DetId::Muon) {
113  if ((*hit)->geographicalId().subdetId() == 3 && !theRPCInTheFit) {
114  LogTrace("Reco|TrackingTools|TrackTransformer") << "RPC Rec Hit discarged";
115  continue;
116  }
117  staHits.push_back(theMuonRecHitBuilder->build(&**hit));
118  DetId hitId = staHits.back()->geographicalId();
119  GlobalPoint glbpoint = trackingGeometry()->idToDet(hitId)->position();
120  float gpy = glbpoint.y();
121  float gpz = glbpoint.z();
122  // if (gpy != 0 && gpz !=0) slopeSum += gpy / gpz;
123 
124  if (gpy > 0 && gpz > 0)
125  quad1 = true;
126  else if (gpy > 0 && gpz < 0)
127  quad2 = true;
128  else if (gpy < 0 && gpz < 0)
129  quad3 = true;
130  else if (gpy < 0 && gpz > 0)
131  quad4 = true;
132  else
133  return tkHits;
134  }
135 
136  if (staHits.empty())
137  return staHits;
138 
139  if (quad1 && quad2)
140  return tkHits;
141  if (quad1 && quad3)
142  return tkHits;
143  if (quad1 && quad4)
144  return tkHits;
145  if (quad2 && quad3)
146  return tkHits;
147  if (quad2 && quad4)
148  return tkHits;
149  if (quad3 && quad4)
150  return tkHits;
151 
152  bool doReverse = staHits.front()->globalPosition().y() > 0 ? true : false;
153 
154  if (quad1)
155  doReverse = SlopeSum(staHits);
156  if (quad2)
157  doReverse = SlopeSum(staHits);
158  if (quad3)
159  doReverse = SlopeSum(staHits);
160  if (quad4)
161  doReverse = SlopeSum(staHits);
162  if (doReverse) {
163  reverse(staHits.begin(), staHits.end());
164  }
165 
166  copy(staHits.begin(), staHits.end(), back_inserter(tkHits));
167 
169  // if ( quad2 && slopeSum > 0) printout = true;
172  // swap = printout;
173 
174  printout = quad1;
175 
176  if (printout)
177  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator hit = tkHits.begin(); hit != tkHits.end();
178  ++hit) {
179  DetId hitId = (*hit)->geographicalId();
180  GlobalPoint glbpoint = trackingGeometry()->idToDet(hitId)->position();
181 
182  if (hitId.det() == DetId::Muon) {
183  if (hitId.subdetId() == MuonSubdetId::DT)
184  LogTrace("TrackFitters") << glbpoint << " I am DT " << DTWireId(hitId);
185  // std::cout<< glbpoint << " I am DT " << DTWireId(hitId)<<std::endl;
186  else if (hitId.subdetId() == MuonSubdetId::CSC)
187  LogTrace("TrackFitters") << glbpoint << " I am CSC " << CSCDetId(hitId);
188  // std::cout<< glbpoint << " I am CSC " << CSCDetId(hitId)<<std::endl;
189  else if (hitId.subdetId() == MuonSubdetId::RPC)
190  LogTrace("TrackFitters") << glbpoint << " I am RPC " << RPCDetId(hitId);
191  else
192  LogTrace("TrackFitters") << " UNKNOWN MUON HIT TYPE ";
193  }
194  }
195  return tkHits;
196 }
T y() const
Definition: PV3DBase.h:60
#define LogTrace(id)
T z() const
Definition: PV3DBase.h:61
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
bool SlopeSum(const TransientTrackingRecHit::ConstRecHitContainer &) const
calculate the sum of slopes for the track
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
trackingRecHit_iterator recHitsEnd() const
last iterator to RecHits
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: DetId.h:17
static constexpr int RPC
Definition: MuonSubdetId.h:13
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
the tracking geometry
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12
trackingRecHit_iterator recHitsBegin() const
first iterator to RecHits
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
const MagneticField* TrackTransformerForCosmicMuons::magneticField ( ) const
inline

the magnetic field

Definition at line 66 of file TrackTransformerForCosmicMuons.h.

References theMGField.

Referenced by transform().

66 { return &*theMGField; }
edm::ESHandle< MagneticField > theMGField
ESHandle< Propagator > TrackTransformerForCosmicMuons::propagator ( bool  up,
int  quad,
float  sumy 
) const
private

Definition at line 263 of file TrackTransformerForCosmicMuons.cc.

References thePropagatorIO, and thePropagatorOI.

Referenced by transform().

263  {
264  if (quad == 1) {
265  if (sumy > 0)
266  return thePropagatorOI;
267  else
268  return thePropagatorIO;
269  }
270  if (quad == 2) {
271  if (sumy > 0)
272  return thePropagatorOI;
273  else
274  return thePropagatorIO;
275  }
276  if (quad == 3) {
277  if (sumy < 0)
278  return thePropagatorOI;
279  else
280  return thePropagatorIO;
281  }
282  if (quad == 4) {
283  if (sumy < 0)
284  return thePropagatorOI;
285  else
286  return thePropagatorIO;
287  }
288  if (up)
289  return thePropagatorIO;
290  else
291  return thePropagatorOI;
292 }
Definition: BitonicSort.h:7
edm::ESHandle< Propagator > thePropagatorIO
void TrackTransformerForCosmicMuons::setServices ( const edm::EventSetup setup)
overridevirtual

set the services needed by the TrackTransformer

Implements TrackTransformerBase.

Definition at line 55 of file TrackTransformerForCosmicMuons.cc.

References edm::EventSetup::get(), edm::EventSetup::getHandle(), LogTrace, metname, AlCaHLTBitMon_QueryRunRegistry::string, theCacheId_GTG, theCacheId_MG, theCacheId_TC, theCacheId_TRH, theFitterIO, theFitterOI, theIOFitterToken, theIOpropToken, theIOSmootherToken, theMFToken, theMGField, theMuonRecHitBuilder, theMuonRecHitBuildToken, theOIFitterToken, theOIpropToken, theOISmootherToken, thePropagatorIO, thePropagatorOI, theSmootherIO, theSmootherOI, theTkRecHitBuildToken, theTrackerRecHitBuilder, theTrackingGeometry, and thGlobTrackGeoToken.

55  {
56  const std::string metname = "Reco|TrackingTools|TrackTransformer";
57 
62 
63  unsigned long long newCacheId_TC = setup.get<TrackingComponentsRecord>().cacheIdentifier();
64 
65  if (newCacheId_TC != theCacheId_TC) {
66  LogTrace(metname) << "Tracking Component changed!";
67  theCacheId_TC = newCacheId_TC;
70  }
71 
72  // Global Tracking Geometry
73  unsigned long long newCacheId_GTG = setup.get<GlobalTrackingGeometryRecord>().cacheIdentifier();
74  if (newCacheId_GTG != theCacheId_GTG) {
75  LogTrace(metname) << "GlobalTrackingGeometry changed!";
76  theCacheId_GTG = newCacheId_GTG;
78  }
79 
80  // Magfield Field
81  unsigned long long newCacheId_MG = setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
82  if (newCacheId_MG != theCacheId_MG) {
83  LogTrace(metname) << "Magnetic Field changed!";
84  theCacheId_MG = newCacheId_MG;
86  }
87 
88  // Transient Rechit Builders
89  unsigned long long newCacheId_TRH = setup.get<TransientRecHitRecord>().cacheIdentifier();
90  if (newCacheId_TRH != theCacheId_TRH) {
91  theCacheId_TRH = newCacheId_TRH;
92  LogTrace(metname) << "TransientRecHitRecord changed!";
95  }
96 }
const edm::ESGetToken< Propagator, TrackingComponentsRecord > theIOpropToken
edm::ESHandle< Propagator > thePropagatorIO
edm::ESHandle< TrajectorySmoother > theSmootherOI
const std::string metname
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theMFToken
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
edm::ESHandle< TrajectorySmoother > theSmootherIO
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theTkRecHitBuildToken
#define LogTrace(id)
edm::ESHandle< TrajectoryFitter > theFitterOI
const edm::ESGetToken< Propagator, TrackingComponentsRecord > theOIpropToken
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > theIOSmootherToken
edm::ESHandle< TransientTrackingRecHitBuilder > theTrackerRecHitBuilder
edm::ESHandle< TrajectoryFitter > theFitterIO
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theMuonRecHitBuildToken
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theOIFitterToken
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > theOISmootherToken
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theIOFitterToken
T get() const
Definition: EventSetup.h:82
edm::ESHandle< MagneticField > theMGField
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > thGlobTrackGeoToken
bool TrackTransformerForCosmicMuons::SlopeSum ( const TransientTrackingRecHit::ConstRecHitContainer tkHits) const

calculate the sum of slopes for the track

decide if the track should be reversed

Definition at line 438 of file TrackTransformerForCosmicMuons.cc.

References DetId::det(), PVValHelper::dy, PVValHelper::dz, alignCSCRings::e, first, DetId::Muon, DetId::subdetId(), trackingGeometry(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by getTransientRecHits(), and transform().

438  {
439  bool retval = false;
440  float y1 = 0;
441  float z1 = 0;
442 
443  bool first = true;
444 
445  std::vector<float> py;
446  std::vector<float> pz;
447  // int quadrant = -1;
448 
449  float sumdy = 0;
450  float sumdz = 0;
451 
452  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator hit = tkHits.begin(); hit != tkHits.end(); ++hit) {
453  DetId hitId = (*hit)->geographicalId();
454  GlobalPoint glbpoint = trackingGeometry()->idToDet(hitId)->position();
455  if (hitId.det() != DetId::Muon || hitId.subdetId() == 3)
456  continue;
457 
458  float y2 = glbpoint.y();
459  float z2 = glbpoint.z();
460  float dslope = 0;
461  float dy = y2 - y1;
462  float dz = z2 - z1;
463 
464  // if (y2 > 0 && z2 > 0) quadrant = 1;
465  // else if (y2 > 0 && z2 < 0) quadrant = 2;
466  // else if (y2 < 0 && z2 < 0) quadrant = 3;
467  // else if (y2 < 0 && z2 > 0) quadrant = 4;
468 
469  if (fabs(dz) > 1e-3)
470  dslope = dy / dz;
471  if (!first) {
472  retval += dslope;
473  sumdy += dy;
474  sumdz += dz;
475  }
476  first = false;
477  py.push_back(y1);
478  pz.push_back(z1);
479  y1 = y2;
480  z1 = z2;
481  }
482  // std::cout<<"quadrant "<<quadrant;
483  // std::cout<<"\tsum dy = "<<sumdy;
484  // std::cout<<"\tsum dz = "<<sumdz;
485  // std::cout<<std::endl;
486 
487  if (sumdz < 0)
488  retval = true;
489 
490  return retval;
491 }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
the tracking geometry
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
ESHandle< TrajectorySmoother > TrackTransformerForCosmicMuons::smoother ( bool  up,
int  quad,
float  sumy 
) const

the smoother used to smooth the trajectory which came from the refitting step

Definition at line 232 of file TrackTransformerForCosmicMuons.cc.

References theSmootherIO, and theSmootherOI.

Referenced by transform().

232  {
233  if (quad == 1) {
234  if (sumy < 0)
235  return theSmootherOI;
236  else
237  return theSmootherIO;
238  }
239  if (quad == 2) {
240  if (sumy < 0)
241  return theSmootherOI;
242  else
243  return theSmootherIO;
244  }
245  if (quad == 3) {
246  if (sumy > 0)
247  return theSmootherOI;
248  else
249  return theSmootherIO;
250  }
251  if (quad == 4) {
252  if (sumy > 0)
253  return theSmootherOI;
254  else
255  return theSmootherIO;
256  }
257  if (up)
258  return theSmootherOI;
259  else
260  return theSmootherIO;
261 }
Definition: BitonicSort.h:7
edm::ESHandle< TrajectorySmoother > theSmootherOI
edm::ESHandle< TrajectorySmoother > theSmootherIO
float TrackTransformerForCosmicMuons::SumDy ( const TransientTrackingRecHit::ConstRecHitContainer tkHits) const

decide if the track should be reversed

Definition at line 494 of file TrackTransformerForCosmicMuons.cc.

References DetId::det(), PVValHelper::dy, PVValHelper::dz, alignCSCRings::e, first, DetId::Muon, DetId::subdetId(), trackingGeometry(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by transform().

494  {
495  bool retval = false;
496  float y1 = 0;
497  float z1 = 0;
498 
499  bool first = true;
500 
501  std::vector<float> py;
502  std::vector<float> pz;
503  // int quadrant = -1;
504 
505  float sumdy = 0;
506  float sumdz = 0;
507 
508  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator hit = tkHits.begin(); hit != tkHits.end(); ++hit) {
509  DetId hitId = (*hit)->geographicalId();
510  GlobalPoint glbpoint = trackingGeometry()->idToDet(hitId)->position();
511  if (hitId.det() != DetId::Muon || hitId.subdetId() == 3)
512  continue;
513 
514  float y2 = glbpoint.y();
515  float z2 = glbpoint.z();
516  float dslope = 0;
517  float dy = y2 - y1;
518  float dz = z2 - z1;
519 
520  // if (y2 > 0 && z2 > 0) quadrant = 1;
521  // else if (y2 > 0 && z2 < 0) quadrant = 2;
522  // else if (y2 < 0 && z2 < 0) quadrant = 3;
523  // else if (y2 < 0 && z2 > 0) quadrant = 4;
524 
525  if (fabs(dz) > 1e-3)
526  dslope = dy / dz;
527  if (!first) {
528  retval += dslope;
529  sumdy += dy;
530  sumdz += dz;
531  }
532  first = false;
533  py.push_back(y1);
534  pz.push_back(z1);
535  y1 = y2;
536  z1 = z2;
537  }
538  // std::cout<<"quadrant "<<quadrant;
539  // std::cout<<"\tsum dy = "<<sumdy;
540  // std::cout<<"\tsum dz = "<<sumdz;
541  // std::cout<<std::endl;
542 
543  return sumdy;
544 }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
the tracking geometry
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
edm::ESHandle<GlobalTrackingGeometry> TrackTransformerForCosmicMuons::trackingGeometry ( ) const
inline

the tracking geometry

Definition at line 69 of file TrackTransformerForCosmicMuons.h.

References theTrackingGeometry.

Referenced by getTransientRecHits(), SlopeSum(), SumDy(), and transform().

69 { return theTrackingGeometry; }
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
vector< Trajectory > TrackTransformerForCosmicMuons::transform ( const reco::Track tr) const
overridevirtual

Convert a reco::Track into Trajectory.

Convert Tracks into Trajectories.

Implements TrackTransformerBase.

Definition at line 295 of file TrackTransformerForCosmicMuons.cc.

References alongMomentum, filterCSVwithJSON::copy, gather_cfg::cout, MuonSubdetId::CSC, CSCDetId, MuonSubdetId::DT, fitter(), reco::Track::innerDetId(), reco::TransientTrack::innermostMeasurementState(), LogTrace, magneticField(), metname, DetId::Muon, oppositeToMomentum, reco::Track::outerDetId(), reco::TransientTrack::outermostMeasurementState(), propagator(), SiPixelPI::quadrant(), reco::TransientTrack::recHitsBegin(), reco::TransientTrack::recHitsEnd(), fileCollector::seed, SlopeSum(), smoother(), AlCaHLTBitMon_QueryRunRegistry::string, DetId::subdetId(), SumDy(), theMuonRecHitBuilder, theRPCInTheFit, reco::TransientTrack::track(), HLT_FULL_cff::track, trackingGeometry(), HLT_FULL_cff::trajectories, up, PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

295  {
296  const std::string metname = "Reco|TrackingTools|TrackTransformer";
297 
299 
300  // Build the transient Rechits
301  TransientTrackingRecHit::ConstRecHitContainer recHitsForReFit; // = getTransientRecHits(track);
303 
304  bool quad1 = false;
305  bool quad2 = false;
306  bool quad3 = false;
307  bool quad4 = false;
308  int quadrant = 0;
309 
310  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit)
311  if ((*hit)->isValid())
312  if ((*hit)->geographicalId().det() == DetId::Muon) {
313  if ((*hit)->geographicalId().subdetId() == 3 && !theRPCInTheFit) {
314  LogTrace("Reco|TrackingTools|TrackTransformer") << "RPC Rec Hit discarged";
315  continue;
316  }
317  staHits.push_back(theMuonRecHitBuilder->build(&**hit));
318  DetId hitId = staHits.back()->geographicalId();
319  GlobalPoint glbpoint = trackingGeometry()->idToDet(hitId)->position();
320  float gpy = glbpoint.y();
321  float gpz = glbpoint.z();
322  // if (gpy != 0 && gpz !=0) slopeSum += gpy / gpz;
323 
324  if (gpy > 0 && gpz > 0) {
325  quad1 = true;
326  quadrant = 1;
327  } else if (gpy > 0 && gpz < 0) {
328  quad2 = true;
329  quadrant = 2;
330  } else if (gpy < 0 && gpz < 0) {
331  quad3 = true;
332  quadrant = 3;
333  } else if (gpy < 0 && gpz > 0) {
334  quad4 = true;
335  quadrant = 4;
336  } else
337  return vector<Trajectory>();
338  }
339 
340  if (staHits.empty())
341  return vector<Trajectory>();
342 
343  if (quad1 && quad2)
344  return vector<Trajectory>();
345  if (quad1 && quad3)
346  return vector<Trajectory>();
347  if (quad1 && quad4)
348  return vector<Trajectory>();
349  if (quad2 && quad3)
350  return vector<Trajectory>();
351  if (quad2 && quad4)
352  return vector<Trajectory>();
353  if (quad3 && quad4)
354  return vector<Trajectory>();
355 
356  bool doReverse = false;
357 
358  if (quad1)
359  doReverse = SlopeSum(staHits);
360  if (quad2)
361  doReverse = SlopeSum(staHits);
362  if (quad3)
363  doReverse = SlopeSum(staHits);
364  if (quad4)
365  doReverse = SlopeSum(staHits);
366 
367  if (doReverse) {
368  reverse(staHits.begin(), staHits.end());
369  }
370 
371  copy(staHits.begin(), staHits.end(), back_inserter(recHitsForReFit));
372 
378 
379  if (recHitsForReFit.size() < 2)
380  return vector<Trajectory>();
381 
382  bool up = recHitsForReFit.back()->globalPosition().y() > 0 ? true : false;
383  LogTrace(metname) << "Up ? " << up;
384 
385  float sumdy = SumDy(recHitsForReFit);
386 
387  PropagationDirection propagationDirection = doReverse ? oppositeToMomentum : alongMomentum;
388  TrajectoryStateOnSurface firstTSOS =
389  doReverse ? track.outermostMeasurementState() : track.innermostMeasurementState();
390  unsigned int innerId = doReverse ? track.track().outerDetId() : track.track().innerDetId();
391 
392  LogTrace(metname) << "Prop Dir: " << propagationDirection << " FirstId " << innerId << " firstTSOS " << firstTSOS;
393 
394  TrajectorySeed seed({}, {}, propagationDirection);
395 
396  if (recHitsForReFit.front()->geographicalId() != DetId(innerId)) {
397  LogTrace(metname) << "Propagation occurring" << endl;
398  firstTSOS = propagator(up, quadrant, sumdy)->propagate(firstTSOS, recHitsForReFit.front()->det()->surface());
399  LogTrace(metname) << "Final destination: " << recHitsForReFit.front()->det()->surface().position() << endl;
400  if (!firstTSOS.isValid()) {
401  std::cout << "Propagation error! Dumping RecHits..." << std::endl;
402 
403  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator hit = recHitsForReFit.begin();
404  hit != recHitsForReFit.end();
405  ++hit) {
406  DetId hitId = (*hit)->geographicalId();
407  GlobalPoint glbpoint = trackingGeometry()->idToDet(hitId)->position();
408  if (hitId.subdetId() == MuonSubdetId::DT)
409  std::cout << glbpoint << " I am DT " << DTWireId(hitId) << std::endl;
410  else if (hitId.subdetId() == MuonSubdetId::CSC)
411  std::cout << glbpoint << " I am CSC " << CSCDetId(hitId) << std::endl;
412  }
413 
414  LogTrace(metname) << "Propagation error!" << endl;
415  return vector<Trajectory>();
416  }
417  }
418 
419  vector<Trajectory>&& trajectories = fitter(up, quadrant, sumdy)->fit(seed, recHitsForReFit, firstTSOS);
420 
421  if (trajectories.empty()) {
422  LogTrace(metname) << "No Track refitted!" << endl;
423  return vector<Trajectory>();
424  }
425 
426  Trajectory const& trajectoryBW = trajectories.front();
427 
428  vector<Trajectory> trajectoriesSM = smoother(up, quadrant, sumdy)->trajectories(trajectoryBW);
429 
430  if (trajectoriesSM.empty()) {
431  LogTrace(metname) << "No Track smoothed!" << endl;
432  }
433 
434  return trajectoriesSM;
435 }
Definition: BitonicSort.h:7
edm::ESHandle< Propagator > propagator(bool, int, float) const
const std::string metname
int quadrant(const DetId &detid, const TrackerTopology *tTopo_, bool phase_)
T y() const
Definition: PV3DBase.h:60
PropagationDirection
edm::ESHandle< TrajectoryFitter > fitter(bool, int, float) const
the refitter used to refit the reco::Track
#define LogTrace(id)
float SumDy(const TransientTrackingRecHit::ConstRecHitContainer &) const
decide if the track should be reversed
T z() const
Definition: PV3DBase.h:61
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
bool SlopeSum(const TransientTrackingRecHit::ConstRecHitContainer &) const
calculate the sum of slopes for the track
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: DetId.h:17
edm::ESHandle< TrajectorySmoother > smoother(bool, int, float) const
the smoother used to smooth the trajectory which came from the refitting step
tuple cout
Definition: gather_cfg.py:144
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
the tracking geometry
static constexpr int DT
Definition: MuonSubdetId.h:11
const MagneticField * magneticField() const
the magnetic field
static constexpr int CSC
Definition: MuonSubdetId.h:12

Member Data Documentation

unsigned long long TrackTransformerForCosmicMuons::theCacheId_GTG
private
unsigned long long TrackTransformerForCosmicMuons::theCacheId_MG
private
unsigned long long TrackTransformerForCosmicMuons::theCacheId_TC
private
unsigned long long TrackTransformerForCosmicMuons::theCacheId_TRH
private
edm::ESHandle<TrajectoryFitter> TrackTransformerForCosmicMuons::theFitterIO
private

Definition at line 114 of file TrackTransformerForCosmicMuons.h.

Referenced by fitter(), and setServices().

edm::ESHandle<TrajectoryFitter> TrackTransformerForCosmicMuons::theFitterOI
private

Definition at line 115 of file TrackTransformerForCosmicMuons.h.

Referenced by fitter(), and setServices().

const edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> TrackTransformerForCosmicMuons::theIOFitterToken
private

Definition at line 92 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

const edm::ESGetToken<Propagator, TrackingComponentsRecord> TrackTransformerForCosmicMuons::theIOpropToken
private

Definition at line 88 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

const edm::ESGetToken<TrajectorySmoother, TrajectoryFitter::Record> TrackTransformerForCosmicMuons::theIOSmootherToken
private

Definition at line 94 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> TrackTransformerForCosmicMuons::theMFToken
private

Definition at line 91 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

edm::ESHandle<MagneticField> TrackTransformerForCosmicMuons::theMGField
private

Definition at line 112 of file TrackTransformerForCosmicMuons.h.

Referenced by magneticField(), and setServices().

edm::ESHandle<TransientTrackingRecHitBuilder> TrackTransformerForCosmicMuons::theMuonRecHitBuilder
private

Definition at line 124 of file TrackTransformerForCosmicMuons.h.

Referenced by getTransientRecHits(), setServices(), and transform().

std::string TrackTransformerForCosmicMuons::theMuonRecHitBuilderName
private

Definition at line 123 of file TrackTransformerForCosmicMuons.h.

const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> TrackTransformerForCosmicMuons::theMuonRecHitBuildToken
private

Definition at line 97 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

const edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> TrackTransformerForCosmicMuons::theOIFitterToken
private

Definition at line 93 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

const edm::ESGetToken<Propagator, TrackingComponentsRecord> TrackTransformerForCosmicMuons::theOIpropToken
private

Definition at line 89 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

const edm::ESGetToken<TrajectorySmoother, TrajectoryFitter::Record> TrackTransformerForCosmicMuons::theOISmootherToken
private

Definition at line 95 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

edm::ESHandle<Propagator> TrackTransformerForCosmicMuons::thePropagatorIO
private

Definition at line 99 of file TrackTransformerForCosmicMuons.h.

Referenced by propagator(), and setServices().

edm::ESHandle<Propagator> TrackTransformerForCosmicMuons::thePropagatorOI
private

Definition at line 100 of file TrackTransformerForCosmicMuons.h.

Referenced by propagator(), and setServices().

bool TrackTransformerForCosmicMuons::theRPCInTheFit
private
edm::ESHandle<TrajectorySmoother> TrackTransformerForCosmicMuons::theSmootherIO
private

Definition at line 117 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices(), and smoother().

edm::ESHandle<TrajectorySmoother> TrackTransformerForCosmicMuons::theSmootherOI
private

Definition at line 118 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices(), and smoother().

const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> TrackTransformerForCosmicMuons::theTkRecHitBuildToken
private

Definition at line 96 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

edm::ESHandle<TransientTrackingRecHitBuilder> TrackTransformerForCosmicMuons::theTrackerRecHitBuilder
private

Definition at line 121 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().

std::string TrackTransformerForCosmicMuons::theTrackerRecHitBuilderName
private

Definition at line 120 of file TrackTransformerForCosmicMuons.h.

edm::ESHandle<GlobalTrackingGeometry> TrackTransformerForCosmicMuons::theTrackingGeometry
private

Definition at line 111 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices(), and trackingGeometry().

const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> TrackTransformerForCosmicMuons::thGlobTrackGeoToken
private

Definition at line 90 of file TrackTransformerForCosmicMuons.h.

Referenced by setServices().