30 isolator_(iConfig.exists(
"userIsolation") ? iConfig.getParameter<edm::
ParameterSet>(
"userIsolation") : edm::
ParameterSet(), consumesCollector(),
false) ,
31 useUserData_(iConfig.exists(
"userData"))
59 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
60 if (addEfficiencies_) {
64 addPhotonID_ = iConfig.getParameter<
bool>(
"addPhotonID" );
68 photIDSrcs_.push_back(NameTag(
"", iConfig.getParameter<
edm::InputTag>(
"photonIDSource")));
73 if (!photIDSrcs_.empty()){
74 throw cms::Exception(
"Configuration") <<
"PATPhotonProducer: you can't specify both 'photonIDSource' and 'photonIDSources'\n";
79 for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
85 "PATPhotonProducer: id addPhotonID is true, you must specify either:\n" <<
86 "\tInputTag photonIDSource = <someTag>\n" <<
"or\n" <<
87 "\tPSet photonIDSources = { \n" <<
88 "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
91 photIDTokens_ =
edm::vector_transform(photIDSrcs_, [
this](NameTag
const &
tag){
return mayConsume<edm::ValueMap<Bool_t> >(tag.second);});
93 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions");
94 if (addResolutions_) {
102 produces<std::vector<Photon> >();
105 readIsolationLabels(iConfig,
"isoDeposits", isoDepositLabels_, isoDepositTokens_);
107 readIsolationLabels(iConfig,
"isolationValues", isolationValueLabels_, isolationValueTokens_);
111 PATPhotonProducer::~PATPhotonProducer() {
152 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > >genMatches(
genMatchTokens_.size());
176 std::vector<edm::Handle<edm::ValueMap<Bool_t> > > idhandles;
177 std::vector<pat::Photon::IdPair> ids;
188 std::vector<Photon> * PATPhotons =
new std::vector<Photon>();
191 unsigned int idx = itPhoton - photons->begin();
194 Photon aPhoton(photonRef);
200 std::vector<DetId> selectedCells;
201 bool barrel = itPhoton->isEB();
204 for (
reco::CaloCluster_iterator clusIt = itPhoton->superCluster()->clustersBegin(); clusIt!=itPhoton->superCluster()->clustersEnd(); ++clusIt) {
206 DetId seed = lazyTools.getMaximum(**clusIt).first;
210 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
213 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
214 selectedCells.push_back(
hit.first);
220 std::sort(selectedCells.begin(),selectedCells.end());
221 std::unique(selectedCells.begin(),selectedCells.end());
226 float cryPhi, cryEta, thetatilt, phitilt;
229 switch( photonRef->
superCluster()->seed()->hitsAndFractions().at(0).first.subdetId() ) {
242 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];
306 bool passelectronveto =
false;
320 float maxDR=999., maxDRDPhi=999., maxDRDEta=999., maxDRRawEnergy=0.;
321 float subClusRawE[3], subClusDPhi[3], subClusDEta[3];
322 memset(subClusRawE,0,3*
sizeof(
float));
323 memset(subClusDPhi,0,3*
sizeof(
float));
324 memset(subClusDEta,0,3*
sizeof(
float));
326 for(
auto clus = photonRef->
superCluster()->clustersBegin()+1; clus != photonRef->
superCluster()->clustersEnd(); ++clus ) {
327 const float this_deta = (*clus)->eta() - photonRef->
superCluster()->seed()->eta();
329 const float this_dr = std::hypot(this_deta,this_dphi);
330 if(this_dr > maxDR || maxDR == 999.0
f) {
332 maxDRDEta = this_deta;
333 maxDRDPhi = this_dphi;
334 maxDRRawEnergy = (*clus)->energy();
337 subClusRawE[iclus] = (*clus)->energy();
338 subClusDEta[iclus] = this_deta;
339 subClusDPhi[iclus] = this_dphi;
344 const float e2nd = EcalClusterTools::e2nd( *photonRef->
superCluster()->seed(), &*rechitsH );
350 std::vector<float> vCov = EcalClusterTools::localCovariances( *photonRef->
superCluster()->seed(), &*rechitsH,
ecalTopology_ );
351 const float see = (
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
352 const float spp = (
isnan(vCov[2]) ? 0. :
sqrt(vCov[2]));
353 const float sep = vCov[1];
387 PATPhotons->push_back(aPhoton);
394 std::auto_ptr<std::vector<Photon> > myPhotons(PATPhotons);
395 iEvent.
put(myPhotons);
404 iDesc.
setComment(
"PAT photon producer module");
412 iDesc.
add<
bool>(
"embedSuperCluster",
true)->setComment(
"embed external super cluster");
413 iDesc.
add<
bool>(
"embedSeedCluster",
true)->setComment(
"embed external seed cluster");
414 iDesc.
add<
bool>(
"embedBasicClusters",
true)->setComment(
"embed external basic clusters");
415 iDesc.
add<
bool>(
"embedPreshowerClusters",
true)->setComment(
"embed external preshower clusters");
416 iDesc.
add<
bool>(
"embedRecHits",
true)->setComment(
"embed external RecHits");
421 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
422 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
423 std::vector<edm::InputTag> emptySourceVector;
426 )->
setComment(
"input with MC match information");
431 iDesc.
add<
bool>(
"addPhotonID",
true)->setComment(
"add photon ID variables");
436 )->
setComment(
"input with photon ID variables");
449 isoDepositsPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
463 isolationValuesPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
464 iDesc.
addOptional(
"isolationValues", isolationValuesPSet);
469 iDesc.
add(
"efficiencies", efficienciesPSet);
470 iDesc.
add<
bool>(
"addEfficiencies",
false);
479 iDesc.
add(
"userIsolation", isolationPSet);
482 )->
setComment(
"input with high level selection");
484 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_