29 void create1D(
L2Histo & h,
char *hname) {
30 TString name=
"h";name+=h.getId();
31 if(hname[0]) name=hname;
32 TString title=h.getTitle();
34 int sum=h.getNunder()+h.getNover();
36 TH1F *hout=
new TH1F(name,title,nbin,0,nbin);
37 float * y=hout->GetArray();
38 const int *
data=h.getData();
39 for (
int ii=0;ii<nbin;ii++ ){
44 y[nbin+1]=h.getNover();
45 hout->SetEntries(sum);
46 hout->SetLineColor(kBlue);
52 TString name=
"h";name+=h.getId();
53 TString title=h.getTitle();
55 int nbinX=h.getNbinX();
56 int nbinY=h.getNbin()/nbinX;
57 int sum=h.getNunder()+h.getNover();
59 TH2F *hout=
new TH2F(name,title,nbinX,0,nbinX,nbinY,0,nbinY);
61 const int *data=h.getData();
62 for (
int i =0;i <nbin;i ++ ){
66 hout->SetBinContent(ix+1,iy+1,data[i]);
71 hout->SetEntries(sum);
78 int main(
int argc,
char ** argv ) {
79 printf(
"Converting L2-bin-histos to root histos START...");
82 printf(
"\nERROR: must specify an input and output file, e.g.:\n %s inp.hist.bin out.hist.root\n STOP\n",argv[0]);
86 char *histFname=argv[1];
89 FILE *histFd=fopen(histFname,
"r");
92 TString ofilename=argv[2];
93 printf(
"outfile=%s\n",ofilename.Data());
95 TFile *ofile=
new TFile(ofilename,
"recreate");
100 int ret=h.read(histFd);
103 int iMax=-3, iFWHM=-4;
104 h.findMax( &iMax, &iFWHM);
105 if(h.getId()<1000) printf(
"h%d, '%s' binMax=%d \n",h.getId(),h.getTitle(),iMax);
114 strncpy(hname+1,h.getTitle()+5,6);
119 if(h.is1D()) create1D(h,hname);