check3He.C
1 |
void check3He()
|
---|---|
2 |
{ |
3 |
|
4 |
|
5 |
TFile *fr = new TFile("sim_digi.root"); |
6 |
TTree *tr = (TTree*)fr->Get("er");
|
7 |
TClonesArray *tracks = new TClonesArray("ERQTelescopeTrack", 10); |
8 |
tr->SetBranchAddress("ERQTelescopeTrack_DoubleSi_SD2_XY_1", &tracks);
|
9 |
|
10 |
TFile *fw = new TFile("output.root", "RECREATE"); |
11 |
TTree *tw = new TTree("out","a simple Tree with simple variables"); |
12 |
|
13 |
Float_t x, y, z, energy; |
14 |
TLorentzVector *particle = new TLorentzVector();
|
15 |
|
16 |
// tw->Branch("x",&x,"x/F");
|
17 |
// tw->Branch("y",&y,"y/F");
|
18 |
// tw->Branch("z",&z,"z/F");
|
19 |
tw->Branch("energy",&energy,"energy/F"); |
20 |
|
21 |
tw->Branch("particle.", "TLorentzVector", &particle); |
22 |
|
23 |
Double_t dE, E; |
24 |
|
25 |
//read all entries and fill the histograms
|
26 |
Long64_t nentries = tr->GetEntriesFast(); |
27 |
// nentries = 1000;
|
28 |
for (Long64_t i = 0; i < nentries; i++) { |
29 |
tr->GetEntry(i); |
30 |
|
31 |
dE = 0;
|
32 |
E = 0;
|
33 |
x = 0; y = 0; z = 0; |
34 |
particle->SetXYZT(0, 0, 0, 0); |
35 |
|
36 |
for (int iPoint = 0; iPoint < tracks->GetEntriesFast(); iPoint++) { |
37 |
ERQTelescopeTrack* t = (ERQTelescopeTrack*)tracks->At(iPoint); |
38 |
|
39 |
if (tracks->GetEntriesFast() == 1) { |
40 |
|
41 |
x = t->fTelescopeX-t->fTargetX; |
42 |
y = t->fTelescopeY-t->fTargetY; |
43 |
z = t->fTelescopeZ-t->fTargetZ; |
44 |
energy = t->fSumEdep; |
45 |
|
46 |
TVector3 p; |
47 |
p.SetXYZ(x, y, z); |
48 |
p.SetMag( TMath::Sqrt( TMath::Power(energy + 2.809,2) - TMath::Power(2.809, 2) ) ); |
49 |
particle->SetVect(p); |
50 |
particle->SetE(energy + 2.809); |
51 |
} |
52 |
|
53 |
} |
54 |
|
55 |
tw->Fill(); |
56 |
|
57 |
} |
58 |
|
59 |
tw->Write(); |
60 |
fw->Close(); |
61 |
|
62 |
// if (gROOT->IsBatch())
|
63 |
// return;
|
64 |
|
65 |
} |
66 |
|