Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
runCCPi0Loop.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file runCCPi0Loop.C
1 #include <calib_emc_pi0/CaloCalibEmc_Pi0.h>
2 //#include "GetTChainMacro.C"
3 #include <fstream>
4 #include <string>
5 #include "TChain.h"
6 #include "TTree.h"
7 #include "TString.h"
8 
9 
10 
11 void runCCPi0Loop(int nevents = -1, const char *ifile="", const char *ofile="")
12 {
13  R__LOAD_LIBRARY(libcalibCaloEmc_pi0.so)
14 
15  CaloCalibEmc_Pi0 calo_obj("CaloCalibEmc_Pi0", ofile);
16  calo_obj.InitRun(0);
17  TTree * intree1 = GetTChainMacro(ifile);
18  // calo_obj.InitializeBadTowers();
19  calo_obj.Loop(nevents, ifile, intree1);
20  calo_obj.End(0);
21 }
22 
23 
24 TTree* GetTChainMacro(TString ifile="")
25 {
26  ifstream inFile;
27  inFile.open(ifile, ios::in); // open to read
28  if (!inFile)
29  {
30  cerr << "Unable to open file:\n ";
31  exit(1);
32  }
33 
34  TChain *pitree = new TChain("_eventTree");
35  string root_file;
36  int lines=0;
37  while (std::getline(inFile, root_file))
38  {
39  pitree->Add(root_file.c_str());
40  lines += 1;
41  }
42  printf("total lines: %d\n",lines);
43  inFile.close();
44 
45  return (TTree *) pitree;
46 }