Subversion Repositories f9daq

Rev

Blame | Last modification | View Log | RSS feed

void printgain(char * foutput=NULL){
   
   char fname[0xff];
   char run[0xff];
   sprintf(fname,"%s",gSystem->BaseName(_file0->GetName()));
   fname[11]=0;
   strncpy(run,fname,4);
   run[4]=0;
   TIter nxt(gDirectory->GetListOfKeys());
   TKey *key;

   FILE *fo=stdout;
   if (foutput!=NULL && strlen(foutput)>1) {
     fo = fopen(foutput,"a");
     printf("FILE=%s",foutput);
   }
   while ((key = (TKey*)nxt())) {
     
      TClass *cl = gROOT->GetClass(key->GetClassName());
     
      if (!cl->InheritsFrom("TCanvas")) continue;
      TCanvas *c1 = (TCanvas*)key->ReadObj();
      TPad *pad = (TPad *)c1->GetListOfPrimitives()->At(1);

      TH2F *h2 = (TH2F*)pad->GetListOfPrimitives()->At(0);
      TCanvas c2;
      if (h2) {
        h2->Print();
        fprintf(fo,"<gain run='%s' sn='%s'>\n", run,&fname[5]);
        for (int i=0;i < h2->GetNbinsX();i++){
          for (int j=0;j < h2->GetNbinsY();j++){
            fprintf(fo,"<v i='%d'>%g</v>\n",i* h2->GetNbinsY()+j, h2->GetBinContent(i+1,j+1));
          }
        }
        fprintf(fo,"</gain>\n");
      }    
      else printf("not found\n");
     
   }
//   TCanvas *c1 = gDirectory->Get("0063_ZJ6743_Gain")
//   hFra40 = (TH1F*)c1->GetPrimitive("hFracEtcorr2Part");

}