Commit 82def348 authored by Kostyleva D.A's avatar Kostyleva D.A

CFD method is added to class AEvent

parent 567705d8
......@@ -111,35 +111,18 @@ int main(int argc, const char * argv[])
TFile* rfile = new TFile(outroot, "RECREATE");
TTree* rtree = new TTree("rtree", "tree for drs4 analysis");
//rtree->Branch("t1", &t1, "t1/D"); //br for time of threshold crossing signal in 1 ch
// rtree->Branch("t2", &t2, "t2/D"); //br for time of threshold crossing signal in 2 ch
// int ncell;
// const int ncellMax = 1024;
// double amp_ch1[ncellMax], time_ch1[ncellMax]; //variable size array
//------for other channels
// double amp_ch2[ncellMax], time_ch2[ncellMax];
// rtree->Branch("ncell", &ncell, "ncell/I");
// rtree->Branch("amp_ch1", amp_ch1, "amp_ch1[ncell]/D");
// rtree->Branch("time_ch1", time_ch1, "time_ch1[ncell]/D");
// RawEvent *event = new RawEvent();
// rtree->Bronch("rawEvent", "RawEvent", &event);
TString bName;
RawEvent *event[4];
RawEvent* event[4];
for (Int_t i = 0; i<4; i++) {
// RawEvent* event = new RawEvent[i];
event[i] = new RawEvent();
bName.Form("ch%d.", i);
rtree->Bronch(bName.Data(), "RawEvent", &event[i]);
}
//------for other channels
// rtree->Branch("amp_ch2", amp_ch2, "amp_ch2[ncell]/D");
// rtree->Branch("time_ch2", time_ch2, "time_ch2[ncell]/D");
//----------------
// open the binary waveform file
......@@ -351,7 +334,7 @@ int main(int argc, const char * argv[])
rfile->Close();
// delete event;
// delete[] event;
delete[] event;
return 1;
}
......
......@@ -7,7 +7,7 @@
#include "AEvent.h"
AEvent::AEvent() : fNPoints(1024) {
AEvent::AEvent() : fNPoints(1024) { //fNPoints is number of points in one event, 1024 or 1000
// TODO Auto-generated constructor stub
Init();
......@@ -53,7 +53,7 @@ void AEvent::ProcessEvent() {
Double_t maxAmpT = 0.;
maxAmp = fAmpPos[0];
for(Int_t j=0; j<NCELLS; j++) {
for(Int_t j=0; j < NCELLS; j++) {
if(fAmpPos[j] > maxAmp) {
maxAmp = fAmpPos[j];
maxAmpT = fTime[j];
......@@ -75,6 +75,7 @@ void AEvent::Reset() {
for (Int_t i = 0; i < NCELLS; i++) {
fAmpPos[i] = 0;
fTime[i] = 0;
fAmpCFD[i] = 0;
}
fAmpMax = 0.;
......@@ -109,5 +110,46 @@ void AEvent::SetGraphs() {
return;
}
void AEvent::SetCFD() {
void AEvent::SetCFD(/*Double_t c, Int_t td*/) {
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]);
}
//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];}
}
return;
}
......@@ -36,6 +36,8 @@ private:
Double_t fTime[NCELLS]; //array for raw times
Double_t fAmpMax;
Double_t fTimeAmpMax;
Double_t fAmpCFD[NCELLS]; //array for CFD amplitudes (attenuated, inversed and delayed)
Double_t fCFD; //zero-crossing time
TGraph *gSignal;
TGraph *gCFD;
......@@ -55,13 +57,14 @@ public:
//Resets arrays to zeros
TGraph* GetGraph() {
return gSignal;
return gCFD;
// return gSignal;
}
private:
void Init();
void SetGraphs();
void SetCFD();
void SetCFD(/*Double_t c = 0.5, Int_t td = 5*/);
};
#endif /* DATACLASSES_AEVENT_H_ */
......@@ -8,38 +8,41 @@ void analyse()
const Int_t noBranches = 4;
TString bName;
RawEvent *revent[noBranches];
RawEvent *revent[noBranches]; // pointer to the array (of RawEvent class) in which raw data for each channel will be put
for (Int_t j = 0; j<noBranches; j++) {
revent[j] = new RawEvent();
revent[j] = new RawEvent(); //each raw event element is of class RawEvent()
bName.Form("ch%d", j);
tr->SetBranchAddress(bName.Data(), &revent[j]);
tr->SetBranchAddress(bName.Data(), &revent[j]); //read the tree tr with raw data and fill array revent with raw data
}
// tr->SetMakeClass(1);
TFile *fw = new TFile("../data/dataDSR4/analysis_07_1.root", "RECREATE");
TTree *tw = new TTree("atree", "title of drs4 analysis tree");
TFile *fw = new TFile("../data/dataDSR4/analysis_07_1.root", "RECREATE"); //create .root file with somehow analyzed data
TTree *tw = new TTree("atree", "title of drs4 analysis tree"); //create analysis tree atree in it
AEvent *wevent[noBranches];
AEvent *wevent[noBranches]; // pointer to the array (of AEvent class) in which analyzed data for each channel will be put
for (Int_t j = 0; j<noBranches; j++) {
wevent[j] = new AEvent();
bName.Form("Ach%d.", j);
wevent[j]->SetInputEvent(&revent[j]);
tw->Bronch(bName.Data(), "AEvent", &wevent[j]);
wevent[j]->SetInputEvent(&revent[j]); //takes raw event from RawEvent
tw->Bronch(bName.Data(), "AEvent", &wevent[j]); // create branches in atree to hold analyzed data
}
//----event loop in tr input tree
Long64_t nentries = tr->GetEntries();
for(Long64_t i = 0; i < nentries; i++) {
tr->GetEntry(i);
for (Int_t j = 0; j<noBranches; j++) {
wevent[j]->Reset();
wevent[j]->ProcessEvent();
wevent[j]->ProcessEvent(); //here all the analysis is going on so far
}
tw->Fill();
}
//----end of event loop
tw->Write();
fw->Close();
......
......@@ -21,7 +21,7 @@ void testShowCFD()
}//for over events
TCanvas *c1 = new TCanvas("c1","test",10,10,1000,600);
TCanvas *c1 = new TCanvas("c1","CFD implementation",10,10,1000,600);
c1->Divide(3,2);
for (Int_t i = 0; i < 6; i++) {
......
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