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) {
AEvent::~AEvent() {
// TODO Auto-generated destructor stub
delete gSignal;
delete gCFD;
delete fGraphSignal;
delete fGraphCFD;
delete fInputEvent;
}
......@@ -86,6 +86,7 @@ void AEvent::Reset() {
fAmpMax = 0.;
fTimeAmpMax = 0.;
fCFD = 0.;
}
void AEvent::SetInputEvent(RawEvent** event) {
......@@ -103,60 +104,68 @@ void AEvent::Init() {
fTime.Set(fNPoints);
fAmpCFD.Set(fNPoints);
gSignal = new TGraph();
gCFD = new TGraph();
fGraphSignal = new TGraph();
fGraphCFD = new TGraph();
fInputEvent = 0;
fCFratio = 0.;
fCFtimeDelay = 0.;
}
void AEvent::SetGraphs() {
gSignal->Set(fNPoints);
fGraphSignal->Set(fNPoints);
for (Int_t i=0; i<fNPoints; i++) {
gSignal->SetPoint(i, fTime[i], fAmpPos[i]);
fGraphSignal->SetPoint(i, fTime[i], fAmpPos[i]);
}
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++) {
//CFD method
if(i>td) {
fAmpCFD[i] = fAmpPos[i]*c*(-1);
fAmpCFD[i] = fAmpCFD[i] + fAmpPos[i - td];
gCFD->SetPoint(i, fTime[i], fAmpCFD[i]);
if(i>fCFtimeDelay) {
// fAmpCFD[i] = fAmpPos[i]*cfRatio*(-1);
fAmpCFD[i] = fAmpPos[i]*fCFratio*(-1);
// 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
if(fAmpCFD[i] > maxCFD) {
maxCFD = fAmpCFD[i];
imax = i;
tmax = fTime[i];
}
//point for min CFD amplitude
if(fAmpCFD[i] < minCFD) {
minCFD = fAmpCFD[i];
imin = i;
tmin = fTime[i];
}
}
//finding "zero" of CFD amplitude
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;
......
......@@ -41,11 +41,14 @@ private:
TArrayD fAmpCFD; //array for CFD amplitudes (attenuated, inversed and delayed)
Double_t fCFD; //zero-crossing time
TGraph *gSignal;
TGraph *gCFD;
TGraph *fGraphSignal;
TGraph *fGraphCFD;
RawEvent *fInputEvent; //!
Double_t fCFratio; //!
Double_t fCFtimeDelay; //!
public:
AEvent();
AEvent(const Int_t npoints);
......@@ -56,18 +59,23 @@ public:
void ProcessEvent();
// void Integral()
void SetInputEvent(RawEvent** event);
void SetCFratio(Double_t ratio) { fCFratio = ratio; };
void SetCFtimeDelay(Double_t timeDelay) { fCFtimeDelay = timeDelay; };
void Reset();
//Resets arrays to zeros
TGraph* GetGraph() {
return gCFD;
//todo
return fGraphCFD;
// return gSignal;
}
private:
void Init();
void SetGraphs();
void SetCFD(/*Double_t c = 0.5, Int_t td = 5*/);
void SetCFD();
};
#endif /* DATACLASSES_AEVENT_H_ */
......@@ -6,6 +6,8 @@ void analyse()
TTree *tr = (TTree*)f->Get("rtree");
const Int_t noBranches = 4;
const Double_t cfRatio = 0.5;
const Int_t cfTD = 5;
TString bName;
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()
wevent[j] = new AEvent();
bName.Form("Ach%d.", j);
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
}
......
......@@ -26,7 +26,7 @@ void testShowCFD()
for (Int_t i = 0; i < 6; i++) {
c1->cd(i+1);
gr[i]->Draw();
gr[i]->Draw("");
}
// 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