CMS 3D CMS Logo

HLTScoutingEgammaProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTrigger/Egamma
4 // Class: HLTScoutingEgammaProducer
5 //
11 //
12 // Original Author: David G. Sheffield (Rutgers)
13 // Created: Mon, 20 Jul 2015
14 //
15 //
16 
18 
19 //
20 // constructors and destructor
21 //
23  : EgammaCandidateCollection_(
24  consumes<reco::RecoEcalCandidateCollection>(iConfig.getParameter<edm::InputTag>("EgammaCandidates"))),
25  EgammaGsfTrackCollection_(
26  consumes<reco::GsfTrackCollection>(iConfig.getParameter<edm::InputTag>("EgammaGsfTracks"))),
27  SigmaIEtaIEtaMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("SigmaIEtaIEtaMap"))),
28  HoverEMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("HoverEMap"))),
29  DetaMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("DetaMap"))),
30  DphiMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("DphiMap"))),
31  MissingHitsMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("MissingHitsMap"))),
32  OneOEMinusOneOPMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("OneOEMinusOneOPMap"))),
33  EcalPFClusterIsoMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("EcalPFClusterIsoMap"))),
34  EleGsfTrackIsoMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("EleGsfTrackIsoMap"))),
35  HcalPFClusterIsoMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("HcalPFClusterIsoMap"))),
36  egammaPtCut(iConfig.getParameter<double>("egammaPtCut")),
37  egammaEtaCut(iConfig.getParameter<double>("egammaEtaCut")),
38  egammaHoverECut(iConfig.getParameter<double>("egammaHoverECut")) {
39  //register products
40  produces<ScoutingElectronCollection>();
41  produces<ScoutingPhotonCollection>();
42 }
43 
45 
46 // ------------ method called to produce the data ------------
48  using namespace edm;
49 
50  std::unique_ptr<ScoutingElectronCollection> outElectrons(new ScoutingElectronCollection());
51  std::unique_ptr<ScoutingPhotonCollection> outPhotons(new ScoutingPhotonCollection());
52 
53  // Get RecoEcalCandidate
54  Handle<reco::RecoEcalCandidateCollection> EgammaCandidateCollection;
55  if (!iEvent.getByToken(EgammaCandidateCollection_, EgammaCandidateCollection)) {
56  iEvent.put(std::move(outElectrons));
57  iEvent.put(std::move(outPhotons));
58  return;
59  }
60 
61  // Get GsfTrack
62  Handle<reco::GsfTrackCollection> EgammaGsfTrackCollection;
63  if (!iEvent.getByToken(EgammaGsfTrackCollection_, EgammaGsfTrackCollection)) {
64  iEvent.put(std::move(outElectrons));
65  iEvent.put(std::move(outPhotons));
66  return;
67  }
68 
69  // Get SigmaIEtaIEtaMap
71  if (!iEvent.getByToken(SigmaIEtaIEtaMap_, SigmaIEtaIEtaMap)) {
72  iEvent.put(std::move(outElectrons));
73  iEvent.put(std::move(outPhotons));
74  return;
75  }
76 
77  // Get HoverEMap
79  if (!iEvent.getByToken(HoverEMap_, HoverEMap)) {
80  iEvent.put(std::move(outElectrons));
81  iEvent.put(std::move(outPhotons));
82  return;
83  }
84 
85  // Get DetaMap
87  if (!iEvent.getByToken(DetaMap_, DetaMap)) {
88  iEvent.put(std::move(outElectrons));
89  iEvent.put(std::move(outPhotons));
90  return;
91  }
92 
93  // Get DphiMap
95  if (!iEvent.getByToken(DphiMap_, DphiMap)) {
96  iEvent.put(std::move(outElectrons));
97  iEvent.put(std::move(outPhotons));
98  return;
99  }
100 
101  // Get MissingHitsMap
103  if (!iEvent.getByToken(MissingHitsMap_, MissingHitsMap)) {
104  iEvent.put(std::move(outElectrons));
105  iEvent.put(std::move(outPhotons));
106  return;
107  }
108 
109  // Get 1/E - 1/p Map
111  if (!iEvent.getByToken(OneOEMinusOneOPMap_, OneOEMinusOneOPMap)) {
112  iEvent.put(std::move(outElectrons));
113  iEvent.put(std::move(outPhotons));
114  return;
115  }
116 
117  // Get EcalPFClusterIsoMap
119  if (!iEvent.getByToken(EcalPFClusterIsoMap_, EcalPFClusterIsoMap)) {
120  iEvent.put(std::move(outElectrons));
121  iEvent.put(std::move(outPhotons));
122  return;
123  }
124 
125  // Get EleGsfTrackIsoMap
127  if (!iEvent.getByToken(EleGsfTrackIsoMap_, EleGsfTrackIsoMap)) {
128  iEvent.put(std::move(outElectrons));
129  iEvent.put(std::move(outPhotons));
130  return;
131  }
132 
133  // Get HcalPFClusterIsoMap
135  if (!iEvent.getByToken(HcalPFClusterIsoMap_, HcalPFClusterIsoMap)) {
136  iEvent.put(std::move(outElectrons));
137  iEvent.put(std::move(outPhotons));
138  return;
139  }
140 
141  // Produce electrons and photons
142  int index = 0;
143  for (auto& candidate : *EgammaCandidateCollection) {
144  reco::RecoEcalCandidateRef candidateRef = getRef(EgammaCandidateCollection, index);
145  ++index;
146  if (candidateRef.isNull() && !candidateRef.isAvailable())
147  continue;
148 
149  if ((*HoverEMap)[candidateRef] > egammaHoverECut)
150  continue;
151  if (candidate.pt() < egammaPtCut)
152  continue;
153  if (fabs(candidate.eta()) > egammaEtaCut)
154  continue;
155 
156  reco::SuperClusterRef scRef = candidate.superCluster();
157  if (scRef.isNull() && !scRef.isAvailable())
158  continue;
159  float d0 = 0.0;
160  float dz = 0.0;
161  int charge = -999;
162  for (auto& track : *EgammaGsfTrackCollection) {
163  RefToBase<TrajectorySeed> seed = track.extra()->seedRef();
165  RefToBase<reco::CaloCluster> caloCluster = elseed->caloCluster();
166  reco::SuperClusterRef scRefFromTrk = caloCluster.castTo<reco::SuperClusterRef>();
167  if (scRefFromTrk == scRef) {
168  d0 = track.d0();
169  dz = track.dz();
170  charge = track.charge();
171  }
172  }
173  if (charge == -999) { // No associated track. Candidate is a scouting photon
174  outPhotons->emplace_back(candidate.pt(),
175  candidate.eta(),
176  candidate.phi(),
177  candidate.mass(),
178  (*SigmaIEtaIEtaMap)[candidateRef],
179  (*HoverEMap)[candidateRef],
180  (*EcalPFClusterIsoMap)[candidateRef],
181  (*HcalPFClusterIsoMap)[candidateRef]);
182  } else { // Candidate is a scouting electron
183  outElectrons->emplace_back(candidate.pt(),
184  candidate.eta(),
185  candidate.phi(),
186  candidate.mass(),
187  d0,
188  dz,
189  (*DetaMap)[candidateRef],
190  (*DphiMap)[candidateRef],
191  (*SigmaIEtaIEtaMap)[candidateRef],
192  (*HoverEMap)[candidateRef],
193  (*OneOEMinusOneOPMap)[candidateRef],
194  (*MissingHitsMap)[candidateRef],
195  charge,
196  (*EcalPFClusterIsoMap)[candidateRef],
197  (*HcalPFClusterIsoMap)[candidateRef],
198  (*EleGsfTrackIsoMap)[candidateRef]);
199  }
200  }
201 
202  // Put output
203  iEvent.put(std::move(outElectrons));
204  iEvent.put(std::move(outPhotons));
205 }
206 
207 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
210  desc.add<edm::InputTag>("EgammaCandidates", edm::InputTag("hltEgammaCandidates"));
211  desc.add<edm::InputTag>("EgammaGsfTracks", edm::InputTag("hltEgammaGsfTracks"));
212  desc.add<edm::InputTag>("SigmaIEtaIEtaMap", edm::InputTag("hltEgammaClusterShape:sigmaIEtaIEta5x5"));
213  desc.add<edm::InputTag>("HoverEMap", edm::InputTag("hltEgammaHoverE"));
214  desc.add<edm::InputTag>("DetaMap", edm::InputTag("hltEgammaGsfTrackVars:Deta"));
215  desc.add<edm::InputTag>("DphiMap", edm::InputTag("hltEgammaGsfTrackVars:Dphi"));
216  desc.add<edm::InputTag>("MissingHitsMap", edm::InputTag("hltEgammaGsfTrackVars:MissingHits"));
217  desc.add<edm::InputTag>("OneOEMinusOneOPMap", edm::InputTag("hltEgammaGsfTrackVars:OneOESuperMinusOneOP"));
218  desc.add<edm::InputTag>("EcalPFClusterIsoMap", edm::InputTag("hltEgammaEcalPFClusterIso"));
219  desc.add<edm::InputTag>("EleGsfTrackIsoMap", edm::InputTag("hltEgammaEleGsfTrackIso"));
220  desc.add<edm::InputTag>("HcalPFClusterIsoMap", edm::InputTag("hltEgammaHcalPFClusterIso"));
221  desc.add<double>("egammaPtCut", 4.0);
222  desc.add<double>("egammaEtaCut", 2.5);
223  desc.add<double>("egammaHoverECut", 1.0);
224  descriptions.add("hltScoutingEgammaProducer", desc);
225 }
226 
227 // declare this class as a framework plugin
edm::StreamID
Definition: StreamID.h:30
reco::RecoEcalCandidateCollection
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
Definition: RecoEcalCandidateFwd.h:9
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
HLT_2018_cff.DetaMap
DetaMap
Definition: HLT_2018_cff.py:88481
HLT_2018_cff.MissingHitsMap
MissingHitsMap
Definition: HLT_2018_cff.py:88477
HLTScoutingEgammaProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTScoutingEgammaProducer.cc:208
HLT_2018_cff.HcalPFClusterIsoMap
HcalPFClusterIsoMap
Definition: HLT_2018_cff.py:88460
HLTScoutingEgammaProducer::HcalPFClusterIsoMap_
const edm::EDGetTokenT< RecoEcalCandMap > HcalPFClusterIsoMap_
Definition: HLTScoutingEgammaProducer.h:67
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
HLTScoutingEgammaProducer::OneOEMinusOneOPMap_
const edm::EDGetTokenT< RecoEcalCandMap > OneOEMinusOneOPMap_
Definition: HLTScoutingEgammaProducer.h:64
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTScoutingEgammaProducer.h
HLT_2018_cff.egammaPtCut
egammaPtCut
Definition: HLT_2018_cff.py:88474
HLTScoutingEgammaProducer::DetaMap_
const edm::EDGetTokenT< RecoEcalCandMap > DetaMap_
Definition: HLTScoutingEgammaProducer.h:61
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HLT_2018_cff.EleGsfTrackIsoMap
EleGsfTrackIsoMap
Definition: HLT_2018_cff.py:88483
HLT_2018_cff.OneOEMinusOneOPMap
OneOEMinusOneOPMap
Definition: HLT_2018_cff.py:88480
HLTScoutingEgammaProducer::produce
void produce(edm::StreamID sid, edm::Event &iEvent, edm::EventSetup const &setup) const final
Definition: HLTScoutingEgammaProducer.cc:47
HLTScoutingEgammaProducer::HoverEMap_
const edm::EDGetTokenT< RecoEcalCandMap > HoverEMap_
Definition: HLTScoutingEgammaProducer.h:60
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::Ref
Definition: AssociativeIterator.h:58
HLTScoutingEgammaProducer::egammaPtCut
const double egammaPtCut
Definition: HLTScoutingEgammaProducer.h:69
MakerMacros.h
ScoutingPhotonCollection
std::vector< ScoutingPhoton > ScoutingPhotonCollection
Definition: ScoutingPhoton.h:45
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HLT_2018_cff.EcalPFClusterIsoMap
EcalPFClusterIsoMap
Definition: HLT_2018_cff.py:88461
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
HLT_2018_cff.SigmaIEtaIEtaMap
SigmaIEtaIEtaMap
Definition: HLT_2018_cff.py:88476
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
edm::getRef
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
edm::AssociationMap
Definition: AssociationMap.h:48
HLTScoutingEgammaProducer::DphiMap_
const edm::EDGetTokenT< RecoEcalCandMap > DphiMap_
Definition: HLTScoutingEgammaProducer.h:62
HLTScoutingEgammaProducer::SigmaIEtaIEtaMap_
const edm::EDGetTokenT< RecoEcalCandMap > SigmaIEtaIEtaMap_
Definition: HLTScoutingEgammaProducer.h:59
HLTScoutingEgammaProducer::EleGsfTrackIsoMap_
const edm::EDGetTokenT< RecoEcalCandMap > EleGsfTrackIsoMap_
Definition: HLTScoutingEgammaProducer.h:66
iEvent
int iEvent
Definition: GenABIO.cc:224
HLTScoutingEgammaProducer::EcalPFClusterIsoMap_
const edm::EDGetTokenT< RecoEcalCandMap > EcalPFClusterIsoMap_
Definition: HLTScoutingEgammaProducer.h:65
edm::EventSetup
Definition: EventSetup.h:57
HLTScoutingEgammaProducer::HLTScoutingEgammaProducer
HLTScoutingEgammaProducer(const edm::ParameterSet &)
Definition: HLTScoutingEgammaProducer.cc:22
HLTScoutingEgammaProducer
Definition: HLTScoutingEgammaProducer.h:44
ScoutingElectronCollection
std::vector< ScoutingElectron > ScoutingElectronCollection
Definition: ScoutingElectron.h:99
HLT_2018_cff.egammaHoverECut
egammaHoverECut
Definition: HLT_2018_cff.py:88482
HLTScoutingEgammaProducer::EgammaGsfTrackCollection_
const edm::EDGetTokenT< reco::GsfTrackCollection > EgammaGsfTrackCollection_
Definition: HLTScoutingEgammaProducer.h:58
HLTScoutingEgammaProducer::egammaHoverECut
const double egammaHoverECut
Definition: HLTScoutingEgammaProducer.h:71
reco::GsfTrackCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLTScoutingEgammaProducer::~HLTScoutingEgammaProducer
~HLTScoutingEgammaProducer() override
PVValHelper::dz
Definition: PVValidationHelpers.h:50
HLTScoutingEgammaProducer::MissingHitsMap_
const edm::EDGetTokenT< RecoEcalCandMap > MissingHitsMap_
Definition: HLTScoutingEgammaProducer.h:63
HLTScoutingEgammaProducer::EgammaCandidateCollection_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > EgammaCandidateCollection_
Definition: HLTScoutingEgammaProducer.h:57
HLT_2018_cff.egammaEtaCut
egammaEtaCut
Definition: HLT_2018_cff.py:88471
edm::RefToBase< TrajectorySeed >
HLTScoutingEgammaProducer::egammaEtaCut
const double egammaEtaCut
Definition: HLTScoutingEgammaProducer.h:70
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
HLT_2018_cff.DphiMap
DphiMap
Definition: HLT_2018_cff.py:88484
HLT_2018_cff.HoverEMap
HoverEMap
Definition: HLT_2018_cff.py:88478
edm::Event
Definition: Event.h:73
d0
static constexpr float d0
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
edm::InputTag
Definition: InputTag.h:15
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295