Пример #1
0
THStack * GetBkgStack(TFile *f, const char * name, const char * xtitle, TLegend * leg, int mode=0){
   char full_name[200];

   if (leg) {
      leg->SetFillStyle(0);
      leg->SetBorderSize(0);
      leg->SetTextSize(0.04);
   }

   sprintf(full_name, "stack_%s", name);
   THStack * stack = new THStack(full_name, "");

   TH1F * h_base = (TH1F *)f->Get(name);
   h_base->SetXTitle(xtitle);
   stack->SetHistogram(h_base);

   if (mode == 0)
   {
/*
      AddHist(stack, leg, f, name, "vbh_h_zz_4l",   "VV > H > ZZ > 4L",  FILL0, MYGREEN2);
      AddHist(stack, leg, f, name, "gg_zz_4l",      "gg > ZZ > 4L",      FILL0, MYORANGE1);
      AddHist(stack, leg, f, name, "gg_zz_2l2l",    "gg > ZZ > 2L2L",    FILL0, MYBLUE1);
      AddHist(stack, leg, f, name, "qq_zz_2e2mu",   "qq > ZZ > 2e2mu",   FILL0, MYCYAN2);
      AddHist(stack, leg, f, name, "gg_h_zz_4l",    "gg > H > ZZ > 4L",  FILL0, MYMAGENTA2);
      AddHist(stack, leg, f, name, "qq_zz_4e",      "qq > ZZ > 4e",      FILL0, MYGREEN1);   
      AddHist(stack, leg, f, name, "qq_zz_4mu",     "qq > ZZ > 4mu",     FILL0, MYORANGE2);  
      AddHist(stack, leg, f, name, "wh_zh_tth_hzz", "HW HW Htt, H > ZZ", FILL0, MYCYAN1);   
      AddHist(stack, leg, f, name, "wh_zh_tth_hww", "HW HZ Htt, H > WW", FILL0, MYMAGENTA1);
*/
      AddHist(stack, leg, f, name, "zh_hzz",  "HZ, H > ZZ",  FILL0, MYCYAN1);   
      AddHist(stack, leg, f, name, "zh_hww",  "HZ, H > WW",  FILL0, MYMAGENTA1);
      AddHist(stack, leg, f, name, "h_zz_4l", "H > ZZ > 4L", FILL0, MYGREEN2);
      AddHist(stack, leg, f, name, "zz_4l",   "ZZ > 4L",     FILL0, MYBLUE2);
   }
   return stack;
}
Пример #2
0
bool HistList::AddHist(double *res,int n,double m,double sd,CString raw)
{
	gsl_histogram *r;
	if(n<=0) return false;
	double std=gsl_stats_sd(res,1,n);
	double bin=3.49*std/pow(n*1.0,1.0/3);//Scott's ruler
	if(bin<=0) return false;	
	double a=gsl_stats_min(res,1,n);
	double b=gsl_stats_max(res,1,n);
	int num=(int)((b-a)/bin);
	r=gsl_histogram_alloc(num);
	gsl_histogram_set_ranges_uniform(r,a,b);
	for(int i=0;i<n;i++)
	{
		gsl_histogram_increment(r,res[i]);
	}
	bool bResult=AddHist(r,m,sd,raw);
	gsl_histogram_free(r);
	return bResult;
}
Пример #3
0
//---------------------------------------------------------------------------
void __fastcall TFtpOptDialog::BtnOkClick(TObject *Sender)
{
	AnsiString PathOffset_Text=PathOffset->Text;
	AnsiString Interval_Text=Interval->Text;
	AnsiString Offset_Text=Offset->Text;
	AnsiString RetryInterval_Text=RetryInterval->Text;
	AnsiString User_Text=User->Text,Passwd_Text=Passwd->Text;
	AnsiString Addr_Text=Addr->Text,s;
	int topts[4];
	
	topts[0]=(int)(atof(PathOffset_Text.c_str())*3600.0);
	topts[1]=(int)(atof(Interval_Text.c_str())*3600.0);
	topts[2]=(int)(atof(Offset_Text.c_str())*3600.0);
	topts[3]=atoi(RetryInterval_Text.c_str());
	
	Path=s.sprintf("%s:%s@%s::T=%d,%d,%d,%d",User_Text.c_str(),
				   Passwd_Text.c_str(),Addr_Text.c_str(),
				   topts[0],topts[1],topts[2],topts[3]);
	
	AddHist(Addr,History);
}
Пример #4
0
// convert file -------------------------------------------------------------
void __fastcall TMainWindow::ConvertFile(void)
{
    rnxopt_t rnxopt={0};
    AnsiString InFile_Text=InFile->Text;
    AnsiString OutFile1_Text=OutFile1->Text,OutFile2_Text=OutFile2->Text;
    AnsiString OutFile3_Text=OutFile3->Text,OutFile4_Text=OutFile4->Text;
    AnsiString OutFile5_Text=OutFile5->Text,OutFile6_Text=OutFile6->Text;
    AnsiString OutFile7_Text=OutFile7->Text;
    int i,format,sat;
    char file[1024]="",*ofile[7],ofile_[7][1024]={""},msg[256],*p;
    char buff[256],tstr[32];
    double RNXVER[]={2.10,2.11,2.12,3.00,3.01,3.02};
    FILE *fp;
    
    // abort conversion
    if (BtnConvert->Caption=="Abort") {
        abortf=1;
        return;
    }
    for (i=0;i<7;i++) ofile[i]=ofile_[i];
    
    // recognize input file format
    strcpy(file,InFile_Text.c_str());
    if (!(p=strrchr(file,'.'))) p=file;
    if (Format->ItemIndex==0) { // auto
        if      (!strcmp(p,".rtcm2")) format=STRFMT_RTCM2;
        else if (!strcmp(p,".rtcm3")) format=STRFMT_RTCM3;
        else if (!strcmp(p,".gps"  )) format=STRFMT_OEM4;
        else if (!strcmp(p,".ubx"  )) format=STRFMT_UBX;
        else if (!strcmp(p,".log"  )) format=STRFMT_SS2;
        else if (!strcmp(p,".bin"  )) format=STRFMT_CRES;
        else if (!strcmp(p,".jps"  )) format=STRFMT_JAVAD;
        else if (!strcmp(p,".bnx"  )) format=STRFMT_BINEX;
        else if (!strcmp(p,".binex")) format=STRFMT_BINEX;
        else if (!strcmp(p,".rt17" )) format=STRFMT_RT17;
        else if (!strcmp(p,".obs"  )) format=STRFMT_RINEX;
        else if (!strcmp(p,".OBS"  )) format=STRFMT_RINEX;
        else if (!strcmp(p,".nav"  )) format=STRFMT_RINEX;
        else if (!strcmp(p,".NAV"  )) format=STRFMT_RINEX;
        else if (!strcmp(p+2,"nav" )) format=STRFMT_RINEX;
        else if (!strcmp(p+2,"NAV" )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"o"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"O"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"n"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"N"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"p"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"P"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"g"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"G"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"h"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"H"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"q"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"Q"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"l"   )) format=STRFMT_RINEX;
        else if (!strcmp(p+3,"L"   )) format=STRFMT_RINEX;
        else {
            showmsg("file format can not be recognized");
            return;
        }
    }
    else {
        for (i=0;formatstrs[i];i++) {
            if (Format->Text==formatstrs[i]) break;
        }
        if (formatstrs[i]) format=i; else return;
    }
    rnxopt.rnxver=RNXVER[RnxVer];
    
    if (format==STRFMT_RTCM2||format==STRFMT_RTCM3||format==STRFMT_RT17) {
        
        // input start date/time for rtcm 2 ro rtcm 3
        if (StartDialog->ShowModal()!=mrOk) return;
        rnxopt.trtcm=StartDialog->Time;
    }
    if (OutFile1->Enabled&&OutFileEna1->Checked) strcpy(ofile[0],OutFile1_Text.c_str());
    if (OutFile2->Enabled&&OutFileEna2->Checked) strcpy(ofile[1],OutFile2_Text.c_str());
    if (OutFile3->Enabled&&OutFileEna3->Checked) strcpy(ofile[2],OutFile3_Text.c_str());
    if (OutFile4->Enabled&&OutFileEna4->Checked) strcpy(ofile[3],OutFile4_Text.c_str());
    if (OutFile5->Enabled&&OutFileEna5->Checked) strcpy(ofile[4],OutFile5_Text.c_str());
    if (OutFile6->Enabled&&OutFileEna6->Checked) strcpy(ofile[5],OutFile6_Text.c_str());
    if (OutFile7->Enabled&&OutFileEna7->Checked) strcpy(ofile[6],OutFile7_Text.c_str());
    
    // check overwrite output file
    for (i=0;i<6;i++) {
        if (!*ofile[i]||!(fp=fopen(ofile[i],"r"))) continue;
        fclose(fp);
        ConfDialog->Label2->Caption=ofile[i];
        if (ConfDialog->ShowModal()!=mrOk) return;
    }
    GetTime(&rnxopt.ts,&rnxopt.te,&rnxopt.tint,&rnxopt.tunit);
    strncpy(rnxopt.staid,RnxCode.c_str(),31);
    sprintf(rnxopt.prog,"%s %s",PRGNAME,VER_RTKLIB);
    strncpy(rnxopt.runby,RunBy.c_str(),31);
    strncpy(rnxopt.marker,Marker.c_str(),63);
    strncpy(rnxopt.markerno,MarkerNo.c_str(),31);
    strncpy(rnxopt.markertype,MarkerType.c_str(),31);
    for (i=0;i<2;i++) strncpy(rnxopt.name[i],Name[i].c_str(),31);
    for (i=0;i<3;i++) strncpy(rnxopt.rec [i],Rec [i].c_str(),31);
    for (i=0;i<3;i++) strncpy(rnxopt.ant [i],Ant [i].c_str(),31);
    if (AutoPos) {
        for (i=0;i<3;i++) rnxopt.apppos[i]=AppPos[i];
    }
    for (i=0;i<3;i++) rnxopt.antdel[i]=AntDel[i];
    strncpy(rnxopt.rcvopt,RcvOption.c_str(),255);
    rnxopt.navsys=NavSys;
    rnxopt.obstype=ObsType;
    rnxopt.freqtype=FreqType;
    p=rnxopt.comment[0];
    sprintf(p,"log: %-53.53s",file);
    p=rnxopt.comment[1];
    p+=sprintf(p,"format: %s",formatstrs[format]);
    if (*rnxopt.rcvopt) sprintf(p,", option: %s",rnxopt.rcvopt);
    for (i=0;i<2;i++) strncpy(rnxopt.comment[i+2],Comment[i].c_str(),63);
    for (i=0;i<6;i++) strcpy(rnxopt.mask[i],CodeMask[i].c_str());
    rnxopt.autopos=AutoPos;
    rnxopt.scanobs=ScanObs;
    rnxopt.outiono=OutIono;
    rnxopt.outtime=OutTime;
    rnxopt.outleaps=OutLeaps;
    
    strcpy(buff,ExSats.c_str());
    for (p=strtok(buff," ");p;p=strtok(NULL," ")) {
        if (!(sat=satid2no(p))) continue;
        rnxopt.exsats[sat-1]=1;
    }
    abortf=0;
    BtnConvert  ->Caption="Abort";
    Panel1      ->Enabled=false;
    Panel2      ->Enabled=false;
    BtnPlot     ->Enabled=false;
    BtnPost     ->Enabled=false;
    BtnOptions  ->Enabled=false;
    BtnExit     ->Enabled=false;
    Format      ->Enabled=false;
    BtnKey      ->Enabled=false;
    LabelInFile ->Enabled=false;
    LabelOutDir ->Enabled=false;
    LabelOutFile->Enabled=false;
    LabelFormat ->Enabled=false;
    Message     ->Caption="";
    
    if (TraceLevel>0) {
        traceopen(TRACEFILE);
        tracelevel(TraceLevel);
    }
    // convert to rinex
    (void)convrnx(format,&rnxopt,file,ofile);
    
    if (TraceLevel>0) {
        traceclose();
    }
    BtnConvert  ->Caption="&Convert";
    Panel1      ->Enabled=true;
    Panel2      ->Enabled=true;
    BtnPlot     ->Enabled=true;
    BtnPost     ->Enabled=true;
    BtnOptions  ->Enabled=true;
    BtnExit     ->Enabled=true;
    Format      ->Enabled=true;
    BtnKey      ->Enabled=true;
    LabelInFile ->Enabled=true;
    LabelOutDir ->Enabled=true;
    LabelOutFile->Enabled=true;
    LabelFormat ->Enabled=true;
    
#if 0
    // set time-start/end if time not specified
    if (!TimeStartF->Checked&&rnxopt.tstart.time!=0) {
        time2str(rnxopt.tstart,tstr,0);
        tstr[10]='\0';
        TimeY1->Text=tstr;
        TimeH1->Text=tstr+11;
    }
    if (!TimeEndF->Checked&&rnxopt.tend.time!=0) {
        time2str(rnxopt.tend,tstr,0);
        tstr[10]='\0';
        TimeY2->Text=tstr;
        TimeH2->Text=tstr+11;
    }
#endif
    RnxTime=rnxopt.tstart;
    
    AddHist(InFile);
}