CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_(consumes<reco::RecoEcalCandidateCollection>
24  (iConfig.getParameter<edm::InputTag>("EgammaCandidates"))),
25  EgammaGsfTrackCollection_(consumes<reco::GsfTrackCollection>
26  (iConfig.getParameter<edm::InputTag>("EgammaGsfTracks"))),
27  SigmaIEtaIEtaMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>(
28  "SigmaIEtaIEtaMap"))),
29  HoverEMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("HoverEMap"))),
30  DetaMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("DetaMap"))),
31  DphiMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>("DphiMap"))),
32  MissingHitsMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>(
33  "MissingHitsMap"))),
34  OneOEMinusOneOPMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>(
35  "OneOEMinusOneOPMap"))),
36  EcalPFClusterIsoMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>(
37  "EcalPFClusterIsoMap"))),
38  EleGsfTrackIsoMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>(
39  "EleGsfTrackIsoMap"))),
40  HcalPFClusterIsoMap_(consumes<RecoEcalCandMap>(iConfig.getParameter<edm::InputTag>(
41  "HcalPFClusterIsoMap"))),
42  egammaPtCut(iConfig.getParameter<double>("egammaPtCut")),
43  egammaEtaCut(iConfig.getParameter<double>("egammaEtaCut")),
44  egammaHoverECut(iConfig.getParameter<double>("egammaHoverECut"))
45 {
46  //register products
47  produces<ScoutingElectronCollection>();
48  produces<ScoutingPhotonCollection>();
49 }
50 
52 { }
53 
54 // ------------ method called to produce the data ------------
56 {
57  using namespace edm;
58 
59  // Get RecoEcalCandidate
60  Handle<reco::RecoEcalCandidateCollection> EgammaCandidateCollection;
62  EgammaCandidateCollection)){
63  edm::LogError ("HLTScoutingEgammaProducer")
64  << "invalid collection: EgammaCandidateCollection" << "\n";
65  return;
66  }
67 
68  // Get GsfTrack
69  Handle<reco::GsfTrackCollection> EgammaGsfTrackCollection;
71  EgammaGsfTrackCollection)){
72  edm::LogError ("HLTScoutingEgammaProducer")
73  << "invalid collection: EgammaGsfTrackCollection" << "\n";
74  return;
75  }
76 
77  // Get SigmaIEtaIEtaMap
78  Handle<RecoEcalCandMap> SigmaIEtaIEtaMap;
79  if(!iEvent.getByToken(SigmaIEtaIEtaMap_, SigmaIEtaIEtaMap)){
80  edm::LogError ("HLTScoutingEgammaProducer")
81  << "invalid collection: hltEgammaClusterShape:sigmaIEtaIEta5x5" << "\n";
82  return;
83  }
84 
85  // Get HoverEMap
86  Handle<RecoEcalCandMap> HoverEMap;
87  if(!iEvent.getByToken(HoverEMap_, HoverEMap)){
88  edm::LogError ("HLTScoutingEgammaProducer")
89  << "invalid collection: hltEgammaHoverE" << "\n";
90  return;
91  }
92 
93  // Get DetaMap
95  if(!iEvent.getByToken(DetaMap_, DetaMap)){
96  edm::LogError ("HLTScoutingEgammaProducer")
97  << "invalid collection: hltEgammaGsfTrackVars:Deta" << "\n";
98  return;
99  }
100 
101  // Get DphiMap
102  Handle<RecoEcalCandMap> DphiMap;
103  if(!iEvent.getByToken(DphiMap_, DphiMap)){
104  edm::LogError ("HLTScoutingEgammaProducer")
105  << "invalid collection: hltEgammaGsfTrackVars:Dphi" << "\n";
106  return;
107  }
108 
109  // Get MissingHitsMap
110  Handle<RecoEcalCandMap> MissingHitsMap;
111  if(!iEvent.getByToken(MissingHitsMap_, MissingHitsMap)){
112  edm::LogError ("HLTScoutingEgammaProducer")
113  << "invalid collection: hltEgammaGsfTrackVars:MissingHits" << "\n";
114  return;
115  }
116 
117  // Get 1/E - 1/p Map
118  Handle<RecoEcalCandMap> OneOEMinusOneOPMap;
119  if(!iEvent.getByToken(OneOEMinusOneOPMap_, OneOEMinusOneOPMap)){
120  edm::LogError ("HLTScoutingEgammaProducer")
121  << "invalid collection: hltEgammaGsfTrackVars:OneOESuperMinusOneOP" << "\n";
122  return;
123  }
124 
125  // Get EcalPFClusterIsoMap
126  Handle<RecoEcalCandMap> EcalPFClusterIsoMap;
127  if(!iEvent.getByToken(EcalPFClusterIsoMap_, EcalPFClusterIsoMap)){
128  edm::LogError ("HLTScoutingEgammaProducer")
129  << "invalid collection: hltEgammaEcalPFClusterIso" << "\n";
130  return;
131  }
132 
133  // Get EleGsfTrackIsoMap
134  Handle<RecoEcalCandMap> EleGsfTrackIsoMap;
135  if(!iEvent.getByToken(EleGsfTrackIsoMap_, EleGsfTrackIsoMap)){
136  edm::LogError ("HLTScoutingEgammaProducer")
137  << "invalid collection: hltEgammaEleGsfTrackIso" << "\n";
138  return;
139  }
140 
141  // Get HcalPFClusterIsoMap
142  Handle<RecoEcalCandMap> HcalPFClusterIsoMap;
143  if(!iEvent.getByToken(HcalPFClusterIsoMap_, HcalPFClusterIsoMap)){
144  edm::LogError ("HLTScoutingEgammaProducer")
145  << "invalid collection: HcalPFClusterIso" << "\n";
146  return;
147  }
148 
149  // Produce electrons and photons
150  std::auto_ptr<ScoutingElectronCollection> outElectrons(new ScoutingElectronCollection());
151  std::auto_ptr<ScoutingPhotonCollection> outPhotons(new ScoutingPhotonCollection());
152  int index = 0;
153  for (auto &candidate : *EgammaCandidateCollection) {
154  reco::RecoEcalCandidateRef candidateRef = getRef(EgammaCandidateCollection, index);
155  ++index;
156  if (candidateRef.isNull() && !candidateRef.isAvailable())
157  continue;
158 
159  if ((*HoverEMap)[candidateRef] > egammaHoverECut)
160  continue;
161  if (candidate.pt() < egammaPtCut)
162  continue;
163  if (fabs(candidate.eta()) > egammaEtaCut)
164  continue;
165 
166  reco::SuperClusterRef scRef = candidate.superCluster();
167  if (scRef.isNull() && !scRef.isAvailable())
168  continue;
169  float d0 = 0.0;
170  float dz = 0.0;
171  int charge = -999;
172  for (auto &track: *EgammaGsfTrackCollection) {
173  RefToBase<TrajectorySeed> seed = track.extra()->seedRef();
175  RefToBase<reco::CaloCluster> caloCluster = elseed->caloCluster();
176  reco::SuperClusterRef scRefFromTrk = caloCluster.castTo<reco::SuperClusterRef>() ;
177  if (scRefFromTrk == scRef) {
178  d0 = track.d0();
179  dz = track.dz();
180  charge = track.charge();
181  }
182  }
183  if (charge == -999) { // No associated track. Candidate is a scouting photon
184  outPhotons->emplace_back(candidate.pt(), candidate.eta(), candidate.phi(),
185  candidate.mass(), (*SigmaIEtaIEtaMap)[candidateRef],
186  (*HoverEMap)[candidateRef],
187  (*EcalPFClusterIsoMap)[candidateRef],
188  (*HcalPFClusterIsoMap)[candidateRef]);
189  } else { // Candidate is a scouting electron
190  outElectrons->emplace_back(candidate.pt(), candidate.eta(), candidate.phi(),
191  candidate.mass(), d0, dz, (*DetaMap)[candidateRef],
192  (*DphiMap)[candidateRef], (*SigmaIEtaIEtaMap)[candidateRef],
193  (*HoverEMap)[candidateRef],
194  (*OneOEMinusOneOPMap)[candidateRef],
195  (*MissingHitsMap)[candidateRef], charge,
196  (*EcalPFClusterIsoMap)[candidateRef],
197  (*HcalPFClusterIsoMap)[candidateRef],
198  (*EleGsfTrackIsoMap)[candidateRef]);
199  }
200  }
201 
202  // Put output
203  iEvent.put(outElectrons);
204  iEvent.put(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(
213  "hltEgammaClusterShape:sigmaIEtaIEta5x5"));
214  desc.add<edm::InputTag>("HoverEMap", edm::InputTag("hltEgammaHoverE"));
215  desc.add<edm::InputTag>("DetaMap", edm::InputTag("hltEgammaGsfTrackVars:Deta"));
216  desc.add<edm::InputTag>("DphiMap", edm::InputTag("hltEgammaGsfTrackVars:Dphi"));
217  desc.add<edm::InputTag>("MissingHitsMap", edm::InputTag("hltEgammaGsfTrackVars:MissingHits"));
218  desc.add<edm::InputTag>("OneOEMinusOneOPMap", edm::InputTag(
219  "hltEgammaGsfTrackVars:OneOESuperMinusOneOP"));
220  desc.add<edm::InputTag>("EcalPFClusterIsoMap", edm::InputTag("hltEgammaEcalPFClusterIso"));
221  desc.add<edm::InputTag>("EleGsfTrackIsoMap", edm::InputTag("hltEgammaEleGsfTrackIso"));
222  desc.add<edm::InputTag>("HcalPFClusterIsoMap", edm::InputTag("hltEgammaHcalPFClusterIso"));
223  desc.add<double>("egammaPtCut", 4.0);
224  desc.add<double>("egammaEtaCut", 2.5);
225  desc.add<double>("egammaHoverECut", 1.0);
226  descriptions.add("hltScoutingEgammaProducer", desc);
227 }
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
bool isAvailable() const
Definition: Ref.h:576
const edm::EDGetTokenT< RecoEcalCandMap > SigmaIEtaIEtaMap_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
const edm::EDGetTokenT< reco::GsfTrackCollection > EgammaGsfTrackCollection_
const edm::EDGetTokenT< RecoEcalCandMap > EleGsfTrackIsoMap_
const edm::EDGetTokenT< RecoEcalCandMap > HoverEMap_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > EgammaCandidateCollection_
virtual void produce(edm::StreamID sid, edm::Event &iEvent, edm::EventSetup const &setup) const overridefinal
int iEvent
Definition: GenABIO.cc:230
const edm::EDGetTokenT< RecoEcalCandMap > DetaMap_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isNull() const
Checks for null.
Definition: Ref.h:249
std::vector< ScoutingElectron > ScoutingElectronCollection
const edm::EDGetTokenT< RecoEcalCandMap > OneOEMinusOneOPMap_
const edm::EDGetTokenT< RecoEcalCandMap > MissingHitsMap_
const edm::EDGetTokenT< RecoEcalCandMap > DphiMap_
REF castTo() const
Definition: RefToBase.h:271
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
const edm::EDGetTokenT< RecoEcalCandMap > HcalPFClusterIsoMap_
std::vector< ScoutingPhoton > ScoutingPhotonCollection
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
const edm::EDGetTokenT< RecoEcalCandMap > EcalPFClusterIsoMap_
HLTScoutingEgammaProducer(const edm::ParameterSet &)