CMS 3D CMS Logo

HLTDisplacedtktkVtxProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 
20 
21 using namespace edm;
22 using namespace reco;
23 using namespace std;
24 using namespace trigger;
25 //
26 // constructors and destructor
27 //
29  : transientTrackRecordToken_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))),
30  srcTag_(iConfig.getParameter<edm::InputTag>("Src")),
31  srcToken_(consumes<reco::RecoChargedCandidateCollection>(srcTag_)),
32  previousCandTag_(iConfig.getParameter<edm::InputTag>("PreviousCandTag")),
33  previousCandToken_(consumes<trigger::TriggerFilterObjectWithRefs>(previousCandTag_)),
34  maxEta_(iConfig.getParameter<double>("MaxEta")),
35  minPt_(iConfig.getParameter<double>("MinPt")),
36  minPtPair_(iConfig.getParameter<double>("MinPtPair")),
37  minInvMass_(iConfig.getParameter<double>("MinInvMass")),
38  maxInvMass_(iConfig.getParameter<double>("MaxInvMass")),
39  massParticle1_(iConfig.getParameter<double>("massParticle1")),
40  massParticle2_(iConfig.getParameter<double>("massParticle2")),
41  chargeOpt_(iConfig.getParameter<int>("ChargeOpt")),
42  triggerTypeDaughters_(iConfig.getParameter<int>("triggerTypeDaughters")) {
43  produces<VertexCollection>();
44 }
45 
47 
50  desc.add<edm::InputTag>("Src", edm::InputTag("hltL3MuonCandidates"));
51  desc.add<edm::InputTag>("PreviousCandTag", edm::InputTag(""));
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<double>("massParticle1", 0.1396);
58  desc.add<double>("massParticle2", 0.4937);
59  desc.add<int>("ChargeOpt", -1);
60  desc.add<int>("triggerTypeDaughters", 0);
61 
62  descriptions.add("hltDisplacedtktkVtxProducer", desc);
63 }
64 
65 // ------------ method called on each new Event ------------
67  double const firstTrackMass = massParticle1_;
68  double const firstTrackMass2 = firstTrackMass * firstTrackMass;
69  double const secondTrackMass = massParticle2_;
70  double const secondTrackMass2 = secondTrackMass * secondTrackMass;
71 
72  // get hold of track trks
74  iEvent.getByToken(srcToken_, trackcands);
75 
76  // get the transient track builder
77  auto const& theB = iSetup.getHandle(transientTrackRecordToken_);
78 
79  std::unique_ptr<VertexCollection> vertexCollection(new VertexCollection());
80 
81  // look at all trackcands, check cuts and make vertices
82  double e1, e2;
84 
85  RecoChargedCandidateCollection::const_iterator cand1;
86  RecoChargedCandidateCollection::const_iterator cand2;
87 
88  // get the objects passing the previous filter
90  iEvent.getByToken(previousCandToken_, previousCands);
91 
92  vector<RecoChargedCandidateRef> vPrevCands;
93  previousCands->getObjects(triggerTypeDaughters_, vPrevCands);
94 
95  std::vector<bool> candComp;
96  for (cand1 = trackcands->begin(); cand1 != trackcands->end(); cand1++)
97  candComp.push_back(checkPreviousCand(cand1->get<TrackRef>(), vPrevCands));
98 
99  for (cand1 = trackcands->begin(); cand1 != trackcands->end(); cand1++) {
100  TrackRef tk1 = cand1->get<TrackRef>();
101  LogDebug("HLTDisplacedtktkVtxProducer") << " 1st track in loop: q*pt= " << cand1->charge() * cand1->pt()
102  << ", eta= " << cand1->eta() << ", hits= " << tk1->numberOfValidHits();
103 
104  //first check if this track passed the previous filter
105  if (!candComp[cand1 - trackcands->begin()])
106  continue;
107  // if( ! checkPreviousCand( tk1, vPrevCands) ) continue;
108 
109  // cuts
110  if (abs(cand1->eta()) > maxEta_)
111  continue;
112  if (cand1->pt() < minPt_)
113  continue;
114 
115  cand2 = trackcands->begin();
117  cand2 = cand1 + 1;
118  }
119 
120  for (; cand2 != trackcands->end(); cand2++) {
121  TrackRef tk2 = cand2->get<TrackRef>();
122  if (tk1 == tk2)
123  continue;
124 
125  // eta cut
126  LogDebug("HLTDisplacedtktkVtxProducer")
127  << " 2nd track in loop: q*pt= " << cand2->charge() * cand2->pt() << ", eta= " << cand2->eta()
128  << ", hits= " << tk2->numberOfValidHits() << ", d0= " << tk2->d0();
129  //first check if this track passed the previous filter
130  if (!candComp[cand2 - trackcands->begin()])
131  continue;
132  // if( ! checkPreviousCand( tk2, vPrevCands) ) continue;
133 
134  // cuts
135  if (abs(cand2->eta()) > maxEta_)
136  continue;
137  if (cand2->pt() < minPt_)
138  continue;
139 
140  // opposite sign or same sign
141  if (chargeOpt_ < 0) {
142  if (cand1->charge() * cand2->charge() > 0)
143  continue;
144  } else if (chargeOpt_ > 0) {
145  if (cand1->charge() * cand2->charge() < 0)
146  continue;
147  }
148 
149  // Combined ditrack system
150  e1 = sqrt(cand1->momentum().Mag2() + firstTrackMass2);
151  e2 = sqrt(cand2->momentum().Mag2() + secondTrackMass2);
152  p1 = Particle::LorentzVector(cand1->px(), cand1->py(), cand1->pz(), e1);
153  p2 = Particle::LorentzVector(cand2->px(), cand2->py(), cand2->pz(), e2);
154  p = p1 + p2;
155 
156  if (p.pt() < minPtPair_)
157  continue;
158 
159  double invmass = abs(p.mass());
160  LogDebug("HLTDisplacedtktkVtxProducer") << " ... 1-2 invmass= " << invmass;
161 
162  if (invmass < minInvMass_)
163  continue;
164  if (invmass > maxInvMass_)
165  continue;
166 
167  // do the vertex fit
168  vector<TransientTrack> t_tks;
169  TransientTrack ttkp1 = (*theB).build(&tk1);
170  TransientTrack ttkp2 = (*theB).build(&tk2);
171  t_tks.push_back(ttkp1);
172  t_tks.push_back(ttkp2);
173 
174  if (t_tks.size() != 2)
175  continue;
176 
177  KalmanVertexFitter kvf;
178  TransientVertex tv = kvf.vertex(t_tks);
179 
180  if (!tv.isValid())
181  continue;
182 
183  Vertex vertex = tv;
184 
185  // put vertex in the event
186  vertexCollection->push_back(vertex);
187  }
188  }
190 }
191 
193  const vector<RecoChargedCandidateRef>& refVect) const {
194  bool ok = false;
195  for (auto& i : refVect) {
196  if (i->get<TrackRef>() == trackref) {
197  ok = true;
198  break;
199  }
200  }
201  return ok;
202 }
ConfigurationDescriptions.h
trigger::TriggerFilterObjectWithRefs
Definition: TriggerFilterObjectWithRefs.h:35
KalmanVertexFitter::vertex
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
Definition: KalmanVertexFitter.h:49
HLTDisplacedtktkVtxProducer.h
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
HLTDisplacedtktkVtxProducer::massParticle1_
const double massParticle1_
Definition: HLTDisplacedtktkVtxProducer.h:55
KalmanVertexFitter.h
HLTDisplacedtktkVtxProducer::minPt_
const double minPt_
Definition: HLTDisplacedtktkVtxProducer.h:51
TransientVertex::isValid
bool isValid() const
Definition: TransientVertex.h:195
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTDisplacedtktkVtxProducer::~HLTDisplacedtktkVtxProducer
~HLTDisplacedtktkVtxProducer() override
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
HLTDisplacedtktkVtxProducer::minInvMass_
const double minInvMass_
Definition: HLTDisplacedtktkVtxProducer.h:53
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
edm::Handle
Definition: AssociativeIterator.h:50
HLTDisplacedtktkVtxProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HLTDisplacedtktkVtxProducer.cc:66
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 >
CandidateFwd.h
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
p2
double p2[4]
Definition: TauolaWrapper.h:90
HLTDisplacedtktkVtxProducer::previousCandToken_
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > previousCandToken_
Definition: HLTDisplacedtktkVtxProducer.h:49
HLTDisplacedtktkVtxProducer::massParticle2_
const double massParticle2_
Definition: HLTDisplacedtktkVtxProducer.h:56
RefToBase.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLTDisplacedtktkVtxProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTDisplacedtktkVtxProducer.cc:48
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
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
HLTDisplacedtktkVtxProducer::maxEta_
const double maxEta_
Definition: HLTDisplacedtktkVtxProducer.h:50
reco::JetExtendedAssociation::LorentzVector
math::PtEtaPhiELorentzVectorF LorentzVector
Definition: JetExtendedAssociation.h:25
VertexFwd.h
HLTDisplacedtktkVtxProducer::HLTDisplacedtktkVtxProducer
HLTDisplacedtktkVtxProducer(const edm::ParameterSet &)
Definition: HLTDisplacedtktkVtxProducer.cc:28
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
TriggerRefsCollections.h
HLTDisplacedtktkVtxProducer::transientTrackRecordToken_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackRecordToken_
Definition: HLTDisplacedtktkVtxProducer.h:45
HLTDisplacedtktkVtxProducer::checkPreviousCand
bool checkPreviousCand(const reco::TrackRef &trackref, const std::vector< reco::RecoChargedCandidateRef > &ref2) const
Definition: HLTDisplacedtktkVtxProducer.cc:192
HLTDisplacedtktkVtxProducer::maxInvMass_
const double maxInvMass_
Definition: HLTDisplacedtktkVtxProducer.h:54
trigger
Definition: HLTPrescaleTableCond.h:8
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
HLTDisplacedtktkVtxProducer::srcToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > srcToken_
Definition: HLTDisplacedtktkVtxProducer.h:47
RecoChargedCandidateFwd.h
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
HLTDisplacedtktkVtxProducer::chargeOpt_
const int chargeOpt_
Definition: HLTDisplacedtktkVtxProducer.h:57
KalmanVertexFitter
Definition: KalmanVertexFitter.h:22
HLTDisplacedtktkVtxProducer::minPtPair_
const double minPtPair_
Definition: HLTDisplacedtktkVtxProducer.h:52
HLTDisplacedtktkVtxProducer::triggerTypeDaughters_
const int triggerTypeDaughters_
Definition: HLTDisplacedtktkVtxProducer.h:58