31 isolator_(iConfig.exists(
"userIsolation") ? iConfig.getParameter<edm::
ParameterSet>(
"userIsolation") : edm::
ParameterSet(), consumesCollector(),
false) ,
32 useUserData_(iConfig.exists(
"userData"))
60 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
61 if (addEfficiencies_) {
65 addPhotonID_ = iConfig.getParameter<
bool>(
"addPhotonID" );
69 photIDSrcs_.push_back(NameTag(
"", iConfig.getParameter<
edm::InputTag>(
"photonIDSource")));
74 if (!photIDSrcs_.empty()){
75 throw cms::Exception(
"Configuration") <<
"PATPhotonProducer: you can't specify both 'photonIDSource' and 'photonIDSources'\n";
80 for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
86 "PATPhotonProducer: id addPhotonID is true, you must specify either:\n" <<
87 "\tInputTag photonIDSource = <someTag>\n" <<
"or\n" <<
88 "\tPSet photonIDSources = { \n" <<
89 "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
92 photIDTokens_ =
edm::vector_transform(photIDSrcs_, [
this](NameTag
const &
tag){
return mayConsume<edm::ValueMap<Bool_t> >(tag.second);});
94 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions");
95 if (addResolutions_) {
103 produces<std::vector<Photon> >();
106 readIsolationLabels(iConfig,
"isoDeposits", isoDepositLabels_, isoDepositTokens_);
108 readIsolationLabels(iConfig,
"isolationValues", isolationValueLabels_, isolationValueTokens_);
112 PATPhotonProducer::~PATPhotonProducer() {
150 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > >genMatches(
genMatchTokens_.size());
174 std::vector<edm::Handle<edm::ValueMap<Bool_t> > > idhandles;
175 std::vector<pat::Photon::IdPair> ids;
186 std::vector<Photon> * PATPhotons =
new std::vector<Photon>();
189 unsigned int idx = itPhoton - photons->begin();
192 Photon aPhoton(photonRef);
198 std::vector<DetId> selectedCells;
199 bool barrel = itPhoton->isEB();
202 for (
reco::CaloCluster_iterator clusIt = itPhoton->superCluster()->clustersBegin(); clusIt!=itPhoton->superCluster()->clustersEnd(); ++clusIt) {
204 DetId seed = lazyTools.getMaximum(**clusIt).first;
208 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
211 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
212 selectedCells.push_back(
hit.first);
218 std::sort(selectedCells.begin(),selectedCells.end());
219 std::unique(selectedCells.begin(),selectedCells.end());
224 float cryPhi, cryEta, thetatilt, phitilt;
228 switch( photonRef->
superCluster()->seed()->hitsAndFractions().at(0).first.subdetId() ) {
241 edm::LogError(
"PFECALSuperClusterProducer::calculateRegressedEnergy") <<
"Supercluster seed is either EB nor EE!" << std::endl;
248 unsigned nSelectedCells = selectedCells.
size();
249 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
251 if ( it != recHits->
end() ) {
255 selectedRecHits.
sort();
260 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
285 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
289 for (
size_t j = 0;
j<isolationValues.size(); ++
j) {
296 ids[
i].second = (*idhandles[
i])[photonRef];
307 bool passelectronveto =
false;
322 float maxDR=999., maxDRDPhi=999., maxDRDEta=999., maxDRRawEnergy=0.;
323 float subClusRawE[3], subClusDPhi[3], subClusDEta[3];
324 memset(subClusRawE,0,3*
sizeof(
float));
325 memset(subClusDPhi,0,3*
sizeof(
float));
326 memset(subClusDEta,0,3*
sizeof(
float));
328 for(
auto clus = photonRef->
superCluster()->clustersBegin()+1; clus != photonRef->
superCluster()->clustersEnd(); ++clus ) {
329 const float this_deta = (*clus)->eta() - photonRef->
superCluster()->seed()->eta();
331 const float this_dr = std::hypot(this_deta,this_dphi);
332 if(this_dr > maxDR || maxDR == 999.0
f) {
334 maxDRDEta = this_deta;
335 maxDRDPhi = this_dphi;
336 maxDRRawEnergy = (*clus)->energy();
339 subClusRawE[iclus] = (*clus)->energy();
340 subClusDEta[iclus] = this_deta;
341 subClusDPhi[iclus] = this_dphi;
346 const float eMax = EcalClusterTools::eMax( *photonRef->
superCluster()->seed(), &*rechitsH );
347 const float e2nd = EcalClusterTools::e2nd( *photonRef->
superCluster()->seed(), &*rechitsH );
353 std::vector<float> vCov = EcalClusterTools::localCovariances( *photonRef->
superCluster()->seed(), &*rechitsH,
ecalTopology_ );
354 const float see = (
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
355 const float spp = (
isnan(vCov[2]) ? 0. :
sqrt(vCov[2]));
391 PATPhotons->push_back(aPhoton);
398 std::auto_ptr<std::vector<Photon> > myPhotons(PATPhotons);
399 iEvent.
put(myPhotons);
408 iDesc.
setComment(
"PAT photon producer module");
417 iDesc.
add<
bool>(
"embedSuperCluster",
true)->setComment(
"embed external super cluster");
418 iDesc.
add<
bool>(
"embedSeedCluster",
true)->setComment(
"embed external seed cluster");
419 iDesc.
add<
bool>(
"embedBasicClusters",
true)->setComment(
"embed external basic clusters");
420 iDesc.
add<
bool>(
"embedPreshowerClusters",
true)->setComment(
"embed external preshower clusters");
421 iDesc.
add<
bool>(
"embedRecHits",
true)->setComment(
"embed external RecHits");
424 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
425 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
426 std::vector<edm::InputTag> emptySourceVector;
429 )->
setComment(
"input with MC match information");
434 iDesc.
add<
bool>(
"addPhotonID",
true)->setComment(
"add photon ID variables");
439 )->
setComment(
"input with photon ID variables");
452 isoDepositsPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
466 isolationValuesPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
467 iDesc.
addOptional(
"isolationValues", isolationValuesPSet);
472 iDesc.
add(
"efficiencies", efficienciesPSet);
473 iDesc.
add<
bool>(
"addEfficiencies",
false);
482 iDesc.
add(
"userIsolation", isolationPSet);
485 )->
setComment(
"input with high level selection");
487 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
bool embedPreshowerClusters_
T getParameter(std::string const &) const
void setComment(std::string const &value)
Assists in assimilating all pat::UserData into pat objects.
Analysis-level Photon class.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
pat::PATUserDataHelper< pat::Photon > userDataHelper_
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
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_
#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)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
double Phi_mpi_pi(double x)
void embedSuperCluster()
method to store the photon's supercluster internally
pat::helper::KinResolutionsLoader resolutionLoader_
GreaterByEt< Photon > eTComparator_
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 >
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_
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_
void setPhotonIDs(const std::vector< IdPair > &ids)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setPassElectronVeto(bool flag)
void embedSeedCluster()
method to store the electron's seedcluster internally
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_
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)
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
void localCoordsEB(const reco::CaloCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
void setMaxDRDPhi(float m)
iterator find(key_type k)
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_