Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hadd_Cosmic_SIM_HCAL.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file hadd_Cosmic_SIM_HCAL.C
1 #include "TFile.h"
2 #include "TString.h"
3 #include "TH1F.h"
4 #include "TCanvas.h"
5 #include "TLegend.h"
6 #include "TF1.h"
7 #include <string>
8 
9 void hadd_Cosmic_SIM_HCAL(string det = "HCALIN")
10 {
11  int hbdchanIHC[4][4] = {{4, 8, 12, 16},
12  {3, 7, 11, 15},
13  {2, 6, 10, 14},
14  {1, 5, 9, 13}};
15 
16  TH1F *h_hcal_tower_sim[16];
17 
18  TFile *File_InPut[4];
19  string HistName;
20  for(int i_col = 0; i_col < 4; ++i_col)
21  {
22  string inputfile = Form("/sphenix/user/xusun/software/data/cosmic/TowerCalibAna/Proto4TowerInfoSIM_%s_%d.root",det.c_str(),i_col);
23  File_InPut[i_col] = TFile::Open(inputfile.c_str());
24  for(int i_row = 0; i_row < 4; ++i_row)
25  {
26  int i_tower = hbdchanIHC[i_row][i_col]-1;
27  if(det == "HCALIN") HistName = Form("h_mHCALIN_SIM_twr_%d",i_tower);
28  if(det == "HCALOUT") HistName = Form("h_mHCALOUT_SIM_twr_%d",i_tower);
29  h_hcal_tower_sim[i_tower] = (TH1F*)File_InPut[i_col]->Get(HistName.c_str())->Clone();
30  }
31  }
32 
33  string outputfile = Form("/sphenix/user/xusun/software/data/cosmic/TowerCalibAna/Proto4TowerInfoSIM_%s.root",det.c_str());
34  TFile *File_OutPut = new TFile(outputfile.c_str(),"RECREATE");
35  File_OutPut->cd();
36  for(int i_tower = 0; i_tower < 16; ++i_tower)
37  {
38  h_hcal_tower_sim[i_tower]->Write();
39  }
40  File_OutPut->Close();
41 }