File indexing completed on 2025-08-06 08:21:02
0001 #include"cdbHistConv.C"
0002
0003
0004 void rescaleTSC(TH2F* h_tsc,TH2F* h_cos);
0005 void checkTsc(TH2F* h);
0006
0007 void genCDBTTree(){
0008
0009
0010 TFile* fin = new TFile("HCal_newcalib_simprecalib_template.root");
0011 TH2F* h_ohcal = (TH2F*) fin->Get("h_2Dohcal_calib");
0012 TH2F* h_ihcal = (TH2F*) fin->Get("h_2Dihcal_calib");
0013
0014
0015 TFile* ftemp = new TFile("/sphenix/u/bseidlitz/work/macros/calibrations/calo/hcal_cosmics/tempAna/y23Ana/temp_corr_24to23.root");
0016 TH2F* h_temp_corr_ohcal = (TH2F*) ftemp->Get("h_temp_corr_tbt_ohcal");
0017 TH2F* h_temp_corr_ihcal = (TH2F*) ftemp->Get("h_temp_corr_tbt_ihcal");
0018 h_ohcal->Multiply(h_temp_corr_ohcal);
0019 h_ihcal->Multiply(h_temp_corr_ihcal);
0020
0021
0022 TFile* ftsc_ohcal = new TFile("../fitout_hcalout.root");
0023 TFile* ftsc_ihcal = new TFile("../fitout_hcalin.root");
0024 TH2F* h_tsc_corr_ohcal = (TH2F*) ftsc_ohcal->Get("corrPat");
0025 TH2F* h_tsc_corr_ihcal = (TH2F*) ftsc_ihcal->Get("corrPat");
0026
0027 checkTsc(h_tsc_corr_ohcal);
0028 checkTsc(h_tsc_corr_ihcal);
0029 rescaleTSC(h_tsc_corr_ohcal,h_ohcal);
0030 rescaleTSC(h_tsc_corr_ihcal,h_ihcal);
0031
0032
0033
0034
0035
0036 string outputfile = "ohcal_cdb_calib.root";
0037 string fieldName = "ohcal_abscalib_mip";
0038 histToCaloCDBTree( outputfile, fieldName, 1, h_ohcal);
0039
0040 outputfile = "ihcal_cdb_calib.root";
0041 fieldName = "ihcal_abscalib_mip";
0042 histToCaloCDBTree( outputfile, fieldName, 1, h_ihcal);
0043
0044
0045 }
0046
0047
0048 void checkTsc(TH2F* h){
0049
0050 for (int ie=0; ie<24; ie++)
0051 for (int ip=0; ip<64; ip++)
0052 if (h->GetBinContent(ie+1,ip+1) < 0.5 || h->GetBinContent(ie+1,ip+1) > 1.3)
0053 h->SetBinContent(ie+1,ip+1,1);
0054
0055
0056 }
0057
0058
0059 void rescaleTSC(TH2F* h_tsc,TH2F* h_cos){
0060
0061 int bin1l = 26;
0062 int bin1h = 37;
0063 int bin2h = 58;
0064 int bin2l = 5;
0065 float etaAvg_tsc[24] = {0};
0066 float etaAvg_cos[24] = {0};
0067
0068 for (int ie=0; ie<24; ie++){
0069 int c = 0;
0070 for (int ip=0; ip<64; ip++){
0071 if ( ip <= bin2l || (ip >= bin1l && ip <= bin1h) || ip >= bin2h){
0072 etaAvg_tsc[ie] += h_tsc->GetBinContent(ie+1,ip+1);
0073 etaAvg_cos[ie] += h_cos->GetBinContent(ie+1,ip+1);
0074 c++;
0075 }
0076 }
0077 etaAvg_tsc[ie] /= c;
0078 cout << ie << " " << etaAvg_tsc[ie] << endl;
0079 etaAvg_cos[ie] /= c;
0080 for (int ip=0; ip<64; ip++){
0081 float val = h_tsc->GetBinContent(ie+1,ip+1);
0082 val /= etaAvg_tsc[ie];
0083 h_tsc->SetBinContent(ie+1,ip+1,val);
0084 }
0085 }
0086
0087
0088
0089 }
0090