1 |
#include "UserCode/L1RpcTriggerAnalysis/interface/SynchroSelectorMuon.h"
|
2 |
|
3 |
|
4 |
#include "FWCore/Framework/interface/Event.h"
|
5 |
#include "FWCore/Framework/interface/EventSetup.h"
|
6 |
#include "FWCore/Framework/interface/ESHandle.h"
|
7 |
#include "FWCore/Utilities/interface/InputTag.h"
|
8 |
|
9 |
#include "DataFormats/MuonReco/interface/Muon.h"
|
10 |
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
11 |
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
12 |
#include "DataFormats/TrackReco/interface/Track.h"
|
13 |
|
14 |
#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
|
15 |
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
|
16 |
|
17 |
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
|
18 |
#include "MagneticField/Engine/interface/MagneticField.h"
|
19 |
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
|
20 |
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
|
21 |
|
22 |
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
|
23 |
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
|
24 |
|
25 |
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
|
26 |
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
|
27 |
|
28 |
#include "TObjArray.h"
|
29 |
#include "TH1F.h"
|
30 |
#include <cmath>
|
31 |
using namespace edm;
|
32 |
using namespace std;
|
33 |
|
34 |
SynchroSelectorMuon::SynchroSelectorMuon(const edm::ParameterSet& cfg) : SynchroSelector(cfg)
|
35 |
{ }
|
36 |
|
37 |
SynchroSelectorMuon::SynchroSelectorMuon(const edm::ParameterSet& cfg, TObjArray& histos)
|
38 |
: SynchroSelector(cfg)
|
39 |
{ initHistos(histos); }
|
40 |
|
41 |
void SynchroSelectorMuon::initHistos(TObjArray& histos)
|
42 |
{
|
43 |
hDxy = new TH1F("hDxy_SSMuon","hDxy_SSMuon",100.,0.,1.); histos.Add(hDxy);
|
44 |
SynchroSelector::hPullX = new TH1F("hPullX_Muon","hPullX_Muon",100,-10.,10.); histos.Add(hPullX);
|
45 |
SynchroSelector::hDistX = new TH1F("hDistX_Muon","hDistX_Muon",100,-100.,100.); histos.Add(hDistX);
|
46 |
}
|
47 |
|
48 |
bool SynchroSelectorMuon::takeIt(const RPCDetId & det, const edm::Event&ev, const edm::EventSetup& es)
|
49 |
{
|
50 |
|
51 |
math::XYZPoint reference(0.,0.,0.);
|
52 |
if (theConfig.exists("beamSpot")) {
|
53 |
edm::InputTag beamSpot = theConfig.getParameter<edm::InputTag>("beamSpot");
|
54 |
edm::Handle<reco::BeamSpot> bsHandle;
|
55 |
ev.getByLabel( beamSpot, bsHandle);
|
56 |
if (bsHandle.isValid()) reference = math::XYZPoint(bsHandle->x0(), bsHandle->y0(), bsHandle->z0());
|
57 |
}
|
58 |
|
59 |
edm::Handle<reco::MuonCollection> muons;
|
60 |
ev.getByLabel( theConfig.getParameter<std::string>("muonColl"), muons);
|
61 |
const reco::Muon * theMuon = 0;
|
62 |
for (reco::MuonCollection::const_iterator im = muons->begin(); im != muons->end(); ++im) {
|
63 |
if (!im->isTrackerMuon()) continue;
|
64 |
if (!im->isStandAloneMuon()) continue;
|
65 |
if (!im->isGlobalMuon()) continue;
|
66 |
if (im->track()->pt() < theConfig.getParameter<double>("minPt")) continue;
|
67 |
if (fabs(im->track()->eta()) > theConfig.getParameter<double>("maxEta")) continue;
|
68 |
if (im->track()->dxy(reference) > theConfig.getParameter<double>("maxTIP")) continue;
|
69 |
if (!theMuon || (im->track()->pt() > theMuon->track()->pt()) ) theMuon = &(*im);
|
70 |
}
|
71 |
|
72 |
if (!theMuon) return false;
|
73 |
|
74 |
edm::ESHandle<GlobalTrackingGeometry> globalGeometry;
|
75 |
es.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
|
76 |
edm::ESHandle<MagneticField> magField;
|
77 |
es.get<IdealMagneticFieldRecord>().get(magField);
|
78 |
|
79 |
if (hDxy) hDxy->Fill(fabs(theMuon->innerTrack()->dxy(reference)));
|
80 |
TrajectoryStateOnSurface aTSOS = trajectoryStateTransform::innerStateOnSurface( *(theMuon->outerTrack()), *globalGeometry, magField.product());
|
81 |
return checkTraj(aTSOS, det,ev,es);
|
82 |
}
|
83 |
|
84 |
bool SynchroSelectorMuon::checkTraj(TrajectoryStateOnSurface & aTSOS, const RPCDetId & det, const edm::Event&ev, const edm::EventSetup& es)
|
85 |
{
|
86 |
if (!checkRpcDetMatching(aTSOS,det,ev,es)) return false;
|
87 |
if (!checkUniqueRecHitMatching(aTSOS,det,ev,es)) return false;
|
88 |
return true;
|
89 |
}
|
90 |
|
91 |
|
92 |
|