-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperChiara.C
54 lines (46 loc) · 1.37 KB
/
perChiara.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
#include <TTree.h>
#include <RooRealVar.h>
#include <RooArgSet.h>
#include <RooArgList.h>>
#include <TList.h>
#include <TObject.h>
#include <TKey.h>
TTree *dataset2tree(RooDataSet *dataset){
const RooArgSet *args = dataset->get();
RooArgList argList(*args);
Double_t variables[50];
Long64_t nEntries= dataset->numEntries();
//nEntries=1;
TTree *tree = new TTree("tree","tree");
tree->SetDirectory(0);
TIterator *it1=NULL;
it1 = argList.createIterator();
int index1=0;
for(RooRealVar *var = (RooRealVar *) it1->Next(); var!=NULL;
var = (RooRealVar *) it1->Next(),index1++){
TString name(var->GetName());
name.ReplaceAll("-","_");
tree->Branch(name, &(variables[index1]), name+"/D");
}
Double_t newweight;
tree->Branch("newweight", &newweight, "newweight/D");
// tree->Print();
for(Long64_t jentry=0; jentry<nEntries; jentry++){
TIterator *it=NULL;
RooArgList argList1(*(dataset->get(jentry)));
it = argList1.createIterator();
//(dataset->get(jentry))->Print();
int index=0;
for(RooRealVar *var = (RooRealVar *) it->Next(); var!=NULL;
var = (RooRealVar *) it->Next(), index++){
variables[index]=var->getVal();
//var->Print();
if(var->GetName() == "evweight") newweight = evweight*2;
}
delete it;
tree->Fill();
}
tree->ResetBranchAddresses();
// tree->Print();
return tree;
}