CMS 3D CMS Logo

HLTDisplacedmumuVtxProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 
21 
22 using namespace edm;
23 using namespace reco;
24 using namespace std;
25 using namespace trigger;
26 //
27 // constructors and destructor
28 //
30  : transientTrackRecordToken_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))),
31  srcTag_(iConfig.getParameter<edm::InputTag>("Src")),
32  srcToken_(consumes<reco::RecoChargedCandidateCollection>(srcTag_)),
33  previousCandTag_(iConfig.getParameter<edm::InputTag>("PreviousCandTag")),
34  previousCandToken_(consumes<trigger::TriggerFilterObjectWithRefs>(previousCandTag_)),
35  matchToPrevious_(iConfig.getParameter<bool>("matchToPrevious")),
36  maxEta_(iConfig.getParameter<double>("MaxEta")),
37  minPt_(iConfig.getParameter<double>("MinPt")),
38  minPtPair_(iConfig.getParameter<double>("MinPtPair")),
39  minInvMass_(iConfig.getParameter<double>("MinInvMass")),
40  maxInvMass_(iConfig.getParameter<double>("MaxInvMass")),
41  chargeOpt_(iConfig.getParameter<int>("ChargeOpt")) {
42  produces<VertexCollection>();
43 }
44 
46 
49  desc.add<edm::InputTag>("Src", edm::InputTag("hltL3MuonCandidates"));
50  desc.add<edm::InputTag>("PreviousCandTag", edm::InputTag(""));
51  desc.add<bool>("matchToPrevious", true);
52  desc.add<double>("MaxEta", 2.5);
53  desc.add<double>("MinPt", 0.0);
54  desc.add<double>("MinPtPair", 0.0);
55  desc.add<double>("MinInvMass", 1.0);
56  desc.add<double>("MaxInvMass", 20.0);
57  desc.add<int>("ChargeOpt", -1);
58  descriptions.add("hltDisplacedmumuVtxProducer", desc);
59 }
60 
61 // ------------ method called on each new Event ------------
63  double const MuMass = 0.106;
64  double const MuMass2 = MuMass * MuMass;
65 
66  // get hold of muon trks
68  iEvent.getByToken(srcToken_, mucands);
69 
70  // get the transient track builder
71  auto const& theB = iSetup.getHandle(transientTrackRecordToken_);
72 
73  std::unique_ptr<VertexCollection> vertexCollection(new VertexCollection());
74 
75  // look at all mucands, check cuts and make vertices
76  double e1, e2;
78 
79  RecoChargedCandidateCollection::const_iterator cand1;
80  RecoChargedCandidateCollection::const_iterator cand2;
81 
82  // get the objects passing the previous filter
84  if (matchToPrevious_)
85  iEvent.getByToken(previousCandToken_, previousCands);
86 
87  vector<RecoChargedCandidateRef> vPrevCands;
88  if (matchToPrevious_)
89  previousCands->getObjects(TriggerMuon, vPrevCands);
90 
91  for (cand1 = mucands->begin(); cand1 != mucands->end(); cand1++) {
92  TrackRef tk1 = cand1->get<TrackRef>();
93  LogDebug("HLTDisplacedMumuFilter") << " 1st muon in loop: q*pt= " << cand1->charge() * cand1->pt()
94  << ", eta= " << cand1->eta() << ", hits= " << tk1->numberOfValidHits();
95 
96  //first check if this muon passed the previous filter
97  if (matchToPrevious_ && !checkPreviousCand(tk1, vPrevCands))
98  continue;
99 
100  // cuts
101  if (fabs(cand1->eta()) > maxEta_)
102  continue;
103  if (cand1->pt() < minPt_)
104  continue;
105 
106  cand2 = cand1;
107  cand2++;
108  for (; cand2 != mucands->end(); cand2++) {
109  TrackRef tk2 = cand2->get<TrackRef>();
110 
111  // eta cut
112  LogDebug("HLTDisplacedmumuVtxProducer")
113  << " 2nd muon in loop: q*pt= " << cand2->charge() * cand2->pt() << ", eta= " << cand2->eta()
114  << ", hits= " << tk2->numberOfValidHits() << ", d0= " << tk2->d0();
115  //first check if this muon passed the previous filter
116  if (matchToPrevious_ && !checkPreviousCand(tk2, vPrevCands))
117  continue;
118 
119  // cuts
120  if (fabs(cand2->eta()) > maxEta_)
121  continue;
122  if (cand2->pt() < minPt_)
123  continue;
124 
125  // opposite sign or same sign
126  if (chargeOpt_ < 0) {
127  if (cand1->charge() * cand2->charge() > 0)
128  continue;
129  } else if (chargeOpt_ > 0) {
130  if (cand1->charge() * cand2->charge() < 0)
131  continue;
132  }
133 
134  // Combined dimuon system
135  e1 = sqrt(cand1->momentum().Mag2() + MuMass2);
136  e2 = sqrt(cand2->momentum().Mag2() + MuMass2);
137  p1 = Particle::LorentzVector(cand1->px(), cand1->py(), cand1->pz(), e1);
138  p2 = Particle::LorentzVector(cand2->px(), cand2->py(), cand2->pz(), e2);
139  p = p1 + p2;
140 
141  if (p.pt() < minPtPair_)
142  continue;
143 
144  double invmass = abs(p.mass());
145  LogDebug("HLTDisplacedMumuFilter") << " ... 1-2 invmass= " << invmass;
146 
147  if (invmass < minInvMass_)
148  continue;
149  if (invmass > maxInvMass_)
150  continue;
151 
152  // do the vertex fit
153  vector<TransientTrack> t_tks;
154  TransientTrack ttkp1 = (*theB).build(&tk1);
155  TransientTrack ttkp2 = (*theB).build(&tk2);
156  t_tks.push_back(ttkp1);
157  t_tks.push_back(ttkp2);
158 
159  if (t_tks.size() != 2)
160  continue;
161 
162  KalmanVertexFitter kvf;
163  TransientVertex tv = kvf.vertex(t_tks);
164 
165  if (!tv.isValid())
166  continue;
167 
168  Vertex vertex = tv;
169 
170  // put vertex in the event
171  vertexCollection->push_back(vertex);
172  }
173  }
175 }
176 
178  const vector<RecoChargedCandidateRef>& refVect) const {
179  bool ok = false;
180  for (auto& i : refVect) {
181  if (i->get<TrackRef>() == trackref) {
182  ok = true;
183  break;
184  }
185  }
186  return ok;
187 }
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
trigger::TriggerFilterObjectWithRefs
Definition: TriggerFilterObjectWithRefs.h:35
KalmanVertexFitter::vertex
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
Definition: KalmanVertexFitter.h:49
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
KalmanVertexFitter.h
ESHandle.h
HLTDisplacedmumuVtxProducer::transientTrackRecordToken_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackRecordToken_
Definition: HLTDisplacedmumuVtxProducer.h:43
TransientVertex::isValid
bool isValid() const
Definition: TransientVertex.h:195
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTDisplacedmumuVtxProducer::minPtPair_
const double minPtPair_
Definition: HLTDisplacedmumuVtxProducer.h:51
HLTDisplacedmumuVtxProducer::maxInvMass_
const double maxInvMass_
Definition: HLTDisplacedmumuVtxProducer.h:53
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
TriggerFilterObjectWithRefs.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
edm::Handle
Definition: AssociativeIterator.h:50
RecoCandidate.h
trigger::TriggerRefsCollections::getObjects
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
Definition: TriggerRefsCollections.h:590
reco::RecoChargedCandidateCollection
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
Definition: RecoChargedCandidateFwd.h:9
edm::Ref< TrackCollection >
HLTDisplacedmumuVtxProducer::srcToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > srcToken_
Definition: HLTDisplacedmumuVtxProducer.h:45
CandidateFwd.h
HLTDisplacedmumuVtxProducer::chargeOpt_
const int chargeOpt_
Definition: HLTDisplacedmumuVtxProducer.h:54
Track.h
TrackFwd.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
trigger::TriggerMuon
Definition: TriggerTypeDefs.h:79
p2
double p2[4]
Definition: TauolaWrapper.h:90
HLTDisplacedmumuVtxProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: HLTDisplacedmumuVtxProducer.cc:62
RefToBase.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HLTDisplacedmumuVtxProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTDisplacedmumuVtxProducer.cc:47
StorageManager_cfg.e1
e1
Definition: StorageManager_cfg.py:16
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
p1
double p1[4]
Definition: TauolaWrapper.h:89
TransientVertex
Definition: TransientVertex.h:18
edm::EventSetup
Definition: EventSetup.h:58
HLTDisplacedmumuVtxProducer::HLTDisplacedmumuVtxProducer
HLTDisplacedmumuVtxProducer(const edm::ParameterSet &)
Definition: HLTDisplacedmumuVtxProducer.cc:29
HLTDisplacedmumuVtxProducer::maxEta_
const double maxEta_
Definition: HLTDisplacedmumuVtxProducer.h:49
reco::JetExtendedAssociation::LorentzVector
math::PtEtaPhiELorentzVectorF LorentzVector
Definition: JetExtendedAssociation.h:25
VertexFwd.h
TransientVertex.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
reco::TransientTrack
Definition: TransientTrack.h:19
RecoChargedCandidate.h
Vertex.h
spclusmultinvestigator_cfi.vertexCollection
vertexCollection
Definition: spclusmultinvestigator_cfi.py:4
l1t::VertexCollection
std::vector< Vertex > VertexCollection
Definition: Vertex.h:12
HLTDisplacedmumuVtxProducer::matchToPrevious_
const bool matchToPrevious_
Definition: HLTDisplacedmumuVtxProducer.h:48
TriggerRefsCollections.h
HLTDisplacedmumuVtxProducer.h
trigger
Definition: HLTPrescaleTableCond.h:8
HLTDisplacedmumuVtxProducer::minInvMass_
const double minInvMass_
Definition: HLTDisplacedmumuVtxProducer.h:52
Candidate.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
RecoChargedCandidateFwd.h
HLTDisplacedmumuVtxProducer::~HLTDisplacedmumuVtxProducer
~HLTDisplacedmumuVtxProducer() override
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
HLTDisplacedmumuVtxProducer::checkPreviousCand
bool checkPreviousCand(const reco::TrackRef &trackref, const std::vector< reco::RecoChargedCandidateRef > &ref2) const
Definition: HLTDisplacedmumuVtxProducer.cc:177
HLTDisplacedmumuVtxProducer::minPt_
const double minPt_
Definition: HLTDisplacedmumuVtxProducer.h:50
KalmanVertexFitter
Definition: KalmanVertexFitter.h:22
HLTDisplacedmumuVtxProducer::previousCandToken_
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > previousCandToken_
Definition: HLTDisplacedmumuVtxProducer.h:47