11 #include "TObjString.h"
14 #include "TTreeReader.h"
15 #include "TTreeReaderValue.h"
16 #include "TTreeReaderArray.h"
19 #include <boost/format.hpp>
20 #include <boost/math/special_functions/sign.hpp>
30 int mod_arr[26] = {2,2,1,1,1,3,3,3,3,3,3,2,2,1,2,2,1,1,2,2,3,3,3,3,3,3};
31 float slot[26] = {5,6,1,3,2,12,10,11,9,8,7,1,2,4,8,7,6,5,4,3,1,3,2,4,6,5};
32 TTreeReader* myReader;
33 if (mod_arr[inFee] == 1)
35 myReader =
new TTreeReader(R1);
37 else if (mod_arr[inFee] == 2)
39 myReader =
new TTreeReader(R2);
41 else if (mod_arr[inFee] == 3)
43 myReader =
new TTreeReader(R3);
45 TTreeReaderValue<Float_t> FEE(*myReader,
"FEE");
46 TTreeReaderValue<Int_t> FEE_Chan(*myReader,
"FEE_Chan");
49 TTreeReaderValue<Double_t>
phi(*myReader,
"phi");
52 TTreeReaderValue<Double_t> PadR(*myReader,
"PadR");
56 if (sector < 12) phiOffset = 2*M_PI*((
double)sector/12.) - 2*M_PI*(1./12.)/2;
57 else phiOffset = 2*M_PI*(((
double)sector-12.)/12.) - 2*M_PI*(1./12.)/2;
59 while(myReader->Next())
61 if (slot[inFee]-1 == *FEE && channel == *FEE_Chan)
63 double x = (*PadR/10)*std::cos(*phi+phiOffset);
64 double y = (*PadR/10)*std::sin(*phi+phiOffset);
66 pos.SetX(x); pos.SetY(y); pos.SetZ(zPos);
71 pos.SetX(0); pos.SetY(0); pos.SetZ(0);
77 const string &
outfile =
"/sphenix/user/rosstom/test/TPCEventDisplay_10169.json",
78 const string &indir =
"/sphenix/user/rosstom/test/testFiles/",
79 const string &runName =
"pedestal-00010169"){
81 std::ofstream outdata;
84 cerr <<
"ERROR: file could not be opened" << endl;
88 outdata <<
"{\n \"EVENT\": {\n \"runid\": 1, \n \"evtid\": 1, \n \"time\": 0, \n \"type\": \"Collision\", \n \"s_nn\": 0, \n \"B\": 3.0,\n \"pv\": [0,0,0] \n },\n" << endl;
90 outdata <<
" \"META\": {\n \"HITS\": {\n \"INNERTRACKER\": {\n \"type\": \"3D\",\n \"options\": {\n \"size\": 5,\n \"color\": 16777215\n } \n },\n" << endl;
91 outdata <<
" \"TRACKHITS\": {\n \"type\": \"3D\",\n \"options\": {\n \"size\": 5,\n \"transparent\": 0.5,\n \"color\": 16777215\n } \n },\n" << endl;
92 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;
93 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;
94 outdata <<
" \"TRACKHITS\": [\n\n ";
96 TTree *
R1 =
new TTree(
"R1",
"TPC Sector Mapping for R1");
97 TTree *
R2 =
new TTree(
"R2",
"TPC Sector Mapping for R1");
98 TTree *
R3 =
new TTree(
"R3",
"TPC Sector Mapping for R1");
100 R1->ReadFile(
"/sphenix/u/rosstom/calibrations/TPC/Mapping/PadPlane/AutoPad-R1-RevA.sch.ChannelMapping.csv",
101 "Entry/I:Radius/I:Pad/I:U/I:G/I:Pin/C:PinColID/I:PinRowID/I:PadName/C:FEE/F:FEE_Connector/C:FEE_Chan/I:phi/D:x/D:y/D:PadX/D:PadY/D:PadR/D:PadPhi/D",
',');
102 R2->ReadFile(
"/sphenix/u/rosstom/calibrations/TPC/Mapping/PadPlane/AutoPad-R2-RevA-Pads.sch.ChannelMapping.csv",
103 "Entry/I:Radius/I:Pad/I:U/I:G/I:Pin/C:PinColID/I:PinRowID/I:PadName/C:FEE/F:FEE_Connector/C:FEE_Chan/I:phi/D:x/D:y/D:PadX/D:PadY/D:PadR/D:PadPhi/D",
',');
104 R3->ReadFile(
"/sphenix/u/rosstom/calibrations/TPC/Mapping/PadPlane/AutoPad-R3-RevA.sch.ChannelMapping.csv",
105 "Entry/I:Radius/I:Pad/I:U/I:G/I:Pin/C:PinColID/I:PinRowID/I:PadName/C:FEE/F:FEE_Connector/C:FEE_Chan/I:phi/D:x/D:y/D:PadX/D:PadY/D:PadR/D:PadPhi/D",
',');
107 bool firstClus =
true;
109 for (
int q = 0; q < 24; q++)
111 cout <<
"Processing sector " << q << endl;
117 string fileName = indir+
"TPC_ebdc"+sectorNumber+
"_"+runName+
"-0000.prdf_TPCRawDataTree.root";
119 TFile *TPCFile = TFile::Open(fileName.c_str());
120 TTreeReader myReader(
"SampleTree", TPCFile);
122 TTreeReaderValue<Int_t> nSamples(myReader,
"nSamples");
123 TTreeReaderValue<Int_t> fee(myReader,
"fee");
124 TTreeReaderArray<UShort_t> adcSamples(myReader,
"adcSamples");
125 TTreeReaderValue<Int_t> Channel(myReader,
"Channel");
127 while(myReader.Next())
129 int mod_arr[26]={2,2,1,1,1,3,3,3,3,3,3,2,2,1,2,2,1,1,2,2,3,3,3,3,3,3};
131 if (*nSamples <= 1)
continue;
135 for(
int adc_sam_no=0;adc_sam_no<*nSamples;adc_sam_no++)
139 adcMax = adcSamples[adc_sam_no];
140 adcMaxPos = adc_sam_no;
144 if (adcSamples[adc_sam_no] > adcMax)
146 adcMax = adcSamples[adc_sam_no];
147 adcMaxPos = adc_sam_no;
156 zPos = 105. - (adcMaxPos/((
double)*nSamples-1.))*105.;
160 zPos = -105. + (adcMaxPos/((
double)*nSamples-1.))*105.;
165 zeroVec.SetX(0);zeroVec.SetY(0);zeroVec.SetZ(0);
166 if (binXYZ == zeroVec)
continue;
170 if (firstClus) firstClus =
false;
189 outdata <<
"],\n \"JETS\": [\n ]\n }," << endl;
190 outdata <<
"\"TRACKS\": {" << endl;
191 outdata <<
"\""<<
"INNERTRACKER"<<
"\": [";
192 outdata <<
"]" << endl;
193 outdata <<
"}" << endl;
194 outdata <<
"}" << endl;