ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h
Revision: 1.42
Committed: Wed Jun 19 22:42:22 2013 UTC (11 years, 10 months ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.41: +16 -10 lines
Log Message:
added option to add a bool, isVeto, to a cut definition.  This will cause only things FAILING this cut to be plotted

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 ahart 1.29 #include <regex>
13 lantonel 1.6 #include "TH1.h"
14 lantonel 1.9 #include "TH2.h"
15 lantonel 1.1 #include "TH1D.h"
16     #include "TH2D.h"
17     #include "TLorentzVector.h"
18 wulsin 1.35 #include "TTree.h"
19 lantonel 1.1
20 ahart 1.41 #include "FWCore/Framework/interface/EDProducer.h"
21 lantonel 1.1 #include "FWCore/Framework/interface/Event.h"
22     #include "FWCore/Framework/interface/EventSetup.h"
23     #include "FWCore/ParameterSet/interface/ParameterSet.h"
24     #include "FWCore/ServiceRegistry/interface/Service.h"
25     #include "DataFormats/Common/interface/Handle.h"
26     #include "CommonTools/UtilAlgos/interface/TFileService.h"
27     #include "FWCore/Framework/interface/MakerMacros.h"
28 lantonel 1.10 #include "DataFormats/Math/interface/deltaPhi.h"
29     #include "DataFormats/Math/interface/deltaR.h"
30 lantonel 1.1
31     #include "ProductArea/BNcollections/interface/BNbxlumi.h"
32     #include "ProductArea/BNcollections/interface/BNelectron.h"
33     #include "ProductArea/BNcollections/interface/BNevent.h"
34     #include "ProductArea/BNcollections/interface/BNjet.h"
35     #include "ProductArea/BNcollections/interface/BNmcparticle.h"
36     #include "ProductArea/BNcollections/interface/BNmet.h"
37     #include "ProductArea/BNcollections/interface/BNmuon.h"
38     #include "ProductArea/BNcollections/interface/BNphoton.h"
39     #include "ProductArea/BNcollections/interface/BNprimaryvertex.h"
40     #include "ProductArea/BNcollections/interface/BNskimbits.h"
41     #include "ProductArea/BNcollections/interface/BNsupercluster.h"
42     #include "ProductArea/BNcollections/interface/BNtrack.h"
43     #include "ProductArea/BNcollections/interface/BNtrigger.h"
44     #include "ProductArea/BNcollections/interface/BNtrigobj.h"
45     #include "ProductArea/BNcollections/interface/BNtau.h"
46     #include "ProductArea/BNcollections/interface/BNgenjet.h"
47 lantonel 1.26
48 lantonel 1.1
49     #include "OSUT3Analysis/AnaTools/interface/CutFlow.h"
50 lantonel 1.9 #include "OSUT3Analysis/AnaTools/interface/PUWeight.h"
51 ahart 1.16 #include "OSUT3Analysis/AnaTools/interface/SFWeight.h"
52 biliu 1.40 #include "OSUT3Analysis/AnaTools/interface/BtagSFWeight.h"
53 ahart 1.29 #include "OSUT3Analysis/AnaTools/interface/StopCTauWeight.h"
54 lantonel 1.1
55     using namespace std;
56    
57 ahart 1.41 class OSUAnalysis : public edm::EDProducer
58 lantonel 1.1 {
59     public:
60     OSUAnalysis (const edm::ParameterSet &);
61     ~OSUAnalysis ();
62    
63 ahart 1.41 void produce (edm::Event &, const edm::EventSetup &);
64 lantonel 1.1 bool evaluateComparison (double, string, double);
65 ahart 1.31 bool evaluateComparison (string, string, string);
66 biliu 1.34 bool evaluateTriggers (vector<string>, vector<string>, const BNtriggerCollection*);
67 lantonel 1.3 double applyFunction(string, double);
68    
69 ahart 1.31 double valueLookup (const BNjet* object, string variable, string function, string &stringValue);
70     double valueLookup (const BNmuon* object, string variable, string function, string &stringValue);
71     double valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue);
72     double valueLookup (const BNelectron* object, string variable, string function, string &stringValue);
73     double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue);
74     double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue);
75     double valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue);
76     double valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue);
77     double valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue);
78     double valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue);
79     double valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue);
80     double valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue);
81     double valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue);
82     double valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue);
83     double valueLookup (const BNevent* object, string variable, string function, string &stringValue);
84     double valueLookup (const BNtau* object, string variable, string function, string &stringValue);
85     double valueLookup (const BNmet* object, string variable, string function, string &stringValue);
86     double valueLookup (const BNtrack* object, string variable, string function, string &stringValue);
87     double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue);
88     double valueLookup (const BNgenjet* object, string variable, string function, string &stringValue);
89     double valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue);
90     double valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue);
91     double valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue);
92     double valueLookup (const BNphoton* object, string variable, string function, string &stringValue);
93     double valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue);
94     double valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue);
95     double valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue);
96     double valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue);
97     double valueLookup (const BNstop* object, string variable, string function, string &stringValue);
98 jbrinson 1.14
99 jbrinson 1.13 int getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl);
100 jbrinson 1.14 double getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl);
101     double getTrkPtRes (const BNtrack* track1);
102     double getTrkIsIso (const BNtrack* track1);
103 wulsin 1.20 double getTrkCaloTotRhoCorr(const BNtrack* track);
104 jbrinson 1.13 void WriteDeadEcal ();
105     int getTrkIsMatchedDeadEcal (const BNtrack* track1);
106    
107 lantonel 1.1 //BNskimbits
108     //BNtrigobj
109    
110     vector<string> splitString (string);
111 ahart 1.31 void getTwoObjs(string tempInputCollection, string& obj1, string& obj2);
112     string getObjToGet(string obj);
113 lantonel 1.1
114     private:
115    
116     //flagMap:
117     //string holds input collection type
118     //outer vector corresponds to each cut
119     //inner vector corresponds to each object in input collection
120 lantonel 1.42 //pair(bool) first bool counts towards the event passing, second bool determines whether to plot the object
121     typedef map<string, vector<vector<pair<bool,bool> > > > flagMap;
122    
123     typedef vector<pair<bool,bool> > flagPair;
124 ahart 1.16
125 lantonel 1.1 //counterMap:
126     //string holds input collection type
127     //vector corresponds to each cut
128     //int holds number of objects passing all cuts up to that point
129     typedef map<string ,vector <int> > counterMap;
130    
131     // Remember to define parameters to be retrieved from the configuration file.
132     edm::InputTag jets_;
133     edm::InputTag muons_;
134     edm::InputTag electrons_;
135     edm::InputTag events_;
136     edm::InputTag taus_;
137     edm::InputTag mets_;
138     edm::InputTag tracks_;
139     edm::InputTag genjets_;
140     edm::InputTag mcparticles_;
141 ahart 1.21 edm::InputTag stops_;
142 lantonel 1.1 edm::InputTag primaryvertexs_;
143     edm::InputTag bxlumis_;
144     edm::InputTag photons_;
145     edm::InputTag superclusters_;
146 lantonel 1.2 edm::InputTag triggers_;
147 ahart 1.31 edm::InputTag trigobjs_;
148     string puFile_;
149     string deadEcalFile_;
150     string muonSFFile_;
151     string dataPU_;
152     string electronSFID_;
153     string muonSF_;
154     string dataset_;
155     string datasetType_;
156 lantonel 1.1 vector<edm::ParameterSet> channels_;
157 lantonel 1.4 vector<edm::ParameterSet> histogramSets_;
158 ahart 1.41 bool useEDMFormat_;
159 wulsin 1.35 vector<edm::ParameterSet> treeBranchSets_;
160 lantonel 1.9 bool plotAllObjectsInPassingEvents_;
161 lantonel 1.15 bool doPileupReweighting_;
162 ahart 1.28 bool applyLeptonSF_;
163 biliu 1.40 bool applyBtagSF_;
164     int minBtag_;
165     int maxBtag_;
166 ahart 1.31 bool printEventInfo_;
167 wulsin 1.39 bool printAllTriggers_;
168 ahart 1.31 bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy
169 ahart 1.21 vector<double> stopCTau_;
170 biliu 1.33 bool GetPlotsAfterEachCut_;
171    
172 jbrinson 1.13 struct DeadEcal {
173 ahart 1.16 double etaEcal;
174     double phiEcal;
175 jbrinson 1.13 };
176 ahart 1.16
177 ahart 1.31 vector<DeadEcal> DeadEcalVec;
178 jbrinson 1.13
179 jbrinson 1.14
180 jbrinson 1.13 //Collections
181 lantonel 1.11 edm::Handle<BNtriggerCollection> triggers;
182 ahart 1.31 edm::Handle<BNtrigobjCollection> trigobjs;
183 lantonel 1.11 edm::Handle<BNjetCollection> jets;
184     edm::Handle<BNmuonCollection> muons;
185     edm::Handle<BNelectronCollection> electrons;
186     edm::Handle<BNeventCollection> events;
187     edm::Handle<BNtauCollection> taus;
188     edm::Handle<BNmetCollection> mets;
189     edm::Handle<BNtrackCollection> tracks;
190     edm::Handle<BNgenjetCollection> genjets;
191     edm::Handle<BNmcparticleCollection> mcparticles;
192     edm::Handle<BNprimaryvertexCollection> primaryvertexs;
193     edm::Handle<BNbxlumiCollection> bxlumis;
194     edm::Handle<BNphotonCollection> photons;
195     edm::Handle<BNsuperclusterCollection> superclusters;
196 lantonel 1.24 edm::Handle<BNstopCollection> stops;
197 lantonel 1.26
198 ahart 1.31 edm::Handle<double> rhokt6CaloJetsHandle_;
199 lantonel 1.11
200 ahart 1.16 flagMap cumulativeFlags;
201 lantonel 1.42 flagMap vetoFlags;
202 lantonel 1.8
203 biliu 1.33 vector<vector<map<string, TH1D*>>> oneDHists_;
204     vector<vector<map<string, TH2D*>>> twoDHists_;
205 wulsin 1.35 vector<TTree*> BNTrees_; // one tree per channel
206     map<string, vector<float>> BNTreeBranchVals_; // data structure to hold the values of the branches to be stored in the BNTrees_; the string is the name of a variable
207 lantonel 1.1
208     edm::Service<TFileService> fs_;
209    
210     CutFlow *masterCutFlow_;
211     vector<CutFlow *> cutFlows_;
212    
213 lantonel 1.4 typedef struct {
214 ahart 1.16 string name;
215     string title;
216     vector<double> bins;
217 ahart 1.30 vector<double> variableBinsX;
218     vector<double> variableBinsY;
219 ahart 1.16 string inputCollection;
220     vector<string> inputVariables;
221 lantonel 1.4 } histogram;
222 lantonel 1.1
223 wulsin 1.35 typedef struct {
224     string name;
225     string inputCollection;
226     string inputVariable;
227     } BranchSpecs;
228    
229    
230 lantonel 1.1 struct cut {
231 ahart 1.16 string inputCollection;
232     vector<string> functions;
233     vector<string> variables;
234     vector<string> comparativeOperators;// >, <, =, etc.
235     vector<double> cutValues;
236 ahart 1.31 vector<string> cutStringValues;
237 ahart 1.16 vector<string> logicalOperators;//and, or
238 lantonel 1.42 int numSubcuts;
239 ahart 1.16 int numberRequired;
240     string eventComparativeOperator;
241     string name;
242 lantonel 1.42 bool isVeto;
243 lantonel 1.1 };
244    
245     struct channel {
246 ahart 1.16 string name;
247     vector<string> triggers;
248 biliu 1.34 vector<string> triggersToVeto;
249 ahart 1.16 vector<cut> cuts;
250 lantonel 1.1 };
251    
252 lantonel 1.12 vector<string> objectsToGet;
253     vector<string> objectsToCut;
254 lantonel 1.4 vector<string> objectsToPlot;
255 lantonel 1.1 vector<channel> channels;
256 lantonel 1.4 vector<histogram> histograms;
257 wulsin 1.35 vector<BranchSpecs> treeBranches_;
258 lantonel 1.1
259 lantonel 1.9 PUWeight *puWeight_;
260 ahart 1.16 MuonSFWeight *muonSFWeight_;
261 ahart 1.32 double muonScaleFactor_;
262 ahart 1.16 ElectronSFWeight *electronSFWeight_;
263 ahart 1.32 double electronScaleFactor_;
264 biliu 1.40 BtagSFWeight *bTagSFWeight_;
265     double bTagScaleFactor_;
266 ahart 1.29
267     StopCTauWeight *stopCTauWeight_;
268     double stopCTauScaleFactor_;
269 lantonel 1.9
270 lantonel 1.1 template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string);
271 lantonel 1.42 template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, flagPair, flagPair, string);
272    
273     template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, flagPair flags);
274     template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, flagPair, double);
275     template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double);
276     template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, flagPair, double);
277     template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double);
278     bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType);
279    
280 lantonel 1.12
281 lantonel 1.1
282 lantonel 1.11 template <class InputObject> int getGenMatchedParticleIndex(InputObject);
283     int getPdgIdBinValue(int);
284     int findTauMotherIndex(const BNmcparticle*);
285    
286 jbrinson 1.17 template <class InputObject> double getGenDeltaRLowest(InputObject);
287    
288    
289 ahart 1.16 const BNprimaryvertex *chosenVertex ();
290     const BNmet *chosenMET ();
291     const BNelectron *chosenElectron ();
292     const BNmuon *chosenMuon ();
293 jbrinson 1.13
294 lantonel 1.1 };
295    
296     #endif