File indexing completed on 2024-04-06 12:21:28
0001 #ifndef L1Trigger_Phase2L1ParticleFlow_corrector_h
0002 #define L1Trigger_Phase2L1ParticleFlow_corrector_h
0003 #include <TGraph.h>
0004 #include <TH1.h>
0005 #include <string>
0006 #include <vector>
0007
0008 class TDirectory;
0009
0010 namespace l1t {
0011 class PFCluster;
0012 }
0013
0014 namespace l1tpf {
0015 class corrector {
0016 public:
0017 corrector() : is2d_(false), neta_(0), nemf_(0), emfMax_(-1), emulate_(false) {}
0018 corrector(const std::string &iFile, float emfMax = -1, bool debug = false, bool emulate = false);
0019 corrector(const std::string &iFile,
0020 const std::string &directory,
0021 float emfMax = -1,
0022 bool debug = false,
0023 bool emulate = false);
0024 corrector(TDirectory *src, float emfMax = -1, bool debug = false, bool emulate = false);
0025
0026 corrector(const TH1 *index, float emfMax = -1);
0027 ~corrector();
0028
0029
0030 corrector(const corrector &corr) = delete;
0031 corrector &operator=(const corrector &corr) = delete;
0032 corrector(corrector &&corr);
0033 corrector &operator=(corrector &&corr);
0034
0035 float correctedPt(float et, float emEt, float eta) const;
0036 float correctedPt(float et, float eta) const { return correctedPt(et, 0, eta); }
0037 void correctPt(l1t::PFCluster &cluster, float preserveEmEt = true) const;
0038
0039 bool valid() const { return (index_.get() != nullptr); }
0040
0041
0042 void setGraph(const TGraph &graph, int ieta, int iemf = 0);
0043
0044 bool is2d() const { return is2d_; }
0045 unsigned int neta() const { return neta_; }
0046 unsigned int nemf() const { return nemf_; }
0047
0048 const TH1 &getIndex() const { return *index_; }
0049
0050 TGraph *getGraph(int ieta, int iemf = 0) { return corrections_[ieta * nemf_ + iemf]; }
0051 const TGraph *getGraph(int ieta, int iemf = 0) const { return corrections_[ieta * nemf_ + iemf]; }
0052
0053
0054 void writeToFile(const std::string &filename, const std::string &directory) const;
0055
0056 void writeToFile(TDirectory *dest) const;
0057
0058 private:
0059 std::unique_ptr<TH1> index_;
0060 std::vector<TGraph *> corrections_;
0061 std::vector<TH1 *> correctionsEmulated_;
0062 bool is2d_;
0063 unsigned int neta_, nemf_;
0064 float emfMax_;
0065 bool emulate_;
0066
0067 void init_(const std::string &iFile, const std::string &directory, bool debug, bool emulate);
0068 void init_(TDirectory *src, bool debug);
0069 void initEmulation_(TDirectory *src, bool debug);
0070 };
0071 }
0072 #endif