22 runMvas_(iConfig.getParameter<
bool>(
"runMvas")),
23 produceJetIds_(iConfig.getParameter<
bool>(
"produceJetIds")),
24 inputIsCorrected_(iConfig.getParameter<
bool>(
"inputIsCorrected")),
25 applyJec_(iConfig.getParameter<
bool>(
"applyJec")),
26 jec_(iConfig.getParameter<
std::
string>(
"jec")),
27 residualsFromTxt_(iConfig.getParameter<
bool>(
"residualsFromTxt")),
28 usePuppi_(iConfig.getParameter<
bool>(
"usePuppi")) {
34 std::vector<edm::ParameterSet>
algos = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"algos");
35 for (
auto const& algoPset : algos) {
40 assert(algos.size() == 1);
48 produces<edm::ValueMap<StoredPileupJetIdentifier> > (
"");
52 algos_.emplace_back(label, std::make_unique<PileupJetIdAlgo>(&algoGBRForestsAndConstants));
54 produces<edm::ValueMap<float> > (label+
"Discriminant");
55 produces<edm::ValueMap<int> > (label+
"Id");
61 input_vm_pujetid_token_ = consumes<edm::ValueMap<StoredPileupJetIdentifier> >(iConfig.
getParameter<
edm::InputTag>(
"jetids"));
90 iEvent.
getByToken(input_vertex_token_, vertexHandle);
96 iEvent.
getByToken(input_vm_pujetid_token_, vmap);
103 vector<StoredPileupJetIdentifier>
ids;
104 map<string, vector<float> >
mvas;
105 map<string, vector<int> > idflags;
107 VertexCollection::const_iterator
vtx;
110 vtx = vertexes.begin();
111 while( vtx != vertexes.end() && ( vtx->isFake() || vtx->ndof() < 4 ) ) {
114 if( vtx == vertexes.end() ) { vtx = vertexes.begin(); }
119 for (
unsigned int i=0;
i<jets.
size(); ++
i ) {
121 auto algoi = algos_.begin();
128 ispat = patjet !=
nullptr;
141 initJetEnergyCorrector( iSetup, iEvent.
isRealData() );
146 jecCor_->setJetPt(jet.
pt());
148 jecCor_->setJetEta(jet.
eta());
149 jecCor_->setJetA(jet.
jetArea());
150 jecCor_->setRho(rho);
151 jec = jecCor_->getCorrection();
155 std::unique_ptr<reco::Jet> corrJet;
162 corrJet.reset(dynamic_cast<reco::Jet *>( jet.
clone() ));
164 corrJet->scaleEnergy(scale);
166 const reco::Jet * theJet = ( applyJec ? corrJet.get() : &
jet );
172 ids.push_back( puIdentifier );
175 puIdentifier = (*vmap)[jets.
refAt(
i)];
176 puIdentifier.
jetPt(theJet->
pt());
179 ialgo->
set(puIdentifier);
185 mvas[algoi->first].push_back( puIdentifier.
mva() );
186 idflags[algoi->first].push_back( puIdentifier.
idFlag() );
187 for( ++algoi; algoi!=algos_.end(); ++algoi) {
188 ialgo = algoi->second.get();
189 ialgo->
set(puIdentifier);
191 mvas[algoi->first].push_back(
id.
mva() );
192 idflags[algoi->first].push_back(
id.idFlag() );
199 for(
const auto& ialgo : algos_) {
201 vector<float> &
mva = mvas[ialgo.first];
202 auto mvaout = std::make_unique<ValueMap<float>>();
204 mvafiller.insert(jetHandle,mva.begin(),mva.end());
206 iEvent.
put(
std::move(mvaout),ialgo.first+
"Discriminant");
209 vector<int> & idflag = idflags[ialgo.first];
210 auto idflagout = std::make_unique<ValueMap<int>>();
212 idflagfiller.insert(jetHandle,idflag.begin(),idflag.end());
219 assert( jetHandle->size() == ids.size() );
220 auto idsout = std::make_unique<ValueMap<StoredPileupJetIdentifier>>();
222 idsfiller.insert(jetHandle,ids.begin(),ids.end());
248 std::vector<std::string> jecLevels;
249 jecLevels.push_back(
"L1FastJet");
250 jecLevels.push_back(
"L2Relative");
251 jecLevels.push_back(
"L3Absolute");
252 if(isData && ! gc->
residualsFromTxt() ) jecLevels.push_back(
"L2L3Residual");
257 for(std::vector<std::string>::const_iterator ll = jecLevels.begin(); ll != jecLevels.end(); ++ll)
260 jetCorPars_.push_back(ip);
267 jecCor_ = std::make_unique<FactorizedJetCorrector>(jetCorPars_);
std::vector< PileupJetIdAlgo::AlgoGBRForestsAndConstants > const & vAlgoGBRForestsAndConstants() const
T getParameter(std::string const &) const
void set(const PileupJetIdentifier &)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const int & idFlag() const
const float & mva() const
Base class for all types of Jets.
double pt() const final
transverse momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
const float & jetPt() const
PileupJetIdProducer(const edm::ParameterSet &, GBRForestsAndConstants const *)
RefToBase< value_type > refAt(size_type i) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
PileupJetIdentifier computeIdVariables(const reco::Jet *jet, float jec, const reco::Vertex *, const reco::VertexCollection &, double rho, bool usePuppi)
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
bool inputIsCorrected() const
std::string const & jec() const
edm::FileInPath const & residualsTxt() const
void initJetEnergyCorrector(const edm::EventSetup &iSetup, bool isData)
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< PileupJetIdAlgo::AlgoGBRForestsAndConstants > vAlgoGBRForestsAndConstants_
const float & jetPhi() const
edm::FileInPath residualsTxt_
bool produceJetIds() const
T const * product() const
PileupJetIdentifier computeMva()
Analysis-level calorimeter jet class.
CompositePtrCandidate * clone() const override
returns a clone of the candidate
GBRForestsAndConstants(edm::ParameterSet const &)
virtual float jetArea() const
get jet area
const_reference at(size_type pos) const
std::string fullPath() const
bool residualsFromTxt() const
Jet correctedJet(const std::string &level, const std::string &flavor="none", const std::string &set="") const
double phi() const final
momentum azimuthal angle
~PileupJetIdProducer() override
const float & jetEta() const