32 isolator_(iConfig.exists(
"userIsolation") ? iConfig.getParameter<edm::
ParameterSet>(
"userIsolation") : edm::
ParameterSet(), consumesCollector(),
false) ,
33 useUserData_(iConfig.exists(
"userData"))
61 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
62 if (addEfficiencies_) {
66 addPhotonID_ = iConfig.getParameter<
bool>(
"addPhotonID" );
70 photIDSrcs_.push_back(NameTag(
"", iConfig.getParameter<
edm::InputTag>(
"photonIDSource")));
75 if (!photIDSrcs_.empty()){
76 throw cms::Exception(
"Configuration") <<
"PATPhotonProducer: you can't specify both 'photonIDSource' and 'photonIDSources'\n";
81 for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
87 "PATPhotonProducer: id addPhotonID is true, you must specify either:\n" <<
88 "\tInputTag photonIDSource = <someTag>\n" <<
"or\n" <<
89 "\tPSet photonIDSources = { \n" <<
90 "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
93 photIDTokens_ =
edm::vector_transform(photIDSrcs_, [
this](NameTag
const &
tag){
return mayConsume<edm::ValueMap<Bool_t> >(tag.second);});
95 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions");
96 if (addResolutions_) {
100 if ( useUserData_ ) {
104 produces<std::vector<Photon> >();
107 readIsolationLabels(iConfig,
"isoDeposits", isoDepositLabels_, isoDepositTokens_);
109 readIsolationLabels(iConfig,
"isolationValues", isolationValueLabels_, isolationValueTokens_);
113 PATPhotonProducer::~PATPhotonProducer() {
151 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > >genMatches(
genMatchTokens_.size());
175 std::vector<edm::Handle<edm::ValueMap<Bool_t> > > idhandles;
176 std::vector<pat::Photon::IdPair> ids;
187 std::vector<Photon> * PATPhotons =
new std::vector<Photon>();
190 unsigned int idx = itPhoton - photons->begin();
193 Photon aPhoton(photonRef);
199 std::vector<DetId> selectedCells;
200 bool barrel = itPhoton->isEB();
203 for (
reco::CaloCluster_iterator clusIt = itPhoton->superCluster()->clustersBegin(); clusIt!=itPhoton->superCluster()->clustersEnd(); ++clusIt) {
205 DetId seed = lazyTools.getMaximum(**clusIt).first;
209 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
212 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
213 selectedCells.push_back(
hit.first);
219 std::sort(selectedCells.begin(),selectedCells.end());
220 std::unique(selectedCells.begin(),selectedCells.end());
234 if(photonRef->
superCluster()->seed()->hitsAndFractions().at(0).first.subdetId()==
EcalBarrel ) recHits = recHitsEBHandle.product();
241 unsigned nSelectedCells = selectedCells.
size();
242 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
244 if ( it != recHits->
end() ) {
248 selectedRecHits.
sort();
253 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
278 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
282 for (
size_t j = 0;
j<isolationValues.size(); ++
j) {
289 ids[
i].second = (*idhandles[
i])[photonRef];
300 bool passelectronveto =
false;
316 recHitsEBHandle.product(),recHitsEEHandle.
product(),
353 PATPhotons->push_back(aPhoton);
360 std::auto_ptr<std::vector<Photon> > myPhotons(PATPhotons);
361 iEvent.
put(myPhotons);
370 iDesc.
setComment(
"PAT photon producer module");
379 iDesc.
add<
bool>(
"embedSuperCluster",
true)->setComment(
"embed external super cluster");
380 iDesc.
add<
bool>(
"embedSeedCluster",
true)->setComment(
"embed external seed cluster");
381 iDesc.
add<
bool>(
"embedBasicClusters",
true)->setComment(
"embed external basic clusters");
382 iDesc.
add<
bool>(
"embedPreshowerClusters",
true)->setComment(
"embed external preshower clusters");
383 iDesc.
add<
bool>(
"embedRecHits",
true)->setComment(
"embed external RecHits");
386 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
387 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
388 std::vector<edm::InputTag> emptySourceVector;
391 )->
setComment(
"input with MC match information");
396 iDesc.
add<
bool>(
"addPhotonID",
true)->setComment(
"add photon ID variables");
401 )->
setComment(
"input with photon ID variables");
414 isoDepositsPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
428 isolationValuesPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
429 iDesc.
addOptional(
"isolationValues", isolationValuesPSet);
434 iDesc.
add(
"efficiencies", efficienciesPSet);
435 iDesc.
add<
bool>(
"addEfficiencies",
false);
444 iDesc.
add(
"userIsolation", isolationPSet);
447 )->
setComment(
"input with high level selection");
449 descriptions.
add(
"PATPhotonProducer", iDesc);
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
bool enabled() const
'true' if this there is at least one efficiency configured
float sigmaIPhiIPhi() const
bool embedPreshowerClusters_
T getParameter(std::string const &) const
void setComment(std::string const &value)
Assists in assimilating all pat::UserData into pat objects.
const std::vector< float > & subClusRawEnergy() const
Analysis-level Photon class.
pat::PATUserDataHelper< pat::Photon > userDataHelper_
float maxSubClusDRRawEnergy() const
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
float maxSubClusDRDEta() const
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
void setSubClusDPhi3(float s)
static const HistoName names[]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setAllowAnything()
allow any parameter label/value pairs
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
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)
#define DEFINE_FWK_MODULE(type)
void setMaxDRRawEnergy(float m)
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
void embedBasicClusters()
method to store the electron's basic clusters
edm::EDGetTokenT< edm::View< reco::Photon > > photonToken_
std::vector< EcalRecHit >::const_iterator const_iterator
void setSubClusDPhi2(float s)
void push_back(T const &t)
float seedCrysPhiOrY() const
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
void embedSuperCluster()
method to store the photon's supercluster internally
pat::helper::KinResolutionsLoader resolutionLoader_
float sigmaIEtaIEta() const
GreaterByEt< Photon > eTComparator_
const CaloGeometry * ecalGeometry_
float sigmaIEtaIPhi() const
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 >
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
edm::InputTag reducedEndcapRecHitCollection_
bool enabled() const
'true' if this there is at least one efficiency configured
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static void fillDescription(edm::ParameterSetDescription &iDesc)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
bool enabled() const
True if it has a non null configuration.
IsolationLabels isoDepositLabels_
void setIsolation(IsolationKeys key, float value)
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.
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
const CaloTopology * ecalTopology_
float seedCrysIPhiOrIY() const
IsolationLabels isolationValueLabels_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void setMaxDRDEta(float m)
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
pat::helper::EfficiencyLoader efficiencyLoader_
float maxSubClusDR() const
void setPhotonIDs(const std::vector< IdPair > &ids)
float seedCrysIEtaOrIX() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setPassElectronVeto(bool flag)
void embedSeedCluster()
method to store the electron's seedcluster internally
float maxSubClusDRDPhi() const
void embedPreshowerClusters()
method to store the electron's preshower clusters
void setSeedEnergy(float e)
void setSubClusDPhi1(float s)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< NameTag > photIDSrcs_
void setSubClusDEta1(float s)
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
pat::helper::MultiIsolator isolator_
float seedCrysEtaOrX() const
const_iterator end() const
void addGenParticleRef(const reco::GenParticleRef &ref)
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
void setHasPixelSeed(bool flag)
T const * product() const
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
void setSubClusDEta2(float s)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
bool hasPixelSeed() const
Bool flagging photons having a non-zero size vector of Ref to electornPixel seeds.
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
void setSubClusRawE2(float s)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
const std::vector< float > & subClusDEta() const
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
void setMaxDRDPhi(float m)
iterator find(key_type k)
const std::vector< float > & subClusDPhi() const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
void setSubClusDEta3(float s)
void setSubClusRawE1(float s)
PATPhotonProducer(const edm::ParameterSet &iConfig)
void setSubClusRawE3(float s)
volatile std::atomic< bool > shutdown_flag false
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
edm::InputTag reducedBarrelRecHitCollection_
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Produces the pat::Photon.
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_