forked from LLRCMS/KLUBAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOfflineProducerHelper.h
153 lines (130 loc) · 6.63 KB
/
OfflineProducerHelper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#ifndef HHKINFIT2
#define HHKINFIT2
#endif
#ifndef OfflineHelper_h
#define OfflineHelper_h
/** \class OfflineProducerHelper
*
* Collection of functions to analyze HTauTau primary trees, without CMSSW dependencies.
*
* $Date: 2012/06/06 00:27:43 $
* $Revision: 1.3 $
* \author G. Ortona - LLR
*/
#include <TString.h>
#include "TMath.h"
#include "bigTree.h"
#include "TLorentzVector.h"
#include <iostream>
#include <vector>
#include <utility>
#include <TH1F.h>
#include <tuple>
// using namespace std;
class OfflineProducerHelper {
public:
enum particleType {
MUON = 0,
ELECTRON = 1,
TAU =2
};
float m_MVAEleIDCuts[2][2][3] ;
enum pairType {
MuHad = 0,
EHad = 1,
HadHad = 2,
MuMu = 3,
EE = 4,
EMu = 5,
EEPrompt = 6, // prompt Z->ee/mumu decays
MuMuPrompt = 7,
Other = 8 // for e.g. h->bb
};
enum eleMVAIDWP {
EMVATight = 0, // 80% eff
EMVALoose = 1 // 90% eff
};
enum muIDWP {
MuLoose = 0,
MuSoft = 1,
MuMedium = 2,
MuTight = 3,
MuHighPt = 4
};
enum aeleWP {
aeleVLoose = 0,
aeleLoose = 1,
aeleMedium = 2,
aeleTight = 3,
aeleVTight = 4
};
enum amuWP {
amuLoose = 0,
amuTight = 1
};
OfflineProducerHelper();
OfflineProducerHelper(TH1F* hCounter, TH1F *htauids);
OfflineProducerHelper(TH1F* hCounter);
void SetEleMVAIDCuts();
int FindTriggerNumber(TString triggername);
bool IsTriggerFired(int triggerbit, int triggerNumber);
bool IsTriggerFired(int triggerbit, TString triggerName){return IsTriggerFired(triggerbit, FindTriggerNumber(triggerName));}
int printFiredPaths(int);
bool isMuon(int type){if(type == MUON)return true; else return false;}
bool isElectron(int type){if(type == ELECTRON)return true; else return false;}
bool isTau(int type){if(type == TAU)return true; else return false;}
int getPairType (int type1, int type2); // return pair type giving as input the particle types of the two composants
bool checkBit (int word, int bitpos); // check bit "bitpos" in a word
int getTAUidNumber(TString tauIDname);
// whatApply: use "OSCharge" (appplies on pairs only)
// whatApply: use "All", "Iso", "pTMin", "etaMax", "againstEle", "againstMu", "Vertex"; separate various arguments with a semicolon
// is contains "All" it will override all the other settings; additional parameters are not considered (have no effect)
// a selection is applied by default if no parameter is specified
bool checkPassBaseline (bigTree* tree, int iPair, TString whatApply = "All"){return pairPassBaseline(tree,iPair,whatApply,true);}
bool pairPassBaseline (bigTree* tree, int iPair, TString whatApply = "All", bool debug=false);
bool eleBaseline (bigTree* tree, int iDau, float ptMin, float relIso, int MVAIDflag = 0, TString whatApply = "All", bool debug=false); // return true if leptons passes the baseline selections
bool eleBaseline (bigTree* tree, int iDau, float ptMin, float etaMax, float relIso, int MVAIDflag = 0, TString whatApply = "All", bool debug=false); // version with eta cut
bool muBaseline (bigTree* tree, int iDau, float ptMin, float etaMax, float relIso, int muIDWP, TString whatApply = "All", bool debug=false);
bool tauBaseline (bigTree* tree, int iDau, float ptMin, float etaMax, int againstEleWP, int againstMuWP, float isoRaw3Hits, TString whatApply = "All",bool debug=false);
bool tightEleMVAID (float BDT, float fSCeta); // compute tight ele MVA id WP, but isBDT in ntuples has been fixed --> this will be soon deprecated
int getMothPairType (bigTree* tree, int iMoth); // return the pair type of a given pair in the tree
// approx!! I call it using lepton eta and not superCluster eta
bool EleMVAID (float BDT, float eta, float pT, int strength) ;
// bool jetPassPuID (bigTree* tree, int ijet);
/*
// separate check of various requirements applied in baseline
bool combRelIso (bigTree* tree, int iDau, float iso); // for mu, ele
bool combIsodBetaRaw3Hits (bigTree* tree, int iDau, float iso); // for tau
bool passEleID (bigTree* tree, int iDau); // tight ele ID
bool passMuID (bigTree* tree, int iDau); // medium mu ID
bool passTauID (bigTree* tree, int iDau); // tau pog ID (decay Mode Finding OLD || NEW)
bool passTauAntiEle (bigTree* tree, int iDau, int againstEleWP);
bool passTauAntiMu (bigTree* tree, int iDau, int againstMuWP);
*/
TLorentzVector buildDauP4 (bigTree* tree, int iDau); // build daughter 4 vector
TLorentzVector buildMothP4 (bigTree* tree, int iMoth); // build pair 4 vector
TLorentzVector buildGenP4 (bigTree* tree, int iGen); // build pair 4 vector
bool getBestJets (bigTree* tree, int& jet1, int& jet2, int strategy); // select jets, possibly two b jets, returns true if found, else false
int getBestPair (bigTree* tree, std::vector<int>& pairIdxs, TString strategy = "OSMaxPt"); // from a vector of indexes to pairs in the evemt retutn index to the one chose by a stategy
int getBestPair (bigTree* tree, TString strategy = "OSMaxPt"); // calls the previous on the whole pair collection of the event
int getPairByIndexes (bigTree* tree, int dau1, int dau2); // knowing the sons, get the pair formed
typedef std::tuple <float, float, int, float, float, int, int> tauPair_t; // pt1 - iso1 - idx1 - pt2 - iso2 - idx2 - idxoriginalPair
int getBestPairHTauTau (bigTree* tree, TString whatApply = "All", bool debug = false); // returns best pair formed by idx1, idx2, using HTauTau strategy - for studies
int getBestPairPtAndRawIsoOrd (bigTree* tree, TString whatApply = "All", bool debug = false); // returns best pair formed by idx1, idx2, sorting them by pt in each pair, then by raw iso
static bool pairSort (const tauPair_t& pA, const tauPair_t& pB);
static bool pairSortRawIso (const tauPair_t& pA, const tauPair_t& pB);
float DeltaRDau(bigTree* tree, int dau1idx, int dau2idx);
// --------------------------------
// gen related functions
// --------------------------------
int MCHiggsTauTauDecayMode (bigTree* tree); // find the MC decay of the Higgs to tau in the event
bool getHardTauFinalVisGenProducts (bigTree* tree, int& ind1, int& ind2); // find hard scatter tau decay products and store their indices; return false if problems, else true
bool drMatchGenReco (bigTree* tree, int iGen, int iReco, float dRcone = 0.5);
int getRecoMatchedToGen (bigTree* tree, int iGen, bool checkId = true, bool checkCharge = false, float dRcone = 0.5);
// std::pair<int, int> getHardScatterSonsIdx(bigTree* tree, int iGenH);
~OfflineProducerHelper(){}
private:
std::vector<TString> triggerlist;
std::vector<TString> tauidlist;
};
#endif