ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h
Revision: 1.14
Committed: Thu Mar 14 10:06:38 2013 UTC (12 years, 1 month ago) by jbrinson
Content type: text/plain
Branch: MAIN
Changes since 1.13: +5 -3 lines
Log Message:
Added functions for calculating ptRes, added members to BNtrack

File Contents

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