1 void selectAllM6(
const char* infile,
char* outputdir =
"./",
int rescaleNev=0){
5 cout <<
" selectAllM6, input: " << infile <<
"\tout dir: " << outputdir << endl;
6 gSystem->Load(
"StEStructPoolSupport.so");
8 TFile * tf=
new TFile(infile);
11 cout<<
"error opening file "<<endl;
20 TH1D* hns = (TH1D*)tf->Get(
"NEventsSame");
21 int nevs = hns->GetEntries();
22 TH1D* hnm = (TH1D*)tf->Get(
"NEventsMixed");
23 int nevm = hnm->GetEntries();
24 cout << infile <<
" has " << nevs <<
" sibling events and " << nevm <<
" mixed events." << endl;
26 TH1D* hcb = (TH1D*)tf->Get(
"hcb");
27 if(!hcb) { cout <<
"error loading hcb" << endl;
return;}
28 TH1D* hcbs = (TH1D*)hcb->Clone(
"hcbs");
29 TH1D* hcbm = (TH1D*)hcb->Clone(
"hcbm");
30 hcbs->Scale( nevs / hcbs->Integral() );
31 hcbm->Scale( nevm / hcbm->Integral() );
33 cout <<
"Targets " << endl;
34 for(
int i=0; i<10; i++) cout << hcbs->GetBinContent(i+1) <<
"\t" << hcbm->GetBinContent(i+1) << endl;
35 cout <<
"Totals:\t" << hcbs->Integral() <<
"\t" << hcbm->Integral() << endl;
45 for(
int i=0; i<10; i++) {
47 fname=outputdir; fname+=
"final0"; fname+=i; fname+=
".root";
48 cout <<
"writing " << fname << endl;
49 adder.addCuts(fname,tf,narray,num);
52 tfout =
new TFile(fname,
"UPDATE");
53 TH1D* hs = (TH1D*)tfout->Get(
"NEventsSame");
54 hs->SetEntries( hcbs->GetBinContent(i+1) );
56 TH1D* hm = (TH1D*)tfout->Get(
"NEventsMixed");
57 hm->SetEntries( hcbm->GetBinContent(i+1) );