CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTDisplacedmumuVtxProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 
5 
11 
16 
22 
23 
25 
26 using namespace edm;
27 using namespace reco;
28 using namespace std;
29 
30 //
31 // constructors and destructor
32 //
34  src_ (iConfig.getParameter<edm::InputTag>("Src")),
35  maxEta_ (iConfig.getParameter<double>("MaxEta")),
36  minPt_ (iConfig.getParameter<double>("MinPt")),
37  minPtPair_ (iConfig.getParameter<double>("MinPtPair")),
38  minInvMass_ (iConfig.getParameter<double>("MinInvMass")),
39  maxInvMass_ (iConfig.getParameter<double>("MaxInvMass")),
40  chargeOpt_ (iConfig.getParameter<int>("ChargeOpt"))
41 {
42  produces<VertexCollection>();
43 }
44 
45 
47 {
48 
49 }
50 
51 
52 // ------------ method called once each job just before starting event loop ------------
54 {
55 
56 }
57 
58 // ------------ method called once each job just after ending the event loop ------------
60 {
61 
62 }
63 
64 // ------------ method called on each new Event ------------
66 {
67  double const MuMass = 0.106;
68  double const MuMass2 = MuMass*MuMass;
69 
70 
71  // get hold of muon trks
73  iEvent.getByLabel (src_,mucands);
74 
75  //get the transient track builder:
77  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
78 
79  std::auto_ptr<VertexCollection> vertexCollection(new VertexCollection());
80 
81  // look at all mucands, check cuts and make vertices
82  double e1,e2;
84 
85  RecoChargedCandidateCollection::const_iterator cand1;
86  RecoChargedCandidateCollection::const_iterator cand2;
87  for (cand1=mucands->begin(); cand1!=mucands->end(); cand1++) {
88  TrackRef tk1 = cand1->get<TrackRef>();
89 
90  LogDebug("HLTDisplacedMumuFilter") << " 1st muon in loop: q*pt= " << tk1->charge()*tk1->pt() << ", eta= " << tk1->eta() << ", hits= " << tk1->numberOfValidHits();
91 
92  // cuts
93  if (fabs(tk1->eta())>maxEta_) continue;
94  if (tk1->pt() < minPt_) continue;
95 
96  cand2 = cand1; cand2++;
97  for (; cand2!=mucands->end(); cand2++) {
98  TrackRef tk2 = cand2->get<TrackRef>();
99 
100  // eta cut
101  LogDebug("HLTMuonDimuonFilter") << " 2nd muon in loop: q*pt= " << tk2->charge()*tk2->pt() << ", eta= " << tk2->eta() << ", hits= " << tk2->numberOfValidHits() << ", d0= " << tk2->d0();
102 
103  // cuts
104  if (fabs(tk2->eta())>maxEta_) continue;
105  if (tk2->pt() < minPt_) continue;
106 
107  // opposite sign or same sign
108  if (chargeOpt_<0) {
109  if (tk1->charge()*tk2->charge()>0) continue;
110  } else if (chargeOpt_>0) {
111  if (tk1->charge()*tk2->charge()<0) continue;
112  }
113 
114  // Combined dimuon system
115  e1 = sqrt(tk1->momentum().Mag2()+MuMass2);
116  e2 = sqrt(tk2->momentum().Mag2()+MuMass2);
117  p1 = Particle::LorentzVector(tk1->px(),tk1->py(),tk1->pz(),e1);
118  p2 = Particle::LorentzVector(tk2->px(),tk2->py(),tk2->pz(),e2);
119  p = p1+p2;
120 
121 
122  if (p.pt()<minPtPair_) continue;
123 
124  double invmass = abs(p.mass());
125  LogDebug("HLTDisplacedMumuFilter") << " ... 1-2 invmass= " << invmass;
126 
127  if (invmass<minInvMass_) continue;
128  if (invmass>maxInvMass_) continue;
129 
130  // do the vertex fit
131  vector<TransientTrack> t_tks;
132  TransientTrack ttkp1 = (*theB).build(&tk1);
133  TransientTrack ttkp2 = (*theB).build(&tk2);
134  t_tks.push_back(ttkp1);
135  t_tks.push_back(ttkp2);
136 
137 
138  if (t_tks.size()!=2) continue;
139 
140  KalmanVertexFitter kvf;
141  TransientVertex tv = kvf.vertex(t_tks);
142 
143  if (!tv.isValid()) continue;
144 
145  Vertex vertex = tv;
146 
147  // put vertex in the event
148  vertexCollection->push_back(vertex);
149  }
150  }
151  iEvent.put(vertexCollection);
152 }
153 
#define LogDebug(id)
HLTDisplacedmumuVtxProducer(const edm::ParameterSet &)
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const
#define abs(x)
Definition: mlp_lapack.h:159
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
T sqrt(T t)
Definition: SSEVec.h:28
virtual void produce(edm::Event &, const edm::EventSetup &)
double p2[4]
Definition: TauolaWrapper.h:90
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
const T & get() const
Definition: EventSetup.h:55
double p1[4]
Definition: TauolaWrapper.h:89
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:239
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:26
bool isValid() const
math::PtEtaPhiELorentzVectorF LorentzVector