12 #include "TApplication.h" 26 if (detector ==
"NearDet") {
28 }
else if (detector ==
"FarDet") {
30 }
else if (detector ==
"TestBeam") {
44 if (detector ==
"NearDet") {
46 }
else if (detector ==
"FarDet") {
48 }
else if (detector ==
"TestBeam") {
64 std::vector<std::vector<int>> FEBList;
66 std::ifstream FEBFile(FEBListPath);
71 std::cout <<
"The file could not be opened\n";
75 std::stringstream FEBFileStream;
76 FEBFileStream << FEBFile.rdbuf();
81 while (FEBFileStream){
89 FEBFileStream >> aDiblock >> aDCM >> anFEB;
91 std::vector<int> thisFEB = {aDiblock, aDCM, anFEB};
92 FEBList.push_back(thisFEB);
104 sprintf(rootFile,
"%s/DSO_apd-%d-%02d-%02d-%02d.root", plotOutDir.c_str(), detID, aDB, aDCM, aFEB);
112 std::vector<int32_t> rawph[32];
113 std::vector<uint32_t> rawticks[32];
121 hahacolor[1] = 920 + 2;
122 hahacolor[2] = 632 - 7;
123 hahacolor[3] = 900 + 5;
124 hahacolor[4] = 400 - 6;
126 hahacolor[6] = 616 + 2;
127 hahacolor[7] = 616 - 6;
128 hahacolor[8] = 800 + 10;
129 hahacolor[9] = 880 - 7;
131 hahacolor[11] = 600 + 2;
132 hahacolor[12] = 600 - 3;
133 hahacolor[13] = 600 + 3;
134 hahacolor[14] = 600 - 6;
135 hahacolor[15] = 860 + 7;
136 hahacolor[16] = 432 + 1;
137 hahacolor[17] = 880 - 5;
138 hahacolor[18] = 432 - 6;
140 hahacolor[20] = 416 + 3;
141 hahacolor[21] = 416 - 6;
142 hahacolor[22] = 416 + 2;
143 hahacolor[23] = 820 - 5;
144 hahacolor[24] = 820 - 7;
145 hahacolor[25] = 820 + 4;
146 hahacolor[26] = 400 + 2;
147 hahacolor[27] = 400 + 3;
148 hahacolor[28] = 800 + 7;
149 hahacolor[29] = 632 + 2;
150 hahacolor[30] = 860 + 7;
151 hahacolor[31] = 900 + 6;
152 hahacolor[32] = 800 + 4;
160 TH2F* hthresholdmap =
new TH2F(
"hthreshold",
"", 8, -0.5, 7.5, 4, -0.5, 3.5);
161 TH2F* hthreshold2map =
new TH2F(
"hthreshold2",
"", 8, -0.5, 7.5, 4, -0.5, 3.5);
164 TFile
file(rootFile,
"RECREATE");
168 infile = fopen(dsoFile.c_str(),
"r");
170 ret_status = fscanf(infile,
"%d, %d, %u, %u, %*x, %*x, %*x\n", &thefeb, &pix, &ph, &time);
171 if (ret_status<0)
break;
172 rawph[pix].push_back(ph);
173 rawticks[pix].push_back(time);
179 step = rawticks[pix].at(1) - rawticks[pix].at(0);
180 if (rawticks[pix].at(2) == (rawticks[pix].at(1)+step))
184 float width = 15.625e-9*
step;
185 float fftmax = 1.0/width;
186 for (
int p=0;
p<32;
p++) {
188 std::ostringstream sstrd;
189 sstrd << aDB <<
"-" << aDCM <<
"-" << aFEB <<
":" <<
p;
190 hadcpix[
p] =
new TH1F((
"hadcpix" + (sstrd.str())).c_str(),
";DCS", 300, -150, 150);
191 hadctpix[
p] =
new TH1F((
"hadctpix" + (sstrd.str())).c_str(),
";sample;DCS", thenum, -0.5 * width, (thenum - 0.5) * width);
192 hdsotpix[
p] =
new TH1F((
"hdsotpix" + (sstrd.str())).c_str(),
";sample;DSO", thenum, -0.5 * width, (thenum - 0.5) * width);
193 hfftpix[
p] =
new TH1F((
"hfftpix" + (sstrd.str())).c_str(),
";frequency [Hz]", thenum, 0.0, fftmax);
195 cpix[
p] =
new TCanvas((
"cpix" + (sstrd.str())).c_str(),
"", 400, 500);
197 for (
int j=0;
j<thenum-3;
j++) {
198 hadcpix[
p]->Fill(rawph[p][
j + 3] - rawph[p][
j]);
199 hadctpix[
p]->Fill(j * width,(rawph[p][j + 3] - rawph[p][j]));
200 hdsotpix[
p]->Fill(j * width,(rawph[p][j]));
203 TF1 *mygaus =
new TF1(
"mygaus",
"gaus");
205 int status1 =
int(hadcpix[p]->
Fit(mygaus));
206 int fthreshold = 0.0;
208 if( status1 && hadcpix[p]->GetRMS() < mygaus->GetParameter(2))
209 fthreshold = (
int)4.0 * mygaus->GetParameter(2);
211 fthreshold = (
int)4.0 * hadcpix[p]->GetRMS();
216 int mapj = (
int)((p - mapi) / 8);
218 hthresholdmap->Fill(mapi, mapj, fthreshold);
219 hadcpix[
p]->SetLineColor(hahacolor[p]);
220 hadctpix[
p]->SetLineColor(hahacolor[p]);
221 hdsotpix[
p]->SetLineColor(hahacolor[p]);
223 hdsotpix[
p]->FFT(hfftpix[p],
"MAG");
224 hfftpix[
p]->Scale(1.0 /
sqrt(thenum));
226 hfftpix[
p]->SetAxisRange(fftmax / 1000.0, 0.5 * fftmax);
227 hfftpix[
p]->SetLineColor(hahacolor[p]);
229 hadcpix[
p]->GetXaxis()->SetLabelSize(0.06);
230 hadcpix[
p]->GetYaxis()->SetLabelSize(0.06);
231 hadctpix[
p]->GetXaxis()->SetLabelSize(0.06);
232 hadctpix[
p]->GetYaxis()->SetLabelSize(0.06);
233 hdsotpix[
p]->GetXaxis()->SetLabelSize(0.06);
234 hdsotpix[
p]->GetYaxis()->SetLabelSize(0.06);
235 hfftpix[
p]->GetXaxis()->SetLabelSize(0.06);
236 hfftpix[
p]->GetYaxis()->SetLabelSize(0.06);
240 hthresholdmap->SetMinimum(0);
241 hthresholdmap->SetMaximum(100);
242 hthresholdmap->SetMarkerSize(3);
243 hthresholdmap->SetStats(0);
244 hthresholdmap->Write();
245 hthreshold2map->SetMinimum(0);
246 hthreshold2map->SetMaximum(100);
247 hthreshold2map->SetMarkerSize(3);
248 hthreshold2map->SetStats(0);
249 hthreshold2map->Write();
250 for(
int j = 0;
j < 32;
j++){
251 hadctpix[
j]->Write();
252 hdsotpix[
j]->Write();
260 for(
int pix = 0; pix < 32; ++pix){
261 TCanvas* cadcpix =
new TCanvas;
262 hadcpix[pix]->Draw();
265 sprintf(outfilename,
"%s/DIBLOCK%d/noisyAPD_dcm-%d-%d-%d-%d_hadcpix_%d.png", plotOutDir.c_str(), aDB, detID, aDB, aDCM, aFEB, pix);
266 cadcpix->Print(outfilename);
268 TCanvas* cadctpix =
new TCanvas;
269 hadctpix[pix]->Draw(
"hist");
270 sprintf(outfilename,
"%s/DIBLOCK%d/noisyAPD_dcm-%d-%d-%d-%d_hadctpix_%d.png", plotOutDir.c_str(), aDB, detID, aDB, aDCM, aFEB, pix);
271 cadctpix->Print(outfilename);
273 TCanvas* cdsotpix =
new TCanvas;
274 hdsotpix[pix]->Draw(
"hist");
275 sprintf(outfilename,
"%s/DIBLOCK%d/noisyAPD_dcm-%d-%d-%d-%d_hdsotpix_%d.png", plotOutDir.c_str(), aDB, detID, aDB, aDCM, aFEB, pix);
276 cdsotpix->Print(outfilename);
278 TCanvas* cfftpix =
new TCanvas;
279 hfftpix[pix]->Draw(
"hist");
280 sprintf(outfilename,
"%s/DIBLOCK%d/noisyAPD_dcm-%d-%d-%d-%d_hfftpix_%d.png", plotOutDir.c_str(), aDB, detID, aDB, aDCM, aFEB, pix);
281 cfftpix->Print(outfilename);
291 for(
unsigned int FEBIdx = 0; FEBIdx < FEBlist.size(); ++FEBIdx){
292 int aDB = FEBlist.at(FEBIdx).at(0);
293 int aDCM = FEBlist.at(FEBIdx).at(1);
294 int aFEB = FEBlist.at(FEBIdx).at(2);
298 sprintf(dsoFile,
"%s/dcm-%d-%02d-%02d/standardVoltage/standardVoltage-FEB%02d.dat", dsoScanDir.c_str(), detID, aDB, aDCM, aFEB);
301 ifstream
File(dsoFile);
304 std::cout <<
"We are now using Diblock: " << aDB <<
" DCM: " << aDCM <<
" FEB: " << aFEB <<
std::endl;
305 MakePlots(detector, dsoFile, plotOutDir, aDB, aDCM, aFEB);
309 std::cout <<
"We cannot use Diblock: " << aDB <<
" DCM: " << aDCM <<
" FEB: " << aFEB <<
std::endl;
318 std::vector<std::vector<int>> FEBlist =
ParseFEBList(FEBListPath, dsoScanDir, detector);
322 FEBLoop(detector, dsoScanDir, FEBlist, plotOutDir);
void DSOPlotMaker(std::string detector, std::string dsoScanDir, std::string FEBListPath, std::string plotOutDir)
::xsd::cxx::tree::time< char, simple_type > time
string outfilename
knobs that need extra care
int GetNumberOfDiblocks(std::string detector)
std::vector< std::vector< int > > ParseFEBList(std::string FEBListPath, std::string dsoScanDir, std::string detector)
Open the FEB file and parse the contents.
void FEBLoop(std::string detector, std::string dsoScanDir, std::vector< std::vector< int >> FEBlist, std::string plotOutDir)
void MakePlots(std::string detector, std::string dsoFile, std::string plotOutDir, int aDB, int aDCM, int aFEB)
int GetDetID(std::string detector)