ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h
Revision: 1.41
Committed: Tue Jun 11 00:35:34 2013 UTC (11 years, 10 months ago) by ahart
Content type: text/plain
Branch: MAIN
Changes since 1.40: +4 -3 lines
Log Message:
Changed OSUAnalysis to an EDProducer.

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     //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 ahart 1.41 bool useEDMFormat_;
157 wulsin 1.35 vector<edm::ParameterSet> treeBranchSets_;
158 lantonel 1.9 bool plotAllObjectsInPassingEvents_;
159 lantonel 1.15 bool doPileupReweighting_;
160 ahart 1.28 bool applyLeptonSF_;
161 biliu 1.40 bool applyBtagSF_;
162     int minBtag_;
163     int maxBtag_;
164 ahart 1.31 bool printEventInfo_;
165 wulsin 1.39 bool printAllTriggers_;
166 ahart 1.31 bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy
167 ahart 1.21 vector<double> stopCTau_;
168 biliu 1.33 bool GetPlotsAfterEachCut_;
169    
170 jbrinson 1.13 struct DeadEcal {
171 ahart 1.16 double etaEcal;
172     double phiEcal;
173 jbrinson 1.13 };
174 ahart 1.16
175 ahart 1.31 vector<DeadEcal> DeadEcalVec;
176 jbrinson 1.13
177 jbrinson 1.14
178 jbrinson 1.13 //Collections
179 lantonel 1.11 edm::Handle<BNtriggerCollection> triggers;
180 ahart 1.31 edm::Handle<BNtrigobjCollection> trigobjs;
181 lantonel 1.11 edm::Handle<BNjetCollection> jets;
182     edm::Handle<BNmuonCollection> muons;
183     edm::Handle<BNelectronCollection> electrons;
184     edm::Handle<BNeventCollection> events;
185     edm::Handle<BNtauCollection> taus;
186     edm::Handle<BNmetCollection> mets;
187     edm::Handle<BNtrackCollection> tracks;
188     edm::Handle<BNgenjetCollection> genjets;
189     edm::Handle<BNmcparticleCollection> mcparticles;
190     edm::Handle<BNprimaryvertexCollection> primaryvertexs;
191     edm::Handle<BNbxlumiCollection> bxlumis;
192     edm::Handle<BNphotonCollection> photons;
193     edm::Handle<BNsuperclusterCollection> superclusters;
194 lantonel 1.24 edm::Handle<BNstopCollection> stops;
195 lantonel 1.26
196 ahart 1.31 edm::Handle<double> rhokt6CaloJetsHandle_;
197 lantonel 1.11
198 ahart 1.16 flagMap cumulativeFlags;
199 lantonel 1.8
200 biliu 1.33 vector<vector<map<string, TH1D*>>> oneDHists_;
201     vector<vector<map<string, TH2D*>>> twoDHists_;
202 wulsin 1.35 vector<TTree*> BNTrees_; // one tree per channel
203     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
204 lantonel 1.1
205     edm::Service<TFileService> fs_;
206    
207     CutFlow *masterCutFlow_;
208     vector<CutFlow *> cutFlows_;
209    
210 lantonel 1.4 typedef struct {
211 ahart 1.16 string name;
212     string title;
213     vector<double> bins;
214 ahart 1.30 vector<double> variableBinsX;
215     vector<double> variableBinsY;
216 ahart 1.16 string inputCollection;
217     vector<string> inputVariables;
218 lantonel 1.4 } histogram;
219 lantonel 1.1
220 wulsin 1.35 typedef struct {
221     string name;
222     string inputCollection;
223     string inputVariable;
224     } BranchSpecs;
225    
226    
227 lantonel 1.1 struct cut {
228 ahart 1.16 string inputCollection;
229     vector<string> functions;
230     vector<string> variables;
231     vector<string> comparativeOperators;// >, <, =, etc.
232     vector<double> cutValues;
233 ahart 1.31 vector<string> cutStringValues;
234 ahart 1.16 vector<string> logicalOperators;//and, or
235     int numSubcuts;
236     int numberRequired;
237     string eventComparativeOperator;
238     string name;
239 lantonel 1.1 };
240    
241     struct channel {
242 ahart 1.16 string name;
243     vector<string> triggers;
244 biliu 1.34 vector<string> triggersToVeto;
245 ahart 1.16 vector<cut> cuts;
246 lantonel 1.1 };
247    
248 lantonel 1.12 vector<string> objectsToGet;
249     vector<string> objectsToCut;
250 lantonel 1.4 vector<string> objectsToPlot;
251 lantonel 1.1 vector<channel> channels;
252 lantonel 1.4 vector<histogram> histograms;
253 wulsin 1.35 vector<BranchSpecs> treeBranches_;
254 lantonel 1.1
255 lantonel 1.9 PUWeight *puWeight_;
256 ahart 1.16 MuonSFWeight *muonSFWeight_;
257 ahart 1.32 double muonScaleFactor_;
258 ahart 1.16 ElectronSFWeight *electronSFWeight_;
259 ahart 1.32 double electronScaleFactor_;
260 biliu 1.40 BtagSFWeight *bTagSFWeight_;
261     double bTagScaleFactor_;
262 ahart 1.29
263     StopCTauWeight *stopCTauWeight_;
264     double stopCTauScaleFactor_;
265 lantonel 1.9
266 lantonel 1.1 template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string);
267 lantonel 1.12 template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string);
268    
269 wulsin 1.35 template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, vector<bool> flags);
270 lantonel 1.10 template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double);
271     template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
272     template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double);
273     template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
274 ahart 1.31 bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1);
275 lantonel 1.1
276 lantonel 1.11 template <class InputObject> int getGenMatchedParticleIndex(InputObject);
277     int getPdgIdBinValue(int);
278     int findTauMotherIndex(const BNmcparticle*);
279    
280 jbrinson 1.17 template <class InputObject> double getGenDeltaRLowest(InputObject);
281    
282    
283 ahart 1.16 const BNprimaryvertex *chosenVertex ();
284     const BNmet *chosenMET ();
285     const BNelectron *chosenElectron ();
286     const BNmuon *chosenMuon ();
287 jbrinson 1.13
288 lantonel 1.1 };
289    
290     #endif