CMS 3D CMS Logo

HLTJetCollectionsForLeptonPlusJets.cc
Go to the documentation of this file.
2 
4 
9 
11 
13 
17 
18 template <typename jetType>
20  : hltLeptonTag(iConfig.getParameter<edm::InputTag>("HltLeptonTag")),
21  sourceJetTag(iConfig.getParameter<edm::InputTag>("SourceJetTag")),
22  minDeltaR_(iConfig.getParameter<double>("minDeltaR")) {
23  using namespace edm;
24  using namespace std;
25  typedef vector<RefVector<vector<jetType>, jetType, refhelper::FindUsingAdvance<vector<jetType>, jetType>>>
26  JetCollectionVector;
27  m_theLeptonToken = consumes<trigger::TriggerFilterObjectWithRefs>(hltLeptonTag);
28  m_theJetToken = consumes<std::vector<jetType>>(sourceJetTag);
29  produces<JetCollectionVector>();
30 }
31 
32 template <typename jetType>
34  // do anything here that needs to be done at desctruction time
35  // (e.g. close files, deallocate resources etc.)
36 }
37 
38 template <typename jetType>
41  desc.add<edm::InputTag>("HltLeptonTag", edm::InputTag("triggerFilterObjectWithRefs"));
42  desc.add<edm::InputTag>("SourceJetTag", edm::InputTag("caloJetCollection"));
43  desc.add<double>("minDeltaR", 0.5);
45 }
46 
47 //
48 // member functions
49 //
50 
51 // ------------ method called to produce the data ------------
52 // template <typename T>
53 template <typename jetType>
55  using namespace edm;
56  using namespace std;
57 
58  typedef vector<RefVector<vector<jetType>, jetType, refhelper::FindUsingAdvance<vector<jetType>, jetType>>>
59  JetCollectionVector;
60  typedef vector<jetType> JetCollection;
63 
65  iEvent.getByToken(m_theLeptonToken, PrevFilterOutput);
66 
67  //its easier on the if statement flow if I try everything at once, shouldnt add to timing
68  // Electrons can be stored as objects of types TriggerCluster, TriggerElectron, or TriggerPhoton
69  vector<Ref<reco::RecoEcalCandidateCollection>> clusCands;
70  PrevFilterOutput->getObjects(trigger::TriggerCluster, clusCands);
71 
72  vector<Ref<reco::ElectronCollection>> eleCands;
73  PrevFilterOutput->getObjects(trigger::TriggerElectron, eleCands);
74 
75  trigger::VRphoton photonCands;
76  PrevFilterOutput->getObjects(trigger::TriggerPhoton, photonCands);
77 
78  vector<reco::RecoChargedCandidateRef> muonCands;
79  PrevFilterOutput->getObjects(trigger::TriggerMuon, muonCands);
80 
81  Handle<JetCollection> theJetCollectionHandle;
82  iEvent.getByToken(m_theJetToken, theJetCollectionHandle);
83 
84  const JetCollection& theJetCollection = *theJetCollectionHandle;
85 
86  unique_ptr<JetCollectionVector> allSelections(new JetCollectionVector());
87 
88  if (!clusCands.empty()) { // try trigger clusters
89  for (auto& clusCand : clusCands) {
90  JetRefVector refVector;
91  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
92  if (deltaR(clusCand->superCluster()->position(), theJetCollection[j]) > minDeltaR_)
93  refVector.push_back(JetRef(theJetCollectionHandle, j));
94  }
95  allSelections->push_back(refVector);
96  }
97  }
98 
99  if (!eleCands.empty()) { // try electrons
100  for (auto& eleCand : eleCands) {
101  JetRefVector refVector;
102  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
103  if (deltaR(eleCand->superCluster()->position(), theJetCollection[j]) > minDeltaR_)
104  refVector.push_back(JetRef(theJetCollectionHandle, j));
105  }
106  allSelections->push_back(refVector);
107  }
108  }
109 
110  if (!photonCands.empty()) { // try photons
111  for (auto& photonCand : photonCands) {
112  JetRefVector refVector;
113  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
114  if (deltaR(photonCand->superCluster()->position(), theJetCollection[j]) > minDeltaR_)
115  refVector.push_back(JetRef(theJetCollectionHandle, j));
116  }
117  allSelections->push_back(refVector);
118  }
119  }
120 
121  if (!muonCands.empty()) { // muons
122  for (auto& muonCand : muonCands) {
123  JetRefVector refVector;
124  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
125  if (deltaR(muonCand->p4(), theJetCollection[j]) > minDeltaR_)
126  refVector.push_back(JetRef(theJetCollectionHandle, j));
127  }
128  allSelections->push_back(refVector);
129  }
130  }
131 
132  iEvent.put(std::move(allSelections));
133 
134  return;
135 }
HLTJetCollectionsForLeptonPlusJets
Definition: HLTJetCollectionsForLeptonPlusJets.h:40
defaultModuleLabel.h
HLTJetCollectionsForLeptonPlusJets::m_theJetToken
edm::EDGetTokenT< std::vector< jetType > > m_theJetToken
Definition: HLTJetCollectionsForLeptonPlusJets.h:50
HLTJetCollectionsForLeptonPlusJets.h
Handle.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
trigger::TriggerElectron
Definition: TriggerTypeDefs.h:78
trigger::VRphoton
std::vector< reco::RecoEcalCandidateRef > VRphoton
Definition: TriggerRefsCollections.h:70
HLTJetCollectionsForLeptonPlusJets::m_theLeptonToken
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > m_theLeptonToken
Definition: HLTJetCollectionsForLeptonPlusJets.h:49
l1t::JetRefVector
edm::RefVector< JetBxCollection > JetRefVector
Definition: Jet.h:13
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HLTJetCollectionsForLeptonPlusJets::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HLTJetCollectionsForLeptonPlusJets.cc:54
edm::RefVector
Definition: EDProductfwd.h:27
edm::Handle< trigger::TriggerFilterObjectWithRefs >
RecoCandidate.h
trigger::TriggerRefsCollections::getObjects
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
Definition: TriggerRefsCollections.h:593
edm::Ref
Definition: AssociativeIterator.h:58
deltaR.h
MakerMacros.h
HLTJetCollectionsForLeptonPlusJets::sourceJetTag
edm::InputTag sourceJetTag
Definition: HLTJetCollectionsForLeptonPlusJets.h:52
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HLTJetCollectionsForLeptonPlusJets::hltLeptonTag
edm::InputTag hltLeptonTag
Definition: HLTJetCollectionsForLeptonPlusJets.h:51
pat::JetCollection
std::vector< Jet > JetCollection
Definition: Jet.h:53
trigger::TriggerMuon
Definition: TriggerTypeDefs.h:79
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLTJetCollectionsForLeptonPlusJets::HLTJetCollectionsForLeptonPlusJets
HLTJetCollectionsForLeptonPlusJets(const edm::ParameterSet &)
Definition: HLTJetCollectionsForLeptonPlusJets.cc:19
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
defaultModuleLabel
std::string defaultModuleLabel()
Definition: defaultModuleLabel.h:16
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
trigger::TriggerCluster
Definition: TriggerTypeDefs.h:88
l1t::JetRef
edm::Ref< JetBxCollection > JetRef
Definition: Jet.h:12
Electron.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HLT_2018_cff.jetType
jetType
Definition: HLT_2018_cff.py:7318
RecoEcalCandidate.h
RecoChargedCandidate.h
SuperCluster.h
trigger::TriggerPhoton
HLT.
Definition: TriggerTypeDefs.h:77
HLTJetCollectionsForLeptonPlusJets::~HLTJetCollectionsForLeptonPlusJets
~HLTJetCollectionsForLeptonPlusJets() override
Definition: HLTJetCollectionsForLeptonPlusJets.cc:33
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
RecoChargedCandidateFwd.h
edm::InputTag
Definition: InputTag.h:15
HLTJetCollectionsForLeptonPlusJets::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTJetCollectionsForLeptonPlusJets.cc:39
HLTJetCollectionsForLeptonPlusJets::minDeltaR_
double minDeltaR_
Definition: HLTJetCollectionsForLeptonPlusJets.h:54
edm::refhelper::FindUsingAdvance
Definition: RefTraits.h:14