Skip to content

Commit c5a92bc

Browse files
committed
Including Rise Time and Integral
1 parent f4c9c7c commit c5a92bc

File tree

2 files changed

+104
-39
lines changed

2 files changed

+104
-39
lines changed

outTree.C

Lines changed: 97 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <iostream>
77
#include "TH1F.h"
88
#include <math.h>
9+
#include "TF1.h"
910

1011
void outTree::Loop()
1112
{
@@ -32,49 +33,109 @@ void outTree::Loop()
3233
// METHOD2: replace line
3334
// fChain->GetEntry(jentry); //read all branches
3435
//by b_branchname->GetEntry(ientry); //read only this branch
35-
TH1F* h = new TH1F("h", "muon spectrum", 1000, .0, 18.5);
36-
TH1F* h1 = new TH1F("h1", "Pulse Output1", 2499, -2.68000004411e-08, 2.31600001399e-08);
37-
TH1F* h2 = new TH1F("h2", "Pulse Output2", 2499, -2.68000004411e-08, 2.31600001399e-08);
38-
TH1F* h3 = new TH1F("h3", "Pulse Output3", 2499, -2.68000004411e-08, 2.31600001399e-08);
36+
/*
37+
TH1F* h = new TH1F("h", "muon spectrum", 500, .0, 18.5);
38+
TH1F* h1 = new TH1F("h1", "Pulse Output1", 2499, -2.68000004410851e-08, 2.316000013991015e-08);
39+
TH1F* h2 = new TH1F("h2", "Pulse Output2", 2499, -2.68000004410851e-08, 2.316000013991015e-08);
40+
TH1F* h3 = new TH1F("h3", "Pulse Output3", 2499, -2.68000004410851e-08, 2.316000013991015e-08);
41+
42+
TH1F* h4 = new TH1F("h4", "Time peak spectrum", 2499, -2.68000004410851e-08, 2.316000013991015e-08);
43+
TH1F* h5 = new TH1F("h5", "Rise Time spectrum", 2499, -2.68000004410851e-08, 2.316000013991015e-08);
44+
TH1F* h6 = new TH1F("h6", "Intregral", 500, .0, 1e-9);
45+
*/
46+
47+
TH1F* h = new TH1F("h", "muon spectrum", 100, .0, 18.5);
48+
TH1F* h1 = new TH1F("h1", "Pulse Output1", 2499, -3.399999926045894e-08, 4.656000101022073e-07);
49+
TH1F* h2 = new TH1F("h2", "Pulse Output2", 2499, -3.399999926045894e-08, 4.656000101022073e-07);
50+
TH1F* h3 = new TH1F("h3", "Pulse Output3", 2499, -3.399999926045894e-08, 4.656000101022073e-07);
51+
TH1F* h4 = new TH1F("h4", "Time peak spectrum", 2499, -3.399999926045894e-08, 4.656000101022073e-07);
52+
TH1F* h5 = new TH1F("h5", "Rise Time spectrum", 2499, -3.399999926045894e-08, 4.656000101022073e-07);
53+
TH1F* h6 = new TH1F("h6", "Intregral", 500, .0, 1e-7);
54+
3955
float min2 = 1.0;
4056
std::cout.precision(16);
4157

4258

4359
if (fChain == 0) return;
4460

45-
Long64_t nentries = fChain->GetEntriesFast();
46-
Long64_t nbytes = 0, nb = 0;
47-
for (Long64_t jentry = 1; jentry < nentries; jentry++) {
48-
Long64_t ientry = LoadTree(jentry);
49-
if (ientry < 0) break;
50-
nb = fChain->GetEntry(jentry); nbytes += nb;
51-
// if (Cut(ientry) < 0) continue;
52-
if(jentry < 2000){
53-
//std::cout << "entry: " << jentry << std::endl;
54-
//std::cout << "vector size: " << Time->size() << " Time: " << Time->at(0) << " " << Time->at(1) << " " << Time->at(2) << " " << Time->at(Time->size()-1) << std::endl;
55-
}
56-
57-
int ctr = 0;
58-
for (std::vector<float>::iterator it = Time->begin() ; it != Time->end(); ++it){
59-
//if(ctr == 0 || ctr == Time->size() -1)std::cout << ' ' << *it << std::endl;
60-
ctr++;
61-
}
62-
int ctr1 = 0;
63-
min2 = 1.0;
64-
for (std::vector<float>::iterator it1 = Amp->begin() ; it1 != Amp->end(); ++it1){
65-
//if(ctr1 == 0 || ctr1 == Amp->size() -1)std::cout << ' ' << *it1 << std::endl;
66-
ctr1++;
67-
if(*it1 < min2){
68-
min2 = *it1;
69-
}
61+
Long64_t nentries = fChain->GetEntriesFast();
62+
Long64_t nbytes = 0, nb = 0;
63+
for (Long64_t jentry = 1; jentry < nentries; jentry++) {
64+
Long64_t ientry = LoadTree(jentry);
65+
if (ientry < 0) break;
66+
nb = fChain->GetEntry(jentry); nbytes += nb;
67+
// if (Cut(ientry) < 0) continue;
68+
if(jentry < 2000){
69+
//std::cout << "entry: " << jentry << std::endl;
70+
//std::cout << "vector size: " << Time->size() << " Time: " << Time->at(0) << " " << Time->at(1) << " " << Time->at(2) << " " << Time->at(Time->size()-1) << std::endl;
71+
}
72+
73+
int ctr = 0;
74+
double time[5000];
75+
for(std::vector<float>::iterator it = Time->begin(); it != Time->end(); ++it){
76+
//if(ctr == 0 || ctr == Time->size() -1)std::cout << ' ' << *it << std::endl;
77+
time[ctr] = *it;
78+
ctr++;
79+
}
80+
81+
int ctr1 = 0;
82+
min2 = 1.0;
83+
double time_min = 20;
84+
double deltaT = time[1]-time[0];
85+
double integral = .0;
86+
for(std::vector<float>::iterator it1 = Amp->begin(); it1 != Amp->end(); ++it1){
87+
//if(ctr1 == 0 || ctr1 == Amp->size() -1)std::cout << ' ' << *it1 << std::endl;
88+
//if(jentry == 6)h1->Fill(time[ctr1],fabs(*it1));
89+
//if(jentry == 635)h2->Fill(time[ctr1],fabs(*it1));
90+
//if(jentry == 276)h3->Fill(time[ctr1],fabs(*it1));
91+
if(jentry == 6)h1->Fill(time[ctr1],*it1);
92+
if(jentry == 635)h2->Fill(time[ctr1],*it1);
93+
if(jentry == 276)h3->Fill(time[ctr1],*it1);
94+
if(*it1 < min2){
95+
min2 = *it1;
96+
time_min = time[ctr1];
7097
}
98+
ctr1++;
99+
}
71100

72-
h->Fill(fabs(min2));
73-
if(min2 < 1.0)std::cout << "min2: " << min2 << std::endl;
74-
101+
//std::cout << time[500]-time[499] << " " << time[745] - time[744] << std::endl;
102+
double RiseTime = -99.;
103+
int ctr2 = 0;
104+
for(std::vector<float>::iterator it1 = Amp->begin(); it1 != Amp->end(); ++it1){
105+
if(*it1 <0.20*min2)integral += (*it1)*deltaT;
106+
if(*it1 < 0.90*min2){
107+
RiseTime = time[ctr2];
108+
break;
109+
}
110+
ctr2++;
111+
}
112+
113+
//std::cout << "Int: " << fabs(integral) << std::endl;
114+
//std::cout << "ctr1: " << ctr1 << std::endl;
115+
116+
h->Fill(fabs(min2));
117+
h4->Fill(time_min);
118+
h5->Fill(RiseTime);
119+
h6->Fill(fabs(integral));
120+
//if(min2 < 1.0)std::cout << "min2: " << min2 << std::endl;
121+
75122
}
76-
77-
TFile* fout = new TFile("file_out.root", "recreate");
78-
h->Write();
79-
fout->Close();
123+
/*
124+
TF1 *f1 = new TF1("f1", "[0]*exp(-1*(x-1e-07)/[1])", 0.09e-06, 0.3e-06);
125+
f1->SetParameters(11., 1e-07);
126+
h1->Fit(f1,"VMWLR");
127+
f1->SetParameters(11., 1e-07);
128+
h2->Fit(f1,"VMWLR");
129+
f1->SetParameters(11., 1e-07);
130+
h3->Fit(f1,"VMWLR");
131+
*/
132+
TFile* fout = new TFile("file_out_Crystal.root", "recreate");
133+
h->Write();
134+
h1->Write();
135+
h2->Write();
136+
h3->Write();
137+
h4->Write();
138+
h5->Write();
139+
h6->Write();
140+
fout->Close();
80141
}

outTree.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ outTree::outTree(TTree *tree) : fChain(0)
5151
// if parameter tree is not specified (or zero), connect the file
5252
// used to generate this class and read the Tree.
5353
if (tree == 0) {
54-
TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/media/data/cmorgoth/scope_data/data_Scope_Total.root");
55-
if (!f || !f->IsOpen()) {
56-
f = new TFile("/media/data/cmorgoth/scope_data/data_Scope_Total.root");
54+
//TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/media/data/cmorgoth/scope_data/data_Scope_Total.root");
55+
//TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/home/cmorgoth/No_crystal_Data/NoCrystalData.root");
56+
TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/home/cmorgoth/CrystalData/CrystalData.root");
57+
if (!f || !f->IsOpen()) {
58+
//f = new TFile("/media/data/cmorgoth/scope_data/data_Scope_Total.root");
59+
//f = new TFile("/home/cmorgoth/No_crystal_Data/NoCrystalData.root");
60+
f = new TFile("/home/cmorgoth/CrystalData/CrystalData.root");
5761
}
5862
f->GetObject("outTree",tree);
5963

0 commit comments

Comments
 (0)