Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:12:20

0001 #pragma once
0002 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
0003 #include <fun4all/SubsysReco.h>
0004 #include <fun4all/Fun4AllServer.h>
0005 #include <fun4all/Fun4AllInputManager.h>
0006 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0007 #include <fun4all/Fun4AllDstInputManager.h>
0008 //#include <rawwaveformtowerbuilder/RawWaveformTowerBuilder.h>
0009 #include <fun4all/Fun4AllDstOutputManager.h>
0010 #include <fun4all/Fun4AllUtils.h>
0011 
0012 #include <cdbobjects/CDBTTree.h>  // for CDBTTree
0013 #include "TowerInfo.h"
0014 #include "TowerInfoDefs.h"
0015 
0016 #include <litecaloeval/LiteCaloEval.h>
0017 #include <caloreco/CaloTowerCalib.h>
0018 #include <caloreco/RawClusterBuilderTemplate.h>
0019 
0020 #include <phool/recoConsts.h>
0021 
0022 #include "/sphenix/u/bseidlitz/work/macros/calibrations/calo/calib_nov23/towerslope/TSCtoCDBTTree.C"
0023 
0024 R__LOAD_LIBRARY(libfun4all.so)
0025 R__LOAD_LIBRARY(libfun4allraw.so)
0026 R__LOAD_LIBRARY(libcalo_reco.so)
0027 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
0028 R__LOAD_LIBRARY(libcalo_io.so)
0029 R__LOAD_LIBRARY(libcdbobjects)
0030 
0031 void mergeCDBTTrees(const char * infile1, const char * infile2, const char * outputfile);
0032 
0033 #endif
0034 
0035 //void doTscFit(int nevents = 0, const char *fname = "input.list", const char * outfile =  "defout.root", const char * fitoutfile = "deffitout.root")
0036 void doTscFit(const std::string &hist_fname = "parallel_test/combine_out/out1.root", const std::string &calib_fname = "parallel_test/local_cdb_copy.root")
0037 {
0038   //Fun4AllServer *se = Fun4AllServer::instance();
0039 
0040   string fitoutfile = "tsc_fitout.root";
0041 
0042   LiteCaloEval modlce;
0043   modlce.CaloType(LiteCaloEval::CEMC);
0044   modlce.Get_Histos(hist_fname.c_str(),fitoutfile.c_str());
0045   modlce.m_myminbin =  8;  
0046   modlce.m_mymaxbin =  95 + 1 ; 
0047   modlce.setFitMin(0.12);
0048   modlce.setFitMax(0.7);
0049   modlce.FitRelativeShifts(&modlce,110);
0050 
0051   // create the cdbttree from tsc output andd multiply the corrections 
0052   // into the base calibration to pickup for pi0 first iteration
0053   TSCtoCDBTTree(fitoutfile.c_str(),"tsc_output_cdb.root");
0054   mergeCDBTTrees("tsc_output_cdb.root",calib_fname.c_str(),calib_fname.c_str());
0055 
0056   size_t pos = calib_fname.find_last_of('.');
0057   string f_calib_save_name = calib_fname;
0058   f_calib_save_name.insert(pos,"_postTSC");
0059 
0060   TFile* f_calib_mod = new TFile(calib_fname.c_str());
0061   f_calib_mod->Cp(f_calib_save_name.c_str());
0062 
0063   gSystem->Exit(0);
0064 }
0065 
0066 
0067 void mergeCDBTTrees(const char * infile1, const char * infile2, const char * outputfile)
0068 {
0069 
0070   CDBTTree *cdbttree1 = new CDBTTree(infile1);  
0071   CDBTTree *cdbttree2 = new CDBTTree(infile2);  
0072   CDBTTree *cdbttreeOut = new CDBTTree(outputfile);
0073 
0074   string m_fieldname = "Femc_datadriven_qm1_correction";
0075 
0076   for(int i = 0; i < 96 ; i++)
0077   {
0078     for(int j = 0; j < 256; j++)
0079     {
0080       unsigned int key = TowerInfoDefs::encode_emcal(i,j);
0081       float val1 = cdbttree1->GetFloatValue(key, m_fieldname);
0082       float val2 = cdbttree2->GetFloatValue(key, m_fieldname);
0083       cdbttreeOut->SetFloatValue(key,m_fieldname,val1*val2);
0084     }
0085   }
0086 
0087   cdbttreeOut->Commit();
0088   cdbttreeOut->WriteCDBTTree();
0089   delete cdbttreeOut;
0090   delete cdbttree1;
0091   delete cdbttree2;
0092 
0093 }//end macro
0094