ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/PollackPrograms/src/ntupleProducer.h
Revision: 1.1
Committed: Wed Feb 20 21:39:45 2013 UTC (12 years, 2 months ago) by bpollack
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
commiting moriond analysis package

File Contents

# User Rev Content
1 bpollack 1.1 // system include files
2     #include <memory>
3     #include <string>
4    
5     // user include files
6     #include "FWCore/Framework/interface/Frameworkfwd.h"
7     #include "FWCore/Framework/interface/EDAnalyzer.h"
8     #include "FWCore/Framework/interface/ESHandle.h"
9     #include "FWCore/Framework/interface/EventSetup.h"
10     #include "FWCore/Framework/interface/Event.h"
11     #include "FWCore/Framework/interface/MakerMacros.h"
12     #include "FWCore/Framework/interface/LuminosityBlock.h"
13     #include "FWCore/ParameterSet/interface/ParameterSet.h"
14    
15     #include "Geometry/Records/interface/CaloGeometryRecord.h"
16     #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
17     #include "DataFormats/GeometryVector/interface/GlobalVector.h"
18     #include "DataFormats/GeometryVector/interface/LocalPoint.h"
19     #include "DataFormats/GeometryVector/interface/LocalVector.h"
20     #include "DataFormats/Math/interface/Point3D.h"
21     #include "DataFormats/Math/interface/Vector3D.h"
22     #include "DataFormats/Math/interface/LorentzVector.h"
23     #include "DataFormats/Math/interface/deltaPhi.h"
24     #include "DataFormats/Math/interface/deltaR.h"
25    
26     // Libraries for objects
27     #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
28     #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
29     #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
30    
31     #include "DataFormats/JetReco/interface/CaloJet.h"
32     #include "DataFormats/JetReco/interface/CaloJetCollection.h"
33     #include "DataFormats/JetReco/interface/GenJet.h"
34     #include "DataFormats/JetReco/interface/GenJetCollection.h"
35     #include "DataFormats/JetReco/interface/PFJet.h"
36     #include "DataFormats/JetReco/interface/PFJetCollection.h"
37     #include "DataFormats/JetReco/interface/JetID.h"
38     #include "DataFormats/JetReco/interface/JPTJetCollection.h"
39     #include "DataFormats/JetReco/interface/JPTJet.h"
40    
41     #include "DataFormats/METReco/interface/PFMET.h"
42     #include "DataFormats/METReco/interface/PFMETCollection.h"
43     #include "DataFormats/METReco/interface/PFMETFwd.h"
44     #include "DataFormats/METReco/interface/MET.h"
45     #include "DataFormats/METReco/interface/METCollection.h"
46     #include "DataFormats/METReco/interface/METFwd.h"
47    
48     #include "DataFormats/MuonReco/interface/Muon.h"
49     #include "DataFormats/MuonReco/interface/MuonFwd.h"
50     #include "DataFormats/MuonReco/interface/MuonSelectors.h"
51    
52     #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
53     #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
54     #include "DataFormats/EgammaCandidates/interface/Photon.h"
55     #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
56     #include "DataFormats/EgammaCandidates/interface/Conversion.h"
57     #include "DataFormats/EgammaReco/interface/SuperCluster.h"
58    
59     #include "DataFormats/TrackReco/interface/Track.h"
60     #include "DataFormats/TrackReco/interface/TrackFwd.h"
61     #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
62     #include "DataFormats/VertexReco/interface/Vertex.h"
63     #include "DataFormats/VertexReco/interface/VertexFwd.h"
64     #include "DataFormats/BTauReco/interface/JetTag.h"
65     #include "DataFormats/BeamSpot/interface/BeamSpot.h"
66     #include "DataFormats/Luminosity/interface/LumiSummary.h"
67     #include "DataFormats/Common/interface/ValueMap.h"
68    
69     // Generator data formats
70     #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
71     #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
72     #include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h"
73     #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
74     #include "SimDataFormats/JetMatching/interface/JetFlavour.h"
75     #include "SimDataFormats/JetMatching/interface/JetFlavourMatching.h"
76     #include "SimDataFormats/JetMatching/interface/MatchedPartons.h"
77     #include "SimDataFormats/JetMatching/interface/JetMatchedPartons.h"
78    
79     // PAT
80     #include "DataFormats/PatCandidates/interface/Electron.h"
81     #include "DataFormats/PatCandidates/interface/Muon.h"
82     #include "DataFormats/PatCandidates/interface/Photon.h"
83     #include "DataFormats/PatCandidates/interface/MET.h"
84     #include "DataFormats/PatCandidates/interface/Jet.h"
85     #include "DataFormats/PatCandidates/interface/Tau.h"
86    
87     //#include "RecoVertex/PrimaryVertexProducer/interface/VertexHigherPtSquared.h"
88    
89     // JEC
90     #include "JetMETCorrections/Objects/interface/JetCorrector.h"
91     #include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h"
92     #include "CondFormats/JetMETObjects/interface/JetCorrectionUncertainty.h"
93     #include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
94    
95     // Jet associators
96     #include "RecoJets/JetAssociationAlgorithms/interface/JetTracksAssociationDRCalo.h"
97     #include "RecoJets/JetAssociationAlgorithms/interface/JetTracksAssociationDRVertex.h"
98    
99     // EGamma tools
100     #include "RecoEgamma/PhotonIdentification/interface/PhotonIsolationCalculator.h"
101     #include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
102     #include "EGamma/EGammaAnalysisTools/interface/ElectronEffectiveArea.h"
103     #include "EGamma/EGammaAnalysisTools/src/PFIsolationEstimator.cc"
104     //#include "EGamma/EGammaAnalysisTools/interface/EGammaMvaEleEstimator.h"
105     //#include "TrackingTools/Records/interface/TransientTrackRecord.h"
106    
107     #include "FWCore/ServiceRegistry/interface/Service.h"
108     #include "CommonTools/UtilAlgos/interface/TFileService.h"
109    
110     #include "DataFormats/METReco/interface/BeamHaloSummary.h"
111    
112     // ntuple storage classes
113     #include "TCPrimaryVtx.h"
114     #include "TCJet.h"
115     #include "TCMET.h"
116     #include "TCMuon.h"
117     #include "TCElectron.h"
118     #include "TCTau.h"
119     #include "TCPhoton.h"
120     #include "TCTriggerObject.h"
121     #include "TCGenJet.h"
122     #include "TCGenParticle.h"
123    
124     // Need for HLT trigger info:
125     #include "FWCore/Common/interface/TriggerNames.h"
126     #include "DataFormats/Common/interface/TriggerResults.h"
127     #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
128     #include "DataFormats/HLTReco/interface/TriggerObject.h"
129     #include "DataFormats/HLTReco/interface/TriggerEvent.h"
130    
131     //Root stuff
132     #include "TROOT.h"
133     #include "TH1.h"
134     #include "TH2.h"
135     #include "TProfile.h"
136     #include "TFile.h"
137     #include "TTree.h"
138     #include "TBranch.h"
139     #include "TString.h"
140     #include "TObject.h"
141     #include "TObjArray.h"
142     #include "TClonesArray.h"
143     #include "TRefArray.h"
144     #include "TLorentzVector.h"
145     #include "TVector3.h"
146    
147     using namespace edm;
148     using namespace std;
149     using namespace reco;
150    
151     //
152     // class declaration
153     //
154    
155     struct Filters { //Filters
156     Bool_t isScraping;
157     Bool_t isNoiseHcalHBHE;
158     Bool_t isNoiseHcalLaser;
159     Bool_t isNoiseEcalTP;
160     Bool_t isNoiseEcalBE;
161     Bool_t isCSCTightHalo;
162     Bool_t isCSCLooseHalo;
163     };
164    
165    
166     class ntupleProducer : public edm::EDAnalyzer {
167     public:
168     explicit ntupleProducer(const edm::ParameterSet&);
169     ~ntupleProducer();
170    
171     private:
172     virtual void beginJob() ;
173     virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
174     virtual void analyze(const edm::Event&, const edm::EventSetup&);
175     virtual void endLuminosityBlock(const edm::LuminosityBlock&,const edm::EventSetup&);
176     virtual void endRun(const edm::Run&, const edm::EventSetup&);
177     virtual void endJob() ;
178    
179     virtual bool triggerDecision(edm::Handle<edm::TriggerResults>& hltR, int iTrigger);
180     virtual float sumPtSquared(const Vertex& v);
181     virtual bool associateJetToVertex(reco::PFJet inJet, Handle<reco::VertexCollection> vtxCollection, TCJet *outJet);
182     virtual bool electronMVA(Handle<reco::VertexCollection> vtxCollection, vector<pat::Electron>::const_iterator iElectron);
183     virtual bool isFilteredOutScraping(const edm::Event& iEvent, const edm::EventSetup& iSetup, int numtrack=10, double thresh=0.25);
184     // ----------member data ---------------------------
185    
186     struct JetCompare :
187     public std::binary_function<reco::Jet, reco::Jet, bool> {
188     inline bool operator () (const reco::Jet &j1,
189     const reco::Jet &j2) const
190     { return (j1.p4().Pt() > j2.p4().Pt()); }
191     };
192    
193     typedef std::map<reco::Jet, unsigned int, JetCompare> flavourMap;
194     typedef reco::JetTagCollection::const_iterator tag_iter;
195    
196     //Standard event info
197     ULong64_t eventNumber;
198     UInt_t runNumber, lumiSection, bunchCross, nEvents;
199     float ptHat, qScale, evtWeight;
200     float deliveredLumi, recordedLumi, lumiDeadTime;
201     float rhoFactor, rho25Factor, rhoMuFactor,;
202     vector<string> savedTriggerNames;
203    
204     edm::Service<TFileService> fs;
205     TTree* eventTree;
206     TTree* runTree;
207     TTree* jobTree;
208    
209     edm::InputTag jetTag_;
210     edm::InputTag metTag_;
211     edm::InputTag genJetTag_;
212     edm::InputTag muonTag_;
213     edm::InputTag electronTag_;
214     edm::InputTag photonTag_;
215     edm::InputTag tauTag_;
216     edm::InputTag primaryVtxTag_;
217     edm::InputTag triggerResultsTag_;
218     edm::InputTag rhoCorrTag_, rho25CorrTag_, rhoMuCorrTag_;
219     edm::InputTag hcalHBHEFilterTag_;
220     edm::InputTag ecalTPFilterTag_;
221     edm::InputTag ecalBEFilterTag_;
222     edm::InputTag hcalLaserFilterTag_;
223     edm::InputTag partFlowTag_;
224     edm::ParameterSet photonIsoCalcTag_;
225    
226     bool saveJets_;
227     bool saveElectrons_;
228     bool saveMuons_;
229     bool savePhotons_;
230     bool saveTaus_;
231     bool saveMET_;
232     bool saveGenJets_;
233     bool saveGenParticles_;
234     bool isRealData;
235    
236     //Physics object containers
237     TClonesArray* recoJets;
238     TClonesArray* recoJPT;
239     TClonesArray* recoMuons;
240     TClonesArray* recoElectrons;
241     TClonesArray* recoTaus;
242     TClonesArray* recoPhotons;
243     TClonesArray* triggerObjects;
244     TClonesArray* genJets;
245     TClonesArray* genParticles;
246     TCMET* recoMET;
247     TCMET* recoMET_corr;
248    
249     //Vertex info
250     TClonesArray* primaryVtx;
251     TVector3* beamSpot;
252     unsigned nPUVertices;
253     float nPUVerticesTrue;
254    
255     //Triggers
256     HLTConfigProvider hltConfig_;
257     string hlTriggerResults_, hltProcess_, triggerName_;
258     TriggerNames triggerNames;
259     vector<string> hlNames;
260     vector<string> triggerPaths_;
261     ULong64_t triggerStatus;
262     unsigned hltPrescale[64];
263    
264     // Technical filters
265     Filters myNoiseFilters;
266    
267     //Isolator
268     PFIsolationEstimator phoIsolator;
269     PFIsolationEstimator eleIsolator;
270     };