Ejemplo n.º 1
0
static void
RunUI(Port &port, OperationEnvironment &env)
{
  WriteMenu();

  while (true) {
    fprintf(stdout, "> ");

    char in[20];
    if (fgets(in, 20, stdin) == NULL || strlen(in) == 0) {
      fprintf(stdout, "Invalid input\n");
      continue;
    }

    switch (in[0]) {
    case '?':
    case 'h':
    case 'H':
      WriteMenu();
      break;
    case '1':
      SetMC(port, env);
      break;
    case '2':
      SetBallast(port, env);
      break;
    case '3':
      SetBugs(port, env);
      break;
    case '4':
      SetAltitudeOffset(port, env);
      break;
    case '5':
      SetQNH(port, env);
      break;
    case '6':
      SetVolume(port, env);
      break;
    case 'p':
    case 'P':
      SetPolar(port, env);
      break;
    case 'f':
    case 'F':
      SetFilters(port, env);
      break;
    case 's':
    case 'S':
      SetSCSettings(port, env);
      break;
    case 'q':
    case 'Q':
      fprintf(stdout, "Closing LX1600 Utils ...\n");
      return;
    default:
      fprintf(stdout, "Invalid input\n");
      break;
    }
  }
}
Ejemplo n.º 2
0
void checkcentrality(TString datafilename, TString mcfilename)
{
  TFile *fdt = new TFile(datafilename);
  TFile *fmc = new TFile(mcfilename);

  auto tdt = (TTree *)fdt->Get("nt");
  auto tmc = (TTree *)fmc->Get("nt");

  auto hdt = new TH1F("centrdt","centrdt",50,0,200); hdt->SetMarkerColor(kBlack);
  auto hmc = new TH1F("centrmc","centrmc",50,0,200); hmc->SetMarkerColor(kBlue);

  SetMC({hmc}); SetInc({hmc});
  SetData({hdt});


  tdt->Project("centrdt","bin","weight*(jtpt1>120 && jtpt2>30 && dphi21>2. && hiHF<5500)");
  tmc->Project("centrmc","bin","weight*(jtpt1>120 && jtpt2>30 && dphi21>2. && pthatsample>30)");

  hmc->Scale(hdt->Integral()/hmc->Integral());

  fout->cd();
  hdt->Write();
  hmc->Write();
  fdt->Close();
  fmc->Close();

}
Ejemplo n.º 3
0
void checkvertex(TString datafilename, TString mcfilename)
{

  TFile *fmc = new TFile(mcfilename);
  auto ntmc = (TTree *)fmc->Get("nt");
  TFile *fdt = new TFile(datafilename);
  auto ntdt = (TTree *)fdt->Get("nt");

  auto vdt0 = new TH1F("vdt0","Data no weighting",30,-15,15); vdt0->Sumw2();
  auto vmc0 = new TH1F("vmc0","MC no weighting",30,-15,15); vmc0->Sumw2();

  ntdt->Project("vdt0","vz","weight*(jtpt2>120 && jtpt2>30)");
  ntmc->Project("vmc0","vz","pthatweight*(jtpt2>120 && jtpt2>30 && pthatsample>30)");
  
  vdt0->Scale(1/vdt0->Integral());
  vmc0->Scale(1/vmc0->Integral());

  plotylog = false;
  Draw({vdt0,vmc0});

  auto vdt = new TH1F("vdt","Data weighted",30,-15,15); vdt->Sumw2();
  auto vmc = new TH1F("vmc","MC weighted",30,-15,15); vmc->Sumw2();

  ntdt->Project("vdt","vz","weight*(jtpt2>120 && jtpt2>30)");
  ntmc->Project("vmc","vz","weight*(jtpt2>120 && jtpt2>30 && pthatsample>30)");
  
  vdt->Scale(1/vdt->Integral());
  vmc->Scale(1/vmc->Integral());


  SetMC({vmc, vmc0});
  SetData({vdt,vdt0});
  SetInc({vmc, vmc0});


  fout->cd();
  vdt->Write();
  vmc->Write();
  vdt0->Write();
  vmc0->Write();
  fmc->Close();
  fdt->Close();
}
Ejemplo n.º 4
0
GlidePolar::GlidePolar(const fixed _mc, const fixed _bugs, const fixed _ballast) :
  mc(_mc),
  bugs(_bugs),
  ballast(_ballast),
  cruise_efficiency(fixed(1)),
  VbestLD(fixed(0)),
  Vmax(fixed(75.0)),
  Vmin(fixed(0)),
  ideal_polar(fixed(0.00157), fixed(-0.0734), fixed(1.48)),
  ballast_ratio(0.3),
  reference_mass(300),
  dry_mass(reference_mass),
  wing_area(fixed(0))
{
  Update();

  // Calculate inv_mc
  SetMC(mc);
}
Ejemplo n.º 5
0
GlidePolar::GlidePolar(const double _mc, const double _bugs, const double _ballast)
  :mc(_mc),
   bugs(_bugs),
   ballast(_ballast),
   cruise_efficiency(1),
   VbestLD(0),
   Vmax(75),
   Vmin(0),
   ideal_polar(0.00157, -0.0734, 1.48),
   ballast_ratio(0.3),
   reference_mass(300),
   dry_mass(reference_mass),
   wing_area(0)
{
  Update();

  // Calculate inv_mc
  SetMC(mc);
}
Ejemplo n.º 6
0
OGRErr OGRSpatialReference::importFromUSGS( long iProjSys, long iZone,
                                            double *padfPrjParams,
                                            long iDatum, int bAnglesInPackedDMSFormat )

