impletment the fitting in GeneralSort
This commit is contained in:
parent
f10c5feab1
commit
b89205ab8a
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -91,7 +91,8 @@
|
|||
"transfer_test.C": "cpp",
|
||||
"Transfer.C": "cpp",
|
||||
"Simulation_Helper.C": "cpp",
|
||||
"Check_Simulation.C": "cpp"
|
||||
"Check_Simulation.C": "cpp",
|
||||
"AutoFit.C": "cpp"
|
||||
},
|
||||
|
||||
"better-comments.multilineComments": true,
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
//Global fit paramaters
|
||||
|
||||
vector<double> BestFitMean;
|
||||
vector<double> BestFitCount;
|
||||
vector<double> BestFitSigma;
|
||||
std::vector<double> BestFitMean;
|
||||
std::vector<double> BestFitCount;
|
||||
std::vector<double> BestFitSigma;
|
||||
|
||||
TString recentFitMethod;
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <TSystem.h>
|
||||
#include <TMath.h>
|
||||
|
||||
|
||||
Long64_t processedEntry = 0;
|
||||
float lastPercentage = 0;
|
||||
|
||||
|
@ -26,6 +25,12 @@ Bool_t GeneralSort::Process(Long64_t entry){
|
|||
for( int j = 0; j < detNum[i]; j++){
|
||||
eE[i][j] = TMath::QuietNaN();
|
||||
eT[i][j] = 0;
|
||||
|
||||
if( isTraceExist && traceMethod > 0){
|
||||
teE[i][j] = TMath::QuietNaN();
|
||||
teT[i][j] = TMath::QuietNaN();
|
||||
teR[i][j] = TMath::QuietNaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,9 +45,7 @@ Bool_t GeneralSort::Process(Long64_t entry){
|
|||
for( int i = 0 ; i < multi; i++){
|
||||
int detID = mapping[bd[i]][ch[i]];
|
||||
int detType = FindDetType(detID, detMaxID);
|
||||
|
||||
int low = (i == 0 ? 0 : detMaxID[detType-1]);
|
||||
|
||||
int reducedDetID = detID - low;
|
||||
|
||||
eE[detType][reducedDetID] = e[i] * detParity[detType];
|
||||
|
@ -50,6 +53,7 @@ Bool_t GeneralSort::Process(Long64_t entry){
|
|||
|
||||
}
|
||||
|
||||
//@===================================== Trace
|
||||
if( isTraceExist && traceMethod >= 0 ){
|
||||
|
||||
b_tl->GetEntry(entry);
|
||||
|
@ -74,6 +78,42 @@ Bool_t GeneralSort::Process(Long64_t entry){
|
|||
gTrace->SetPoint(k, k, trace[i][k]);
|
||||
}
|
||||
|
||||
//***=================== fit
|
||||
if( traceMethod == 1){
|
||||
gFit = new TF1("gFit", fitFunc, 0, traceLength, numPara);
|
||||
gFit->SetLineColor(6);
|
||||
gFit->SetRange(0, traceLength);
|
||||
|
||||
gFit->SetParameter(0, e[i]);
|
||||
gFit->SetParameter(1, 100); //triggerTime //TODO how to not hardcode?
|
||||
gFit->SetParameter(2, 10); //rise time //TODO how to not hardcode?
|
||||
gFit->SetParameter(3, trace[i][0]); //base line
|
||||
gFit->SetParameter(4, 100); // decay //TODO how to not hardcode?
|
||||
gFit->SetParameter(5, -0.01); // pre-rise slope //TODO how to not hardcode?
|
||||
|
||||
gFit->SetParLimits(1, 85, 125); //raneg for the trigger time
|
||||
gFit->SetParLimits(5, -2, 0);
|
||||
|
||||
gTrace->Fit("gFit", "QR", "", 0, traceLength);
|
||||
|
||||
|
||||
int detType = FindDetType(detID, detMaxID);
|
||||
int low = (i == 0 ? 0 : detMaxID[detType-1]);
|
||||
int reducedDetID = detID - low;
|
||||
|
||||
teE[detType][reducedDetID] = gFit->GetParameter(0);
|
||||
teT[detType][reducedDetID] = gFit->GetParameter(1);
|
||||
teR[detType][reducedDetID] = gFit->GetParameter(2);
|
||||
|
||||
delete gFit;
|
||||
gFit = nullptr;
|
||||
}
|
||||
|
||||
//***=================== Trapezoid filter
|
||||
if( traceMethod == 2){
|
||||
//TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,11 +28,12 @@ the sequence of each method
|
|||
|
||||
******************************************/
|
||||
|
||||
|
||||
/// in Process_Sort, copy the GeneralSortMapping.h to ~/.proof/working/
|
||||
#include "../working/Mapping.h"
|
||||
#include "../armory/AnalysisLib.h"
|
||||
|
||||
//^######################################### FIT FUNCTION
|
||||
const int numPara = 6;
|
||||
double fitFunc(double * x, double * par){
|
||||
/// par[0] = A
|
||||
/// par[1] = t0
|
||||
|
@ -46,6 +47,50 @@ double fitFunc(double * x, double * par){
|
|||
return par[3] + par[0] * (1 - TMath::Exp(- (x[0] - par[1]) / par[2]) ) * TMath::Exp(- (x[0] - par[1]) / par[4]);
|
||||
}
|
||||
|
||||
//^######################################### TRAPEZOID
|
||||
TGraph * TrapezoidFilter(TGraph * trace){
|
||||
///Trapezoid filter https://doi.org/10.1016/0168-9002(94)91652-7
|
||||
|
||||
//TODO how to not hard code?
|
||||
int baseLineEnd = 80;
|
||||
int riseTime = 10; //ch
|
||||
int flatTop = 20;
|
||||
float decayTime = 2000;
|
||||
|
||||
TGraph * trapezoid = new TGraph();
|
||||
trapezoid->Clear();
|
||||
|
||||
///find baseline;
|
||||
double baseline = 0;
|
||||
for( int i = 0; i < baseLineEnd; i++){
|
||||
baseline += trace->Eval(i);
|
||||
}
|
||||
baseline = baseline*1./baseLineEnd;
|
||||
|
||||
int length = trace->GetN();
|
||||
|
||||
double pn = 0.;
|
||||
double sn = 0.;
|
||||
for( int i = 0; i < length ; i++){
|
||||
|
||||
double dlk = trace->Eval(i) - baseline;
|
||||
if( i - riseTime >= 0 ) dlk -= trace->Eval(i - riseTime) - baseline;
|
||||
if( i - flatTop - riseTime >= 0 ) dlk -= trace->Eval(i - flatTop - riseTime) - baseline;
|
||||
if( i - flatTop - 2*riseTime >= 0) dlk += trace->Eval(i - flatTop - 2*riseTime) - baseline;
|
||||
|
||||
if( i == 0 ){
|
||||
pn = dlk;
|
||||
sn = pn + dlk*decayTime;
|
||||
}else{
|
||||
pn = pn + dlk;
|
||||
sn = sn + pn + dlk*decayTime;
|
||||
}
|
||||
trapezoid->SetPoint(i, i, sn / decayTime / riseTime);
|
||||
}
|
||||
return trapezoid;
|
||||
}
|
||||
|
||||
//^######################################### Class definition
|
||||
// Header file for the classes stored in the TTree if any.
|
||||
class GeneralSort : public TSelector {
|
||||
public :
|
||||
|
@ -95,6 +140,7 @@ public :
|
|||
|
||||
arr = nullptr;
|
||||
gTrace = nullptr;
|
||||
gFit = nullptr;
|
||||
arrTrapezoid = nullptr;
|
||||
gTrapezoid = nullptr;
|
||||
|
||||
|
@ -146,6 +192,7 @@ public :
|
|||
//trace
|
||||
TClonesArray * arr ;//!
|
||||
TGraph * gTrace; //!
|
||||
TF1 * gFit; //!
|
||||
TClonesArray * arrTrapezoid ;//!
|
||||
TGraph * gTrapezoid; //!
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ if [ $# -eq 0 ] || [ $1 == "-help" ]; then
|
|||
echo " RunNum = run number / \"lastRun\" "
|
||||
echo " EventBld = 2/1/0/-1/-2 || 2 = with Trace"
|
||||
echo " GeneralSort = n/0/-n || n = number of worker"
|
||||
echo " TraceMethod = -1/0/1/2 || -1 no trace, 0 save trace, 1 fit, 2 trapezoid"
|
||||
echo " TraceMethod = -1/0/1/2 || -1 no trace, 0 save trace, 1 fit, 2 trapezoid(not implemented)"
|
||||
echo " Monitors = 2/1/0 || 1 = single run, 2 = using the list in ChainMonitors.C"
|
||||
echo " 10 = single run and post to websrv, 20 = list runs and post to websrv"
|
||||
echo ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user