00001 TH2F *h2scan=0;
00002 const int mxBTiles=4800;
00003
00004 float cut_minZ=40;
00005 int isBprs=0;
00006
00007 void findMap( ){
00008
00009 char *crun="calib-nov-8-2008/sum-swapB";
00010 crun="sumD43-70";
00011 gStyle->SetPalette(1,0);
00012 gStyle->SetOptStat(0);
00013
00014
00015 char *pathIn="./";
00016 char *pathOut="ourX/";
00017 char txt[1000], txt2[1000];
00018
00019 sprintf(txt,"%s/%s.hist.root",pathIn,crun);
00020 fd1=new TFile(txt); assert(fd1->IsOpen());
00021 printf("Opened: %s\n",fd1->GetName());
00022 h2scan= (TH2F *)fd1->Get("swapScan"); assert(h2scan);
00023
00024 int id1=1, id2=4800;
00025 id2=41;
00026 c=new TCanvas("aa","aa",1400,300);
00027
00028 TH1F *h1=findBest(h2scan, id1,id2,crun );
00029 h1->Draw();
00030
00031
00032 }
00033
00034
00035
00036
00037
00038
00039 TH1F* findBest( TH2F *h2, int id1, int id2, char *crun) {
00040
00041 char txt[1000], txt2[1000];
00042
00043 sprintf(txt,"mapCor");
00044 sprintf(txt2,"mapping crection %d; old soft ID; new soft ID", crun);
00045 hMapCor=new TH1I(txt,txt2,mxBTiles,0.5,mxBTiles+0.5);
00046
00047
00048 axX=h2->GetXaxis();
00049 float x1=axX->GetXmin();
00050 float x2=axX->GetXmax();
00051 int nbX=axX->GetNbins();
00052 printf("X-axis range --> [%.1f, %.1f], nb=%d %s\n",x1,x2,nbX,axX->GetTitle());
00053
00054 axY=h2->GetYaxis();
00055 float y1=axY->GetXmin();
00056 float y2=axY->GetXmax();
00057 int nbY=axY->GetNbins();
00058 printf("Y-axis range --> [%.1f, %.1f], nb=%d\n",y1,y2,nbY);
00059
00060 TH1F*h1=new TH1F("h1","h1",nbX,x1,x2);
00061
00062
00063 for(int iy=id1; iy<=id2; iy++) {
00064 char txt1[100], txt2[1000];
00065 sprintf(txt1,"id%d",iy);
00066 sprintf(txt2,"soft id=%d; %s",iy,axX->GetTitle());
00067 h1->SetTitle(txt2);
00068 h1->Reset();
00069 int i;
00070 int kBad=1;
00071 for(i=1;i<=nbX;i++) h1->SetBinContent(i,h2->GetBinContent(i,iy));
00072 float peakX=h1->GetMaximumBin();
00073 float peakZ=h1->GetMaximum();
00074 float yield=h1->Integral();
00075 h1->SetEntries(yield);
00076 printf(" work on %s peakX=%.1f peakZ=%.1f\n",txt1,peakX,peakZ);
00077 float idL=peakX-20;
00078 float idH=peakX+20;
00079 h1->SetAxisRange( idL,idH);
00080 float yieldR=h1->Integral();
00081
00082 float r1=peakZ/yieldR;
00083 h1->SetAxisRange( 0,5000);
00084
00085 printf(" ID range=%d,%d r1=%.3f yieldR=%.1f\n",idL,idH,r1,yieldR);
00086 int idBest=(int)peakX;
00087 if(peakZ<cut_minZ) { printf("## DEAD/MISSING softID %d ",iy);
00088 } else if(idBest==iy) { printf("# OK softID %d ",iy);
00089 } else {
00090 printf("ss hReMap->SetBinContent( %4d, %4d); // nMIP=%.0f, PDF page=%d\n",idBest,iy,peakZ, 1+((iy-1)/200));
00091 printf("## CHANGE old softID %d --> %d , nMIP=%.0f-->",idBest,iy,h1->GetBinContent(iy));
00092 assert(isBprs==0);
00093 }
00094 printf(" nMIP=%.0f\n",peakZ);
00095
00096 }
00097
00098 return h1;
00099 }
00100
00101 #if 0
00102 if(yield<cut_yield0) { hStat->SetBinContent(ih,kBad); continue; }
00103 kBad<<=1;
00104
00105 if(isSticky(h,mean)) { hStat->SetBinContent(ih,kBad); continue; }
00106 kBad<<=1;
00107
00108
00109
00110 if(r1< cut_yieldR1) { hStat->SetBinContent(ih,kBad); continue; }
00111 kBad<<=1;
00112
00113 h->Fit("gaus","Q","Rh", adc1, adc2);
00114 TF1 *ff=h->GetFunction("gaus"); assert(ff);
00115 ff->SetLineColor(kRed);
00116 ff->SetLineWidth(1.);
00117 h->Draw();
00118
00119 float ped=ff->GetParameter(1);
00120 float pedErr=ff->GetParError(1);
00121 float sig=ff->GetParameter(2);
00122 float chi2=ff->GetChisquare();
00123 float ndf=ff->GetNDF();
00124
00125 #endif