StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mergePed.C
1 TH2F *h2Ped=0, *h2Sig=0, *h2Peak;
2 TH1F *h1Stat=0, *h2CapStat;
3 TH1F *h1p7=0, *h1p77=0, *h1p777=0;
4 TH2S *h2PedS=0;
5 
6 void mergePed(){
7  int cap1=0, cap2=127;
8  gStyle->SetPalette(1,0);
9 
10  int run=9067013;
11  char *pathIn="outX/";
12  char *pathOut="iter3/";
13  char txt[1000], txt2[1000];
14  int nCap=128;
15 
16  sprintf(txt,"%s/pedBprsR%dallCap.hist.root",pathOut,run);
17  fd2=new TFile(txt,"recreate");
18  int nb=800, xx1=100,xx2=300;
19  h1p7=new TH1F("pedSoftId7","pedestals(cap) , softID=7, crate=0; pedestal(ADC)", nb,xx1,xx2);
20  h1p607=new TH1F("pedSoftId607","pedestals(cap) , softID=607, crate=1; pedestal(ADC)", nb,xx1,xx2);
21  h1p2407=new TH1F("pedSoftId2407","pedestals(cap) , softID=2407, crate=2; pedestal(ADC)", nb,xx1,xx2);
22  h1p3007=new TH1F("pedSoftId3007","pedestals(cap) , softID=3007, crate=2; pedestal(ADC)", nb,xx1,xx2);
23 
24  for(int cap=cap1;cap<=cap2;cap++) {
25  // if(cap==108 || cap==109 ||cap==118 || cap==119 ) continue;
26  sprintf(txt,"%s/pedBprsR%d-cap%d.hist.root",pathIn,run,cap);
27  fd1=new TFile(txt); assert(fd1->IsOpen());
28  TH1F * ih1ped= (TH1F *)fd1->Get("pedBPRS"); assert(ih1ped);
29  TH1F * ih1stat= (TH1F *)fd1->Get("statBPRS"); assert(ih1stat);
30  TH1F * ih1sig= (TH1F *)fd1->Get("sigPedBPRS"); assert(ih1sig);
31  TH1F * ih1peak= (TH1F *)fd1->Get("pedPeakBPRS"); assert(ih1peak);
32  printf("----- merge: %s entries=%d\n",txt,ih1ped->GetEntries());
33  printf(" %s entries=%d\n",txt,ih1stat->GetEntries());
34  axX=ih1ped->GetXaxis();
35  float x1=axX->GetXmin();
36  float x2=axX->GetXmax();
37  int nbX=axX->GetNbins();
38  printf("X-axis range --> [%.1f, %.1f], nb=%d %s\n",x1,x2,nbX,axX->GetTitle());
39 
40  if(h2Ped==0) {
41  sprintf(txt,"pedBPRScap");
42  sprintf(txt2,"BPRS pedestal (ADC), R%d ; BPRS soft ID; capID",run);
43  h2Ped=new TH2F(txt,txt2,nbX,x1,x2,nCap,-0.5,nCap-0.5);
44 
45  sprintf(txt,"sigPedBPRScap");
46  sprintf(txt2,"BPRS sig(ped) (Z=ADC), R%d ; BPRS soft ID; capID",run);
47  h2Sig=new TH2F(txt,txt2,nbX,x1,x2,nCap,-0.5,nCap-0.5);
48 
49  sprintf(txt,"peakPedBPRScap");
50  sprintf(txt2,"integral of pedestal peak, R%d ; BPRS soft ID; capID",run);
51  h2Peak=new TH2F(txt,txt2,nbX,x1,x2,nCap,-0.5,nCap-0.5);
52 
53  sprintf(txt,"statBPRSallCap");
54  sprintf(txt2,"BPRS status from all caps, R%d ; BPRS soft ID; # of bad caps",run);
55  h1Stat=new TH1F(txt,txt2,nbX,x1,x2);
56 
57  sprintf(txt,"capStatBPRSallSoft");
58  sprintf(txt2,"BPRS status from all softID, R%d ; BPRS capID; # of bad softID",run);
59  h1CapStat=new TH1F(txt,txt2,128,-0.5,127.5);
60 
61  printf("H2 created\n");
62  }
63 
64  for(int i=1;i<=nbX;i++) {// i=softID
65  h2Ped->SetBinContent(i,cap+1,ih1ped->GetBinContent(i));
66  h2Sig->SetBinContent(i,cap+1,ih1sig->GetBinContent(i));
67  h2Peak->SetBinContent(i,cap+1,ih1peak->GetBinContent(i));
68  if(ih1stat->GetBinContent(i)>0) {
69  h1Stat->Fill(i,1);
70  h1CapStat->Fill(cap,1);
71  }
72  }
73 
74  h1p7->Fill(ih1ped->GetBinContent(7));
75  h1p607->Fill(ih1ped->GetBinContent(607));
76  h1p2407->Fill(ih1ped->GetBinContent(2407));
77  h1p3007->Fill(ih1ped->GetBinContent(3007));
78 
79  }// end of loop over caps
80 
81  // count dead tiles
82  int nDead=0;
83  for(int i=1;i<=nbX;i++) {// i=softID
84  if(h1Stat->GetBinContent(i)) nDead++;
85  }
86  h1Stat->SetEntries(nDead);
87  printf(" accumulated nDead=%d\n",nDead);
88 
89  fd2->cd();
90  h2Ped->Write();
91  h2Sig->Write();
92  h2Peak->Write();
93  h1Stat->Write();
94  h1CapStat->Write();
95  h1p7->Write();
96  h1p607->Write();
97  h1p2407->Write();
98  h1p3007->Write();
99 
100  printf("total entries=%d\n",h2Ped->GetEntries());
101 
102  return;
103  // dump 3D histo ....
104  for(int k=120;k<=128;k++) //capID
105  for(int i=1;i<=nbX;i++) //chan
106  for(int j=1;j<=nbY;j++) //ADC
107  {
108  float val=h3->GetBinContent(i,j,k);
109  if(val<1.) continue;
110  printf("chan(i)=%d, adc(j)=%d, cap(k)=%d val=%f\n", i-1,j+100,k-1,val);
111  }
112 }
113 
114 void pl7(){
115  c=new TCanvas();
116  c->Divide(3,1);
117  c->cd(1);pedSoft7->Draw();
118  c->cd(2);pedSoft77->Draw();
119  c->cd(3);pedSoft777->Draw();
120 
121 
122 }