ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h
Revision: 1.37
Committed: Fri May 31 11:24:31 2013 UTC (11 years, 11 months ago) by wulsin
Content type: text/plain
Branch: MAIN
CVS Tags: V02-02-00
Changes since 1.36: +1 -0 lines
Log Message:
add flag to fill the BNTree or not

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     #include "FWCore/Framework/interface/EDAnalyzer.h"
21     #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 lantonel 1.1
53 ahart 1.29 #include "OSUT3Analysis/AnaTools/interface/StopCTauWeight.h"
54 lantonel 1.1
55     using namespace std;
56    
57     class OSUAnalysis : public edm::EDAnalyzer
58     {
59     public:
60     OSUAnalysis (const edm::ParameterSet &);
61     ~OSUAnalysis ();
62    
63     void analyze (const edm::Event &, const edm::EventSetup &);
64     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     //bool tells if object passes or fails cuts
121     typedef map<string, vector < vector<bool> > > flagMap;
122 ahart 1.16
123 lantonel 1.1 //counterMap:
124     //string holds input collection type
125     //vector corresponds to each cut
126     //int holds number of objects passing all cuts up to that point
127     typedef map<string ,vector <int> > counterMap;
128    
129     // Remember to define parameters to be retrieved from the configuration file.
130     edm::InputTag jets_;
131     edm::InputTag muons_;
132     edm::InputTag electrons_;
133     edm::InputTag events_;
134     edm::InputTag taus_;
135     edm::InputTag mets_;
136     edm::InputTag tracks_;
137     edm::InputTag genjets_;
138     edm::InputTag mcparticles_;
139 ahart 1.21 edm::InputTag stops_;
140 lantonel 1.1 edm::InputTag primaryvertexs_;
141     edm::InputTag bxlumis_;
142     edm::InputTag photons_;
143     edm::InputTag superclusters_;
144 lantonel 1.2 edm::InputTag triggers_;
145 ahart 1.31 edm::InputTag trigobjs_;
146     string puFile_;
147     string deadEcalFile_;
148     string muonSFFile_;
149     string dataPU_;
150     string electronSFID_;
151     string muonSF_;
152     string dataset_;
153     string datasetType_;
154 lantonel 1.1 vector<edm::ParameterSet> channels_;
155 lantonel 1.4 vector<edm::ParameterSet> histogramSets_;
156 wulsin 1.35 vector<edm::ParameterSet> treeBranchSets_;
157 lantonel 1.9 bool plotAllObjectsInPassingEvents_;
158 lantonel 1.15 bool doPileupReweighting_;
159 wulsin 1.37 bool fillBNTree_;
160 ahart 1.28 bool applyLeptonSF_;
161 ahart 1.31 bool printEventInfo_;
162     bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy
163 ahart 1.21 vector<double> stopCTau_;
164 biliu 1.33 bool GetPlotsAfterEachCut_;
165    
166 jbrinson 1.13 struct DeadEcal {
167 ahart 1.16 double etaEcal;
168     double phiEcal;
169 jbrinson 1.13 };
170 ahart 1.16
171 ahart 1.31 vector<DeadEcal> DeadEcalVec;
172 jbrinson 1.13
173 jbrinson 1.14
174 jbrinson 1.13 //Collections
175 lantonel 1.11 edm::Handle<BNtriggerCollection> triggers;
176 ahart 1.31 edm::Handle<BNtrigobjCollection> trigobjs;
177 lantonel 1.11 edm::Handle<BNjetCollection> jets;
178     edm::Handle<BNmuonCollection> muons;
179     edm::Handle<BNelectronCollection> electrons;
180     edm::Handle<BNeventCollection> events;
181     edm::Handle<BNtauCollection> taus;
182     edm::Handle<BNmetCollection> mets;
183     edm::Handle<BNtrackCollection> tracks;
184     edm::Handle<BNgenjetCollection> genjets;
185     edm::Handle<BNmcparticleCollection> mcparticles;
186     edm::Handle<BNprimaryvertexCollection> primaryvertexs;
187     edm::Handle<BNbxlumiCollection> bxlumis;
188     edm::Handle<BNphotonCollection> photons;
189     edm::Handle<BNsuperclusterCollection> superclusters;
190 lantonel 1.24 edm::Handle<BNstopCollection> stops;
191 lantonel 1.26
192 ahart 1.31 edm::Handle<double> rhokt6CaloJetsHandle_;
193 lantonel 1.11
194 ahart 1.16 flagMap cumulativeFlags;
195 lantonel 1.8
196 biliu 1.33 vector<vector<map<string, TH1D*>>> oneDHists_;
197     vector<vector<map<string, TH2D*>>> twoDHists_;
198 wulsin 1.35 vector<TTree*> BNTrees_; // one tree per channel
199     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
200 lantonel 1.1
201     edm::Service<TFileService> fs_;
202    
203     CutFlow *masterCutFlow_;
204     vector<CutFlow *> cutFlows_;
205    
206 lantonel 1.4 typedef struct {
207 ahart 1.16 string name;
208     string title;
209     vector<double> bins;
210 ahart 1.30 vector<double> variableBinsX;
211     vector<double> variableBinsY;
212 ahart 1.16 string inputCollection;
213     vector<string> inputVariables;
214 lantonel 1.4 } histogram;
215 lantonel 1.1
216 wulsin 1.35 typedef struct {
217     string name;
218     string inputCollection;
219     string inputVariable;
220     } BranchSpecs;
221    
222    
223 lantonel 1.1 struct cut {
224 ahart 1.16 string inputCollection;
225     vector<string> functions;
226     vector<string> variables;
227     vector<string> comparativeOperators;// >, <, =, etc.
228     vector<double> cutValues;
229 ahart 1.31 vector<string> cutStringValues;
230 ahart 1.16 vector<string> logicalOperators;//and, or
231     int numSubcuts;
232     int numberRequired;
233     string eventComparativeOperator;
234     string name;
235 lantonel 1.1 };
236    
237     struct channel {
238 ahart 1.16 string name;
239     vector<string> triggers;
240 biliu 1.34 vector<string> triggersToVeto;
241 ahart 1.16 vector<cut> cuts;
242 lantonel 1.1 };
243    
244 lantonel 1.12 vector<string> objectsToGet;
245     vector<string> objectsToCut;
246 lantonel 1.4 vector<string> objectsToPlot;
247 lantonel 1.1 vector<channel> channels;
248 lantonel 1.4 vector<histogram> histograms;
249 wulsin 1.35 vector<BranchSpecs> treeBranches_;
250 lantonel 1.1
251 lantonel 1.9 PUWeight *puWeight_;
252 ahart 1.16 MuonSFWeight *muonSFWeight_;
253 ahart 1.32 double muonScaleFactor_;
254 ahart 1.16 ElectronSFWeight *electronSFWeight_;
255 ahart 1.32 double electronScaleFactor_;
256 ahart 1.29
257     StopCTauWeight *stopCTauWeight_;
258     double stopCTauScaleFactor_;
259 lantonel 1.9
260 lantonel 1.1 template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string);
261 lantonel 1.12 template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string);
262    
263 wulsin 1.35 template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, vector<bool> flags);
264 lantonel 1.10 template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double);
265     template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
266     template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double);
267     template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
268 ahart 1.31 bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1);
269 lantonel 1.1
270 lantonel 1.11 template <class InputObject> int getGenMatchedParticleIndex(InputObject);
271     int getPdgIdBinValue(int);
272     int findTauMotherIndex(const BNmcparticle*);
273    
274 jbrinson 1.17 template <class InputObject> double getGenDeltaRLowest(InputObject);
275    
276    
277 ahart 1.16 const BNprimaryvertex *chosenVertex ();
278     const BNmet *chosenMET ();
279     const BNelectron *chosenElectron ();
280     const BNmuon *chosenMuon ();
281 jbrinson 1.13
282 lantonel 1.1 };
283    
284     #endif