18 gridWidth_(iConfig.getParameter<double>(
"gridWidth")),
19 band_(iConfig.getParameter<double>(
"bandWidth")),
20 hiBinCut_(iConfig.getParameter<int>(
"hiBinCut")),
21 doCentrality_(iConfig.getParameter<bool>(
"doCentrality")),
22 keepGridInfo_(iConfig.getParameter<bool>(
"keepGridInfo"))
52 produces<std::vector<double > >(
"mapEmptyCorrFac");
53 produces<std::vector<double > >(
"mapToRhoCorr");
54 produces<std::vector<double > >(
"mapToRhoMCorr");
55 produces<std::vector<double > >(
"mapToRhoCorr1Bin");
56 produces<std::vector<double > >(
"mapToRhoMCorr1Bin");
59 produces<std::vector<double > >(
"mapRhoVsEtaGrid");
60 produces<std::vector<double > >(
"mapMeanRhoVsEtaGrid");
61 produces<std::vector<double > >(
"mapEtaMaxGrid");
62 produces<std::vector<double > >(
"mapEtaMinGrid");
92 bool doEmptyArea =
true;
98 if(hiBin <
hiBinCut_) doEmptyArea =
false;
102 int neta = (int)mapEtaRanges->size();
104 std::unique_ptr<std::vector<double>> mapToRhoCorrOut (
new std::vector<double>(neta-1,1
e-6));
105 std::unique_ptr<std::vector<double>> mapToRhoMCorrOut (
new std::vector<double>(neta-1,1
e-6));
106 std::unique_ptr<std::vector<double>> mapToRhoCorr1BinOut (
new std::vector<double>(neta-1,1
e-6));
107 std::unique_ptr<std::vector<double>> mapToRhoMCorr1BinOut (
new std::vector<double>(neta-1,1
e-6));
109 setupGrid(mapEtaRanges->at(0), mapEtaRanges->at(neta-1));
112 double allAcceptanceCorr = 1;
123 for(
int ieta = 0; ieta<(neta-1); ieta++) {
125 double correctionKt = 1;
126 double rho = mapRho->at(ieta);
127 double rhoM = mapRhoM->at(ieta);
130 double etamin = mapEtaRanges->at(ieta);
131 double etamax = mapEtaRanges->at(ieta+1);
140 mapToRhoCorrOut->at(ieta) = correctionKt*
rho;
141 mapToRhoMCorrOut->at(ieta) = correctionKt*rhoM;
143 mapToRhoCorr1BinOut->at(ieta) = allAcceptanceCorr*
rho;
144 mapToRhoMCorr1BinOut->at(ieta) = allAcceptanceCorr*rhoM;
148 iEvent.
put(
std::move(mapToRhoMCorrOut),
"mapToRhoMCorr");
149 iEvent.
put(
std::move(mapToRhoCorr1BinOut),
"mapToRhoCorr1Bin");
150 iEvent.
put(
std::move(mapToRhoMCorr1BinOut),
"mapToRhoMCorr1Bin");
154 std::unique_ptr<std::vector<double>> mapRhoVsEtaGridOut (
new std::vector<double>(
ny_,0.));
155 std::unique_ptr<std::vector<double>> mapMeanRhoVsEtaGridOut (
new std::vector<double>(
ny_,0.));
156 std::unique_ptr<std::vector<double>> mapEtaMaxGridOut (
new std::vector<double>(
ny_,0.));
157 std::unique_ptr<std::vector<double>> mapEtaMinGridOut (
new std::vector<double>(
ny_,0.));
160 for(
int ieta = 0; ieta <
ny_; ieta++) {
161 mapRhoVsEtaGridOut->at(ieta) =
rhoVsEta_[ieta];
167 iEvent.
put(
std::move(mapRhoVsEtaGridOut),
"mapRhoVsEtaGrid");
168 iEvent.
put(
std::move(mapMeanRhoVsEtaGridOut),
"mapMeanRhoVsEtaGrid");
169 iEvent.
put(
std::move(mapEtaMaxGridOut),
"mapEtaMaxGrid");
170 iEvent.
put(
std::move(mapEtaMinGridOut),
"mapEtaMinGrid");
182 vector<vector<double>> scalarPt(
ny_, vector<double>(
nphi_, 0.0));
187 for(
unsigned icand = 0; icand < pfCandidateColl->size(); icand++) {
193 scalarPt[jeta][jphi] += pfCandidate.
pt();
198 for(
int jeta = 0; jeta <
ny_; jeta++){
202 vector<double> rhoVsPhi;
205 for(
int jphi = 0; jphi <
nphi_; jphi++){
206 double binpt = scalarPt[jeta][jphi];
209 if(binpt > 0) rhoVsPhi.push_back(binpt);
216 sort(rhoVsPhi.begin(), rhoVsPhi.end());
218 int nFull = nphi_ - nEmpty;
225 rhoVsEta_[jeta] = (rhoVsPhi[(int)(nFull / 2 - 1)] + rhoVsPhi[(int)(nFull / 2)]) / 2;
229 rhoVsEta_[jeta] = rhoVsPhi[(int)(nFull / 2)];
232 rhoVsEta_[jeta] *= (((double) nFull)/((double) nphi_));
246 for(
auto jet = jets->begin();
jet != jets->end(); ++
jet) {
249 double areaKt =
jet->jetArea();
251 std::vector<std::pair<int, int> > pfIndicesJet;
252 std::vector<std::pair<int, int> > pfIndicesJetInbound;
254 int nConstitJetInbound = 0;
255 for(
auto daughter :
jet->getJetConstituentsQuick()){
260 pfIndicesJet.push_back(std::make_pair(jphi, jeta));
263 pfIndicesJetInbound.push_back(std::make_pair(jphi, jeta));
264 nConstitJetInbound++;
268 if(nConstitJet == nConstitJetInbound){
278 int nthisInbound = 0;
279 if (nConstitJetInbound > 0) nthisInbound =
numJetGridCells(pfIndicesJetInbound);
282 double fractionArea = ((double)nthisInbound)/((double)nthis);
314 ny_ = int(nyDouble+0.5);
330 for(
int jeta = 0; jeta <
ny_; jeta++){
332 etaMaxGrid_[jeta] = etamin + dy_*((double)jeta + 1.);
353 if (iphi ==
nphi_) iphi = 0;
372 int iy = int(floor( (pfCand->
eta() -
ymin_) /
dy_ ));
373 if (iy < 0 || iy >=
ny_)
return -1;
375 assert (iy < ny_ && iy >= 0);
399 nyJet_ = int(nyDouble+0.5);
424 if (iyjet < 0 || iyjet >=
nyJet_)
return -1;
426 assert (iyjet < nyJet_ && iyjet >= 0);
436 std::sort(indices.begin(),indices.end());
437 int lowestJPhi = indices[0].first;
438 int lowestJEta = indices[0].second;
439 int highestJEta = lowestJEta;
442 for(
unsigned int iconst = 1; iconst < indices.size(); iconst++){
443 int jphi = indices[iconst].first;
444 int jeta = indices[iconst].second;
445 if (jphi == lowestJPhi){
446 if (jeta < lowestJEta) lowestJEta = jeta;
447 if (jeta > highestJEta) highestJEta = jeta;
450 ngrid += highestJEta - lowestJEta + 1;
455 ngrid += highestJEta - lowestJEta + 1;
476 desc.
add<
double>(
"gridWidth",0.05);
477 desc.
add<
double>(
"bandWidth",0.2);
478 desc.
add<
bool>(
"doCentrality",
true);
479 desc.
add<
int>(
"hiBinCut",100);
480 desc.
add<
bool>(
"keepGridInfo",
false);
481 descriptions.
add(
"hiFJGridEmptyAreaCalculator",desc);
edm::EDGetTokenT< std::vector< double > > mapRhoToken_
T getParameter(std::string const &) const
edm::EDGetTokenT< int > centralityBinToken_
std::vector< double > rhoVsEta_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double ymin_
internal parameters for grid
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
input tokens
int tileIndexEta(const reco::PFCandidate *pfCand)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandsToken_
#define DEFINE_FWK_MODULE(type)
Base class for all types of Jets.
std::vector< double > etaMinGrid_
std::vector< double > meanRhoVsEta_
virtual double phi() const final
momentum azimuthal angle
virtual void endStream() override
void setupGrid(double eta_min, double eta_max)
configure the grid
edm::EDGetTokenT< std::vector< double > > mapRhoMToken_
int tileIndexEtaJet(const reco::PFCandidate *pfCand)
int numJetGridCells(std::vector< std::pair< int, int > > &indices)
number of grid cells that overlap with jet constituents filling in the in between area ...
void setupGridJet(const reco::Jet *jet)
edm::EDGetTokenT< std::vector< double > > mapEtaToken_
int tileIndexPhi(const reco::PFCandidate *pfCand)
std::vector< double > etaMaxGrid_
void calculateAreaFractionOfJets(const edm::Event &iEvent, const edm::EventSetup &iSetup)
const double twopi_
information about the grid
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void beginStream(edm::StreamID) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
T const * product() const
void calculateGridRho(const edm::Event &iEvent, const edm::EventSetup &iSetup)
HiFJGridEmptyAreaCalculator(const edm::ParameterSet &)
~HiFJGridEmptyAreaCalculator()
virtual void produce(edm::Event &, const edm::EventSetup &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Particle reconstructed by the particle flow algorithm.
double gridWidth_
input parameters
virtual double eta() const final
momentum pseudorapidity
virtual double pt() const final
transverse momentum