int sec=4; const int nBox=3, nTube=12; char *cbox[nBox]={"S1","S2","S3"}; TFile* fd=new TFile("out/pi5067.hist.root"); //TFile* fd=new TFile("out/pi5062.hist.root"); TH2F *hgsmd=new TH2F("gsmd","SMD relative yield vs. strip ID",290,0.5,290.5,100,0,0.05); TObjArray* HList=new TObjArray(0); int pr1=0; //0=no ,1=draw 2=ps &, 3=gif int pr2=0; // 0=no ,1=draw 2=ps &, 3=gif float sumG=0; int nSum=0; mapmtInt(int secX=5) { sec=secX; gStyle->SetOptStat(1111111); initTubeHisto(); // doOneGain("05U150"); return; // doGainsPre('P',1); // doGainsPre('Q',1); //doGainsPre('R',1); // for(sec=5;sec<=8;sec++) { doGainsSmd('U',2); doGainsSmd('V',2); } printf("//=============================================\n"); printTubeHisto(); return; gStyle->SetPalette(1); printf("sumG=%f nSum=%d\n",sumG, nSum); c=new TCanvas(); hgsmd->Draw("colz"); // c2->cd(0); TH1F* h3=(TH1F*)HList->FindObject("05P1-02"); h3->Draw(); printf("#x, %s, %.3f, %.3f\n",h3->GetName(),h3->GetMean(),h3->GetRMS()); } //============================================= printTubeHisto() { int ib; for (ib=0;ibFindObject(tt1); assert(h3); printf("#3, %s, %.4f, %.4f\n",h3->GetName(),h3->GetMean(),h3->GetRMS()); if(pr2) { TCanvas *c2=new TCanvas("aa2","aa2",500,300); h3->Draw(); if(pr2>1) { TString C=h3->GetName(); c2->Print(C+".ps"); if(pr2>2) c2->Print(C+".gif"); } } // return; } } } //============================================= initTubeHisto() { int ib; for (ib=0;ibAdd(h); } } } //============================================= doGainsPre(char layer='P', int key=1) { char sub; int eta; for(sub='A';sub<='E';sub++) { for(eta=1;eta<=12;eta++) { char tt1[100],tt2[100]; sprintf(tt1,"%02d%c%c%02d",sec,layer,sub,eta); doOneGain(tt1,key); } } } //============================================= doGainsSmd(char uv='U', int key=1) { int strip; for(strip=1;strip<=288;strip++) { char tt1[100],tt2[100]; sprintf(tt1,"%02d%c%03d",sec,uv,strip); float x=doOneGain(tt1,key); float y=x/avr_rYiled(strip); float gain1=y*8 * avr_noPE(strip); printf(" %3f, %.3f \n",y, gain1); hgsmd->Fill(strip,x); if(strip>=100 && strip<200) { sumG+=x; nSum++; } } } //================================== float doOneGain(char *tt1, int key=1){ TH1F * h=(TH1F*) fd->Get(tt1); assert(h); TH1F * h2=(TH1F*) h->Clone(); h2->SetAxisRange(5,200); float sum=h2->Integral(); float rYiled=sum/h->GetEntries(); // printf("%s %f %f\n",tt1,sum,gain1); char tt2[100],tt3[100]; char *tit=h->GetTitle(); char *p=strstr(tit,"tube="); assert(p); sprintf(tt2,"%s",p+5); tt2[7]=0; char *p2=strstr(tit,"chan="); assert(p2); sprintf(tt3,"%s",p2+5); tt3[7]=0; printf("#%d, %s, %s, %s, %.0f, %.4f, ",key,tt1,p+5,tt3,sum,rYiled); if(pr1>=0) { TH1F* h3=(TH1F*)HList->FindObject(tt2); assert(h3); h3->Fill(rYiled); } if(pr1) { TCanvas *c1=new TCanvas("aa","aa",300,310); c1->Divide(1,2); c1->cd(1); h->Draw(); gPad->SetLogy(); c1->cd(2); h2->Draw(); if(pr1>1) { TString C=h->GetName(); c1->Print(C+".ps"); if(pr1>2) c1->Print(C+".gif"); } delete h2; } return rYiled; } //============================================= float avr_rYiled(int stripID) { float y=0; float ya=0,yb=0,xa=1,xb=2; if ( stripID<1) { ; } else if (stripID<60) { xa=1; ya=0.006; xb=60; yb=0.037; } else if (stripID<150) { xa=60; ya=0.037; xb=150; yb=0.017; } else { xa=150; ya=0.017; xb=290; yb=0.003; } y=ya+(yb-ya)/(xb-xa) *(stripID -xa); return y; } //============================================= float avr_noPE(int stripID) { float y=0; float ya=0,yb=0,xa=1,xb=2; if ( stripID<1) { ; } else if (stripID<20) { xa=1; ya=2.; xb=20; yb=4.; } else if (stripID<250) { xa=20; ya=4.; xb=250; yb=6.; } else { xa=250; ya=6.; xb=290; yb=9.; } y=ya+(yb-ya)/(xb-xa) *(stripID -xa); return y; }