-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoinc.C
92 lines (77 loc) · 2.58 KB
/
coinc.C
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
85
86
87
88
89
90
91
92
#include <TH2.h>
#include <TStyle.h>
#include <iostream>
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TSelector.h>
//========================================//
//Global Variables goodness
const int NFILES = 8;
const int RefChan = 4; // Silicon back
const int FrontChan = 0;
//end of Global Variable fun
//========================================//
//Make a file and a tree
TFile *f[NFILES];
TTree *T[NFILES];
// Declaration of leaf types
Int_t eventID[NFILES];
Int_t trigID[NFILES];
Double_t energy[NFILES];
Double_t t1[NFILES];
// List of branches
TBranch *b_eventID[NFILES]; //!
TBranch *b_trigID[NFILES]; //!
TBranch *b_energy[NFILES]; //!
TBranch *b_t1[NFILES]; //!
//We want some histograms
TH2F *hLvE = new TH2F("hLvE","\\text{Energy vs. Position};\\text{Position } \\left( Q_{L}/Q_{B} \\approx \\frac{x}{L}\\right);Energy Deposited in Silicon",500,0,1,500,0,1000);
int coinc()
{
// Channel Map for Silicon only no gas
f[0] = new TFile("wave0.root"); // two front middle
f[1] = new TFile("wave1.root"); // ""
f[2] = new TFile("wave2.root"); // ""
f[3] = new TFile("wave3.root"); // ""
f[4] = new TFile("wave4.root"); // back 1
f[5] = new TFile("wave5.root"); // back 2
f[6] = new TFile("wave6.root"); // back 3
f[7] = new TFile("wave7.root"); // back 4
int entry[NFILES];
int numEntries[NFILES];
for(int i =0; i<NFILES; i++)
{
T[i] = (TTree*)f[i]->Get("T"); //magic
T[i]->SetBranchAddress("eventID", &eventID[i], &b_eventID[i]);
T[i]->SetBranchAddress("trigID", &trigID[i], &b_trigID[i]);
T[i]->SetBranchAddress("energy", &energy[i], &b_energy[i]);
T[i]->SetBranchAddress("t1", &t1[i], &b_t1[i]);
numEntries[i]=T[i]->GetEntries();
} //reads in a root tree branch and places it in the array: array, branch
for(int i = 0; i< NFILES; i++)
{
entry[i] = 0;
}
for(int iRef = 0; iRef < numEntries[RefChan]; iRef++ )
{
T[RefChan]->GetEntry(iRef); // get the data
cout << eventID[RefChan] << " " << energy[RefChan] << endl;
for(int iOther = entry[FrontChan]; iOther < numEntries[FrontChan]; iOther++)
{
T[FrontChan]->GetEntry(iOther);
if(eventID[FrontChan] == eventID[RefChan])
{
cout << "YAY! " << eventID[FrontChan] << " " << energy[FrontChan] << " " << energy[RefChan] << endl;
hLvE->Fill(energy[FrontChan]/energy[RefChan],energy[RefChan]);
}
if(eventID[FrontChan] > eventID[RefChan])
{
entry[FrontChan] = iOther;
break;
}
}
}
hLvE->Draw();
return 0;
}