Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plot_gain_factors2.C
Go to the documentation of this file.
2 {
3 // test program to read a file with a list of file names
4 //
5 
6 #include <TRandom.h>
7 
8 gROOT->Reset();
9 //TTree *Bfield = (TTree *) gROOT->FindObject("Bfield");
10 gStyle->SetPalette(1,0);
11 gStyle->SetOptStat(kTRUE);
12 gStyle->SetOptStat(11111111);
13 gStyle->SetOptFit(kTRUE);
14 gStyle->SetPadRightMargin(0.15);
15 gStyle->SetPadLeftMargin(0.15);
16 gStyle->SetPadBottomMargin(0.15);
17 //
18 
19  char string[256];
20  Int_t j,jj;
21  Int_t ndx;
22  Int_t nbins=100;
23 
24  const int nchan=2800;
25 
26  Double_t g2931[nchan];
27  Double_t g3079[nchan];
28  Double_t g3179[nchan];
29  Double_t g3180[nchan];
30  Double_t g3182[nchan];
31  Double_t g2931_r20_60[nchan];
32  Double_t g3079_r20_60[nchan];
33  Double_t g3179_r20_60[nchan];
34  Double_t g3180_r20_60[nchan];
35  Double_t g3182_r20_60[nchan];
36 
37  Double_t g3079_3182_r20[nchan];
38  Double_t g3079_3182_r20_60[nchan];
39  Double_t g2931_3182_r20[nchan];
40  Double_t g2931_3182_r20_60[nchan];
41 
42  // Look at runs 2931-3182;
43 
44  sprintf(string,"GainFactorIter1_2931-3182_r20-60.root");
45  printf ("Histogram input filename=%s\n",string);
46  TFile *in = new TFile(string,"read");
47 
48  TH1D *h_unordered2931_3182_r20_60 = (TH1D*)in->Get("h_unordered");
49  TH2D *h_yvsx2931_3182_r20_60 = (TH2D*)in->Get("h_yvsx");
50 
51  ifstream gainfile;
52  ofstream outgain;
53  outgain.open ("plot_gain_factors2.list");
54 
55  // Repeat for Run2931-3182
56 
57  gainfile.close();
58 
59  TString infile = "GainFactorIter1_2931-3182_r20-60.txt";
60  cout << "Opening file: " << infile.Data() << endl;
61  gainfile.open (infile.Data());
62  if (!gainfile) {
63  cout << "ERROR: Failed to open data file= " << infile.Data() << endl;
64  return;
65  }
66 
67  TString line;
68  while (line.ReadLine(gainfile)){
69 
70  TObjArray *tokens = line.Tokenize(" ");
71  Float_t gain = (((TObjString*)tokens->At(0))->GetString()).Atof();
72  TString s = ((TObjString*)tokens->At(1))->GetString().Remove(0,8);
73  Int_t channel = s.Atoi();
74  g2931_3182_r20_60[channel] = gain;
75  outgain << " R3182_r20_60, channel=" << channel << " gain=" << gain << endl;
76 
77  }
78  gainfile.close();
79 
80 
81 
82  TCanvas *c10 = new TCanvas("c10","c10 plot_gain_factors2",200,10,1000,500);
83  c10->Divide(2,1);
84  // c10->SetGridx();
85  // c10->SetGridy();
86  // c10->SetLogz();
87 
88  Float_t zmin=0.8;
89  Float_t zmax=1.6;
90  c10->cd(1);
91  runnum = 3182;
92 
93  sprintf(string,"Electron Gain Factors Run 2931-3182, Jul27");
94  h_yvsx2931_3182_r20_60->SetTitle(string);
95  h_yvsx2931_3182_r20_60->GetZaxis()->SetRangeUser(zmin,zmax);
96  h_yvsx2931_3182_r20_60->GetYaxis()->SetTitle("y");
97  h_yvsx2931_3182_r20_60->GetXaxis()->SetTitle("x");
98  h_yvsx2931_3182_r20_60->Draw("colz");
99 
100  Float_t ymin=0;
101  Float_t ymax=150;
102  c10->cd(2);
103 
104  h_unordered2931_3182_r20_60->SetTitle(string);;
105  h_unordered2931_3182_r20_60->GetYaxis()->SetRangeUser(ymin,ymax);
106  h_unordered2931_3182_r20_60->GetYaxis()->SetTitle("Counts");
107  h_unordered2931_3182_r20_60->GetXaxis()->SetTitle("Gain Factor");
108  h_unordered2931_3182_r20_60->Fit("gaus");
109  h_unordered2931_3182_r20_60->Draw("");
110 
111  Float_t zmin=0.8;
112  Float_t zmax=1.6;
113  c10->cd(3);
114 
115  Float_t ymin=0;
116  Float_t ymax=150;
117  c10->cd(4);
118 
119  // print histograms
120 
121  sprintf(string,"plot_gain_factors2.pdf");
122  c10->SaveAs(string);
123 
124  // close files
125 
126  outgain.close();
127 
128  // in->Close();
129 
130 
131 }
132 
sprintf(text,"Post KinFit Cut")
double zmax
TFile * infile
Definition: tw_corr.C:45
void plot_gain_factors2(void)
Double_t ymin
Definition: bcal_hist_eff.C:89
Double_t ymax
Definition: bcal_hist_eff.C:91
Int_t ndx
printf("string=%s", string)
double zmin