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")) {
33 std::vector<edm::ParameterSet>
algos = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"algos");
34 for (
auto const& algoPset : algos) {
39 assert(algos.size() == 1);
47 produces<edm::ValueMap<StoredPileupJetIdentifier> > (
"");
51 algos_.emplace_back(label, std::make_unique<PileupJetIdAlgo>(&algoGBRForestsAndConstants));
53 produces<edm::ValueMap<float> > (label+
"Discriminant");
54 produces<edm::ValueMap<int> > (label+
"Id");
60 input_vm_pujetid_token_ = consumes<edm::ValueMap<StoredPileupJetIdentifier> >(iConfig.
getParameter<
edm::InputTag>(
"jetids"));
89 iEvent.
getByToken(input_vertex_token_, vertexHandle);
95 iEvent.
getByToken(input_vm_pujetid_token_, vmap);
102 vector<StoredPileupJetIdentifier>
ids;
103 map<string, vector<float> >
mvas;
104 map<string, vector<int> > idflags;
106 VertexCollection::const_iterator
vtx;
109 vtx = vertexes.begin();
110 while( vtx != vertexes.end() && ( vtx->isFake() || vtx->ndof() < 4 ) ) {
113 if( vtx == vertexes.end() ) { vtx = vertexes.begin(); }
118 for (
unsigned int i=0;
i<jets.
size(); ++
i ) {
120 auto algoi = algos_.begin();
127 ispat = patjet !=
nullptr;
140 initJetEnergyCorrector( iSetup, iEvent.
isRealData() );
145 jecCor_->setJetPt(jet.
pt());
147 jecCor_->setJetEta(jet.
eta());
148 jecCor_->setJetA(jet.
jetArea());
149 jecCor_->setRho(rho);
150 jec = jecCor_->getCorrection();
154 std::unique_ptr<reco::Jet> corrJet;
161 corrJet.reset(dynamic_cast<reco::Jet *>( jet.
clone() ));
163 corrJet->scaleEnergy(scale);
165 const reco::Jet * theJet = ( applyJec ? corrJet.get() : &
jet );
171 ids.push_back( puIdentifier );
174 puIdentifier = (*vmap)[jets.
refAt(
i)];
175 puIdentifier.
jetPt(theJet->
pt());
178 ialgo->
set(puIdentifier);
184 mvas[algoi->first].push_back( puIdentifier.
mva() );
185 idflags[algoi->first].push_back( puIdentifier.
idFlag() );
186 for( ++algoi; algoi!=algos_.end(); ++algoi) {
187 ialgo = algoi->second.get();
188 ialgo->
set(puIdentifier);
190 mvas[algoi->first].push_back(
id.
mva() );
191 idflags[algoi->first].push_back(
id.idFlag() );
198 for(
const auto& ialgo : algos_) {
200 vector<float> &
mva = mvas[ialgo.first];
201 auto mvaout = std::make_unique<ValueMap<float>>();
203 mvafiller.insert(jetHandle,mva.begin(),mva.end());
205 iEvent.
put(
std::move(mvaout),ialgo.first+
"Discriminant");
208 vector<int> & idflag = idflags[ialgo.first];
209 auto idflagout = std::make_unique<ValueMap<int>>();
211 idflagfiller.insert(jetHandle,idflag.begin(),idflag.end());
218 assert( jetHandle->size() == ids.size() );
219 auto idsout = std::make_unique<ValueMap<StoredPileupJetIdentifier>>();
221 idsfiller.insert(jetHandle,ids.begin(),ids.end());
247 std::vector<std::string> jecLevels;
248 jecLevels.push_back(
"L1FastJet");
249 jecLevels.push_back(
"L2Relative");
250 jecLevels.push_back(
"L3Absolute");
251 if(isData && ! gc->
residualsFromTxt() ) jecLevels.push_back(
"L2L3Residual");
256 for(std::vector<std::string>::const_iterator ll = jecLevels.begin(); ll != jecLevels.end(); ++ll)
259 jetCorPars_.push_back(ip);
266 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
#define DEFINE_FWK_MODULE(type)
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)
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
PileupJetIdentifier computeIdVariables(const reco::Jet *jet, float jec, const reco::Vertex *, const reco::VertexCollection &, double rho)
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