Commit d92d4eae authored by Vratislav Chudoba's avatar Vratislav Chudoba

Function AEvent::SetCFD() modified.

parent 3ac26a0b
...@@ -22,8 +22,8 @@ AEvent::AEvent(const Int_t npoints) : fNPoints(npoints) { ...@@ -22,8 +22,8 @@ AEvent::AEvent(const Int_t npoints) : fNPoints(npoints) {
AEvent::~AEvent() { AEvent::~AEvent() {
// TODO Auto-generated destructor stub // TODO Auto-generated destructor stub
delete gSignal; delete fGraphSignal;
delete gCFD; delete fGraphCFD;
delete fInputEvent; delete fInputEvent;
} }
...@@ -86,6 +86,7 @@ void AEvent::Reset() { ...@@ -86,6 +86,7 @@ void AEvent::Reset() {
fAmpMax = 0.; fAmpMax = 0.;
fTimeAmpMax = 0.; fTimeAmpMax = 0.;
fCFD = 0.;
} }
void AEvent::SetInputEvent(RawEvent** event) { void AEvent::SetInputEvent(RawEvent** event) {
...@@ -103,60 +104,68 @@ void AEvent::Init() { ...@@ -103,60 +104,68 @@ void AEvent::Init() {
fTime.Set(fNPoints); fTime.Set(fNPoints);
fAmpCFD.Set(fNPoints); fAmpCFD.Set(fNPoints);
gSignal = new TGraph(); fGraphSignal = new TGraph();
gCFD = new TGraph(); fGraphCFD = new TGraph();
fInputEvent = 0; fInputEvent = 0;
fCFratio = 0.;
fCFtimeDelay = 0.;
} }
void AEvent::SetGraphs() { void AEvent::SetGraphs() {
gSignal->Set(fNPoints); fGraphSignal->Set(fNPoints);
for (Int_t i=0; i<fNPoints; i++) { for (Int_t i=0; i<fNPoints; i++) {
gSignal->SetPoint(i, fTime[i], fAmpPos[i]); fGraphSignal->SetPoint(i, fTime[i], fAmpPos[i]);
} }
return; return;
} }
void AEvent::SetCFD(/*Double_t c, Int_t td*/) { void AEvent::SetCFD() {
// Double_t c = 0.5; //attenuation coefficient
// Int_t td = 5; //time of delay in points
Double_t level = 100.; //todo what is it?
fGraphCFD->Set(fNPoints);
//working variables
Double_t maxCFD = 0., minCFD = 0.;
Int_t imax = 0, imin = 0;
gCFD->Set(fNPoints);
Double_t c = 0.5; //attenuation coefficient
Int_t td = 5; //time of delay in points
Double_t maxCFD, minCFD, imax, imin, tmax, tmin, level;
maxCFD = 0.;
minCFD = 0.;
level = 100.;
for (Int_t i=0; i<fNPoints; i++) { for (Int_t i=0; i<fNPoints; i++) {
//CFD method //CFD method
if(i>td) { if(i>fCFtimeDelay) {
fAmpCFD[i] = fAmpPos[i]*c*(-1); // fAmpCFD[i] = fAmpPos[i]*cfRatio*(-1);
fAmpCFD[i] = fAmpCFD[i] + fAmpPos[i - td]; fAmpCFD[i] = fAmpPos[i]*fCFratio*(-1);
gCFD->SetPoint(i, fTime[i], fAmpCFD[i]); // fAmpCFD[i] = fAmpCFD[i] + fAmpPos[i - timeDelay];
fAmpCFD[i] = fAmpCFD[i] + fAmpPos[i - fCFtimeDelay];
fGraphCFD->SetPoint(i, fTime[i], fAmpCFD[i]);
} }
//point for max CFD amplitude //point for max CFD amplitude
if(fAmpCFD[i] > maxCFD) { if(fAmpCFD[i] > maxCFD) {
maxCFD = fAmpCFD[i]; maxCFD = fAmpCFD[i];
imax = i; imax = i;
tmax = fTime[i];
} }
//point for min CFD amplitude //point for min CFD amplitude
if(fAmpCFD[i] < minCFD) { if(fAmpCFD[i] < minCFD) {
minCFD = fAmpCFD[i]; minCFD = fAmpCFD[i];
imin = i; imin = i;
tmin = fTime[i];
} }
} }
//finding "zero" of CFD amplitude //finding "zero" of CFD amplitude
for(Int_t j = imin; j < imax; j++) { for(Int_t j = imin; j < imax; j++) {
if(abs(fAmpCFD[j]) < level) {level = abs(fAmpCFD[j]); fCFD = fTime[j];} if(abs(fAmpCFD[j]) < level) {
level = abs(fAmpCFD[j]);
fCFD = fTime[j];
}
} }
return; return;
......
...@@ -41,11 +41,14 @@ private: ...@@ -41,11 +41,14 @@ private:
TArrayD fAmpCFD; //array for CFD amplitudes (attenuated, inversed and delayed) TArrayD fAmpCFD; //array for CFD amplitudes (attenuated, inversed and delayed)
Double_t fCFD; //zero-crossing time Double_t fCFD; //zero-crossing time
TGraph *gSignal; TGraph *fGraphSignal;
TGraph *gCFD; TGraph *fGraphCFD;
RawEvent *fInputEvent; //! RawEvent *fInputEvent; //!
Double_t fCFratio; //!
Double_t fCFtimeDelay; //!
public: public:
AEvent(); AEvent();
AEvent(const Int_t npoints); AEvent(const Int_t npoints);
...@@ -56,18 +59,23 @@ public: ...@@ -56,18 +59,23 @@ public:
void ProcessEvent(); void ProcessEvent();
// void Integral() // void Integral()
void SetInputEvent(RawEvent** event); void SetInputEvent(RawEvent** event);
void SetCFratio(Double_t ratio) { fCFratio = ratio; };
void SetCFtimeDelay(Double_t timeDelay) { fCFtimeDelay = timeDelay; };
void Reset(); void Reset();
//Resets arrays to zeros //Resets arrays to zeros
TGraph* GetGraph() { TGraph* GetGraph() {
return gCFD; //todo
return fGraphCFD;
// return gSignal; // return gSignal;
} }
private: private:
void Init(); void Init();
void SetGraphs(); void SetGraphs();
void SetCFD(/*Double_t c = 0.5, Int_t td = 5*/); void SetCFD();
}; };
#endif /* DATACLASSES_AEVENT_H_ */ #endif /* DATACLASSES_AEVENT_H_ */
...@@ -6,6 +6,8 @@ void analyse() ...@@ -6,6 +6,8 @@ void analyse()
TTree *tr = (TTree*)f->Get("rtree"); TTree *tr = (TTree*)f->Get("rtree");
const Int_t noBranches = 4; const Int_t noBranches = 4;
const Double_t cfRatio = 0.5;
const Int_t cfTD = 5;
TString bName; TString bName;
RawEvent *revent[noBranches]; // pointer to the array (of RawEvent class) in which raw data for each channel will be put RawEvent *revent[noBranches]; // pointer to the array (of RawEvent class) in which raw data for each channel will be put
...@@ -25,6 +27,8 @@ void analyse() ...@@ -25,6 +27,8 @@ void analyse()
wevent[j] = new AEvent(); wevent[j] = new AEvent();
bName.Form("Ach%d.", j); bName.Form("Ach%d.", j);
wevent[j]->SetInputEvent(&revent[j]); //takes raw event from RawEvent wevent[j]->SetInputEvent(&revent[j]); //takes raw event from RawEvent
wevent[j]->SetCFratio(cfRatio);
wevent[j]->SetCFtimeDelay(cfTD);
tw->Bronch(bName.Data(), "AEvent", &wevent[j]); // create branches in atree to hold analyzed data tw->Bronch(bName.Data(), "AEvent", &wevent[j]); // create branches in atree to hold analyzed data
} }
......
...@@ -26,7 +26,7 @@ void testShowCFD() ...@@ -26,7 +26,7 @@ void testShowCFD()
for (Int_t i = 0; i < 6; i++) { for (Int_t i = 0; i < 6; i++) {
c1->cd(i+1); c1->cd(i+1);
gr[i]->Draw(); gr[i]->Draw("");
} }
// c1->cd(2); // c1->cd(2);
......
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