31 {
32
33 if(argc!=2){
34 printf("input parameters:\n./PrintPhotonSF [file] \n");
35 printf("example:\n PrintPhotonSF $ROOTCOREBIN/data/PhotonEfficiencyCorrection/INPUTFILE.root\n");
36 return 0;
37 }
38
39
40 if(!std::filesystem::exists(argv[1])){
41 printf("Error: file %s not exists\n",argv[1]);
42 return 0;
43 }
44
45 TString
file(argv[1]);
46
47
48 TList * listDirectories = TFile::Open(
file)->GetListOfKeys();
49 const int ndirs = listDirectories->GetSize();
50 if(0==ndirs){
51 printf("Error: file %s does not contains any keys\n",argv[1]);
52 return 0;
53 }
54 TString
dirName = listDirectories->First()->GetName();
55 if(ndirs>1) {
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());
64 else{
65 dirName = listDirectories->At(ndir_input-1)->GetName();
66 printf(
"\nprint SF for directory: %s\n",
dirName.Data());
67 }
68 }
69 else printf(
"Reads: %s\nDirectory: %s\n",argv[1],
dirName.Data());
70
71
73 if(
getenv(
"ROOTCOREDIR")==
nullptr){
74 cout << "Please setup RootCore before running the PrintPhotonSF [file]"<<endl;
75 return 0.;
76 }
77
78
81
83 printf("Tool not initialized properly, check the error massages\n");
84 return 0;
85 }
86
89
90
91 TH2F *
h =
file.Contains(
"AFII") ? (TH2F*)TFile::Open(
file)->Get(Form(
"%s/AltFast2_sf",
dirName.Data())) : (TH2F*)TFile::Open(
file)->Get(Form(
"%s/FullSim_sf",
dirName.Data()));
92
93
94 const Double_t * pTbounds =
h->GetXaxis()->GetXbins()->GetArray();
95 const Double_t * Etabounds =
h->GetYaxis()->GetXbins()->GetArray();
96
97 const int npTbins =
h->GetXaxis()->GetNbins();
98 const int nEtabins =
h->GetYaxis()->GetNbins();
99
101
102
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);
119 } cout << endl;
120 }
121 cout << dash_line.Data() <<endl;
122
123}
Scalar eta() const
pseudorapidity method
Header file for AthHistogramAlgorithm.
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
std::string getenv(const std::string &variableName)
get an environment variable