From c07d2158912bcf67c5268b83fdf2bb6637461f81 Mon Sep 17 00:00:00 2001 From: YiHui Liu Date: Wed, 13 Jul 2022 13:32:31 +0800 Subject: [PATCH] remove C/C++ file --- .clang-format | 208 ----------------------------------- .gitignore | 3 - CMakeLists.txt | 19 ---- include/BindHandler.h | 27 ----- include/BlockHandler.h | 38 ------- include/CsvReader.h | 72 ------------ include/FileHandler.h | 67 ----------- include/GaussFit.h | 132 ---------------------- include/GaussNewton.h | Bin 3846 -> 0 bytes include/LevenbergMarquardt.h | Bin 6334 -> 0 bytes include/clip.h | 62 ----------- include/utils.h | 96 ---------------- main.cpp | 48 -------- process.cpp | 9 -- requirements.txt | Bin 168 -> 140 bytes 15 files changed, 781 deletions(-) delete mode 100644 .clang-format delete mode 100644 CMakeLists.txt delete mode 100644 include/BindHandler.h delete mode 100644 include/BlockHandler.h delete mode 100644 include/CsvReader.h delete mode 100644 include/FileHandler.h delete mode 100644 include/GaussFit.h delete mode 100644 include/GaussNewton.h delete mode 100644 include/LevenbergMarquardt.h delete mode 100644 include/clip.h delete mode 100644 include/utils.h delete mode 100644 main.cpp delete mode 100644 process.cpp diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 0bddc96..0000000 --- a/.clang-format +++ /dev/null @@ -1,208 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: Google -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignArrayOfStructures: None -AlignConsecutiveMacros: None -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: None -AlignConsecutiveDeclarations: None -AlignEscapedNewlines: Left -AlignOperands: Align -AlignTrailingComments: true -AllowAllArgumentsOnNextLine: true -AllowAllConstructorInitializersOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortEnumsOnASingleLine: true -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: WithoutElse -AllowShortLoopsOnASingleLine: true -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: Yes -AttributeMacros: - - __capability -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: Never - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - BeforeLambdaBody: false - BeforeWhile: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeConceptDeclarations: true -BreakBeforeBraces: Attach -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeColon -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 100 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DeriveLineEnding: true -DerivePointerAlignment: true -DisableFormat: false -EmptyLineAfterAccessModifier: Never -EmptyLineBeforeAccessModifier: LogicalBlock -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IfMacros: - - KJ_IF_MAYBE -IncludeBlocks: Regroup -IncludeCategories: - - Regex: '^[<"].*\.h[>"]' - Priority: 0 - SortPriority: 0 - CaseSensitive: false - - Regex: '^[<"].*\.hh[>"]' - Priority: 1 - SortPriority: 1 - CaseSensitive: false - - Regex: '.*' - Priority: 2 - SortPriority: 2 - CaseSensitive: false -IncludeIsMainRegex: '([-_](test|unittest))?$' -IncludeIsMainSourceRegex: '' -IndentAccessModifiers: false -IndentCaseLabels: true -IndentCaseBlocks: false -IndentGotoLabels: true -IndentPPDirectives: None -IndentExternBlock: AfterExternBlock -IndentRequires: false -IndentWidth: 4 -IndentWrappedFunctionNames: false -InsertTrailingCommas: None -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -LambdaBodyIndentation: Signature -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Never -ObjCBlockIndentWidth: 2 -ObjCBreakBeforeNestedBlockParam: true -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -PenaltyIndentedWhitespace: 0 -PointerAlignment: Left -PPIndentWidth: -1 -RawStringFormats: - - Language: Cpp - Delimiters: - - cc - - CC - - cpp - - Cpp - - CPP - - 'c++' - - 'C++' - CanonicalDelimiter: '' - BasedOnStyle: google - - Language: TextProto - Delimiters: - - pb - - PB - - proto - - PROTO - EnclosingFunctions: - - EqualsProto - - EquivToProto - - PARSE_PARTIAL_TEXT_PROTO - - PARSE_TEST_PROTO - - PARSE_TEXT_PROTO - - ParseTextOrDie - - ParseTextProtoOrDie - - ParseTestProto - - ParsePartialTestProto - CanonicalDelimiter: pb - BasedOnStyle: google -ReferenceAlignment: Pointer -ReflowComments: true -ShortNamespaceLines: 1 -SortIncludes: CaseSensitive -SortJavaStaticImport: Before -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCaseColon: false -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceAroundPointerQualifiers: Default -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: Never -SpacesInConditionalStatement: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInLineCommentPrefix: - Minimum: 1 - Maximum: -1 -SpacesInParentheses: false -SpacesInSquareBrackets: false -SpaceBeforeSquareBrackets: false -BitFieldColonSpacing: Both -Standard: Auto -StatementAttributeLikeMacros: - - Q_EMIT -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 8 -UseCRLF: false -UseTab: Never -WhitespaceSensitiveMacros: - - STRINGIZE - - PP_STRINGIZE - - BOOST_PP_STRINGIZE - - NS_SWIFT_NAME - - CF_SWIFT_NAME -... - diff --git a/.gitignore b/.gitignore index 04bba47..5054165 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ *.csv *.json *.png -cal.txt 2016Q3D/ result/ @@ -12,7 +11,6 @@ result/ venv/ # build cache -build/ __pycache__ # config @@ -23,4 +21,3 @@ __pycache__ *.ipynb *.code-workspace -*.exe diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 095bb2a..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(Q3D) -set(Eigen3_DIR D:/Microsoft/vcpkg/installed/x64-windows/share/eigen3) -SET(CMAKE_TOOLCHAIN_FILE D:/Microsoft/vcpkg/scripts/buildsystems/vcpkg.cmake) - -find_package(ROOT REQUIRED Spectrum) -find_package(Eigen3 CONFIG REQUIRED) - -include(${ROOT_USE_FILE}) -include_directories(${PROJECT_SOURCE_DIR}/include) - -file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp) -file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.h) - -add_executable(Q3D main.cpp ${sources} ${headers}) -target_link_libraries(Q3D ${ROOT_LIBRARIES} Eigen3::Eigen) - -install(TARGETS Q3D DESTINATION F:/NuclearAstroPhy/Q3D-Calibration) diff --git a/include/BindHandler.h b/include/BindHandler.h deleted file mode 100644 index 46bd988..0000000 --- a/include/BindHandler.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#ifndef bind_handler_h -#define bind_handler_h - -#include "GaussFit.h" -#include "utils.h" - -#include - -class BindHandler { -public: - BindHandler(){}; - ~BindHandler(){}; - -public: - std::vector data; - -public: - void addData(std::vector); -}; - -void BindHandler::addData(std::vector newData) { - data.insert(data.end(), newData.begin(), newData.end()); -} - -#endif diff --git a/include/BlockHandler.h b/include/BlockHandler.h deleted file mode 100644 index 7919ef7..0000000 --- a/include/BlockHandler.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#ifndef block_handler_h -#define block_handler_h - -#include "BindHandler.h" -#include "FileHandler.h" - -class BlockHandler { -public: - BlockHandler(){}; - BlockHandler(int n_, int m_ = 8) { n = n_, m = m_; }; - ~BlockHandler(){}; - -public: - int n, m = 8; - BindHandler bind[8]; - std::vector data; - -public: - void addData(FileHandler); - void splitData(); -}; - -void BlockHandler::addData(FileHandler FH) { data.push_back(FH); } - -void BlockHandler::splitData() { - FileHandler FH; - for (int i = 0; i < data.size(); i++) { - FileHandler FH = data.at(i); - for (int j = 0; j < m; j++) { - bind[j].addData(FH.adcValue[n][j]); - std::vector().swap(FH.adcValue[n][j]); - } - } -} - -#endif diff --git a/include/CsvReader.h b/include/CsvReader.h deleted file mode 100644 index 433a5fb..0000000 --- a/include/CsvReader.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#ifndef csv_reader_h -#define csv_reader_h - -#include -#include -#include -#include -#include - -using std::string; -using std::vector; - -class CsvReader { -public: - CsvReader(string); - ~CsvReader() {}; - -public: - string file; - vector> strArray; - -public: - int rows(); - void readData(); - string operator()(int i, int j) const; -}; - -CsvReader::CsvReader(string file_) { file = file_; } - -int CsvReader::rows() { return strArray.size(); } - -void CsvReader::readData() { - std::ifstream inFile(file); - string lineStr; - while (std::getline(inFile, lineStr)) { - std::stringstream ss(lineStr); - string str; - vector lineArray; - while (std::getline(ss, str, ',')) lineArray.push_back(str); - strArray.push_back(lineArray); - } -} - -string CsvReader::operator()(int i, int j) const { - vector lineArray; - int n = strArray.size(), m; - - if (i < 0 || i > n - 1) std::cout << "Row Index Out Of Bounds " << std::endl; - lineArray = strArray.at(i); - m = lineArray.size(); - if (j < 0 || j > m - 1) std::cout << "Column Index Out Of Bounds " << std::endl; - - return lineArray.at(j); -} - -std::ostream& operator<<(std::ostream& cout, CsvReader& cR) { - vector lineArray; - int n = cR.strArray.size(), m; - - for (int i = 0; i < n; i++) { - lineArray = cR.strArray.at(i); - m = lineArray.size(); - for (int j = 0; j < m; j++) cout << lineArray.at(j) << " "; - if (i < n - 1) cout << std::endl; - } - - return cout; -} - -#endif diff --git a/include/FileHandler.h b/include/FileHandler.h deleted file mode 100644 index d525190..0000000 --- a/include/FileHandler.h +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -#ifndef file_handler_h -#define file_handler_h - -#include "utils.h" -#include -#include -#include - -#include - -class FileHandler { -public: - FileHandler(){}; - FileHandler(string, int n_ = 6, int thMin_ = 800, int thMax_ = 4000); - ~FileHandler(){}; - -public: - int n = 6, m = 8; - int thMin, thMax, pX; - string file; - std::vector adcValue[6][8]; - -public: - void readData(); -}; - -FileHandler::FileHandler(string file_, int n_, int thMin_, int thMax_) { - file = file_; - n = n_; - thMin = thMin_; - thMax = thMax_; -} - -void FileHandler::readData() { - TFile *fRun = new TFile(file.c_str()); - TTree *t = (TTree *)fRun->Get("Tree1"); - - int na, nc, ntot = t->GetEntriesFast(); - UInt_t dataArray[6][16]; - double x1, x2; - string adc; - - for (int i = 0; i < n; i++) - for (int j = 0; j < m; j++) { - na = i / 2; - nc = j + 2 * m * (i % 2); - adc = "adc" + to_string(na) + "ch" + to_string(nc); - t->SetBranchAddress(adc.c_str(), &dataArray[i][j]); - adc = "adc" + to_string(na) + "ch" + to_string(nc + m); - t->SetBranchAddress(adc.c_str(), &dataArray[i][j + m]); - } - - for (int i = 0; i < ntot; i++) { - t->GetEntry(i); - for (int j = 0; j < n; j++) - for (int k = 0; k < m; k++) { - x1 = dataArray[j][k]; - x2 = dataArray[j][k + m]; - if ((x1 + x2) < thMin || (x1 + x2) > thMax) continue; - adcValue[j][k].push_back(Eigen::Vector2d(x1, x2)); - } - } -} - -#endif diff --git a/include/GaussFit.h b/include/GaussFit.h deleted file mode 100644 index ff6d017..0000000 --- a/include/GaussFit.h +++ /dev/null @@ -1,132 +0,0 @@ -#pragma once - -#ifndef gauss_fit_h -#define gauss_fit_h - -#include "GaussNewton.h" -#include "LevenbergMarquardt.h" -#include "clip.h" -#include "utils.h" -#include -#include - -#include -#include - -double Gaussian(double x, double* p) { - return p[0] * std::exp(-(x - p[1]) * (x - p[1]) / (2 * p[2] * p[2])); -} - -double* GaussianJacobian(double x, double* p) { - double* resJ = new double[3]; - resJ[0] = -Gaussian(x, p) / p[0]; - resJ[1] = -(x - p[1]) * Gaussian(x, p) / (p[2] * p[2]); - resJ[2] = -(x - p[1]) * (x - p[1]) * Gaussian(x, p) / (p[2] * p[2] * p[2]); - return resJ; -} - -class GaussFit { -public: - GaussFit(){}; - ~GaussFit(){}; - -public: - double* parma = new double[3]; - std::vector data; - -public: - void addData(double x, double y); - double* fit(int type_ = 0); - double RSquare(); - int getTotal(); - void draw(std::string title = "./Figure.png"); -}; - -void GaussFit::addData(double x, double y) { data.push_back(Eigen::Vector2d(x, y)); } - -double* GaussFit::fit(int type_) { - double x, y; - - SigmaClip* SC2 = new SigmaClip(); - data = SC2->clip(data); - - parma[0] = dataMax2D(data); - parma[1] = dataAvg2D(data); - parma[2] = dataStd2D(data); - - if (DEBUG > 1) - for (int i = 0; i < data.size(); i++) { - Eigen::Vector2d& point = data.at(i); - x = point(0), y = point(1); - std::cout << x << " " << y << std::endl; - } - - if (type_ == 0) { - LevenbergMarquardt LM(3, parma, Gaussian, GaussianJacobian); - LM.data = data; - parma = LM.solve(); - } else if (type_ == 1) { - LevenbergMarquardt LM(3, parma, Gaussian, GaussianJacobian, type_ = type_); - LM.data = data; - parma = LM.solve(); - } else { - GaussNewton GN(3, parma, Gaussian, GaussianJacobian); - GN.data = data; - parma = GN.solve(); - } - - if (DEBUG) std::cout << parma[0] << " " << parma[1] << ", " << parma[2] << std::endl; - if (DEBUG) std::cout << RSquare() << std::endl; - - if (RSquare() < 0.6) - for (int i = 0; i < 3; i++) parma[i] = 0; - - return parma; -} - -double GaussFit::RSquare() { - double x, y, mu; - double RSS = 0, TSS = 0; - - std::vector yData; - for (int i = 0; i < data.size(); i++) yData.push_back(data.at(i)(1)); - mu = dataAvg(yData); - - for (int i = 0; i < data.size(); i++) { - Eigen::Vector2d& point = data.at(i); - x = point(0), y = point(1); - RSS += std::pow(y - Gaussian(x, parma), 2); - TSS += std::pow(y - mu, 2); - } - - return 1 - RSS / TSS; -} - -int GaussFit::getTotal() { - int sum = 0; - for (int i = 0; i < data.size(); i++) { - Eigen::Vector2d& point = data.at(i); - sum += point(1); - } - return sum; -} - -void GaussFit::draw(std::string title) { - TCanvas* c1 = new TCanvas("Gauss Fit", "Gauss Fit", 0, 0, 1600, 1200); - TH1F* h1 = new TH1F("", "Raw Data", CHANNEL_NUMBER, 0, CHANNEL_NUMBER); - TH1F* h2 = new TH1F("", "Fit Data", CHANNEL_NUMBER, 0, CHANNEL_NUMBER); - - for (int i = 0; i < data.size(); i++) { - Eigen::Vector2d& point = data.at(i); - h1->SetBinContent(point(0), point(1)); - } - for (int i = 0; i < CHANNEL_NUMBER; i++) h2->SetBinContent(i, Gaussian(i, parma)); - - c1->cd(1); - h1->Draw("L"); - h2->SetLineColor(kRed); - h2->Draw("SAME"); - c1->SaveAs(title.c_str()); -} - -#endif diff --git a/include/GaussNewton.h b/include/GaussNewton.h deleted file mode 100644 index 58df989c45b5a321573bb28cff93f1289d31fac5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3846 zcmd5_ug~wO#l9wk*@TlDZ6rjzlj{lp=?WAuFEy^ z%t$Ib7;9l{2lKl?y^}sZ4UD$sSO#WIL*8b1MW$xwmbp5SWqE|LUHpG2 z^YYMq_wjdS%qhmFV9^Jc9#BpAqDWe&-KJrj$l93wbKorZL{5#}F7|%|bc!`gW+VX@ zeu~#s4DSKv*Ab1|_-=uP+Gxuyymzr*&qOvqpGXCmRp9AML#lZ9*XQk3u?Ib}tjfN9 zD`dfa)-JVARqh8neJG7U6|p}N-z}uWGMtl1BFqR=V9~Z`S znuwO$iX(Ss<7e6{bj~CB<1zv2W z9$2Z%WDCAu%43KM@p=6I^lR(JtM8x7S@<^Y8DEA_uW#eq%a32IjmerFBKoPZ(Zt^t zI+4aWtkeWii>oz}6IAqMb@gF=-{iS6#$J>+$7mZ|_D!A|u(66NkN3-C>*zC#hQs=` zTioTSkK&pCwg2V&qTeIpx}L7{R#5||K~G%A2)h@1f0$?2^%ddXW2Ei=inDJq%JyzW z**A+iGpwi^m+#_yF_Tx*F@1L(re?Z)A18hT=VcRJsslxZy}++RcBo2LBdiMQG{LDs z&eQTPQhS^cKg+fzPomuT7%GAHg}&)^mW@>pJ76uFPvt#uta`2g8rIk`p2}1~zWP?D zTyIyBf!%$_^nIRZ_7q7mN4@dHNHEGn7H9P509?j5|B; z83i)4%&krPJp!65oP`Q_YotyJ<`zmV+5D(I|0cupSo^N4uQERQXzpb!G@5*4G}ldR z_YgOY95p~cnc+PXOL}EFZDMRI(wB{Zc4S6KnbYezJpP?;8V|Heu2w64w~tkDAoYxy z>YO*{ChjYJlQZ76c}67W7OQswU!6Qd)UP>n0@a|0^7VR#bG`E;uEX+<6`qo@ALS~x z_lFI5;;Pg4BCm>0=9Q{~Z&XEib7O6F#tI3~1e^V$ZWW#pG1AYKB7LS7J;d!y}MZ|BTEwLZXahaPbL@0oIr`KYED t=dg2Wt)=5gx+>m8#cg5Dtl>hIIub_EX~{-sGFOM6flvHJ%Q!H~{{W|*B+CE* diff --git a/include/LevenbergMarquardt.h b/include/LevenbergMarquardt.h deleted file mode 100644 index 0c8a2b14cdb7ee8df7692a050ee2bf9390ecc24e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6334 zcmd^E&2Af26h3Pt7QDeok&xXqZtVybC3F>9w2vv$A%Z;6O8oLd)>oi2|3v|UM zufUVAX2UZev4J-LzVDtnxj!@GOadE(D%-g;=bZbUzwg|c{`KdYoXAXu@=T`q&g7N6 zltUTIhw_2@tVu3MxHiJIBix_hcZttSd5Z5D^af6ICf~_xSeQX_fosnTZPm*mKfbm$ zF>rq(n!q}3WwIq-;My~X;f`#(-#NbTU*b*Wb9glesu`q)K&z6pPP;?go5Su7?#7<& zI)6gHGC6m@jC)SwK$erSf99^nUV7SOj?k6 z0D1a3kT%w#e%W3dd(d0M*z7m7Nle`J;Wc;7EA0wmq07t@PZ!uW+6j?!c}&%#$gkgxtm0Ry)#0c-*f$Oh}A2|hkeL<-@=OB>p}iLERL|l z0w48Ivo%9aEZy~S(mTGdX^-8MS#2ToOK~jGeIbrN-v55^(caHL)T5}f@i4OS>%os-Q(t3L$1Y1mK6kMg;(G-4 z)A+^=kRf6z3uNfOwBy36Wu?twed2Q5x|CHs^*Qs14uNIjax{RA2jGizzp`u}e6R$o zlx0I~8S09*cY$!6uwC4hWJ9gBkRh6IGApi$+<$|+uVVNxx+%vrohVh@-bNLjN36bs zE9BQ5WIE!~>i*hUkK0RDaBGA+wNmTSf1)+t~{lX64PjsOsr7!(lBM^PDBQ z4rN$xJc-R6n;SN(SaN))xSz}SMZYV{b)aL{c&1@hS-+b;nWve)X%c~HAGyiK32t*U z$2~o-FqT|x;bU_xMx+w!vJO;flx&C9+4~rJCywKFYIA457o$LAhTLr0?;A){!&_*% za~30YR&lReYsvDX_QI1NPary7e81M=DM#}~fr2NDOt@k+cZ!uojx|6(iTj0%CA~6C z`?z+H)R#p-=ME#J$m#V4KH-VEi3i#<|3>G86E3ZZsq_n+TJ=2b3~^qYyA0~AqbKYb zJ^O^U%DJgtZn(Q0cUr2`*E0+Cy;osZHhXd*vt4Hvryj>UY8{=qJWt^@pYE*JQeG(6 z5_{34|395+aawo2`;$3){uFiIwBkAC*(iS3rGQSm4_T{vAs11GDi;*k|>OZBGMF5cl#V ziuJ0VX7-B8-*)=d^Q>vzD~INoJ*%cq*;-RZCdQPJ)8|C1mnoi0OxkmCH_24F&dTVH zi+t(4;EMAies1L?IljX0s&h|o>~|`A zkfAi$-Sd1MlUE})Yvt%wGh|vR)!CZkeclXywSa9e%4XfPFXz*cg>#M*Z{2y!w=p`| zwv);*y(OOeEk1pm>L%#diNn;!Dr64M!a7`*BU!V(cq%woamw94!*LnFh;OGBDu%lT`e*;l>V*&sG diff --git a/include/clip.h b/include/clip.h deleted file mode 100644 index b2b6659..0000000 --- a/include/clip.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -#ifndef clip_h -#define clip_h - -#include "utils.h" - -#include - -class SigmaClip { -private: - int maxiters = 5; - double sigma = 3, minValue = INF, maxValue = -INF; - double (*cenF)(std::vector data) = nullptr; - double (*stdF)(std::vector data) = nullptr; - -public: - SigmaClip(double sigma = 3, int maxiters = 5, - double (*cenF)(std::vector data) = nullptr, - double (*stdF)(std::vector data) = nullptr); - ~SigmaClip(){}; - std::vector clip(std::vector data); - -private: - void computeBound(std::vector data); -}; - -SigmaClip::SigmaClip(double sigma_, int maxiters_, - double (*cenF_)(std::vector data), - double (*stdF_)(std::vector data)) { - sigma = sigma_; - maxiters = maxiters_; - cenF = cenF_ == nullptr ? dataAvg2D : cenF_; - stdF = stdF_ == nullptr ? dataStd2D : stdF_; -} - -void SigmaClip::computeBound(std::vector data) { - double std = (*stdF)(data); - double mean = (*cenF)(data); - - minValue = mean - (std * sigma); - maxValue = mean + (std * sigma); -} - -std::vector SigmaClip::clip(std::vector data) { - std::vector::iterator itor; - - minValue = INF, maxValue = -INF; - for (int k = 1; k <= maxiters; k++) { - computeBound(data); - for (itor = data.begin(); itor != data.end();) { - if ((*itor)(0) < minValue || (*itor)(0) > maxValue) - data.erase(itor); - else - itor++; - } - } - - return data; -} - -#endif diff --git a/include/utils.h b/include/utils.h deleted file mode 100644 index b29bae6..0000000 --- a/include/utils.h +++ /dev/null @@ -1,96 +0,0 @@ -#pragma once - -#ifndef utils_h -#define utils_h - -#include -#include - -#define DEBUG 0 -#define INF 1e9 -#define CHANNEL_NUMBER 4096 - -using namespace std; -using std::string; -using std::to_string; - -double dataMax(std::vector data) { - double x, m = -INF; - for (int i = 0; i < data.size(); i++) { - x = data.at(i); - m = std::max(m, x); - } - return m; -} - -double dataAvg(std::vector data) { - double m = 0; - for (int i = 0; i < data.size(); i++) m += data.at(i); - return m / data.size(); -} - -double dataStd(std::vector data) { - double m = 0; - double mu = dataAvg(data); - for (int i = 0; i < data.size(); i++) m += std::pow(data.at(i) - mu, 2); - return m / (data.size() - 1); -} - -double dataMax2D(std::vector data) { - double m = -INF; - for (int i = 0; i < data.size(); i++) { - Eigen::Vector2d &point = data.at(i); - m = std::max(m, point(1)); - } - return m; -} - -double dataAvg2D(std::vector data) { - int n = 0; - double m = 0; - for (int i = 0; i < data.size(); i++) { - Eigen::Vector2d &point = data.at(i); - n += point(1); - m += point(0) * point(1); - } - return m / n; -} - -double dataStd2D(std::vector data) { - int n = 0; - double m = 0; - double mu = dataAvg2D(data); - for (int i = 0; i < data.size(); i++) { - Eigen::Vector2d &point = data.at(i); - n += point(1); - m += std::pow(point(0) - mu, 2) * point(1); - } - return std::sqrt(m / (n - 1)); -} - -double dataMax2DInd(std::vector data) { - double x = 0, m = -INF; - for (int i = 0; i < data.size(); i++) { - Eigen::Vector2d &point = data.at(i); - if (point(1) > m) { - x = point(0); - m = point(1); - } - } - return x; -} - -double dataStd2DSQRT(std::vector data) { return std::sqrt(dataMax2D(data)); } - -string rmString(string str, string substr) { - int pos; - int len = substr.length(); - while (true) { - pos = str.find(substr); - if (pos < 0) break; - str.erase(pos, len); - } - return str; -} - -#endif diff --git a/main.cpp b/main.cpp deleted file mode 100644 index bfe513e..0000000 --- a/main.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "BlockHandler.h" -#include "CsvReader.h" -#include "FileHandler.h" -#include "utils.h" - -#include - -using namespace std; - -int main() { - int n, id, E; - string run; - FileHandler *FH; - BlockHandler *BH; - CsvReader CR("config1.csv"); - - CR.readData(); - n = CR.rows(); - E = stoi(CR(0, 3)); - - FH = new FileHandler[n - 1]; - BH = new BlockHandler[5]; - for (int i = 0; i < 5; i++) BH[i] = BlockHandler(i); - - for (int i = 1; i < n; i++) { - run = CR(i, 0); - FH[i - 1] = FileHandler("2016Q3D/root/raw/201609Q3D" + run + ".root", 5); - FH[i - 1].pX = stoi(CR(i, 2)); - FH[i - 1].readData(); - BH[stoi(CR(i, 1))].addData(FH[i - 1]); - } - - for (int i = 0; i < 5; i++) BH[i].splitData(); - - string s; - for (int i = 0; i < 5; i++) { - for (int j = 0; j < 8; j++) { - s = "result/bind/" + to_string(E) + "-" + to_string(i) + "-" + to_string(j) + ".txt"; - std::ofstream ofs(s); - for (int k = 0; k < BH[i].bind[j].data.size(); k++) { - auto p = BH[i].bind[j].data.at(k); - ofs << p(0) << " " << p(1) << std::endl; - } - } - } - - return 0; -} diff --git a/process.cpp b/process.cpp deleted file mode 100644 index 5df244d..0000000 --- a/process.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include - -void process() { - gInterpreter->AddIncludePath("./include"); - gROOT->ProcessLine(".L getADC.cpp"); - gROOT->ProcessLine("getADC(\"2016Q3D/root/raw/201609Q3D1002.root\")"); -} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f3fe5eb50d8adaf61706355768507c17c4261e84..24451cbe925d800dc36acc2f368dc8ec14a531e4 100644 GIT binary patch delta 6 NcmZ3%*uyxX2LK1!0#g70 delta 35 ncmeBST){Y@N2Zt|n<0lGl_8O#h#`-`76=U(^njR`fr|kEnb!t>