plotapdhv2.C
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <sstream>
4 #include "TH1D.h"
5 #include "TH2D.h"
6 #include "TFile.h"
7 #include "TCanvas.h"
8 #include "TStyle.h"
9 
10 using namespace std;
11 
12 void plotapdhv(const char* fname){
13  //little root macro to check the text file of HVs to set for nominal gain
14  //right now it only plots up to diblock7, someone will have to fix it when we
15  //get past that point with apd instrumentation. Consider it milestone.
16  gStyle->SetOptStat("e m r i o");
17  const int NDIBLK=15;
18  TH2D *dcmvprt[NDIBLK];
19  TH2D *dcmvprt_volt[NDIBLK];
20  for(int i=0;i<NDIBLK;i++){
21  dcmvprt[i] = new TH2D(Form("dcmvprt_%d",i),Form(";DCM %d; PRT",i),12,0.5,12.5,64,-0.5,63.5);
22  dcmvprt[i]->SetStats(0);
23 
24  dcmvprt_volt[i] = new TH2D(Form("dcmvprt_volt_%d",i),Form(";DCM %d; PRT",i),12,0.5,12.5,64,-0.5,63.5);
25  dcmvprt_volt[i]->SetStats(0);
26  // dcmvprt_volt[i]->SetMinimum(-1);
27  dcmvprt_volt[i]->SetMaximum(4500);
28  }
29  TH1D *voltage=new TH1D("",";Ideal (warm) APD Voltage;",100,350,450);
30  TH1D *febicept = new TH1D("",";FEB calibration intercept",30,280,310);
31  TH1D *febslope = new TH1D("",";FEB calibration slope",10,0.0255,0.0265);
32  TH1D *febset = new TH1D("",";FEB Setpoint",600,0,6000);
33  TH1D *vset = new TH1D("",";Voltage for 2000",150,250,400);
34 
35  ifstream in(fname);
36  // string apd_sn;
37  int dib;
38  int dcm;
39  int prt;
40  float t;
41  // float v;
42  // string feb;
43  // float icpt;
44  // float slope;
45  string iblank;
46  string dcsstring;
47  float setpoint;
48  // in>>apd_sn;
49  string line;
50  int count = 0;
51  while(std::getline(in,line)){
52  std::istringstream iss(line);
53  std::getline(iss,iblank,',');
54  std::getline(iss,dcsstring,'-');
55  std::getline(iss,iblank,'-');
56  string sdib;
57  std::getline(iss,sdib,'-');
58  dib = atoi(sdib.c_str());
59  string sdcm;
60  std::getline(iss,sdcm,',');
61  dcm = atoi(sdcm.c_str());
62  string sprt;
63  std::getline(iss,sprt,',');
64  prt = atoi(sprt.c_str());
65  string st;
66  std::getline(iss,st,',');
67  t = atof(st.c_str());
68  string ssetpoint;
69  std::getline(iss,ssetpoint,',');
70  setpoint = atof(ssetpoint.c_str());
71  if(setpoint<100){
72  setpoint=2.0;
73  cout<<"low setpoint "<<setpoint<<" dcm "<<dcm<<" prt "<<prt<<endl;
74  }
75  std::getline(iss,iblank,',');
76  std::getline(iss,iblank,',');
77  std::getline(iss,iblank,',');
78  std::getline(iss,iblank,',');
79  std::getline(iss,iblank);
80 
81  cout<<"dib "<<dib<<" dcm "<<dcm<<" prt "<<prt<<" setpoint "<<setpoint<<" "<<endl;
82  dcmvprt[dib]->Fill(dcm,prt);
83  dcmvprt_volt[dib]->Fill(dcm,prt,setpoint);
84  // voltage->Fill(v);
85  // febicept->Fill(icpt);
86  // febslope->Fill(slope);
87  febset->Fill(setpoint);
88  // double actualv = 2000*slope+icpt;
89  // cout<<" actual v "<<actualv<<" slope "<<slope<<endl;
90  // vset->Fill(actualv);
91  // cout<<apd_sn<<" "<<dib<<" "<<dcm<<" "<<prt<<" "<<v<<" "<<feb<<" "<<icpt<<" "<<slope<<" "<<setpoint<<endl;
92  count++;
93  // getline(in,line);
94  }
95  cout<<"count "<<count<<endl;
96  TCanvas *can1 = new TCanvas("can1","can1");
97  can1->Divide(2,2);
98  can1->cd(1);
99  dcmvprt[1]->Draw("colz");
100  dcmvprt[1]->GetXaxis()->CenterTitle();
101  dcmvprt[1]->GetYaxis()->CenterTitle();
102  can1->cd(2);
103  dcmvprt[2]->Draw("colz");
104  dcmvprt[2]->GetXaxis()->CenterTitle();
105  dcmvprt[2]->GetYaxis()->CenterTitle();
106  can1->cd(3);
107  dcmvprt[3]->Draw("colz");
108  dcmvprt[3]->GetXaxis()->CenterTitle();
109  dcmvprt[3]->GetYaxis()->CenterTitle();
110  can1->cd(4);
111  dcmvprt[4]->Draw("colz");
112  dcmvprt[4]->GetXaxis()->CenterTitle();
113  dcmvprt[4]->GetYaxis()->CenterTitle();
114 
115  TCanvas *can2 = new TCanvas("can2","can2");
116  can2->Divide(2,2);
117  can2->cd(1);
118  dcmvprt[5]->Draw("colz");
119  dcmvprt[5]->GetXaxis()->CenterTitle();
120  dcmvprt[5]->GetYaxis()->CenterTitle();
121  can2->cd(2);
122  dcmvprt[6]->Draw("colz");
123  dcmvprt[6]->GetXaxis()->CenterTitle();
124  dcmvprt[6]->GetYaxis()->CenterTitle();
125  can2->cd(3);
126  dcmvprt[7]->Draw("colz");
127  dcmvprt[7]->GetXaxis()->CenterTitle();
128  dcmvprt[7]->GetYaxis()->CenterTitle();
129  can2->cd(4);
130  dcmvprt[8]->Draw("colz");
131  dcmvprt[8]->GetXaxis()->CenterTitle();
132  dcmvprt[8]->GetYaxis()->CenterTitle();
133 
134  TCanvas *can3 = new TCanvas("can3","can3");
135  can3->Divide(2,2);
136  can3->cd(1);
137  dcmvprt[9]->Draw("colz");
138  dcmvprt[9]->GetXaxis()->CenterTitle();
139  dcmvprt[9]->GetYaxis()->CenterTitle();
140  can3->cd(2);
141  dcmvprt[10]->Draw("colz");
142  dcmvprt[10]->GetXaxis()->CenterTitle();
143  dcmvprt[10]->GetYaxis()->CenterTitle();
144  can3->cd(3);
145  dcmvprt[11]->Draw("colz");
146  dcmvprt[11]->GetXaxis()->CenterTitle();
147  dcmvprt[11]->GetYaxis()->CenterTitle();
148  can3->cd(4);
149  dcmvprt[12]->Draw("colz");
150  dcmvprt[12]->GetXaxis()->CenterTitle();
151  dcmvprt[12]->GetYaxis()->CenterTitle();
152 
153 
154  TCanvas *can6 = new TCanvas("can6","can6");
155  can6->Divide(2,2);
156  can6->cd(1);
157  dcmvprt_volt[1]->Draw("colz");
158  dcmvprt_volt[1]->GetXaxis()->CenterTitle();
159  dcmvprt_volt[1]->GetYaxis()->CenterTitle();
160  can6->cd(2);
161  dcmvprt_volt[2]->Draw("colz");
162  dcmvprt_volt[2]->GetXaxis()->CenterTitle();
163  dcmvprt_volt[2]->GetYaxis()->CenterTitle();
164  can6->cd(3);
165  dcmvprt_volt[3]->Draw("colz");
166  dcmvprt_volt[3]->GetXaxis()->CenterTitle();
167  dcmvprt_volt[3]->GetYaxis()->CenterTitle();
168  can6->cd(4);
169  dcmvprt_volt[4]->Draw("colz");
170  dcmvprt_volt[4]->GetXaxis()->CenterTitle();
171  dcmvprt_volt[4]->GetYaxis()->CenterTitle();
172 
173  TCanvas *can7 = new TCanvas("can7","can7");
174  can7->Divide(2,2);
175  can7->cd(1);
176  dcmvprt_volt[5]->Draw("colz");
177  dcmvprt_volt[5]->GetXaxis()->CenterTitle();
178  dcmvprt_volt[5]->GetYaxis()->CenterTitle();
179  can7->cd(2);
180  dcmvprt_volt[6]->Draw("colz");
181  dcmvprt_volt[6]->GetXaxis()->CenterTitle();
182  dcmvprt_volt[6]->GetYaxis()->CenterTitle();
183  can7->cd(3);
184  dcmvprt_volt[7]->Draw("colz");
185  dcmvprt_volt[7]->GetXaxis()->CenterTitle();
186  dcmvprt_volt[7]->GetYaxis()->CenterTitle();
187  can7->cd(4);
188  dcmvprt_volt[8]->Draw("colz");
189  dcmvprt_volt[8]->GetXaxis()->CenterTitle();
190  dcmvprt_volt[8]->GetYaxis()->CenterTitle();
191 
192  TCanvas *can8 = new TCanvas("can8","can8");
193  can8->Divide(2,2);
194  can8->cd(1);
195  dcmvprt_volt[9]->Draw("colz");
196  dcmvprt_volt[9]->GetXaxis()->CenterTitle();
197  dcmvprt_volt[9]->GetYaxis()->CenterTitle();
198  can8->cd(2);
199  dcmvprt_volt[10]->Draw("colz");
200  dcmvprt_volt[10]->GetXaxis()->CenterTitle();
201  dcmvprt_volt[10]->GetYaxis()->CenterTitle();
202  can8->cd(3);
203  dcmvprt_volt[11]->Draw("colz");
204  dcmvprt_volt[11]->GetXaxis()->CenterTitle();
205  dcmvprt_volt[11]->GetYaxis()->CenterTitle();
206  can8->cd(4);
207  dcmvprt_volt[12]->Draw("colz");
208  dcmvprt_volt[12]->GetXaxis()->CenterTitle();
209  dcmvprt_volt[12]->GetYaxis()->CenterTitle();
210 
211  // TCanvas *can2 = new TCanvas("can2","can2");
212  // can2->cd();
213  // voltage->Draw();
214  // TCanvas *can3 = new TCanvas("can3","can3");
215  // can3->cd();
216  // febicept->Draw();
217  // TCanvas *can4 = new TCanvas("can4","can4");
218  // can4->cd();
219  // febslope->GetXaxis()->SetNdivisions(504);
220  // febslope->Draw();
221  TCanvas *canf = new TCanvas("canf","canf");
222  canf->cd();
223  febset->Draw();
224  // TCanvas *can7 = new TCanvas("can7","can7");
225  // can7->cd();
226  // vset->SetStats(0);
227  // vset->Draw();
228 
229  for(int i=1;i<NDIBLK;i++){
230  for(int j=1;j<=dcmvprt[i]->GetNbinsX();j++){
231  for(int k=1;k<=dcmvprt[i]->GetNbinsY();k++){
232  if(dcmvprt[i]->GetBinContent(j,k)<0.5) cout<<"zero! diblock "<<i<<" dcm "<<j<<" port "<<k-1<<endl;
233  if(dcmvprt[i]->GetBinContent(j,k)>1.5) cout<<"double! diblock "<<i<<" dcm "<<j<<" port "<<k-1<<endl;
234  }
235  }
236  }
237 
238 
239 }
void plotapdhv(const char *fname)
Definition: plotapdhv2.C:12
const double j
Definition: BetheBloch.cxx:29
TCanvas * can1
Definition: tutCAFMacro.C:16
OStream cout
Definition: OStream.cxx:6
ifstream in
Definition: comparison.C:7
TCanvas * can2
Definition: tutCAFMacro.C:40