Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tsdst_plus_tsfit.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file tsdst_plus_tsfit.C
1 #pragma once
2 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
3 #include <fun4all/SubsysReco.h>
8 //#include <rawwaveformtowerbuilder/RawWaveformTowerBuilder.h>
10 #include <fun4all/Fun4AllUtils.h>
11 
12 #include <litecaloeval/LiteCaloEval.h>
13 #include <caloreco/CaloTowerCalib.h>
14 #include <caloreco/RawClusterBuilderTemplate.h>
15 //#include <calib_emc_pi0/CaloCalibEmc_Pi0.h>
16 
17 #include <phool/recoConsts.h>
18 
20 #include "mergeCDBTTrees.C"
21 #include "TSCtoCDBTTree.C"
22 
23 R__LOAD_LIBRARY(libfun4all.so)
24 R__LOAD_LIBRARY(libfun4allraw.so)
25 R__LOAD_LIBRARY(libcalo_reco.so)
26 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
27 //R__LOAD_LIBRARY(libcalibCaloEmc_pi0.so)
28 
29 
30 
31 #endif
32 
33 // to get files from my local area
34 void tsdst_plus_tsfit(int nevents = 1, const char *fname = "input.list", const char * outfile = "defout.root", const char * fitoutfile = "deffitout.root")
35 //,const int runNumber)
36 {
37 
39 
40 
42 
43  TString infiletstr(fname);
44  if (infiletstr.Contains(".list"))
45  in->AddListFile(fname);
46  else
47  in->fileopen(fname);
48 
49  se->registerInputManager(in);
50 
51 
52  // initalize CDB to pull what we "think" is the "base" calibration
53  // into a local cdbttree so we can update it with the tower slope output
55  ifstream file(fname);
56  string first_file;
57  getline(file, first_file);
58 
59  pair<int, int> runseg = Fun4AllUtils::GetRunSegment(first_file);
60  int runnumber = runseg.first;
61  cout << "run number = " << runnumber << endl;
62 
63  // global tag
64  rc->set_StringFlag("CDB_GLOBALTAG","MDC2");
65  // // 64 bit timestamp
66  rc->set_uint64Flag("TIMESTAMP",runnumber);
67 
68  string local_cdb_copy_name = "local_cdb_copy.root";
69  createLocalEMCalCalibFile(local_cdb_copy_name.c_str(),runnumber);
70 
71 
72  //JF to Blair Nov 23 -- leaving these next blocks, similar code
73  // would be needed if we run a second iteration of towerslope
74  // which is fairly possible.
75 
76  //CaloTowerBuilder *ca = new CaloTowerBuilder();
77 
78  // // recoConsts *rc = recoConsts::instance();
79  // // rc->set_StringFlag("CDB_GLOBALTAG","ProdA_2023"); // this points to the global tag in the CDB
80  // // The calibrations have a validity range set by the beam clock which is not read out of the prdfs as of now
81  //rc->set_uint64Flag("TIMESTAMP",runNumber);
82 
83 
84  // CaloTowerCalib *calib = new CaloTowerCalib("CEMCCALIB");
85  // // calib->setCalibName("cemc_abscalib_cosmic");// these two lines are needed to choose your own calibration
86  // // calib->setFieldName("cemc_abscalib_cosmic");
87  // calib->set_detector_type(CaloTowerCalib::CEMC);
88  // se->registerSubsystem(calib);
89 
90  std::cout << "in tow dst " << std::endl;
91 
92 
93  LiteCaloEval *eval7e = new LiteCaloEval("CEMCEVALUATOR2", "CEMC",outfile);
94  // LiteCaloEval *eval = new LiteCaloEval("HOCEMCEVALUATOR2", "HCALOUT", outputfile.c_str());
95  // eval->Verbosity(verbosity);
97  eval7e->setInputTowerNodeName("TOWERINFO_CALIB_CEMC");
98  //eval->CaloType(LiteCaloEval::HCALOUT);
99  se->registerSubsystem(eval7e);
100 
101 
102  se->run(nevents);
103 
104  se->End();
105  se->PrintTimer();
106 
107 
108  LiteCaloEval modlce;
109 
110  //reflce.CaloType(LiteCaloEval::CEMC);
112 
113 
114  modlce.Get_Histos(outfile,fitoutfile);
115 
116  modlce.m_myminbin = 8; // this really is min bin (no -1/+1 needed)
117  // but not sure if for summer 23 this should
118  // be 8 or 9 I think 8 according to Joey Clement
119  // on ~Nov 1, mattermost post
120  modlce.m_mymaxbin = 95 + 1 ; // this actually means maxbin is 1 less
121  // modlce.m_mymaxbin = 95+1; // so that means maxbin is 95 which is
122  // really the max eta bin for emc, indexed 0 through 95
123 
124 
125  modlce.setFitMin(0.12);
126  modlce.setFitMax(0.7);
127 
128  modlce.FitRelativeShifts(&modlce,110);
129 
130 
131  // create the cdbttree from tsc output andd multiply the corrections
132  // into the base calibration to pickup for pi0 first iteration
133  TSCtoCDBTTree(fitoutfile,"tsc_output_cdb.root");
134  mergeCDBTTrees("tsc_output_cdb.root",local_cdb_copy_name.c_str(),"calib_post_TSC.root");
135 
136  gSystem->Exit(0);
137 }