forked from cmorgoth/MuonTestScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspectrum.cc
More file actions
84 lines (68 loc) · 2.48 KB
/
spectrum.cc
File metadata and controls
84 lines (68 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <vector>
#include "TMath.h"
#include "TFile.h"
#include "TH1F.h"
#include "TTree.h"
#include "TROOT.h"
#include "TBranch.h"
#include "TSystem.h"
//#ifdef __MAKECINT__
//#pragma link C++ class vector<float>+;
//#endif
int main(){
gROOT->Reset();
std::cout << "here it breaks -1" << std::endl;
gROOT->ProcessLine("#include <vector>");
std::cout << "here it breaks -2" << std::endl;
TFile* f = new TFile("/media/data/cmorgoth/scope_data/NoCrystalData/NoCrystalData.root");
TTree* tree = (TTree*)f->Get("outTree");
std::cout.precision(12);
double ptime;
std::vector<float> *Amp;
std::vector<float> *Time;
TBranch *BTime = 0;
TBranch *BAmp = 0;
//tree->SetBranchAddress("ptime", &ptime);
//tree->SetBranchAddress("Amp", &Amp, &BAmp);
//tree->SetBranchAddress("Time", &Time, &BTime);
tree->SetBranchAddress("ptime", &ptime);
tree->SetBranchAddress("Amp", &Amp);
tree->SetBranchAddress("Time", &Time);
TH1F* h = new TH1F("h", "muon spectrum", 1000, .0, .5);
TH1F* h1 = new TH1F("h1", "Pulse Output1", 2499, -2.68000004411e-08, 2.31600001399e-08);
TH1F* h2 = new TH1F("h2", "Pulse Output2", 2499, -2.68000004411e-08, 2.31600001399e-08);
TH1F* h3 = new TH1F("h3", "Pulse Output3", 2499, -2.68000004411e-08, 2.31600001399e-08);
float min2 = 1.0;
for(int i = 0; i < 10/*tree->GetEntries()*/; i++){
tree->GetEntry(i);
//BTime->GetEntry(i);
//BAmp->GetEntry(i);
std::cout << "here it breaks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
float min = 1.0;
min2 = 1.0;
//int size = Time->size();
//std::cout << "vector size: " << Amp->size() << " Time: " << Time->at(0) << " " << Time->at(1) << " " << Time->at(2) << " " << Time->at(size-1) << std::endl;
//std::cout << " Time: " << Time->at(0)-Time->at(1) << " " << Time->at(1)-Time->at(2) << " " << Time->at(2)-Time->at(3) << " " << Time->at(size-1) << std::endl;
//std::cout << "time stamp: " << ptime << std::endl;
for(int j = 0; j < Amp->size(); j++){
if(i = 1)h1->Fill(Time->at(j),Amp->at(j));
if(i = 109)h2->Fill(Time->at(j),Amp->at(j));
if(i = 267)h3->Fill(Time->at(j),Amp->at(j));
if(Amp->at(j) < min2){
min2 = Amp->at(j);
}
}
h->Fill(TMath::Abs(min2));
//if(min2 != 1.0)std::cout << "Min: " << min2 << std::endl;
}
h1->Draw();
TFile* f1 = new TFile("test.root","RECREATE");
h->Write();
h1->Write();
h2->Write();
h3->Write();
f1->Close();
f->Close();
return 0;
}