{
    if( !padfPrjParams )
        return OGRERR_CORRUPT_DATA;

    double (*pfnUnpackAnglesFn)(double);
    if (bAnglesInPackedDMSFormat)
        pfnUnpackAnglesFn = CPLPackedDMSToDec;
    else
        pfnUnpackAnglesFn = OGRSpatialReferenceUSGSUnpackNoOp;

/* -------------------------------------------------------------------- */
/*      Operate on the basis of the projection code.                    */
/* -------------------------------------------------------------------- */
    switch ( iProjSys )
    {
        case GEO:
            break;

        case UTM:
            {
                int bNorth = TRUE;

                if ( !iZone )
                {
                    if ( padfPrjParams[2] != 0.0 )
                        iZone = (long) padfPrjParams[2];
                    else if (padfPrjParams[0] != 0.0 && padfPrjParams[1] != 0.0)
                    {
                        iZone = (long)(((pfnUnpackAnglesFn(padfPrjParams[0])
                                         + 180.0) / 6.0) + 1.0);
                        if ( pfnUnpackAnglesFn(padfPrjParams[0]) < 0 )
                            bNorth = FALSE;
                    }
                }

                if ( iZone < 0 )
                {
                    iZone = -iZone;
                    bNorth = FALSE;
                }
                SetUTM( iZone, bNorth );
            }
            break;

        case SPCS:
            {
                int bNAD83 = TRUE;

                if ( iDatum == 0 )
                    bNAD83 = FALSE;
                else if ( iDatum != 8 )
                    CPLError( CE_Warning, CPLE_AppDefined,
                              "Wrong datum for State Plane projection %d. "
                              "Should be 0 or 8.", (int) iDatum );
                
                SetStatePlane( iZone, bNAD83 );
            }
            break;

        case ALBERS:
            SetACEA( pfnUnpackAnglesFn(padfPrjParams[2]),
                     pfnUnpackAnglesFn(padfPrjParams[3]),
                     pfnUnpackAnglesFn(padfPrjParams[5]),
                     pfnUnpackAnglesFn(padfPrjParams[4]),
                     padfPrjParams[6], padfPrjParams[7] );
            break;

        case LAMCC:
            SetLCC( pfnUnpackAnglesFn(padfPrjParams[2]),
                    pfnUnpackAnglesFn(padfPrjParams[3]),
                    pfnUnpackAnglesFn(padfPrjParams[5]),
                    pfnUnpackAnglesFn(padfPrjParams[4]),
                    padfPrjParams[6], padfPrjParams[7] );
            break;

        case MERCAT:
            SetMercator( pfnUnpackAnglesFn(padfPrjParams[5]),
                         pfnUnpackAnglesFn(padfPrjParams[4]),
                         1.0,
                         padfPrjParams[6], padfPrjParams[7] );
            break;

        case PS:
            SetPS( pfnUnpackAnglesFn(padfPrjParams[5]),
                   pfnUnpackAnglesFn(padfPrjParams[4]),
                   1.0,
                   padfPrjParams[6], padfPrjParams[7] );

            break;

        case POLYC:
            SetPolyconic( pfnUnpackAnglesFn(padfPrjParams[5]),
                          pfnUnpackAnglesFn(padfPrjParams[4]),
                          padfPrjParams[6], padfPrjParams[7] );
            break;

        case EQUIDC:
            if ( padfPrjParams[8] )
            {
                SetEC( pfnUnpackAnglesFn(padfPrjParams[2]),
                       pfnUnpackAnglesFn(padfPrjParams[3]),
                       pfnUnpackAnglesFn(padfPrjParams[5]),
                       pfnUnpackAnglesFn(padfPrjParams[4]),
                       padfPrjParams[6], padfPrjParams[7] );
            }
            else
            {
                SetEC( pfnUnpackAnglesFn(padfPrjParams[2]),
                       pfnUnpackAnglesFn(padfPrjParams[2]),
                       pfnUnpackAnglesFn(padfPrjParams[5]),
                       pfnUnpackAnglesFn(padfPrjParams[4]),
                       padfPrjParams[6], padfPrjParams[7] );
            }
            break;

        case TM:
            SetTM( pfnUnpackAnglesFn(padfPrjParams[5]),
                   pfnUnpackAnglesFn(padfPrjParams[4]),
                   padfPrjParams[2],
                   padfPrjParams[6], padfPrjParams[7] );
            break;

        case STEREO:
            SetStereographic( pfnUnpackAnglesFn(padfPrjParams[5]),
                              pfnUnpackAnglesFn(padfPrjParams[4]),
                              1.0,
                              padfPrjParams[6], padfPrjParams[7] );
            break;

        case LAMAZ:
            SetLAEA( pfnUnpackAnglesFn(padfPrjParams[5]),
                     pfnUnpackAnglesFn(padfPrjParams[4]),
                     padfPrjParams[6], padfPrjParams[7] );
            break;

        case AZMEQD:
            SetAE( pfnUnpackAnglesFn(padfPrjParams[5]),
                   pfnUnpackAnglesFn(padfPrjParams[4]),
                   padfPrjParams[6], padfPrjParams[7] );
            break;

        case GNOMON:
            SetGnomonic( pfnUnpackAnglesFn(padfPrjParams[5]),
                         pfnUnpackAnglesFn(padfPrjParams[4]),
                         padfPrjParams[6], padfPrjParams[7] );
            break;

        case ORTHO:
            SetOrthographic( pfnUnpackAnglesFn(padfPrjParams[5]),
                             pfnUnpackAnglesFn(padfPrjParams[4]),
                             padfPrjParams[6], padfPrjParams[7] );
            break;

        // FIXME: GVNSP --- General Vertical Near-Side Perspective skipped

        case SNSOID:
            SetSinusoidal( pfnUnpackAnglesFn(padfPrjParams[4]),
                           padfPrjParams[6], padfPrjParams[7] );
            break;

        case EQRECT:
            SetEquirectangular2( 0.0,
                                 pfnUnpackAnglesFn(padfPrjParams[4]),
                                 pfnUnpackAnglesFn(padfPrjParams[5]),
                                 padfPrjParams[6], padfPrjParams[7] );
            break;

        case MILLER:
            SetMC( pfnUnpackAnglesFn(padfPrjParams[5]),
                   pfnUnpackAnglesFn(padfPrjParams[4]),
                   padfPrjParams[6], padfPrjParams[7] );
            break;

        case VGRINT:
            SetVDG( pfnUnpackAnglesFn(padfPrjParams[4]),
                    padfPrjParams[6], padfPrjParams[7] );
            break;

        case HOM:
            if ( padfPrjParams[12] )
            {
                SetHOM( pfnUnpackAnglesFn(padfPrjParams[5]),
                        pfnUnpackAnglesFn(padfPrjParams[4]),
                        pfnUnpackAnglesFn(padfPrjParams[3]),
                        0.0, padfPrjParams[2],
                        padfPrjParams[6],  padfPrjParams[7] );
            }
            else
            {
                SetHOM2PNO( pfnUnpackAnglesFn(padfPrjParams[5]),
                            pfnUnpackAnglesFn(padfPrjParams[9]),
                            pfnUnpackAnglesFn(padfPrjParams[8]),
                            pfnUnpackAnglesFn(padfPrjParams[11]),
                            pfnUnpackAnglesFn(padfPrjParams[10]),
                            padfPrjParams[2],
                            padfPrjParams[6],  padfPrjParams[7] );
            }
            break;

        case ROBIN:
            SetRobinson( pfnUnpackAnglesFn(padfPrjParams[4]),
                         padfPrjParams[6], padfPrjParams[7] );
            break;

        // FIXME: SOM --- Space Oblique Mercator skipped

        // FIXME: ALASKA --- Alaska Conformal skipped

        // FIXME: GOODE --- Interrupted Goode skipped

        case MOLL:
            SetMollweide( pfnUnpackAnglesFn(padfPrjParams[4]),
                          padfPrjParams[6], padfPrjParams[7] );
            break;

        // FIXME: IMOLL --- Interrupted Mollweide skipped

        // FIXME: HAMMER --- Hammer skipped

        case WAGIV:
            SetWagner( 4, 0.0, padfPrjParams[6], padfPrjParams[7] );
            break;

        case WAGVII:
            SetWagner( 7, 0.0, padfPrjParams[6], padfPrjParams[7] );
            break;

        // FIXME: OBEQA --- Oblated Equal Area skipped

        // FIXME: ISINUS1 --- Integerized Sinusoidal Grid (the same as 99) skipped
        
        // FIXME: CEA --- Cylindrical Equal Area skipped (Grid corners set in meters for EASE grid)

        // FIXME: BCEA --- Cylindrical Equal Area skipped (Grid corners set in DMS degs for EASE grid)

        // FIXME: ISINUS --- Integrized Sinusoidal skipped

        default:
            CPLDebug( "OSR_USGS", "Unsupported projection: %ld", iProjSys );
            SetLocalCS( CPLString().Printf("GCTP projection number %ld", iProjSys) );
            break;
            
    }

/* -------------------------------------------------------------------- */
/*      Try to translate the datum/spheroid.                            */
/* -------------------------------------------------------------------- */

    if ( !IsLocal() )
    {
        char    *pszName = NULL;
        double  dfSemiMajor, dfInvFlattening;

        if ( iDatum < 0  ) // Use specified ellipsoid parameters
        {
            if ( padfPrjParams[0] > 0.0 )
            {
                if ( padfPrjParams[1] > 1.0 )
                {
                    if( ABS(padfPrjParams[0] - padfPrjParams[1]) < 0.01 )
                        dfInvFlattening = 0.0;
                    else
                    {
                        dfInvFlattening = padfPrjParams[0]
                            / ( padfPrjParams[0] - padfPrjParams[1] );
                    }
                }
                else if ( padfPrjParams[1] > 0.0 )
                {
                    dfInvFlattening =
                        1.0 / ( 1.0 - sqrt(1.0 - padfPrjParams[1]) );
                }
                else
                    dfInvFlattening = 0.0;

                SetGeogCS( "Unknown datum based upon the custom spheroid",
                           "Not specified (based on custom spheroid)",
                           "Custom spheroid", padfPrjParams[0], dfInvFlattening,
                           NULL, 0, NULL, 0 );
            }
            else if ( padfPrjParams[1] > 0.0 )  // Clarke 1866
            {
                if ( OSRGetEllipsoidInfo( 7008, &pszName, &dfSemiMajor,
                                          &dfInvFlattening ) == OGRERR_NONE )
                {
                    SetGeogCS( CPLString().Printf(
                                    "Unknown datum based upon the %s ellipsoid",
                                    pszName ),
                               CPLString().Printf( 
                                    "Not specified (based on %s spheroid)",
                                    pszName ),
                               pszName, dfSemiMajor, dfInvFlattening,
                               NULL, 0.0, NULL, 0.0 );
                    SetAuthority( "SPHEROID", "EPSG", 7008 );
                }
            }
            else                              // Sphere, rad 6370997 m
            {
                if ( OSRGetEllipsoidInfo( 7047, &pszName, &dfSemiMajor,
                                     &dfInvFlattening ) == OGRERR_NONE )
                {
                    SetGeogCS( CPLString().Printf(
                                    "Unknown datum based upon the %s ellipsoid",
                                    pszName ),
                               CPLString().Printf(
                                    "Not specified (based on %s spheroid)",
                                    pszName ),
                               pszName, dfSemiMajor, dfInvFlattening,
                               NULL, 0.0, NULL, 0.0 );
                    SetAuthority( "SPHEROID", "EPSG", 7047 );
                }
            }

        }
        else if ( iDatum < NUMBER_OF_ELLIPSOIDS && aoEllips[iDatum] )
        {
            if( OSRGetEllipsoidInfo( aoEllips[iDatum], &pszName,
                                     &dfSemiMajor, &dfInvFlattening ) == OGRERR_NONE )
            {
                SetGeogCS( CPLString().Printf("Unknown datum based upon the %s ellipsoid",
                                              pszName ),
                           CPLString().Printf( "Not specified (based on %s spheroid)",
                                               pszName ),
                           pszName, dfSemiMajor, dfInvFlattening,
                           NULL, 0.0, NULL, 0.0 );
                SetAuthority( "SPHEROID", "EPSG", aoEllips[iDatum] );
            }
            else
            {
                CPLError( CE_Warning, CPLE_AppDefined,
                          "Failed to lookup datum code %d, likely due to missing GDAL gcs.csv\n"
                          " file.  Falling back to use WGS84.", 
                          (int) iDatum );
                SetWellKnownGeogCS("WGS84" );
            }
        }
        else
        {
            CPLError( CE_Warning, CPLE_AppDefined,
                      "Wrong datum code %d. Supported datums 0--%d only.\n"
                      "Setting WGS84 as a fallback.",
                      (int) iDatum, NUMBER_OF_ELLIPSOIDS );
            SetWellKnownGeogCS( "WGS84" );
        }

        if ( pszName )
            CPLFree( pszName );
    }

/* -------------------------------------------------------------------- */
/*      Grid units translation                                          */
/* -------------------------------------------------------------------- */
    if( IsLocal() || IsProjected() )
        SetLinearUnits( SRS_UL_METER, 1.0 );

    FixupOrdering();

    return OGRERR_NONE;
}
Ejemplo n.º 7
0
OGRErr OGRSpatialReference::importFromPanorama( long iProjSys, long iDatum,
                                                long iEllips,
                                                double *padfPrjParams )

