1 void combineRatios(
char* dir,
char* OutFilename,
int num,
int startnum = 0) {
14 cout <<
"OVERFLOW, increase MAX!!!" << endl;
21 for(
int i=0; i<num; i++) {
22 filename=dir; filename+=
"/"; filename+=
"final0"; filename+=i+startnum; filename+=
".root";
23 cout <<
"Loading "<< filename.Data() << endl;
24 tf[i] =
new TFile(filename.Data());
30 tfout =
new TFile(OutFilename,
"RECREATE");
31 const char* plotnames[] = {
"DEtaDPhi",
"YtYt",
"EtaEta",
"PhiPhi"};
32 const int NUMPLOTS = 4;
35 double npairs[4][MAX+1];
36 const char* pairnames[] = {
"SibppNDEtaDPhi",
"SibmmNDEtaDPhi",
"SibpmNDEtaDPhi",
"SibmpNDEtaDPhi"};
41 for(
int plot=0; plot<NUMPLOTS; plot++) {
44 for(i=0; i<num; i++) {
45 ehelp.setTFile(tf[i]);
48 plots[i] = (TH2D**)ehelp.buildNChargeTypes(name);
51 for(
int j=0; j<4; j++) {
52 htemp = (TH2D*)tf[i]->Get(pairnames[j]);
54 cout <<
"ERROR reading " << pairnames[j] << endl;
57 npairsCS[j] = htemp->Integral();
60 npairs[0][i] = npairsCS[0] + npairsCS[1];
61 npairs[1][i] = npairsCS[2] + npairsCS[3];
62 npairs[2][i] = npairs[0][i] + npairs[1][i];
63 npairs[3][i] = npairs[2][i];
64 if(i==0) {
for(j=0; j<4; j++) npairs[j][MAX] = 0;}
65 for(j=0; j<4; j++) npairs[j][MAX] += npairs[j][i];
69 for (
int type=0; type<4; type++) {
70 plots[0][type]->Scale(npairs[type][0]);
71 TH2D* hout = (TH2D*)plots[0][type]->Clone();
72 for(i=1; i<num; i++) {
73 plots[i][type]->Scale(npairs[type][i]);
74 hout->Add(plots[i][type]);
76 hout->Scale(1.0/npairs[type][MAX]);
78 cout <<
"Writing " << hout->GetName() << endl;