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 
39  theTrackerRecHitBuilderName = parameterSet.getParameter<string>("TrackerRecHitBuilder");
40  theMuonRecHitBuilderName = parameterSet.getParameter<string>("MuonRecHitBuilder");
41 
42  theRPCInTheFit = parameterSet.getParameter<bool>("RefitRPCHits");
43 
44  theCacheId_TC = theCacheId_GTG = theCacheId_MG = theCacheId_TRH = 0;
45  theSkipStationDT = parameterSet.getParameter<int>("SkipStationDT");
46  theSkipStationCSC = parameterSet.getParameter<int>("SkipStationCSC");
47  theSkipWheelDT = parameterSet.getParameter<int>("SkipWheelDT");
48  theTrackerSkipSystem = parameterSet.getParameter<int>("TrackerSkipSystem");
49  theTrackerSkipSection = parameterSet.getParameter<int>("TrackerSkipSection");//layer, wheel, or disk depending on the system
50 }
51 
54 
55 
57 
58  const std::string metname = "Reco|TrackingTools|TrackTransformer";
59 
60  setup.get<TrajectoryFitter::Record>().get("KFFitterForRefitInsideOut",theFitterIO);
61  setup.get<TrajectoryFitter::Record>().get("KFSmootherForRefitInsideOut",theSmootherIO);
62  setup.get<TrajectoryFitter::Record>().get("KFFitterForRefitOutsideIn",theFitterOI);
63  setup.get<TrajectoryFitter::Record>().get("KFSmootherForRefitOutsideIn",theSmootherOI);
64 
65  unsigned long long newCacheId_TC = setup.get<TrackingComponentsRecord>().cacheIdentifier();
66 
67  if ( newCacheId_TC != theCacheId_TC ){
68  LogTrace(metname) << "Tracking Component changed!";
69  theCacheId_TC = newCacheId_TC;
70  setup.get<TrackingComponentsRecord>().get("SmartPropagatorRK",thePropagatorIO);
71  setup.get<TrackingComponentsRecord>().get("SmartPropagatorRKOpposite",thePropagatorOI);
72 
73  }
74 
75  // Global Tracking Geometry
76  unsigned long long newCacheId_GTG = setup.get<GlobalTrackingGeometryRecord>().cacheIdentifier();
77  if ( newCacheId_GTG != theCacheId_GTG ) {
78  LogTrace(metname) << "GlobalTrackingGeometry changed!";
79  theCacheId_GTG = newCacheId_GTG;
80  setup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
81  }
82 
83  // Magfield Field
84  unsigned long long newCacheId_MG = setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
85  if ( newCacheId_MG != theCacheId_MG ) {
86  LogTrace(metname) << "Magnetic Field changed!";
87  theCacheId_MG = newCacheId_MG;
88  setup.get<IdealMagneticFieldRecord>().get(theMGField);
89  }
90 
91  // Transient Rechit Builders
92  unsigned long long newCacheId_TRH = setup.get<TransientRecHitRecord>().cacheIdentifier();
93  if ( newCacheId_TRH != theCacheId_TRH ) {
94  theCacheId_TRH = newCacheId_TRH;
95  LogTrace(metname) << "TransientRecHitRecord changed!";
96  setup.get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName,theTrackerRecHitBuilder);
97  setup.get<TransientRecHitRecord>().get(theMuonRecHitBuilderName,theMuonRecHitBuilder);
98  }
99 
100  //Retrieve tracker topology from geometry
102  setup.get<TrackerTopologyRcd>().get(tTopoHand);
103  tTopo_=tTopoHand.product();
104 }
105 
106 
109 
112 
113  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
114  if((*hit)->isValid()) {
115  if ( (*hit)->geographicalId().det() == DetId::Tracker && TrackerKeep((*hit)->geographicalId())) {
116  tkHits.push_back(theTrackerRecHitBuilder->build(&**hit));
117  } else if ( (*hit)->geographicalId().det() == DetId::Muon && MuonKeep((*hit)->geographicalId())){
118  if( (*hit)->geographicalId().subdetId() == 3 && !theRPCInTheFit){
119  LogTrace("Reco|TrackingTools|TrackTransformer") << "RPC Rec Hit discarged";
120  continue;
121  }
122  staHits.push_back(theMuonRecHitBuilder->build(&**hit));
123  }
124  }
125  }
126 
127  if(staHits.empty()) return staHits;
128 
129 /*
130  bool up = staHits.front()->globalPosition().y()>0 ? true : false;
131 
132  if(up){
133  reverse(staHits.begin(),staHits.end());
134  reverse(tkHits.begin(),tkHits.end());
135  }
136 */
137  copy(staHits.begin(),staHits.end(),back_inserter(tkHits));
138 
139  for(TransientTrackingRecHit::ConstRecHitContainer::const_iterator hit = tkHits.begin();
140  hit !=tkHits.end(); ++hit){
141 
142  DetId hitId = (*hit)->geographicalId();
143  GlobalPoint glbpoint = trackingGeometry()->idToDet(hitId)->position();
144 
145  if(hitId.det() == DetId::Tracker) {
146  if (hitId.subdetId() == StripSubdetector::TIB )
147  LogTrace("TrackFitters") << glbpoint << " I am TIB " << tTopo_->tibLayer(hitId);
148  else if (hitId.subdetId() == StripSubdetector::TOB )
149  LogTrace("TrackFitters") << glbpoint << " I am TOB " << tTopo_->tobLayer(hitId);
150  else if (hitId.subdetId() == StripSubdetector::TEC )
151  LogTrace("TrackFitters") << glbpoint << " I am TEC " << tTopo_->tecWheel(hitId);
152  else if (hitId.subdetId() == StripSubdetector::TID )
153  LogTrace("TrackFitters") << glbpoint << " I am TID " << tTopo_->tidWheel(hitId);
154  else if (hitId.subdetId() == (int) PixelSubdetector::PixelBarrel )
155  LogTrace("TrackFitters") << glbpoint << " I am PixBar " << tTopo_->pxbLayer(hitId);
156  else if (hitId.subdetId() == (int) PixelSubdetector::PixelEndcap )
157  LogTrace("TrackFitters") << glbpoint << " I am PixFwd " << tTopo_->pxfDisk(hitId);
158  else
159  LogTrace("TrackFitters") << " UNKNOWN TRACKER HIT TYPE ";
160  } else if(hitId.det() == DetId::Muon) {
161  if(hitId.subdetId() == MuonSubdetId::DT)
162  LogTrace("TrackFitters") << glbpoint << " I am DT " << DTWireId(hitId);
163  else if (hitId.subdetId() == MuonSubdetId::CSC )
164  LogTrace("TrackFitters") << glbpoint << " I am CSC " << CSCDetId(hitId);
165  else if (hitId.subdetId() == MuonSubdetId::RPC )
166  LogTrace("TrackFitters") << glbpoint << " I am RPC " << RPCDetId(hitId);
167  else
168  LogTrace("TrackFitters") << " UNKNOWN MUON HIT TYPE ";
169  } else
170  LogTrace("TrackFitters") << " UNKNOWN HIT TYPE ";
171  }
172 
173  return tkHits;
174 }
175 
176 
179  if(up) return theFitterOI;
180  else return theFitterIO;
181 }
182 
185  if(up) return theSmootherOI;
186  else return theSmootherIO;
187 }
188 
190  if(up) return thePropagatorIO;
191  else return thePropagatorOI;
192 }
193 
194 
195 
198 
199  const std::string metname = "Reco|TrackingTools|TrackTransformer";
200 
201  reco::TransientTrack track(tr,magneticField(),trackingGeometry());
202 
203  // Build the transient Rechits
204  TransientTrackingRecHit::ConstRecHitContainer recHitsForReFit = getTransientRecHits(track);
205 
206  if(recHitsForReFit.size() < 2) return vector<Trajectory>();
207 
208  bool up = recHitsForReFit.back()->globalPosition().y()>0 ? true : false;
209  LogTrace(metname) << "Up ? " << up;
210 
211  PropagationDirection propagationDirection = up ? oppositeToMomentum : alongMomentum;
213  unsigned int innerId = up ? track.track().outerDetId() : track.track().innerDetId();
214 
215  LogTrace(metname) << "Prop Dir: " << propagationDirection << " FirstId " << innerId << " firstTSOS " << firstTSOS;
216 
218 
219 
220  if(recHitsForReFit.front()->geographicalId() != DetId(innerId)){
221  LogTrace(metname)<<"Propagation occurring"<<endl;
222  firstTSOS = propagator(up)->propagate(firstTSOS, recHitsForReFit.front()->det()->surface());
223  LogTrace(metname)<<"Final destination: " << recHitsForReFit.front()->det()->surface().position() << endl;
224  if(!firstTSOS.isValid()){
225  LogTrace(metname)<<"Propagation error!"<<endl;
226  return vector<Trajectory>();
227  }
228  }
229 
230 
231  vector<Trajectory> trajectories = fitter(up)->fit(seed,recHitsForReFit,firstTSOS);
232 
233  if(trajectories.empty()){
234  LogTrace(metname)<<"No Track refitted!"<<endl;
235  return vector<Trajectory>();
236  }
237 
238  Trajectory trajectoryBW = trajectories.front();
239 
240  vector<Trajectory> trajectoriesSM = smoother(up)->trajectories(trajectoryBW);
241 
242  if(trajectoriesSM.empty()){
243  LogTrace(metname)<<"No Track smoothed!"<<endl;
244  return vector<Trajectory>();
245  }
246 
247  return trajectoriesSM;
248 
249 }
250 
251 //
252 // Selection for Tracker Hits
253 //
255 
256  if (id.det() != DetId::Tracker ) return false;
257  if (theTrackerSkipSystem < 0 ) return true;
258  bool retVal = true;
259 
260  int layer = -999;
261 
262  if ( id.subdetId() == theTrackerSkipSystem)
263  layer=tTopo_->layer(id);
264 
265  if (theTrackerSkipSection > -998 && layer == theTrackerSkipSection) retVal = false;
266 
267  return retVal;
268 }
269 //
270 // Selection for Muon hits
271 //
273 
274  if (id.det() != DetId::Muon) return false;
275  if (theSkipStationDT < 0 && theSkipStationCSC < 0) return true;
276 
277  int station = -999;
278  int wheel = -999;
279  bool isRPC = false;
280  bool isDT = false;
281  bool isCSC = false;
282 
283  if ( id.subdetId() == MuonSubdetId::DT ) {
284  DTChamberId did(id.rawId());
285  station = did.station();
286  wheel = did.wheel();
287  isDT = true;
288  } else if ( id.subdetId() == MuonSubdetId::CSC ) {
289  CSCDetId did(id.rawId());
290  station = did.station();
291  isCSC = true;
292  } else if ( id.subdetId() == MuonSubdetId::RPC ) {
293  RPCDetId rpcid(id.rawId());
294  station = rpcid.station();
295  isRPC = true;
296  }
297 
298  if (isRPC && (station == theSkipStationCSC || station == theSkipStationDT)) return false;
299  if (isDT && station == theSkipStationDT ) return false;
300  if (isCSC && station == theSkipStationCSC ) return false;
301 
302  if (isDT && theSkipWheelDT > -998 && wheel == theSkipWheelDT) return false;
303 
304  return true;
305 }
Definition: BitonicSort.h:8
T getParameter(std::string const &) const
std::vector< Trajectory > transform(const reco::Track &) const override
Convert a reco::Track into Trajectory.
def copy(args, dbName)
const std::string metname
bool TrackerKeep(DetId id) const
check (via options) if this is a tracker rec hit for removal
edm::ESHandle< TrajectoryFitter > fitter(bool) const
the refitter used to refit the reco::Track
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
PropagationDirection
bool isDT(GeomDetEnumerators::SubDetector m)
TrajectoryStateOnSurface innermostMeasurementState() const
void setServices(const edm::EventSetup &) override
set the services needed by the TrackTransformer
edm::ESHandle< TrajectorySmoother > smoother(bool) const
the smoother used to smooth the trajectory which came from the refitting step
static const int CSC
Definition: MuonSubdetId.h:13
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:96
TrajectoryStateOnSurface outermostMeasurementState() const
bool MuonKeep(DetId id) const
check (via options) if this is a muon rec hit for removal
#define LogTrace(id)
trackingRecHit_iterator recHitsEnd() const
last iterator to RecHits
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: DetId.h:18
bool isRPC(GeomDetEnumerators::SubDetector m)
const Track & track() const
TrackTransformerForGlobalCosmicMuons(const edm::ParameterSet &)
Constructor.
HLT enums.
static const int RPC
Definition: MuonSubdetId.h:14
T get() const
Definition: EventSetup.h:71
edm::ESHandle< Propagator > propagator(bool) const
bool isCSC(GeomDetEnumerators::SubDetector m)
int station() const
Definition: CSCDetId.h:86
static const int DT
Definition: MuonSubdetId.h:12
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:101
T const * product() const
Definition: ESHandle.h:86
trackingRecHit_iterator recHitsBegin() const
first iterator to RecHits
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
TransientTrackingRecHit::ConstRecHitContainer getTransientRecHits(const reco::TransientTrack &track) const
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
int station() const
Definition: RPCDetId.h:96