{
    Clear();

/* -------------------------------------------------------------------- */
/*      Use safe defaults if projection parameters are not supplied.    */
/* -------------------------------------------------------------------- */
    int     bProjAllocated = FALSE;

    if( padfPrjParams == NULL )
    {
        int     i;

        padfPrjParams = (double *)CPLMalloc( 8 * sizeof(double) );
        if ( !padfPrjParams )
            return OGRERR_NOT_ENOUGH_MEMORY;
        for ( i = 0; i < 7; i++ )
            padfPrjParams[i] = 0.0;
        bProjAllocated = TRUE;
    }

/* -------------------------------------------------------------------- */
/*      Operate on the basis of the projection code.                    */
/* -------------------------------------------------------------------- */
    switch ( iProjSys )
    {
        case PAN_PROJ_NONE:
            break;

        case PAN_PROJ_UTM:
            {
                long nZone;

                if ( padfPrjParams[7] == 0.0 )
                    nZone = (long)TO_ZONE(padfPrjParams[3]);
                else
                    nZone = (long) padfPrjParams[7];

                // XXX: no way to determine south hemisphere. Always assume
                // nothern hemisphere.
                SetUTM( nZone, TRUE );
            }
            break;

        case PAN_PROJ_WAG1:
            SetWagner( 1, 0.0,
                       padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_MERCAT:
            SetMercator( TO_DEGREES * padfPrjParams[0],
                         TO_DEGREES * padfPrjParams[3],
                         padfPrjParams[4],
                         padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_PS:
            SetPS( TO_DEGREES * padfPrjParams[2],
                   TO_DEGREES * padfPrjParams[3],
                   padfPrjParams[4],
                   padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_POLYC:
            SetPolyconic( TO_DEGREES * padfPrjParams[2],
                          TO_DEGREES * padfPrjParams[3],
                          padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_EC:
            SetEC( TO_DEGREES * padfPrjParams[0],
                   TO_DEGREES * padfPrjParams[1],
                   TO_DEGREES * padfPrjParams[2],
                   TO_DEGREES * padfPrjParams[3],
                   padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_LCC:
            SetLCC( TO_DEGREES * padfPrjParams[0],
                    TO_DEGREES * padfPrjParams[1],
                    TO_DEGREES * padfPrjParams[2],
                    TO_DEGREES * padfPrjParams[3],
                    padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_TM:
            {
                // XXX: we need zone number to compute false easting
                // parameter, because usually it is not contained in the
                // "Panorama" projection definition.
                // FIXME: what to do with negative values?
                long    nZone;
                double  dfCenterLong;

                if ( padfPrjParams[7] == 0.0 )
                {
                    nZone = (long)TO_ZONE(padfPrjParams[3]);
                    dfCenterLong = TO_DEGREES * padfPrjParams[3];
                }
                else
                {
                    nZone = (long) padfPrjParams[7];
                    dfCenterLong = 6 * nZone - 3;
                }

                padfPrjParams[5] = nZone * 1000000.0 + 500000.0;
                padfPrjParams[4] = 1.0;
                SetTM( TO_DEGREES * padfPrjParams[2],
                       dfCenterLong,
                       padfPrjParams[4],
                       padfPrjParams[5], padfPrjParams[6] );
            }
            break;

        case PAN_PROJ_STEREO:
            SetStereographic( TO_DEGREES * padfPrjParams[2],
                              TO_DEGREES * padfPrjParams[3],
                              padfPrjParams[4],
                              padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_AE:
            SetAE( TO_DEGREES * padfPrjParams[0],
                   TO_DEGREES * padfPrjParams[3],
                   padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_GNOMON:
            SetGnomonic( TO_DEGREES * padfPrjParams[2],
                         TO_DEGREES * padfPrjParams[3],
                         padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_MOLL:
            SetMollweide( TO_DEGREES * padfPrjParams[3],
                          padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_LAEA:
            SetLAEA( TO_DEGREES * padfPrjParams[0],
                     TO_DEGREES * padfPrjParams[3],
                     padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_EQC:
            SetEquirectangular( TO_DEGREES * padfPrjParams[0],
                                TO_DEGREES * padfPrjParams[3],
                                padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_CEA:
            SetCEA( TO_DEGREES * padfPrjParams[0],
                    TO_DEGREES * padfPrjParams[3],
                    padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_IMWP:
            SetIWMPolyconic( TO_DEGREES * padfPrjParams[0],
                             TO_DEGREES * padfPrjParams[1],
                             TO_DEGREES * padfPrjParams[3],
                             padfPrjParams[5], padfPrjParams[6] );
            break;

        case PAN_PROJ_MILLER:
            SetMC(TO_DEGREES * padfPrjParams[5],
                TO_DEGREES * padfPrjParams[4],
                padfPrjParams[6], padfPrjParams[7]);
            break;

        default:
            CPLDebug( "OSR_Panorama", "Unsupported projection: %ld", iProjSys );
            SetLocalCS( CPLString().Printf("\"Panorama\" projection number %ld",
                                   iProjSys) );
            break;

    }

/* -------------------------------------------------------------------- */
/*      Try to translate the datum/spheroid.                            */
/* -------------------------------------------------------------------- */

    if ( !IsLocal() )
    {
        if ( iDatum > 0 && iDatum < NUMBER_OF_DATUMS && aoDatums[iDatum] )
        {
            OGRSpatialReference oGCS;
            oGCS.importFromEPSG( aoDatums[iDatum] );
            CopyGeogCSFrom( &oGCS );
        }

        else if ( iEllips > 0
                  && iEllips < (long)NUMBER_OF_ELLIPSOIDS
                  && aoEllips[iEllips] )
        {
            char    *pszName = NULL;
            double  dfSemiMajor, dfInvFlattening;

            if ( OSRGetEllipsoidInfo( aoEllips[iEllips], &pszName,
                            &dfSemiMajor, &dfInvFlattening ) == OGRERR_NONE )
            {
                SetGeogCS( CPLString().Printf(
                            "Unknown datum based upon the %s ellipsoid",
                            pszName ),
                           CPLString().Printf(
                            "Not specified (based on %s spheroid)", pszName ),
                           pszName, dfSemiMajor, dfInvFlattening,
                           NULL, 0.0, NULL, 0.0 );
                SetAuthority( "SPHEROID", "EPSG", aoEllips[iEllips] );
            }
            else
            {
                CPLError( CE_Warning, CPLE_AppDefined,
                          "Failed to lookup ellipsoid code %ld, likely due to"
                          " missing GDAL gcs.csv\n"
                          " file.  Falling back to use Pulkovo 42.", iEllips );
                SetWellKnownGeogCS( "EPSG:4284" );
            }

            if ( pszName )
                CPLFree( pszName );
        }

        else
        {
            CPLError( CE_Warning, CPLE_AppDefined,
                      "Wrong datum code %ld. Supported datums are 1--%ld only.\n"
                      "Falling back to use Pulkovo 42.",
                      iDatum, NUMBER_OF_DATUMS - 1 );
            SetWellKnownGeogCS( "EPSG:4284" );
        }
    }

/* -------------------------------------------------------------------- */
/*      Grid units translation                                          */
/* -------------------------------------------------------------------- */
    if( IsLocal() || IsProjected() )
        SetLinearUnits( SRS_UL_METER, 1.0 );

    FixupOrdering();

    if ( bProjAllocated && padfPrjParams )
        CPLFree( padfPrjParams );

    return OGRERR_NONE;
}
Ejemplo n.º 8
0
void skiplightreweightdraw()
{
	float beta  = 0.045;//110/50 = 0.28;//FEXGSP = 0.4
	float gamma = 1.182;//110/50 = 1.24;//FEXGSP = 0.4

	auto f= new TFile("skiplightreweight.root");
	auto h12all = (TH1F *)f->Get("h12all");
	auto h12fcr = (TH1F *)f->Get("h12fcr");
	auto h12fex = (TH1F *)f->Get("h12fex");
	auto h12gsp = (TH1F *)f->Get("h12gsp");
	auto hSLall = (TH1F *)f->Get("hSLall");
	auto hSLfcr = (TH1F *)f->Get("hSLfcr");
	auto hSLfex = (TH1F *)f->Get("hSLfex");
	auto hSLgsp = (TH1F *)f->Get("hSLgsp");
	auto h12data = (TH1F *)f->Get("h12data");
	auto hSLdata = (TH1F *)f->Get("hSLdata");

	auto h12dphiall = (TH1F *)f->Get("h12dphiall");
	auto h12dphifcr = (TH1F *)f->Get("h12dphifcr");
	auto h12dphifex = (TH1F *)f->Get("h12dphifex");
	auto h12dphigsp = (TH1F *)f->Get("h12dphigsp");
	auto hSLdphiall = (TH1F *)f->Get("hSLdphiall");
	auto hSLdphifcr = (TH1F *)f->Get("hSLdphifcr");
	auto hSLdphifex = (TH1F *)f->Get("hSLdphifex");
	auto hSLdphigsp = (TH1F *)f->Get("hSLdphigsp");
	auto h12dphidata = (TH1F *)f->Get("h12dphidata");
	auto hSLdphidata = (TH1F *)f->Get("hSLdphidata");

	auto h12dphiNSall = (TH1F *)f->Get("h12dphiNSall");
	auto h12dphiNSfcr = (TH1F *)f->Get("h12dphiNSfcr");
	auto h12dphiNSfex = (TH1F *)f->Get("h12dphiNSfex");
	auto h12dphiNSgsp = (TH1F *)f->Get("h12dphiNSgsp");
	auto hSLdphiNSall = (TH1F *)f->Get("hSLdphiNSall");
	auto hSLdphiNSfcr = (TH1F *)f->Get("hSLdphiNSfcr");
	auto hSLdphiNSfex = (TH1F *)f->Get("hSLdphiNSfex");
	auto hSLdphiNSgsp = (TH1F *)f->Get("hSLdphiNSgsp");
	auto h12dphiNSdata = (TH1F *)f->Get("h12dphiNSdata");
	auto hSLdphiNSdata = (TH1F *)f->Get("hSLdphiNSdata");


	auto h12ordall = (TH1F *)f->Get("h12ordall");
	auto h12ordfcr = (TH1F *)f->Get("h12ordfcr");
	auto h12ordfex = (TH1F *)f->Get("h12ordfex");
	auto h12ordgsp = (TH1F *)f->Get("h12ordgsp");
	auto hSLordall = (TH1F *)f->Get("hSLordall");
	auto hSLordfcr = (TH1F *)f->Get("hSLordfcr");
	auto hSLordfex = (TH1F *)f->Get("hSLordfex");
	auto hSLordgsp = (TH1F *)f->Get("hSLordgsp");
	auto h12orddata = (TH1F *)f->Get("h12orddata");
	auto hSLorddata = (TH1F *)f->Get("hSLorddata");


	auto h12reweighted = (TH1F *)h12all->Clone("h12reweighted");
	auto hSLreweighted = (TH1F *)hSLall->Clone("hSLreweighted");
	h12reweighted->Reset();h12reweighted->SetTitle("h12reweighted");
	hSLreweighted->Reset();hSLreweighted->SetTitle("hSLreweighted");

	auto h12dphiNSreweighted = (TH1F *)h12dphiNSall->Clone("h12dphiNSreweighted");
	auto hSLdphiNSreweighted = (TH1F *)hSLdphiNSall->Clone("hSLdphiNSreweighted");
	h12dphiNSreweighted->Reset();h12dphiNSreweighted->SetTitle("h12dphiNSreweighted");
	hSLdphiNSreweighted->Reset();hSLdphiNSreweighted->SetTitle("hSLdphiNSreweighted");

	auto h12dphireweighted = (TH1F *)h12dphiall->Clone("h12dphireweighted");
	auto hSLdphireweighted = (TH1F *)hSLdphiall->Clone("hSLdphireweighted");
	h12dphireweighted->Reset();h12dphireweighted->SetTitle("h12dphireweighted");
	hSLdphireweighted->Reset();hSLdphireweighted->SetTitle("hSLdphireweighted");

	auto h12ordreweighted = (TH1F *)h12ordall->Clone("h12ordreweighted");
	auto hSLordreweighted = (TH1F *)hSLordall->Clone("hSLordreweighted");
	h12ordreweighted->Reset();h12ordreweighted->SetTitle("h12ordreweighted");
	hSLordreweighted->Reset();hSLordreweighted->SetTitle("hSLordreweighted");


	h12reweighted->Add(h12fex,h12gsp,beta,gamma);
	h12reweighted->Add(h12fcr);

	hSLreweighted->Add(hSLfex,hSLgsp,beta,gamma);
	hSLreweighted->Add(hSLfcr);

	h12dphireweighted->Add(h12dphifex,h12dphigsp,beta,gamma);
	h12dphireweighted->Add(h12dphifcr);

	hSLdphireweighted->Add(hSLdphifex,hSLdphigsp,beta,gamma);
	hSLdphireweighted->Add(hSLdphifcr);

	h12dphiNSreweighted->Add(h12dphiNSfex,h12dphiNSgsp,beta,gamma);
	h12dphiNSreweighted->Add(h12dphiNSfcr);

	hSLdphiNSreweighted->Add(hSLdphiNSfex,hSLdphiNSgsp,beta,gamma);
	hSLdphiNSreweighted->Add(hSLdphiNSfcr);

	h12ordreweighted->Add(h12ordfex,h12ordgsp,beta,gamma);
	h12ordreweighted->Add(h12ordfcr);

	hSLordreweighted->Add(hSLordfex,hSLordgsp,beta,gamma);
	hSLordreweighted->Add(hSLordfcr);



	Normalize({h12data,h12all,hSLdata,hSLall,
			h12dphiall,hSLdphiall,h12dphidata,hSLdphidata,
			h12dphiNSall,hSLdphiNSall,h12dphiNSdata,hSLdphiNSdata,
			h12ordall,hSLordall,h12orddata,hSLorddata});
	SetMC({h12all,hSLall,h12dphiall,hSLdphiall});

	ploteffectiveentries = false;
	plotymax = 0.12;
	plotylog = false;
	plotputmean = true;
	aktstring+="PF Jets R=0.4";
  	plotsecondline = "p_{T,1}>120GeV,p_{T,2}>30GeV";
  	plotthirdline  = "#Delta#phi>2#pi/3, CSV>0.9";
  	
  	
  	plotfilenameend = "12";
  	DrawCompare(h12data,h12all);
	plotfilenameend = "SL";
  	DrawCompare(hSLdata,hSLall);

	Normalize({h12reweighted,hSLreweighted});
	SetMC({h12reweighted,hSLreweighted});

	plotfilenameend = "12";
	DrawCompare(h12data,h12reweighted);
	plotfilenameend = "SL";
	DrawCompare(hSLdata,hSLreweighted);

	plotfilenameend = "";

	// vector<int> colors = {TColor::GetColor("#FA7200"),
	// 					  TColor::GetColor("#9ACD32"),
	// 					  TColor::GetColor("#0D98BA")};//{kGreen-9, kOrange+1,kBlue+3};

	vector<int> colors = {TColor::GetColor(25,87,5),//18,58,5),
						  TColor::GetColor(255,109,24),//234,117,1),//255,117,24),
						  TColor::GetColor(77,135,232)};//{kGreen-9, kOrange+1,kBlue+3};


	auto h12stack = stackhists({h12fcr,h12fex,h12gsp},colors,"h12stack","(P)");
	DrawCompare(h12data,h12stack,"x_{J}");


	h12fex->Scale(beta); h12gsp->Scale(gamma);
	auto h12stack2 = stackhists({h12fcr,h12fex,h12gsp},colors,"h12stack2","(W)");
	DrawCompare(h12data,h12stack2,"x_{J}");


	auto hSLstack = stackhists({hSLfcr,hSLfex,hSLgsp},colors,"hSLstack","(P)");
	DrawCompare(hSLdata,hSLstack,"x_{J}");


	hSLfex->Scale(beta); hSLgsp->Scale(gamma);
	auto hSLstack2 = stackhists({hSLfcr,hSLfex,hSLgsp},colors,"hSLstack2","(W)");
	DrawCompare(hSLdata,hSLstack2,"x_{J}");





	plotputmean = false;
	plotylog = false;
	plotymax = 1.1;
	plotymin = 1E-5;


	Normalize({hSLordreweighted,h12ordreweighted});
	SetMC({hSLordreweighted,h12ordreweighted});

	DrawCompare(h12orddata,h12ordreweighted);
	DrawCompare(hSLorddata,hSLordreweighted);

	auto h12ordstack = stackhists({h12ordfcr,h12ordfex,h12ordgsp},colors,"h12ordstack","(P)");
	DrawCompare(h12orddata,h12ordstack,"skiplight order");


	h12ordfex->Scale(beta); h12ordgsp->Scale(gamma);
	auto h12ordstack2 = stackhists({h12ordfcr,h12ordfex,h12ordgsp},colors,"h12ordstack2","(W)");
	DrawCompare(h12orddata,h12ordstack2,"skiplight order");


	auto hSLordstack = stackhists({hSLordfcr,hSLordfex,hSLordgsp},colors,"hSLordstack","(P)");
	DrawCompare(hSLorddata,hSLordstack,"skiplight order");


	hSLordfex->Scale(beta); hSLordgsp->Scale(gamma);
	auto hSLordstack2 = stackhists({hSLordfcr,hSLordfex,hSLordgsp},colors,"hSLordstack2","(W)");
	DrawCompare(hSLorddata,hSLordstack2,"skiplight order");






	plotylog = true;
	plotymin = 9999;
	plotputmean = false;
	plotputwidth = true;
	plotymax = 0.5;
	plotthirdline  = "CSV>0.9";

	DrawCompare(h12dphidata,h12dphiall,"#Delta#phi");
	DrawCompare(hSLdphidata,hSLdphiall,"#Delta#phi");


	Normalize({hSLdphireweighted,h12dphireweighted});
	SetMC({hSLdphireweighted,h12dphireweighted});

	DrawCompare(h12dphidata,h12dphireweighted,"#Delta#phi");
	DrawCompare(hSLdphidata,hSLdphireweighted,"#Delta#phi");

	//plotymax = 0.5;

	auto h12dphistack = stackhists({h12dphifcr,h12dphifex,h12dphigsp},colors,"h12dphistack","(P)");
	DrawCompare(h12dphidata,h12dphistack,"#Delta#phi");

	h12dphifex->Scale(beta); h12dphigsp->Scale(gamma);
	auto h12dphistack2 = stackhists({h12dphifcr,h12dphifex,h12dphigsp},colors,"h12dphistack2","(W)");
	DrawCompare(h12dphidata,h12dphistack2,"#Delta#phi");


	auto hSLdphistack = stackhists({hSLdphifcr,hSLdphifex,hSLdphigsp},colors,"hSLdphistack","(P)");
	DrawCompare(hSLdphidata,hSLdphistack,"#Delta#phi");

	hSLdphifex->Scale(beta); hSLdphigsp->Scale(gamma);
	auto hSLdphistack2 = stackhists({hSLdphifcr,hSLdphifex,hSLdphigsp},colors,"hSLdphistack2","(W)");
	DrawCompare(hSLdphidata,hSLdphistack2,"#Delta#phi");



	plotylog = false;
	plotymax = 0.25;
//only interesting dphi region
	DrawCompare(h12dphiNSdata,h12dphiNSall);
	DrawCompare(hSLdphiNSdata,hSLdphiNSall);


	Normalize({hSLdphiNSreweighted,h12dphiNSreweighted});
	SetMC({hSLdphiNSreweighted,h12dphiNSreweighted});

	DrawCompare(h12dphiNSdata,h12dphiNSreweighted);
	DrawCompare(hSLdphiNSdata,hSLdphiNSreweighted);



	auto h12dphiNSstack = stackhists({h12dphiNSfcr,h12dphiNSfex,h12dphiNSgsp},colors,"h12dphiNSstack","(P)");
	DrawCompare(h12dphiNSdata,h12dphiNSstack,"#Delta#phi");

	h12dphiNSfex->Scale(beta); h12dphiNSgsp->Scale(gamma);
	auto h12dphiNSstack2 = stackhists({h12dphiNSfcr,h12dphiNSfex,h12dphiNSgsp},colors,"h12dphiNSstack2","(W)");
	DrawCompare(h12dphiNSdata,h12dphiNSstack2,"#Delta#phi");


	auto hSLdphiNSstack = stackhists({hSLdphiNSfcr,hSLdphiNSfex,hSLdphiNSgsp},colors,"hSLdphiNSstack","(P)");
	DrawCompare(hSLdphiNSdata,hSLdphiNSstack,"#Delta#phi");

	hSLdphiNSfex->Scale(beta); hSLdphiNSgsp->Scale(gamma);
	auto hSLdphiNSstack2 = stackhists({hSLdphiNSfcr,hSLdphiNSfex,hSLdphiNSgsp},colors,"hSLdphiNSstack2","(W)");
	DrawCompare(hSLdphiNSdata,hSLdphiNSstack2,"#Delta#phi");



// 	int nearsidebin1 = 1;
// 	int nearsidebin2 = hSLdphifex->GetNbinsX()/3;

// 	int awaysidebin1 = hSLdphifex->GetNbinsX()/3*2;
// 	int awaysidebin2 = hSLdphifex->GetNbinsX()-1;

// 	float NnsFEX  = hSLdphifex->Integral(nearsidebin1,nearsidebin2);
// 	float NnsGSP  = hSLdphigsp->Integral(nearsidebin1,nearsidebin2);
// 	float NasFEX  = hSLdphifex->Integral(awaysidebin1,awaysidebin2);
// 	float NasGSP  = hSLdphigsp->Integral(awaysidebin1,awaysidebin2);

// 	float NnsData = hSLdphidata->Integral(nearsidebin1,nearsidebin2);
// 	float NasData = hSLdphidata->Integral(awaysidebin1,awaysidebin2);

// 	float alpha = (NnsData - NnsGSP*(1+NasFEX/NasGSP))/(NnsFEX - NnsGSP*NasFEX/NasGSP); 
// 	float beta2 = ((1-alpha)*NasFEX+NasGSP)/NasGSP;

// if (alpha<0) alpha =0;

// 	cout<<"!!!"<<alpha<<" "<<beta2<<endl;



// 	hSLdphifex->Scale(alpha); hSLdphigsp->Scale(beta2);
// 	auto hSLdphistack2_new = stackhists({hSLdphifcr,hSLdphifex,hSLdphigsp},colors,"hSLdphistack2_new");
// 	DrawCompare(hSLdphidata,hSLdphistack2_new,"#Delta#phi");


// 	cout<<" NasFEX+NasGSP = "<<NasFEX+NasGSP<<" ?= "<<
// 		hSLdphifex->Integral(awaysidebin1,awaysidebin2)+hSLdphigsp->Integral(awaysidebin1,awaysidebin2)<<endl;


// 	ploteffectiveentries = false;
// 	plotymax = 0.12;
// 	plotylog = false;
// 	plotputmean = true;
// 	aktstring+="PF Jets R=0.4";
//   	plotsecondline = "p_{T,1}>120GeV,p_{T,2}>30GeV";
//   	plotthirdline  = "#Delta#phi>2#pi/3, CSV>0.9";






// 	auto h12reweightedtwice = (TH1F *)h12all->Clone("h12reweightedtwice");
// 	auto hSLreweightedtwice = (TH1F *)hSLall->Clone("hSLreweightedtwice");
// 	h12reweightedtwice->Reset();h12reweightedtwice->SetTitle("h12reweightedtwice");
// 	hSLreweightedtwice->Reset();hSLreweightedtwice->SetTitle("hSLreweightedtwice");

// 	h12reweightedtwice->Add(h12fex,h12gsp,alpha,beta2);
// 	h12reweightedtwice->Add(h12fcr);
// 	cout<<"h12reweightedtwice "<<h12reweightedtwice->GetMean()<<endl;

// 	hSLreweightedtwice->Add(hSLfex,hSLgsp,alpha,beta2);
// 	hSLreweightedtwice->Add(hSLfcr);
// 	cout<<"hSLreweightedtwice "<<hSLreweightedtwice->GetMean()<<endl;

// 	Normalize({h12reweightedtwice,hSLreweightedtwice});
// 	SetMC({h12reweightedtwice,hSLreweightedtwice});

// 	plotfilenameend = "12";
// 	DrawCompare(h12data,h12reweightedtwice);
// 	plotfilenameend = "SL";
// 	DrawCompare(hSLdata,hSLreweightedtwice);
// 	plotfilenameend="";



// 	hSLfex->Scale(alpha); hSLgsp->Scale(beta2);
// 	auto hSLstack2_new = stackhists({hSLfcr,hSLfex,hSLgsp},colors,"hSLstack2_new");
// 	DrawCompare(hSLdata,hSLstack2_new,"x_{J}");

// 	h12fex->Scale(alpha); h12gsp->Scale(beta2);
// 	auto h12stack2_new = stackhists({h12fcr,h12fex,h12gsp},colors,"h12stack2_new");
// 	DrawCompare(h12data,h12stack2_new,"x_{J}","___");






}
Ejemplo n.º 9
0
void checkdatadj(TString datafilename, TString djfilename)
{
  TFile *f = new TFile(datafilename);
  auto nt = (TTree *)f->Get("nt");
  auto hjtpt1 = new TH1F("data_jtpt1","data_jtpt1",ptbins,ptmin,ptmax);
  nt->Project(hjtpt1->GetName(),"jtpt1","weight");
  auto hjtpt2 = new TH1F("data_jtpt2","data_jtpt2",ptbins,0,200);
  nt->Project(hjtpt2->GetName(),"jtpt2","weight*(dijet && jtpt1>120 && jtpt2>30 && acos(cos(jtphi1-jtphi2))>2./3*3.14)");
  auto hdataaj = new TH1F("data_aj","data_aj",20,0,1);
  nt->Project(hdataaj->GetName(),"abs(jtpt1-jtpt2)/(jtpt1+jtpt2)",
              "weight*(dijet && jtpt1>120 && jtpt2>30 && acos(cos(jtphi1-jtphi2))>2./3*3.14)");
  auto hdatabtgaj = new TH1F("data_btgaj","data_btgaj",20,0,1);
  nt->Project(hdatabtgaj->GetName(),"abs(jtpt1-jtpt2)/(jtpt1+jtpt2)",
	      "weight*(dijet && jtpt1>120 && jtpt2>30 && acos(cos(jtphi1-jtphi2))>2./3*3.14 && discr_csvSimple1>0.9 && discr_csvSimple2>0.9)");

  auto hdataxj = new TH1F("data_xj","data_xj",20,0,1);
  nt->Project(hdataxj->GetName(),"jtpt2/jtpt1",
              "weight*(dijet && jtpt1>120 && jtpt2>30 && acos(cos(jtphi1-jtphi2))>2./3*3.14)");
  auto hdatadphi = new TH1F("data_dphi","data_dphi",20,0,3.142);
  nt->Project(hdatadphi->GetName(),"acos(cos(jtphi1-jtphi2))",
              "weight*(dijet && jtpt1>120 && jtpt2>30)");
  auto hdatadphi2 = new TH1F("data_dphi2","data_dphi2",20,2,3.142);
  nt->Project(hdatadphi2->GetName(),"acos(cos(jtphi1-jtphi2))",
              "weight*(dijet && jtpt1>120 && jtpt2>30)");
  auto hdatabtgdphi = new TH1F("data_btgdphi","data_btgdphi",20,0,3.142);
  nt->Project(hdatabtgdphi->GetName(),"acos(cos(jtphi1-jtphi2))",
              "weight*(dijet && jtpt1>120 && jtpt2>30 && discr_csvSimple1>0.9 && discr_csvSimple2>0.9)");


  SetData({hjtpt1,hjtpt2,hdataaj,hdatabtgaj,hdataxj,hdatadphi,hdatadphi2,hdatabtgdphi});
  SetB({hdatabtgaj,hdatabtgdphi});


  fout->cd();
  hjtpt1->Write();
  hjtpt2->Write();
  hdataaj->Write();
  hdataxj->Write();
  hdatadphi->Write();
  hdatadphi2->Write();
  hdatabtgaj->Write();
  hdatabtgdphi->Write();
  f->Close();

  f = new TFile(djfilename);
  nt = (TTree *)f->Get("nt");
  auto hdjjtpt1 = new TH1F("dj_jtpt1","dj_jtpt1",ptbins,ptmin,ptmax);
  nt->Project(hdjjtpt1->GetName(),"jtpt1","weight");
  auto hmcjtpt2 = new TH1F("mc_jtpt2","mc_jtpt2",ptbins,0,200);
  nt->Project(hmcjtpt2->GetName(),"jtpt2","weight*(dijet && jtpt1>120 && jtpt2>30 && acos(cos(jtphi1-jtphi2))>2./3*3.14)");
  auto hmcaj = new TH1F("mc_aj","mc_aj",20,0,1);
  nt->Project(hmcaj->GetName(),"abs(jtpt1-jtpt2)/(jtpt1+jtpt2)",
              "weight*(dijet && jtpt1>120 && jtpt2>30 && acos(cos(jtphi1-jtphi2))>2./3*3.14)");
  auto hmcbtgaj = new TH1F("mc_btgaj","mc_btgaj",20,0,1);
  nt->Project(hmcbtgaj->GetName(),"abs(jtpt1-jtpt2)/(jtpt1+jtpt2)",
              "weight*(dijet && jtpt1>120 && jtpt2>30 && acos(cos(jtphi1-jtphi2))>2./3*3.14 && discr_csvSimple1>0.9 && discr_csvSimple2>0.9)");
  auto hmcxj = new TH1F("mc_xj","mc_xj",20,0,1);
  nt->Project(hmcxj->GetName(),"jtpt2/jtpt1",
              "weight*(dijet && jtpt1>120 && jtpt2>30 && acos(cos(jtphi1-jtphi2))>2./3*3.14)");
  auto hmcdphi = new TH1F("mc_dphi","mc_dphi",20,0,3.142);
  nt->Project(hmcdphi->GetName(),"acos(cos(jtphi1-jtphi2))",
              "weight*(dijet && jtpt1>120 && jtpt2>30)");
  auto hmcdphi2 = new TH1F("mc_dphi2","mc_dphi2",20,2,3.142);
  nt->Project(hmcdphi2->GetName(),"acos(cos(jtphi1-jtphi2))",
              "weight*(dijet && jtpt1>120 && jtpt2>30)");
  auto hmcbtgdphi = new TH1F("mc_btgdphi","mc_btgdphi",20,0,3.142);
  nt->Project(hmcbtgdphi->GetName(),"acos(cos(jtphi1-jtphi2))",
              "weight*(dijet && jtpt1>120 && jtpt2>30 && discr_csvSimple1>0.9 && discr_csvSimple2>0.9)");

  SetMC({hdjjtpt1,hmcjtpt2,hmcaj,hmcbtgaj,hmcxj,hmcdphi,hmcdphi2,hmcbtgdphi});
  SetInc({hdjjtpt1,hmcjtpt2,hmcaj,hmcxj,hmcdphi,hmcdphi2});
  SetB({hmcbtgaj,hmcbtgdphi});

  auto temp = new TH1F("temp","temp",10,0.5,1.5);
  nt->Project("temp","dijet","weight");
  int numberofdijets = temp->Integral();
  cout<<"# of dijets = "<<numberofdijets<<endl;
  //hmcaj->Scale(1./numberofdijets);
  //hmcxj->Scale(1./numberofdijets);
  //hmcdphi->Scale(1./numberofdijets);

  fout->cd();
  hdjjtpt1->Write();
  hmcjtpt2->Write();
  hmcaj->Write();
  hmcxj->Write();
  hmcdphi->Write();
  hmcdphi2->Write();
  hmcbtgaj->Write();
  hmcbtgdphi->Write();
  f->Close();

}
Ejemplo n.º 10
0
void findtruthpp()
{
  seth(10,0,1);
  auto hmcppxJTrue = geth("hmcppxJTrue","true;x_{J};Event fractions");
  auto hmcppxJTrueTag = geth("hmcppxJTrueTag","true tagged;x_{J};Event fractions");
  auto hmcppxJTrueTagCorr = geth("hmcppxJTrueTagCorr","true tagged corrected;x_{J};Event fractions");

  TFile *fmcpp = new TFile(config.getFileName_djt("mcppbfa"));
  Fill(fmcpp,[&] (dict &m) {
    if (m["pthat"]<pthatcut) return;
    if (m[pairCodeSB1]!=0) return;
    // if (m["pthat"]<80) return;
    
    // if (m["bProdCode"]!=1) return;
    float w = m["weight"]*processweight((int)m["bProdCode"]);

    // float w = m["weight"];
    // if (m["bProdCode"]==2) return;

    float corr = tageffcorrectionpp(m["jtpt1"],m["jteta1"],m[jtptSB],m[jtetaSB]);
    float wb = w*corr;

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23)
      hmcppxJTrue->Fill(m[jtptSB]/m["jtpt1"],w);

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23
        && m["discr_csvV1_1"]>0.9 && m[discr_csvV1_SB]>0.9) {
      hmcppxJTrueTag->Fill(m[jtptSB]/m["jtpt1"],w);
      hmcppxJTrueTagCorr->Fill(m[jtptSB]/m["jtpt1"],wb);
    }


  });

  NormalizeAllHists();
  plotputmean = true;
  plotytitle = "Event fractions";
  plotdivide = false;
  // aktstring += "R=0.4 |#eta|<2.0";
  // plotsecondline = Form("p_{T,1}>%d GeV, p_{T,2}>%d GeV", (int)pt1cut, (int)pt2cut);
  // plotthirdline = "#Delta#phi>2/3#pi";
  plottextposy = 0.8;
  plottextposx = 0.2;

  plotmeanposy = 0.43;
  plotymax = 0.2;
  plotymin = 0;
  plotlegendpos = BottomRight;//TopLeft;
  
  aktstring = "pp";
  SetMC({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});
  SetData({hmcppxJTrue});
  Draw({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});


  hmcppxJTrue->SetMinimum(0);
  hmcppxJTrue->SetMaximum(0.3);
  hmcppxJTrue->SetLineWidth(2);
  hmcppxJTrue->SetMarkerStyle(kNone);
  hmcppxJTrue->SetFillStyle(0);

  hmcppxJTrueTag->SetMarkerStyle(kOpenCircle);
  hmcppxJTrueTagCorr->SetMarkerStyle(kOpenSquare);


  plotymax = 0.3;

  SetB({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});


  float xjtrue = hmcppxJTrue->GetMean();
  float xjtruetag = hmcppxJTrueTag->GetMean();
  float xjtruetagcorr = hmcppxJTrueTagCorr->GetMean();

  float exjtrue = hmcppxJTrue->GetMeanError();
  float exjtruetag = hmcppxJTrueTag->GetMeanError();
  float exjtruetagcorr = hmcppxJTrueTagCorr->GetMeanError();

  auto c = getc();
  hmcppxJTrue->Draw("hist");
  hmcppxJTrueTag->Draw("E1,same");
  hmcppxJTrueTagCorr->Draw("E1,same");

  plotlegendpos = TopLeft;
  auto l = getLegend();
  l->AddEntry(hmcppxJTrue,Form("b-dijets, #LTx_{J}#GT=%.3f#pm%.3f",xjtrue,exjtrue),"L");
  l->AddEntry(hmcppxJTrueTag,Form("uncorrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetag,exjtruetag),"P");
  l->AddEntry(hmcppxJTrueTagCorr,Form("corrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetagcorr,exjtruetagcorr),"P");
  l->Draw();
  TLatex *Tl = new TLatex();
  Tl->DrawLatexNDC(0.2, 0.8, aktstring);
  SavePlot(c,"closurepp");
}
Ejemplo n.º 11
0
void findtruthPbPb(int binMin, int binMax)
{
  TFile *fmc = new TFile(config.getFileName_djt("mcPbbfa"));

  buildNamesuffix = TString::Format("_bin_%d_%d",binMin, binMax);
  //  buildTitlesuffix = TString::Format("%d-%d %%",binMin/2, binMax/2);

  seth(10,0,1);
  auto hmcPbPbxJTrue = geth("hmcPbPbxJTrue","PbPb true;x_{J};Event fractions");
  auto hmcPbPbxJTrueTag = geth("hmcPbPbxJTrueTag","PbPb true tagged;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorr = geth("hmcPbPbxJTrueTagCorr","PbPb true tagged corrected;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorrPt = geth("hmcPbPbxJTrueTagCorrPt","PbPb true tagged corrected pt;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorrEta = geth("hmcPbPbxJTrueTagCorrEta","PbPb true tagged corrected eta;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorrBin = geth("hmcPbPbxJTrueTagCorrBin","PbPb true tagged corrected bin;x_{J};Event fractions");

  seth(12,20,140);//10,40,100);
  auto hpt2true = geth("hpt2true","true;p_{T,2} GeV");
  auto hpt2truetag = geth("hpt2truetag","true tagged;p_{T,2} GeV");
  auto hpt2truetagovertrue = geth("hpt2truetagovertrue","true tagged/true;p_{T,2} GeV");
  auto hpt2truetagcorr = geth("hpt2truetagcorr","true tagged corrected;p_{T,2} GeV");
  auto hpt2truetagcorrovertrue = geth("hpt2truetagcorrovertrue","true tagged corrected/true;p_{T,2} GeV");

  seth(10,100,200);
  auto hpt1true = geth("hpt1true","true;p_{T,1} GeV");
  auto hpt1truetag = geth("hpt1truetag","true tagged;p_{T,1} GeV");
  auto hpt1truetagovertrue = geth("hpt1truetagovertrue","true tagged/true;p_{T,1} GeV");
  auto hpt1truetagcorr = geth("hpt1truetagcorr","true tagged corrected;p_{T,1} GeV");
  auto hpt1truetagcorrovertrue = geth("hpt1truetagcorrovertrue","true tagged corrected/true;p_{T,1} GeV");

  seth(10,0,200);
  auto hbintrue = geth("hbintrue","true;bin");
  auto hbintruetag = geth("hbintruetag","true tagged;bin");
  auto hbintruetagovertrue = geth("hbintruetagovertrue","true tagged/true;bin");
  auto hbintruetagcorr = geth("hbintruetagcorr","true tagged corrected;bin");
  auto hbintruetagcorrovertrue = geth("hbintruetagcorrovertrue","true tagged corrected/true;bin");

  seth(20,-2,2);
  auto heta2true = geth("heta2true","true;#eta_{2}");
  auto heta2truetag = geth("heta2truetag","true tagged;#eta_{2}");
  auto heta2truetagovertrue = geth("heta2truetagovertrue","true tagged/true;#eta_{2}");
  auto heta2truetagcorr = geth("heta2truetagcorr","true tagged corrected;#eta_{2}");
  auto heta2truetagcorrovertrue = geth("heta2truetagcorrovertrue","true tagged corrected/true;#eta_{2}");

  auto heta1true = geth("heta1true","true;#eta_{1}");
  auto heta1truetag = geth("heta1truetag","true tagged;#eta_{1}");
  auto heta1truetagovertrue = geth("heta1truetagovertrue","true tagged/true;#eta_{1}");
  auto heta1truetagcorr = geth("heta1truetagcorr","true tagged corrected;#eta_{1}");
  auto heta1truetagcorrovertrue = geth("heta1truetagcorrovertrue","true tagged corrected/true;#eta_{1}");

  unordered_set<int> eventstodiscard = {1805770,1116573,1084397};//,
                                        // 5755734,1599758,395810,
                                      // 1363321,211625,3195128};
//

  Fill(fmc,[&] (dict &m) {
    if (m["bin"]<binMin || m["bin"]>=binMax) return;
    if (m["pthat"]<pthatcut) return;
    if (m[pairCodeSB1]!=0) return;

    // if (m["bProdCode"]>1) return;

    if (eventstodiscard.find(m["event"])!=eventstodiscard.end()) return; //kill large-weight GSP event

    float w = m["weight"]*processweight((int)m["bProdCode"]); //because we have only b-dijets


    float corr = tageffcorrectionPbPb(m["jtpt1"],m["jteta1"],m[jtptSB],m[jtetaSB],m["bin"]);
    // float corrpt  = getPbPbcorrectionPt(m["jtpt1"],m[jtptSB]);
    // float correta = getPbPbcorrectionEta(m["jteta1"],m[jtetaSB]);
    // float corrbin = getPbPbcorrectionBin(m["bin"]);


    float wb = w*corr;



   if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[refptSB]>20 && m[dphiSB1]>PI23) {
      hmcPbPbxJTrue->Fill(m[jtptSB]/m["jtpt1"],w);
      hpt2true->Fill(m[jtptSB],w);
      hpt1true->Fill(m["jtpt1"],w);
      heta2true->Fill(m[jtetaSB],w);
      heta1true->Fill(m["jteta1"],w);
      hbintrue->Fill(m["bin"],w);
   }

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[refptSB]>20 && m[dphiSB1]>PI23
        && m["discr_csvV1_1"]>0.9 &&  m[discr_csvV1_SB]>0.9) { //

     //corrpt *= m[jtptSB] < 60 ? 1./0.7 : 1;
     //wb *= m[jtptSB] < 60 ? 1./0.7 : 1;

      hmcPbPbxJTrueTag->Fill(m[jtptSB]/m["jtpt1"],w);
      hmcPbPbxJTrueTagCorr->Fill(m[jtptSB]/m["jtpt1"],wb);
      // hmcPbPbxJTrueTagCorrPt->Fill(m[jtptSB]/m["jtpt1"],w*corrpt);
      // hmcPbPbxJTrueTagCorrEta->Fill(m[jtptSB]/m["jtpt1"],w*corrpt*correta);
      // hmcPbPbxJTrueTagCorrBin->Fill(m[jtptSB]/m["jtpt1"],w*corrpt*correta*corrbin);


      hpt2truetag->Fill(m[jtptSB],w);
      hpt1truetag->Fill(m["jtpt1"],w);
      heta2truetag->Fill(m[jtetaSB],w);
      heta1truetag->Fill(m["jteta1"],w);
      hbintruetag->Fill(m["bin"],w);

      hpt2truetagcorr->Fill(m[jtptSB],wb);
      hpt1truetagcorr->Fill(m["jtpt1"],wb);
      heta2truetagcorr->Fill(m[jtetaSB],wb);
      heta1truetagcorr->Fill(m["jteta1"],wb);
      hbintruetagcorr->Fill(m["bin"],wb);

    }






  });

  NormalizeAllHists();
//plotymax = 9999;
  aktstring = TString::Format("PbPb %d-%d %%",binMin/2, binMax/2);//TString::Format("PbPb#Delta#phi>2/3#pi %d-%d %%",binMin/2, binMax/2);

  SetMC({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr});
  SetData({hmcPbPbxJTrue});
  hmcPbPbxJTrue->SetMinimum(0);
  hmcPbPbxJTrue->SetMaximum(0.3);
  hmcPbPbxJTrue->SetLineWidth(2);
  hmcPbPbxJTrue->SetMarkerStyle(kNone);
  hmcPbPbxJTrue->SetFillStyle(0);

  hmcPbPbxJTrueTag->SetMarkerStyle(kOpenCircle);
  hmcPbPbxJTrueTagCorr->SetMarkerStyle(kOpenSquare);


  plotymax = 0.3;
  Draw({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr});

  SetB({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr});

  float xjtrue = hmcPbPbxJTrue->GetMean();
  float xjtruetag = hmcPbPbxJTrueTag->GetMean();
  float xjtruetagcorr = hmcPbPbxJTrueTagCorr->GetMean();

  float exjtrue = hmcPbPbxJTrue->GetMeanError();
  float exjtruetag = hmcPbPbxJTrueTag->GetMeanError();
  float exjtruetagcorr = hmcPbPbxJTrueTagCorr->GetMeanError();

  auto c = getc();
  hmcPbPbxJTrue->Draw("hist");
  hmcPbPbxJTrueTag->Draw("E1,same");
  hmcPbPbxJTrueTagCorr->Draw("E1,same");

  plotlegendpos = TopLeft;
  auto l = getLegend();
  l->AddEntry(hmcPbPbxJTrue,Form("b-dijets, #LTx_{J}#GT=%.3f#pm%.3f",xjtrue,exjtrue),"L");
  l->AddEntry(hmcPbPbxJTrueTag,Form("uncorrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetag,exjtruetag),"P");
  l->AddEntry(hmcPbPbxJTrueTagCorr,Form("corrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetagcorr,exjtruetagcorr),"P");
  l->Draw();
  TLatex *Tl = new TLatex();
  Tl->DrawLatexNDC(0.2, 0.8, aktstring);
  SavePlot(c,Form("closure%d%d",binMin,binMax));


    // //if (binMin==0 && binMax==200) {

    // Draw({hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorrPt,hmcPbPbxJTrueTagCorrEta,hmcPbPbxJTrueTagCorrBin});
 

    // SetMC({hpt2truetag,hpt1truetag,heta2truetag,heta1truetag,hbintruetag});

    // plotputmean = false;

    // plotymax = 0.2;

    // Draw({hpt2true,hpt2truetag,hpt2truetagcorr});

    // plotymax = 0.3;

    // Draw({hpt1true,hpt1truetag,hpt1truetagcorr});

    // plotymax = 0.2;
    // Draw({heta2true,heta2truetag,heta2truetagcorr});
    // Draw({heta1true,heta1truetag,heta1truetagcorr});

    // plotymax = 1;
    // Draw({hbintrue,hbintruetag,hbintruetagcorr});


plotymin = 0;
plotymax = 0.2;

Draw({hpt2truetag,hpt2true});
Draw({hpt2truetagcorr,hpt2true});
hpt2truetagovertrue->Divide(hpt2truetag,hpt2true,1,1); //"B"
hpt1truetagovertrue->Divide(hpt1truetag,hpt1true,1,1); //"B"
heta2truetagovertrue->Divide(heta2truetag,heta2true,1,1); //"B"
heta1truetagovertrue->Divide(heta1truetag,heta1true,1,1); //"B"
hbintruetagovertrue->Divide(hbintruetag,hbintrue,1,1); //"B"


hpt2truetagcorrovertrue->Divide(hpt2truetagcorr,hpt2true,1,1); //"B"
hpt1truetagcorrovertrue->Divide(hpt1truetagcorr,hpt1true,1,1); //"B"
heta2truetagcorrovertrue->Divide(heta2truetagcorr,heta2true,1,1); //"B"
heta1truetagcorrovertrue->Divide(heta1truetagcorr,heta1true,1,1); //"B"
hbintruetagcorrovertrue->Divide(hbintruetagcorr,hbintrue,1,1); //"B"

 NormalizeAllHists();

Draw({hpt2truetagovertrue,hpt2truetagcorrovertrue});
Draw({hpt1truetagovertrue,hpt1truetagcorrovertrue});
Draw({heta2truetagovertrue,heta2truetagcorrovertrue});
Draw({heta1truetagovertrue,heta1truetagcorrovertrue});
Draw({hbintruetagovertrue,hbintruetagcorrovertrue});



 // }

}