Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:19

0001 #ifndef HiJetBackground_HiFJGridEmptyAreaCalculator_h
0002 #define HiJetBackground_HiFJGridEmptyAreaCalculator_h
0003 
0004 // system include files
0005 #include <memory>
0006 #include <sstream>
0007 #include <string>
0008 #include <vector>
0009 
0010 // user include files
0011 #include "FWCore/Framework/interface/Frameworkfwd.h"
0012 #include "FWCore/Framework/interface/stream/EDProducer.h"
0013 
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016 
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/Utilities/interface/StreamID.h"
0019 
0020 #include "DataFormats/Common/interface/Handle.h"
0021 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0022 #include "DataFormats/PatCandidates/interface/Jet.h"
0023 
0024 class HiFJGridEmptyAreaCalculator : public edm::stream::EDProducer<> {
0025 public:
0026   explicit HiFJGridEmptyAreaCalculator(const edm::ParameterSet&);
0027   ~HiFJGridEmptyAreaCalculator() override;
0028 
0029   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0030 
0031 private:
0032   void beginStream(edm::StreamID) override;
0033   void produce(edm::Event&, const edm::EventSetup&) override;
0034   void endStream() override;
0035 
0036   /// @name setting a new event
0037   //\{
0038   //----------------------------------------------------------------
0039 
0040   /// tell the background estimator that it has a new event, composed
0041   /// of the specified particles.
0042 
0043 private:
0044   /// configure the grid
0045   void setupGrid(double eta_min, double eta_max);
0046   void setupGridJet(const reco::Jet* jet);
0047 
0048   /// retrieve the grid cell index for a given PseudoJet
0049   int tileIndexJet(const reco::Candidate* pfCand);
0050   int tileIndexEta(const reco::Candidate* pfCand);
0051   int tileIndexEtaJet(const reco::Candidate* pfCand);
0052   int tileIndexPhi(const reco::Candidate* pfCand);
0053 
0054   ///number of grid cells that overlap with jet constituents filling in the in between area
0055   int numJetGridCells(std::vector<std::pair<int, int>>& indices);
0056 
0057   /// calculates the area of jets that fall within the eta
0058   /// range by scaling kt areas using grid areas
0059   void calculateAreaFractionOfJets(const edm::Event& iEvent, const edm::EventSetup& iSetup);
0060   void calculateGridRho(const edm::Event& iEvent, const edm::EventSetup& iSetup);
0061 
0062   /// information about the grid
0063   const double twopi_ = 2 * M_PI;
0064 
0065   ///internal parameters for grid
0066 
0067   //parameters of grid covering the full acceptance
0068   double ymin_;
0069   double ymax_;
0070   double dy_;
0071   double dphi_;
0072   double tileArea_;
0073 
0074   //parameters of grid around jets
0075   double dyJet_;
0076   double yminJet_;
0077   double ymaxJet_;
0078   double totalInboundArea_;
0079 
0080   //leave bands at boundaries
0081   double etaminJet_;
0082   double etamaxJet_;
0083 
0084   //for the grid calculation covering the full acceptance
0085   int ny_;
0086   int nphi_;
0087   int ntotal_;
0088 
0089   //for the grid calculation around each jet
0090   int ntotalJet_;
0091   int nyJet_;
0092 
0093   ///input parameters
0094   double gridWidth_;
0095   double band_;
0096   int hiBinCut_;
0097   bool doCentrality_;
0098   bool keepGridInfo_;
0099 
0100   std::vector<double> rhoVsEta_;
0101   std::vector<double> meanRhoVsEta_;
0102   std::vector<double> etaMaxGrid_;
0103   std::vector<double> etaMinGrid_;
0104 
0105   int n_tiles() { return ntotal_; }
0106 
0107   /// input tokens
0108   edm::EDGetTokenT<edm::View<reco::Jet>> jetsToken_;
0109   edm::EDGetTokenT<reco::CandidateView> pfCandsToken_;
0110   edm::EDGetTokenT<std::vector<double>> mapEtaToken_;
0111   edm::EDGetTokenT<std::vector<double>> mapRhoToken_;
0112   edm::EDGetTokenT<std::vector<double>> mapRhoMToken_;
0113 
0114   edm::EDGetTokenT<int> centralityBinToken_;
0115 };
0116 
0117 #endif