Skip to content

Commit 9a93afa

Browse files
committed
adding spectrum code
1 parent b7c7f34 commit 9a93afa

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

spectrum.cc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
gROOT->Reset();
3+
4+
TFile* f = new TFile("/media/data/cmorgoth/scope_data/NoCrystalData/NoCrystalData.root");
5+
TTree* tree = (TTree*)f->Get("outTree");
6+
7+
std::cout.precision(12);
8+
double ptime;
9+
std::vector<float> *Amp;
10+
std::vector<float> *Time;
11+
12+
tree->SetBranchAddress("ptime", &ptime);
13+
tree->SetBranchAddress("Amp", &Amp);
14+
tree->SetBranchAddress("Time", &Time);
15+
16+
TH1F* h = new TH1F("h", "muon spectrum", 1000, .0, .5);
17+
float min2 = 1.0;
18+
for(int i = 0; i < tree->GetEntries(); i++){
19+
tree->GetEntry(i);
20+
float min = 1.0;
21+
min2 = 1.0;
22+
//std::cout << "vector size: " << Amp->size() << std::endl;
23+
//std::cout << "time stamp: " << ptime << std::endl;
24+
for(int j = 0; j < Amp->size(); j++){
25+
if(Amp->at(j) < min2){
26+
min2 = Amp->at(j);
27+
}
28+
}
29+
30+
h->Fill(TMath::Abs(min2));
31+
if(min2 != 1.0)std::cout << "Min: " << min2 << std::endl;
32+
33+
}
34+
35+
h->Draw();
36+
TFile* f1 = new TFile("test.root","RECREATE");
37+
h->Write();
38+
f1->Close();
39+
f->Close();
40+
}

0 commit comments

Comments
 (0)