Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-10 01:53:49

0001 #ifndef LINPUPPI_REF_H
0002 #define LINPUPPI_REF_H
0003 
0004 #include "DataFormats/L1TParticleFlow/interface/layer1_emulator.h"
0005 
0006 #include <vector>
0007 
0008 namespace edm {
0009   class ParameterSet;
0010 }
0011 
0012 namespace l1ct {
0013 
0014   class LinPuppiEmulator {
0015   public:
0016     enum class SortAlgo { Insertion, BitonicRUFL, BitonicHLS, Hybrid, FoldedHybrid };
0017 
0018     LinPuppiEmulator(unsigned int nTrack,
0019                      unsigned int nIn,
0020                      unsigned int nOut,
0021                      unsigned int nVtx,
0022                      unsigned int dR2Min,
0023                      unsigned int dR2Max,
0024                      unsigned int iptMax,
0025                      unsigned int dzCut,
0026                      double ptSlopeNe,
0027                      double ptSlopePh,
0028                      double ptZeroNe,
0029                      double ptZeroPh,
0030                      double alphaSlope,
0031                      double alphaZero,
0032                      double alphaCrop,
0033                      double priorNe,
0034                      double priorPh,
0035                      pt_t ptCut,
0036                      unsigned int nFinalSort = 0,
0037                      SortAlgo finalSortAlgo = SortAlgo::Insertion)
0038         : nTrack_(nTrack),
0039           nIn_(nIn),
0040           nOut_(nOut),
0041           nVtx_(nVtx),
0042           dR2Min_(dR2Min),
0043           dR2Max_(dR2Max),
0044           iptMax_(iptMax),
0045           dzCut_(dzCut),
0046           absEtaBins_(),
0047           ptSlopeNe_(1, ptSlopeNe),
0048           ptSlopePh_(1, ptSlopePh),
0049           ptZeroNe_(1, ptZeroNe),
0050           ptZeroPh_(1, ptZeroPh),
0051           alphaSlope_(1, alphaSlope),
0052           alphaZero_(1, alphaZero),
0053           alphaCrop_(1, alphaCrop),
0054           priorNe_(1, priorNe),
0055           priorPh_(1, priorPh),
0056           ptCut_(1, ptCut),
0057           nFinalSort_(nFinalSort ? nFinalSort : nOut),
0058           finalSortAlgo_(finalSortAlgo),
0059           debug_(false),
0060           fakePuppi_(false) {}
0061 
0062     LinPuppiEmulator(unsigned int nTrack,
0063                      unsigned int nIn,
0064                      unsigned int nOut,
0065                      unsigned int nVtx,
0066                      unsigned int dR2Min,
0067                      unsigned int dR2Max,
0068                      unsigned int iptMax,
0069                      unsigned int dzCut,
0070                      glbeta_t etaCut,
0071                      double ptSlopeNe_0,
0072                      double ptSlopeNe_1,
0073                      double ptSlopePh_0,
0074                      double ptSlopePh_1,
0075                      double ptZeroNe_0,
0076                      double ptZeroNe_1,
0077                      double ptZeroPh_0,
0078                      double ptZeroPh_1,
0079                      double alphaSlope_0,
0080                      double alphaSlope_1,
0081                      double alphaZero_0,
0082                      double alphaZero_1,
0083                      double alphaCrop_0,
0084                      double alphaCrop_1,
0085                      double priorNe_0,
0086                      double priorNe_1,
0087                      double priorPh_0,
0088                      double priorPh_1,
0089                      pt_t ptCut_0,
0090                      pt_t ptCut_1,
0091                      unsigned int nFinalSort = 0,
0092                      SortAlgo finalSortAlgo = SortAlgo::Insertion);
0093 
0094     LinPuppiEmulator(unsigned int nTrack,
0095                      unsigned int nIn,
0096                      unsigned int nOut,
0097                      unsigned int nVtx,
0098                      unsigned int dR2Min,
0099                      unsigned int dR2Max,
0100                      unsigned int iptMax,
0101                      unsigned int dzCut,
0102                      const std::vector<glbeta_t> &absEtaBins,
0103                      const std::vector<double> &ptSlopeNe,
0104                      const std::vector<double> &ptSlopePh,
0105                      const std::vector<double> &ptZeroNe,
0106                      const std::vector<double> &ptZeroPh,
0107                      const std::vector<double> &alphaSlope,
0108                      const std::vector<double> &alphaZero,
0109                      const std::vector<double> &alphaCrop,
0110                      const std::vector<double> &priorNe,
0111                      const std::vector<double> &priorPh,
0112                      const std::vector<pt_t> &ptCut,
0113                      unsigned int nFinalSort,
0114                      SortAlgo finalSortAlgo)
0115         : nTrack_(nTrack),
0116           nIn_(nIn),
0117           nOut_(nOut),
0118           nVtx_(nVtx),
0119           dR2Min_(dR2Min),
0120           dR2Max_(dR2Max),
0121           iptMax_(iptMax),
0122           dzCut_(dzCut),
0123           absEtaBins_(absEtaBins),
0124           ptSlopeNe_(ptSlopeNe),
0125           ptSlopePh_(ptSlopePh),
0126           ptZeroNe_(ptZeroNe),
0127           ptZeroPh_(ptZeroPh),
0128           alphaSlope_(alphaSlope),
0129           alphaZero_(alphaZero),
0130           alphaCrop_(alphaCrop),
0131           priorNe_(priorNe),
0132           priorPh_(priorPh),
0133           ptCut_(ptCut),
0134           nFinalSort_(nFinalSort),
0135           finalSortAlgo_(finalSortAlgo),
0136           debug_(false),
0137           fakePuppi_(false) {}
0138 
0139     LinPuppiEmulator(const edm::ParameterSet &iConfig);
0140 
0141     // charged
0142     void linpuppi_chs_ref(const PFRegionEmu &region,
0143                           const PVObjEmu &pv,
0144                           const std::vector<PFChargedObjEmu> &pfch /*[nTrack]*/,
0145                           std::vector<PuppiObjEmu> &outallch /*[nTrack]*/) const;
0146     //vtx vetor
0147     void linpuppi_chs_ref(const PFRegionEmu &region,
0148                           const std::vector<PVObjEmu> &pv /*[nVtx]*/,
0149                           const std::vector<PFChargedObjEmu> &pfch /*[nTrack]*/,
0150                           std::vector<PuppiObjEmu> &outallch /*[nTrack]*/) const;
0151 
0152     // neutrals, in the tracker
0153     void linpuppi_flt(const PFRegionEmu &region,
0154                       const std::vector<TkObjEmu> &track /*[nTrack]*/,
0155                       const std::vector<PVObjEmu> &pv /*[nVtx]*/,
0156                       const std::vector<PFNeutralObjEmu> &pfallne /*[nIn]*/,
0157                       std::vector<PuppiObjEmu> &outallne_nocut /*[nIn]*/,
0158                       std::vector<PuppiObjEmu> &outallne /*[nIn]*/,
0159                       std::vector<PuppiObjEmu> &outselne /*[nOut]*/) const;
0160     void linpuppi_ref(const PFRegionEmu &region,
0161                       const std::vector<TkObjEmu> &track /*[nTrack]*/,
0162                       const std::vector<PVObjEmu> &pv /*[nVtx]*/,
0163                       const std::vector<PFNeutralObjEmu> &pfallne /*[nIn]*/,
0164                       std::vector<PuppiObjEmu> &outallne_nocut /*[nIn]*/,
0165                       std::vector<PuppiObjEmu> &outallne /*[nIn]*/,
0166                       std::vector<PuppiObjEmu> &outselne /*[nOut]*/) const;
0167     void linpuppi_ref(const PFRegionEmu &region,
0168                       const std::vector<TkObjEmu> &track /*[nTrack]*/,
0169                       const std::vector<PVObjEmu> &pv /*[nVtx]*/,
0170                       const std::vector<PFNeutralObjEmu> &pfallne /*[nIn]*/,
0171                       std::vector<PuppiObjEmu> &outselne /*[nOut]*/) const {
0172       std::vector<PuppiObjEmu> outallne_nocut, outallne;
0173       linpuppi_ref(region, track, pv, pfallne, outallne_nocut, outallne, outselne);
0174     }
0175 
0176     // neutrals, forward
0177     void fwdlinpuppi_ref(const PFRegionEmu &region,
0178                          const std::vector<HadCaloObjEmu> &caloin /*[nIn]*/,
0179                          std::vector<PuppiObjEmu> &outallne_nocut /*[nIn]*/,
0180                          std::vector<PuppiObjEmu> &outallne /*[nIn]*/,
0181                          std::vector<PuppiObjEmu> &outselne /*[nOut]*/) const;
0182     void fwdlinpuppi_flt(const PFRegionEmu &region,
0183                          const std::vector<HadCaloObjEmu> &caloin /*[nIn]*/,
0184                          std::vector<PuppiObjEmu> &outallne_nocut /*[nIn]*/,
0185                          std::vector<PuppiObjEmu> &outallne /*[nIn]*/,
0186                          std::vector<PuppiObjEmu> &outselne /*[nOut]*/) const;
0187 
0188     static void puppisort_and_crop_ref(unsigned int nOutMax,
0189                                        const std::vector<PuppiObjEmu> &in,
0190                                        std::vector<PuppiObjEmu> &out,
0191                                        SortAlgo algo = SortAlgo::Insertion);
0192 
0193     // for CMSSW
0194     void run(const PFInputRegion &in, const std::vector<l1ct::PVObjEmu> &pvs, OutputRegion &out) const;
0195 
0196     void setDebug(bool debug = true) { debug_ = debug; }
0197 
0198     // instead of running Puppi, write Puppi debug information into the output Puppi candidates
0199     void setFakePuppi(bool fakePuppi = true) { fakePuppi_ = fakePuppi; }
0200 
0201   protected:
0202     unsigned int nTrack_, nIn_, nOut_,
0203         nVtx_;  // nIn_, nOut refer to the calorimeter clusters or neutral PF candidates as input and as output (after sorting)
0204     unsigned int dR2Min_, dR2Max_, iptMax_, dzCut_;
0205     std::vector<glbeta_t> absEtaBins_;
0206     std::vector<double> ptSlopeNe_, ptSlopePh_, ptZeroNe_, ptZeroPh_;
0207     std::vector<double> alphaSlope_, alphaZero_, alphaCrop_;
0208     std::vector<double> priorNe_, priorPh_;
0209     std::vector<pt_t> ptCut_;
0210     unsigned int nFinalSort_;  // output after a full sort of charged + neutral
0211     SortAlgo finalSortAlgo_;
0212 
0213     bool debug_;
0214     bool fakePuppi_;
0215     // utility
0216     unsigned int find_ieta(const PFRegionEmu &region, eta_t eta) const;
0217     std::pair<pt_t, puppiWgt_t> sum2puppiPt_ref(uint64_t sum, pt_t pt, unsigned int ieta, bool isEM, int icand) const;
0218     std::pair<float, float> sum2puppiPt_flt(float sum, float pt, unsigned int ieta, bool isEM, int icand) const;
0219   };
0220 
0221 }  // namespace l1ct
0222 
0223 #endif