Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-27 04:04:49

0001 #ifndef __PUSubtractor__
0002 #define __PUSubtractor__
0003 
0004 #include <vector>
0005 
0006 #include "fastjet/PseudoJet.hh"
0007 #include "fastjet/ClusterSequence.hh"
0008 #include "fastjet/ClusterSequenceArea.hh"
0009 #include "fastjet/GhostedAreaSpec.hh"
0010 
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/Framework/interface/ConsumesCollector.h"
0015 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0017 
0018 #include "DataFormats/JetReco/interface/CaloJet.h"
0019 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0020 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0021 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0022 
0023 class CaloGeometryRecord;
0024 
0025 class PileUpSubtractor {
0026 public:
0027   typedef std::shared_ptr<fastjet::ClusterSequence> ClusterSequencePtr;
0028   typedef std::shared_ptr<fastjet::GhostedAreaSpec> ActiveAreaSpecPtr;
0029   typedef std::shared_ptr<fastjet::RangeDefinition> RangeDefPtr;
0030   typedef std::shared_ptr<fastjet::JetDefinition> JetDefPtr;
0031 
0032   PileUpSubtractor(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC);
0033   virtual ~PileUpSubtractor() { ; }
0034 
0035   virtual void setDefinition(JetDefPtr const& jetDef);
0036   virtual void reset(std::vector<edm::Ptr<reco::Candidate> >& input,
0037                      std::vector<fastjet::PseudoJet>& towers,
0038                      std::vector<fastjet::PseudoJet>& output);
0039   virtual void setupGeometryMap(edm::Event& iEvent, const edm::EventSetup& iSetup);
0040   virtual void calculatePedestal(std::vector<fastjet::PseudoJet> const& coll);
0041   virtual void subtractPedestal(std::vector<fastjet::PseudoJet>& coll);
0042   virtual void calculateOrphanInput(std::vector<fastjet::PseudoJet>& orphanInput);
0043   virtual void offsetCorrectJets();
0044   virtual double getMeanAtTower(const reco::CandidatePtr& in) const;
0045   virtual double getSigmaAtTower(const reco::CandidatePtr& in) const;
0046   virtual double getPileUpAtTower(const reco::CandidatePtr& in) const;
0047   virtual double getPileUpEnergy(int ijet) const { return jetOffset_[ijet]; }
0048   virtual double getCone(double cone, double eta, double phi, double& et, double& pu);
0049   int getN(const reco::CandidatePtr& in) const;
0050   int getNwithJets(const reco::CandidatePtr& in) const;
0051 
0052   int ieta(const reco::CandidatePtr& in) const;
0053   int iphi(const reco::CandidatePtr& in) const;
0054 
0055 protected:
0056   // From jet producer
0057   JetDefPtr fjJetDefinition_;                         // fastjet jet definition
0058   ClusterSequencePtr fjClusterSeq_;                   // fastjet cluster sequence
0059   std::vector<edm::Ptr<reco::Candidate> >* inputs_;   // input candidates
0060   std::vector<fastjet::PseudoJet>* fjInputs_;         // fastjet inputs
0061   std::vector<fastjet::PseudoJet>* fjJets_;           // fastjet jets
0062   std::vector<fastjet::PseudoJet> fjOriginalInputs_;  // to back-up unsubtracted fastjet inputs
0063 
0064   // PU subtraction parameters
0065   bool reRunAlgo_;
0066   bool doAreaFastjet_;
0067   bool doRhoFastjet_;
0068   double jetPtMin_;
0069   double puPtMin_;
0070 
0071   double ghostEtaMax;
0072   int activeAreaRepeats;
0073   double ghostArea;
0074 
0075   double nSigmaPU_;                 // number of sigma for pileup
0076   double radiusPU_;                 // pileup radius
0077   ActiveAreaSpecPtr fjActiveArea_;  // fastjet active area definition
0078   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geoToken_;
0079   CaloGeometry const* geo_;             // geometry
0080   int ietamax_;                         // maximum eta in geometry
0081   int ietamin_;                         // minimum eta in geometry
0082   std::vector<HcalDetId> allgeomid_;    // all det ids in the geometry
0083   std::map<int, int> geomtowers_;       // map of geometry towers to det id
0084   std::map<int, int> ntowersWithJets_;  // number of towers with jets
0085   std::map<int, double> esigma_;        // energy sigma
0086   std::map<int, double> emean_;         // energy mean
0087 
0088   std::vector<double> jetOffset_;
0089 };
0090 
0091 #include "FWCore/PluginManager/interface/PluginFactory.h"
0092 namespace edm {
0093   class ParameterSet;
0094   class EventSetup;
0095   class ConsumesCollector;
0096 }  // namespace edm
0097 typedef edmplugin::PluginFactory<PileUpSubtractor*(const edm::ParameterSet&, edm::ConsumesCollector&&)>
0098     PileUpSubtractorFactory;
0099 
0100 #endif