85 std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection>>>
genMatchTokens_;
105 template <
typename T>
118 typedef std::pair<std::string, edm::InputTag>
NameTag;
140 template <
typename T>
150 if (depconf.
exists(
"tracker"))
152 if (depconf.
exists(
"ecal"))
154 if (depconf.
exists(
"hcal"))
156 if (depconf.
exists(
"pfAllParticles")) {
159 if (depconf.
exists(
"pfChargedHadrons")) {
163 if (depconf.
exists(
"pfChargedAll")) {
166 if (depconf.
exists(
"pfPUChargedHadrons")) {
170 if (depconf.
exists(
"pfNeutralHadrons")) {
174 if (depconf.
exists(
"pfPhotons")) {
177 if (depconf.
exists(
"user")) {
178 std::vector<edm::InputTag> userdeps = depconf.
getParameter<std::vector<edm::InputTag>>(
"user");
179 std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
181 for (; it != ed; ++it, ++
key) {
193 : ecalClusterToolsESGetTokens_{consumesCollector()},
194 isolator_(iConfig.getParameter<
edm::ParameterSet>(
"userIsolation"), consumesCollector(),
false),
195 useUserData_(iConfig.exists(
"userData")),
199 photonToken_ = consumes<edm::View<reco::Photon>>(iConfig.getParameter<
edm::InputTag>(
"photonSource"));
200 electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<
edm::InputTag>(
"electronSource"));
201 hConversionsToken_ = consumes<reco::ConversionCollection>(iConfig.getParameter<
edm::InputTag>(
"conversionSource"));
202 beamLineToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<
edm::InputTag>(
"beamLineSrc"));
203 embedSuperCluster_ = iConfig.getParameter<
bool>(
"embedSuperCluster");
204 embedSeedCluster_ = iConfig.getParameter<
bool>(
"embedSeedCluster");
205 embedBasicClusters_ = iConfig.getParameter<
bool>(
"embedBasicClusters");
206 embedPreshowerClusters_ = iConfig.getParameter<
bool>(
"embedPreshowerClusters");
207 embedRecHits_ = iConfig.getParameter<
bool>(
"embedRecHits");
208 reducedBarrelRecHitCollection_ = iConfig.getParameter<
edm::InputTag>(
"reducedBarrelRecHitCollection");
209 reducedBarrelRecHitCollectionToken_ = mayConsume<EcalRecHitCollection>(reducedBarrelRecHitCollection_);
210 reducedEndcapRecHitCollection_ = iConfig.getParameter<
edm::InputTag>(
"reducedEndcapRecHitCollection");
211 reducedEndcapRecHitCollectionToken_ = mayConsume<EcalRecHitCollection>(reducedEndcapRecHitCollection_);
213 addGenMatch_ = iConfig.getParameter<
bool>(
"addGenMatch");
215 embedGenMatch_ = iConfig.getParameter<
bool>(
"embedGenMatch");
220 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
221 if (addEfficiencies_) {
226 addPuppiIsolation_ = iConfig.getParameter<
bool>(
"addPuppiIsolation");
227 if (addPuppiIsolation_) {
228 PUPPIIsolation_charged_hadrons_ =
229 consumes<edm::ValueMap<float>>(iConfig.getParameter<
edm::InputTag>(
"puppiIsolationChargedHadrons"));
230 PUPPIIsolation_neutral_hadrons_ =
231 consumes<edm::ValueMap<float>>(iConfig.getParameter<
edm::InputTag>(
"puppiIsolationNeutralHadrons"));
232 PUPPIIsolation_photons_ =
233 consumes<edm::ValueMap<float>>(iConfig.getParameter<
edm::InputTag>(
"puppiIsolationPhotons"));
235 addPFClusterIso_ = iConfig.getParameter<
bool>(
"addPFClusterIso");
236 if (addPFClusterIso_) {
237 ecalPFClusterIsoT_ = consumes<edm::ValueMap<float>>(iConfig.getParameter<
edm::InputTag>(
"ecalPFClusterIsoMap"));
238 auto hcPFC = iConfig.getParameter<
edm::InputTag>(
"hcalPFClusterIsoMap");
239 if (not hcPFC.label().empty())
244 addPhotonID_ = iConfig.getParameter<
bool>(
"addPhotonID");
248 photIDSrcs_.push_back(NameTag(
"", iConfig.getParameter<
edm::InputTag>(
"photonIDSource")));
253 if (!photIDSrcs_.empty()) {
255 <<
"PATPhotonProducer: you can't specify both 'photonIDSource' and 'photonIDSources'\n";
260 for (std::vector<std::string>::const_iterator it =
names.begin(), ed =
names.end(); it != ed; ++it) {
265 if (photIDSrcs_.empty())
266 throw cms::Exception(
"Configuration") <<
"PATPhotonProducer: id addPhotonID is true, you must specify either:\n" 267 <<
"\tInputTag photonIDSource = <someTag>\n" 269 <<
"\tPSet photonIDSources = { \n" 270 <<
"\t\tInputTag <someName> = <someTag> // as many as you want \n " 274 photIDSrcs_, [
this](NameTag
const&
tag) {
return mayConsume<edm::ValueMap<Bool_t>>(
tag.second); });
276 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions");
277 if (addResolutions_) {
287 produces<std::vector<Photon>>();
290 readIsolationLabels(iConfig,
"isoDeposits", isoDepositLabels_, isoDepositTokens_);
292 readIsolationLabels(iConfig,
"isolationValues", isolationValueLabels_, isolationValueTokens_);
294 saveRegressionData_ = iConfig.getParameter<
bool>(
"saveRegressionData");
301 if (
iEvent.isRealData()) {
331 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>> genMatches(
genMatchTokens_.size());
357 std::vector<edm::Handle<edm::ValueMap<Bool_t>>> idhandles;
358 std::vector<pat::Photon::IdPair> ids;
379 std::vector<Photon>* PATPhotons =
new std::vector<Photon>();
382 unsigned int idx = itPhoton -
photons->begin();
385 Photon aPhoton(photonRef);
396 std::vector<DetId> selectedCells;
397 bool barrel = itPhoton->isEB();
401 clusIt != itPhoton->superCluster()->clustersEnd();
404 DetId seed = lazyTools.getMaximum(**clusIt).first;
406 std::vector<DetId> dets5x5 =
409 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
412 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
413 selectedCells.push_back(
hit.first);
419 std::sort(selectedCells.begin(), selectedCells.end());
420 std::unique(selectedCells.begin(), selectedCells.end());
433 recHits = recHitsEBHandle.product();
439 unsigned nSelectedCells = selectedCells.
size();
440 for (
unsigned icell = 0; icell < nSelectedCells; ++icell) {
446 selectedRecHits.
sort();
452 for (
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
481 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
492 ids[
i].second = (*idhandles[
i])[photonRef];
502 bool passelectronveto =
false;
520 recHitsEBHandle.product(),
592 (*PUPPIIsolation_neutral_hadrons)[phoPtr],
593 (*PUPPIIsolation_photons)[phoPtr]);
614 PATPhotons->push_back(aPhoton);
621 std::unique_ptr<std::vector<Photon>> myPhotons(PATPhotons);
630 iDesc.
setComment(
"PAT photon producer module");
643 "ecalPFClusterIsoMap",
edm::InputTag(
"photonEcalPFClusterIsolationProducer"),
true) and
645 "hcalPFClusterIsoMap",
edm::InputTag(
"photonHcalPFClusterIsolationProducer"),
true))
or 652 "puppiIsolationChargedHadrons",
edm::InputTag(
"egmPhotonPUPPIIsolation",
"h+-DR030-"),
true) and
654 "puppiIsolationNeutralHadrons",
edm::InputTag(
"egmPhotonPUPPIIsolation",
"h0-DR030-"),
true) and
656 "puppiIsolationPhotons",
edm::InputTag(
"egmPhotonPUPPIIsolation",
"gamma-DR030-"),
true))
or 659 iDesc.
add<
bool>(
"embedSuperCluster",
true)->setComment(
"embed external super cluster");
660 iDesc.
add<
bool>(
"embedSeedCluster",
true)->setComment(
"embed external seed cluster");
661 iDesc.
add<
bool>(
"embedBasicClusters",
true)->setComment(
"embed external basic clusters");
662 iDesc.
add<
bool>(
"embedPreshowerClusters",
true)->setComment(
"embed external preshower clusters");
663 iDesc.
add<
bool>(
"embedRecHits",
true)->setComment(
"embed external RecHits");
666 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
667 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
668 std::vector<edm::InputTag> emptySourceVector;
672 ->
setComment(
"input with MC match information");
677 iDesc.
add<
bool>(
"addPhotonID",
true)->setComment(
"add photon ID variables");
683 ->
setComment(
"input with photon ID variables");
696 isoDepositsPSet.
addOptional<std::vector<edm::InputTag>>(
"user");
710 isolationValuesPSet.
addOptional<std::vector<edm::InputTag>>(
"user");
711 iDesc.
addOptional(
"isolationValues", isolationValuesPSet);
716 iDesc.
add(
"efficiencies", efficienciesPSet);
717 iDesc.
add<
bool>(
"addEfficiencies",
false);
726 iDesc.
add(
"userIsolation", isolationPSet);
729 ->
setComment(
"input with high level selection");
731 iDesc.
add<
bool>(
"saveRegressionData",
true)->setComment(
"save regression input variables");
733 descriptions.
add(
"PATPhotonProducer", iDesc);
float maxSubClusDRDEta() const
bool hasPixelSeed() const
Bool flagging photons having a non-zero size vector of Ref to electornPixel seeds.
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
bool embedPreshowerClusters_
void setPflowIsolationVariables(const PflowIsolationVariables &pfisol)
Set Particle Flow Isolation variables.
bool enabled() const
'true' if this there is at least one efficiency configured
void setComment(std::string const &value)
float sigmaIPhiIPhi() const
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
T getParameter(std::string const &) const
float seedCrysPhiOrY() const
pat::PATUserDataHelper< pat::Photon > userDataHelper_
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
float maxSubClusDRDPhi() const
bool enabled() const
True if it has a non null configuration.
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
void setSubClusDPhi3(float s)
std::pair< std::string, edm::InputTag > NameTag
const Point & position() const
position
float seedCrysIPhiOrIY() const
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T >>> &tokens)
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
void setAllowAnything()
allow any parameter label/value pairs
std::vector< edm::EDGetTokenT< edm::ValueMap< Bool_t > > > photIDTokens_
void fill(const reco::SuperCluster &superClus, const EcalRecHitCollection *ebRecHits, const EcalRecHitCollection *eeRecHits, const CaloGeometry *geom, const CaloTopology *topology, const reco::VertexCollection *vertices)
float maxSubClusDRRawEnergy() const
void setMaxDRRawEnergy(float m)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
void embedSeedCluster()
method to store the electron's seedcluster internally
T const * product() const
constexpr bool isUninitialized() const noexcept
edm::EDGetTokenT< edm::View< reco::Photon > > photonToken_
std::vector< EcalRecHit >::const_iterator const_iterator
void setSubClusDPhi2(float s)
edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
void push_back(T const &t)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
float seedCrysEtaOrX() const
void setIsolationPUPPI(float chargedhadrons_, float neutralhadrons_, float photons_)
Sets PUPPI isolation.
pat::helper::KinResolutionsLoader resolutionLoader_
edm::EDGetTokenT< edm::ValueMap< float > > hcalPFClusterIsoT_
GreaterByEt< Photon > eTComparator_
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
IsolationKeys
Enum defining isolation keys.
const CaloGeometry * ecalGeometry_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
const std::string names[nVars_]
edm::InputTag reducedEndcapRecHitCollection_
float seedCrysIEtaOrIX() const
std::vector< IsolationLabel > IsolationLabels
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
static void fillDescription(edm::ParameterSetDescription &iDesc)
IsolationLabels isoDepositLabels_
void setIsolation(IsolationKeys key, float value)
const std::vector< float > & subClusDEta() const
void setComment(std::string const &value)
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
const std::vector< float > & subClusDPhi() const
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
const CaloTopology * ecalTopology_
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
IsolationLabels isolationValueLabels_
void setMaxDRDEta(float m)
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
pat::helper::EfficiencyLoader efficiencyLoader_
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
def unique(seq, keepstr=True)
bool enabled() const
'true' if this there is at least one efficiency configured
void setPhotonIDs(const std::vector< IdPair > &ids)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
void embedBasicClusters()
method to store the electron's basic clusters
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_photons_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setPassElectronVeto(bool flag)
#define DEFINE_FWK_MODULE(type)
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
void setSeedEnergy(float e)
void setSubClusDPhi1(float s)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
~PATPhotonProducer() override
std::vector< NameTag > photIDSrcs_
void setSubClusDEta1(float s)
pat::helper::MultiIsolator isolator_
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
void embedPreshowerClusters()
method to store the electron's preshower clusters
float sigmaIEtaIEta() const
void embedSuperCluster()
method to store the photon's supercluster internally
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
void addGenParticleRef(const reco::GenParticleRef &ref)
float sigmaIEtaIPhi() const
void setHasPixelSeed(bool flag)
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
void setSubClusDEta2(float s)
void setSubClusRawE2(float s)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
float maxSubClusDR() const
void setMaxDRDPhi(float m)
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
void setSubClusDEta3(float s)
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > ecalTopologyToken_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
void setSubClusRawE1(float s)
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
PATPhotonProducer(const edm::ParameterSet &iConfig)
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > ecalGeometryToken_
void setSubClusRawE3(float s)
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
const PflowIsolationVariables & getPflowIsolationVariables() const
Get Particle Flow Isolation variables block.
edm::InputTag reducedBarrelRecHitCollection_
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
const std::vector< float > & subClusRawEnergy() const
edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
Produces the pat::Photon.
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_