ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/MyVirtualJetProducer.h
Revision: 1.1
Committed: Wed Jun 2 13:53:19 2010 UTC (14 years, 11 months ago) by yilmaz
Content type: text/plain
Branch: MAIN
Log Message:
Algorithm analysis code

File Contents

# User Rev Content
1 yilmaz 1.1 #ifndef RecoJets_JetProducers_plugins_MyVirtualJetProducer_h
2     #define RecoJets_JetProducers_plugins_MyVirtualJetProducer_h
3    
4    
5     #include "FWCore/Framework/interface/EDProducer.h"
6     #include "FWCore/ParameterSet/interface/ParameterSet.h"
7     #include "DataFormats/Candidate/interface/Candidate.h"
8     #include "DataFormats/Candidate/interface/CandidateFwd.h"
9     #include "DataFormats/JetReco/interface/Jet.h"
10     #include "DataFormats/JetReco/interface/CaloJet.h"
11     #include "DataFormats/JetReco/interface/PFJet.h"
12     #include "DataFormats/JetReco/interface/BasicJet.h"
13     #include "DataFormats/JetReco/interface/GenJet.h"
14    
15     #include "RecoJets/JetProducers/interface/PileUpSubtractor.h"
16    
17     #include "fastjet/JetDefinition.hh"
18     #include "fastjet/ClusterSequence.hh"
19     #include "fastjet/ClusterSequenceArea.hh"
20     #include "fastjet/PseudoJet.hh"
21     #include "fastjet/ActiveAreaSpec.hh"
22    
23     #include <vector>
24     #include <boost/shared_ptr.hpp>
25    
26    
27     class MyVirtualJetProducer : public edm::EDProducer
28     {
29     protected:
30     //
31     // typedefs & structs
32     //
33     struct JetType {
34     enum Type {
35     BasicJet,
36     GenJet,
37     CaloJet,
38     PFJet,
39     TrackJet,
40     LastJetType // no real type, technical
41     };
42     static const char *names[];
43     static Type byName(const std::string &name);
44     };
45    
46     JetType::Type jetTypeE;
47    
48     inline bool makeCaloJet(const JetType::Type &fTag) {
49     return fTag == JetType::CaloJet;
50     }
51     inline bool makePFJet(const JetType::Type &fTag) {
52     return fTag == JetType::PFJet;
53     }
54     inline bool makeGenJet(const JetType::Type &fTag) {
55     return fTag == JetType::GenJet;
56     }
57     inline bool makeTrackJet(const JetType::Type &fTag) {
58     return fTag == JetType::TrackJet;
59     }
60     inline bool makeBasicJet(const JetType::Type &fTag) {
61     return fTag == JetType::BasicJet;
62     }
63    
64    
65     //
66     // construction/destruction
67     //
68     public:
69     explicit MyVirtualJetProducer(const edm::ParameterSet& iConfig);
70     virtual ~MyVirtualJetProducer();
71    
72     // typedefs
73     typedef boost::shared_ptr<fastjet::ClusterSequence> ClusterSequencePtr;
74     typedef boost::shared_ptr<fastjet::JetDefinition::Plugin> PluginPtr;
75     typedef boost::shared_ptr<fastjet::JetDefinition> JetDefPtr;
76     typedef boost::shared_ptr<fastjet::ActiveAreaSpec> ActiveAreaSpecPtr;
77     typedef boost::shared_ptr<fastjet::RangeDefinition> RangeDefPtr;
78    
79     //
80     // member functions
81     //
82     public:
83     virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup);
84     std::string jetType() const { return jetType_; }
85    
86     protected:
87    
88     //
89     // Internal methods for jet production.
90     // The user can either use the defaults, or override all of these methods.
91     //
92    
93     // This method creates the "produces" statement in the constructor.
94     // The default is to produce a single jet collection as per the user's request
95     // (Calo,PF,Basic, or Gen).
96     virtual void makeProduces( std::string s, std::string tag = "" );
97    
98     // This method inputs the constituents from "inputs" and modifies
99     // fjInputs.
100     virtual void inputTowers();
101    
102     // This checks if the tower is anomalous (if a calo tower).
103     virtual bool isAnomalousTower(reco::CandidatePtr input);
104    
105     // This will copy the fastjet constituents to the jet itself.
106     virtual void copyConstituents(const std::vector<fastjet::PseudoJet>&fjConstituents,
107     reco::Jet* jet);
108    
109     // This will run the actual algorithm. This method is pure virtual and
110     // has no default.
111     virtual void runAlgorithm( edm::Event& iEvent, const edm::EventSetup& iSetup) = 0;
112    
113     // Do the offset correction.
114     // Only runs if "doPUOffsetCorrection_" is true.
115     void offsetCorrectJets(std::vector<fastjet::PseudoJet> & orphanInput);
116    
117     // This will write the jets to the event.
118     // The default is to write out the single jet collection in the default "produces"
119     // statement.
120     // This is a function template that can be called for the five types
121     // CaloJet, PFJet, GenJet, TrackJet, BasicJet. This is not suitable
122     // for compound jets.
123     // Note: The "output" method is virtual and can be overriden.
124     // The default behavior is to call the function template "writeJets".
125     virtual void output( edm::Event & iEvent, edm::EventSetup const& iSetup );
126     template< typename T >
127     void writeJets( edm::Event & iEvent, edm::EventSetup const& iSetup );
128    
129     // This method copies the constituents from the fjConstituents method
130     // to an output of CandidatePtr's.
131     virtual std::vector<reco::CandidatePtr>
132     getConstituents(const std::vector<fastjet::PseudoJet>&fjConstituents);
133    
134    
135    
136     //
137     // member data
138     //
139     protected:
140     std::string moduleLabel_; // label for this module
141     edm::InputTag src_; // input constituent source
142     edm::InputTag srcPVs_; // primary vertex source
143     std::string jetType_; // type of jet (Calo,PF,Basic,Gen)
144     std::string jetAlgorithm_; // the jet algorithm to use
145     double rParam_; // the R parameter to use
146     double inputEtMin_; // minimum et of input constituents
147     double inputEMin_; // minimum e of input constituents
148     double jetPtMin_; // minimum jet pt
149     bool doPVCorrection_; // correct to primary vertex?
150    
151     // for restricting inputs due to processing time
152     bool restrictInputs_; // restrict inputs to first "maxInputs" inputs.
153     unsigned int maxInputs_; // maximum number of inputs.
154    
155     // for fastjet jet area calculation
156     bool doAreaFastjet_; // calculate area w/ fastjet?
157     // for fastjet rho calculation
158     bool doRhoFastjet_; // calculate rho w/ fastjet?
159    
160     // for pileup offset correction
161     bool doPUOffsetCorr_; // add the pileup calculation from offset correction?
162    
163     // anomalous cell cuts
164     unsigned int maxBadEcalCells_; // maximum number of bad ECAL cells
165     unsigned int maxRecoveredEcalCells_; // maximum number of recovered ECAL cells
166     unsigned int maxProblematicEcalCells_; // maximum number of problematic ECAL cells
167     unsigned int maxBadHcalCells_; // maximum number of bad HCAL cells
168     unsigned int maxRecoveredHcalCells_; // maximum number of recovered HCAL cells
169     unsigned int maxProblematicHcalCells_; // maximum number of problematic HCAL cells
170    
171     std::vector<edm::Ptr<reco::Candidate> > inputs_; // input candidates [View, PtrVector and CandCollection have limitations]
172     reco::Particle::Point vertex_; // Primary vertex
173     ClusterSequencePtr fjClusterSeq_; // fastjet cluster sequence
174     JetDefPtr fjJetDefinition_; // fastjet jet definition
175     PluginPtr fjPlugin_; // fastjet plugin
176     ActiveAreaSpecPtr fjActiveArea_; // fastjet active area definition
177     RangeDefPtr fjRangeDef_; // range definition
178     std::vector<fastjet::PseudoJet> fjInputs_; // fastjet inputs
179     std::vector<fastjet::PseudoJet> fjJets_; // fastjet jets
180    
181     std::string jetCollInstanceName_; // instance name for output jet collection
182     boost::shared_ptr<PileUpSubtractor> subtractor_;
183    
184     };
185    
186    
187    
188    
189    
190     #endif