CMS 3D CMS Logo

TrackTransformerForGlobalCosmicMuons.cc
Go to the documentation of this file.
2 
6 
9 
13 
20 
24 
29 
32 
33 using namespace std;
34 using namespace edm;
35 
38  theTrackerRecHitBuilderName = parameterSet.getParameter<string>("TrackerRecHitBuilder");
39  theMuonRecHitBuilderName = parameterSet.getParameter<string>("MuonRecHitBuilder");
40 
41  theRPCInTheFit = parameterSet.getParameter<bool>("RefitRPCHits");
42 
43  theCacheId_TC = theCacheId_GTG = theCacheId_MG = theCacheId_TRH = 0;
44  theSkipStationDT = parameterSet.getParameter<int>("SkipStationDT");
45  theSkipStationCSC = parameterSet.getParameter<int>("SkipStationCSC");
46  theSkipWheelDT = parameterSet.getParameter<int>("SkipWheelDT");
47  theTrackerSkipSystem = parameterSet.getParameter<int>("TrackerSkipSystem");
48  theTrackerSkipSection =
49  parameterSet.getParameter<int>("TrackerSkipSection"); //layer, wheel, or disk depending on the system
50 }
51 
54 
56  const std::string metname = "Reco|TrackingTools|TrackTransformer";
57 
58  setup.get<TrajectoryFitter::Record>().get("KFFitterForRefitInsideOut", theFitterIO);
59  setup.get<TrajectoryFitter::Record>().get("KFSmootherForRefitInsideOut", theSmootherIO);
60  setup.get<TrajectoryFitter::Record>().get("KFFitterForRefitOutsideIn", theFitterOI);
61  setup.get<TrajectoryFitter::Record>().get("KFSmootherForRefitOutsideIn", theSmootherOI);
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;
68  setup.get<TrackingComponentsRecord>().get("SmartPropagatorRK", thePropagatorIO);
69  setup.get<TrackingComponentsRecord>().get("SmartPropagatorRKOpposite", thePropagatorOI);
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;
77  setup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
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;
85  setup.get<IdealMagneticFieldRecord>().get(theMGField);
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!";
93  setup.get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName, theTrackerRecHitBuilder);
94  setup.get<TransientRecHitRecord>().get(theMuonRecHitBuilderName, theMuonRecHitBuilder);
95  }
96 
97  //Retrieve tracker topology from geometry
99  setup.get<TrackerTopologyRcd>().get(tTopoHand);
100  tTopo_ = tTopoHand.product();
101 }
102 
104  const reco::TransientTrack& track) const {
107 
108  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
109  if ((*hit)->isValid()) {
110  if ((*hit)->geographicalId().det() == DetId::Tracker && TrackerKeep((*hit)->geographicalId())) {
111  tkHits.push_back(theTrackerRecHitBuilder->build(&**hit));
112  } else if ((*hit)->geographicalId().det() == DetId::Muon && MuonKeep((*hit)->geographicalId())) {
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  }
119  }
120  }
121 
122  if (staHits.empty())
123  return staHits;
124 
125  /*
126  bool up = staHits.front()->globalPosition().y()>0 ? true : false;
127 
128  if(up){
129  reverse(staHits.begin(),staHits.end());
130  reverse(tkHits.begin(),tkHits.end());
131  }
132 */
133  copy(staHits.begin(), staHits.end(), back_inserter(tkHits));
134 
135  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator hit = tkHits.begin(); hit != tkHits.end(); ++hit) {
136  DetId hitId = (*hit)->geographicalId();
137  GlobalPoint glbpoint = trackingGeometry()->idToDet(hitId)->position();
138 
139  if (hitId.det() == DetId::Tracker) {
140  if (hitId.subdetId() == StripSubdetector::TIB)
141  LogTrace("TrackFitters") << glbpoint << " I am TIB " << tTopo_->tibLayer(hitId);
142  else if (hitId.subdetId() == StripSubdetector::TOB)
143  LogTrace("TrackFitters") << glbpoint << " I am TOB " << tTopo_->tobLayer(hitId);
144  else if (hitId.subdetId() == StripSubdetector::TEC)
145  LogTrace("TrackFitters") << glbpoint << " I am TEC " << tTopo_->tecWheel(hitId);
146  else if (hitId.subdetId() == StripSubdetector::TID)
147  LogTrace("TrackFitters") << glbpoint << " I am TID " << tTopo_->tidWheel(hitId);
148  else if (hitId.subdetId() == (int)PixelSubdetector::PixelBarrel)
149  LogTrace("TrackFitters") << glbpoint << " I am PixBar " << tTopo_->pxbLayer(hitId);
150  else if (hitId.subdetId() == (int)PixelSubdetector::PixelEndcap)
151  LogTrace("TrackFitters") << glbpoint << " I am PixFwd " << tTopo_->pxfDisk(hitId);
152  else
153  LogTrace("TrackFitters") << " UNKNOWN TRACKER HIT TYPE ";
154  } else if (hitId.det() == DetId::Muon) {
155  if (hitId.subdetId() == MuonSubdetId::DT)
156  LogTrace("TrackFitters") << glbpoint << " I am DT " << DTWireId(hitId);
157  else if (hitId.subdetId() == MuonSubdetId::CSC)
158  LogTrace("TrackFitters") << glbpoint << " I am CSC " << CSCDetId(hitId);
159  else if (hitId.subdetId() == MuonSubdetId::RPC)
160  LogTrace("TrackFitters") << glbpoint << " I am RPC " << RPCDetId(hitId);
161  else
162  LogTrace("TrackFitters") << " UNKNOWN MUON HIT TYPE ";
163  } else
164  LogTrace("TrackFitters") << " UNKNOWN HIT TYPE ";
165  }
166 
167  return tkHits;
168 }
169 
172  if (up)
173  return theFitterOI;
174  else
175  return theFitterIO;
176 }
177 
180  if (up)
181  return theSmootherOI;
182  else
183  return theSmootherIO;
184 }
185 
187  if (up)
188  return thePropagatorIO;
189  else
190  return thePropagatorOI;
191 }
192 
195  const std::string metname = "Reco|TrackingTools|TrackTransformer";
196 
197  reco::TransientTrack track(tr, magneticField(), trackingGeometry());
198 
199  // Build the transient Rechits
200  TransientTrackingRecHit::ConstRecHitContainer recHitsForReFit = getTransientRecHits(track);
201 
202  if (recHitsForReFit.size() < 2)
203  return vector<Trajectory>();
204 
205  bool up = recHitsForReFit.back()->globalPosition().y() > 0 ? true : false;
206  LogTrace(metname) << "Up ? " << up;
207 
208  PropagationDirection propagationDirection = up ? oppositeToMomentum : alongMomentum;
209  TrajectoryStateOnSurface firstTSOS = up ? track.outermostMeasurementState() : track.innermostMeasurementState();
210  unsigned int innerId = up ? track.track().outerDetId() : track.track().innerDetId();
211 
212  LogTrace(metname) << "Prop Dir: " << propagationDirection << " FirstId " << innerId << " firstTSOS " << firstTSOS;
213 
214  TrajectorySeed seed({}, {}, propagationDirection);
215 
216  if (recHitsForReFit.front()->geographicalId() != DetId(innerId)) {
217  LogTrace(metname) << "Propagation occurring" << endl;
218  firstTSOS = propagator(up)->propagate(firstTSOS, recHitsForReFit.front()->det()->surface());
219  LogTrace(metname) << "Final destination: " << recHitsForReFit.front()->det()->surface().position() << endl;
220  if (!firstTSOS.isValid()) {
221  LogTrace(metname) << "Propagation error!" << endl;
222  return vector<Trajectory>();
223  }
224  }
225 
226  vector<Trajectory> trajectories = fitter(up)->fit(seed, recHitsForReFit, firstTSOS);
227 
228  if (trajectories.empty()) {
229  LogTrace(metname) << "No Track refitted!" << endl;
230  return vector<Trajectory>();
231  }
232 
233  Trajectory trajectoryBW = trajectories.front();
234 
235  vector<Trajectory> trajectoriesSM = smoother(up)->trajectories(trajectoryBW);
236 
237  if (trajectoriesSM.empty()) {
238  LogTrace(metname) << "No Track smoothed!" << endl;
239  return vector<Trajectory>();
240  }
241 
242  return trajectoriesSM;
243 }
244 
245 //
246 // Selection for Tracker Hits
247 //
249  if (id.det() != DetId::Tracker)
250  return false;
251  if (theTrackerSkipSystem < 0)
252  return true;
253  bool retVal = true;
254 
255  int layer = -999;
256 
257  if (id.subdetId() == theTrackerSkipSystem)
258  layer = tTopo_->layer(id);
259 
260  if (theTrackerSkipSection > -998 && layer == theTrackerSkipSection)
261  retVal = false;
262 
263  return retVal;
264 }
265 //
266 // Selection for Muon hits
267 //
269  if (id.det() != DetId::Muon)
270  return false;
271  if (theSkipStationDT < 0 && theSkipStationCSC < 0)
272  return true;
273 
274  int station = -999;
275  int wheel = -999;
276  bool isRPC = false;
277  bool isDT = false;
278  bool isCSC = false;
279 
280  if (id.subdetId() == MuonSubdetId::DT) {
281  DTChamberId did(id.rawId());
282  station = did.station();
283  wheel = did.wheel();
284  isDT = true;
285  } else if (id.subdetId() == MuonSubdetId::CSC) {
286  CSCDetId did(id.rawId());
287  station = did.station();
288  isCSC = true;
289  } else if (id.subdetId() == MuonSubdetId::RPC) {
290  RPCDetId rpcid(id.rawId());
291  station = rpcid.station();
292  isRPC = true;
293  }
294 
295  if (isRPC && (station == theSkipStationCSC || station == theSkipStationDT))
296  return false;
297  if (isDT && station == theSkipStationDT)
298  return false;
299  if (isCSC && station == theSkipStationCSC)
300  return false;
301 
302  if (isDT && theSkipWheelDT > -998 && wheel == theSkipWheelDT)
303  return false;
304 
305  return true;
306 }
Propagator.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TrajectoryStateOnSurface.h
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
TrackTransformerForGlobalCosmicMuons::transform
std::vector< Trajectory > transform(const reco::Track &) const override
Convert a reco::Track into Trajectory.
Definition: TrackTransformerForGlobalCosmicMuons.cc:194
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11776
MessageLogger.h
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
TrackTransformerForGlobalCosmicMuons::~TrackTransformerForGlobalCosmicMuons
~TrackTransformerForGlobalCosmicMuons() override
Destructor.
Definition: TrackTransformerForGlobalCosmicMuons.cc:53
relativeConstraints.station
station
Definition: relativeConstraints.py:67
GeomDetEnumerators::isRPC
bool isRPC(GeomDetEnumerators::SubDetector m)
Definition: GeomDetEnumerators.cc:90
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackTransformerForGlobalCosmicMuons::fitter
edm::ESHandle< TrajectoryFitter > fitter(bool) const
the refitter used to refit the reco::Track
Definition: TrackTransformerForGlobalCosmicMuons.cc:171
TransientRecHitRecord.h
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
RPCDetId
Definition: RPCDetId.h:16
TrackTransformerForGlobalCosmicMuons::TrackTransformerForGlobalCosmicMuons
TrackTransformerForGlobalCosmicMuons(const edm::ParameterSet &)
Constructor.
Definition: TrackTransformerForGlobalCosmicMuons.cc:37
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
oppositeToMomentum
Definition: PropagationDirection.h:4
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
TrackTransformerForGlobalCosmicMuons::TrackerKeep
bool TrackerKeep(DetId id) const
check (via options) if this is a tracker rec hit for removal
Definition: TrackTransformerForGlobalCosmicMuons.cc:248
FastTrackerRecHitMaskProducer_cfi.trajectories
trajectories
Definition: FastTrackerRecHitMaskProducer_cfi.py:7
TransientTrack.h
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
CSCDetId.h
TrackTransformerForGlobalCosmicMuons::propagator
edm::ESHandle< Propagator > propagator(bool) const
Definition: TrackTransformerForGlobalCosmicMuons.cc:186
TrackTransformerForGlobalCosmicMuons.h
fileCollector.seed
seed
Definition: fileCollector.py:127
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TrackerTopology.h
TrackerTopologyRcd.h
Track.h
TrackFwd.h
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
DTWireId
Definition: DTWireId.h:12
reco::Track
Definition: Track.h:27
IdealMagneticFieldRecord.h
edm::ESHandle< TrackerTopology >
TrajectoryFitterRecord
Definition: TrajectoryFitterRecord.h:12
TrajectoryFitter.h
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
Point3DBase< float, GlobalTag >
GeomDetEnumerators::isCSC
bool isCSC(GeomDetEnumerators::SubDetector m)
Definition: GeomDetEnumerators.cc:88
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
GlobalTrackingGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCDetId.h
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:47
DetId::Tracker
Definition: DetId.h:25
TrackingRecHit::ConstRecHitContainer
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: TrackingRecHit.h:32
CSCDetId
Definition: CSCDetId.h:26
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
edm::EventSetup
Definition: EventSetup.h:57
TrajectorySmoother.h
get
#define get
TrackTransformerForGlobalCosmicMuons::setServices
void setServices(const edm::EventSetup &) override
set the services needed by the TrackTransformer
Definition: TrackTransformerForGlobalCosmicMuons.cc:55
MuonSubdetId.h
TrackTransformerForGlobalCosmicMuons::MuonKeep
bool MuonKeep(DetId id) const
check (via options) if this is a muon rec hit for removal
Definition: TrackTransformerForGlobalCosmicMuons.cc:268
Trajectory.h
std
Definition: JetResolutionObject.h:76
reco::TransientTrack
Definition: TransientTrack.h:19
StripSubdetector::TEC
static constexpr auto TEC
Definition: StripSubdetector.h:19
DTWireId.h
DetId.h
Trajectory
Definition: Trajectory.h:38
MuonSubdetId::RPC
static constexpr int RPC
Definition: MuonSubdetId.h:13
TrackingComponentsRecord.h
TrackTransformerForGlobalCosmicMuons::smoother
edm::ESHandle< TrajectorySmoother > smoother(bool) const
the smoother used to smooth the trajectory which came from the refitting step
Definition: TrackTransformerForGlobalCosmicMuons.cc:179
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
edm::parameterSet
ParameterSet const & parameterSet(Provenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
TrajectorySeed
Definition: TrajectorySeed.h:18
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TransientTrackingRecHitBuilder.h
DetId::Muon
Definition: DetId.h:26
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
GeomDetEnumerators::isDT
bool isDT(GeomDetEnumerators::SubDetector m)
Definition: GeomDetEnumerators.cc:86
alongMomentum
Definition: PropagationDirection.h:4
up
Definition: BitonicSort.h:7
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
hit
Definition: SiStripHitEffFromCalibTree.cc:88
TrackTransformerForGlobalCosmicMuons::getTransientRecHits
TransientTrackingRecHit::ConstRecHitContainer getTransientRecHits(const reco::TransientTrack &track) const
Definition: TrackTransformerForGlobalCosmicMuons.cc:103
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12