From 0883ebdb6ee59e96738d1ba135b7ae9069b0f7a0 Mon Sep 17 00:00:00 2001 From: vsitaraman Date: Thu, 22 Jan 2026 15:07:10 -0500 Subject: [PATCH] modified: Armory/Makefile deleted: Armory/README.md modified: Calibration.C Sudarsan pointed out that the gain match and calibration stages have the ring and wedge swapped, so I fixed that. modified: ProcessRun.sh changes for running on laptop modified: TrackRecon.C same inconsistency as in Calibration.C fixed deleted: makeplots.C not used anymore modified: mapping.h corrected teh mapping for the QQQs poptentially, need to confirm modified: mapping_old.txt --- Armory/Makefile | 12 +- Armory/README.md | 6 - Calibration.C | 2 +- ProcessRun.sh | 7 +- TrackRecon.C | 10 +- makeplots.C | 87 ------------- mapping.h | 332 +++++++++++++++++++++++++++-------------------- mapping_old.txt | 64 ++++----- 8 files changed, 238 insertions(+), 282 deletions(-) delete mode 100644 Armory/README.md delete mode 100644 makeplots.C diff --git a/Armory/Makefile b/Armory/Makefile index ba76824..9cc4957 100644 --- a/Armory/Makefile +++ b/Armory/Makefile @@ -10,7 +10,7 @@ COPTS = -fPIC -DLINUX -g -O0 -Wall -std=c++17 -lpthread ROOTLIBS = `root-config --cflags --glibs` -ALL = Mapper AnasenMS +ALL = Mapper EventBuilder#AnasenMS ######################################################################### @@ -23,6 +23,10 @@ Mapper : Mapper.cpp ../mapping.h ClassDet.h @echo "--------- making Mapper" $(CC) $(COPTS) -o Mapper Mapper.cpp $(ROOTLIBS) -AnasenMS : constant.h Isotope.h ClassTransfer.h ClassSX3.h ClassPW.h ClassAnasen.h anasenMS.cpp - @echo "--------- making ANASEN Monte Carlo" - $(CC) $(COPTS) -o AnasenMS anasenMS.cpp $(ROOTLIBS) +# AnasenMS : constant.h Isotope.h ClassTransfer.h ClassSX3.h ClassPW.h ClassAnasen.h anasenMS.cpp +# @echo "--------- making ANASEN Monte Carlo" +# $(CC) $(COPTS) -o AnasenMS anasenMS.cpp $(ROOTLIBS) + +EventBuilder : EventBuilder.cpp ../ClassData.h fsuReader.h ../Hit.h + @echo "--------- making EventBuilder" + $(CC) $(COPTS) -o EventBuilder EventBuilder.cpp $(ROOTLIBS) diff --git a/Armory/README.md b/Armory/README.md deleted file mode 100644 index 8b1911a..0000000 --- a/Armory/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# HistPlotter - - Header-only class to encapsulate CERN ROOT 1D/2D Histogram plotting and application of TCuts. - - Can specify folder hierarchy while setting up fills, currently supports only one level. - - Cuts specified using a two-column text file containing cut names, and target .root files. These .root files must contain a TCutG of name "CUTG". - - Tested for use in macros, with TSelector design pattern and compiled code. - - Idea inspired from MyFill() pattern created by github user gwm17 diff --git a/Calibration.C b/Calibration.C index f4a25d7..02f830d 100644 --- a/Calibration.C +++ b/Calibration.C @@ -222,7 +222,7 @@ void Calibration::Terminate() calibArray[det][ring][wedge] = slope_keV; calibValid[det][ring][wedge] = true; - outFile << det << " " << ring << " " << wedge << " " + outFile << det << " " << wedge << " " << ring << " " << slope_keV << "\n"; // printf("QQQ DET=%d R=%d W=%d ADCpeak=%.1f slope_keV=%.6f\n",det, ring, wedge, adcPeak, slope_keV); diff --git a/ProcessRun.sh b/ProcessRun.sh index 7991804..1400239 100755 --- a/ProcessRun.sh +++ b/ProcessRun.sh @@ -12,12 +12,13 @@ timeWindow=$2 option=$3 -rawFolder=/home/tandem/data1/2024_09_17Fap/data +# rawFolder=/home/tandem/data1/2024_09_17Fap/data +rawFolder=../Raw_data rootFolder=../root_data if [ $option -eq 0 ]; then - rsync -auh --info=progress2 splitpole@128.186.111.223:/media/nvmeData/2024_09_17Fap/*.fsu /home/tandem/data1/2024_09_17Fap/data + # rsync -auh --info=progress2 splitpole@128.186.111.223:/media/nvmeData/2024_09_17Fap/*.fsu /home/tandem/data1/2024_09_17Fap/data fileList=`\ls -1 ${rawFolder}/*Run_${runID}_*.fsu` @@ -30,4 +31,4 @@ if [ $option -eq 0 ]; then ./Mapper ${rootFolder}/*${runID}*${timeWindow}.root fi -root "processRun.C(\"${rootFolder}/ProtonRun_${runID}_mapped.root\")" +root "processRun.C(\"${rootFolder}/Run_${runID}_mapped.root\")" diff --git a/TrackRecon.C b/TrackRecon.C index b261033..6d39d88 100644 --- a/TrackRecon.C +++ b/TrackRecon.C @@ -144,7 +144,7 @@ void TrackRecon::Begin(TTree * /*tree*/) { int det, ring, wedge; double gainw, gainr; - while (infile >> det >> ring >> wedge >> gainw >> gainr) + while (infile >> det >> wedge >> ring >> gainw >> gainr) { qqqGain[det][ring][wedge] = gainw; qqqGainValid[det][ring][wedge] = (gainw > 0); @@ -160,7 +160,7 @@ void TrackRecon::Begin(TTree * /*tree*/) { int det, ring, wedge; double slope; - while (infile >> det >> ring >> wedge >> slope) + while (infile >> det >> wedge >> ring >> slope) { qqqCalib[det][ring][wedge] = slope; qqqCalibValid[det][ring][wedge] = (slope > 0); @@ -202,11 +202,7 @@ Bool_t TrackRecon::Process(Long64_t entry) int qqqAdjCh = 0; for (int i = 0; i < qqq.multi; i++) { - if (qqq.id[i] == 3 && qqq.ch[i] <= 16) - { - qqq.ch[i] = 16-qqq.ch[i] ; - } - if (qqq.id[i] == 1 && qqq.ch[i] <= 16) + if ((qqq.id[i] == 3 || qqq.id[i] ==1) && qqq.ch[i] <= 16) { qqq.ch[i] = 16-qqq.ch[i] ; } diff --git a/makeplots.C b/makeplots.C deleted file mode 100644 index f1b4983..0000000 --- a/makeplots.C +++ /dev/null @@ -1,87 +0,0 @@ -#include "GainMatchQQQ.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "Armory/HistPlotter.h" -#include "TVector3.h" - -void makeplots() -{ - TCanvas *c1 = new TCanvas("c1", "c1", 0, 0, 1024, 768); - c1->Divide(2, 2); - - TH2F *h1, *h2, *h3, *h4 = nullptr; - - std::string type = "Cal_cut"; - TFile *inFile = TFile::Open("Cal_checkQQQ.root"); - TF1 f1("x","x",0 ,80); - - - for (int ring = 0; ring < 16; ring++) - { - for (int wedge = 0; wedge < 16; wedge++) - { - - c1->cd(1); - h1 = (TH2F *)inFile->Get(Form("E%s/h%s_qqq%d_ring%d_wedge%d", type.c_str(), type.c_str(), 0, ring, wedge)); - gPad->SetGrid(); - if (h1) - { - h1->SetTitle(Form("QQQ%d Ring %d Wedge %d %s E", 0, ring, wedge, type.c_str())); - h1->Draw("COLZ"); - f1.DrawClone("same"); - - gPad->Modified(); - gPad->Update(); - } - - c1->cd(2); - h2 = (TH2F *)inFile->Get(Form("E%s/h%s_qqq%d_ring%d_wedge%d", type.c_str(), type.c_str(), 1, ring, wedge)); - gPad->SetGrid(); - if (h2) - { - std::cout<SetTitle(Form("QQQ%d Ring %d Wedge %d %s E", 1, ring, wedge, type.c_str())); - h2->Draw("COLZ"); - f1.DrawClone("same"); - gPad->Modified(); - gPad->Update(); - } - - c1->cd(3); - h3 = (TH2F *)inFile->Get(Form("E%s/h%s_qqq%d_ring%d_wedge%d", type.c_str(), type.c_str(), 2, ring, wedge)); - gPad->SetGrid(); - if (h3) - { - h3->SetTitle(Form("QQQ%d Ring %d Wedge %d %s E", 2, ring, wedge, type.c_str())); - h3->Draw("COLZ"); - f1.DrawClone("same"); - gPad->Modified(); - gPad->Update(); - } - - c1->cd(4); - h4 = (TH2F *)inFile->Get(Form("E%s/h%s_qqq%d_ring%d_wedge%d", type.c_str(), type.c_str(), 3, ring, wedge)); - gPad->SetGrid(); - if (h4) - { - h4->SetTitle(Form("QQQ%d Ring %d Wedge %d %s E", 3, ring, wedge, type.c_str())); - h4->Draw("COLZ"); - f1.DrawClone("same"); - gPad->Modified(); - gPad->Update(); - } - while (gPad->WaitPrimitive()); - } - } - - inFile->Close(); -} \ No newline at end of file diff --git a/mapping.h b/mapping.h index 23876f4..3697704 100644 --- a/mapping.h +++ b/mapping.h @@ -12,19 +12,18 @@ #include const std::map board = { - {0, 17122}, // id, sn - {1, 17123}, - {2, 22320}, - {3, 22130}, - {4, 22129}, - {5, 15529}, - {6, 15528}, - // {7,89}, - {7, 334}, - {8, 379}, - {9, 325}, - {10, 405} -}; + {0, 17122}, // id, sn + {1, 17123}, + {2, 22320}, + {3, 22130}, + {4, 22129}, + {5, 15529}, + {6, 15528}, + // {7,89}, + {7, 334}, + {8, 379}, + {9, 325}, + {10, 405}}; const int nBd = board.size(); const int nV1740 = 7; @@ -39,194 +38,229 @@ const int nV1725 = 4; // The detID = Type * 10000 + index * 100 + channel // fro example, detID(superX3-8, ch-7) = 00807 - -// use the GenMapping() to get that +// use the GenMapping() to get that const std::vector mapping = { - //================== 17122 - 806, 807, 804, 805, 803, 802, 801, 800, 1006, 1007, 1004, 1005, 1003, 1002, 1001, 1000, - 606, 607, 604, 605, 603, 602, 601, 600, 1106, 1107, 1104, 1105, 1103, 1102, 1101, 1100, - 711, 710, 709, 708, 911, 910, 909, 908, 1011, 1010, 1009, 1008, 811, 810, 809, 808, - 706, 707, 704, 705, 703, 702, 701, 700, 906, 907, 904, 905, 903, 902, 901, 900, - //================== 17123 - 1406, 1407, 1404, 1405, 1403, 1402, 1401, 1400, 1606, 1607, 1604, 1605, 1603, 1602, 1601, 1600, - 1306, 1307, 1304, 1305, 1303, 1302, 1301, 1300, 1506, 1507, 1504, 1505, 1503, 1502, 1501, 1500, - 1311, 1310, 1309, 1308, 1711, 1710, 1709, 1708, 1611, 1610, 1609, 1608, 1411, 1410, 1409, 1408, - 1206, 1207, 1204, 1205, 1203, 1202, 1201, 1200, 1706, 1707, 1704, 1705, 1703, 1702, 1701, 1700, - //================== 22320 - 6, 7, 4, 5, 3, 2, 1, 0, 506, 507, 504, 505, 503, 502, 501, 500, - 111, 110, 109, 108, 311, 310, 309, 308, 411, 410, 409, 408, 211, 210, 209, 208, - 206, 207, 204, 205, 203, 202, 201, 200, 406, 407, 404, 405, 403, 402, 401, 400, - 106, 107, 104, 105, 103, 102, 101, 100, 306, 307, 304, 305, 303, 302, 301, 300, - //================== 22130 - 1911, 1910, 1909, 1908, 2111, 2110, 2109, 2108, 2211, 2210, 2209, 2208, 2011, 2010, 2009, 2008, - 11, 10, 9, 8, 511, 510, 509, 508, 611, 610, 609, 608, 1111, 1110, 1109, 1108, - 2006, 2007, 2004, 2005, 2003, 2002, 2001, 2000, 2206, 2207, 2204, 2205, 2203, 2202, 2201, 2200, - 1906, 1907, 1904, 1905, 1903, 1902, 1901, 1900, 2106, 2107, 2104, 2105, 2103, 2102, 2101, 2100, - //================== 22129 - 1806, 1807, 1804, 1805, 1803, 1802, 1801, 1800, 2306, 2307, 2304, 2305, 2303, 2302, 2301, 2300, - 10016, 10017, 10018, 10019, 10020, 10021, 10022, 10023, 10024, 10025, 10026, 10027, 10028, 10029, 10030, 10031, - 10116, 10117, 10118, 10119, 10120, 10121, 10122, 10123, 10124, 10125, 10126, 10127, 10128, 10129, 10130, 10131, - 10015, 10014, 10013, 10012, 10011, 10010, 10009, 10008, 10007, 10006, 10005, 10004, 10003, 10002, 10001, 10000, - //================== 15529 - 10231, 10230, 10229, 10228, 10227, 10226, 10225, 10224, 10223, 10222, 10221, 10220, 10219, 10218, 10217, 10216, - 10115, 10114, 10113, 10112, 10111, 10110, 10109, 10108, 10107, 10106, 10105, 10104, 10103, 10102, 10101, 10100, - 10315, 10314, 10313, 10312, 10311, 10310, 10309, 10308, 10307, 10306, 10305, 10304, 10303, 10302, 10301, 10300, - 10215, 10214, 10213, 10212, 10211, 10210, 10209, 10208, 10207, 10206, 10205, 10204, 10203, 10202, 10201, 10200, - //================== 15528 - 10316, 10317, 10318, 10319, 10320, 10321, 10322, 10323, 10324, 10325, 10326, 10327, 10328, 10329, 10330, 10331, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - //================== 89 - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 -// 30004, -1, 30003, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - //================== 334 - 20116, 20117, 20118, 20119, -1, 20121, 20122, 20123, 20016, 20017, 20018, -1, 20020, 20021, 20022, 20023, - //================== 379 - -1 , 20001, 20002, 20003, 20004, 20005, -1, 20007, 20008, -1, 20010, 20011, 20012, 20013, 20014, 20015, - //================== 325 - 20100, 20101, 20102, 20103, 20104, 20105, 20106, 20107, 20108, 20109, 20110, 20111, 20112, -1, 20114, 20115, - //================== 405 - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - 20006, -1, 30005, 20009, -1, 20120, 20000, 20019, 20113, 30000, 30004, 30001, 30002, -1, 30003, -1 -}; + //================== 17122 + 806, 807, 804, 805, 803, 802, 801, 800, 1006, 1007, 1004, 1005, 1003, 1002, 1001, 1000, + 606, 607, 604, 605, 603, 602, 601, 600, 1106, 1107, 1104, 1105, 1103, 1102, 1101, 1100, + 711, 710, 709, 708, 911, 910, 909, 908, 1011, 1010, 1009, 1008, 811, 810, 809, 808, + 706, 707, 704, 705, 703, 702, 701, 700, 906, 907, 904, 905, 903, 902, 901, 900, + //================== 17123 + 1406, 1407, 1404, 1405, 1403, 1402, 1401, 1400, 1606, 1607, 1604, 1605, 1603, 1602, 1601, 1600, + 1306, 1307, 1304, 1305, 1303, 1302, 1301, 1300, 1506, 1507, 1504, 1505, 1503, 1502, 1501, 1500, + 1311, 1310, 1309, 1308, 1711, 1710, 1709, 1708, 1611, 1610, 1609, 1608, 1411, 1410, 1409, 1408, + 1206, 1207, 1204, 1205, 1203, 1202, 1201, 1200, 1706, 1707, 1704, 1705, 1703, 1702, 1701, 1700, + //================== 22320 + 6, 7, 4, 5, 3, 2, 1, 0, 506, 507, 504, 505, 503, 502, 501, 500, + 111, 110, 109, 108, 311, 310, 309, 308, 411, 410, 409, 408, 211, 210, 209, 208, + 206, 207, 204, 205, 203, 202, 201, 200, 406, 407, 404, 405, 403, 402, 401, 400, + 106, 107, 104, 105, 103, 102, 101, 100, 306, 307, 304, 305, 303, 302, 301, 300, + //================== 22130 + 1911, 1910, 1909, 1908, 2111, 2110, 2109, 2108, 2211, 2210, 2209, 2208, 2011, 2010, 2009, 2008, + 11, 10, 9, 8, 511, 510, 509, 508, 611, 610, 609, 608, 1111, 1110, 1109, 1108, + 2006, 2007, 2004, 2005, 2003, 2002, 2001, 2000, 2206, 2207, 2204, 2205, 2203, 2202, 2201, 2200, + 1906, 1907, 1904, 1905, 1903, 1902, 1901, 1900, 2106, 2107, 2104, 2105, 2103, 2102, 2101, 2100, + //================== 22129 + 1806, 1807, 1804, 1805, 1803, 1802, 1801, 1800, 2306, 2307, 2304, 2305, 2303, 2302, 2301, 2300, + 10016, 10017, 10018, 10019, 10020, 10021, 10022, 10023, 10024, 10025, 10026, 10027, 10028, 10029, 10030, 10031, + 10116, 10117, 10118, 10119, 10120, 10121, 10122, 10123, 10124, 10125, 10126, 10127, 10128, 10129, 10130, 10131, + 10015, 10014, 10013, 10012, 10011, 10010, 10009, 10008, 10007, 10006, 10005, 10004, 10003, 10002, 10001, 10000, + //================== 15529 + 10231, 10230, 10229, 10228, 10227, 10226, 10225, 10224, 10223, 10222, 10221, 10220, 10219, 10218, 10217, 10216, + 10100, 10101, 10102, 10103, 10104, 10105, 10106, 10107, 10108, 10109, 10110, 10111, 10112, 10113, 10114, 10115, + // 10115, 10114, 10113, 10112, 10111, 10110, 10109, 10108, 10107, 10106, 10105, 10104, 10103, 10102, 10101, 10100, + 10300, 10301, 10302, 10303, 10304, 10305, 10306, 10307, 10308, 10309, 10310, 10311, 10312, 10313, 10314, 10315, + // 10315, 10314, 10313, 10312, 10311, 10310, 10309, 10308, 10307, 10306, 10305, 10304, 10303, 10302, 10301, 10300, + 10215, 10214, 10213, 10212, 10211, 10210, 10209, 10208, 10207, 10206, 10205, 10204, 10203, 10202, 10201, 10200, + //================== 15528 + 10316, 10317, 10318, 10319, 10320, 10321, 10322, 10323, 10324, 10325, 10326, 10327, 10328, 10329, 10330, 10331, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + //================== 89 + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + // 30004, -1, 30003, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + //================== 334 + 20116, 20117, 20118, 20119, -1, 20121, 20122, 20123, 20016, 20017, 20018, -1, 20020, 20021, 20022, 20023, + //================== 379 + -1, 20001, 20002, 20003, 20004, 20005, -1, 20007, 20008, -1, 20010, 20011, 20012, 20013, 20014, 20015, + //================== 325 + 20100, 20101, 20102, 20103, 20104, 20105, 20106, 20107, 20108, 20109, 20110, 20111, 20112, -1, 20114, 20115, + //================== 405 + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + 20006, -1, 30005, 20009, -1, 20120, 20000, 20019, 20113, 30000, 30004, 30001, 30002, -1, 30003, -1}; -//MCP moved from channel 1 to 2 after Run number 322 -//MCP and Rf moved to ch 0 and 1 after Run number after Run282 -//moved back to ch -void PrintMapping(){ +// MCP moved from channel 1 to 2 after Run number 322 +// MCP and Rf moved to ch 0 and 1 after Run number after Run282 +// moved back to ch +void PrintMapping() +{ int digiID = 0; int count = 0; printf("==================== ID-MAP: \n"); - printf("%11s|", ""); for(int i = 0 ; i < 16; i++ ) printf("%7d|", i); + printf("%11s|", ""); + for (int i = 0; i < 16; i++) + printf("%7d|", i); printf("\n"); - for(int i = 0 ; i < 12 + 16*8; i++ ) printf("-"); - for(size_t i = 0 ; i < mapping.size(); i ++){ - if( (i) % 16 == 0 ) { + for (int i = 0; i < 12 + 16 * 8; i++) + printf("-"); + for (size_t i = 0; i < mapping.size(); i++) + { + if ((i) % 16 == 0) + { printf("\n"); - if( digiID < nBd ){ - if( board.at(digiID) > 1000 ) { - if( count == 3 ) digiID ++; - if( i % 64 == 0 ) { + if (digiID < nBd) + { + if (board.at(digiID) > 1000) + { + if (count == 3) + digiID++; + if (i % 64 == 0) + { printf("%11d|", board.at(digiID)); count = 0; } - }else{ - if( count == 1 ) digiID ++; - if( i % 16 == 0 ) { + } + else + { + if (count == 1) + digiID++; + if (i % 16 == 0) + { printf("%11d|", board.at(digiID)); count = 0; } } } - if( count != 0) printf("%11s|", ""); - count ++; + if (count != 0) + printf("%11s|", ""); + count++; } int typeID = mapping[i] / 10000; - int detID = (mapping[i] - typeID*10000 )/100; - int ch = mapping[i] - typeID*10000 - detID * 100; + int detID = (mapping[i] - typeID * 10000) / 100; + int ch = mapping[i] - typeID * 10000 - detID * 100; - if( mapping[i] == -1 ) { + if (mapping[i] == -1) + { printf("%7s|", ""); + } + else + { - }else{ + if (typeID == 0) + { // SX3 - if( typeID == 0){ // SX3 - - printf("\033[36m%3d(%2d)\033[0m|", detID, ch); - - }else if( typeID == 1){ // QQQ + printf("\033[36m%3d(%2d)\033[0m|", detID, ch); + } + else if (typeID == 1) + { // QQQ printf("\033[91m%3d(%2d)\033[0m|", detID, ch); - - }else if( typeID == 2){ // PC + } + else if (typeID == 2) + { // PC printf("\033[35m%3d(%2d)\033[0m|", detID, ch); - - }else if( typeID == 3){ // MISC + } + else if (typeID == 3) + { // MISC printf("\033[33m%3d(%2d)\033[0m|", detID, ch); - } } } printf("\n"); - for(int i = 0 ; i < 12 + 16*8; i++ ) printf("-"); + for (int i = 0; i < 12 + 16 * 8; i++) + printf("-"); printf("\n"); - } - -void GenMapping(std::string mapFile){ - +void GenMapping(std::string mapFile) +{ std::vector map; + std::ifstream inputFile(mapFile); // Replace "your_file.txt" with the actual file path - std::ifstream inputFile(mapFile); // Replace "your_file.txt" with the actual file path - - if (!inputFile.is_open()) { + if (!inputFile.is_open()) + { printf("Error: Could not open the file (%s).\n", mapFile.c_str()); - return ; + return; } std::string line; // Read the file line by line - while (std::getline(inputFile, line)) { + while (std::getline(inputFile, line)) + { std::vector words; std::istringstream iss(line); // Extract words from the current line - while (true) { + while (true) + { std::string word; - if (!(iss >> word)) break; // Break if there are no more words + if (!(iss >> word)) + break; // Break if there are no more words word.erase(std::remove_if(word.begin(), word.end(), ::isspace), word.end()); words.push_back(word); - } - if( atoi(words[0].c_str()) % 16 == 0 ) printf("=================\n"); + if (atoi(words[0].c_str()) % 16 == 0) + printf("=================\n"); - - int detID = atoi(words[1].c_str())*100; - if(words.size() < 5 ) printf(" hahhahha %s\n", line.c_str()); - if( words[2] == "BARREL" ) { - if( words[3] == "FRONTDOWN" ){ + int detID = atoi(words[1].c_str()) * 100; + if (words.size() < 5) + printf(" hahhahha %s\n", line.c_str()); + if (words[2] == "BARREL") + { + if (words[3] == "FRONTDOWN") + { int chID = atoi(words[4].c_str()); - if( chID % 2 != 0 ) chID -= 1; + if (chID % 2 != 0) + chID -= 1; detID += chID; } - if( words[3] == "FRONTUP" ){ + if (words[3] == "FRONTUP") + { int chID = atoi(words[4].c_str()); - if( chID % 2 == 0 ) chID += 1; + if (chID % 2 == 0) + chID += 1; detID += chID; } - if( words[3] == "BACK") detID += atoi(words[4].c_str()) + 8; + if (words[3] == "BACK") + detID += atoi(words[4].c_str()) + 8; } - if( words[2] == "FQQQ" ) { + if (words[2] == "FQQQ") + { detID += 10000; - if( words[3] == "WEDGE") detID += atoi(words[4].c_str()); - if( words[3] == "RING") detID += atoi(words[4].c_str()) + 16; + if (words[3] == "WEDGE") + detID += atoi(words[4].c_str()); + if (words[3] == "RING") + detID += atoi(words[4].c_str()) + 16; } - if( words[2] == "PC" ) { + if (words[2] == "PC") + { detID += 20000; - if( words[3] == "ANODE") detID += atoi(words[4].c_str()); - if( words[3] == "CATHODE") detID += 100 + atoi(words[4].c_str()); + if (words[3] == "ANODE") + detID += atoi(words[4].c_str()); + if (words[3] == "CATHODE") + detID += 100 + atoi(words[4].c_str()); } - if( words[2] == "blank") { + if (words[2] == "blank") + { detID = -1; } @@ -242,29 +276,42 @@ void GenMapping(std::string mapFile){ int digiID = 0; int count = 0; printf("===============================\n"); - for( size_t i = 0; i < ((map.size() +15)/16) * 16; i++){ - if( i % 16 == 0) { + for (size_t i = 0; i < ((map.size() + 15) / 16) * 16; i++) + { + if (i % 16 == 0) + { printf("\n"); - if( digiID < nBd ){ - if( board.at(digiID) > 1000 ) { - if( count == 3 ) digiID ++; - if( i % 64 == 0 ) { + if (digiID < nBd) + { + if (board.at(digiID) > 1000) + { + if (count == 3) + digiID++; + if (i % 64 == 0) + { printf(" //================== %d\n", board.at(digiID)); count = 0; } - }else{ - if( count == 1 ) digiID ++; - if( i % 16 == 0 ) { + } + else + { + if (count == 1) + digiID++; + if (i % 16 == 0) + { printf(" //================== %d\n", board.at(digiID)); count = 0; } } } - count ++; + count++; } - if( i < map.size() ){ + if (i < map.size()) + { printf(" %5d,", map[i]); - }else{ + } + else + { printf(" %5d,", -1); } } @@ -273,13 +320,14 @@ void GenMapping(std::string mapFile){ printf("sorting mapping and see if there any repeated\n"); std::sort(map.begin(), map.end()); - for( size_t i = 1; i < map.size(); i++){ - if( map[i] == -1 ) continue; - if( map[i] == map[i-1] ) printf("%5d \n", map[i]); + for (size_t i = 1; i < map.size(); i++) + { + if (map[i] == -1) + continue; + if (map[i] == map[i - 1]) + printf("%5d \n", map[i]); } printf("=========== Done. if nothing show, no repeat. \n"); - - } -#endif +#endif diff --git a/mapping_old.txt b/mapping_old.txt index 9fdc738..a424886 100644 --- a/mapping_old.txt +++ b/mapping_old.txt @@ -302,22 +302,22 @@ 301 1 FQQQ RING 13 302 1 FQQQ RING 14 303 1 FQQQ RING 15 -304 1 FQQQ WEDGE 15 -305 1 FQQQ WEDGE 14 -306 1 FQQQ WEDGE 13 -307 1 FQQQ WEDGE 12 -308 1 FQQQ WEDGE 11 -309 1 FQQQ WEDGE 10 -310 1 FQQQ WEDGE 9 -311 1 FQQQ WEDGE 8 -312 1 FQQQ WEDGE 7 -313 1 FQQQ WEDGE 6 -314 1 FQQQ WEDGE 5 -315 1 FQQQ WEDGE 4 -316 1 FQQQ WEDGE 3 -317 1 FQQQ WEDGE 2 -318 1 FQQQ WEDGE 1 -319 1 FQQQ WEDGE 0 +304 1 FQQQ WEDGE 0 +305 1 FQQQ WEDGE 1 +306 1 FQQQ WEDGE 2 +307 1 FQQQ WEDGE 3 +308 1 FQQQ WEDGE 4 +309 1 FQQQ WEDGE 5 +310 1 FQQQ WEDGE 6 +311 1 FQQQ WEDGE 7 +312 1 FQQQ WEDGE 8 +313 1 FQQQ WEDGE 9 +314 1 FQQQ WEDGE 10 +315 1 FQQQ WEDGE 11 +316 1 FQQQ WEDGE 12 +317 1 FQQQ WEDGE 13 +318 1 FQQQ WEDGE 14 +319 1 FQQQ WEDGE 15 320 2 FQQQ RING 15 321 2 FQQQ RING 14 322 2 FQQQ RING 13 @@ -366,22 +366,22 @@ 365 2 FQQQ WEDGE 2 366 2 FQQQ WEDGE 1 367 2 FQQQ WEDGE 0 -368 3 FQQQ WEDGE 15 -369 3 FQQQ WEDGE 14 -370 3 FQQQ WEDGE 13 -371 3 FQQQ WEDGE 12 -372 3 FQQQ WEDGE 11 -373 3 FQQQ WEDGE 10 -374 3 FQQQ WEDGE 9 -375 3 FQQQ WEDGE 8 -376 3 FQQQ WEDGE 7 -377 3 FQQQ WEDGE 6 -378 3 FQQQ WEDGE 5 -379 3 FQQQ WEDGE 4 -380 3 FQQQ WEDGE 3 -381 3 FQQQ WEDGE 2 -382 3 FQQQ WEDGE 1 -383 3 FQQQ WEDGE 0 +368 3 FQQQ WEDGE 0 +369 3 FQQQ WEDGE 1 +370 3 FQQQ WEDGE 2 +371 3 FQQQ WEDGE 3 +372 3 FQQQ WEDGE 4 +373 3 FQQQ WEDGE 5 +374 3 FQQQ WEDGE 6 +375 3 FQQQ WEDGE 7 +376 3 FQQQ WEDGE 8 +377 3 FQQQ WEDGE 9 +378 3 FQQQ WEDGE 10 +379 3 FQQQ WEDGE 11 +380 3 FQQQ WEDGE 12 +381 3 FQQQ WEDGE 13 +382 3 FQQQ WEDGE 14 +383 3 FQQQ WEDGE 15 384 3 FQQQ RING 0 385 3 FQQQ RING 1 386 3 FQQQ RING 2