ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h
Revision: 1.26
Committed: Sat Apr 27 15:53:06 2013 UTC (12 years ago) by lantonel
Content type: text/plain
Branch: MAIN
CVS Tags: V00-01-00
Changes since 1.25: +4 -5 lines
Log Message:
\f\i\x\e\d\ \b\u\g\ \w\h\i\c\h\ \w\a\s\ \b\r\e\a\k\i\n\g\ \t\h\i\n\g\s\ \f\o\r\ \p\e\o\p\l\e\ \n\o\t\ \u\s\i\n\g\ \t\h\e\ \'\D\i\s\p\l\a\c\e\d\S\U\S\Y\'\ \f\l\a\g\ \i\n\ \t\h\e\i\r\ \B\u\i\l\d\f\i\l\e\.\x\m\l

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 #include "ProductArea/BNcollections/interface/BNstop.h"
46
47
48 #include "OSUT3Analysis/AnaTools/interface/CutFlow.h"
49 #include "OSUT3Analysis/AnaTools/interface/PUWeight.h"
50 #include "OSUT3Analysis/AnaTools/interface/SFWeight.h"
51
52 #ifdef DISPLACED_SUSY
53 #include "DisplacedSUSY/Configuration/interface/CTauWeight.h"
54 #endif
55
56 using namespace std;
57
58 class OSUAnalysis : public edm::EDAnalyzer
59 {
60 public:
61 OSUAnalysis (const edm::ParameterSet &);
62 ~OSUAnalysis ();
63
64 void analyze (const edm::Event &, const edm::EventSetup &);
65 bool evaluateComparison (double, string, double);
66 bool evaluateTriggers (vector<string>,const BNtriggerCollection*);
67 double applyFunction(string, double);
68
69 double valueLookup (const BNjet* object, string variable, string function = "");
70 double valueLookup (const BNmuon* object, string variable, string function = "");
71 double valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function = "");
72 double valueLookup (const BNelectron* object, string variable, string function = "");
73 double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function = "");
74 double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function = "");
75 double valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function = "");
76 double valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function = "");
77 double valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function = "");
78 double valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function = "");
79 double valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function = "");
80 double valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function = "");
81 double valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function);
82 double valueLookup (const BNevent* object, string variable, string function = "");
83 double valueLookup (const BNtau* object, string variable, string function = "");
84 double valueLookup (const BNmet* object, string variable, string function = "");
85 double valueLookup (const BNtrack* object, string variable, string function = "");
86 double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function = "");
87 double valueLookup (const BNgenjet* object, string variable, string function = "");
88 double valueLookup (const BNmcparticle* object, string variable, string function = "");
89 double valueLookup (const BNprimaryvertex* object, string variable, string function = "");
90 double valueLookup (const BNbxlumi* object, string variable, string function = "");
91 double valueLookup (const BNphoton* object, string variable, string function = "");
92 double valueLookup (const BNsupercluster* object, string variable, string function = "");
93 double valueLookup (const BNstop* object, string variable, string function = "");
94
95 int getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl);
96 double getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl);
97 double getTrkPtRes (const BNtrack* track1);
98 double getTrkIsIso (const BNtrack* track1);
99 double getTrkCaloTotRhoCorr(const BNtrack* track);
100 void WriteDeadEcal ();
101 int getTrkIsMatchedDeadEcal (const BNtrack* track1);
102
103 //BNskimbits
104 //BNtrigobj
105
106 vector<string> splitString (string);
107 void getTwoObjs(string tempInputCollection, string& obj1, string& obj2);
108 string getObjToGet(string obj);
109
110 private:
111
112 //flagMap:
113 //string holds input collection type
114 //outer vector corresponds to each cut
115 //inner vector corresponds to each object in input collection
116 //bool tells if object passes or fails cuts
117 typedef map<string, vector < vector<bool> > > flagMap;
118
119 //counterMap:
120 //string holds input collection type
121 //vector corresponds to each cut
122 //int holds number of objects passing all cuts up to that point
123 typedef map<string ,vector <int> > counterMap;
124
125 // Remember to define parameters to be retrieved from the configuration file.
126 edm::InputTag jets_;
127 edm::InputTag muons_;
128 edm::InputTag electrons_;
129 edm::InputTag events_;
130 edm::InputTag taus_;
131 edm::InputTag mets_;
132 edm::InputTag tracks_;
133 edm::InputTag genjets_;
134 edm::InputTag mcparticles_;
135 edm::InputTag stops_;
136 edm::InputTag primaryvertexs_;
137 edm::InputTag bxlumis_;
138 edm::InputTag photons_;
139 edm::InputTag superclusters_;
140 edm::InputTag triggers_;
141 std::string puFile_;
142 std::string deadEcalFile_;
143 std::string muonSFFile_;
144 std::string dataPU_;
145 std::string electronSFID_;
146 std::string muonSF_;
147 std::string dataset_;
148 std::string datasetType_;
149 vector<edm::ParameterSet> channels_;
150 vector<edm::ParameterSet> histogramSets_;
151 bool plotAllObjectsInPassingEvents_;
152 bool doPileupReweighting_;
153 bool printEventInfo_;
154 bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy
155 vector<double> stopCTau_;
156
157 struct DeadEcal {
158 double etaEcal;
159 double phiEcal;
160 };
161
162 std::vector<DeadEcal> DeadEcalVec;
163
164
165 //Collections
166 edm::Handle<BNtriggerCollection> triggers;
167 edm::Handle<BNjetCollection> jets;
168 edm::Handle<BNmuonCollection> muons;
169 edm::Handle<BNelectronCollection> electrons;
170 edm::Handle<BNeventCollection> events;
171 edm::Handle<BNtauCollection> taus;
172 edm::Handle<BNmetCollection> mets;
173 edm::Handle<BNtrackCollection> tracks;
174 edm::Handle<BNgenjetCollection> genjets;
175 edm::Handle<BNmcparticleCollection> mcparticles;
176 edm::Handle<BNprimaryvertexCollection> primaryvertexs;
177 edm::Handle<BNbxlumiCollection> bxlumis;
178 edm::Handle<BNphotonCollection> photons;
179 edm::Handle<BNsuperclusterCollection> superclusters;
180 edm::Handle<BNstopCollection> stops;
181
182 edm::Handle<double> rhokt6CaloJetsHandle_;
183
184 flagMap cumulativeFlags;
185
186 vector<map<string, TH1D*> > oneDHists_;
187 vector<map<string, TH2D*> > twoDHists_;
188
189 edm::Service<TFileService> fs_;
190
191 CutFlow *masterCutFlow_;
192 vector<CutFlow *> cutFlows_;
193
194 typedef struct {
195 string name;
196 string title;
197 vector<double> bins;
198 string inputCollection;
199 vector<string> inputVariables;
200 } histogram;
201
202 struct cut {
203 string inputCollection;
204 vector<string> functions;
205 vector<string> variables;
206 vector<string> comparativeOperators;// >, <, =, etc.
207 vector<double> cutValues;
208 vector<string> logicalOperators;//and, or
209 int numSubcuts;
210 int numberRequired;
211 string eventComparativeOperator;
212 string name;
213 };
214
215 struct channel {
216 string name;
217 vector<string> triggers;
218 vector<cut> cuts;
219 };
220
221 vector<string> objectsToGet;
222 vector<string> objectsToCut;
223 vector<string> objectsToPlot;
224 vector<channel> channels;
225 vector<histogram> histograms;
226
227 PUWeight *puWeight_;
228 MuonSFWeight *muonSFWeight_;
229 ElectronSFWeight *electronSFWeight_;
230 #ifdef DISPLACED_SUSY
231 CTauWeight *cTauWeight_;
232 #endif
233 double cTauScaleFactor_;
234
235 template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string);
236 template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string);
237
238 template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double);
239 template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
240 template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double);
241 template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
242 bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1);
243
244 template <class InputObject> int getGenMatchedParticleIndex(InputObject);
245 int getPdgIdBinValue(int);
246 int findTauMotherIndex(const BNmcparticle*);
247
248 template <class InputObject> double getGenDeltaRLowest(InputObject);
249
250
251 const BNprimaryvertex *chosenVertex ();
252 const BNmet *chosenMET ();
253 const BNelectron *chosenElectron ();
254 const BNmuon *chosenMuon ();
255
256 };
257
258 #endif