Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TestCDBHistos.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TestCDBHistos.C
1 #include <cdbobjects/CDBHistos.h>
2 
3 R__LOAD_LIBRARY(libcdbobjects.so)
4 
5 void TestCDBHistos(const std::string &fname = "testhistos.root")
6 {
7  CDBHistos *cdbhistos = new CDBHistos(fname);
8  TH1 *h1 = new TH1F("h1","best 1d ever",100,0,1);
9  cdbhistos->registerHisto(h1);
10  TH2 *h2 = new TH2F("h2","best 2d ever",100,0,1,100,1,2);
11  cdbhistos->registerHisto(h2);
12  TH3 *h3 = new TH3F("h3","best 3d ever",100,0,1,100,1,2,100,2,3);
13  cdbhistos->registerHisto(h3);
14  TProfile *tp = new TProfile("tp","best tprofile ever",100,0,1,-10,10);
15  cdbhistos->registerHisto(tp);
16  for (int i = 0; i<100; i++)
17  {
18  h1->Fill(i/100.);
19  h2->Fill(i/100.,1+i/100.);
20  h3->Fill(i/100.,1+i/100.,2+i/100.,1.);
21  tp->Fill(i/100.,1+i/100.);
22  }
23  cdbhistos->WriteCDBHistos();
24  delete cdbhistos;
25 }
26 
27 CDBHistos *TestWrite(const std::string &fname = "testhistos.root")
28 {
29  CDBHistos *cdbhistos = new CDBHistos(fname);
30  return cdbhistos;
31 }
32 
33 CDBHistos *Read(const std::string &fname = "testhistos.root")
34 {
35  CDBHistos *cdbhistos = new CDBHistos(fname);
36  cdbhistos->LoadCalibrations();
37  cdbhistos->Print();
38  cdbhistos->getHisto("h1")->Draw();
39  return cdbhistos;
40 }