ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h
(Generate patch)

Comparing UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h (file contents):
Revision 1.21 by ahart, Thu Apr 11 00:56:49 2013 UTC vs.
Revision 1.51 by jbrinson, Tue Jul 23 11:10:47 2013 UTC

# Line 9 | Line 9
9   #include <fstream>
10   #include <iostream>
11   #include <algorithm>
12 + #include <regex>
13   #include "TH1.h"
14   #include "TH2.h"
15   #include "TH1D.h"
16   #include "TH2D.h"
17   #include "TLorentzVector.h"
18 + #include "TVector3.h"
19 + #include "TVector2.h"
20 + #include "TTree.h"
21  
22 < #include "FWCore/Framework/interface/EDAnalyzer.h"
22 > #include "FWCore/Framework/interface/EDProducer.h"
23   #include "FWCore/Framework/interface/Event.h"
24   #include "FWCore/Framework/interface/EventSetup.h"
25   #include "FWCore/ParameterSet/interface/ParameterSet.h"
# Line 43 | Line 47
47   #include "ProductArea/BNcollections/interface/BNtau.h"
48   #include "ProductArea/BNcollections/interface/BNgenjet.h"
49  
50 +
51   #include "OSUT3Analysis/AnaTools/interface/CutFlow.h"
52   #include "OSUT3Analysis/AnaTools/interface/PUWeight.h"
53   #include "OSUT3Analysis/AnaTools/interface/SFWeight.h"
54 <
55 < #ifdef DISPLACED_SUSY
51 < #include "DisplacedSUSY/Configuration/interface/CTauWeight.h"
52 < #endif
54 > #include "OSUT3Analysis/AnaTools/interface/BtagSFWeight.h"
55 > #include "OSUT3Analysis/AnaTools/interface/StopCTauWeight.h"
56  
57   using namespace std;
58  
59 < class OSUAnalysis : public edm::EDAnalyzer
59 > class OSUAnalysis : public edm::EDProducer
60    {
61      public:
62        OSUAnalysis (const edm::ParameterSet &);
63        ~OSUAnalysis ();
64  
65 <      void analyze (const edm::Event &, const edm::EventSetup &);
65 >      void produce (edm::Event &, const edm::EventSetup &);
66        bool evaluateComparison (double, string, double);
67 <      bool evaluateTriggers   (vector<string>,const BNtriggerCollection*);
67 >      bool evaluateComparison (string, string, string);
68 >      bool evaluateTriggers   (vector<string>, vector<string>, const BNtriggerCollection*);
69        double applyFunction(string, double);
70  
71 <      double valueLookup (const BNjet* object, string variable, string function = "");
72 <      double valueLookup (const BNmuon* object, string variable, string function = "");
73 <      double valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function = "");
74 <      double valueLookup (const BNelectron* object, string variable, string function = "");
75 <      double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function = "");
76 <      double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function = "");
77 <      double valueLookup (const BNelectron* object1, const BNtrack* 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 BNevent* object, string variable, string function = "");
82 <      double valueLookup (const BNtau* object, string variable, string function = "");
83 <      double valueLookup (const BNmet* object, string variable, string function = "");
84 <      double valueLookup (const BNtrack* object, string variable, string function = "");
85 <      double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function = "");
86 <      double valueLookup (const BNgenjet* object, string variable, string function = "");
87 <      double valueLookup (const BNmcparticle* object, string variable, string function = "");
88 <      double valueLookup (const BNprimaryvertex* object, string variable, string function = "");
89 <      double valueLookup (const BNbxlumi* object, string variable, string function = "");
90 <      double valueLookup (const BNphoton* object, string variable, string function = "");
91 <      double valueLookup (const BNsupercluster* object, string variable, string function = "");
71 >      double valueLookup (const BNjet* object, string variable, string function, string &stringValue);
72 >      double valueLookup (const BNmuon* object, string variable, string function, string &stringValue);
73 >      double valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue);
74 >      double valueLookup (const BNelectron* object, string variable, string function, string &stringValue);
75 >      double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue);
76 >      double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue);
77 >      double valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue);
78 >      double valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue);
79 >      double valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue);
80 >      double valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue);
81 >      double valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue);
82 >      double valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue);
83 >      double valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue);
84 >      double valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue);  
85 >      double valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue);  
86 >      double valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue);
87 >      double valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue);
88 >      double valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue);
89 >      double valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue);
90 >      double valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue);
91 >      double valueLookup (const BNevent* object, string variable, string function, string &stringValue);
92 >      double valueLookup (const BNtau* object, string variable, string function, string &stringValue);
93 >      double valueLookup (const BNmet* object, string variable, string function, string &stringValue);
94 >      double valueLookup (const BNtrack* object, string variable, string function, string &stringValue);
95 >      double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue);
96 >      double valueLookup (const BNgenjet* object, string variable, string function, string &stringValue);
97 >      double valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue);
98 >      double valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue);
99 >      double valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue);
100 >      double valueLookup (const BNphoton* object, string variable, string function, string &stringValue);
101 >      double valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue);
102 >      double valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue);
103 >      double valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue);
104 >      double valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue);
105 >      double valueLookup (const BNstop* object, string variable, string function, string &stringValue);
106  
107        int getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl);
108        double getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl);
109 +      double getHt (const BNjetCollection* jetColl);
110        double getTrkPtRes (const BNtrack* track1);
111        double getTrkIsIso (const BNtrack* track1);
112        double getTrkCaloTotRhoCorr(const BNtrack* track);
113 +      double getTrkDepTrkRp5RhoCorr(const BNtrack* track);
114 +      double getTrkDepTrkRp3RhoCorr(const BNtrack* track);
115        void WriteDeadEcal ();
116        int getTrkIsMatchedDeadEcal (const BNtrack* track1);
117  
# Line 98 | Line 119 | class OSUAnalysis : public edm::EDAnalyz
119        //BNtrigobj
120  
121        vector<string> splitString (string);
122 <
122 >      void getTwoObjs(string tempInputCollection, string& obj1, string& obj2);
123 >      string getObjToGet(string obj);
124  
125      private:
126  
# Line 106 | Line 128 | class OSUAnalysis : public edm::EDAnalyz
128        //string       holds input collection type
129        //outer vector corresponds to each cut
130        //inner vector corresponds to each object in input collection
131 <      //bool         tells if object passes or fails cuts
132 <      typedef map<string, vector < vector<bool> > > flagMap;
131 >      //pair(bool) first bool counts towards the event passing, second bool determines whether to plot the object        
132 >      typedef map<string, vector<vector<pair<bool,bool> > > > flagMap;
133 >
134 >      typedef vector<pair<bool,bool> > flagPair;
135  
136        //counterMap:
137        //string holds input collection type
# Line 131 | Line 155 | class OSUAnalysis : public edm::EDAnalyz
155        edm::InputTag photons_;
156        edm::InputTag superclusters_;
157        edm::InputTag triggers_;
158 <      std::string puFile_;
159 <      std::string deadEcalFile_;
160 <      std::string muonSFFile_;
161 <      std::string dataPU_;
162 <      std::string electronSFID_;
163 <      std::string muonSF_;
164 <      std::string dataset_;
165 <      std::string datasetType_;
158 >      edm::InputTag trigobjs_;
159 >      string puFile_;
160 >      string deadEcalFile_;
161 >      string muonSFFile_;
162 >      string dataPU_;
163 >      string electronSFID_;
164 >      string muonSF_;
165 >      string dataset_;
166 >      string datasetType_;
167        vector<edm::ParameterSet> channels_;
168        vector<edm::ParameterSet> histogramSets_;
169 +      bool useEDMFormat_;
170 +      vector<edm::ParameterSet> treeBranchSets_;  
171        bool plotAllObjectsInPassingEvents_;
172        bool doPileupReweighting_;
173 <      bool printEventInfo_;  
174 <      bool useTrackCaloRhoCorr_;  // to use the calo-based rho correction for the by-hand calculation of the track isolation energy
173 >      bool applyLeptonSF_;
174 >      bool applyBtagSF_;
175 >      int  minBtag_;
176 >      bool printEventInfo_;
177 >      bool printAllTriggers_;
178 >      bool useTrackCaloRhoCorr_;  // to use the calo-based rho correction for the by-hand calculation of the track isolation energy
179        vector<double> stopCTau_;
180 <
180 >      bool GetPlotsAfterEachCut_;
181 >      
182        struct DeadEcal {
183          double etaEcal;
184          double phiEcal;
185        };
186  
187 <      std::vector<DeadEcal> DeadEcalVec;
187 >      vector<DeadEcal> DeadEcalVec;
188  
189  
190        //Collections
191        edm::Handle<BNtriggerCollection> triggers;
192 +      edm::Handle<BNtrigobjCollection> trigobjs;
193        edm::Handle<BNjetCollection> jets;
194        edm::Handle<BNmuonCollection> muons;
195        edm::Handle<BNelectronCollection> electrons;
# Line 170 | Line 203 | class OSUAnalysis : public edm::EDAnalyz
203        edm::Handle<BNbxlumiCollection> bxlumis;
204        edm::Handle<BNphotonCollection> photons;
205        edm::Handle<BNsuperclusterCollection> superclusters;
206 <      edm::Handle<double> rhokt6CaloJetsHandle_;  
206 >      edm::Handle<BNstopCollection> stops;
207 >
208 >      edm::Handle<double> rhokt6CaloJetsHandle_;
209  
210        flagMap cumulativeFlags;
211 +      flagMap vetoFlags;
212  
213 <      vector<map<string, TH1D*> > oneDHists_;
214 <      vector<map<string, TH2D*> > twoDHists_;
213 >      vector<vector<map<string, TH1D*>>> oneDHists_;
214 >      vector<vector<map<string, TH2D*>>> twoDHists_;
215 >      vector<TTree*> BNTrees_;  // one tree per channel  
216 >      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  
217  
218        edm::Service<TFileService> fs_;
219  
# Line 186 | Line 224 | class OSUAnalysis : public edm::EDAnalyz
224          string name;
225          string title;
226          vector<double> bins;
227 +        vector<double> variableBinsX;
228 +        vector<double> variableBinsY;
229          string inputCollection;
230          vector<string> inputVariables;
231        } histogram;
232  
233 +      typedef struct {
234 +        string name;
235 +        string inputCollection;
236 +        string inputVariable;
237 +      } BranchSpecs;
238 +
239 +
240        struct cut {
241          string inputCollection;
242          vector<string> functions;
243          vector<string> variables;
244          vector<string> comparativeOperators;// >, <, =, etc.
245          vector<double> cutValues;
246 +        vector<string> cutStringValues;
247          vector<string> logicalOperators;//and, or
248 <        int numSubcuts;
248 >        int    numSubcuts;
249          int    numberRequired;
250          string eventComparativeOperator;
251          string name;
252 +        bool   isVeto;
253        };
254  
255        struct channel {
256          string name;
257          vector<string> triggers;
258 +        vector<string> triggersToVeto;
259          vector<cut> cuts;
260        };
261  
262        vector<string>  objectsToGet;
263        vector<string>  objectsToCut;
264        vector<string>  objectsToPlot;
265 +      vector<string>  objectsToFlag;
266 +
267        vector<channel> channels;
268        vector<histogram> histograms;
269 +      vector<BranchSpecs> treeBranches_;
270  
271        PUWeight *puWeight_;
272        MuonSFWeight *muonSFWeight_;
273 +      double muonScaleFactor_;
274        ElectronSFWeight *electronSFWeight_;
275 < #ifdef DISPLACED_SUSY
276 <      CTauWeight *cTauWeight_;
277 < #endif
278 <      double cTauScaleFactor_;
275 >      double electronScaleFactor_;
276 >      BtagSFWeight *bTagSFWeight_;
277 >      double bTagScaleFactor_;    
278 >
279 >      StopCTauWeight *stopCTauWeight_;
280 >      double stopCTauScaleFactor_;
281 >
282 >      ofstream* findEventsLog;
283 >      bool isFirstEvent_;  
284  
285        template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string);
286 <      template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string);
286 >      template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, flagPair, flagPair, string);
287 >
288 >      template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, flagPair flags);  
289 >      template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, flagPair, double);
290 >      template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double);
291 >      template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, flagPair, double);
292 >      template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double);
293 >      bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType);
294 >
295  
229      template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double);
230      template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
231      template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double);
232      template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double);
296  
297        template <class InputObject> int getGenMatchedParticleIndex(InputObject);
298        int getPdgIdBinValue(int);
# Line 242 | Line 305 | class OSUAnalysis : public edm::EDAnalyz
305        const BNmet *chosenMET ();
306        const BNelectron *chosenElectron ();
307        const BNmuon *chosenMuon ();
308 +      double chosenHT ();
309 +      pair<const BNmuon *, const BNmuon*> leadMuonPair ();
310 +      pair<const BNelectron *, const BNelectron*> leadElectronPair ();
311  
312    };
313  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines