-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeWHSkim.C
executable file
·58 lines (43 loc) · 1.8 KB
/
makeWHSkim.C
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
#include <fstream>
#include <sstream>
#include <iostream>
#include <TROOT.h>
#include <TFile.h>
#include <TTree.h>
#include <TChain.h>
using namespace std;
void makeWHSkim(string path = "/tas/olivito/phase2/output/V00-00-02", string tag = "tt-4p", string cond = "PhaseI_Configuration0_NoPileUp") {
//--------------------------------------------------
// cut for output files
//--------------------------------------------------
char* sel = "(nleps >= 1) && (lep1pt > 30.) && (nb >= 2)";
cout << "Skimming with selection : "<<sel<<endl;
//--------------------------------------------------
// input and output file
//--------------------------------------------------
char* infilename = Form("%s/%s*%s_baby.root",path.c_str(),tag.c_str(),cond.c_str());
char* outfilename = Form("%s/skim_1lpt30_2b/%s_%s_baby.root",path.c_str(),tag.c_str(),cond.c_str());
//--------------------------------------------------
// cout stuff
//--------------------------------------------------
cout << "Reading in : " << infilename << endl;
cout << "Writing to : " << outfilename << endl;
cout << "Selection : " << sel << endl;
//--------------------------------------------------
// read input file, write to output files
//--------------------------------------------------
long long max_tree_size = 20000000000000000LL;
TTree::SetMaxTreeSize(max_tree_size);
TChain *chain = new TChain("t");
chain->Add(infilename);
cout << "Input tree has entries: " << chain->GetEntries() << endl;
//-------------------
// skim
//-------------------
TFile *outfile = TFile::Open(outfilename, "RECREATE");
assert( outfile != 0 );
TTree* outtree = chain->CopyTree( sel );
cout << "Output tree has entries: " << outtree->GetEntries() << endl;
outtree->Write();
outfile->Close();
}