CMS 3D CMS Logo

HLTMuonPointingFilter.cc
Go to the documentation of this file.
1 
6 /* This Class Header */
8 
9 /* Collaborating Class Header */
19 
21 
29 
30 /* C++ Headers */
31 using namespace std;
32 using namespace edm;
33 
34 /* ====================================================================== */
35 
38  theSTAMuonToken( consumes<reco::TrackCollection>( pset.getParameter<edm::InputTag>("SALabel") ) ), // token to read the muons
39  thePropagatorName(pset.getParameter<std::string>("PropagatorName") ),
40  theRadius( pset.getParameter<double>("radius") ), // cyl's radius (cm)
41  theMaxZ( pset.getParameter<double>("maxZ") ), // cyl's half lenght (cm)
42  thePixHits( pset.getParameter<unsigned int>("PixHits") ), // pixel hits
43  theTkLayers( pset.getParameter<unsigned int>("TkLayers") ), // tracker layers with measurements
44  theMuonHits( pset.getParameter<unsigned int>("MuonHits") ), // muon hits
45  thePropagator(nullptr),
46  m_cacheRecordId(0)
47 {
48  // Get a surface (here a cylinder of radius 1290mm) ECAL
51  theCyl = Cylinder::build(theRadius, pos0, rot0);
52 
53  Plane::PositionType posPos(0,0,theMaxZ);
54  Plane::PositionType posNeg(0,0,-theMaxZ);
55 
56  thePosPlane = Plane::build(posPos,rot0);
57  theNegPlane = Plane::build(posNeg,rot0);
58 
59  LogDebug("HLTMuonPointing") << " SALabel : " << pset.getParameter<edm::InputTag>("SALabel")
60  << " Radius : " << theRadius
61  << " Half lenght : " << theMaxZ
62  << " Min pixel hits : " << thePixHits
63  << " Min tk layers measurements : " << theTkLayers
64  << " Min muon hits : " << theMuonHits;
65 
66 }
67 
70 
71 /* Operations */
73  bool accept = false;
74 
75  const TrackingComponentsRecord & tkRec = eventSetup.get<TrackingComponentsRecord>();
76  if (not thePropagator or tkRec.cacheIdentifier() != m_cacheRecordId) {
77  // delete the old propagator
78  delete thePropagator;
79 
80  // get the new propagator from the EventSetup and clone it (for thread safety)
81  ESHandle<Propagator> propagatorHandle;
82  tkRec.get(thePropagatorName, propagatorHandle);
83  thePropagator = propagatorHandle.product()->clone();
85  throw cms::Exception("Configuration") << "the propagator " << thePropagatorName << " should be configured with PropagationDirection = \"anyDirection\"" << std::endl;
87  }
88 
89  ESHandle<MagneticField> theMGField;
90  eventSetup.get<IdealMagneticFieldRecord>().get(theMGField);
91 
92  ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
93  eventSetup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
94 
95  // Get the RecTrack collection from the event
97  event.getByToken(theSTAMuonToken, staTracks);
98 
99  reco::TrackCollection::const_iterator staTrack;
100 
101  for (staTrack = staTracks->begin(); staTrack != staTracks->end(); ++staTrack){
102  reco::TransientTrack track(*staTrack,&*theMGField,theTrackingGeometry);
103 
104  const reco::HitPattern& p = track.hitPattern();
105 
106  const unsigned int pixelHits = p.numberOfValidPixelHits();
107  const unsigned int trkLayers = p.trackerLayersWithMeasurement();
108  const unsigned int nMuonHits = p.numberOfValidMuonHits();
109 
111 
112  LogDebug("HLTMuonPointing") << " InnerTSOS " << innerTSOS;
113 
114  TrajectoryStateOnSurface tsosAtCyl =
115  thePropagator->propagate(*innerTSOS.freeState(), *theCyl);
116 
117  if ( tsosAtCyl.isValid() ) {
118  LogDebug("HLTMuonPointing") << " extrap TSOS " << tsosAtCyl
119  << " number of pixel hits " << pixelHits
120  << " number of tracker layers with interactions " << trkLayers
121  << " number of muon hits " << nMuonHits;
122  if (fabs(tsosAtCyl.globalPosition().z())<theMaxZ ) {
123  if(pixelHits >= thePixHits){
124  if(trkLayers >= theTkLayers){
125  if(nMuonHits >= theMuonHits){
126  accept=true;
127  return accept;
128  }
129  }
130  }
131  }
132  else {
133  LogDebug("HLTMuonPointing") << " extrap TSOS z too big " << tsosAtCyl.globalPosition().z()
134  << " number of pixel hits " << pixelHits
135  << " number of tracker layers with interactions " << trkLayers
136  << " number of muon hits " << nMuonHits;
137  TrajectoryStateOnSurface tsosAtPlane;
138  if (tsosAtCyl.globalPosition().z()>0)
139  tsosAtPlane=thePropagator->propagate(*innerTSOS.freeState(), *thePosPlane);
140  else
141  tsosAtPlane=thePropagator->propagate(*innerTSOS.freeState(), *theNegPlane);
142 
143  if (tsosAtPlane.isValid()){
144  if (tsosAtPlane.globalPosition().perp()< theRadius){
145  if (pixelHits >= thePixHits){
146  if(trkLayers >= theTkLayers){
147  if(nMuonHits >= theMuonHits){
148  accept=true;
149  return accept;
150  }
151  }
152  }
153  }
154  }
155  else
156  LogDebug("HLTMuonPointing") << " extrap to plane failed ";
157  }
158  } else {
159  LogDebug("HLTMuonPointing") << " extrap to cyl failed ";
160  }
161 
162  }
163 
164  return accept;
165 }
166 
169 
170  desc.add<edm::InputTag>("SALabel", edm::InputTag("hltCosmicMuonBarrelOnly"));
171  desc.add<std::string>("PropagatorName", "SteppingHelixPropagatorAny");
172  desc.add<double>("radius", 90.0);
173  desc.add<double>("maxZ", 280.0);
174  desc.add<unsigned int>("PixHits", 0);
175  desc.add<unsigned int>("TkLayers", 0);
176  desc.add<unsigned int>("MuonHits", 0);
177 
178  descriptions.add("hltMuonPointingFilter", desc);
179 }
180 
181 
182 // declare this class as a framework plugin
#define LogDebug(id)
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
virtual Propagator * clone() const =0
T perp() const
Definition: PV3DBase.h:72
HLTMuonPointingFilter(const edm::ParameterSet &)
Constructor.
const unsigned int thePixHits
Plane::PlanePointer thePosPlane
#define nullptr
const HitPattern & hitPattern() const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
GlobalPoint globalPosition() const
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:557
Plane::PlanePointer theNegPlane
TrajectoryStateOnSurface innermostMeasurementState() const
bool filter(edm::Event &, edm::EventSetup const &) override
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
Definition: Cylinder.h:51
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:151
Cylinder::CylinderPointer theCyl
~HLTMuonPointingFilter() override
Destructor.
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
static PlanePointer build(Args &&...args)
Definition: Plane.h:33
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:64
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const unsigned int theMuonHits
unsigned long long m_cacheRecordId
const edm::EDGetTokenT< reco::TrackCollection > theSTAMuonToken
const unsigned int theTkLayers
void add(std::string const &label, ParameterSetDescription const &psetDescription)
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
const std::string thePropagatorName
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:71
int numberOfValidPixelHits() const
Definition: HitPattern.h:916
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int numberOfValidMuonHits() const
Definition: HitPattern.h:906
T const * product() const
Definition: ESHandle.h:86
Definition: event.py:1