1 #ifndef ELECTRONMVAVARIABLEHELPER_H 2 #define ELECTRONMVAVARIABLEHELPER_H 33 template <
class ParticleType>
46 const std::vector<T> &
values,
62 template<
class ParticleType>
73 produces<edm::ValueMap<float>>(
"convVtxFitProb");
74 produces<edm::ValueMap<float>>(
"kfhits");
75 produces<edm::ValueMap<float>>(
"kfchi2");
78 template<
class ParticleType>
82 template<
class ParticleType>
100 throw cms::Exception(
" Collection not found: ") <<
" failed to find a standard AOD or miniAOD particle collection " << std::endl;
116 <<
"Failed to retrieve event content needed for this MVA" 118 <<
"Check python MVA configuration file." 126 std::vector<float> convVtxFitProbVals;
127 std::vector<float> kfhitsVals;
128 std::vector<float> kfchi2Vals;
130 for (
size_t i = 0;
i < electrons->size(); ++
i){
131 auto iCand = electrons->ptrAt(
i);
136 float convVtxFitProb = -1.;
140 convVtxFitProb = TMath::Prob( vtx.
chi2(), vtx.
ndof());
144 convVtxFitProbVals.push_back(convVtxFitProb);
151 float kfchi2 = validKf ? trackRef->normalizedChi2() : 0 ;
152 float kfhits = validKf ? trackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
154 kfchi2Vals.push_back(kfchi2);
155 kfhitsVals.push_back(kfhits);
163 writeValueMap(iEvent, electrons, convVtxFitProbVals,
"convVtxFitProb" );
166 template<
class ParticleType>
template<
typename T>
169 const std::vector<T> &
values,
172 auto valMap = std::make_unique<edm::ValueMap<T>>();
174 filler.insert(
handle, values.begin(), values.end());
const edm::EDGetTokenT< reco::BeamSpot > beamSpotTokenMiniAOD_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
const edm::EDGetTokenT< edm::View< ParticleType > > electronsTokenMiniAOD_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool isValid() const
Tells whether the vertex is valid.
std::vector< Vertex > VertexCollection
collection of Vertex objects
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
const edm::EDGetTokenT< reco::ConversionCollection > conversionsTokenMiniAOD_
const edm::EDGetTokenT< reco::VertexCollection > vtxTokenMiniAOD_
double chi2() const
chi-squares
edm::View< reco::Candidate > CandView
ElectronMVAVariableHelper(const edm::ParameterSet &iConfig)
T const * get() const
Returns C++ pointer to the item.
bool isNull() const
Checks for null.
const edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
T const * product() const
const edm::EDGetTokenT< reco::VertexCollection > vtxToken_
void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< ParticleType > > &handle, const std::vector< T > &values, const std::string &label) const
const edm::EDGetTokenT< reco::ConversionCollection > conversionsToken_
~ElectronMVAVariableHelper() override
const edm::EDGetTokenT< edm::View< ParticleType > > electronsToken_
const Point & position() const
position
ParticleType
Definition of particle types.
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override