Commit 5180a1eb authored by Muzalevsky I.A's avatar Muzalevsky I.A

Merge branch 'master' of http://er.jinr.ru:90/vratislav.chudoba/NeuRad_tests

Conflicts:
	convertTektronix/exp2.root
	convertTektronix/read1.cpp
	dataClasses/AEvent.cpp
parents e2025d14 ea515242
...@@ -334,7 +334,9 @@ int main(int argc, const char * argv[]) ...@@ -334,7 +334,9 @@ int main(int argc, const char * argv[])
rfile->Close(); rfile->Close();
// delete event; // delete event;
printf("error1\n");
delete[] event; delete[] event;
printf("error2\n");
return 1; return 1;
} }
......
void analyse()
{
gSystem->Load("../libData.so");
TFile *f = new TFile("../data/rawDataDSR4/NeuRad_test_07_1.root");
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
for (Int_t j = 0; j<noBranches; j++) {
revent[j] = new RawEvent(); //each raw event element is of class RawEvent()
bName.Form("ch%d.", 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"); //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]; // 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]); //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
}
//----event loop in tr input tree
Long64_t nentries = tr->GetEntries();
for(Long64_t i = 0; i < nentries; i++) {
tr->GetEntry(i);
if ( !(tr->GetEntry(i)%100) ) {
printf("Found event #%d\n", tr->GetEntry(i));
}
for (Int_t j = 0; j<noBranches; j++) {
wevent[j]->Reset();
wevent[j]->ProcessEvent(); //here all the analysis is going on so far
}
tw->Fill();
}
//----end of event loop
tw->Write();
fw->Close();
return;
}
void read1(Int_t input=0) { #include <fstream>
cout<<input<<endl;
//void read1() { #include "TString.h"
gSystem->Load("../libData.so"); #include "TFile.h"
#include "TError.h"
#include "TTree.h"
#include "../dataClasses/RawEvent.h"
int main(int argc, char* argv[])
{
if (argc != 3) {
// Tell the user how to run the program
std::cerr << "Usage: " << argv[0] << " [list with input files] [outputfile]" << std::endl;
/* "Usage messages" are a conventional way of telling the user
* how to run a program if they enter the command incorrectly.
*/
return 1;
}
// Print the user's name:
TString infiles = argv[1];
TString ofile = argv[2];
// std::cout << argv[1] << "says hello, " << argv[2] << "!" << std::endl;
// std::cout << infiles << "says hello, " << ofile << "!" << std::endl;
// return 0;
Double_t A1[1000],A2[1000],A3[1000],A4[1000]; Double_t A1[1000],A2[1000],A3[1000],A4[1000];
Double_t T[1000]; Double_t T[1000];
Int_t i,j,k,n,p,Nchannel,Nlines; Int_t i,j,k,n,p,Nchannel,Nlines;
TString line1,line2,line3,line4,fileName; TString line1,line2,line3,line4,fileName;
Double_t amp1,amp2,amp3,amp4,time; Double_t amp1,amp2,amp3,amp4,time;
TFile *f1 = new TFile("exp2.root","RECREATE"); TFile *f1 = new TFile(ofile.Data(),"RECREATE");
TTree *tree = new TTree("rtree","signal"); TTree *tree = new TTree("rtree","signal");
tree->Branch("A1",A1,"A1[1000]/D"); tree->Branch("A1",A1,"A1[1000]/D");
tree->Branch("A2",A2,"A2[1000]/D"); tree->Branch("A2",A2,"A2[1000]/D");
...@@ -39,7 +63,7 @@ cout<<input<<endl; ...@@ -39,7 +63,7 @@ cout<<input<<endl;
ifstream myfile3; ifstream myfile3;
ifstream myfile4; ifstream myfile4;
myfile.open("../data/rawDataTektronix/infiles.dat"); // открываю файл с названиями файлов с данными для подсчёта общего количества файлов myfile.open(infiles.Data()); // открываю файл с названиями файлов с данными для подсчёта общего количества файлов
if (myfile.is_open()) { /// для создания динамического массива с путями к файлам с данными if (myfile.is_open()) { /// для создания динамического массива с путями к файлам с данными
while(1){ while(1){
fileName.ReadLine(myfile); fileName.ReadLine(myfile);
...@@ -48,12 +72,15 @@ cout<<input<<endl; ...@@ -48,12 +72,15 @@ cout<<input<<endl;
} }
myfile.close(); myfile.close();
} }
else {Error("read.cpp", "Some error when opening file","infiles.dat");return;} else {
Error("read.cpp", "Some error when opening file %s", infiles.Data());
return 1;
}
TString *NameLines = new TString[Nlines]; // создание массива в котором хранятся строки из файла "infiles.dat" TString *NameLines = new TString[Nlines]; // создание массива в котором хранятся строки из файла "infiles.dat"
// TString NameLines[Nlines]; // TString NameLines[Nlines];
myfile.open("../data/rawDataTektronix/infiles.dat"); myfile.open(infiles.Data());
for(i=0;;i++){ for(i=0;;i++){
fileName.ReadLine(myfile); fileName.ReadLine(myfile);
NameLines[i] = fileName; NameLines[i] = fileName;
...@@ -129,9 +156,11 @@ cout<<input<<endl; ...@@ -129,9 +156,11 @@ cout<<input<<endl;
} }
else { else {
Error("read.cpp", "Some error when opening data file number of %d", i); Error("read.cpp", "Some error when opening data file number of %d", i);
return; return 1;
} }
}//for i }//for i
tree->Write(); tree->Write();
f1->Close(); f1->Close();
return 0;
} }
...@@ -55,6 +55,14 @@ void AEvent::ProcessEvent() { ...@@ -55,6 +55,14 @@ void AEvent::ProcessEvent() {
fTime[j] = time[j]; fTime[j] = time[j];
} }
// SetGraphs();
const Double_t zeroLevel = FindZeroLevel();
// const Double_t zeroLevel = 0;
for(Int_t j = 0; j < fNPoints; j++) {
//fAmpPos[j] = amp[j]*(-1.) - zeroLevel;
fAmpPos[j] = fAmpPos[j] - zeroLevel;
}
Double_t maxAmp = 0.; Double_t maxAmp = 0.;
Double_t maxAmpT = 0.; Double_t maxAmpT = 0.;
...@@ -125,9 +133,8 @@ void AEvent::SetGraphs() { ...@@ -125,9 +133,8 @@ void AEvent::SetGraphs() {
} }
void AEvent::SetCFD() { void AEvent::SetCFD() {
// Double_t c = 0.5; //attenuation coefficient
// Int_t td = 5; //time of delay in points Double_t level = 100.; //is necessary to find cfd amplitude value closest to zero
Double_t level = 100.; //todo what is it?
fGraphCFD->Set(fNPoints); fGraphCFD->Set(fNPoints);
...@@ -139,9 +146,7 @@ void AEvent::SetCFD() { ...@@ -139,9 +146,7 @@ void AEvent::SetCFD() {
//CFD method //CFD method
if(i>fCFtimeDelay) { if(i>fCFtimeDelay) {
// fAmpCFD[i] = fAmpPos[i]*cfRatio*(-1);
fAmpCFD[i] = fAmpPos[i]*fCFratio*(-1); fAmpCFD[i] = fAmpPos[i]*fCFratio*(-1);
// fAmpCFD[i] = fAmpCFD[i] + fAmpPos[i - timeDelay];
fAmpCFD[i] = fAmpCFD[i] + fAmpPos[i - fCFtimeDelay]; fAmpCFD[i] = fAmpCFD[i] + fAmpPos[i - fCFtimeDelay];
fGraphCFD->SetPoint(i, fTime[i], fAmpCFD[i]); fGraphCFD->SetPoint(i, fTime[i], fAmpCFD[i]);
} }
...@@ -167,9 +172,31 @@ void AEvent::SetCFD() { ...@@ -167,9 +172,31 @@ void AEvent::SetCFD() {
fCFD = fTime[j]; fCFD = fTime[j];
} }
} }
} }
Double_t AEvent::FindZeroLevel(Int_t pmin, Int_t pmax) {
// fGraphZero->Set(fNPoints);
// const Double_t *amp = fInputEvent->GetAmp();
// const Double_t *time = fInputEvent->GetTime();
SetGraphs();
Double_t correction = 0;
TF1 *fit1 = new TF1("fit1","[0]");
fit1->SetRange(pmin,pmax);
// Warning("AEvent::FindZeroLevel", "Graph was not set");
if (!fGraphSignal) {
Warning("AEvent::FindZeroLevel", "Graph was not set");
return 0;
}
// fGraphSignal->Print();
fGraphSignal->Fit(fit1,"RQN","goff");
// fGraphSignal->Fit(fit1,"QR","goff");
correction = fit1->GetParameter(0);
// printf("zero level %f\n", correction);
delete fit1;
return correction;
Double_t AEvent::GetfCFD() { Double_t AEvent::GetfCFD() {
return fCFD; return fCFD;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "TString.h" #include "TString.h"
#include "TTree.h" #include "TTree.h"
#include "TFile.h" #include "TFile.h"
#include "TF1.h"
//#include "TMath.h" //#include "TMath.h"
...@@ -43,10 +44,11 @@ private: ...@@ -43,10 +44,11 @@ private:
TGraph *fGraphSignal; TGraph *fGraphSignal;
TGraph *fGraphCFD; TGraph *fGraphCFD;
TGraph *fGraphZero;
RawEvent *fInputEvent; //! RawEvent *fInputEvent; //!
Double_t fCFratio; //! Double_t fCFratio; //!
Double_t fCFtimeDelay; //! Double_t fCFtimeDelay; //!
public: public:
...@@ -59,20 +61,33 @@ public: ...@@ -59,20 +61,33 @@ public:
Double_t GetOnefAmpPos(Int_t i); Double_t GetOnefAmpPos(Int_t i);
void SetRawDataFile(const char* inprawfile, const char* treename); void SetRawDataFile(const char* inprawfile, const char* treename);
void ProcessEvent(); void ProcessEvent();
// void Integral()
void SetInputEvent(RawEvent** event); void SetInputEvent(RawEvent** event);
void SetCFratio(Double_t ratio) { fCFratio = ratio; }; void SetCFratio(Double_t ratio) { fCFratio = ratio; };
void SetCFtimeDelay(Double_t timeDelay) { fCFtimeDelay = timeDelay; }; //CFD set attenuation coefficient
void SetCFtimeDelay(Double_t timeDelay) { fCFtimeDelay = timeDelay; };
//CFD set time delay (in points)
void Reset(); void Reset();
//Resets arrays to zeros //Resets arrays to zeros
TGraph* GetGraph() { TGraph* GetGraphCFD() {
//todo
return fGraphCFD; return fGraphCFD;
// return gSignal;
} }
//draws CFD graphs
TGraph* GetGraphSignal() {
return fGraphSignal;
}
//draws signal shape graphs
Double_t FindZeroLevel(Int_t pmin = 10, Int_t pmax = 100);
//for zero level correction
//one parameter fit between pmin and pmax
//returns fit parameter i.e. number on which amplitude should be corrected
private: private:
void Init(); void Init();
......
...@@ -13,7 +13,7 @@ void analyse() ...@@ -13,7 +13,7 @@ void analyse()
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
for (Int_t j = 0; j<noBranches; j++) { for (Int_t j = 0; j<noBranches; j++) {
revent[j] = new RawEvent(); //each raw event element is of class RawEvent() revent[j] = new RawEvent(); //each raw event element is of class RawEvent()
bName.Form("ch%d", j); bName.Form("ch%d.", j);
tr->SetBranchAddress(bName.Data(), &revent[j]); //read the tree tr with raw data and fill array revent with raw data tr->SetBranchAddress(bName.Data(), &revent[j]); //read the tree tr with raw data and fill array revent with raw data
} }
...@@ -37,6 +37,9 @@ void analyse() ...@@ -37,6 +37,9 @@ void analyse()
for(Long64_t i = 0; i < nentries; i++) { for(Long64_t i = 0; i < nentries; i++) {
tr->GetEntry(i); tr->GetEntry(i);
if ( !(tr->GetEntry(i)%100) ) {
printf("Found event #%d\n", tr->GetEntry(i));
}
for (Int_t j = 0; j<noBranches; j++) { for (Int_t j = 0; j<noBranches; j++) {
wevent[j]->Reset(); wevent[j]->Reset();
......
...@@ -17,7 +17,7 @@ void testShowCFD() ...@@ -17,7 +17,7 @@ void testShowCFD()
for (Int_t i = 0; i < 10; i++) { for (Int_t i = 0; i < 10; i++) {
gr[i] = 0; gr[i] = 0;
tr->GetEntry(i+kFirstEvent); tr->GetEntry(i+kFirstEvent);
gr[i] = new TGraph(*revent->GetGraph()); gr[i] = new TGraph(*revent->GetGraphCFD());
}//for over events }//for over events
......
...@@ -9,24 +9,33 @@ void testShowGraphs() ...@@ -9,24 +9,33 @@ void testShowGraphs()
TTree *tr = (TTree*)fr.Get("atree"); TTree *tr = (TTree*)fr.Get("atree");
AEvent *revent = new AEvent(); AEvent *revent = new AEvent();
tr->SetBranchAddress("Ach0.",&revent); cout << tr->SetBranchAddress("Ach0.",&revent) << endl;
TGraph *gr[10]; TGraph *gr[10];
cout << "warning" << endl;
cout << tr->GetEntries() << endl;
//loop over events //loop over events
for (Int_t i = 0; i < 10; i++) { for (Long64_t i = 0; i < 10; i++) {
gr[i] = 0; gr[i] = 0;
tr->GetEntry(i+kFirstEvent); cout << "warning 1" << endl;
gr[i] = new TGraph(*revent->GetGraph()); cout << i+kFirstEvent << endl;
// tr->GetEntry(i+kFirstEvent);
tr->GetEntry(i);
cout << "warning 2" << endl;
gr[i] = new TGraph(*revent->GetGraphSignal());
}//for over events }//for over events
cout << "warning 3" << endl;
TCanvas *c1 = new TCanvas("c1","test",10,10,1000,600); TCanvas *c1 = new TCanvas("c1","test",10,10,1000,600);
c1->Divide(3,2); c1->Divide(3,2);
for (Int_t i = 0; i < 6; i++) { for (Int_t k = 0; k < 6; k++) {
c1->cd(i+1); c1->cd(k+1);
gr[i]->Draw(); gr[k]->Draw();
} }
// c1->cd(2); // c1->cd(2);
......
...@@ -24,11 +24,15 @@ PWD = $(shell pwd) ...@@ -24,11 +24,15 @@ PWD = $(shell pwd)
DATA = $(PWD)/dataClasses DATA = $(PWD)/dataClasses
CONVERTDRS4 = $(PWD)/convertDRS4 CONVERTDRS4 = $(PWD)/convertDRS4
CONVERTTEKTRONIX = $(PWD)/convertTektronix
CONVERTRAWTOANALYZED = $(PWD)/convertRawToAnalyzed
-include $(DATA)/Data.mk -include $(DATA)/Data.mk
all: libData.so \ all: libData.so \
read_binary_DRS4 read_binary_DRS4 \
convertTektronix \
convertRawToAnalyzed
#ROOT html documentation, it will be done as a program which will be alsa compiled by this makefile, program will be as a last condition after all of the libraries #ROOT html documentation, it will be done as a program which will be alsa compiled by this makefile, program will be as a last condition after all of the libraries
...@@ -67,6 +71,14 @@ read_binary_DRS4: $(CONVERTDRS4)/read_binary.cpp libData.so ...@@ -67,6 +71,14 @@ read_binary_DRS4: $(CONVERTDRS4)/read_binary.cpp libData.so
@echo 'Finished building target: $@' @echo 'Finished building target: $@'
@echo ' ' @echo ' '
convertRawToAnalyzed: $(CONVERTRAWTOANALYZED)/analyse.cpp libData.so
@echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker'
# $(CC) -L $(ROOTLIBS) -shared -o"libData.so" $(DATAOBJS) $(DATALIBS)
$(CC) -o $(CONVERTRAWTOANALYZED)/convertRawToAnalyzed $(CONVERTRAWTOANALYZED)/analyse.cpp -lm `root-config --cflags --libs` -L $(PWD) -lData -Wl,-rpath,$(PWD)
@echo 'Finished building target: $@'
@echo ' '
.PHONY: all clean .PHONY: all clean
# Each subdirectory must supply rules for building sources it contributes # Each subdirectory must supply rules for building sources it contributes
......
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