From 873af2064bd77c61a23d83e088866f84e835ae10 Mon Sep 17 00:00:00 2001 From: jackaraz Date: Mon, 21 Mar 2022 12:11:57 +0000 Subject: [PATCH] add SoftDrop --- madanalysis/build/makefile_writer.py | 4 +- .../Interfaces/fastjet/SoftDrop.h | 100 ++++++++++++++++++ .../Process/Analyzer/AnalyzerBase.h | 5 + 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 tools/SampleAnalyzer/Interfaces/fastjet/SoftDrop.h diff --git a/madanalysis/build/makefile_writer.py b/madanalysis/build/makefile_writer.py index 2867acd4..4d319d4c 100644 --- a/madanalysis/build/makefile_writer.py +++ b/madanalysis/build/makefile_writer.py @@ -387,7 +387,9 @@ def Makefile( libs.extend(['-lfastjet_for_ma5']) if options.has_fastjet_lib: # libs.extend(['$(shell fastjet-config --libs --plugins)']) # --rpath=no)']) - libs.extend(['$(shell $(MA5_BASE)/tools/SampleAnalyzer/ExternalSymLink/Bin/fastjet-config --libs --plugins)']) # --rpath=no)']) + libs.extend(['$(shell $(MA5_BASE)/tools/SampleAnalyzer/ExternalSymLink/Bin/fastjet-config --libs --plugins)']) + # Add fjcontrib libraries + libs.extend(["-lRecursiveTools"]) # SoftDrop file.write('LIBFLAGS += '+' '.join(libs)+'\n') # - delphes diff --git a/tools/SampleAnalyzer/Interfaces/fastjet/SoftDrop.h b/tools/SampleAnalyzer/Interfaces/fastjet/SoftDrop.h new file mode 100644 index 00000000..22cc5cdd --- /dev/null +++ b/tools/SampleAnalyzer/Interfaces/fastjet/SoftDrop.h @@ -0,0 +1,100 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2012-2022 Jack Araz, Eric Conte & Benjamin Fuks +// The MadAnalysis development team, email: +// +// This file is part of MadAnalysis 5. +// Official website: +// +// MadAnalysis 5 is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// MadAnalysis 5 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with MadAnalysis 5. If not, see +// +//////////////////////////////////////////////////////////////////////////////// + +#ifndef MADANALYSIS5_SOFTDROP_H +#define MADANALYSIS5_SOFTDROP_H + +// STL headers +#include +#include + +// FastJet headers +#include "fastjet/contrib/SoftDrop.hh" +#include "fastjet/PseudoJet.hh" + +// SampleAnalyser headers +#include "SampleAnalyzer/Commons/Base/PortableDatatypes.h" +#include "SampleAnalyzer/Commons/DataFormat/RecJetFormat.h" + +using namespace std; + +namespace MA5 { + namespace Substructure { + class SoftDrop { + + //--------------------------------------------------------------------------------- + // data members + //--------------------------------------------------------------------------------- + protected : + + // SoftDrop input variables + MAfloat32 beta_; + MAfloat32 symmetry_cut_; + + // ------------------------------------------------------------- + // method members + // ------------------------------------------------------------- + public: + + /// Constructor without argument + SoftDrop() {} + + /// Destructor + virtual ~SoftDrop() {} + + // Constructor with arguments + SoftDrop(MAfloat32 beta, MAfloat32 symmetry_cut) { Initialize(beta, symmetry_cut); } + + void Initialize(MAfloat32 beta, MAfloat32 symmetry_cut) + { + beta_ = beta; + symmetry_cut_ = symmetry_cut; + } + + // Execute with a single jet + const RecJetFormat *Execute(const RecJetFormat *jet) + { + RecJetFormat *NewJet = new RecJetFormat(); + NewJet->Reset(); + fastjet::contrib::SoftDrop sd(beta_, symmetry_cut_); + fastjet::PseudoJet sd_jet = sd(jet->pseudojet()); + MALorentzVector q(sd_jet.px(), sd_jet.py(), sd_jet.pz(), sd_jet.e()); + NewJet->setMomentum(q); + NewJet->setPseudoJet(sd_jet); + return NewJet; + } + + // Execute with a list of jets + std::vector Execute(std::vector &jets) + { + std::vector output_jets; + for (auto &jet: jets) + output_jets.push_back(Execute(jet)); + + return output_jets; + } + + }; + } +} +#endif //MADANALYSIS5_SOFTDROP_H diff --git a/tools/SampleAnalyzer/Process/Analyzer/AnalyzerBase.h b/tools/SampleAnalyzer/Process/Analyzer/AnalyzerBase.h index b786fac4..f046f6e2 100644 --- a/tools/SampleAnalyzer/Process/Analyzer/AnalyzerBase.h +++ b/tools/SampleAnalyzer/Process/Analyzer/AnalyzerBase.h @@ -40,6 +40,11 @@ #include "SampleAnalyzer/Process/RegionSelection/RegionSelectionManager.h" #include "SampleAnalyzer/Commons/Base/PortableDatatypes.h" +// FJcontrib tools +#ifdef MA5_FASTJET_MODE +#include "SampleAnalyzer/Interfaces/fastjet/SoftDrop.h" +#endif + // STL headers #include #include