13 minimumTowersFraction_(iConfig.getParameter<double>(
"minimumTowersFraction")),
14 sumRecHits_(iConfig.getParameter<bool>(
"sumRecHits")),
15 dropZeroTowers_(iConfig.getUntrackedParameter<bool>(
"dropZeroTowers",
true)) {
20 for (std::map<int, double>::iterator iter =
esigma_.begin(); iter !=
esigma_.end(); ++iter) {
21 iter->second = s * (iter->second);
26 LogDebug(
"PileUpSubtractor") <<
"The subtractor correcting jets...\n";
45 vector<fastjet::PseudoJet>::iterator pseudojetTMP =
fjJets_->begin(), jetsEnd =
fjJets_->end();
46 for (; pseudojetTMP != jetsEnd; ++pseudojetTMP) {
47 int ijet = pseudojetTMP -
fjJets_->begin();
50 std::vector<fastjet::PseudoJet>
towers = sorted_by_pt(pseudojetTMP->constituents());
53 for (vector<fastjet::PseudoJet>::const_iterator ito = towers.begin(), towEnd = towers.end(); ito != towEnd; ++ito) {
55 int it =
ieta(originalTower);
56 double Original_Et = originalTower->et();
60 newjetet = newjetet + etnew;
67 LogDebug(
"PileUpSubtractor") <<
"The subtractor subtracting pedestals...\n";
71 vector<fastjet::PseudoJet> newcoll;
73 for (vector<fastjet::PseudoJet>::iterator input_object = coll.begin(), fjInputsEnd = coll.end();
74 input_object != fjInputsEnd;
81 double Original_Et = itow->et();
83 Original_Et =
getEt(itow);
86 double etnew = Original_Et - (*(
emean_.find(it))).second - (*(
esigma_.find(it))).second;
87 float mScale = etnew / input_object->Et();
92 input_object->py() * mScale,
93 input_object->pz() * mScale,
94 input_object->e() * mScale);
96 int index = input_object->user_index();
97 input_object->reset_momentum(towP4.px(), towP4.py(), towP4.pz(), towP4.energy());
98 input_object->set_user_index(index);
101 newcoll.push_back(*input_object);
109 LogDebug(
"PileUpSubtractor") <<
"The subtractor calculating pedestals...\n";
111 map<int, double> emean2;
112 map<int, int> ntowers;
114 int ietaold = -10000;
126 for (vector<fastjet::PseudoJet>::const_iterator input_object = coll.begin(), fjInputsEnd = coll.end();
127 input_object != fjInputsEnd;
130 ieta0 =
ieta(originalTower);
131 double Original_Et = originalTower->et();
133 Original_Et =
getEt(originalTower);
136 if (ieta0 - ietaold != 0) {
138 emean2[ieta0] = emean2[ieta0] + Original_Et * Original_Et;
143 emean2[ieta0] = emean2[ieta0] + Original_Et * Original_Et;
149 int it = (*gt).first;
151 double e1 = (*(
emean_.find(it))).second;
152 double e2 = (*emean2.find(it)).
second;
155 LogDebug(
"PileUpSubtractor") <<
" ieta : " << it <<
" number of towers : " << nt <<
" e1 : " << e1 <<
" e2 : " << e2
160 double eee = e2 / nt - e1 * e1 / (nt *
nt);
168 LogDebug(
"PileUpSubtractor") <<
" ieta : " << it <<
" Pedestals : " <<
emean_[it] <<
" " <<
esigma_[it] <<
"\n";
173 LogDebug(
"PileUpSubtractor") <<
"The subtractor calculating orphan input...\n";
177 vector<int> jettowers;
178 vector<pair<int, int> > excludedTowers;
180 for (
auto const& pseudojetTMP : *
fjJets_) {
187 auto exclude =
find(excludedTowers.begin(), excludedTowers.end(), pair<int, int>(im.ieta(), im.iphi()));
188 if (dr <
radiusPU_ && exclude == excludedTowers.end() &&
192 excludedTowers.push_back(pair<int, int>(im.ieta(), im.iphi()));
197 int index = it.user_index();
200 auto exclude =
find(excludedTowers.begin(), excludedTowers.end(), pair<int, int>(ie, ip));
201 if (exclude != excludedTowers.end()) {
202 jettowers.push_back(index);
213 int index = it.user_index();
214 vector<int>::const_iterator itjet =
find(jettowers.begin(), jettowers.end(),
index);
215 if (itjet == jettowers.end()) {
217 fastjet::PseudoJet orphan(originalTower->px(), originalTower->py(), originalTower->pz(), originalTower->energy());
218 orphan.set_user_index(index);
220 orphanInput.push_back(orphan);
229 double et = energy *
sin(pos.
theta());
void calculatePedestal(std::vector< fastjet::PseudoJet > const &coll) override
int def(FILE *, FILE *, int)
std::vector< double > jetOffset_
std::map< int, double > esigma_
MultipleAlgoIterator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
double getEt(const reco::CandidatePtr &in) const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::vector< fastjet::PseudoJet > * fjJets_
T const * get() const
Returns C++ pointer to the item.
std::vector< fastjet::PseudoJet > fjOriginalInputs_
Sin< T >::type sin(const T &t)
double getEta(const reco::CandidatePtr &in) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
int ieta(const reco::CandidatePtr &in) const
std::map< int, int > geomtowers_
Geom::Theta< T > theta() const
U second(std::pair< T, U > const &p)
double minimumTowersFraction_
std::vector< fastjet::PseudoJet > * fjInputs_
std::map< int, double > emean_
std::map< int, int > ntowersWithJets_
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
void offsetCorrectJets() override
void rescaleRMS(double s)
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void subtractPedestal(std::vector< fastjet::PseudoJet > &coll) override
int iphi(const reco::CandidatePtr &in) const
CaloTowerDetId id() const
ActiveAreaSpecPtr fjActiveArea_
ClusterSequencePtr fjClusterSeq_
std::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
CaloGeometry const * geo_
void calculateOrphanInput(std::vector< fastjet::PseudoJet > &orphanInput) override
std::vector< HcalDetId > allgeomid_
JetDefPtr fjJetDefinition_
std::vector< edm::Ptr< reco::Candidate > > * inputs_