-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_elecs_shms_all.C
132 lines (101 loc) · 3.49 KB
/
get_elecs_shms_all.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <iostream>
#include <fstream>
#include <string>
#include <TFile.h>
#include <TDirectory.h>
#include <TTree.h>
#include <TMatrixD.h>
#include <TROOT.h>
#include <TMatrixDBase.h>
#include <TMath.h>
#include <TChain.h>
#include <TH1F.h>
#include <TF1.h>
#include <cstdlib>
#include "TColor.h"
#include "TH3.h"
using namespace std;
static const double degtorad = 3.141592653589793/180.;
void formatit(TH1F *histo, TString bar, TString xax, TString yax, Int_t flag, Int_t flag2, Int_t flagc){
gPad->SetTicks(1,1);
gPad->SetLeftMargin(0.15);
gPad->SetRightMargin(0.03);
gPad->SetTopMargin(0.03);
gPad->SetBottomMargin(0.13);
// gPad->SetLiny(1);
if (flag == 1){
gPad->SetLogy(1);
}
histo->SetLabelSize(0.045, "x");
histo->SetLabelSize(0.045, "y");
histo->GetXaxis()->SetTitleSize(0.055);
histo->GetYaxis()->SetTitleSize(0.055);
histo->GetXaxis()->CenterTitle(1);
histo->GetYaxis()->CenterTitle(1);
histo->GetXaxis()->SetTitleOffset(1.1);
histo->GetYaxis()->SetTitleOffset(1.3);
histo->GetYaxis()->SetTitle(yax);
histo->GetXaxis()->SetTitle(xax);
histo->SetLineColor(kAzure-2);
histo->SetLineWidth(3);
histo->SetLineStyle(1);
if(flag2 == 0){
histo->Draw("");
}
if(flag2 == 1){
histo->Draw("same");
}
if(flagc == 2){
histo->SetLineStyle(1);
histo->SetLineColor(kAzure-2);
}
if(flagc == 3){
histo->SetLineStyle(1);
histo->SetLineColor(kPink+10);
}
leg = new TLegend(0.15,0.85,0.35,0.95);
leg->SetFillColor(-1);
leg->SetFillStyle(0);
leg->SetTextSize(0.055);
leg->SetTextColor(kAzure-2);
leg->SetBorderSize(0);
leg->AddEntry(histo,bar,"");
leg->Draw("same");
}
TH1F *pion_histo = new TH1F("","",150,0.,1.5);
TH1F *elec_histo = new TH1F("","",150,0.,1.5);
TH1F *all_histo = new TH1F("","",150,0.,1.5);
void get_elecs_shms_all(Int_t run_num, Double_t elec_goal){
Double_t shtrk, npe, delta;
string myfile;
myfile = Form("/net/cdaqfs/home/cdaq/hallc-online/hallc_replay/ROOTfiles/shms_replay_production_%d_-1.root",run_num);
TFile *fileis = new TFile(myfile.c_str());
cout << "root file is: " << myfile << endl;
TTree *tis = (TTree*)fileis->Get("T");
tis->SetBranchAddress("P.cal.etracknorm",&shtrk);
tis->SetBranchAddress("P.ngcer.npeSum",&npe);
tis->SetBranchAddress("P.gtr.dp",&delta);
Int_t nentries = tis->GetEntries();
cout << " ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" << endl;
cout << "you are indeed sampling " << nentries << " coda events " << endl;
cout << " ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" << endl;
for(Int_t i=0; i < nentries; i++){
tis->GetEntry(i);
if(delta > -10. && delta < 22.){
all_histo->Fill(shtrk);
}
if(npe > 2. && shtrk > 0.7 && delta > -10. && delta < 22.){
elec_histo->Fill(shtrk);
}
if(npe == 0. && shtrk < 0.7 && delta > -10. && delta < 22.){
pion_histo->Fill(shtrk);
}
}
Double_t elec_events = elec_histo->Integral();
Double_t pion_events = pion_histo->Integral();
cout << "Look here for your desired SHMS electrons in this whole run: " << elec_events << endl;
cout << " ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" << endl;
cout << "this is " << elec_events*100./elec_goal/1000 << "% of" << " " << elec_goal << " " << " K electrons" << endl;
cout << " ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" << endl;
cout << " ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" << endl;
}