#include <filesystem>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include "TFile.h"
#include "TString.h"
#include "TList.h"
#include "TKey.h"
#include "TH2F.h"
#include "ElectronEfficiencyCorrection/TElectronEfficiencyCorrectionTool.h"
#include "AsgMessaging/MessageCheck.h"
#include "AsgTools/StandaloneToolHandle.h"
Go to the source code of this file.
|
#define | GEV 1000.0 |
|
#define | TEV 1000000.0 |
|
◆ GEV
◆ TEV
◆ main()
int main |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
Definition at line 30 of file PrintPhotonSF.cxx.
33 printf(
"input parameters:\n./PrintPhotonSF [file] \n");
34 printf(
"example:\n PrintPhotonSF $ROOTCOREBIN/data/PhotonEfficiencyCorrection/INPUTFILE.root\n");
40 printf(
"Error: file %s not exists\n",
argv[1]);
47 TList * listDirectories = TFile::Open(
file)->GetListOfKeys();
48 const int ndirs = listDirectories->GetSize();
50 printf(
"Error: file %s does not contains any keys\n",
argv[1]);
53 TString dirName = listDirectories->First()->GetName();
55 printf(
"Reads: %s, found %d folders:\n",
argv[1],ndirs);
56 TIter
next(listDirectories);
58 while ((
key = (TKey*)
next())) printf(
"%s\n",
key->GetName());
59 printf(
"which directory to use? (type the number from 1 to %d): ",ndirs);
60 int ndir_input=0; cin >> ndir_input;
61 if(ndir_input>ndirs || ndir_input<1)
62 printf(
"\nWarning... entered wrong key number, will print SF for directory: %s\n",dirName.Data());
64 dirName = listDirectories->At(ndir_input-1)->GetName();
65 printf(
"\nprint SF for directory: %s\n",dirName.Data());
68 else printf(
"Reads: %s\nDirectory: %s\n",
argv[1],dirName.Data());
72 if(
getenv(
"ROOTCOREDIR")==
nullptr){
73 cout <<
"Please setup RootCore before running the PrintPhotonSF [file]"<<endl;
82 printf(
"Tool not initialized properly, check the error massages\n");
90 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()));
93 const Double_t * pTbounds =
h->GetXaxis()->GetXbins()->GetArray();
94 const Double_t * Etabounds =
h->GetYaxis()->GetXbins()->GetArray();
96 const int npTbins =
h->GetXaxis()->GetNbins();
97 const int nEtabins =
h->GetYaxis()->GetNbins();
102 cout <<
"-----------------------------------------------------------------------------------"<<endl;
103 cout <<
"Table of photon ScaleFactors obtained by data-driven measurements for input file:"<<endl; cout <<
file <<endl;
104 cout <<
"-----------------------------------------------------------------------------------"<<endl;
105 TString dash_line=
"---------------";
for(
int i=1;
i<=nEtabins;
i++) dash_line+=
"------------------";
106 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;
107 cout << dash_line.Data() <<endl;
108 for (
int i=1;
i<=npTbins;
i++){
109 pt=0.5*(pTbounds[
i-1]+pTbounds[
i]);
110 if(
pt/
GEV<100) printf(
"|%2.1f-%2.1f\t\t|",pTbounds[
i-1]/
GEV,pTbounds[
i]/
GEV);
111 else if(
pt<
TEV) printf(
"|%2.0f - %2.0f\t\t|",pTbounds[
i-1]/
GEV,pTbounds[
i]/
GEV);
112 else printf(
"|%2.0f-%2.0f\t\t|",pTbounds[
i-1]/
GEV,pTbounds[
i]/
GEV);
113 for(
int j=1;j<=nEtabins;j++){
114 eta=0.5*(Etabounds[j-1]+Etabounds[j]);
117 printf(
"%2.2f+/-%2.4f\t|",
sf.SF,
sf.Total);
120 cout << dash_line.Data() <<endl;
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)