39 #include <Math/VectorUtil.h>
134 for (
auto& particle : genParticles) {
136 if (
abs(particle.pdgId()) != 22 || particle.status() != 1)
142 closestPhoton = &particle;
160 : phoMapTags_(iConfig.getParameter<std::
vector<std::
string>>(
"phoMVAs")),
161 phoMapBranchNames_(iConfig.getParameter<std::
vector<std::
string>>(
"phoMVALabels")),
162 nPhoMaps_(phoMapBranchNames_.
size()),
163 valMapTags_(iConfig.getParameter<std::
vector<std::
string>>(
"phoMVAValMaps")),
164 valMapBranchNames_(iConfig.getParameter<std::
vector<std::
string>>(
"phoMVAValMapLabels")),
165 nValMaps_(valMapBranchNames_.
size()),
166 mvaCatTags_(iConfig.getParameter<std::
vector<std::
string>>(
"phoMVACats")),
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")),
173 vertices_(consumes<std::
vector<
reco::Vertex>>(iConfig.getParameter<edm::
InputTag>(
"vertices"))),
179 mvaPasses_(nPhoMaps_),
180 mvaValues_(nValMaps_),
182 variableHelper_(consumesCollector()),
183 mvaVarMngr_(
iConfig.getParameter<
std::string>(
"variableDefinition"), MVAVariableHelper::indexMap()),
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>(
263 for (
const auto& pu : *pileup) {
264 int bx = pu.getBunchCrossing();
266 genNpu_ = pu.getPU_NumInteractions();
290 std::vector<float> extraVariables =
variableHelper_.getAuxVariables(iEvent);
292 for (
auto const& pho :
src->ptrs()) {
301 const auto&
seed = *(pho->superCluster()->seed());
306 for (
int iVar = 0; iVar <
nVars_; ++iVar) {
320 for (
size_t k = 0; k <
nCats_; ++
k)
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
EventNumber_t event() const
const double ptThreshold_
bool isPromptFinalState() const
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
MVAVariableManager< reco::Photon > mvaVarMngr_
#define DEFINE_FWK_MODULE(type)
edm::LuminosityBlockNumber_t luminosityBlock() const
const std::vector< std::string > mvaCatBranchNames_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileup_
T * make(const Args &...args) const
make new ROOT object
float getValue(int index, const ParticleType &particle, const std::vector< float > &auxVariables) const
const bool doEnergyMatrix_
const std::vector< std::string > valMapTags_
std::vector< int > mvaCats_
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > mvaCatTokens_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
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)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > phoMapTokens_
const std::vector< std::string > valMapBranchNames_
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
const std::vector< std::string > phoMapBranchNames_
const edm::EDGetTokenT< edm::View< reco::Photon > > src_
const edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
const LorentzVector & p4(P4type type) 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_
std::vector< float > vars_
PhotonMVANtuplizer(const edm::ParameterSet &)
tuple size
Write out results.
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > valMapTokens_