Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:24:01

0001 #include <cdbobjects/CDBHistos.h>
0002 
0003 #include <Rtypes.h>
0004 #include <TH1.h>
0005 #include <TH2.h>
0006 #include <TH3.h>
0007 #include <TProfile.h>
0008 
0009 R__LOAD_LIBRARY(libcdbobjects.so)
0010 
0011 void TestCDBHistos(const std::string &fname = "testhistos.root")
0012 {
0013   CDBHistos *cdbhistos = new CDBHistos(fname);
0014   TH1 *h1 = new TH1F("h1","best 1d ever",100,0,1);
0015   cdbhistos->registerHisto(h1);
0016   TH2 *h2 = new TH2F("h2","best 2d ever",100,0,1,100,1,2);
0017   cdbhistos->registerHisto(h2);
0018   TH3 *h3 = new TH3F("h3","best 3d ever",100,0,1,100,1,2,100,2,3);
0019   cdbhistos->registerHisto(h3);
0020   TProfile *tp = new TProfile("tp","best tprofile ever",100,0,1,-10,10);
0021   cdbhistos->registerHisto(tp);
0022   for (int i = 0; i<100; i++)
0023   {
0024     h1->Fill(i/100.);
0025     h2->Fill(i/100.,1+i/100.);
0026     h3->Fill(i/100.,1+i/100.,2+i/100.,1.);
0027     tp->Fill(i/100.,1+i/100.);
0028   }
0029   cdbhistos->WriteCDBHistos();
0030   delete cdbhistos;
0031 }
0032 
0033 CDBHistos *TestWrite(const std::string &fname = "testhistos.root")
0034 {
0035   CDBHistos *cdbhistos = new CDBHistos(fname);
0036   return cdbhistos;
0037 }
0038 
0039 CDBHistos *Read(const std::string &fname = "testhistos.root")
0040 {
0041   CDBHistos *cdbhistos = new CDBHistos(fname);
0042   cdbhistos->LoadCalibrations();
0043   cdbhistos->Print();
0044   cdbhistos->getHisto("h1")->Draw();
0045   return cdbhistos;
0046 }