// // // // reads a tree and keeps only the useful parts // // filenames // // qcd_bce_20_30.root // qcd_bce_30_80.root // qcd_bce_80_170.root // // // // this is a modified version that removes events with 2 electrons that have ET>20GeV #include #include "TTree.h" #include "TFile.h" #include "TBranch.h" using namespace std; void Skimmer( TString ReadFile, TString outputFile, int Type); void Runner() { // wenu: //Skimmer("../wenu_redigi.root","wenu_redigi_MT.root",0); // Skimmer("../zee_m20.root","zee_redigi_skimmed.root",0); //return; // //Skimmer("../qcd_20_30_a.root","q1_a_MT.root",1); //Skimmer("../qcd_20_30_b.root","q1_b_MT.root",1); //Skimmer("../qcd_20_30_c.root","q1_b_MT.root",1); // //Skimmer("../qcd_30_80_a.root","q2_a_MT.root",2); //Skimmer("../qcd_30_80_b.root","q2_b_MT.root",2); //Skimmer("../qcd_30_80_c.root","q2_c_MT.root",2); //Skimmer("../qcd_30_80_d.root","q2_d_MT.root",2); // // Skimmer("../qcd_80_170_v1.root","q3_MT.root",3); Skimmer("../bce_20_30_v1.root","q4_MT.root",4); Skimmer("../bce_30_80_v1.root","q5_MT.root",5); Skimmer("../bce_80_170_v1.root","q6_MT.root",6); // Skimmer("../zee_m20_v1.root","zee_MT.root",7); Skimmer("../wtaunu.root","wtaunu_MT.root",8); Skimmer("../ztautau.root","ztautau_MT.root",9); // Skimmer("../gjets_15_20_v1.root","gj0_MT.root",10); Skimmer("../gjets_20_25_v1.root","gj1_MT.root",11); Skimmer("../gjets_25_30.root","gj2_MT.root",12); Skimmer("../gjets_30_35.root","gj3_MT.root",13); Skimmer("../gjets_35.root","gj4_MT.root",14); Skimmer("../wmunu.root","wmunu_MT.root",15); Skimmer("../ttbar_tauola.root","ttbar_MT.root",16); } void Skimmer( TString ReadFile, TString outputFile, int Type) { cout << "File: " << ReadFile << endl; cout << "Target: " << outputFile << ", Type: " << Type << endl; //TString ReadFile = "qcd_bce_80_170.root"; // output //TString outputFile = "q6_skimmed.root"; //const int Type = ; double ETd = 20.; TFile f(ReadFile); TTree *tree = (TTree*)f.Get("probe_tree"); // get the usefull variables // // variables: sc ET, sc eta, sc phi, HLT path, MET // // isolations: trk, ecal, ecal // ID: sihih, dfi, dhi, eop, hoe // // // General quantities TBranch *b_et_probe_sc = tree->GetBranch("probe_sc_et"); double probe_sc_et[4]; b_et_probe_sc->SetAddress(probe_sc_et); // TBranch *b_et_probe_eta = tree->GetBranch("probe_sc_eta"); double probe_sc_eta[4]; b_et_probe_eta->SetAddress(probe_sc_eta); // TBranch *b_et_probe_phi = tree->GetBranch("probe_sc_phi"); double probe_sc_phi[4]; b_et_probe_phi->SetAddress(probe_sc_phi); // TBranch *b_event_MET = tree->GetBranch("event_MET"); double event_MET; b_event_MET->SetAddress(&event_MET); // TBranch *b_event_MET_phi = tree->GetBranch("event_MET_phi"); double event_MET_phi; b_event_MET_phi->SetAddress(&event_MET_phi); // TBranch *b_event_HLTPath = tree->GetBranch("event_HLTPath"); int event_HLTPath; b_event_HLTPath->SetAddress(&event_HLTPath); // TBranch *b_elec_num = tree->GetBranch("elec_1_duplicate_removal"); int elec_1_duplicate_removal; b_elec_num->SetAddress(&elec_1_duplicate_removal); // // ISOLATIONS TBranch *b_et_probe_trk = tree->GetBranch("probe_isolation_value"); double probe_trk[4]; b_et_probe_trk->SetAddress(probe_trk); // TBranch *b_et_probe_ecal = tree->GetBranch("probe_ecal_isolation_value"); double probe_ecal[4]; b_et_probe_ecal->SetAddress(probe_ecal); // TBranch *b_et_probe_hcal = tree->GetBranch("probe_hcal_isolation_value"); double probe_hcal[4]; b_et_probe_hcal->SetAddress(probe_hcal); // // IDs // TBranch *b_et_probe_sihih = tree->GetBranch("probe_ele_sihih"); double probe_sihih[4]; b_et_probe_sihih->SetAddress(probe_sihih); // TBranch *b_et_probe_shh = tree->GetBranch("probe_ele_shh"); double probe_shh[4]; b_et_probe_shh->SetAddress(probe_shh); // TBranch *b_et_probe_hoe = tree->GetBranch("probe_ele_hoe"); double probe_hoe[4]; b_et_probe_hoe->SetAddress(probe_hoe); // TBranch *b_et_probe_dfi = tree->GetBranch("probe_ele_dfi"); double probe_dfi[4]; b_et_probe_dfi->SetAddress(probe_dfi); // TBranch *b_et_probe_dhi = tree->GetBranch("probe_ele_dhi"); double probe_dhi[4]; b_et_probe_dhi->SetAddress(probe_dhi); // TBranch *b_et_probe_eop = tree->GetBranch("probe_ele_eop"); double probe_eop[4]; b_et_probe_eop->SetAddress(probe_eop); // TBranch *b_et_probe_tip = tree->GetBranch("probe_ele_tip"); double probe_tip[4]; b_et_probe_tip->SetAddress(probe_tip); // TBranch *b_et_probe_fid = tree->GetBranch("probe_sc_fiducial_cut"); int probe_sc_fiducial_cut[4]; b_et_probe_fid->SetAddress(probe_sc_fiducial_cut); // this is an extra requirement: electron is matched to an HLT object // TO BE REMOVED LATER TBranch *b_et_probe_trig = tree->GetBranch("probe_trigger_cut"); int probe_trigger_cut[4]; b_et_probe_trig->SetAddress(probe_trigger_cut); Long64_t N = tree->GetEntries(); // // new file here! TFile f2(outputFile, "recreate"); TTree *t = new TTree("probe_tree", "probe_tree"); // // the new branches double sc_et; TBranch *new_sc_et = t->Branch("probe_sc_et", &sc_et, "probe_sc_et/D"); double sc_eta; TBranch *new_sc_eta = t->Branch("probe_sc_eta", &sc_eta, "probe_sc_eta/D"); // double sc_phi; TBranch *new_sc_phi = t->Branch("probe_sc_phi", &sc_phi, "probe_sc_phi/D"); // double sc_MET; TBranch *new_sc_MET = t->Branch("event_MET", &sc_MET, "event_MET/D"); // double sc_MET_phi; TBranch *new_sc_MET_phi = t->Branch("event_MET_phi", &sc_MET_phi, "event_MET_phi/D"); // double sc_trk; TBranch *new_sc_trk = t->Branch("probe_isolation_value",&sc_trk,"probe_isolation_value/D"); // double sc_ecal; TBranch *new_sc_ecal = t->Branch("probe_ecal_isolation_value",&sc_ecal,"probe_ecal_isolation_value/D"); // double sc_hcal; TBranch *new_sc_hcal = t->Branch("probe_hcal_isolation_value",&sc_hcal,"probe_hcal_isolation_value/D"); // double sc_sihih; TBranch *new_sc_sihih = t->Branch("probe_ele_sihih",&sc_sihih,"probe_ele_sihih/D"); // double sc_shh; TBranch *new_sc_shh = t->Branch("probe_ele_shh",&sc_shh,"probe_ele_shh/D"); // double sc_hoe; TBranch *new_sc_hoe = t->Branch("probe_ele_hoe",&sc_hoe,"probe_ele_hoe/D"); // double sc_dfi; TBranch *new_sc_dfi = t->Branch("probe_ele_dfi",&sc_dfi,"probe_ele_dfi/D"); // double sc_dhi; TBranch *new_sc_dhi = t->Branch("probe_ele_dhi",&sc_dhi,"probe_ele_dhi/D"); // double sc_tip; TBranch *new_sc_tip = t->Branch("probe_ele_tip",&sc_tip,"probe_ele_tip/D"); // double sc_eop; TBranch *new_sc_eop = t->Branch("probe_ele_eop",&sc_eop,"probe_ele_eop/D"); unsigned int type; TBranch *new_sc_type = t->Branch("type",&type,"type/s"); unsigned int exclude; TBranch *new_sc_exclude = t->Branch("exclude",&exclude,"exclude/s"); // // ================================================================================= //>SetBranchAddress("probe_sc_et",&sc_et); for (int i=0; i< N; ++i) { tree->GetEntry(i); if (event_HLTPath != 1) continue; if (i%10000 == 0) cout << "Event " << i << endl; // check for events with 2 electrons, if you find them give them negative type bool pass = false; if (elec_1_duplicate_removal>1) { pass = (probe_sc_et[0]>ETd && probe_sc_et[1]>ETd && probe_sc_fiducial_cut[0]>0 && probe_sc_fiducial_cut[1]>0) || (probe_sc_et[0]>ETd && probe_sc_et[2]>ETd && probe_sc_fiducial_cut[0]>0 && probe_sc_fiducial_cut[2]>0) || (probe_sc_et[0]>ETd && probe_sc_et[3]>ETd && probe_sc_fiducial_cut[0]>0 && probe_sc_fiducial_cut[3]>0) || (probe_sc_et[1]>ETd && probe_sc_et[2]>ETd && probe_sc_fiducial_cut[1]>0 && probe_sc_fiducial_cut[2]>0) || (probe_sc_et[1]>ETd && probe_sc_et[3]>ETd && probe_sc_fiducial_cut[1]>0 && probe_sc_fiducial_cut[3]>0) || (probe_sc_et[2]>ETd && probe_sc_et[3]>ETd && probe_sc_fiducial_cut[2]>0 && probe_sc_fiducial_cut[3]>0); //if (pass) continue; } unsigned int exclusion = 0; if (pass) exclusion = 1; for (int j=0; j<4; ++j) { if (probe_sc_et[j] < 20 || probe_sc_fiducial_cut[j] < 0.5) continue; // extra: usually no such requirement applied: //if (probe_trigger_cut[j] != 1) continue; /* cout << j << ": " << probe_sc_et[j] << " HLT= " << event_HLTPath << " hcal iso " << probe_sihih[j] << endl; */ // ok fill the tree now: sc_et = probe_sc_et[j]; sc_eta = probe_sc_eta[j]; sc_phi = probe_sc_phi[j]; sc_MET = event_MET; sc_MET_phi = event_MET_phi; sc_trk = probe_trk[j]; sc_ecal = probe_ecal[j]; sc_hcal = probe_hcal[j]; // sc_sihih = probe_sihih[j]; sc_shh = probe_shh[j]; sc_hoe = probe_hoe[j]; sc_dfi = probe_dfi[j]; sc_dhi = probe_dhi[j]; sc_eop = probe_eop[j]; sc_tip = probe_tip[j]; type = Type; exclude = exclusion; // t->Fill(); } } t->Write(); }