CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoJets/JetProducers/plugins/VirtualJetProducer.h

Go to the documentation of this file.
00001 #ifndef RecoJets_JetProducers_plugins_VirtualJetProducer_h
00002 #define RecoJets_JetProducers_plugins_VirtualJetProducer_h
00003 
00004 
00005 #include "FWCore/Framework/interface/EDProducer.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "DataFormats/Candidate/interface/Candidate.h"
00008 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00009 #include "DataFormats/JetReco/interface/Jet.h"
00010 #include "DataFormats/JetReco/interface/CaloJet.h"
00011 #include "DataFormats/JetReco/interface/PFJet.h"
00012 #include "DataFormats/JetReco/interface/BasicJet.h"
00013 #include "DataFormats/JetReco/interface/GenJet.h"
00014 
00015 #include "RecoJets/JetProducers/interface/PileUpSubtractor.h"
00016 
00017 #include "fastjet/JetDefinition.hh"
00018 #include "fastjet/ClusterSequence.hh"
00019 #include "fastjet/ClusterSequenceArea.hh"
00020 #include "fastjet/PseudoJet.hh"
00021 #include "fastjet/ActiveAreaSpec.hh"
00022 
00023 #include <vector>
00024 #include <boost/shared_ptr.hpp>
00025 
00026 
00027 class VirtualJetProducer : public edm::EDProducer
00028 {
00029 protected:
00030   //
00031   // typedefs & structs
00032   //
00033   struct JetType {
00034     enum Type {
00035       BasicJet,
00036       GenJet,
00037       CaloJet,
00038       PFJet,
00039       TrackJet,
00040       LastJetType  // no real type, technical
00041     };
00042     static const char *names[];
00043     static Type byName(const std::string &name);
00044   };
00045     
00046   JetType::Type jetTypeE;
00047 
00048   inline bool makeCaloJet(const JetType::Type &fTag) {
00049     return fTag == JetType::CaloJet;
00050   }
00051   inline bool makePFJet(const JetType::Type &fTag) {
00052     return fTag == JetType::PFJet;
00053   }
00054   inline bool makeGenJet(const JetType::Type &fTag) {
00055     return fTag == JetType::GenJet;
00056   }
00057   inline bool makeTrackJet(const JetType::Type &fTag) {
00058     return fTag == JetType::TrackJet;
00059   }
00060   inline bool makeBasicJet(const JetType::Type &fTag) {
00061     return fTag == JetType::BasicJet;
00062   }
00063   
00064 
00065   //
00066   // construction/destruction
00067   //
00068 public:
00069   explicit VirtualJetProducer(const edm::ParameterSet& iConfig);
00070   virtual ~VirtualJetProducer();
00071   
00072   // typedefs
00073   typedef boost::shared_ptr<fastjet::ClusterSequence>        ClusterSequencePtr;
00074   typedef boost::shared_ptr<fastjet::JetDefinition::Plugin>  PluginPtr;
00075   typedef boost::shared_ptr<fastjet::JetDefinition>          JetDefPtr;
00076   typedef boost::shared_ptr<fastjet::ActiveAreaSpec>         ActiveAreaSpecPtr;
00077   typedef boost::shared_ptr<fastjet::RangeDefinition>        RangeDefPtr;
00078   
00079   //
00080   // member functions
00081   //
00082 public:
00083   virtual void  produce(edm::Event& iEvent, const edm::EventSetup& iSetup);
00084   std::string   jetType() const { return jetType_; }
00085   
00086 protected:
00087 
00088   //
00089   // Internal methods for jet production.
00090   // The user can either use the defaults, or override all of these methods. 
00091   //
00092 
00093   // This method creates the "produces" statement in the constructor.
00094   // The default is to produce a single jet collection as per the user's request
00095   // (Calo,PF,Basic, or Gen). 
00096   virtual void makeProduces( std::string s, std::string tag = "" );
00097 
00098   // This method inputs the constituents from "inputs" and modifies
00099   // fjInputs. 
00100   virtual void inputTowers();
00101 
00102   // This checks if the tower is anomalous (if a calo tower).
00103   virtual bool isAnomalousTower(reco::CandidatePtr input);
00104 
00105   // This will copy the fastjet constituents to the jet itself.
00106   virtual void copyConstituents(const std::vector<fastjet::PseudoJet>&fjConstituents,
00107                                 reco::Jet* jet);
00108 
00109   // This will run the actual algorithm. This method is pure virtual and
00110   // has no default. 
00111   virtual void runAlgorithm( edm::Event& iEvent, const edm::EventSetup& iSetup) = 0;
00112 
00113   // Do the offset correction. 
00114   // Only runs if "doPUOffsetCorrection_" is true.  
00115   void offsetCorrectJets(std::vector<fastjet::PseudoJet> & orphanInput);
00116 
00117   // This will write the jets to the event. 
00118   // The default is to write out the single jet collection in the default "produces"
00119   // statement. 
00120   // This is a function template that can be called for the five types
00121   // CaloJet, PFJet, GenJet, TrackJet, BasicJet. This is not suitable
00122   // for compound jets. 
00123   // Note: The "output" method is virtual and can be overriden.
00124   // The default behavior is to call the function template "writeJets". 
00125   virtual void output(  edm::Event & iEvent, edm::EventSetup const& iSetup );
00126   template< typename T >
00127   void writeJets( edm::Event & iEvent, edm::EventSetup const& iSetup );
00128   
00129   // This method copies the constituents from the fjConstituents method
00130   // to an output of CandidatePtr's. 
00131   virtual std::vector<reco::CandidatePtr>
00132     getConstituents(const std::vector<fastjet::PseudoJet>&fjConstituents);
00133   
00134   
00135   
00136   //
00137   // member data
00138   //
00139 protected:
00140   std::string           moduleLabel_;               // label for this module
00141   edm::InputTag         src_;                       // input constituent source
00142   edm::InputTag         srcPVs_;                    // primary vertex source
00143   std::string           jetType_;                   // type of jet (Calo,PF,Basic,Gen)
00144   std::string           jetAlgorithm_;              // the jet algorithm to use
00145   double                rParam_;                    // the R parameter to use
00146   double                inputEtMin_;                // minimum et of input constituents
00147   double                inputEMin_;                 // minimum e of input constituents
00148   double                jetPtMin_;                  // minimum jet pt
00149   bool                  doPVCorrection_;            // correct to primary vertex? 
00150 
00151   // for restricting inputs due to processing time
00152   bool                  restrictInputs_;            // restrict inputs to first "maxInputs" inputs.
00153   unsigned int          maxInputs_;                 // maximum number of inputs. 
00154 
00155   // for fastjet jet area calculation
00156   bool                  doAreaFastjet_;             // calculate area w/ fastjet?
00157   // for fastjet rho calculation
00158   bool                  doRhoFastjet_;              // calculate rho w/ fastjet?
00159   bool                  doFastJetNonUniform_;       // choice of eta-dependent PU calculation
00160   
00161   // for pileup offset correction
00162   bool                  doPUOffsetCorr_;            // add the pileup calculation from offset correction? 
00163   std::string           puSubtractorName_;
00164 
00165   // anomalous cell cuts
00166   unsigned int          maxBadEcalCells_;           // maximum number of bad ECAL cells
00167   unsigned int          maxRecoveredEcalCells_;     // maximum number of recovered ECAL cells
00168   unsigned int          maxProblematicEcalCells_;   // maximum number of problematic ECAL cells
00169   unsigned int          maxBadHcalCells_;           // maximum number of bad HCAL cells        
00170   unsigned int          maxRecoveredHcalCells_;     // maximum number of recovered HCAL cells  
00171   unsigned int          maxProblematicHcalCells_;   // maximum number of problematic HCAL cells
00172 
00173   std::vector<edm::Ptr<reco::Candidate> > inputs_;  // input candidates [View, PtrVector and CandCollection have limitations]
00174   reco::Particle::Point           vertex_;          // Primary vertex 
00175   ClusterSequencePtr              fjClusterSeq_;    // fastjet cluster sequence
00176   JetDefPtr                       fjJetDefinition_; // fastjet jet definition
00177   PluginPtr                       fjPlugin_;        // fastjet plugin
00178   ActiveAreaSpecPtr               fjActiveArea_;    // fastjet active area definition
00179   RangeDefPtr                     fjRangeDef_;      // range definition
00180   std::vector<fastjet::PseudoJet> fjInputs_;        // fastjet inputs
00181   std::vector<fastjet::PseudoJet> fjJets_;          // fastjet jets
00182 
00183   // Parameters of the eta-dependent rho calculation
00184   std::vector<double>             puCenters_;
00185   double                          puWidth_;
00186 
00187   std::string                     jetCollInstanceName_;       // instance name for output jet collection
00188   boost::shared_ptr<PileUpSubtractor>  subtractor_;
00189 
00190 };
00191 
00192 
00193 
00194 
00195 
00196 #endif