ROOTPWA
dumpWeights.C
Go to the documentation of this file.
1 #include <iomanip>
2 #include <fstream>
3 #include "TFile.h"
4 #include "TTree.h"
5 
6 using namespace std;
7 
8 void dumpWeights(TString file){
9 
10  TFile* infile=TFile::Open(file,"READ");
11  file.ReplaceAll(".root",".wht");
12 
13  ofstream outfile(file.Data());
14 
15  TTree* tr=(TTree*)infile->Get("pwevents");
16  double w=1;
17  tr->SetBranchAddress("impweight",&w);
18 
19  outfile << std::setprecision(10);
20 
21  unsigned int n=tr->GetEntries();
22  for(unsigned int i=0; i<n; ++i){
23  tr->GetEntry(i);
24  outfile << w << endl;
25  }
26 
27  infile->Close();
28  outfile.close();
29 
30 
31 }