Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TSCtoCDBTTree.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TSCtoCDBTTree.C
1 #include <GlobalVariables.C>
2 #include <cdbobjects/CDBTTree.h> // for CDBTTree
4 #include <phool/recoConsts.h>
5 #include "TowerInfo.h"
6 #include "TowerInfoDefs.h"
7 
8 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
9 
10 R__LOAD_LIBRARY(libcdbobjects)
11 R__LOAD_LIBRARY(libphool.so)
12 R__LOAD_LIBRARY(libcalo_reco.so)
13 R__LOAD_LIBRARY(libcalo_io.so)
14 
15 void TSCtoCDBTTree(const char * infile, const char * outputfile)
16 {
17 
18  bool chk4file = gSystem->AccessPathName(infile);
19  TFile *f = nullptr;
20 
21  if(!chk4file)
22  {
23  f = new TFile(infile,"READ");
24  }
25  else
26  {
27  std::cout << "File " << infile << " cant be found in current directory." << std::endl;
28  exit(0);
29  }
30 
31  //write to cdb tree
32  CDBTTree *cdbttree = new CDBTTree(outputfile);
33 
34  //gain values lie in the 2d histogram called corrPat
35  TH2F *cp = (TH2F *)f->Get("corrPat");
36 
37  for(int i = 0; i < 96 ; i++)
38  {
39  for(int j = 0; j < 256; j++)
40  {
41  unsigned int key = TowerInfoDefs::encode_emcal(i,j);
42  float gain = (1.0 / cp->GetBinContent(i+1,j+1) );
43  if (cp->GetBinContent(i+1,j+1)==0) gain = 0;
44  if (isnan(cp->GetBinContent(i+1,j+1))) {gain = 0; cout << i << "," << j << endl;}
45  cdbttree->SetFloatValue(key,"Femc_datadriven_qm1_correction",gain);
46  }
47  }
48 
49  cdbttree->Commit();
50  cdbttree->WriteCDBTTree();
51  //cdbttree->Print();
52  f->Close();
53  delete f;
54  delete cdbttree;
55 
56 }//end macro