File indexing completed on 2025-08-06 08:21:00
0001 #include <GlobalVariables.C>
0002 #include <cdbobjects/CDBTTree.h> // for CDBTTree
0003 #include <ffamodules/CDBInterface.h>
0004 #include <phool/recoConsts.h>
0005 #include "TowerInfo.h"
0006 #include "TowerInfoDefs.h"
0007
0008 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
0009
0010 R__LOAD_LIBRARY(libcdbobjects)
0011 R__LOAD_LIBRARY(libphool.so)
0012 R__LOAD_LIBRARY(libcalo_reco.so)
0013 R__LOAD_LIBRARY(libcalo_io.so)
0014
0015 void TSCtoCDBTTree(const char * infile, const char * outputfile)
0016 {
0017
0018 bool chk4file = gSystem->AccessPathName(infile);
0019 TFile *f = nullptr;
0020
0021 if(!chk4file)
0022 {
0023 f = new TFile(infile,"READ");
0024 }
0025 else
0026 {
0027 std::cout << "File " << infile << " cant be found in current directory." << std::endl;
0028 exit(0);
0029 }
0030
0031
0032 CDBTTree *cdbttree = new CDBTTree(outputfile);
0033
0034
0035 TH2F *cp = (TH2F *)f->Get("corrPat");
0036
0037 for(int i = 0; i < 96 ; i++)
0038 {
0039 for(int j = 0; j < 256; j++)
0040 {
0041 unsigned int key = TowerInfoDefs::encode_emcal(i,j);
0042 float gain = (1.0 / cp->GetBinContent(i+1,j+1) );
0043 if (cp->GetBinContent(i+1,j+1)==0) gain = 0;
0044 if (isnan(cp->GetBinContent(i+1,j+1))) {gain = 0; cout << i << "," << j << endl;}
0045 cdbttree->SetFloatValue(key,"Femc_datadriven_qm1_correction",gain);
0046 }
0047 }
0048
0049 cdbttree->Commit();
0050 cdbttree->WriteCDBTTree();
0051
0052 f->Close();
0053 delete f;
0054 delete cdbttree;
0055
0056 }