Skip to content

Commit e8db6e5

Browse files
author
Markus
committed
update example
1 parent 9f74d9e commit e8db6e5

File tree

3 files changed

+310
-307
lines changed

3 files changed

+310
-307
lines changed

A7LoopBase.C

Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,310 @@ TFile* A7LoopBase::Loop()
3636
}
3737

3838

39+
40+
41+
void A7LoopBase::setTree(SampleInfo mySample )
42+
{
43+
44+
TFile *f = TFile::Open(mySample.FilePath);
45+
f->ls();
46+
TTree* tree = (TTree*) f->Get("treeProducerA7W");
47+
outputFileName = mySample.OutputFileNameTag+".root";
48+
weight = mySample.weight();
49+
Init(tree);
50+
cout << "looping over: \""<< mySample.FilePath<< "\" to put plots into: \""<< outputFileName<<"\""<<endl;;
51+
52+
}
53+
54+
55+
56+
57+
A7LoopBase::~A7LoopBase()
58+
{
59+
if (!fChain) return;
60+
delete fChain->GetCurrentFile();
61+
}
62+
63+
Int_t A7LoopBase::GetEntry(Long64_t entry)
64+
{
65+
// Read contents of entry.
66+
if (!fChain) return 0;
67+
return fChain->GetEntry(entry);
68+
}
69+
Long64_t A7LoopBase::LoadTree(Long64_t entry)
70+
{
71+
// Set the environment to read one entry
72+
if (!fChain) return -5;
73+
Long64_t centry = fChain->LoadTree(entry);
74+
if (centry < 0) return centry;
75+
if (fChain->GetTreeNumber() != fCurrent) {
76+
fCurrent = fChain->GetTreeNumber();
77+
Notify();
78+
}
79+
return centry;
80+
}
81+
82+
void A7LoopBase::Init(TTree *tree)
83+
{
84+
// The Init() function is called when the selector needs to initialize
85+
// a new tree or chain. Typically here the branch addresses and branch
86+
// pointers of the tree will be set.
87+
// It is normally not necessary to make changes to the generated
88+
// code, but the routine can be extended by the user if needed.
89+
// Init() will be called many times when running on PROOF
90+
// (once per file to be processed).
91+
92+
// Set branch addresses and branch pointers
93+
94+
if (!tree) {
95+
cout << "A7LoopBase::Init: error: tree name likely wrong!" <<endl;
96+
return;
97+
}
98+
fChain = tree;
99+
fCurrent = -1;
100+
fChain->SetMakeClass(1);
101+
102+
// fChain->SetBranchAddress("run", &run, &b_run);
103+
// fChain->SetBranchAddress("lumi", &lumi, &b_lumi);
104+
// fChain->SetBranchAddress("evt", &evt, &b_evt);
105+
// fChain->SetBranchAddress("isData", &isData, &b_isData);
106+
fChain->SetBranchAddress("HLT_SingleMu", &HLT_SingleMu, &b_HLT_SingleMu);
107+
// fChain->SetBranchAddress("rho", &rho, &b_rho);
108+
fChain->SetBranchAddress("nVert", &nVert, &b_nVert);
109+
fChain->SetBranchAddress("nJet25", &nJet25, &b_nJet25);
110+
fChain->SetBranchAddress("nBJetLoose25", &nBJetLoose25, &b_nBJetLoose25);
111+
fChain->SetBranchAddress("nBJetMedium25", &nBJetMedium25, &b_nBJetMedium25);
112+
// fChain->SetBranchAddress("nBJetTight25", &nBJetTight25, &b_nBJetTight25);
113+
fChain->SetBranchAddress("nJet40", &nJet40, &b_nJet40);
114+
// fChain->SetBranchAddress("nJet40a", &nJet40a, &b_nJet40a);
115+
// fChain->SetBranchAddress("nBJetLoose40", &nBJetLoose40, &b_nBJetLoose40);
116+
//fChain->SetBranchAddress("nBJetMedium40", &nBJetMedium40, &b_nBJetMedium40);
117+
// fChain->SetBranchAddress("nBJetTight40", &nBJetTight40, &b_nBJetTight40);
118+
// fChain->SetBranchAddress("nLepGood20", &nLepGood20, &b_nLepGood20);
119+
// fChain->SetBranchAddress("nLepGood15", &nLepGood15, &b_nLepGood15);
120+
//fChain->SetBranchAddress("nLepGood10", &nLepGood10, &b_nLepGood10);
121+
// fChain->SetBranchAddress("checkEcalDead", &checkEcalDead, &b_checkEcalDead);
122+
// fChain->SetBranchAddress("checkhcalLaser", &checkhcalLaser, &b_checkhcalLaser);
123+
// fChain->SetBranchAddress("checktrackingFailure", &checktrackingFailure, &b_checktrackingFailure);
124+
// fChain->SetBranchAddress("checkprimaryVertex", &checkprimaryVertex, &b_checkprimaryVertex);
125+
// fChain->SetBranchAddress("checknoscraping", &checknoscraping, &b_checknoscraping);
126+
// fChain->SetBranchAddress("checktrackIsolationMaker", &checktrackIsolationMaker, &b_checktrackIsolationMaker);
127+
// fChain->SetBranchAddress("checkmetNoiseCleaning", &checkmetNoiseCleaning, &b_checkmetNoiseCleaning);
128+
// fChain->SetBranchAddress("checkeeBadSc", &checkeeBadSc, &b_checkeeBadSc);
129+
// fChain->SetBranchAddress("checkecalLaser", &checkecalLaser, &b_checkecalLaser);
130+
// fChain->SetBranchAddress("checktotalKinematics", &checktotalKinematics, &b_checktotalKinematics);
131+
// fChain->SetBranchAddress("checkCSCTightHalo", &checkCSCTightHalo, &b_checkCSCTightHalo);
132+
// fChain->SetBranchAddress("checkHBHENoise", &checkHBHENoise, &b_checkHBHENoise);
133+
// fChain->SetBranchAddress("htJet25", &htJet25, &b_htJet25);
134+
// fChain->SetBranchAddress("mhtJet25", &mhtJet25, &b_mhtJet25);
135+
// fChain->SetBranchAddress("htJet40j", &htJet40j, &b_htJet40j);
136+
// fChain->SetBranchAddress("htJet40ja", &htJet40ja, &b_htJet40ja);
137+
// fChain->SetBranchAddress("htJet40", &htJet40, &b_htJet40);
138+
// fChain->SetBranchAddress("htJet40a", &htJet40a, &b_htJet40a);
139+
// fChain->SetBranchAddress("mhtJet40", &mhtJet40, &b_mhtJet40);
140+
// fChain->SetBranchAddress("mhtJet40a", &mhtJet40a, &b_mhtJet40a);
141+
// fChain->SetBranchAddress("mZ1", &mZ1, &b_mZ1);
142+
// fChain->SetBranchAddress("mZ1SFSS", &mZ1SFSS, &b_mZ1SFSS);
143+
// fChain->SetBranchAddress("minMllSFOS", &minMllSFOS, &b_minMllSFOS);
144+
// fChain->SetBranchAddress("maxMllSFOS", &maxMllSFOS, &b_maxMllSFOS);
145+
// fChain->SetBranchAddress("minMllAFOS", &minMllAFOS, &b_minMllAFOS);
146+
// fChain->SetBranchAddress("maxMllAFOS", &maxMllAFOS, &b_maxMllAFOS);
147+
// fChain->SetBranchAddress("minMllAFSS", &minMllAFSS, &b_minMllAFSS);
148+
// fChain->SetBranchAddress("maxMllAFSS", &maxMllAFSS, &b_maxMllAFSS);
149+
// fChain->SetBranchAddress("minMllAFAS", &minMllAFAS, &b_minMllAFAS);
150+
// fChain->SetBranchAddress("maxMllAFAS", &maxMllAFAS, &b_maxMllAFAS);
151+
// fChain->SetBranchAddress("m2l", &m2l, &b_m2l);
152+
// fChain->SetBranchAddress("minMWjj", &minMWjj, &b_minMWjj);
153+
// // fChain->SetBranchAddress("minMWjjPt", &minMWjjPt, &b_minMWjjPt);
154+
// fChain->SetBranchAddress("bestMWjj", &bestMWjj, &b_bestMWjj);
155+
// fChain->SetBranchAddress("bestMWjjPt", &bestMWjjPt, &b_bestMWjjPt);
156+
// fChain->SetBranchAddress("bestMTopHad", &bestMTopHad, &b_bestMTopHad);
157+
// fChain->SetBranchAddress("bestMTopHadPt", &bestMTopHadPt, &b_bestMTopHadPt);
158+
fChain->SetBranchAddress("met_pt", &met_pt, &b_met_pt);
159+
fChain->SetBranchAddress("met_eta", &met_eta, &b_met_eta);
160+
fChain->SetBranchAddress("met_phi", &met_phi, &b_met_phi);
161+
fChain->SetBranchAddress("met_mass", &met_mass, &b_met_mass);
162+
//fChain->SetBranchAddress("met_sumEt", &met_sumEt, &b_met_sumEt);
163+
/* fChain->SetBranchAddress("metNoPU_pt", &metNoPU_pt, &b_metNoPU_pt);
164+
fChain->SetBranchAddress("metNoPU_eta", &metNoPU_eta, &b_metNoPU_eta);
165+
fChain->SetBranchAddress("metNoPU_phi", &metNoPU_phi, &b_metNoPU_phi);
166+
fChain->SetBranchAddress("metNoPU_mass", &metNoPU_mass, &b_metNoPU_mass);
167+
fChain->SetBranchAddress("nLepOther", &nLepOther, &b_nLepOther);
168+
fChain->SetBranchAddress("LepOther_pt", LepOther_pt, &b_LepOther_pt);
169+
fChain->SetBranchAddress("LepOther_eta", LepOther_eta, &b_LepOther_eta);
170+
fChain->SetBranchAddress("LepOther_phi", LepOther_phi, &b_LepOther_phi);
171+
fChain->SetBranchAddress("LepOther_mass", LepOther_mass, &b_LepOther_mass);
172+
fChain->SetBranchAddress("LepOther_pdgId", LepOther_pdgId, &b_LepOther_pdgId);
173+
fChain->SetBranchAddress("LepOther_charge", LepOther_charge, &b_LepOther_charge);
174+
fChain->SetBranchAddress("LepOther_dxy", LepOther_dxy, &b_LepOther_dxy);
175+
fChain->SetBranchAddress("LepOther_dz", LepOther_dz, &b_LepOther_dz);
176+
fChain->SetBranchAddress("LepOther_edxy", LepOther_edxy, &b_LepOther_edxy);
177+
fChain->SetBranchAddress("LepOther_edz", LepOther_edz, &b_LepOther_edz);
178+
fChain->SetBranchAddress("LepOther_ip3d", LepOther_ip3d, &b_LepOther_ip3d);
179+
fChain->SetBranchAddress("LepOther_sip3d", LepOther_sip3d, &b_LepOther_sip3d);
180+
fChain->SetBranchAddress("LepOther_tightId", LepOther_tightId, &b_LepOther_tightId);
181+
fChain->SetBranchAddress("LepOther_convVeto", LepOther_convVeto, &b_LepOther_convVeto);
182+
fChain->SetBranchAddress("LepOther_lostHits", LepOther_lostHits, &b_LepOther_lostHits);
183+
fChain->SetBranchAddress("LepOther_looseIdSusy", LepOther_looseIdSusy, &b_LepOther_looseIdSusy);
184+
fChain->SetBranchAddress("LepOther_relIso03", LepOther_relIso03, &b_LepOther_relIso03);
185+
fChain->SetBranchAddress("LepOther_relIso04", LepOther_relIso04, &b_LepOther_relIso04);
186+
fChain->SetBranchAddress("LepOther_chargedHadRelIso03", LepOther_chargedHadRelIso03, &b_LepOther_chargedHadRelIso03);
187+
fChain->SetBranchAddress("LepOther_chargedHadRelIso04", LepOther_chargedHadRelIso04, &b_LepOther_chargedHadRelIso04);
188+
fChain->SetBranchAddress("LepOther_convVetoFull", LepOther_convVetoFull, &b_LepOther_convVetoFull);
189+
fChain->SetBranchAddress("LepOther_eleCutId", LepOther_eleCutId, &b_LepOther_eleCutId);
190+
fChain->SetBranchAddress("LepOther_eleMVAId", LepOther_eleMVAId, &b_LepOther_eleMVAId);
191+
fChain->SetBranchAddress("LepOther_tightCharge", LepOther_tightCharge, &b_LepOther_tightCharge);
192+
fChain->SetBranchAddress("LepOther_mvaId", LepOther_mvaId, &b_LepOther_mvaId);
193+
fChain->SetBranchAddress("LepOther_mvaIdTrig", LepOther_mvaIdTrig, &b_LepOther_mvaIdTrig);
194+
fChain->SetBranchAddress("LepOther_nStations", LepOther_nStations, &b_LepOther_nStations);
195+
fChain->SetBranchAddress("LepOther_trkKink", LepOther_trkKink, &b_LepOther_trkKink);
196+
fChain->SetBranchAddress("LepOther_caloCompatibility", LepOther_caloCompatibility, &b_LepOther_caloCompatibility);
197+
fChain->SetBranchAddress("LepOther_globalTrackChi2", LepOther_globalTrackChi2, &b_LepOther_globalTrackChi2);
198+
fChain->SetBranchAddress("LepOther_trackerLayers", LepOther_trackerLayers, &b_LepOther_trackerLayers);
199+
fChain->SetBranchAddress("LepOther_pixelLayers", LepOther_pixelLayers, &b_LepOther_pixelLayers);
200+
fChain->SetBranchAddress("LepOther_mvaTTH", LepOther_mvaTTH, &b_LepOther_mvaTTH);
201+
fChain->SetBranchAddress("LepOther_jetPtRatio", LepOther_jetPtRatio, &b_LepOther_jetPtRatio);
202+
fChain->SetBranchAddress("LepOther_jetBTagCSV", LepOther_jetBTagCSV, &b_LepOther_jetBTagCSV);
203+
fChain->SetBranchAddress("LepOther_jetDR", LepOther_jetDR, &b_LepOther_jetDR);
204+
fChain->SetBranchAddress("LepOther_softMuID", LepOther_softMuID, &b_LepOther_softMuID);
205+
fChain->SetBranchAddress("nTauGood", &nTauGood, &b_nTauGood);
206+
fChain->SetBranchAddress("TauGood_pt", TauGood_pt, &b_TauGood_pt);
207+
fChain->SetBranchAddress("TauGood_eta", TauGood_eta, &b_TauGood_eta);
208+
fChain->SetBranchAddress("TauGood_phi", TauGood_phi, &b_TauGood_phi);
209+
fChain->SetBranchAddress("TauGood_mass", TauGood_mass, &b_TauGood_mass);
210+
fChain->SetBranchAddress("TauGood_pdgId", TauGood_pdgId, &b_TauGood_pdgId);
211+
fChain->SetBranchAddress("TauGood_charge", TauGood_charge, &b_TauGood_charge);
212+
fChain->SetBranchAddress("TauGood_dxy", TauGood_dxy, &b_TauGood_dxy);
213+
fChain->SetBranchAddress("TauGood_dz", TauGood_dz, &b_TauGood_dz);
214+
fChain->SetBranchAddress("TauGood_idMVA2", TauGood_idMVA2, &b_TauGood_idMVA2);
215+
fChain->SetBranchAddress("TauGood_idCI3hit", TauGood_idCI3hit, &b_TauGood_idCI3hit);
216+
fChain->SetBranchAddress("TauGood_isoMVA2", TauGood_isoMVA2, &b_TauGood_isoMVA2);
217+
*/
218+
fChain->SetBranchAddress("nJet", &nJet, &b_nJet);
219+
fChain->SetBranchAddress("Jet_pt", Jet_pt, &b_Jet_pt);
220+
fChain->SetBranchAddress("Jet_eta", Jet_eta, &b_Jet_eta);
221+
fChain->SetBranchAddress("Jet_phi", Jet_phi, &b_Jet_phi);
222+
fChain->SetBranchAddress("Jet_mass", Jet_mass, &b_Jet_mass);
223+
fChain->SetBranchAddress("Jet_btagCSV", Jet_btagCSV, &b_Jet_btagCSV);
224+
fChain->SetBranchAddress("Jet_rawPt", Jet_rawPt, &b_Jet_rawPt);
225+
// fChain->SetBranchAddress("Jet_quarkGluonID", Jet_quarkGluonID, &b_Jet_quarkGluonID);
226+
fChain->SetBranchAddress("Jet_puId", Jet_puId, &b_Jet_puId);
227+
fChain->SetBranchAddress("Jet_area", Jet_area, &b_Jet_area);
228+
fChain->SetBranchAddress("Jet_id", Jet_id, &b_Jet_id);
229+
fChain->SetBranchAddress("Jet_CHEF", Jet_CHEF, &b_Jet_CHEF);
230+
fChain->SetBranchAddress("Jet_NHEF", Jet_NHEF, &b_Jet_NHEF);
231+
fChain->SetBranchAddress("Jet_PHEF", Jet_PHEF, &b_Jet_PHEF);
232+
fChain->SetBranchAddress("Jet_MUEF", Jet_MUEF, &b_Jet_MUEF);
233+
fChain->SetBranchAddress("Jet_ELEF", Jet_ELEF, &b_Jet_ELEF);
234+
fChain->SetBranchAddress("nLepGood", &nLepGood, &b_nLepGood);
235+
fChain->SetBranchAddress("LepGood_pt", LepGood_pt, &b_LepGood_pt);
236+
fChain->SetBranchAddress("LepGood_eta", LepGood_eta, &b_LepGood_eta);
237+
fChain->SetBranchAddress("LepGood_phi", LepGood_phi, &b_LepGood_phi);
238+
fChain->SetBranchAddress("LepGood_mass", LepGood_mass, &b_LepGood_mass);
239+
fChain->SetBranchAddress("LepGood_pdgId", LepGood_pdgId, &b_LepGood_pdgId);
240+
fChain->SetBranchAddress("LepGood_charge", LepGood_charge, &b_LepGood_charge);
241+
fChain->SetBranchAddress("LepGood_dxy", LepGood_dxy, &b_LepGood_dxy);
242+
fChain->SetBranchAddress("LepGood_dz", LepGood_dz, &b_LepGood_dz);
243+
fChain->SetBranchAddress("LepGood_edxy", LepGood_edxy, &b_LepGood_edxy);
244+
fChain->SetBranchAddress("LepGood_edz", LepGood_edz, &b_LepGood_edz);
245+
fChain->SetBranchAddress("LepGood_ip3d", LepGood_ip3d, &b_LepGood_ip3d);
246+
fChain->SetBranchAddress("LepGood_sip3d", LepGood_sip3d, &b_LepGood_sip3d);
247+
fChain->SetBranchAddress("LepGood_tightId", LepGood_tightId, &b_LepGood_tightId);
248+
fChain->SetBranchAddress("LepGood_convVeto", LepGood_convVeto, &b_LepGood_convVeto);
249+
fChain->SetBranchAddress("LepGood_lostHits", LepGood_lostHits, &b_LepGood_lostHits);
250+
fChain->SetBranchAddress("LepGood_looseIdSusy", LepGood_looseIdSusy, &b_LepGood_looseIdSusy);
251+
fChain->SetBranchAddress("LepGood_relIso03", LepGood_relIso03, &b_LepGood_relIso03);
252+
fChain->SetBranchAddress("LepGood_relIso04", LepGood_relIso04, &b_LepGood_relIso04);
253+
/* fChain->SetBranchAddress("LepGood_chargedHadRelIso03", LepGood_chargedHadRelIso03, &b_LepGood_chargedHadRelIso03);
254+
fChain->SetBranchAddress("LepGood_chargedHadRelIso04", LepGood_chargedHadRelIso04, &b_LepGood_chargedHadRelIso04);
255+
fChain->SetBranchAddress("LepGood_convVetoFull", LepGood_convVetoFull, &b_LepGood_convVetoFull);
256+
fChain->SetBranchAddress("LepGood_eleCutId", LepGood_eleCutId, &b_LepGood_eleCutId);
257+
fChain->SetBranchAddress("LepGood_eleMVAId", LepGood_eleMVAId, &b_LepGood_eleMVAId);
258+
fChain->SetBranchAddress("LepGood_tightCharge", LepGood_tightCharge, &b_LepGood_tightCharge);
259+
fChain->SetBranchAddress("LepGood_mvaId", LepGood_mvaId, &b_LepGood_mvaId);
260+
fChain->SetBranchAddress("LepGood_mvaIdTrig", LepGood_mvaIdTrig, &b_LepGood_mvaIdTrig);
261+
fChain->SetBranchAddress("LepGood_nStations", LepGood_nStations, &b_LepGood_nStations);
262+
fChain->SetBranchAddress("LepGood_trkKink", LepGood_trkKink, &b_LepGood_trkKink);
263+
fChain->SetBranchAddress("LepGood_caloCompatibility", LepGood_caloCompatibility, &b_LepGood_caloCompatibility);
264+
fChain->SetBranchAddress("LepGood_globalTrackChi2", LepGood_globalTrackChi2, &b_LepGood_globalTrackChi2);
265+
fChain->SetBranchAddress("LepGood_trackerLayers", LepGood_trackerLayers, &b_LepGood_trackerLayers);
266+
fChain->SetBranchAddress("LepGood_pixelLayers", LepGood_pixelLayers, &b_LepGood_pixelLayers);
267+
fChain->SetBranchAddress("LepGood_mvaTTH", LepGood_mvaTTH, &b_LepGood_mvaTTH);
268+
fChain->SetBranchAddress("LepGood_jetPtRatio", LepGood_jetPtRatio, &b_LepGood_jetPtRatio);
269+
fChain->SetBranchAddress("LepGood_jetBTagCSV", LepGood_jetBTagCSV, &b_LepGood_jetBTagCSV);
270+
fChain->SetBranchAddress("LepGood_jetDR", LepGood_jetDR, &b_LepGood_jetDR);
271+
fChain->SetBranchAddress("LepGood_softMuID", LepGood_softMuID, &b_LepGood_softMuID);*/
272+
273+
274+
Notify();
275+
}
276+
277+
Bool_t A7LoopBase::Notify()
278+
{
279+
// The Notify() function is called when a new file is opened. This
280+
// can be either for a new TTree in a TChain or when when a new TTree
281+
// is started when using PROOF. It is normally not necessary to make changes
282+
// to the generated code, but the routine can be extended by the
283+
// user if needed. The return value is currently not used.
284+
285+
return kTRUE;
286+
}
287+
288+
void A7LoopBase::Show(Long64_t entry)
289+
{
290+
// Print contents of entry.
291+
// If entry is not specified, print current entry
292+
if (!fChain) return;
293+
fChain->Show(entry);
294+
}
295+
Int_t A7LoopBase::Cut(Long64_t entry)
296+
{
297+
// This function may be called from Loop.
298+
// returns 1 if entry is accepted.
299+
cout << " can be used to put preselection cuts for " << entry<<endl;
300+
// returns -1 otherwise.
301+
return 1;
302+
}
303+
304+
Int_t A7LoopBase::CutLepGenAcc(Long64_t entry)
305+
{
306+
// This function may be called from Loop.
307+
// returns 1 if entry is accepted.
308+
cout << " can be used to put preselection cuts for " << entry<<endl;
309+
// returns -1 otherwise.
310+
return 1;
311+
}
312+
313+
Int_t A7LoopBase::CutRECO()
314+
{
315+
// This function may be called from Loop.
316+
int keep = 1;
317+
318+
if(nLepGood==0) keep = -1;
319+
//if(!HLT_SingleMu) continue;
320+
if(LepGood_pt[0]<25) keep = -1;
321+
if(fabs(LepGood_pdgId[0])!=13) keep = -1;
322+
if(LepGood_relIso04[0]>0.12) keep = -1;
323+
if( fabs(LepGood_eta[0]) >2.1) keep = -1;
324+
if(!LepGood_tightId[0]) keep = -1;
325+
326+
if(nLepGood> 1) {
327+
for (int i =1 ;i<nLepGood;i++)
328+
{
329+
if(LepGood_pt[i]>10&& fabs(LepGood_eta[i])<2.4 && LepGood_relIso04[i]<0.2) keep = -1;
330+
}
331+
}
332+
if(nJet==0) keep = -1;
333+
if(Jet_pt[0]<30) keep = -1;
334+
if(fabs(Jet_eta[0])>2.5) keep = -1;
335+
if( nJet40 > 2 ) keep = -1;
336+
if(nBJetLoose25>0) keep = -1;
337+
338+
// returns -1 otherwise.
339+
return keep;
340+
}
341+
342+
343+
39344
#endif
40345

0 commit comments

Comments
 (0)