8 #include "TObjString.h"
12 #include <boost/format.hpp>
13 #include <boost/math/special_functions/sign.hpp>
21 const string &
infile =
"/sphenix/u/rosstom/macros/TrackingProduction/cosmics25926_ntup.root",
22 const string &runNumber =
"25926",
23 int nEventsToRun = 5){
25 TFile *ntpFile = TFile::Open(
infile.c_str());
26 TTree *hitTree = (TTree*)ntpFile->Get(
"ntp_cluster");
30 hitTree->SetBranchAddress(
"event",&event);
31 hitTree->SetBranchAddress(
"x",&x);
32 hitTree->SetBranchAddress(
"y",&y);
33 hitTree->SetBranchAddress(
"z",&z);
34 hitTree->SetBranchAddress(
"adc",&adc);
36 Int_t currentEvent = 0;
39 std::ofstream outdata;
42 cerr <<
"ERROR: file could not be opened" << endl;
45 outdata <<
"{\n \"EVENT\": {\n \"runid\":" << runNumber <<
", \n \"evtid\": 1, \n \"time\": 0, \n \"timeStr\": \"2023-08-23, 15:23:30 EST\", \n \"type\": \"Cosmics\", \n \"s_nn\": 0, \n \"B\": 0.0,\n \"pv\": [0,0,0],\n \"runstats\": [ \n \"sPHENIX Time Projection Chamber\", \"2023-08-23, Run 25926 - Event 1, Clusters\", \"Cosmics Data\"] \n },\n" << endl;
47 outdata <<
" \"META\": {\n \"HITS\": {\n \"INNERTRACKER\": {\n \"type\": \"3D\",\n \"options\": {\n \"size\": 2,\n \"color\": 16777215\n } \n },\n" << endl;
48 outdata <<
" \"TRACKHITS\": {\n \"type\": \"3D\",\n \"options\": {\n \"size\": 2,\n \"transparent\": 0.5,\n \"color\": 16777215\n } \n },\n" << endl;
49 outdata <<
" \"JETS\": {\n \"type\": \"JET\",\n \"options\": {\n \"rmin\": 0,\n \"rmax\": 78,\n \"emin\": 0,\n \"emax\": 30,\n \"color\": 16777215,\n \"transparent\": 0.5 \n }\n }\n }\n }\n," << endl;
50 outdata <<
" \"HITS\": {\n \"CEMC\":[{\"eta\": 0, \"phi\": 0, \"e\": 0}\n ],\n \"HCALIN\": [{\"eta\": 0, \"phi\": 0, \"e\": 0}\n ],\n \"HCALOUT\": [{\"eta\": 0, \"phi\": 0, \"e\": 0}\n \n ],\n\n" << endl;
51 outdata <<
" \"TRACKHITS\": [\n\n ";
53 for(
int i = 0;
i < hitTree->GetEntries();
i++)
57 if (event != currentEvent)
59 if (event == currentEvent + 1)
61 outdata <<
"],\n \"JETS\": [\n ]\n }," << endl;
62 outdata <<
"\"TRACKS\": {" << endl;
63 outdata <<
"\""<<
"INNERTRACKER"<<
"\": [";
64 outdata <<
"]" << endl;
65 outdata <<
"}" << endl;
66 outdata <<
"}" << endl;
71 if (currentEvent >= nEventsToRun)
break;
76 cerr <<
"ERROR: file could not be opened" << endl;
79 outdata <<
"{\n \"EVENT\": {\n \"runid\":" << runNumber <<
", \n \"evtid\": 1, \n \"time\": 0, \n \"timeStr\": \"2023-08-23, 15:23:30 EST\", \n \"type\": \"Cosmics\", \n \"s_nn\": 0, \n \"B\": 0.0,\n \"pv\": [0,0,0],\n \"runstats\": [ \n \"sPHENIX Time Projection Chamber\", \"2023-08-23, Run 25926 - Event" << currentEvent+1 <<
", Clusters\", \"Cosmics Data\"] \n },\n" << endl;
81 outdata <<
" \"META\": {\n \"HITS\": {\n \"INNERTRACKER\": {\n \"type\": \"3D\",\n \"options\": {\n \"size\": 2,\n \"color\": 16777215\n } \n },\n" << endl;
82 outdata <<
" \"TRACKHITS\": {\n \"type\": \"3D\",\n \"options\": {\n \"size\": 2,\n \"transparent\": 0.5,\n \"color\": 16777215\n } \n },\n" << endl;
83 outdata <<
" \"JETS\": {\n \"type\": \"JET\",\n \"options\": {\n \"rmin\": 0,\n \"rmax\": 78,\n \"emin\": 0,\n \"emax\": 30,\n \"color\": 16777215,\n \"transparent\": 0.5 \n }\n }\n }\n }\n," << endl;
84 outdata <<
" \"HITS\": {\n \"CEMC\":[{\"eta\": 0, \"phi\": 0, \"e\": 0}\n ],\n \"HCALIN\": [{\"eta\": 0, \"phi\": 0, \"e\": 0}\n ],\n \"HCALOUT\": [{\"eta\": 0, \"phi\": 0, \"e\": 0}\n \n ],\n\n" << endl;
85 outdata <<
" \"TRACKHITS\": [\n\n ";
89 std::cout <<
"Error: hit for a previous event placed later in the ntuple" << std::endl;
96 if (firstHit) firstHit =
false;
113 std::cout <<
"Done" << std::endl;