ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h
Revision: 1.17
Committed: Wed Mar 20 12:56:37 2013 UTC (12 years, 1 month ago) by jbrinson
Content type: text/plain
Branch: MAIN
Changes since 1.16: +3 -0 lines
Log Message:
Added funiton getGenDeltaRLowest

File Contents

# User Rev Content
1 lantonel 1.1 #ifndef OSU_ANALYSIS
2    
3     #define OSU_ANALYSIS
4    
5     #include <map>
6     #include <string>
7     #include <vector>
8 jbrinson 1.13
9     #include <fstream>
10     #include <iostream>
11 lantonel 1.12 #include <algorithm>
12 lantonel 1.6 #include "TH1.h"
13 lantonel 1.9 #include "TH2.h"
14 lantonel 1.1 #include "TH1D.h"
15     #include "TH2D.h"
16     #include "TLorentzVector.h"
17    
18     #include "FWCore/Framework/interface/EDAnalyzer.h"
19     #include "FWCore/Framework/interface/Event.h"
20     #include "FWCore/Framework/interface/EventSetup.h"
21     #include "FWCore/ParameterSet/interface/ParameterSet.h"
22     #include "FWCore/ServiceRegistry/interface/Service.h"
23     #include "DataFormats/Common/interface/Handle.h"
24     #include "CommonTools/UtilAlgos/interface/TFileService.h"
25     #include "FWCore/Framework/interface/MakerMacros.h"
26 lantonel 1.10 #include "DataFormats/Math/interface/deltaPhi.h"
27     #include "DataFormats/Math/interface/deltaR.h"
28 lantonel 1.1
29     #include "ProductArea/BNcollections/interface/BNbxlumi.h"
30     #include "ProductArea/BNcollections/interface/BNelectron.h"
31     #include "ProductArea/BNcollections/interface/BNevent.h"
32     #include "ProductArea/BNcollections/interface/BNjet.h"
33     #include "ProductArea/BNcollections/interface/BNmcparticle.h"
34     #include "ProductArea/BNcollections/interface/BNmet.h"
35     #include "ProductArea/BNcollections/interface/BNmuon.h"
36     #include "ProductArea/BNcollections/interface/BNphoton.h"
37     #include "ProductArea/BNcollections/interface/BNprimaryvertex.h"
38     #include "ProductArea/BNcollections/interface/BNskimbits.h"
39     #include "ProductArea/BNcollections/interface/BNsupercluster.h"
40     #include "ProductArea/BNcollections/interface/BNtrack.h"
41     #include "ProductArea/BNcollections/interface/BNtrigger.h"
42     #include "ProductArea/BNcollections/interface/BNtrigobj.h"
43     #include "ProductArea/BNcollections/interface/BNtau.h"
44     #include "ProductArea/BNcollections/interface/BNgenjet.h"
45    
46     #include "OSUT3Analysis/AnaTools/interface/CutFlow.h"
47 lantonel 1.9 #include "OSUT3Analysis/AnaTools/interface/PUWeight.h"
48 ahart 1.16 #include "OSUT3Analysis/AnaTools/interface/SFWeight.h"
49 lantonel 1.1
50    
51    
52    
53     using namespace std;
54    
55     class OSUAnalysis : public edm::EDAnalyzer
56     {
57     public:
58     OSUAnalysis (const edm::ParameterSet &);
59     ~OSUAnalysis ();
60    
61     void analyze (const edm::Event &, const edm::EventSetup &);
62     bool evaluateComparison (double, string, double);
63 lantonel 1.2 bool evaluateTriggers (vector<string>,const BNtriggerCollection*);
64 lantonel 1.3 double applyFunction(string, double);
65    
66 lantonel 1.4 double valueLookup (const BNjet* object, string variable, string function = "");
67     double valueLookup (const BNmuon* object, string variable, string function = "");
68 lantonel 1.10 double valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function = "");
69 lantonel 1.4 double valueLookup (const BNelectron* object, string variable, string function = "");
70 lantonel 1.10 double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function = "");
71     double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function = "");
72 lantonel 1.4 double valueLookup (const BNevent* object, string variable, string function = "");
73     double valueLookup (const BNtau* object, string variable, string function = "");
74     double valueLookup (const BNmet* object, string variable, string function = "");
75     double valueLookup (const BNtrack* object, string variable, string function = "");
76     double valueLookup (const BNgenjet* object, string variable, string function = "");
77     double valueLookup (const BNmcparticle* object, string variable, string function = "");
78     double valueLookup (const BNprimaryvertex* object, string variable, string function = "");
79     double valueLookup (const BNbxlumi* object, string variable, string function = "");
80     double valueLookup (const BNphoton* object, string variable, string function = "");
81     double valueLookup (const BNsupercluster* object, string variable, string function = "");
82 jbrinson 1.14
83 jbrinson 1.13 int getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl);
84 jbrinson 1.14 double getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl);
85     double getTrkPtRes (const BNtrack* track1);
86     double getTrkIsIso (const BNtrack* track1);
87 jbrinson 1.13 void WriteDeadEcal ();
88     int getTrkIsMatchedDeadEcal (const BNtrack* track1);
89    
90 lantonel 1.1 //BNskimbits
91     //BNtrigobj
92    
93     vector<string> splitString (string);
94    
95    
96     private:
97    
98     //flagMap:
99     //string holds input collection type
100     //outer vector corresponds to each cut
101     //inner vector corresponds to each object in input collection
102     //bool tells if object passes or fails cuts
103     typedef map<string, vector < vector<bool> > > flagMap;
104 ahart 1.16
105 lantonel 1.1 //counterMap:
106     //string holds input collection type
107     //vector corresponds to each cut
108     //int holds number of objects passing all cuts up to that point
109     typedef map<string ,vector <int> > counterMap;
110    
111     // Remember to define parameters to be retrieved from the configuration file.
112     edm::InputTag jets_;
113     edm::InputTag muons_;
114     edm::InputTag electrons_;
115     edm::InputTag events_;
116     edm::InputTag taus_;
117     edm::InputTag mets_;
118     edm::InputTag tracks_;
119     edm::InputTag genjets_;
120     edm::InputTag mcparticles_;
121     edm::InputTag primaryvertexs_;
122     edm::InputTag bxlumis_;
123     edm::InputTag photons_;
124     edm::InputTag superclusters_;
125 lantonel 1.2 edm::InputTag triggers_;
126 lantonel 1.9 std::string puFile_;
127 jbrinson 1.13 std::string deadEcalFile_;
128 ahart 1.16 std::string muonSFFile_;
129 lantonel 1.9 std::string dataPU_;
130 ahart 1.16 std::string electronSFID_;
131     std::string muonSF_;
132 lantonel 1.9 std::string dataset_;
133     std::string datasetType_;
134 lantonel 1.1 vector<edm::ParameterSet> channels_;
135 lantonel 1.4 vector<edm::ParameterSet> histogramSets_;
136 lantonel 1.9 bool plotAllObjectsInPassingEvents_;
137 lantonel 1.15 bool doPileupReweighting_;
138 lantonel 1.1
139 jbrinson 1.13 struct DeadEcal {
140 ahart 1.16 double etaEcal;
141     double phiEcal;
142 jbrinson 1.13 };
143 ahart 1.16
144 jbrinson 1.13 std::vector<DeadEcal> DeadEcalVec;
145    
146 jbrinson 1.14
147 jbrinson 1.13 //Collections
148 lantonel 1.11 edm::Handle<BNtriggerCollection> triggers;
149     edm::Handle<BNjetCollection> jets;
150     edm::Handle<BNmuonCollection> muons;
151     edm::Handle<BNelectronCollection> electrons;
152     edm::Handle<BNeventCollection> events;
153     edm::Handle<BNtauCollection> taus;
154     edm::Handle<BNmetCollection> mets;
155     edm::Handle<BNtrackCollection> tracks;
156     edm::Handle<BNgenjetCollection> genjets;
157     edm::Handle<BNmcparticleCollection> mcparticles;
158     edm::Handle<BNprimaryvertexCollection> primaryvertexs;
159     edm::Handle<BNbxlumiCollection> bxlumis;
160     edm::Handle<BNphotonCollection> photons;
161     edm::Handle<BNsuperclusterCollection> superclusters;
162    
163 ahart 1.16 flagMap cumulativeFlags;
164 lantonel 1.8
165 lantonel 1.1 vector<map<string, TH1D*> > oneDHists_;
166 lantonel 1.6 vector<map<string, TH2D*> > twoDHists_;
167 lantonel 1.1
168     edm::Service<TFileService> fs_;
169    
170     CutFlow *masterCutFlow_;
171     vector<CutFlow *> cutFlows_;
172    
173 lantonel 1.4 typedef struct {
174 ahart 1.16 string name;
175     string title;
176     vector<double> bins;
177     string inputCollection;
178     vector<string> inputVariables;
179 lantonel 1.4 } histogram;
180 lantonel 1.1
181     struct cut {
182 ahart 1.16 string inputCollection;
183     vector<string> functions;
184     vector<string> variables;
185     vector<string> comparativeOperators;// >, <, =, etc.
186     vector<double> cutValues;
187     vector<string> logicalOperators;//and, or
188     int numSubcuts;
189     int numberRequired;
190     string eventComparativeOperator;
191     string name;
192 lantonel 1.1 };
193    
194     struct channel {
195 ahart 1.16 string name;
196     vector<string> triggers;
197     vector<cut> cuts;
198 lantonel 1.1 };
199    
200 lantonel 1.12 vector<string> objectsToGet;
201     vector<string> objectsToCut;
202 lantonel 1.4 vector<string> objectsToPlot;
203 lantonel 1.1 vector<channel> channels;
204 lantonel 1.4 vector<histogram> histograms;
205 lantonel 1.1
206 lantonel 1.9 PUWeight *puWeight_;
207 ahart 1.16 MuonSFWeight *muonSFWeight_;
208     ElectronSFWeight *electronSFWeight_;
209 lantonel 1.9
210 lantonel 1.1 template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string);
211 lantonel 1.12 template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string);
212    
213 lantonel 1.10 template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double);
214     template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
215     template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double);
216     template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
217 lantonel 1.1
218 lantonel 1.11 template <class InputObject> int getGenMatchedParticleIndex(InputObject);
219     int getPdgIdBinValue(int);
220     int findTauMotherIndex(const BNmcparticle*);
221    
222 jbrinson 1.17 template <class InputObject> double getGenDeltaRLowest(InputObject);
223    
224    
225 ahart 1.16 const BNprimaryvertex *chosenVertex ();
226     const BNmet *chosenMET ();
227     const BNelectron *chosenElectron ();
228     const BNmuon *chosenMuon ();
229 jbrinson 1.13
230 lantonel 1.1 };
231    
232     #endif