39 #include <Math/VectorUtil.h> 136 if (
abs(particle.pdgId()) != 22 || particle.status() != 1)
142 closestPhoton = &particle;
162 nPhoMaps_(phoMapBranchNames_.
size()),
164 valMapBranchNames_(iConfig.getParameter<
std::
vector<
std::
string>>(
"phoMVAValMapLabels")),
165 nValMaps_(valMapBranchNames_.
size()),
167 mvaCatBranchNames_(iConfig.getParameter<
std::
vector<
std::
string>>(
"phoMVACatLabels")),
168 nCats_(mvaCatBranchNames_.
size()),
169 isMC_(iConfig.getParameter<
bool>(
"isMC")),
170 ptThreshold_(iConfig.getParameter<double>(
"ptThreshold")),
171 deltaR_(iConfig.getParameter<double>(
"deltaR")),
179 mvaPasses_(nPhoMaps_),
180 mvaValues_(nValMaps_),
182 variableHelper_(consumesCollector()),
184 nVars_(mvaVarMngr_.getNVars()),
186 doEnergyMatrix_(iConfig.getParameter<
bool>(
"doEnergyMatrix")),
187 energyMatrixSize_(iConfig.getParameter<
int>(
"energyMatrixSize")) {
189 for (
auto const&
tag : phoMapTags_) {
193 for (
auto const&
tag : valMapTags_) {
197 for (
auto const&
tag : mvaCatTags_) {
204 tree_ =
fs->make<TTree>(
"tree",
"tree");
206 tree_->Branch(
"nEvent", &nEvent_);
207 tree_->Branch(
"nRun", &nRun_);
208 tree_->Branch(
"nLumi", &nLumi_);
210 tree_->Branch(
"genNpu", &genNpu_);
211 tree_->Branch(
"matchedToGenPh", &matchedToGenPh_);
213 tree_->Branch(
"vtxN", &vtxN_);
214 tree_->Branch(
"pT", &pT_);
215 tree_->Branch(
"eta", &eta_);
218 tree_->Branch(
"energyMatrix", &energyMatrix_);
221 tree_->Branch(mvaVarMngr_.getName(
i).c_str(), &vars_[
i]);
225 for (
size_t k = 0;
k < nValMaps_; ++
k) {
226 tree_->Branch(valMapBranchNames_[
k].c_str(), &mvaValues_[
k]);
229 for (
size_t k = 0;
k < nPhoMaps_; ++
k) {
230 tree_->Branch(phoMapBranchNames_[
k].c_str(), &mvaPasses_[
k]);
233 for (
size_t k = 0;
k < nCats_; ++
k) {
234 tree_->Branch(mvaCatBranchNames_[
k].c_str(), &mvaCats_[
k]);
254 std::unique_ptr<noZS::EcalClusterLazyTools> lazyTools;
257 lazyTools = std::make_unique<noZS::EcalClusterLazyTools>(
264 int bx =
pu.getBunchCrossing();
292 for (
auto const& pho :
src->ptrs()) {
301 const auto&
seed = *(pho->superCluster()->seed());
306 for (
int iVar = 0; iVar <
nVars_; ++iVar) {
336 desc.add<std::vector<std::string>>(
"phoMVAs", {});
337 desc.add<std::vector<std::string>>(
"phoMVALabels", {});
338 desc.add<std::vector<std::string>>(
"phoMVAValMaps", {});
339 desc.add<std::vector<std::string>>(
"phoMVAValMapLabels", {});
340 desc.add<std::vector<std::string>>(
"phoMVACats", {});
341 desc.add<std::vector<std::string>>(
"phoMVACatLabels", {});
342 desc.add<
bool>(
"doEnergyMatrix",
false);
343 desc.add<
int>(
"energyMatrixSize", 2)->setComment(
"extension of crystals in each direction away from the seed");
344 desc.add<
bool>(
"isMC",
true);
345 desc.add<
double>(
"ptThreshold", 15.0);
346 desc.add<
double>(
"deltaR", 0.1);
static const std::string kSharedResource
const double ptThreshold_
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MVAVariableManager< reco::Photon > mvaVarMngr_
const std::vector< std::string > mvaCatBranchNames_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileup_
const bool doEnergyMatrix_
static std::unordered_map< std::string, int > indexMap()
const std::vector< std::string > valMapTags_
std::vector< int > mvaCats_
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > mvaCatTokens_
std::vector< int > mvaPasses_
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< float > mvaValues_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const std::vector< std::string > mvaCatTags_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > phoMapTokens_
const std::vector< std::string > valMapBranchNames_
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
float getValue(int index, const ParticleType &particle, const std::vector< float > &auxVariables) const
const std::vector< std::string > phoMapBranchNames_
const edm::EDGetTokenT< edm::View< reco::Photon > > src_
const edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
bool isPromptFinalState() const
const edm::EDGetTokenT< edm::View< reco::GenParticle > > genParticles_
const MVAVariableHelper variableHelper_
const int energyMatrixSize_
const std::vector< std::string > phoMapTags_
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< float > energyMatrix_
const std::vector< float > getAuxVariables(const edm::Event &iEvent) const
std::vector< float > vars_
PhotonMVANtuplizer(const edm::ParameterSet &)
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > valMapTokens_