22 std::string HistoFilename =
c1.getValue<
string>(
"HistoFilename");
23 std::string FitterFilename =
c1.getValue<
string>(
"FitterFilename");
24 std::string L3ResponseTxtFilename =
c1.getValue<
string>(
"L3ResponseTxtFilename");
25 std::string L3CorrectionTxtFilename =
c1.getValue<
string>(
"L3CorrectionTxtFilename");
26 std::string L3OutputROOTFilename =
c1.getValue<
string>(
"L3OutputROOTFilename");
27 std::string L2CorrectionTxtFilename =
c1.getValue<
string>(
"L2CorrectionTxtFilename");
28 std::string L2OutputROOTFilename =
c1.getValue<
string>(
"L2OutputROOTFilename");
29 std::vector<double> pt_vec =
c1.getVector<
double>(
"RefPtBoundaries");
30 std::vector<double> eta_vec =
c1.getVector<
double>(
"EtaBoundaries");
35 const int MAX_NETA = 83;
36 const int MAX_NREFPTBINS = 30;
37 const int NCaloPtValues = 18;
38 int NRefPtBins = pt_vec.size() - 1;
39 int NETA = eta_vec.size() - 1;
42 int i, auxi, etabin, ptbin;
45 double MinCaloPt[MAX_NETA], MaxCaloPt[MAX_NETA];
46 double correction_x[MAX_NREFPTBINS], correction_y[MAX_NREFPTBINS], correction_ex[MAX_NREFPTBINS],
47 correction_ey[MAX_NREFPTBINS];
48 double cor_rel[MAX_NREFPTBINS], ref_pt, calo_pt, control_pt;
49 double L3_resp[5], L2_cor[10];
53 TH1F *hcorrection[MAX_NREFPTBINS];
55 TF1 *Correction[MAX_NETA];
56 TF1 *L2Correction[MAX_NETA];
58 std::ifstream L3ResponseFile;
60 TGraph *g_L2Correction[MAX_NETA];
61 TGraphErrors *g_EtaCorrection[MAX_NETA];
62 double aux_CaloPt[NCaloPtValues] = {
63 10, 15, 20, 30, 40, 50, 75, 100, 150, 200, 300, 400, 500, 750, 1000, 1500, 2000, 3000};
64 std::vector<std::string> HistoNamesList;
65 inf =
new TFile(FitterFilename.c_str(),
"r");
68 TIter
next(
inf->GetListOfKeys());
70 HistoNamesList.push_back(
key->GetName());
72 L3ResponseFile.open(L3ResponseTxtFilename.c_str());
73 L3ResponseFile >> L3_resp[0] >> L3_resp[1] >> L3_resp[2] >> L3_resp[3] >> L3_resp[4];
74 L3Response =
new TF1(
"L3Response",
"[0]-[1]/(pow(log10(x),[2])+[3])+[4]/x", pt_vec[0], pt_vec[NRefPtBins - 1]);
75 for (
i = 0;
i < 5;
i++)
76 L3Response->SetParameter(
i, L3_resp[
i]);
77 L3ResponseFile.close();
79 for (
i = 0;
i < NRefPtBins;
i++) {
80 sprintf(
name,
"Correction_vs_Eta_RefPt%d",
i);
83 hcorrection[
i] = (TH1F *)
inf->Get(
name);
85 for (etabin = 0; etabin < NETA; etabin++) {
86 sprintf(
name,
"MeanCaloPt_Eta%d", etabin);
92 for (ptbin = 0; ptbin < NRefPtBins; ptbin++) {
93 cor = hcorrection[ptbin]->GetBinContent(etabin + 1);
94 e_cor = hcorrection[ptbin]->GetBinError(etabin + 1);
95 if (cor > 0 && e_cor > 0.0001 && e_cor < 0.3) {
96 correction_x[auxi] =
h->GetBinContent(ptbin + 1);
97 correction_ex[auxi] = 0.;
98 correction_y[auxi] = cor;
99 correction_ey[auxi] = e_cor;
103 sprintf(
name,
"Correction%d", etabin);
105 MaxCaloPt[etabin] = correction_x[auxi - 1];
106 MinCaloPt[etabin] = correction_x[1];
108 sprintf(
func,
"[0]+[1]/(pow(log10(x),[2])+[3])");
110 sprintf(
func,
"[0]+[1]*log10(x)+[2]*pow(log10(x),2)");
111 Correction[etabin] =
new TF1(
name,
func, MinCaloPt[etabin], MaxCaloPt[etabin]);
114 sprintf(
func,
"[0]");
115 correction_x[0] = 10;
116 correction_x[1] = 100;
117 correction_ex[0] = 0.;
118 correction_ex[1] = 0.;
119 correction_y[0] = 1.;
120 correction_y[1] = 1.;
121 correction_ey[0] = 0.;
122 correction_ey[1] = 0.;
124 Correction[etabin] =
new TF1(
name,
func, 10, 100);
125 MaxCaloPt[etabin] = 0;
126 MinCaloPt[etabin] = 0;
128 g_EtaCorrection[etabin] =
new TGraphErrors(auxi, correction_x, correction_y, correction_ex, correction_ey);
129 Correction[etabin]->SetParameter(0, 0.);
130 Correction[etabin]->SetParameter(1, 0.);
131 Correction[etabin]->SetParameter(2, 0.);
132 Correction[etabin]->SetParameter(3, 0.);
133 g_EtaCorrection[etabin]->Fit(
name,
"RQ");
137 for (ptbin = 0; ptbin < NCaloPtValues; ptbin++) {
138 calo_pt = aux_CaloPt[ptbin];
139 if (calo_pt >= MinCaloPt[etabin] && calo_pt <= MaxCaloPt[etabin]) {
140 ref_pt = calo_pt * Correction[etabin]->Eval(calo_pt);
141 control_pt = ref_pt * (L3Response->Eval(ref_pt));
142 cor_rel[auxi] = control_pt / calo_pt;
143 correction_x[auxi] = calo_pt;
147 sprintf(
name,
"L2Correction%d", etabin);
149 sprintf(
func,
"[0]+[1]*log10(x)+[2]*pow(log10(x),2)");
151 sprintf(
func,
"[0]+[1]*log10(x)");
153 sprintf(
func,
"[0]");
154 correction_x[0] = 10;
155 correction_x[1] = 100;
160 g_L2Correction[etabin] =
new TGraph(auxi, correction_x, cor_rel);
161 L2Correction[etabin] =
new TF1(
name,
func, correction_x[0], correction_x[auxi - 1]);
162 L2Correction[etabin]->SetParameter(0, 0.);
163 L2Correction[etabin]->SetParameter(1, 0.);
164 L2Correction[etabin]->SetParameter(2, 0.);
165 L2Correction[etabin]->SetParameter(3, 0.);
166 L2Correction[etabin]->SetParameter(4, 0.);
167 L2Correction[etabin]->SetParameter(5, 0.);
168 g_L2Correction[etabin]->Fit(
name,
"RQ");
172 L2File.open(L2CorrectionTxtFilename.c_str());
173 L2File.setf(ios::right);
174 for (etabin = 0; etabin < NETA; etabin++) {
175 for (
i = 0;
i < 6;
i++)
176 L2_cor[
i] = L2Correction[etabin]->GetParameter(
i);
177 L2File << setw(11) << eta_vec[etabin] << setw(11) << eta_vec[etabin + 1] << setw(11) << (
int)8 << setw(12)
178 << MinCaloPt[etabin] << setw(12) << MaxCaloPt[etabin] << setw(13) << L2_cor[0] << setw(13) << L2_cor[1]
179 << setw(13) << L2_cor[2] << setw(13) << L2_cor[3] << setw(13) << L2_cor[4] << setw(13) << L2_cor[5] <<
"\n";
182 std::cout << L2CorrectionTxtFilename <<
" written...." << std::endl;
183 outf =
new TFile(L2OutputROOTFilename.c_str(),
"RECREATE");
184 for (etabin = 0; etabin < NETA; etabin++) {
185 sprintf(
name,
"Correction_EtaBin%d", etabin);
186 g_EtaCorrection[etabin]->Write(
name);
187 sprintf(
name,
"L2Correction_EtaBin%d", etabin);
188 g_L2Correction[etabin]->Write(
name);
key
prepare the HTCondor submission files and eventually submit them
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
bool HistoExists(std::vector< std::string > LIST, std::string hname)