40 #include <Math/VectorUtil.h> 153 : isMC_(iConfig.getParameter<
bool>(
"isMC")),
154 deltaR_(iConfig.getParameter<double>(
"deltaR")),
155 ptThreshold_(iConfig.getParameter<double>(
"ptThreshold")),
158 nEleMaps_(eleMapBranchNames_.
size()),
160 valMapBranchNames_(iConfig.getParameter<
std::
vector<
std::
string>>(
"eleMVAValMapLabels")),
161 nValMaps_(valMapBranchNames_.
size()),
163 mvaCatBranchNames_(iConfig.getParameter<
std::
vector<
std::
string>>(
"eleMVACatLabels")),
164 nCats_(mvaCatBranchNames_.
size()),
172 mvaPasses_(nEleMaps_),
173 mvaValues_(nValMaps_),
175 variableHelper_(consumesCollector()),
177 nVars_(mvaVarMngr_.getNVars()),
179 doEnergyMatrix_(iConfig.getParameter<
bool>(
"doEnergyMatrix")),
180 energyMatrixSize_(iConfig.getParameter<
int>(
"energyMatrixSize")) {
182 for (
auto const&
tag : eleMapTags_) {
186 for (
auto const&
tag : valMapTags_) {
190 for (
auto const&
tag : mvaCatTags_) {
197 tree_ =
fs->make<TTree>(
"tree",
"tree");
199 tree_->Branch(
"nEvent", &nEvent_);
200 tree_->Branch(
"nRun", &nRun_);
201 tree_->Branch(
"nLumi", &nLumi_);
203 tree_->Branch(
"genNpu", &genNpu_);
204 tree_->Branch(
"vtxN", &vtxN_);
206 tree_->Branch(
"ele_q", &eleQ_);
207 tree_->Branch(
"ele_3q", &ele3Q_);
210 tree_->Branch(
"energyMatrix", &energyMatrix_);
213 tree_->Branch(
"matchedToGenEle", &matchedToGenEle_);
216 tree_->Branch(mvaVarMngr_.getName(
i).c_str(), &vars_[
i]);
218 tree_->Branch(
"ele_isEB", &eleIsEB_);
219 tree_->Branch(
"ele_isEE", &eleIsEE_);
220 tree_->Branch(
"ele_isEBEtaGap", &eleIsEBEtaGap_);
221 tree_->Branch(
"ele_isEBPhiGap", &eleIsEBPhiGap_);
222 tree_->Branch(
"ele_isEBEEGap", &eleIsEBEEGap_);
223 tree_->Branch(
"ele_isEEDeeGap", &eleIsEEDeeGap_);
224 tree_->Branch(
"ele_isEERingGap", &eleIsEERingGap_);
227 for (
size_t k = 0;
k < nValMaps_; ++
k) {
228 tree_->Branch(valMapBranchNames_[
k].c_str(), &mvaValues_[
k]);
231 for (
size_t k = 0;
k < nEleMaps_; ++
k) {
232 tree_->Branch(eleMapBranchNames_[
k].c_str(), &mvaPasses_[
k]);
235 for (
size_t k = 0;
k < nCats_; ++
k) {
236 tree_->Branch(mvaCatBranchNames_[
k].c_str(), &mvaCats_[
k]);
252 std::unique_ptr<noZS::EcalClusterLazyTools> lazyTools;
255 lazyTools = std::make_unique<noZS::EcalClusterLazyTools>(
268 int bx =
pu.getBunchCrossing();
296 for (
auto const& ele :
src->ptrs()) {
302 const auto&
seed = *(ele->superCluster()->seed());
307 eleQ_ = ele->charge();
308 ele3Q_ = ele->chargeInfo().isGsfCtfScPixConsistent;
310 for (
int iVar = 0; iVar <
nVars_; ++iVar) {
352 if (
std::abs(particle.pdgId()) != 11 || particle.status() != 1)
358 closestElectron = &particle;
362 if (closestElectron ==
nullptr ||
dR >=
deltaR_)
385 desc.add<
bool>(
"doEnergyMatrix",
false);
386 desc.add<
int>(
"energyMatrixSize", 2)->setComment(
"extension of crystals in each direction away from the seed");
387 desc.add<
bool>(
"isMC",
true);
388 desc.add<
double>(
"deltaR", 0.1);
389 desc.add<
double>(
"ptThreshold", 5.0);
390 desc.add<std::vector<std::string>>(
"eleMVAs", {});
391 desc.add<std::vector<std::string>>(
"eleMVALabels", {});
392 desc.add<std::vector<std::string>>(
"eleMVAValMaps", {});
393 desc.add<std::vector<std::string>>(
"eleMVAValMapLabels", {});
394 desc.add<std::vector<std::string>>(
"eleMVACats", {});
395 desc.add<std::vector<std::string>>(
"eleMVACatLabels", {});
static const std::string kSharedResource
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const double ptThreshold_
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > eleMapTokens_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileup_
#define DEFINE_FWK_MODULE(type)
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
const bool doEnergyMatrix_
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > mvaCatTokens_
const std::vector< std::string > mvaCatBranchNames_
std::vector< float > mvaValues_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > valMapTokens_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
static std::unordered_map< std::string, int > indexMap()
bool isDirectHardProcessTauDecayProductFinalState() const
const std::vector< std::string > eleMapBranchNames_
const std::vector< std::string > valMapTags_
const std::vector< std::string > mvaCatTags_
void addDefault(ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
const std::vector< std::string > valMapBranchNames_
std::vector< float > energyMatrix_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< int > mvaPasses_
const MVAVariableHelper variableHelper_
Abs< T >::type abs(const T &t)
std::vector< int > mvaCats_
ElectronMVANtuplizer(const edm::ParameterSet &)
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > src_
const edm::EDGetTokenT< edm::View< reco::GenParticle > > genParticles_
int matchToTruth(reco::GsfElectron const &electron, edm::View< reco::GenParticle > const &genParticles) const
const std::vector< std::string > eleMapTags_
float getValue(int index, const ParticleType &particle, const std::vector< float > &auxVariables) const
std::vector< float > vars_
MVAVariableManager< reco::GsfElectron > mvaVarMngr_
void analyze(const edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_
const int energyMatrixSize_
const std::vector< float > getAuxVariables(const edm::Event &iEvent) const
bool fromHardProcessFinalState() const