Commit fec0cfdd authored by Vratislav Chudoba's avatar Vratislav Chudoba
parents 9cac4343 6486ffd7
...@@ -23,9 +23,9 @@ int main(int argc, char* argv[]) ...@@ -23,9 +23,9 @@ int main(int argc, char* argv[])
if ( (argc < 3) || (argc > 4) ) { if ( (argc < 3) || (argc > 5) ) {
// Tell the user how to run the program // Tell the user how to run the program
std::cerr << "Usage: " << argv[0] << " [list with input files] [outputfile] [number of points in one event (1000)]" << std::endl; std::cerr << "Usage: " << argv[0] << " [list with input files] [outputfile] [smoothParameter (1 - smoothed, 0 - not)] [number of points in one event (1000 or 1024)]" << std::endl;
/* "Usage messages" are a conventional way of telling the user /* "Usage messages" are a conventional way of telling the user
* how to run a program if they enter the command incorrectly. * how to run a program if they enter the command incorrectly.
*/ */
...@@ -34,8 +34,10 @@ int main(int argc, char* argv[]) ...@@ -34,8 +34,10 @@ int main(int argc, char* argv[])
TString infiles = argv[1]; TString infiles = argv[1];
TString ofile = argv[2]; TString ofile = argv[2];
TString Asize = argv[3]; TString smooth = argv[3];
Int_t kEventSize; TString Asize = argv[4];
Int_t kEventSize,intSmoth;
Bool_t smoothPar = kFALSE;
if(argc==3) { if(argc==3) {
kEventSize = 1024; kEventSize = 1024;
...@@ -43,10 +45,24 @@ int main(int argc, char* argv[]) ...@@ -43,10 +45,24 @@ int main(int argc, char* argv[])
noiseMax = 100.; noiseMax = 100.;
Info("convertRawToAnalyzed", "Event size was set to %d", kEventSize); Info("convertRawToAnalyzed", "Event size was set to %d", kEventSize);
} }
if(argc==4) {
if(argc>3) {
intSmoth = smooth.Atoi();
if((intSmoth!=1) && (intSmoth!=0)) {
std::cerr<< argv[3] << " smoothpar should be 1 or 0 " << std::endl;
return 1;
}
if( intSmoth == 1 ) {
smoothPar = kTRUE;
Info("convertRawToAnalyzed", "we gona SMOOTH");
}
else {Info("convertRawToAnalyzed", "we NOT gonna SMOOTH");}
}
if(argc==5) {
kEventSize = Asize.Atoi(); kEventSize = Asize.Atoi();
if(kEventSize!=1000) { if((kEventSize!=1000) && ((kEventSize!=1024))) {
std::cerr<< argv[0] << " the size of Events should be 1000 in this case " << std::endl; std::cerr<< argv[0] << " the size of Events should be 1000 or 1024 " << std::endl;
return 1; return 1;
} }
} }
...@@ -54,7 +70,7 @@ int main(int argc, char* argv[]) ...@@ -54,7 +70,7 @@ int main(int argc, char* argv[])
TFile *f = new TFile(infiles.Data()); TFile *f = new TFile(infiles.Data());
if (/*f == 0 || */f->IsZombie()) { if (/*f == 0 || */f->IsZombie()) {
Error("convertRawToAnalyzed", "Input file was not opened. Program will be terminated"); Error("convertRawToAnalyzed", "Input file was not opened. Program will be terminated");
return 2; return 1;
} }
TTree *tr = (TTree*)f->Get("rtree"); TTree *tr = (TTree*)f->Get("rtree");
...@@ -66,8 +82,6 @@ int main(int argc, char* argv[]) ...@@ -66,8 +82,6 @@ int main(int argc, char* argv[])
tr->SetBranchAddress(bName.Data(), &revent[j]); tr->SetBranchAddress(bName.Data(), &revent[j]);
} }
TFile *fw = new TFile(ofile.Data(), "RECREATE"); //create .root file with somehow analyzed data TFile *fw = new TFile(ofile.Data(), "RECREATE"); //create .root file with somehow analyzed data
TTree *tw = new TTree("atree", "title of drs4 analysis tree"); //create analysis tree atree in it TTree *tw = new TTree("atree", "title of drs4 analysis tree"); //create analysis tree atree in it
...@@ -90,7 +104,7 @@ int main(int argc, char* argv[]) ...@@ -90,7 +104,7 @@ int main(int argc, char* argv[])
//cout<<" Event "<<i<<endl; //cout<<" Event "<<i<<endl;
for (Int_t j = 0; j<noBranches; j++) { for (Int_t j = 0; j<noBranches; j++) {
wevent[j]->Reset(); wevent[j]->Reset();
wevent[j]->ProcessEvent(); //here all the analysis is going on so far wevent[j]->ProcessEvent(smoothPar); //here all the analysis is going on so far
} }
if ( !(i%100) ) { printf("Found event #%lld\n", i); } if ( !(i%100) ) { printf("Found event #%lld\n", i); }
......
...@@ -50,19 +50,22 @@ void AEvent::ProcessEvent(Bool_t bSmooth) { ...@@ -50,19 +50,22 @@ void AEvent::ProcessEvent(Bool_t bSmooth) {
SetMaxAmplitudes(); SetMaxAmplitudes();
SetGraphs();
if (bSmooth == kTRUE) { if (bSmooth == kTRUE) {
SmoothGraphs(); SmoothGraphs();
} }
else {
SetGraphs();
}
FindFrontProperties(); FindFrontProperties();
SetLED(); SetLED();
// SetGraphs(); // SetGraphs();
SetCFD(); SetCFD();
SetChargeCFD(); SetChargeCFD();
SetChargeLED(); SetChargeLED();
SetChargeTF(); SetChargeTF();
SetToT();
// SmoothGraphs(); // SmoothGraphs();
...@@ -84,6 +87,8 @@ void AEvent::Reset() { ...@@ -84,6 +87,8 @@ void AEvent::Reset() {
fTime10=0.; fTime10=0.;
fTime90=0.; fTime90=0.;
fTimeMid=0.; fTimeMid=0.;
fToT=-100.;
fAmpMid=0.;
fAmpMax = 0.; fAmpMax = 0.;
fTimeAmpMax = 0.; fTimeAmpMax = 0.;
fTimeCFD = -100.; fTimeCFD = -100.;
...@@ -110,7 +115,7 @@ void AEvent::Init() { ...@@ -110,7 +115,7 @@ void AEvent::Init() {
fGraphSignal = new TGraph(); fGraphSignal = new TGraph();
fGraphCFD = new TGraph(); fGraphCFD = new TGraph();
fGraphSmooth = new TGraph(); // fGraphSmooth = new TGraph();
fInputEvent = 0; fInputEvent = 0;
fCFratio = 0.; fCFratio = 0.;
...@@ -135,10 +140,8 @@ void AEvent::SetGraphs() { ...@@ -135,10 +140,8 @@ void AEvent::SetGraphs() {
void AEvent::SmoothGraphs() { void AEvent::SmoothGraphs() {
//smoothing graph //smoothing graph
fGraphSignal->Set(fNPoints - fWinSize/2);
fGraphSmooth->Set(fNPoints - fWinSize/2);
//Int_t winSize = 5; //number of smoothing points
Int_t winMidSize = fWinSize / 2; Int_t winMidSize = fWinSize / 2;
Double_t tmin, tmax, meanTime, meanAmp, sumAmp; Double_t tmin, tmax, meanTime, meanAmp, sumAmp;
...@@ -159,7 +162,7 @@ void AEvent::SmoothGraphs() { ...@@ -159,7 +162,7 @@ void AEvent::SmoothGraphs() {
meanAmp = sumAmp / fWinSize; meanAmp = sumAmp / fWinSize;
//cout<<"mean amp "<<fAmpPos[i]<<endl; //cout<<"mean amp "<<fAmpPos[i]<<endl;
fGraphSmooth->SetPoint(i, meanTime, meanAmp); fGraphSignal->SetPoint(i, meanTime, meanAmp);
} }
...@@ -249,6 +252,7 @@ void AEvent::FindFrontProperties() { ...@@ -249,6 +252,7 @@ void AEvent::FindFrontProperties() {
fEdgeXi = fit1->GetChisquare(); fEdgeXi = fit1->GetChisquare();
fTimeMid = (fTime90 -fTime10)*0.5 + fTime10; //time point between fTime90 and fTime10 fTimeMid = (fTime90 -fTime10)*0.5 + fTime10; //time point between fTime90 and fTime10
fAmpMid = fGraphSignal->Eval(fTimeMid);
//adding point where fit function crosses zero //adding point where fit function crosses zero
Double_t a = 0, b = 0; Double_t a = 0, b = 0;
...@@ -427,3 +431,29 @@ void AEvent::SetLED(Double_t threshold) { ...@@ -427,3 +431,29 @@ void AEvent::SetLED(Double_t threshold) {
// сделать через функцию getpoint и цикл по точкам от // сделать через функцию getpoint и цикл по точкам от
} }
void AEvent::SetToT() {
Double_t time = fTimeMid;
Double_t timeBack = 0;
const Double_t ns = 15.; //withing this interval signal should end for sure, in nanosec
const Double_t timeStep = 0.05;
//cout<<"fAmpMid "<<fAmpMid<<endl;
while( fGraphSignal->Eval(time) >= fAmpMid && time < fTimeMid + ns) {
//cout<<"timeback "<<timeBack<<endl;
//cout<<"fGraphSignal->Eval(time) "<<fGraphSignal->Eval(time)<<endl;
//cout<<endl;
//if(timeBack>150.) {return;}
timeBack = time;
time = time + timeStep;
}
//cout<<"timeback "<<timeBack<<endl;
fToT = timeBack - fTimeMid;
//cout<<"ftot "<<fToT<<endl;
}
...@@ -44,6 +44,8 @@ private: ...@@ -44,6 +44,8 @@ private:
Double_t fTime10; //time of 10% of rising edge amplitude in ns Double_t fTime10; //time of 10% of rising edge amplitude in ns
Double_t fTime90; //time of 10% of rising edge amplitude in ns Double_t fTime90; //time of 10% of rising edge amplitude in ns
Double_t fTimeMid; //time point between fTime90 and fTime10 Double_t fTimeMid; //time point between fTime90 and fTime10
Double_t fAmpMid; //amplitude in fTimeMid point. Used in ToT on 50% of rising edge determination
Double_t fToT;
TArrayD fAmpCFD; //array for CFD amplitudes (attenuated, inversed and delayed) TArrayD fAmpCFD; //array for CFD amplitudes (attenuated, inversed and delayed)
Double_t fTimeCFD; //zero-crossing time Double_t fTimeCFD; //zero-crossing time
...@@ -56,7 +58,7 @@ private: ...@@ -56,7 +58,7 @@ private:
TGraph *fGraphSignal; TGraph *fGraphSignal;
TGraph *fGraphCFD; TGraph *fGraphCFD;
TGraph *fGraphSmooth; // TGraph *fGraphSmooth;
RawEvent *fInputEvent; //! RawEvent *fInputEvent; //!
...@@ -107,6 +109,10 @@ public: ...@@ -107,6 +109,10 @@ public:
void SetSmoothPoints(Int_t numofp) {fWinSize = numofp; }; void SetSmoothPoints(Int_t numofp) {fWinSize = numofp; };
//set number of smoothing points //set number of smoothing points
void SetToT();
//calculate time-over-threshold. the threshold value is fTimeMid - middle point of the rising edge
//ToT is calculated within 15 ns range in order to consider all the weirdness of the signal form
void Reset(); void Reset();
//Resets arrays to zeros //Resets arrays to zeros
...@@ -121,10 +127,10 @@ public: ...@@ -121,10 +127,10 @@ public:
return fGraphSignal; return fGraphSignal;
} }
TGraph* GetGraphSmooth() { /*TGraph* GetGraphSmooth() {
return fGraphSmooth; return fGraphSmooth;
} }*/
//draws signal shape graphs //draws signal shape graphs
void FindFrontProperties(); void FindFrontProperties();
......
...@@ -27,7 +27,7 @@ void testShowGraphs() ...@@ -27,7 +27,7 @@ void testShowGraphs()
// TFile fr("../data/dataTektronix/exp18.root"); // TFile fr("../data/dataTektronix/exp18.root");
TFile fr("../data/dataDSR4/analysis_08_2.root"); TFile fr("../data/dataDSR4/analysis_07_8.root");
// TFile fr("../data/dataDSR4/Neurad_081216_2NEW.root"); // TFile fr("../data/dataDSR4/Neurad_081216_2NEW.root");
// TFile fr("../data/dataTektronix/exp18.root"); // TFile fr("../data/dataTektronix/exp18.root");
...@@ -81,7 +81,7 @@ void testShowGraphs() ...@@ -81,7 +81,7 @@ void testShowGraphs()
//f1->SetRange(t10[k], t90[k]); //f1->SetRange(t10[k], t90[k]);
//gr[k]->Fit(f1, "RQ"); //gr[k]->Fit(f1, "RQ");
} }
c1->Print(Form("../macros/picsDRS4/file%s/signals%s", foldername, ext)); //c1->Print(Form("../macros/picsDRS4/file%s/signals%s", foldername, ext));
// c1->cd(2); // c1->cd(2);
// tr->Draw("gAmp.Draw()","","goff",1,124); // tr->Draw("gAmp.Draw()","","goff",1,124);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment