diff --git a/convertDRS4/read_binary.cpp b/convertDRS4/read_binary.cpp index aea2845c9beb20c767fcf384d4d63dc0c56d1092..8de23e13edbf4bee9639ab9f10f677e62aa28cb5 100644 --- a/convertDRS4/read_binary.cpp +++ b/convertDRS4/read_binary.cpp @@ -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; } diff --git a/data/dataDSR4/analysis_07_1.root b/data/dataDSR4/analysis_07_1.root index 32db4adfba5dbbc4841a3f5658c7802305405e6e..3afe6e14ee3731c3ffbe3c1b59b852b6c6b9dfe7 100644 Binary files a/data/dataDSR4/analysis_07_1.root and b/data/dataDSR4/analysis_07_1.root differ diff --git a/dataClasses/AEvent.cpp b/dataClasses/AEvent.cpp index 983d4069b33f1d7775aa0e38df34212060c8aa0f..64088bd7c9f2e938ad288729bd92d10c053f146c 100644 --- a/dataClasses/AEvent.cpp +++ b/dataClasses/AEvent.cpp @@ -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 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; itd) { + 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; + + } diff --git a/dataClasses/AEvent.h b/dataClasses/AEvent.h index e86ea622e4d59761790efdc4acf21ad6cc1e526e..c85cbd957aa6ba80c5ea9ce2c3bae4d04a7fbf2a 100644 --- a/dataClasses/AEvent.h +++ b/dataClasses/AEvent.h @@ -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_ */ diff --git a/macros/analyse.C b/macros/analyse.C index 7ed9e3738306f96460b75bc8a3b439080fedd463..9b8ffd542cf5f5d2214ae1c2f5f86ef89f40d350 100644 --- a/macros/analyse.C +++ b/macros/analyse.C @@ -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; jSetBranchAddress(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; jSetInputEvent(&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; jReset(); - 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(); diff --git a/macros/testShowCFD.cxx b/macros/testShowCFD.cxx index f48591a9fef4b32a6f8779044a6daae2a034168e..c289167cae58c92f6f6c5222ae78b382b576861f 100644 --- a/macros/testShowCFD.cxx +++ b/macros/testShowCFD.cxx @@ -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++) {