22 void create1D(
L2Histo & h,
char *hname) {
23 TString name=
"h";name+=h.getId();
24 if(hname[0]) name=hname;
25 TString title=h.getTitle();
27 int sum=h.getNunder()+h.getNover();
29 TH1F *hout=
new TH1F(name,title,nbin,0,nbin);
30 float * y=hout->GetArray();
31 const int *
data=h.getData();
32 for (
int ii=0;ii<nbin;ii++ ){
37 y[nbin+1]=h.getNover();
38 hout->SetEntries(sum);
39 hout->SetLineColor(kBlue);
45 TString name=
"h";name+=h.getId();
46 TString title=h.getTitle();
48 int nbinX=h.getNbinX();
49 int nbinY=h.getNbin()/nbinX;
50 int sum=h.getNunder()+h.getNover();
52 TH2F *hout=
new TH2F(name,title,nbinX,0,nbinX,nbinY,0,nbinY);
54 const int *data=h.getData();
55 for (
int i =0;i <nbin;i ++ ){
59 hout->SetBinContent(ix+1,iy+1,data[i]);
64 hout->SetEntries(sum);
71 int main(
int argc,
char ** argv ) {
72 printf(
"Converting L2-bin-histos to root histos START...");
75 printf(
"\nERROR: must specify an input and output file, e.g.:\n %s inp.hist.bin out.hist.root\n STOP\n",argv[0]);
79 char *histFname=argv[1];
82 FILE *histFd=fopen(histFname,
"r");
85 TString ofilename=argv[2];
86 printf(
"outfile=%s\n",ofilename.Data());
88 TFile *ofile=
new TFile(ofilename,
"recreate");
93 int ret=h.read(histFd);
96 int iMax=-3, iFWHM=-4;
97 h.findMax( &iMax, &iFWHM);
98 if(h.getId()<1000) printf(
"h%d, '%s' binMax=%d \n",h.getId(),h.getTitle(),iMax);
107 strncpy(hname+1,h.getTitle()+5,6);
112 if(h.is1D()) create1D(h,hname);