13 #include "fastjet/PseudoJet.hh"
14 #include "fastjet/contrib/ConstituentSubtractor.hh"
15 #include "fastjet/Selector.hh"
16 #include "fastjet/tools/GridMedianBackgroundEstimator.hh"
17 #include "fastjet/contrib/RescalingClasses.hh"
34 ATH_MSG_ERROR(
"Incompatible configuration: setting both IgnoreChargedPFO and ApplyToChargedPFO to true"
35 <<
"will set all cPFOs to zero");
36 return StatusCode::FAILURE;
39 ATH_MSG_ERROR(
"Incompatible configuration: ApplyToNeutralPFO=False -- what kind of pileup do you wish to suppress?");
40 return StatusCode::FAILURE;
47 ATH_MSG_ERROR(
"Incompatible configuration: You set both, DoRapidityRescaling and DoRapidityPhiRescaling, to true. Use maximally only one of them.");
48 return StatusCode::FAILURE;
52 ATH_MSG_ERROR(
"Incompatible configuration: You have chosen a background rescaling, but you have not specified the path to the file with rescaling histograms or the name of the histogram. Specify properties FileRescaling and HistogramRescaling.");
53 return StatusCode::FAILURE;
58 if (fullPathToFile.empty()){
59 ATH_MSG_ERROR(
"Incompatible configuration: The provided file for rescaling was not found using PathResolver.");
60 return StatusCode::FAILURE;
62 std::unique_ptr<TFile>
file(TFile::Open(fullPathToFile.data(),
"READ"));
63 if (
file->IsZombie()){
64 ATH_MSG_ERROR(
"Incompatible configuration: The file for rescaling has been tried to open, but it was found it is zombie.");
65 return StatusCode::FAILURE;
69 ATH_MSG_ERROR(
"Incompatible configuration: The provided histogram name was not found in the root file.");
70 return StatusCode::FAILURE;
74 if (
object->InheritsFrom(TH1D::Class())){
75 m_hist.reset(
static_cast<TH1D*
>(
object->Clone(
"hist_cloned")));
76 m_hist->SetDirectory(
nullptr);
77 m_rescaling.reset(
static_cast<fastjet::FunctionOfPseudoJet<double>*
>(
new contrib::BackgroundRescalingYFromRoot<TH1D>(
m_hist.get())));
80 ATH_MSG_ERROR(
"Incompatible configuration: You want to do rapidity rescaling, but the provided histogram name is not a TH1D.");
81 return StatusCode::FAILURE;
85 if (
object->InheritsFrom(TH2D::Class())){
88 m_rescaling.reset(
static_cast<fastjet::FunctionOfPseudoJet<double>*
>(
new contrib::BackgroundRescalingYPhiFromRoot<TH2D>(
m_hist2D.get())));
91 ATH_MSG_ERROR(
"Incompatible configuration: You want to do rapidity-phi rescaling, but the provided histogram name is not a TH2D.");
92 return StatusCode::FAILURE;
98 return StatusCode::SUCCESS;
106 contrib::ConstituentSubtractor subtractor;
118 subtractor.set_use_nearby_hard(-1,-1);
121 std::vector<PseudoJet> inputs_to_correct, inputs_to_not_correct;
122 inputs_to_correct.reserve(cont->
size());
123 inputs_to_not_correct.reserve(cont->
size());
155 PseudoJet pj(
part->p4() );
156 pj.set_user_index(
i );
159 inputs_to_correct.push_back(pj);
161 if (pj.rap()<minRap) minRap = pj.rap();
162 if (pj.rap()>maxRap) maxRap = pj.rap();
165 inputs_to_not_correct.push_back(pj);
176 bge_rho.set_particles(inputs_to_correct);
177 subtractor.set_background_estimator(&bge_rho);
181 ATH_MSG_DEBUG(
"Subtracting event density from constituents");
182 std::vector<PseudoJet> corrected_event=subtractor.subtract_event(inputs_to_correct,
m_maxEta);
186 std::vector<xAOD::JetFourMom_t> corrected_p4s(cont->size(),
xAOD::JetFourMom_t(0.,0.,0.,0.));
188 for(PseudoJet & pj : corrected_event) {
189 ATH_MSG_VERBOSE(
"Setting four-mom for constituent " << pj.user_index() <<
", pt = " << pj.pt());
190 corrected_p4s[pj.user_index()].SetCoordinates(pj.pt(),pj.eta(),pj.phi(),pj.m());
192 for(PseudoJet & pj : inputs_to_not_correct) {
193 ATH_MSG_VERBOSE(
"Setting four-mom for constituent " << pj.user_index() <<
", pt = " << pj.pt());
194 corrected_p4s[pj.user_index()].SetCoordinates(pj.pt(),pj.eta(),pj.phi(),pj.m());
196 for(PseudoJet & pj : inputs_to_not_correct) {
197 ATH_MSG_VERBOSE(
"Setting four-mom for constituent " << pj.user_index() <<
", pt = " << pj.pt());
198 corrected_p4s[pj.user_index()].SetCoordinates(pj.pt(),pj.eta(),pj.phi(),pj.m());
207 ATH_MSG_VERBOSE(
"Initial eta: " <<
part->eta() <<
", subtracted pt: " << corrected_p4s[
i].Eta());
208 ATH_MSG_VERBOSE(
"Initial phi: " <<
part->phi() <<
", subtracted pt: " << corrected_p4s[
i].Phi());
215 return StatusCode::SUCCESS;