29 using namespace TMath;
34 printf(
"input parameters:\n./PrintPhotonSF [file] \n");
35 printf(
"example:\n PrintPhotonSF $ROOTCOREBIN/data/PhotonEfficiencyCorrection/INPUTFILE.root\n");
41 printf(
"Error: file %s not exists\n",
argv[1]);
48 TList * listDirectories = TFile::Open(
file)->GetListOfKeys();
49 const int ndirs = listDirectories->GetSize();
51 printf(
"Error: file %s does not contains any keys\n",
argv[1]);
54 TString
dirName = listDirectories->First()->GetName();
56 printf(
"Reads: %s, found %d folders:\n",
argv[1],ndirs);
57 TIter
next(listDirectories);
59 while ((
key = (TKey*)
next())) printf(
"%s\n",
key->GetName());
60 printf(
"which directory to use? (type the number from 1 to %d): ",ndirs);
61 int ndir_input=0; cin >> ndir_input;
62 if(ndir_input>ndirs || ndir_input<1)
63 printf(
"\nWarning... entered wrong key number, will print SF for directory: %s\n",
dirName.Data());
65 dirName = listDirectories->At(ndir_input-1)->GetName();
66 printf(
"\nprint SF for directory: %s\n",
dirName.Data());
69 else printf(
"Reads: %s\nDirectory: %s\n",
argv[1],
dirName.Data());
73 if(
getenv(
"ROOTCOREDIR")==
nullptr){
74 cout <<
"Please setup RootCore before running the PrintPhotonSF [file]"<<endl;
83 printf(
"Tool not initialized properly, check the error massages\n");
94 const Double_t * pTbounds =
h->GetXaxis()->GetXbins()->GetArray();
95 const Double_t * Etabounds =
h->GetYaxis()->GetXbins()->GetArray();
97 const int npTbins =
h->GetXaxis()->GetNbins();
98 const int nEtabins =
h->GetYaxis()->GetNbins();
103 cout <<
"-----------------------------------------------------------------------------------"<<endl;
104 cout <<
"Table of photon ScaleFactors obtained by data-driven measurements for input file:"<<endl; cout <<
file <<endl;
105 cout <<
"-----------------------------------------------------------------------------------"<<endl;
106 TString dash_line=
"---------------";
for(
int i=1;
i<=nEtabins;
i++) dash_line+=
"------------------";
107 cout <<
"| pt[GeV]\t\t|";
for(
int i=1;
i<=nEtabins;
i++) printf(
"%2.2f<eta<%2.2f\t|",Etabounds[
i-1],Etabounds[
i]); cout<<endl;
108 cout << dash_line.Data() <<endl;
109 for (
int i=1;
i<=npTbins;
i++){
110 pt=0.5*(pTbounds[
i-1]+pTbounds[
i]);
111 if(
pt/
GEV<100) printf(
"|%2.1f-%2.1f\t\t|",pTbounds[
i-1]/
GEV,pTbounds[
i]/
GEV);
112 else if(
pt<
TEV) printf(
"|%2.0f - %2.0f\t\t|",pTbounds[
i-1]/
GEV,pTbounds[
i]/
GEV);
113 else printf(
"|%2.0f-%2.0f\t\t|",pTbounds[
i-1]/
GEV,pTbounds[
i]/
GEV);
114 for(
int j=1;j<=nEtabins;j++){
115 eta=0.5*(Etabounds[j-1]+Etabounds[j]);
118 printf(
"%2.2f+/-%2.4f\t|",
sf.SF,
sf.Total);
121 cout << dash_line.Data() <<endl;