Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:27

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) {}
0018     corrector(const std::string &iFile, float emfMax = -1, bool debug = false);
0019     corrector(const std::string &iFile, const std::string &directory, float emfMax = -1, bool debug = false);
0020     corrector(TDirectory *src, float emfMax = -1, bool debug = false);
0021     // create an empty corrector (you'll need to fill the graphs later)
0022     corrector(const TH1 *index, float emfMax = -1);
0023     ~corrector();
0024 
0025     // no copy, but can move
0026     corrector(const corrector &corr) = delete;
0027     corrector &operator=(const corrector &corr) = delete;
0028     corrector(corrector &&corr);
0029     corrector &operator=(corrector &&corr);
0030 
0031     float correctedPt(float et, float emEt, float eta) const;
0032     float correctedPt(float et, float eta) const { return correctedPt(et, 0, eta); }
0033     void correctPt(l1t::PFCluster &cluster, float preserveEmEt = true) const;
0034 
0035     bool valid() const { return (index_.get() != nullptr); }
0036 
0037     // set the graph (note: it is cloned, and the corrector owns the clone)
0038     void setGraph(const TGraph &graph, int ieta, int iemf = 0);
0039 
0040     bool is2d() const { return is2d_; }
0041     unsigned int neta() const { return neta_; }
0042     unsigned int nemf() const { return nemf_; }
0043     // access the index histogram
0044     const TH1 &getIndex() const { return *index_; }
0045     // access the graphs (owned by the corrector, may be null)
0046     TGraph *getGraph(int ieta, int iemf = 0) { return corrections_[ieta * nemf_ + iemf]; }
0047     const TGraph *getGraph(int ieta, int iemf = 0) const { return corrections_[ieta * nemf_ + iemf]; }
0048 
0049     // store the corrector
0050     void writeToFile(const std::string &filename, const std::string &directory) const;
0051     // store the corrector
0052     void writeToFile(TDirectory *dest) const;
0053 
0054   private:
0055     std::unique_ptr<TH1> index_;
0056     std::vector<TGraph *> corrections_;
0057     bool is2d_;
0058     unsigned int neta_, nemf_;
0059     float emfMax_;
0060 
0061     void init_(const std::string &iFile, const std::string &directory, bool debug);
0062     void init_(TDirectory *src, bool debug);
0063   };
0064 }  // namespace l1tpf
0065 #endif