Go to the documentation of this file.00001 #include <iostream>
00002
00003 #include "FWCore/Framework/interface/ESHandle.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005
00006 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00007 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00008 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00009 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00010 #include "DataFormats/Candidate/interface/Candidate.h"
00011
00012 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00013 #include "DataFormats/TrackReco/interface/Track.h"
00014 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00015 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00016
00017 #include "RecoVertex/KalmanVertexFit/interface/KalmanVertexFitter.h"
00018 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
00019 #include "DataFormats/VertexReco/interface/Vertex.h"
00020 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00021 #include "DataFormats/Common/interface/RefToBase.h"
00022
00023
00024 #include "HLTDisplacedmumuVtxProducer.h"
00025
00026 using namespace edm;
00027 using namespace reco;
00028 using namespace std;
00029
00030
00031
00032
00033 HLTDisplacedmumuVtxProducer::HLTDisplacedmumuVtxProducer(const edm::ParameterSet& iConfig):
00034 src_ (iConfig.getParameter<edm::InputTag>("Src")),
00035 maxEta_ (iConfig.getParameter<double>("MaxEta")),
00036 minPt_ (iConfig.getParameter<double>("MinPt")),
00037 minPtPair_ (iConfig.getParameter<double>("MinPtPair")),
00038 minInvMass_ (iConfig.getParameter<double>("MinInvMass")),
00039 maxInvMass_ (iConfig.getParameter<double>("MaxInvMass")),
00040 chargeOpt_ (iConfig.getParameter<int>("ChargeOpt"))
00041 {
00042 produces<VertexCollection>();
00043 }
00044
00045
00046 HLTDisplacedmumuVtxProducer::~HLTDisplacedmumuVtxProducer()
00047 {
00048
00049 }
00050
00051
00052
00053 void HLTDisplacedmumuVtxProducer::beginJob()
00054 {
00055
00056 }
00057
00058
00059 void HLTDisplacedmumuVtxProducer::endJob()
00060 {
00061
00062 }
00063
00064
00065 void HLTDisplacedmumuVtxProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00066 {
00067 double const MuMass = 0.106;
00068 double const MuMass2 = MuMass*MuMass;
00069
00070
00071
00072 Handle<RecoChargedCandidateCollection> mucands;
00073 iEvent.getByLabel (src_,mucands);
00074
00075
00076 edm::ESHandle<TransientTrackBuilder> theB;
00077 iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
00078
00079 std::auto_ptr<VertexCollection> vertexCollection(new VertexCollection());
00080
00081
00082 double e1,e2;
00083 Particle::LorentzVector p,p1,p2;
00084
00085 RecoChargedCandidateCollection::const_iterator cand1;
00086 RecoChargedCandidateCollection::const_iterator cand2;
00087 for (cand1=mucands->begin(); cand1!=mucands->end(); cand1++) {
00088 TrackRef tk1 = cand1->get<TrackRef>();
00089
00090 LogDebug("HLTDisplacedMumuFilter") << " 1st muon in loop: q*pt= " << tk1->charge()*tk1->pt() << ", eta= " << tk1->eta() << ", hits= " << tk1->numberOfValidHits();
00091
00092
00093 if (fabs(tk1->eta())>maxEta_) continue;
00094 if (tk1->pt() < minPt_) continue;
00095
00096 cand2 = cand1; cand2++;
00097 for (; cand2!=mucands->end(); cand2++) {
00098 TrackRef tk2 = cand2->get<TrackRef>();
00099
00100
00101 LogDebug("HLTMuonDimuonFilter") << " 2nd muon in loop: q*pt= " << tk2->charge()*tk2->pt() << ", eta= " << tk2->eta() << ", hits= " << tk2->numberOfValidHits() << ", d0= " << tk2->d0();
00102
00103
00104 if (fabs(tk2->eta())>maxEta_) continue;
00105 if (tk2->pt() < minPt_) continue;
00106
00107
00108 if (chargeOpt_<0) {
00109 if (tk1->charge()*tk2->charge()>0) continue;
00110 } else if (chargeOpt_>0) {
00111 if (tk1->charge()*tk2->charge()<0) continue;
00112 }
00113
00114
00115 e1 = sqrt(tk1->momentum().Mag2()+MuMass2);
00116 e2 = sqrt(tk2->momentum().Mag2()+MuMass2);
00117 p1 = Particle::LorentzVector(tk1->px(),tk1->py(),tk1->pz(),e1);
00118 p2 = Particle::LorentzVector(tk2->px(),tk2->py(),tk2->pz(),e2);
00119 p = p1+p2;
00120
00121
00122 if (p.pt()<minPtPair_) continue;
00123
00124 double invmass = abs(p.mass());
00125 LogDebug("HLTDisplacedMumuFilter") << " ... 1-2 invmass= " << invmass;
00126
00127 if (invmass<minInvMass_) continue;
00128 if (invmass>maxInvMass_) continue;
00129
00130
00131 vector<TransientTrack> t_tks;
00132 TransientTrack ttkp1 = (*theB).build(&tk1);
00133 TransientTrack ttkp2 = (*theB).build(&tk2);
00134 t_tks.push_back(ttkp1);
00135 t_tks.push_back(ttkp2);
00136
00137
00138 if (t_tks.size()!=2) continue;
00139
00140 KalmanVertexFitter kvf;
00141 TransientVertex tv = kvf.vertex(t_tks);
00142
00143 if (!tv.isValid()) continue;
00144
00145 Vertex vertex = tv;
00146
00147
00148 vertexCollection->push_back(vertex);
00149 }
00150 }
00151 iEvent.put(vertexCollection);
00152 }
00153