StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testPmtSignal.C
1 TH2 *h1fast, *h1full;
2 TH1 *h2fast, *h2full, *h3fast, *h3full;
3 TCanvas *c;
4 TLegend *leg;
5 
6 void testPmtSignal(float pmtGain=1.5e+6, float cathodeNoise=0.0, float dynodeNoise=0.0) {
7  gROOT->Macro("LoadLogger.C");
8  gSystem->Load("StChain");
9  gSystem->Load("StMcEvent");
10  gSystem->Load("StEmcSimulatorMaker");
11  cout << "loaded libraries" << endl;
12 
13  gStyle->SetOptStat(0);
14 
15  StPmtSignal p(pmtGain, cathodeNoise, dynodeNoise);
16  int maxAdc = 4096;
17  float maxEnergy = 60.0;
18  float photoElectronsPerMIP = 63.0;
19  float energyPerMIP = 0.0198;
20  float samplingFraction = 14.1;
21  float totalGain = (maxAdc / maxEnergy) * (energyPerMIP / photoElectronsPerMIP) * samplingFraction;
22  p.setTotalGain(totalGain); // ADC / photoElectron
23  p.setPedestalMean(30.0);
24  p.setPedestalRMS(1.5);
25 
26  h1fast = new TH2D("h1fast","<ADC> / photoElectrons",50, 0.0, 16000.0, 50, 0.0, 4000.0);
27  h1full = new TH2D("h1full","<ADC> / photoElectrons",50, 0.0, 16000.0, 50, 0.0, 4000.0);
28 
29  h2fast = new TH1D("h2fast","ADC distributions for 400 photoElectrons",50, 125.0, 175.0);
30  h2full = new TH1D("h2full","ADC distributions for 400 photoElectrons",50, 125.0, 175.0);
31 
32  h3fast = new TH1D("h3fast","ADC distributions for 8000 photoElectrons",50, 2350.0, 2550.0);
33  h3full = new TH1D("h3full","ADC distributions for 8000 photoElectrons",50, 2350.0, 2550.0);
34 
35  for(int i=0; i<16000; i++) {
36  if(i%1000 == 0) cout << "processing " << i << endl;
37  h1fast->Fill(i, p.getAdc(i, StPmtSignal::kFastSimulator));
38  h1full->Fill(i, p.getAdc(i, StPmtSignal::kFullSimulator));
39 
40  h2fast->Fill(p.getAdc(400, StPmtSignal::kFastSimulator));
41  h2full->Fill(p.getAdc(400, StPmtSignal::kFullSimulator));
42 
43  h3fast->Fill(p.getAdc(8000, StPmtSignal::kFastSimulator));
44  h3full->Fill(p.getAdc(8000, StPmtSignal::kFullSimulator));
45  }
46 
47  h1fast->SetXTitle("nPhotoElectrons");
48  h1fast->SetYTitle("ADC");
49 
50  h2fast->SetXTitle("ADC");
51  h3fast->SetXTitle("ADC");
52 
53  h1full->SetLineColor(kRed);
54  h2full->SetLineColor(kRed);
55  h3full->SetLineColor(kRed);
56 
57  c = new TCanvas("c","",900,300);
58  c->Divide(3,1);
59 
60  c->cd(1);
61  h1fast->Draw("box");
62  h1full->Draw("box same");
63 
64  leg = new TLegend(0.1,0.7,0.5,0.9);
65  leg->AddEntry(h1fast,"fastSimulator");
66  leg->AddEntry(h1full,"fullSimulator");
67  leg->Draw();
68 
69  TVirtualPad * pad = c->cd(2);
70  pad->SetLogy();
71  h2fast->Draw();
72  h2full->Draw("same");
73 
74  pad = c->cd(3);
75  pad->SetLogy();
76  h3fast->Draw();
77  h3full->Draw("same");
78 }