ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/SelMods/src/HwwExampleAnalysisMod.cc
Revision: 1.20
Committed: Thu Oct 20 19:21:56 2011 UTC (13 years, 6 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025c, Mit_025b, Mit_025a
Changes since 1.19: +26 -4 lines
Log Message:
new

File Contents

# User Rev Content
1 ceballos 1.1 // $Id $
2    
3     #include "MitPhysics/SelMods/interface/HwwExampleAnalysisMod.h"
4     #include <TH1D.h>
5     #include <TH2D.h>
6     #include <TParameter.h>
7     #include "MitAna/DataUtil/interface/Debug.h"
8     #include "MitAna/DataTree/interface/Names.h"
9     #include "MitPhysics/Init/interface/ModNames.h"
10     #include "MitAna/DataCont/interface/ObjArray.h"
11     #include "MitCommon/MathTools/interface/MathUtils.h"
12 ceballos 1.18 #include "MitPhysics/Utils/interface/JetTools.h"
13 ceballos 1.14 #include "MitPhysics/Utils/interface/MetTools.h"
14 ceballos 1.1 #include "MitAna/DataTree/interface/ParticleCol.h"
15     #include "TFile.h"
16     #include "TTree.h"
17    
18     using namespace mithep;
19     ClassImp(mithep::HwwExampleAnalysisMod)
20    
21     //--------------------------------------------------------------------------------------------------
22     HwwExampleAnalysisMod::HwwExampleAnalysisMod(const char *name, const char *title) :
23     BaseMod(name,title),
24     fMuonBranchName(Names::gkMuonBrn),
25     fMetName("NoDefaultNameSet"),
26     fCleanJetsName("NoDefaultNameSet"),
27 ceballos 1.6 fCleanJetsNoPtCutName("NoDefaultNameSet"),
28 ceballos 1.5 fVertexName(ModNames::gkGoodVertexesName),
29 ceballos 1.14 fPFCandidatesName(Names::gkPFCandidatesBrn),
30 ceballos 1.1 fMuons(0),
31     fMet(0),
32 ceballos 1.6 fVertices(0),
33 ceballos 1.14 fPFCandidates(0),
34 ceballos 1.20 fPFJetName0("AKt5PFJets"),
35     fPFJet0(0),
36 ceballos 1.13 fNEventsSelected(0)
37 ceballos 1.1 {
38     // Constructor.
39     }
40    
41     //--------------------------------------------------------------------------------------------------
42     void HwwExampleAnalysisMod::Begin()
43     {
44     // Run startup code on the client machine. For this module, we dont do
45     // anything here.
46     }
47    
48     //--------------------------------------------------------------------------------------------------
49     void HwwExampleAnalysisMod::SlaveBegin()
50     {
51     // Run startup code on the computer (slave) doing the actual analysis. Here,
52     // we typically initialize histograms and other analysis objects and request
53     // branches. For this module, we request a branch of the MitTree.
54    
55     // Load Branches
56 ceballos 1.14 ReqBranch(fMuonBranchName, fMuons);
57     ReqBranch(fPFCandidatesName, fPFCandidates);
58 ceballos 1.20 ReqBranch(fPFJetName0, fPFJet0);
59 ceballos 1.1
60     //Create your histograms here
61    
62     //*************************************************************************************************
63     // Selection Histograms
64     //*************************************************************************************************
65 ceballos 1.18 AddTH1(fHWWSelection,"hHWWSelection", ";Cut Number;Number of Events", 16, -1.5, 14.5);
66     AddTH1(fHWWToEESelection,"hHWWToEESelection", ";Cut Number;Number of Events", 16, -1.5, 14.5);
67     AddTH1(fHWWToMuMuSelection,"hHWWToMuMuSelection", ";Cut Number;Number of Events", 16, -1.5, 14.5);
68     AddTH1(fHWWToEMuSelection,"hHWWToEMuSelection", ";Cut Number;Number of Events", 16, -1.5, 14.5);
69 ceballos 1.19 AddTH1(fHWWToMuESelection,"hHWWToMuESelection", ";Cut Number;Number of Events", 16, -1.5, 14.5);
70 ceballos 1.1
71     //***********************************************************************************************
72     // Histograms after preselection
73     //***********************************************************************************************
74     AddTH1(fLeptonEta ,"hLeptonEta",";LeptonEta;Number of Events",100,-5.,5.0);
75     AddTH1(fLeptonPtMax ,"hLeptonPtMax",";Lepton P_t Max;Number of Events",150,0.,150.);
76     AddTH1(fLeptonPtMin ,"hLeptonPtMin",";Lepton P_t Min;Number of Events",150,0.,150.);
77     AddTH1(fMetPtHist ,"hMetPtHist",";Met;Number of Events",150,0.,300.);
78     AddTH1(fMetPhiHist ,"hMetPhiHist",";#phi;Number of Events",28,-3.5,3.5);
79     AddTH1(fUncorrMetPtHist ,"hUncorrMetPtHist",";Met;Number of Events",150,0.,300.);
80     AddTH1(fUncorrMetPhiHist ,"hUncorrMetPhiHist",";#phi;Number of Events",28,-3.5,3.5);
81     AddTH1(fDeltaPhiLeptons ,"hDeltaPhiLeptons",";#Delta#phi_{ll};Number of Events",90,0,180);
82 ceballos 1.8 AddTH1(fDeltaEtaLeptons ,"hDeltaEtaLeptons",";#Delta#eta_{ll};Number of Events",100,-5.,5.0);
83 ceballos 1.1 AddTH1(fDileptonMass ,"hDileptonMass",";Mass_{ll};Number of Events",150,0.,300.);
84    
85     //***********************************************************************************************
86     // N-1 Histograms
87     //***********************************************************************************************
88     //All events
89     AddTH1(fLeptonPtMax_NMinusOne ,"hLeptonPtMax_NMinusOne",
90     ";Lepton P_t Max;Number of Events",150,0.,150.);
91     AddTH1(fLeptonPtMin_NMinusOne ,"hLeptonPtMin_NMinusOne",
92     ";Lepton P_t Min;Number of Events",150,0.,150.);
93     AddTH1(fMetPtHist_NMinusOne ,"hMetPtHist_NMinusOne",
94     ";Met;Number of Events",150,0.,300.);
95     AddTH1(fMetPhiHist_NMinusOne ,"hMetPhiHist_NMinusOne",
96     ";#phi;Number of Events",28,-3.5,3.5);
97     AddTH1(fMETdeltaPhilEtHist_NMinusOne ,"hMETdeltaPhilEtHist_NMinusOne",
98     ";METdeltaPhilEtHist;Number of Events",150,0.,300.);
99     AddTH1(fNCentralJets_NMinusOne ,"hNCentralJets_NMinusOne",
100     ";Number of Central Jets;Number of Events",6,-0.5,5.5);
101     AddTH1(fNSoftMuonsHist_NMinusOne ,"hNSoftMuonsHist_NMinusOne",
102     ";Number of Dirty Muons; Number of Events",6,-0.5,5.5);
103     AddTH1(fDeltaPhiLeptons_NMinusOne ,"hDeltaPhiLeptons_NMinusOne",
104     ";#Delta#phi_{ll};Number of Events",90,0,180);
105     AddTH1(fDeltaEtaLeptons_NMinusOne ,"hDeltaEtaLeptons_NMinusOne",
106     ";#Delta#eta_{ll};Number of Events",100,-5.0,5.0);
107     AddTH1(fDileptonMass_NMinusOne ,"hDileptonMass_NMinusOne",
108     ";Mass_{ll};Number of Events",150,0.,300.);
109     AddTH1(fMinDeltaPhiLeptonMet_NMinusOne ,"hMinDeltaPhiLeptonMet_NMinusOne",
110     ";Min #Delta#phi_{l,Met};Number of Events",90,0.,180);
111    
112     //***********************************************************************************************
113     // After all cuts Histograms
114     //***********************************************************************************************
115     AddTH1(fMinDeltaPhiLeptonMet_afterCuts ,"hMinDeltaPhiLeptonMet_afterCuts",
116     ";Min #Delta#phi_{l,Met};Number of Events",90,0.,180);
117     AddTH1(fMtLepton1_afterCuts ,"hMtLepton1_afterCuts",
118     ";M_t (Lepton1,Met);Number of Events",100,0.,200.);
119     AddTH1(fMtLepton2_afterCuts ,"hMtLepton2_afterCuts",
120     ";M_t (Lepton2,Met);Number of Events",100,0.,200.);
121     AddTH1(fMtHiggs_afterCuts ,"hMtHiggs_afterCuts",
122     ";M_t (l1+l2+Met);Number of Events",150,0.,300.);
123     AddTH1(fLeptonPtPlusMet_afterCuts ,"hLeptonPtPlusMet_afterCuts",
124     ";LeptonPtPlusMet;Number of Events",150,0., 300.);
125    
126     }
127    
128     //--------------------------------------------------------------------------------------------------
129     void HwwExampleAnalysisMod::Process()
130     {
131     // Process entries of the tree. For this module, we just load the branches and
132     LoadBranch(fMuonBranchName);
133 ceballos 1.14 LoadBranch(fPFCandidatesName);
134 ceballos 1.20 LoadBranch(fPFJetName0);
135 ceballos 1.14
136 ceballos 1.1 //Obtain all the good objects from the event cleaning module
137 ceballos 1.5 fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
138 ceballos 1.1 ObjArray<Muon> *CleanMuons = dynamic_cast<ObjArray<Muon>* >(FindObjThisEvt(ModNames::gkCleanMuonsName));
139 ceballos 1.6 ObjArray<Electron> *CleanElectrons = dynamic_cast<ObjArray<Electron>* >(FindObjThisEvt(ModNames::gkCleanElectronsName));
140 ceballos 1.1 ParticleOArr *CleanLeptons = dynamic_cast<mithep::ParticleOArr*>
141     (FindObjThisEvt(ModNames::gkMergedLeptonsName));
142     ObjArray<Jet> *CleanJets = dynamic_cast<ObjArray<Jet>* >
143     (FindObjThisEvt(fCleanJetsName.Data()));
144 ceballos 1.6 ObjArray<Jet> *CleanJetsNoPtCut = dynamic_cast<ObjArray<Jet>* >
145     (FindObjThisEvt(fCleanJetsNoPtCutName.Data()));
146 ceballos 1.2 TParameter<Double_t> *NNLOWeight = GetObjThisEvt<TParameter<Double_t> >("NNLOWeight");
147 ceballos 1.1
148     MetCol *met = dynamic_cast<ObjArray<Met>* >(FindObjThisEvt(fMetName));
149 ceballos 1.14 const Met *stdMet = 0;
150 ceballos 1.1 if (met) {
151 ceballos 1.14 stdMet = met->At(0);
152 ceballos 1.1 } else {
153     cout << "Error: Met Collection " << fMetName << " could not be loaded.\n";
154     return;
155     }
156    
157     //***********************************************************************************************
158     //Kinematic PreSelection
159     //***********************************************************************************************
160     // At least two leptons in the event
161     if (CleanLeptons->GetEntries() < 2) return;
162     // Pt1 > 20 && Pt2 > 10
163 ceballos 1.4 if(CleanLeptons->At(0)->Pt() <= 20 || CleanLeptons->At(1)->Pt() <= 10) return;
164 ceballos 1.1 // opposite charge leptons
165     if(CleanLeptons->At(0)->Charge() * CleanLeptons->At(1)->Charge() > 0) return;
166    
167     CompositeParticle *dilepton = new CompositeParticle();
168     dilepton->AddDaughter(CleanLeptons->At(0));
169     dilepton->AddDaughter(CleanLeptons->At(1));
170    
171     //***********************************************************************************************
172     //Get Dirty Muons: Non-isolated Muons (exclude the clean muons)
173     //***********************************************************************************************
174     ObjArray<Muon> *SoftMuons = new ObjArray<Muon>;
175     for (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
176     const Muon *mu = fMuons->At(i);
177 ceballos 1.20 if(!MuonTools::PassSoftMuonCut(mu, fVertices, 0.2)) continue;
178 ceballos 1.1
179     bool isCleanMuon = kFALSE;
180     for (UInt_t j=0; j<CleanMuons->GetEntries(); j++) {
181     if(fMuons->At(i) == CleanMuons->At(j) &&
182     CleanMuons->At(j)->Pt() > 10) isCleanMuon = kTRUE;
183     }
184     if(isCleanMuon == kFALSE) SoftMuons->Add(mu);
185     }
186    
187     //***********************************************************************************************
188 ceballos 1.6 //|Z_vert-Z_l| maximum
189     //***********************************************************************************************
190 ceballos 1.14 std::vector<double> leptonsDz;
191 ceballos 1.6 double zDiffMax = 0.0;
192     if(fVertices->GetEntries() > 0) {
193     for (UInt_t j=0; j<CleanMuons->GetEntries(); j++) {
194 ceballos 1.14 double pDz = CleanMuons->At(j)->BestTrk()->DzCorrected(*fVertices->At(0));
195     leptonsDz.push_back(pDz);
196 ceballos 1.6 }
197     for (UInt_t j=0; j<CleanElectrons->GetEntries(); j++) {
198 ceballos 1.14 double pDz = CleanElectrons->At(j)->GsfTrk()->DzCorrected(*fVertices->At(0));
199     leptonsDz.push_back(pDz);
200     }
201     for(UInt_t t=0; t<leptonsDz.size(); t++) {
202     for(UInt_t i=t+1; i<leptonsDz.size(); i++) {
203     if(TMath::Abs(leptonsDz[t]-leptonsDz[i]) > zDiffMax) zDiffMax = TMath::Abs(leptonsDz[t]-leptonsDz[i]);
204 ceballos 1.7 }
205 ceballos 1.6 }
206 ceballos 1.14 leptonsDz.clear();
207 ceballos 1.6 }
208    
209     //***********************************************************************************************
210 ceballos 1.1 //Define Event Variables
211     //***********************************************************************************************
212     //delta phi between the 2 leptons in degrees
213     double deltaPhiLeptons = MathUtils::DeltaPhi(CleanLeptons->At(0)->Phi(),
214     CleanLeptons->At(1)->Phi())* 180.0 / TMath::Pi();
215    
216 ceballos 1.8 double deltaEtaLeptons = CleanLeptons->At(0)->Eta() - CleanLeptons->At(1)->Eta();
217 ceballos 1.1
218 ceballos 1.14 double deltaPhiDileptonMet = MathUtils::DeltaPhi(stdMet->Phi(),
219 ceballos 1.1 dilepton->Phi())*180.0 / TMath::Pi();
220    
221 ceballos 1.14 double mtHiggs = TMath::Sqrt(2.0*dilepton->Pt() * stdMet->Pt()*
222 ceballos 1.1 (1.0 - cos(deltaPhiDileptonMet * TMath::Pi() / 180.0)));
223    
224     //angle between MET and closest lepton
225 ceballos 1.14 double deltaPhiMetLepton[2] = {MathUtils::DeltaPhi(stdMet->Phi(), CleanLeptons->At(0)->Phi()),
226     MathUtils::DeltaPhi(stdMet->Phi(), CleanLeptons->At(1)->Phi())};
227 ceballos 1.1
228 ceballos 1.14 double mTW[2] = {TMath::Sqrt(2.0*CleanLeptons->At(0)->Pt()*stdMet->Pt()*
229 ceballos 1.1 (1.0 - cos(deltaPhiMetLepton[0]))),
230 ceballos 1.14 TMath::Sqrt(2.0*CleanLeptons->At(1)->Pt()*stdMet->Pt()*
231 ceballos 1.1 (1.0 - cos(deltaPhiMetLepton[1])))};
232    
233     double minDeltaPhiMetLepton = (deltaPhiMetLepton[0] < deltaPhiMetLepton[1])?
234     deltaPhiMetLepton[0]:deltaPhiMetLepton[1];
235    
236 ceballos 1.16 MetTools metTools(CleanMuons, CleanElectrons, fPFCandidates, fVertices->At(0), 0.1, 8.0, 5.0);
237 ceballos 1.14 double pMET[2] = {metTools.GetProjectedMet(CleanLeptons,stdMet),
238     metTools.GetProjectedTrackMet(CleanLeptons)};
239    
240     double METdeltaPhilEt = TMath::Min(pMET[0],pMET[1]);
241 ceballos 1.1
242 ceballos 1.6 //count the number of central Jets for vetoing and b-tagging
243     vector<Jet*> sortedJetsAll;
244     vector<Jet*> sortedJets;
245     vector<Jet*> sortedJetsLowPt;
246     for(UInt_t i=0; i<CleanJetsNoPtCut->GetEntries(); i++){
247 ceballos 1.17 if(CleanJetsNoPtCut->At(i)->RawMom().Pt() <= 7) continue;
248 ceballos 1.6 Jet* jet_a = new Jet(CleanJetsNoPtCut->At(i)->Px(),
249     CleanJetsNoPtCut->At(i)->Py(),
250     CleanJetsNoPtCut->At(i)->Pz(),
251     CleanJetsNoPtCut->At(i)->E() );
252 ceballos 1.14 jet_a->SetMatchedMCFlavor(CleanJetsNoPtCut->At(i)->MatchedMCFlavor());
253     jet_a->SetCombinedSecondaryVertexBJetTagsDisc(CleanJetsNoPtCut->At(i)->CombinedSecondaryVertexBJetTagsDisc());
254     jet_a->SetCombinedSecondaryVertexMVABJetTagsDisc(CleanJetsNoPtCut->At(i)->CombinedSecondaryVertexMVABJetTagsDisc());
255     jet_a->SetJetProbabilityBJetTagsDisc(CleanJetsNoPtCut->At(i)->JetProbabilityBJetTagsDisc());
256     jet_a->SetJetBProbabilityBJetTagsDisc(CleanJetsNoPtCut->At(i)->JetBProbabilityBJetTagsDisc());
257     jet_a->SetTrackCountingHighEffBJetTagsDisc(CleanJetsNoPtCut->At(i)->TrackCountingHighEffBJetTagsDisc());
258     jet_a->SetTrackCountingHighPurBJetTagsDisc(CleanJetsNoPtCut->At(i)->TrackCountingHighPurBJetTagsDisc());
259     jet_a->SetSimpleSecondaryVertexBJetTagsDisc(CleanJetsNoPtCut->At(i)->SimpleSecondaryVertexBJetTagsDisc());
260     jet_a->SetSimpleSecondaryVertexHighEffBJetTagsDisc(CleanJetsNoPtCut->At(i)->SimpleSecondaryVertexHighEffBJetTagsDisc());
261     jet_a->SetSimpleSecondaryVertexHighPurBJetTagsDisc(CleanJetsNoPtCut->At(i)->SimpleSecondaryVertexHighPurBJetTagsDisc());
262 ceballos 1.6 sortedJetsAll.push_back(jet_a);
263     }
264    
265 ceballos 1.1 for(UInt_t i=0; i<CleanJets->GetEntries(); i++){
266 ceballos 1.9 if(TMath::Abs(CleanJets->At(i)->Eta()) < 5.0 &&
267 ceballos 1.14 CleanJets->At(i)->Pt() > 30.0){
268 ceballos 1.6 Jet* jet_b = new Jet(CleanJets->At(i)->Px(),
269     CleanJets->At(i)->Py(),
270     CleanJets->At(i)->Pz(),
271     CleanJets->At(i)->E() );
272     sortedJets.push_back(jet_b);
273     }
274     }
275    
276     for(UInt_t i=0; i<sortedJetsAll.size(); i++){
277     bool overlap = kFALSE;
278     for(UInt_t j=0; j<sortedJets.size(); j++){
279     if(sortedJetsAll[i]->Pt() == sortedJets[j]->Pt() ||
280     (sortedJetsAll[i]->CombinedSecondaryVertexBJetTagsDisc() == sortedJets[j]->CombinedSecondaryVertexBJetTagsDisc() &&
281     sortedJetsAll[i]->JetBProbabilityBJetTagsDisc() == sortedJets[j]->JetBProbabilityBJetTagsDisc() &&
282     sortedJetsAll[i]->TrackCountingHighPurBJetTagsDisc() == sortedJets[j]->TrackCountingHighPurBJetTagsDisc())
283     ) {
284     sortedJets[j]->SetMatchedMCFlavor(sortedJetsAll[i]->MatchedMCFlavor());
285     sortedJets[j]->SetCombinedSecondaryVertexBJetTagsDisc(sortedJetsAll[i]->CombinedSecondaryVertexBJetTagsDisc());
286     sortedJets[j]->SetCombinedSecondaryVertexMVABJetTagsDisc(sortedJetsAll[i]->CombinedSecondaryVertexMVABJetTagsDisc());
287     sortedJets[j]->SetJetProbabilityBJetTagsDisc(sortedJetsAll[i]->JetProbabilityBJetTagsDisc());
288     sortedJets[j]->SetJetBProbabilityBJetTagsDisc(sortedJetsAll[i]->JetBProbabilityBJetTagsDisc());
289     sortedJets[j]->SetTrackCountingHighEffBJetTagsDisc(sortedJetsAll[i]->TrackCountingHighEffBJetTagsDisc());
290     sortedJets[j]->SetTrackCountingHighPurBJetTagsDisc(sortedJetsAll[i]->TrackCountingHighPurBJetTagsDisc());
291     sortedJets[j]->SetSimpleSecondaryVertexBJetTagsDisc(sortedJetsAll[i]->SimpleSecondaryVertexBJetTagsDisc());
292     sortedJets[j]->SetSimpleSecondaryVertexHighEffBJetTagsDisc(sortedJetsAll[i]->SimpleSecondaryVertexHighEffBJetTagsDisc());
293     sortedJets[j]->SetSimpleSecondaryVertexHighPurBJetTagsDisc(sortedJetsAll[i]->SimpleSecondaryVertexHighPurBJetTagsDisc());
294     overlap = kTRUE;
295     break;
296     }
297     }
298     if(overlap == kFALSE){
299     sortedJetsLowPt.push_back(sortedJetsAll[i]);
300     }
301     }
302     double maxBtag = -99999.;
303     for(UInt_t i=0; i<sortedJetsLowPt.size(); i++){
304     if(sortedJetsLowPt[i]->TrackCountingHighEffBJetTagsDisc() > maxBtag){
305 ceballos 1.20 double dZAverageJetPt = 0.0;
306     double sumJetPt = 0.0;
307     double jetPt = 0.0;
308     for(UInt_t iPF=0; iPF<fPFJet0->GetEntries(); iPF++){
309     const PFJet *jet = fPFJet0->At(iPF);
310     if(MathUtils::DeltaR(jet->Mom(),sortedJetsLowPt[i]->Mom()) < 0.01){
311     jetPt = jet->Pt();
312     for (UInt_t npf=0; npf<jet->NPFCands();npf++) {
313     const PFCandidate *pf = jet->PFCand(npf);
314     if(pf->BestTrk()) {
315     dZAverageJetPt = dZAverageJetPt + pf->Pt()*pf->Pt()*pf->BestTrk()->DzCorrected(*fVertices->At(0));
316     sumJetPt = sumJetPt + pf->Pt()*pf->Pt();
317     }
318     }
319     if(sumJetPt > 0) dZAverageJetPt = TMath::Abs(dZAverageJetPt)/sumJetPt;
320     break;
321     }
322     } // loop over PF jets
323     if(dZAverageJetPt < 2.0 && jetPt > 10){
324     maxBtag = sortedJetsLowPt[i]->TrackCountingHighEffBJetTagsDisc();
325     }
326 ceballos 1.1 }
327     }
328    
329     //Lepton Type
330     int finalstateType = -1;
331     if (CleanLeptons->At(0)->ObjType() == kMuon && CleanLeptons->At(1)->ObjType() == kMuon ){ // mumu
332     finalstateType = 10;
333     } else if(CleanLeptons->At(0)->ObjType() == kElectron && CleanLeptons->At(1)->ObjType() == kElectron ){ // ee
334     finalstateType = 11;
335 ceballos 1.19 } else if(CleanLeptons->At(0)->ObjType() == kElectron && CleanLeptons->At(1)->ObjType() == kMuon) {
336 ceballos 1.1 finalstateType = 12;
337 ceballos 1.19 } else if(CleanLeptons->At(1)->ObjType() == kElectron && CleanLeptons->At(0)->ObjType() == kMuon) {
338     finalstateType = 13;
339 ceballos 1.1 } else {
340     cerr << "Error: finalstate lepton type not supported\n";
341     }
342    
343 ceballos 1.18 double deltaPhiLLJet = 0.0;
344     if(sortedJetsAll.size() > 0 && sortedJetsAll[0]->Pt() > 15.0 && (finalstateType == 10 || finalstateType == 11)){
345     deltaPhiLLJet = MathUtils::DeltaPhi(dilepton->Phi(), sortedJetsAll[0]->Phi())*180.0/TMath::Pi();
346     }
347    
348 ceballos 1.1 //*********************************************************************************************
349     //Define Cuts
350     //*********************************************************************************************
351 ceballos 1.18 const int nCuts = 15;
352 ceballos 1.7 bool passCut[nCuts] = {false, false, false, false, false,
353 ceballos 1.18 false, false, false, false, false,
354     false, false, false, false, false};
355 ceballos 1.1
356 ceballos 1.14 Bool_t PreselPtCut = kTRUE;
357     if(CleanLeptons->At(0)->Pt() <= 20) PreselPtCut = kFALSE;
358     if(CleanLeptons->At(1)->Pt() <= 10) PreselPtCut = kFALSE;
359 ceballos 1.17 //if(CleanLeptons->At(1)->ObjType() == kElectron && CleanLeptons->At(1)->Pt() <= 15) PreselPtCut = kFALSE;
360 ceballos 1.14 if(PreselPtCut == kTRUE) passCut[0] = true;
361 ceballos 1.1
362 ceballos 1.18 if(stdMet->Pt() > 20.0) passCut[1] = true;
363 ceballos 1.1
364 ceballos 1.18 if(dilepton->Mass() > 12.0) passCut[2] = true;
365 ceballos 1.1
366 ceballos 1.18 if(sortedJets.size() < 1) passCut[5] = true;
367    
368     if(deltaPhiLLJet < 165.0) passCut[6] = true;
369 ceballos 1.7
370     if(SoftMuons->GetEntries() == 0) passCut[7] = true;
371 ceballos 1.6
372 ceballos 1.7 if(CleanLeptons->GetEntries() == 2) passCut[8] = true;
373 ceballos 1.1
374 ceballos 1.7 if(maxBtag < 2.1) passCut[9] = true;
375 ceballos 1.1
376     if (finalstateType == 10 || finalstateType == 11){ // mumu/ee
377 ceballos 1.18 if(fabs(dilepton->Mass()-91.1876) > 15.0) passCut[3] = true;
378     if(METdeltaPhilEt > 40) passCut[4] = true;
379 ceballos 1.1 }
380 ceballos 1.19 else { // mue/emu
381 ceballos 1.18 passCut[3] = true;
382     if(METdeltaPhilEt > 20) passCut[4] = true;
383 ceballos 1.1 }
384 ceballos 1.13
385 ceballos 1.18 if(CleanLeptons->At(0)->Pt() > 30) passCut[10] = true;
386    
387     if(CleanLeptons->At(1)->Pt() > 25) passCut[11] = true;
388    
389     if(dilepton->Mass() < 50) passCut[12] = true;
390    
391     if(mtHiggs > 90.0 && mtHiggs < 160.0) passCut[13] = true;
392    
393     if(deltaPhiLeptons < 60.0) passCut[14] = true;
394    
395 ceballos 1.1 //*********************************************************************************************
396     //Make Selection Histograms. Number of events passing each level of cut
397     //*********************************************************************************************
398     bool passAllCuts = true;
399     for(int c=0; c<nCuts; c++) passAllCuts = passAllCuts & passCut[c];
400 ceballos 1.13 if(passAllCuts) fNEventsSelected++;
401    
402 ceballos 1.1 //Cut Selection Histograms
403 ceballos 1.2 fHWWSelection->Fill(-1,NNLOWeight->GetVal());
404 ceballos 1.1 if (finalstateType == 10 )
405 ceballos 1.2 fHWWToMuMuSelection->Fill(-1,NNLOWeight->GetVal());
406 ceballos 1.1 else if(finalstateType == 11 )
407 ceballos 1.2 fHWWToEESelection->Fill(-1,NNLOWeight->GetVal());
408 ceballos 1.1 else if(finalstateType == 12 )
409 ceballos 1.2 fHWWToEMuSelection->Fill(-1,NNLOWeight->GetVal());
410 ceballos 1.19 else if(finalstateType == 13 )
411     fHWWToMuESelection->Fill(-1,NNLOWeight->GetVal());
412 ceballos 1.1
413     for (int k=0;k<nCuts;k++) {
414     bool pass = true;
415     bool passPreviousCut = true;
416     for (int p=0;p<=k;p++) {
417     pass = (pass && passCut[p]);
418     if (p<k)
419     passPreviousCut = (passPreviousCut&& passCut[p]);
420     }
421    
422     if (pass) {
423 ceballos 1.2 fHWWSelection->Fill(k,NNLOWeight->GetVal());
424 ceballos 1.1 if (finalstateType == 10 )
425 ceballos 1.2 fHWWToMuMuSelection->Fill(k,NNLOWeight->GetVal());
426 ceballos 1.1 else if(finalstateType == 11)
427 ceballos 1.2 fHWWToEESelection->Fill(k,NNLOWeight->GetVal());
428 ceballos 1.1 else if(finalstateType == 12)
429 ceballos 1.2 fHWWToEMuSelection->Fill(k,NNLOWeight->GetVal());
430 ceballos 1.19 else if(finalstateType == 13)
431     fHWWToMuESelection->Fill(k,NNLOWeight->GetVal());
432 ceballos 1.1 }
433     }
434    
435     //*****************************************************************************************
436     //Make Preselection Histograms
437     //*****************************************************************************************
438 ceballos 1.2 fLeptonEta->Fill(CleanLeptons->At(0)->Eta(),NNLOWeight->GetVal());
439     fLeptonEta->Fill(CleanLeptons->At(1)->Eta(),NNLOWeight->GetVal());
440     fLeptonPtMax->Fill(CleanLeptons->At(0)->Pt(),NNLOWeight->GetVal());
441     fLeptonPtMin->Fill(CleanLeptons->At(1)->Pt(),NNLOWeight->GetVal());
442 ceballos 1.14 fMetPtHist->Fill(stdMet->Pt(),NNLOWeight->GetVal());
443     fMetPhiHist->Fill(stdMet->Phi(),NNLOWeight->GetVal());
444 ceballos 1.2 fDeltaPhiLeptons->Fill(deltaPhiLeptons,NNLOWeight->GetVal());
445     fDeltaEtaLeptons->Fill(deltaEtaLeptons,NNLOWeight->GetVal());
446     fDileptonMass->Fill(dilepton->Mass(),NNLOWeight->GetVal());
447 ceballos 1.1
448     //*********************************************************************************************
449     // N-1 Histograms
450     //*********************************************************************************************
451     bool pass;;
452    
453     //N Jet Veto
454     pass = true;
455     for (int k=0;k<nCuts;k++) {
456 ceballos 1.18 if (k != 5) pass = (pass && passCut[k]);
457 ceballos 1.1 }
458     if (pass) {
459 ceballos 1.6 fNCentralJets_NMinusOne->Fill(sortedJets.size(),NNLOWeight->GetVal());
460 ceballos 1.1 }
461    
462     // Final Met Cut
463     pass = true;
464     for (int k=0;k<nCuts;k++) {
465 ceballos 1.18 if (k != 4) pass = (pass && passCut[k]);
466 ceballos 1.1 }
467     if (pass) {
468 ceballos 1.14 fMetPtHist_NMinusOne->Fill(stdMet->Pt(),NNLOWeight->GetVal());
469 ceballos 1.1 }
470    
471     // dilepton mass
472     pass = true;
473     for (int k=0;k<nCuts;k++) {
474 ceballos 1.18 if (k != 2 && k != 3) pass = (pass && passCut[k]);
475 ceballos 1.1 }
476     if (pass) {
477 ceballos 1.2 fDileptonMass_NMinusOne->Fill(dilepton->Mass(),NNLOWeight->GetVal());
478 ceballos 1.1 }
479    
480     // Lepton Pt Max, Lepton Pt Min, DeltaPhiLeptons
481     pass = true;
482     for (int k=0;k<nCuts;k++) {
483 ceballos 1.12 if (k != 0)
484     pass = (pass && passCut[k]);
485 ceballos 1.1 }
486     if (pass) {
487 ceballos 1.2 fLeptonPtMax_NMinusOne->Fill(CleanLeptons->At(0)->Pt(),NNLOWeight->GetVal());
488     fLeptonPtMin_NMinusOne->Fill(CleanLeptons->At(1)->Pt(),NNLOWeight->GetVal());
489     fDeltaPhiLeptons_NMinusOne->Fill(deltaPhiLeptons,NNLOWeight->GetVal());
490 ceballos 1.1 }
491    
492     // NSoftMuons
493     pass = true;
494     for (int k=0;k<nCuts;k++) {
495 ceballos 1.18 if (k != 7) pass = (pass && passCut[k]);
496 ceballos 1.1 }
497     if (pass) {
498 ceballos 1.2 fNSoftMuonsHist_NMinusOne->Fill(SoftMuons->GetEntries(),NNLOWeight->GetVal());
499 ceballos 1.1 }
500    
501     //*********************************************************************************************
502     //Plots after all Cuts
503     //*********************************************************************************************
504     if (passAllCuts) {
505 ceballos 1.2 fMinDeltaPhiLeptonMet_afterCuts->Fill(minDeltaPhiMetLepton,NNLOWeight->GetVal());
506     fMtLepton1_afterCuts->Fill(mTW[0],NNLOWeight->GetVal());
507     fMtLepton2_afterCuts->Fill(mTW[1],NNLOWeight->GetVal());
508     fMtHiggs_afterCuts->Fill(mtHiggs,NNLOWeight->GetVal());
509 ceballos 1.14 fLeptonPtPlusMet_afterCuts->Fill(CleanLeptons->At(0)->Pt()+CleanLeptons->At(1)->Pt()+stdMet->Pt(),NNLOWeight->GetVal());
510 ceballos 1.1 }
511    
512     delete dilepton;
513     delete SoftMuons;
514 ceballos 1.6 for(UInt_t i=0; i<sortedJets.size(); i++) delete sortedJets[i];
515     for(UInt_t i=0; i<sortedJetsAll.size(); i++) delete sortedJetsAll[i];
516 ceballos 1.1 return;
517     }
518    
519     //--------------------------------------------------------------------------------------------------
520     void HwwExampleAnalysisMod::SlaveTerminate()
521     {
522    
523     // Run finishing code on the computer (slave) that did the analysis. For this
524     // module, we dont do anything here.
525 ceballos 1.13 cout << "selected events on HwwExampleAnalysisMod: " << fNEventsSelected << endl;
526 ceballos 1.1
527     }
528     //--------------------------------------------------------------------------------------------------
529     void HwwExampleAnalysisMod::Terminate()
530     {
531     // Run finishing code on the client computer. For this module, we dont do
532     // anything here.
533    
534     }