Commit 51b8b7d2 authored by Kostyleva D.A's avatar Kostyleva D.A

New class for some event added.

parent 3c16621b
...@@ -10,18 +10,25 @@ void read_root() ...@@ -10,18 +10,25 @@ void read_root()
// time1.Set(ncellMax); // time1.Set(ncellMax);
const int ncellMax = 1030; const int ncellMax = 1030;
Double_t ampl1[ncellMax]; // int ncells;
Double_t time1[ncellMax]; Double_t ampl1[1023];
Double_t time1[1023];
Double_t ampl1_pos[1023]; //branch for positive signals
Double_t maxAmplitude1;
Double_t timemaxAmplitude1;
Double_t time1_pos[1023];
TFile *fw = new TFile("/home/dariak/NeuRad_tests/data/dataDSR4/analysis_07_1.root", "RECREATE"); TFile *fw = new TFile("/home/dariak/NeuRad_tests/data/dataDSR4/analysis_07_1.root", "RECREATE");
TTree *tw = new TTree("drs4analysis", "title of drs4 analysis tree"); TTree *tw = new TTree("drs4analysis", "title of drs4 analysis tree");
Double_t minAmplitude1;
tw->Branch("minAmplitude1", &minAmplitude1, "minAmplitude1/D");
/* Double_t ampl1[1024];
Double_t time1[1024];*/
tr->SetBranchAddress("amp_ch1", ampl1); tr->SetBranchAddress("amp_ch1", ampl1);
tr->SetBranchAddress("time_ch1", time1); tr->SetBranchAddress("time_ch1", time1);
// tr->SetBranchAddress("ncell", ncells);
tw->Branch("maxAmplitude1", &maxAmplitude1, "maxAmplitude1/D");
tw->Branch("timemaxAmplitude1", &timemaxAmplitude1, "timemaxAmplitude1/D");
tw->Branch("ampl1_pos", ampl1_pos, "ampl1_pos[1023]/D"); //branch for positive signals
tw->Branch("time1_pos", time1_pos, "time1_pos[1023]/D");
const Long64_t nEntries = tr->GetEntries(); const Long64_t nEntries = tr->GetEntries();
cout <<"Number of entries: "<<nEntries<<endl; cout <<"Number of entries: "<<nEntries<<endl;
...@@ -39,51 +46,63 @@ void read_root() ...@@ -39,51 +46,63 @@ void read_root()
gr1->Draw("Al*"); gr1->Draw("Al*");
} }
tr->GetEntry(428); tr->GetEntry(499);
TGraph *gr1 = new TGraph(1023, time1, ampl1); TGraph *gr1 = new TGraph(1023, time1, ampl1);
gr1->SetTitle("Signal shape for one event"); gr1->SetTitle("Signal shape for one event");
gr1->Draw("Al*");*/ gr1->Draw("Al*");*/
//----- //-----
Double_t minAmpl1 = 0.; Double_t maxAmpl1 = 0.;
Double_t timemaxAmpl1 = 0.;
for(Int_t i=0; i<tr->GetEntries(); i++) { for(Int_t i=0; i<tr->GetEntries(); i++) {
tr->GetEntry(i); tr->GetEntry(i);
minAmpl1 = ampl1[0];
//changing polarity of the signal
for(Int_t j=0; j<1023; j++) {
ampl1_pos[j] = ampl1[j]*(-1.);
time1_pos[j] = time1[j];
}
//find minimum by hand //find maximum by hand
maxAmpl1 = ampl1_pos[0];
for(Int_t j=0; j<1023; j++) { for(Int_t j=0; j<1023; j++) {
//cout<<ampl1[j]<<" "<<j<<endl; if(ampl1_pos[j] > maxAmpl1) {
if(ampl1[j] < minAmpl1) { maxAmpl1 = ampl1_pos[j];
minAmpl1 = ampl1[j]; timemaxAmpl1 = time1_pos[j];
} }
/*cout<<"Time "<<i<<" "<<j<<" "<<time1[j]<<endl; //cout<<"Time "<<i<<" "<<j<<" "<<time1[j]<<endl;
//cout<<"Amplitude "<<i<<" "<<j<<" "<<ampl1[j]<<endl; //cout<<"Amplitude "<<i<<" "<<j<<" "<<ampl1[j]<<endl;
cout<<endl;*/ //cout<<endl;
} }
maxAmplitude1 = maxAmpl1;
timemaxAmplitude1 = timemaxAmpl1;
cout<<"Max amplitude "<<maxAmpl1<<" for entry "<<i<<endl;
cout<<"Time for max amplitude "<<timemaxAmpl1<<" for entry "<<i<<endl;
//fitting 90 percent of rising edge //fitting 90 percent of rising edge
for(Int_t k=0; k<1023; k++) { for(Int_t k=0; k<1023; k++) {
if(ampl1[k] < 0.1*minAmpl1 && ampl1[k] > 0.9*minAmpl1) { //we have negative signals, amplitude between 10 and 90 proc from minimum if(ampl1[k] > 0.1*maxAmpl1 && ampl1[k] < 0.9*maxAmpl1) { //we have negative signals, amplitude between 10 and 90 proc from maximum
/*cout<<"rjgnfre"<<endl; /*cout<<"rjgnfre"<<endl;
TGraph *gr2 = new TGraph(1023, time1, ampl1); TGraph *gr2 = new TGraph(1023, time1, ampl1);
gr2->SetTitle("stupido"); gr2->SetTitle("stupido");
gr2->Fit("pol1"); gr2->Fit("pol1");
gr2->Draw("Al*");*/ gr2->Draw("Al*");*/
} }
} }
//getting integral
TGraph *gr3 = new TGraph(1023, time1, ampl1); //getting integral
//for(Int_t k=120; k<180; k++) { TGraph *gr3 = new TGraph(1023, time1, ampl1_pos);
gr3->Integral(120,180); gr3->Integral(120,180);
cout<<"INtegral "<<gr3->Integral(120,180)<<endl; cout<<"INtegral "<<gr3->Integral(120,180)<<endl;
//}
minAmplitude1 = minAmpl1;
cout<<"Min amplitude "<<minAmpl1<<" for entry "<<i<<endl;
tw->Fill(); tw->Fill();
} }
tw->GetEntry(498);
TGraph *gr2 = new TGraph(1023, time1_pos, ampl1_pos);
gr2->SetTitle("Signal shape for one gsgsg event");
gr2->Draw("Al*");
fw->cd(); fw->cd();
tw->Write(); tw->Write();
fw->Close(); fw->Close();
......
#define event_cxx
#include "event.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <iostream>
void event::Loop()
{
// In a ROOT session, you can do:
// Root > .L event.C
// Root > event t
// Root > t.GetEntry(12); // Fill t data members with entry number 12
// Root > t.Show(); // Show values of entry 12
// Root > t.Show(16); // Read and show values of entry 16
// Root > t.Loop(); // Loop on all entries
//
// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus("branchname",1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
// if (Cut(ientry) < 0) continue;
//----Daria added
TGraph *gr3 = new TGraph(1023, time1_pos, ampl1_pos);
gr3->Integral(120,180);
cout<<"INtegral "<<gr3->Integral(120,180)<<endl;
gr3->Draw();
}
}
#define event_cxx
#include "event.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
void event::Loop()
{
// In a ROOT session, you can do:
// Root > .L event.C
// Root > event t
// Root > t.GetEntry(12); // Fill t data members with entry number 12
// Root > t.Show(); // Show values of entry 12
// Root > t.Show(16); // Read and show values of entry 16
// Root > t.Loop(); // Loop on all entries
//
// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus("branchname",1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
// if (Cut(ientry) < 0) continue;
//----Daria added
TGraph *gr3 = new TGraph(1023, time1_pos, ampl1_pos);
gr3->Integral(120,180);
cout<<"INtegral "<<gr3->Integral(120,180)<<endl;
gr3->Draw();
}
}
//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Mon Dec 26 16:40:43 2016 by ROOT version 5.34/36
// from TTree drs4analysis/title of drs4 analysis tree
// found on file: ../data/dataDSR4/analysis_07_1.root
//////////////////////////////////////////////////////////
#ifndef event_h
#define event_h
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TGraph.h>
// Header file for the classes stored in the TTree if any.
// Fixed size dimensions of array or collections stored in the TTree if any.
class event {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain
// Declaration of leaf types
Double_t maxAmplitude1;
Double_t timemaxAmplitude1;
Double_t ampl1_pos[1023];
Double_t time1_pos[1023];
// List of branches
TBranch *b_maxAmplitude1; //!
TBranch *b_timemaxAmplitude1; //!
TBranch *b_ampl1_pos; //!
TBranch *b_time1_pos; //!
event(TTree *tree=0);
virtual ~event();
virtual Int_t Cut(Long64_t entry);
virtual Int_t GetEntry(Long64_t entry);
virtual Long64_t LoadTree(Long64_t entry);
virtual void Init(TTree *tree);
virtual void Loop();
virtual Bool_t Notify();
virtual void Show(Long64_t entry = -1);
};
#endif
#ifdef event_cxx
event::event(TTree *tree) : fChain(0)
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
if (tree == 0) {
TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("../data/dataDSR4/analysis_07_1.root");
if (!f || !f->IsOpen()) {
f = new TFile("../data/dataDSR4/analysis_07_1.root");
}
f->GetObject("drs4analysis",tree);
}
Init(tree);
}
event::~event()
{
if (!fChain) return;
delete fChain->GetCurrentFile();
}
Int_t event::GetEntry(Long64_t entry)
{
// Read contents of entry.
if (!fChain) return 0;
return fChain->GetEntry(entry);
}
Long64_t event::LoadTree(Long64_t entry)
{
// Set the environment to read one entry
if (!fChain) return -5;
Long64_t centry = fChain->LoadTree(entry);
if (centry < 0) return centry;
if (fChain->GetTreeNumber() != fCurrent) {
fCurrent = fChain->GetTreeNumber();
Notify();
}
return centry;
}
void event::Init(TTree *tree)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).
// Set branch addresses and branch pointers
if (!tree) return;
fChain = tree;
fCurrent = -1;
fChain->SetMakeClass(1);
fChain->SetBranchAddress("maxAmplitude1", &maxAmplitude1, &b_maxAmplitude1);
fChain->SetBranchAddress("timemaxAmplitude1", &timemaxAmplitude1, &b_timemaxAmplitude1);
fChain->SetBranchAddress("ampl1_pos", ampl1_pos, &b_ampl1_pos);
fChain->SetBranchAddress("time1_pos", time1_pos, &b_time1_pos);
Notify();
}
Bool_t event::Notify()
{
// The Notify() function is called when a new file is opened. This
// can be either for a new TTree in a TChain or when when a new TTree
// is started when using PROOF. It is normally not necessary to make changes
// to the generated code, but the routine can be extended by the
// user if needed. The return value is currently not used.
return kTRUE;
}
void event::Show(Long64_t entry)
{
// Print contents of entry.
// If entry is not specified, print current entry
if (!fChain) return;
fChain->Show(entry);
}
Int_t event::Cut(Long64_t entry)
{
// This function may be called from Loop.
// returns 1 if entry is accepted.
// returns -1 otherwise.
return 1;
}
#endif // #ifdef event_cxx
//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Mon Dec 26 16:40:43 2016 by ROOT version 5.34/36
// from TTree drs4analysis/title of drs4 analysis tree
// found on file: ../data/dataDSR4/analysis_07_1.root
//////////////////////////////////////////////////////////
#ifndef event_h
#define event_h
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
// Header file for the classes stored in the TTree if any.
// Fixed size dimensions of array or collections stored in the TTree if any.
class event {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain
// Declaration of leaf types
Double_t maxAmplitude1;
Double_t timemaxAmplitude1;
Double_t ampl1_pos[1023];
Double_t time1_pos[1023];
// List of branches
TBranch *b_maxAmplitude1; //!
TBranch *b_timemaxAmplitude1; //!
TBranch *b_ampl1_pos; //!
TBranch *b_time1_pos; //!
event(TTree *tree=0);
virtual ~event();
virtual Int_t Cut(Long64_t entry);
virtual Int_t GetEntry(Long64_t entry);
virtual Long64_t LoadTree(Long64_t entry);
virtual void Init(TTree *tree);
virtual void Loop();
virtual Bool_t Notify();
virtual void Show(Long64_t entry = -1);
};
#endif
#ifdef event_cxx
event::event(TTree *tree) : fChain(0)
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
if (tree == 0) {
TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("../data/dataDSR4/analysis_07_1.root");
if (!f || !f->IsOpen()) {
f = new TFile("../data/dataDSR4/analysis_07_1.root");
}
f->GetObject("drs4analysis",tree);
}
Init(tree);
}
event::~event()
{
if (!fChain) return;
delete fChain->GetCurrentFile();
}
Int_t event::GetEntry(Long64_t entry)
{
// Read contents of entry.
if (!fChain) return 0;
return fChain->GetEntry(entry);
}
Long64_t event::LoadTree(Long64_t entry)
{
// Set the environment to read one entry
if (!fChain) return -5;
Long64_t centry = fChain->LoadTree(entry);
if (centry < 0) return centry;
if (fChain->GetTreeNumber() != fCurrent) {
fCurrent = fChain->GetTreeNumber();
Notify();
}
return centry;
}
void event::Init(TTree *tree)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).
// Set branch addresses and branch pointers
if (!tree) return;
fChain = tree;
fCurrent = -1;
fChain->SetMakeClass(1);
fChain->SetBranchAddress("maxAmplitude1", &maxAmplitude1, &b_maxAmplitude1);
fChain->SetBranchAddress("timemaxAmplitude1", &timemaxAmplitude1, &b_timemaxAmplitude1);
fChain->SetBranchAddress("ampl1_pos", ampl1_pos, &b_ampl1_pos);
fChain->SetBranchAddress("time1_pos", time1_pos, &b_time1_pos);
Notify();
}
Bool_t event::Notify()
{
// The Notify() function is called when a new file is opened. This
// can be either for a new TTree in a TChain or when when a new TTree
// is started when using PROOF. It is normally not necessary to make changes
// to the generated code, but the routine can be extended by the
// user if needed. The return value is currently not used.
return kTRUE;
}
void event::Show(Long64_t entry)
{
// Print contents of entry.
// If entry is not specified, print current entry
if (!fChain) return;
fChain->Show(entry);
}
Int_t event::Cut(Long64_t entry)
{
// This function may be called from Loop.
// returns 1 if entry is accepted.
// returns -1 otherwise.
return 1;
}
#endif // #ifdef event_cxx
# DO NOT DELETE
./event_C.so: event.h /usr/include/root/TROOT.h
./event_C.so: /usr/include/root/TDirectory.h /usr/include/root/TNamed.h
./event_C.so: /usr/include/root/TObject.h /usr/include/root/Rtypes.h
./event_C.so: /usr/include/root/RConfig.h /usr/include/root/RVersion.h
./event_C.so: /usr/include/root/DllImport.h /usr/include/root/Rtypeinfo.h
./event_C.so: /usr/include/root/snprintf.h /usr/include/root/strlcpy.h
./event_C.so: /usr/include/root/TGenericClassInfo.h
./event_C.so: /usr/include/root/TSchemaHelper.h /usr/include/root/TStorage.h
./event_C.so: /usr/include/root/TVersionCheck.h /usr/include/root/Riosfwd.h
./event_C.so: /usr/include/root/TBuffer.h /usr/include/root/TString.h
./event_C.so: /usr/include/root/TMathBase.h /usr/include/root/TList.h
./event_C.so: /usr/include/root/TSeqCollection.h
./event_C.so: /usr/include/root/TCollection.h /usr/include/root/TIterator.h
./event_C.so: /usr/include/root/TDatime.h /usr/include/root/TUUID.h
./event_C.so: /usr/include/root/TChain.h /usr/include/root/TTree.h
./event_C.so: /usr/include/root/TBranch.h /usr/include/root/TObjArray.h
./event_C.so: /usr/include/root/TAttFill.h /usr/include/root/TDataType.h
./event_C.so: /usr/include/root/TDictionary.h /usr/include/root/Property.h
./event_C.so: /usr/include/root/ESTLType.h /usr/include/root/TAttLine.h
./event_C.so: /usr/include/root/TAttMarker.h /usr/include/root/TArrayD.h
./event_C.so: /usr/include/root/TArray.h /usr/include/root/TArrayI.h
./event_C.so: /usr/include/root/TClass.h /usr/include/root/TObjString.h
./event_C.so: /usr/include/root/ThreadLocalStorage.h
./event_C.so: /usr/include/root/RConfigure.h
./event_C.so: /usr/include/root/TVirtualTreePlayer.h
./event_C.so: /usr/include/root/TFile.h /usr/include/root/TDirectoryFile.h
./event_C.so: /usr/include/root/TMap.h /usr/include/root/THashTable.h
./event_C.so: /usr/include/root/TUrl.h /usr/include/root/TGraph.h
./event_C.so: /usr/include/root/TVectorFfwd.h /usr/include/root/TVectorDfwd.h
./event_C.so: /usr/include/root/TFitResultPtr.h /usr/include/root/TH2.h
./event_C.so: /usr/include/root/TH1.h /usr/include/root/TAxis.h
./event_C.so: /usr/include/root/TAttAxis.h /usr/include/root/TArrayC.h
./event_C.so: /usr/include/root/TArrayS.h /usr/include/root/TArrayF.h
./event_C.so: /usr/include/root/Foption.h /usr/include/root/TMatrixFBasefwd.h
./event_C.so: /usr/include/root/TMatrixDBasefwd.h /usr/include/root/TStyle.h
./event_C.so: /usr/include/root/TAttText.h /usr/include/root/TCanvas.h
./event_C.so: /usr/include/root/TPad.h /usr/include/root/TVirtualPad.h
./event_C.so: /usr/include/root/TAttPad.h /usr/include/root/TVirtualX.h
./event_C.so: /usr/include/root/GuiTypes.h /usr/include/root/Buttons.h
./event_C.so: /usr/include/root/TQObject.h /usr/include/root/TAttBBox2D.h
./event_C.so: /usr/include/root/TPoint.h /usr/include/root/TAttCanvas.h
./event_C.so: /usr/include/root/TCanvasImp.h
./event_C.so: /usr/include/root/cintdictversion.h /usr/include/root/RVersion.h
event_C__ROOTBUILDVERSION= 5.34/36
{
TFile fr("../data/dataDSR4/analysis_07_1.root");
TTree *tr = (TTree*)fr.Get("drs4analysis");
tr->MakeClass("event");
}
{
TFile fr("../data/dataDSR4/analysis_07_1.root");
TTree *tr = (TTree*)fr.Get("drs4analysis");
tr->MakeClass("event");
// gSystem->Load("/home/dariak/NeuRad_tests/macros/event_C.so");
// event ev;
// ev.
}
#include <TSystem.h>
#include <iostream>
using namespace std;
void try_event_class()
{
gSystem->Load("/home/dariak/NeuRad_tests/macros/event_C.so");
event ev;
ev.GetEntry(499);
ev.Show();
ev.Loop();
}
#include <TSystem.h>
#include <iostream>
using namespace std;
void try_event_class()
{
gSystem->Load("/home/dariak/NeuRad_tests/macros/event_C.so");
event ev;
ev.GetEntry(501);
ev.Show();
ev.Loop();
}
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