2 #include "TLorentzVector.h"
4 #include "TLorentzRotation.h"
6 #include "TClonesArray.h"
23 ofstream outfile(outputfile.c_str());
29 TClonesArray*
p=
new TClonesArray(
"TLorentzVector");
30 TLorentzVector* beam=NULL;
32 std::vector<int>*
q=NULL;
33 tr->SetBranchAddress(
"weight",&weight);
36 unsigned int nevt=tr->GetEntries();
37 for(
unsigned int i=0;
i<nevt;++
i){
39 if(weight>maxweight)maxweight=weight;
41 cout<<
"Maxweight="<<maxweight<<endl;
43 tr->SetBranchAddress(
"p",&p);
44 tr->SetBranchAddress(
"beam",&beam);
45 tr->SetBranchAddress(
"qbeam",&qbeam);
46 tr->SetBranchAddress(
"q",&q);
50 unsigned int nselected=0;
51 unsigned int attempts=0;
53 for(
unsigned int i=0;
i<nevt;++
i){
56 if(doweight && gRandom->Uniform()>weight/maxweight)
continue;
60 event.writeGAMP(outfile);
61 if(nselected==n)
break;
65 cout <<
"Attempts: " << attempts << endl;
66 cout <<
"Efficiency=" << (double)nselected/(
double)attempts << endl;