2 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
15 #include <caloreco/CaloTowerCalib.h>
16 #include <caloreco/RawClusterBuilderTemplate.h>
17 #include <calib_emc_pi0/CaloCalibEmc_Pi0.h>
30 R__LOAD_LIBRARY(libfun4all.so)
31 R__LOAD_LIBRARY(libfun4allraw.so)
32 R__LOAD_LIBRARY(libcdbobjects)
33 R__LOAD_LIBRARY(libcalo_reco.so)
35 R__LOAD_LIBRARY(libcalibCaloEmc_pi0.so)
47 const int iteration = 1 ,
48 const char *
fname =
"pi0input.list",
49 const char * inputCDBfnameIn =
"inputcdb1.root",
50 const char * outfileloc1 =
"./",
51 const char * outfileloc2 =
"./")
59 gSystem->Load(
"libg4dst");
81 inputCDBfname = defout2 +
"/cdbtree" +
std::to_string(iteration-1) +
".root";
87 TString infiletstr(
fname);
88 if (infiletstr.Contains(
".list"))
98 intrue2->
AddFile(
"updated_geo.root");
135 emc_prof +=
"/EmcProfile/CEMCprof_Thresh30MeV.root";
151 cout <<
"successful registration of pi0 " << endl;
170 calo_obj2.
Get_Histos(outloopfile.c_str() , outfitfile.c_str());
175 make_csv(outfitfile.c_str(), outcsvfile.c_str());
191 cerr <<
"Unable to open file:\n ";
195 TChain *pitree =
new TChain(
"_eventTree");
198 while (std::getline(inFile, root_file))
200 pitree->Add(root_file.c_str());
203 printf(
"total lines: %d\n",lines);
206 return (TTree *) pitree;
211 void make_csv(
const char * input_filechar,
const char * output_filechar)
221 TFile *
file = TFile::Open(input_file.c_str(),
"READ");
224 std::ofstream csvFile(output_file.c_str());
227 TTree *
tree = (TTree*)file->Get(
"nt_corrVals");
230 Long64_t nEntries = tree->GetEntries();
232 if (nEntries != 24576) {std::cout <<
"The number of entries does not match with EMCal. The number is " << nEntries <<
" ." << std::endl;}
236 TObjArray *branches = tree->GetListOfBranches();
241 csvFile <<
"phibin" <<
" , " <<
"etabin" <<
" , " <<
"calib-factor" << std::endl;
243 for (
int j = 0;
j < nEntries;
j++)
252 TBranch *branch = (TBranch*)branches->At(
b);
253 TLeaf *leaf = (TLeaf*)branch->GetListOfLeaves()->At(0);
255 if (
b == 0) {ieta = leaf->GetValue(0);}
256 if (
b == 1) {iphi = leaf->GetValue(0);}
257 if (
b == 3) {agg_corr_val = leaf->GetValue(0);}
259 csvFile << iphi <<
" , " << ieta <<
" , " << agg_corr_val <<
"\n";
266 std::cout <<
"All Done making csvfile:" << output_file << std::endl;
272 const char * output_file1)
280 std::cout <<
"start making CDBTree: " << output_file1 << std::endl;
282 float corrArray[256][96];
283 string line, cell1, cell2, cell3;
286 ifstream
file(input_file.c_str());
289 std::getline(
file, line);
290 while(getline(
file, line))
292 stringstream lineStream(line);
294 getline(lineStream, cell1,
',');
297 getline(lineStream, cell2,
',');
300 getline(lineStream, cell3,
',');
303 corrArray[std::stoi(cell1)][std::stoi(cell2)] = std::stof(cell3);
319 for(
int iphi=0; iphi<256; iphi++){
320 for(
int ieta=0; ieta<96; ieta++){
321 int key = iphi + (ieta << 16);
322 cdbttree->
SetFloatValue(key,
"cemc_pi0_abs_calib", corrArray[iphi][ieta]);
330 std::cout <<
"cdb success " << std::endl;