Esempio n. 1
1
    /**
     * full one column data
     *
     * @param colTag column tag, e.g. "A", "AB", "M"
     * @param nBeg row begin, base 1
     * @prarm data
     */
    void excelreader::SetData(const std::wstring& colTag, int nBeg,
                               const std::list<std::wstring>& data)
    {
        if (data.size() <= 0)
        {
            return;
        }

        int nEnd = nBeg + static_cast<int>(data.size()) - 1;

        // create array
        CComSafeArray<VARIANT> arr(static_cast<ULONG>(0));
        for (std::list<std::wstring>::const_iterator it = data.begin();
             it != data.end(); ++it)
        {
            arr.Add(_variant_t(it->c_str()).Detach(), FALSE);
        }
        VARIANT vArr;
        vArr.vt = VT_ARRAY | VT_VARIANT;
        vArr.parray = (SAFEARRAY*)arr;

        // select range
        WCHAR szTmp1[4];
        wsprintfW(szTmp1, L"%i", nBeg);
        WCHAR szTmp2[4];
        wsprintfW(szTmp2, L"%i", nEnd);
        std::wstring sTmp = colTag + szTmp1 + L":" + colTag + szTmp2;
        _variant_t parm(sTmp.c_str());
        _variant_t result;
        AutoWrap(DISPATCH_PROPERTYGET, &result, pXlSheet, L"Range", 1, parm);

        //full the range
        AutoWrap(DISPATCH_PROPERTYPUT, NULL, result.pdispVal, L"Value",
                 1, vArr);
    }
/* PUBLIC */
void init_pickers(Prover_options opt)
{
  Picker p;
  int i;
  for (i = 0; i < NUM_PICKERS; i++) {
    p = &(Pickers[i]);
    p->idx = NULL;
    p->number_deleted = 0;
    p->number_displaced = 0;
    p->low_delete = INT_MAX;
    p->low_displace = INT_MAX;
  }

  p = &(Pickers[HINTS_PICKER]);
  p->code = "H"; p->name = "Hints";
  p->compare = (Ordertype (*) (void *, void *)) cl_wt_id_compare;
  p->recognizer = hint_matcher;  /* function */
  p->use_for_sos_limit = TRUE;

  p = &(Pickers[AGE_PICKER]);
  p->code = "A"; p->name = "Age";
  p->compare = (Ordertype (*) (void *, void *)) cl_id_compare;
  p->recognizer = any_topform;  /* function */
  p->use_for_sos_limit = FALSE;

  p = &(Pickers[WEIGHT_PICKER]);
  p->code = "W"; p->name = "Weight";
  p->compare = (Ordertype (*) (void *, void *)) cl_wt_id_compare;
  p->recognizer = any_topform;  /* function */
  p->use_for_sos_limit = TRUE;

  p = &(Pickers[FALSE_PICKER]);
  p->code = "F"; p->name = "False_semantics";
  p->compare = (Ordertype (*) (void *, void *)) cl_wt_id_compare;
  p->recognizer = false_semantics;  /* function */
  p->use_for_sos_limit = TRUE;

  p = &(Pickers[TRUE_PICKER]);
  p->code = "T"; p->name = "True_semantics";
  p->compare = (Ordertype (*) (void *, void *)) cl_wt_id_compare;
  p->recognizer = true_semantics;  /* function */
  p->use_for_sos_limit = TRUE;

  p = &(Pickers[RANDOM_PICKER]);
  p->code = "R"; p->name = "Random";
  p->compare = (Ordertype (*) (void *, void *)) cl_id_compare;
  p->recognizer = any_topform;  /* function */
  p->use_for_sos_limit = FALSE;

  update_picker_ratios(opt);

  if (parm(opt->random_seed) >= 0)
    srand(parm(opt->random_seed));
  else {
    unsigned t = absolute_wallclock() + my_process_id();
    printf("\nGenerated seed random number generation: %u\n", t);
    srand(t);
  }
}  /* init_pickers */
Esempio n. 3
0
/* estrutura dos parâmetros: 
 * formparm -> (parm {; parm} ) */
void
formparm (void)
{
  match ('(');
  parm ();
  while (lookahead == ';')
    {
      match (';');
      parm ();
    }
  match (')');
}
/*returns: (-1,0)=>(failure,success)*/
static long
init_wf_loadedSeq(waveformRecord* pwf) {
    long ret = 0;

    if(pwf->inp.type != VME_IO) {
        errlogPrintf("ERROR: Hardware link not VME_IO : %s\n", pwf->name);
        return S_db_badField;
    }
    
    try {
        std::string parm(pwf->inp.value.vmeio.parm);
        evgMrm* evg = dynamic_cast<evgMrm*>(mrf::Object::getObject(parm));
        if(!evg)
            throw std::runtime_error("Failed to lookup EVG");

        evgSeqRamMgr* seqRamMgr = evg->getSeqRamMgr();
        if(!seqRamMgr)
            throw std::runtime_error("Failed to lookup EVG Seq Ram Manager");

        pwf->dpvt = seqRamMgr;
        ret = 0;
    } catch(std::runtime_error& e) {
        errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name);
        ret = S_dev_noDevice;
    } catch(std::exception& e) {
        errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name);
        ret = S_db_noMemory;
    }

    return ret;
}
/* PUBLIC */
BOOL sos_keep1(Topform c, Clist sos, Prover_options opt)
{
  Plist pickers = pickers_for_clause(c);
  if (pickers == NULL)
    return FALSE;  /* no picker will accept the clause */
  else {
    int limit = parm(opt->sos_limit);
    /* printf("sos_keep, sos=%d, c=%d:", clist_length(sos), c->weight); */
    if (limit == -1) {
      zap_plist(pickers);
      return TRUE;  /* some picker wants the clause, and there is no limit */
    }
    else {
      double fullness_of_sos = clist_length(sos) / (double) limit;
      double x = .5;    /* when sos is at (x * limit), start being selective */
      if (fullness_of_sos < x) {
	zap_plist(pickers);
	return TRUE;  /* there is a limit, but we don't yet consider it */
      }
      else {
	Picker p;
	pickers = get_sos_limit_pickers(pickers);
	p = largest_picker(pickers);
	zap_plist(pickers);
	if (p == NULL) {
	  return FALSE;  /* all pickers complete, and we're getting full */
	}
	else {
	  /* keep if wt < than clause at ref_point */
	  double ref_point = x + (1 - fullness_of_sos);
	  /* fullness_of_sos >= x,
	     x <= ref_point <= 1.
	         if sos is full: ref_point=x
		 if sos is at x: ref_point=1
	   */
	  int n = avl_size(p->idx) * ref_point;
	  Topform d = avl_nth_item(p->idx, n);
	  if (d == NULL) {
	    return TRUE;  /* the picker is empty */
	  }
	  else {
	    if (c->weight >= d->weight) {
	      if (c->weight < p->low_delete) {
		printf("\nLow Water (keep, %s): wt=%d\n", p->name, c->weight);
		fflush(stdout);
		p->low_delete = c->weight;
	      }
	      p->number_deleted++;
	      return FALSE;
	    }
	    else {
	      /* keep the clause (smaller than clause at reference point) */
	      return TRUE;
	    }
	  }
	}
      }
    }
  }
}  /* sos_keep1 */
static long 
init_record(dbCommon *pRec, DBLINK* lnk) {
    long ret = 0;

    if(lnk->type != VME_IO) {
        errlogPrintf("ERROR: Hardware link not VME_IO : %s\n", pRec->name);
        return S_db_badField;
    }
    
    try {
        std::string parm(lnk->value.vmeio.parm);
        evgMrm* evg = dynamic_cast<evgMrm*>(mrf::Object::getObject(parm));
        if(!evg)
            throw std::runtime_error("Failed to lookup EVG");

        evgSoftSeqMgr* seqMgr = evg->getSoftSeqMgr();
        if(!seqMgr)
            throw std::runtime_error("Failed to lookup EVG Seq Manager");

        evgSoftSeq* seq = seqMgr->getSoftSeq(lnk->value.vmeio.signal);
        if(!seq)
            throw std::runtime_error("Failed to lookup EVG Sequence");

        pRec->dpvt = seq;
        ret = 0;
    } catch(std::runtime_error& e) {
        errlogPrintf("ERROR: %s : %s\n", e.what(), pRec->name);
        ret = S_dev_noDevice;
    } catch(std::exception& e) {
        errlogPrintf("ERROR: %s : %s\n", e.what(), pRec->name);
        ret = S_db_noMemory;
    }

    return ret;
}
Esempio n. 7
0
void mace4_exit(int exit_code)
{
  if (Opt && flag(Opt->verbose))
    p_mem();

  if (Opt && parm(Opt->report_stderr) > 0)
    fprintf(stderr, "Domain_size=%d. Models=%d. User_CPU=%.2f.\n",
	    Domain_size, Total_models, user_seconds());

  printf("\nUser_CPU=%.2f, System_CPU=%.2f, Wall_clock=%d.\n",
	 user_seconds(), system_seconds(), wallclock());

  if (Total_models == 0)
    printf("\nExiting with failure.\n");
  else
    printf("\nExiting with %d model%s.\n",
	    Total_models, Total_models == 1 ? "" : "s");

  fprintf(stderr, "\n------ process %d exit (%s) ------\n",
	  my_process_id(), exit_string(exit_code));
  printf("\nProcess %d exit (%s) %s",
	  my_process_id(), exit_string(exit_code), get_date());

  printf("The process finished %s", get_date());
  exit(exit_code);
}  /* mace4_exit */
Esempio n. 8
0
static
int check_time_memory(void)
{
  static int Next_report;

  double seconds = user_seconds();
  int max_seconds = parm(Opt->max_seconds);
  int max_seconds_per = parm(Opt->max_seconds_per);
  int max_megs = parm(Opt->max_megs);
  int report = parm(Opt->report_stderr);

  if (max_seconds != -1 && seconds - Start_seconds > max_seconds)
    return SEARCH_MAX_TOTAL_SECONDS;
  else if (max_seconds_per != -1 &&
	   seconds - Start_domain_seconds > parm(Opt->max_seconds_per))
    return SEARCH_MAX_DOMAIN_SECONDS;
  else if (max_megs != -1 && mace_megs() > parm(Opt->max_megs))
    return SEARCH_MAX_MEGS;
  else {
    if (report > 0) {
      if (Next_report == 0)
	Next_report = parm(Opt->report_stderr);
      if (seconds >= Next_report) {
	fprintf(stderr, "Domain_size=%d. Models=%d. User_CPU=%.2f.\n", Domain_size, Total_models, seconds);
	fflush(stderr);
	while (seconds >= Next_report)
	  Next_report += report;
      }
    }
    return SEARCH_GO_NO_MODELS;
  }
}  /* check_time_memory */
////////////////////////////////////////////////////////////////////////////////
//   Writes message to file.
//   Implementation of this function is platform specific
//
//   Note: The current implementation writes the message to the defined file.
//         Will have to be enhanced to support synchronous write operations to
//         the same file.
////////////////////////////////////////////////////////////////////////////////
void TraceFileHandler::handleMessage(
    const char* message,
    Uint32,
    const char* fmt,
    va_list argList)
{
    Uint32 retCode;
    

    if (_configHasChanged)
    {
        _reConfigure();
    }

    if (!_fileHandle)
    {
        // The trace file is not open, which means an earlier fopen() was
        // unsuccessful.  Stop now to avoid logging duplicate error messages.
        return;
    }
  
    AutoMutex writeLock(writeMutex);

    if(!_fileExists(_fileName))
    {
        return;
    }       

        //Move to the End of File
        fseek(_fileHandle,0,SEEK_SET);

        // Write message to file
        fprintf(_fileHandle,"%s", message);
        vfprintf(_fileHandle,fmt,argList);
        retCode = fprintf(_fileHandle,"\n");

        if (retCode < 0)
        {
            // Unable to write message to file
            // Log message
            MessageLoaderParms parm(
                "Common.TraceFileHandlerWindows.UNABLE_TO_WRITE_TRACE_TO_FILE",
                "Unable to write trace message to File $0",
                _fileName);
            _logError(TRCFH_UNABLE_TO_WRITE_TRACE_TO_FILE,parm);
        }
        else
        {
            fflush(_fileHandle);
            // trace message successful written, reset error log messages
            // thus allow writing of errors to log again
            _logErrorBitField = 0;
        }
    
}
Esempio n. 10
0
bool
ChildlessUnaryOpIlInjector::injectIL()
   {
   if (!isOpCodeSupported())
      return false;

   createBlocks(1);
   returnValue(parm(1));

   return true;
   }
Esempio n. 11
0
void MazeController::ligacoes(int value, Maze** maze)
{
	std::list<Liga> p;
	for (int i = 0; i < value; i++)
	{
		for (int j = 0; j < value; j++)
		{
			if (i == 5 && j == 5)

			if (maze[i][j].north == 0){ Liga l; l.aX = j; l.aY = i; l.bX = j; l.bY = i - 1;  p.push_back(l); }
			if (maze[i][j].south == 0){ Liga l; l.aX = j; l.aY = i; l.bX = j; l.bY = i + 1;  p.push_back(l); }
			if (maze[i][j].east == 0) { Liga l; l.aX = j; l.aY = i; l.bX = j + 1; l.bY = i;  p.push_back(l); }
			if (maze[i][j].west == 0) { Liga l; l.aX = j; l.aY = i; l.bX = j - 1; l.bY = i;  p.push_back(l); }

		}
	}


	ofstream myfile;
	myfile.open("example.txt");
	int i = 0;
	while (!p.empty())
	{
		PlTermv av(1);
		string arg1 = "(";
		string arg2 = "(";
		Liga x = p.front();
		arg1 += convertInt(x.aX) + ",";
		arg1 += convertInt(x.aY) + ")";
		arg2 += convertInt(x.bX) + ",";
		arg2 += convertInt(x.bY) + ")";
		p.pop_front();
		string ligacao = "liga(" + arg1 + "," + arg2 + ")";

		av[0] = PlCompound(ligacao.c_str());
		PlQuery query("asserta", av);

		if (query.next_solution()) myfile << ligacao << "." << endl;
		i++;

		PlTermv parm(2);
		parm[0] = PlCompound(arg1.c_str());
		PlQuery query2("liga", parm);
		while (query2.next_solution()){
			cout << arg1 << " ---> ";
			printf(parm[1]);
			cout << " " << endl;
		}

	}
	myfile.close();
}
Esempio n. 12
0
void HttpTrans::recvData(const int& code, FILE* fp, const int& id, const int& reDirectCount)
{
	//std::unique_lock<std::mutex> lock(lock_);
	std::wstring rsp;
	if ( fp )
	{
		fseek(fp, 0L, SEEK_END);
		long length = ftell(fp);
		fseek(fp, 0, SEEK_SET);
		if ( length > 0 )
		{
			char* szBuf = new char[length+1];
			memset(szBuf, 0, length + 1);
			if (fread_s(szBuf, length + 1, 1, length, fp) > 0){
				rsp = cyjh::UTF8ToUnicode(szBuf);
				delete[]szBuf;
			}
		}
	}
	std::shared_ptr<resp_context_> parm(new resp_context_);
	parm->id_ = id;
	parm->errcode_ = code;
	parm->head_ = " ";
	parm->body_ = " ";

	int i = 0;
	int pos = 0;
	while (i < reDirectCount)
	{
		pos = rsp.find(L"\r\n\r\n");
		if ( pos > 0 )
		{
			rsp.erase(0, pos + 4);
		}
		++i;
	}

	pos = rsp.find(L"\r\n\r\n");
	if ( pos > 0 )
	{
		std::wstring whead = rsp.substr(0, pos);
		int size = rsp.size() - pos - 4;
		if ( size > 0 )
		{
			std::wstring wbody = rsp.substr(pos + 4, size);
			parm->body_ = cyjh::UnicodeToUTF8(wbody);
		}
		parm->head_ = cyjh::UnicodeToUTF8(whead);
	}
	CefPostTask(TID_UI, base::Bind(&ackData, parm));
}
Esempio n. 13
0
static
int possible_model(void)
{
  if (flag(Opt->arithmetic)) {
    if (!check_with_arithmetic(Ground_clauses))
      return SEARCH_GO_NO_MODELS;
  }
  else if (!check_that_ground_clauses_are_true())
    fatal_error("possible_model, bad model found");

  {
    static int next_message = 1;
    Total_models++;
    Mstats.current_models++;

    if (flag(Opt->return_models)) {
      Term modelterm = interp_term();
      Interp model = compile_interp(modelterm, FALSE);
      zap_term(modelterm);
      Models = plist_append(Models, model);
    }

    if (flag(Opt->print_models))
      print_model_standard(stdout, TRUE);
    else if (flag(Opt->print_models_tabular))
      p_model(FALSE);
    else if (next_message == Total_models) {
      printf("\nModel %d has been found.\n", Total_models);
      next_message *= 10;
    }
    fflush(stdout);
    if (parm(Opt->max_models) != -1 && Total_models >= parm(Opt->max_models))
      return SEARCH_MAX_MODELS;
    else
      return SEARCH_GO_MODELS;
  }
}  /* possible_model */
Esempio n. 14
0
	void kRasterConst::notifyModification( const kRect< INT32 > &bounds ) const {
		std::vector< bool > mark;
		std::vector< std::pair< kRect< INT32 >, zutil::kIOFunctor< bool, std::pair< const kRect< INT32 > *, const kRasterConst * > > * > >::iterator itr;
		std::pair< const kRect< INT32 > *, const kRasterConst * > parm( &bounds, this );
		for( itr = changeNotifies.begin(); itr != changeNotifies.end(); itr++ ) {
			mark.push_back( !(*(itr->second))( parm ) );
		};
		std::vector< std::pair< kRect< INT32 >, zutil::kIOFunctor< bool, std::pair< const kRect< INT32 > *, const kRasterConst * > > * > > alter;
		for( size_t i = 0; i < mark.size(); ++i ) {
			if( mark[ i ] )
				alter.push_back( changeNotifies[ i ] );
		}
		changeNotifies.swap( alter );
		// TODO: lock changes on traversal (high priority!)
	};
Esempio n. 15
0
	double excelreader::GetDataAsDouble(int row, int col) {
		if (row < 0 || col < 0)
			throw ExcelException("cell not exit");
		WCHAR szTmp[5];
        wsprintfW(szTmp, L"%i", row);
        std::wstring sTmp = GetColumnName(col) + szTmp + L":"
            + GetColumnName(col) + szTmp;
        _variant_t parm(sTmp.c_str());
        _variant_t result;
		AutoWrap(DISPATCH_PROPERTYGET, &result, pXlSheet, L"Range",
                1, (VARIANT)parm);
        _variant_t data;
        AutoWrap(DISPATCH_PROPERTYGET, &data, result.pdispVal, L"Value", 0);

        return (double)data;
    }
/* PUBLIC */
void update_picker_ratios(Prover_options opt)
{
  Pickers[HINTS_PICKER].ratio_part = parm(opt->hints_part);
  Pickers[AGE_PICKER].ratio_part = parm(opt->age_part);
  Pickers[WEIGHT_PICKER].ratio_part = parm(opt->weight_part);
  Pickers[FALSE_PICKER].ratio_part = parm(opt->false_part);
  Pickers[TRUE_PICKER].ratio_part = parm(opt->true_part);
  Pickers[RANDOM_PICKER].ratio_part = parm(opt->random_part);
  /* reset ratio state */
  Current_picker = 0;
  Next_i = 0;
}  /* update_picker_ratios */
Esempio n. 17
0
 /**
     * set single unit or a range
     * for example:
     * SetData(L"D8:D8", L"5");
     * SetData(L"E3:G5", L"kkj");
     * SetData(L"H9", L"H9");
     *
     * @param cell mark a range, e.g. "A1:B2".
     *             for a single unit, use "A1:A1" or "A1".
     * @param data all unit of rang set to this value
     */
    void excelreader::SetData(const std::wstring& cell,
                               const std::wstring& data)
    {
        if (cell.empty())
        {
            throw ExcelException("cell not exist");
        }

        _variant_t parm(cell.c_str());
        _variant_t result;
        AutoWrap(DISPATCH_PROPERTYGET, &result, pXlSheet, L"Range",
                 1, (VARIANT)parm);

        //full the range
        _variant_t vtData(data.c_str());
        AutoWrap(DISPATCH_PROPERTYPUT, NULL, result.pdispVal, L"Value",
                 1, (VARIANT)vtData);
    }
Esempio n. 18
0
	std::string excelreader::GetDataAsString(int row, int col) {
       if (row < 0 || col < 0)
           throw ExcelException("Cell not exit");
       	WCHAR szTmp[6];
        wsprintfW(szTmp, L"%i", row);
        std::wstring sTmp = GetColumnName(col) + szTmp + L":"
            + GetColumnName(col) + szTmp;
        _variant_t parm(sTmp.c_str());
        _variant_t result;
		AutoWrap(DISPATCH_PROPERTYGET, &result, pXlSheet, L"Range",
                1, (VARIANT)parm);
        _variant_t data;
        AutoWrap(DISPATCH_PROPERTYGET, &data, result.pdispVal, L"Value", 0);
        //if (VariantChangeType(&data, &data, 0, VT_BSTR) != S_OK) {
        //   throw ExcelException("Cannot convert data to string");
        //}
		//CW2A ansiBuffer((_bstr_t)data);
		//CT2A cc((_bstr_t)data);
        //std::string s(cc); 
		return tostr(data);
    }
/**     Initialization    **/
static long 
init_wf_pvt (dbCommon *pRec) {
    long ret = 0;
    waveformRecord* pwf = (waveformRecord*)pRec;

    if(pwf->inp.type != VME_IO) {
        errlogPrintf("ERROR: Hardware link not VME_IO : %s\n", pwf->name);
        return S_db_badField;
    }
    
    try {
        std::string parm(pwf->inp.value.vmeio.parm);
        evgMrm* evg = dynamic_cast<evgMrm*>(mrf::Object::getObject(parm));
        if(!evg)
            throw std::runtime_error("Failed to lookup EVG");

        evgSoftSeqMgr* seqMgr = evg->getSoftSeqMgr();
        if(!seqMgr)
            throw std::runtime_error("Failed to lookup EVG Seq Manager");

        evgSoftSeq* seq = seqMgr->getSoftSeq(pwf->inp.value.vmeio.signal);
        if(!seq)
            throw std::runtime_error("Failed to lookup EVG Sequence");

        Pvt* pvt = new Pvt;
        pvt->evg = evg;
        pvt->seq = seq;
        pwf->dpvt = pvt;
        ret = 0;
    } catch(std::runtime_error& e) {
        errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name);
        ret = S_dev_noDevice;
    } catch(std::exception& e) {
        errlogPrintf("ERROR: %s : %s\n", e.what(), pwf->name);
        ret = S_db_noMemory;
    }

    return ret;
}
HardRecoil_Manager::HardRecoil_Manager(const char* parameter_filename) {

  PParameterReader parm(parameter_filename);
  std::cout << "HardRecoil_Manager Initialization" << std::endl;

  ptnbins = parm.GetInt("HardRecoil_pTbins");
  ptbins = parm.GetVDouble("HardRecoil_pTbins_edges");
  zbsetmodel = parm.GetBool("HardRecoil_zbsetmodel", kFALSE);
  run3bool = parm.GetBool("Run3");
  run4bool = parm.GetBool("Run4");

 if (run3bool == run4bool && zbsetmodel) {
    std::cout << "ERROR:  HardRecoil_Manager can only process Run3 or Run4 at a time.  Set only one of the Run3 and Run4 parameters at top of parameters file to true." << std::endl;
    exit(0);
  }

  if(zbsetmodel){
    ptnbinsset = parm.GetInt("HardRecoil_pTbinsSET");
    ptbinsset = parm.GetVDouble("HardRecoil_pTbinsSET_edges");
    luminbins = parm.GetInt("HardRecoil_lumibins");
    lumibins = parm.GetVDouble("HardRecoil_lumibins_edges");
    dphinbins = parm.GetInt("HardRecoil_dphibins");
    dphibins = parm.GetVDouble("HardRecoil_dphibins_edges");

    zphirespnbins = parm.GetInt("HardRecoil_zphirespbins");
    zphirespbins = parm.GetVDouble("HardRecoil_zphirespbins_edges");
    if(run3bool){
      zphirespA = parm.GetVDouble("HardRecoil_zphiresp_ParameterA");
      zphirespB = parm.GetVDouble("HardRecoil_zphiresp_ParameterB");
      zphirespC = parm.GetVDouble("HardRecoil_zphiresp_ParameterC");
      zphirespD = parm.GetVDouble("HardRecoil_zphiresp_ParameterD");
      zphirespMean = parm.GetVDouble("HardRecoil_zphiresp_Mean");
    }else{
      zphirespA = parm.GetVDouble("HardRecoil_zphiresp_ParameterA_run4");
      zphirespB = parm.GetVDouble("HardRecoil_zphiresp_ParameterB_run4");
      zphirespC = parm.GetVDouble("HardRecoil_zphiresp_ParameterC_run4");
      zphirespD = parm.GetVDouble("HardRecoil_zphiresp_ParameterD_run4");
      zphirespMean = parm.GetVDouble("HardRecoil_zphiresp_Mean_run4");
    }
  }else{
    ptnbinsset = ptnbins;
    ptbinsset = ptbins;
  }

  flipped = false;

  if(parm.GetInt("EtFlowFudge")==8){//so don't grab file for old versions of etflow, like option 3
    TString etflow_fname(parm.GetChar("EtFlowFile"));
    TFile* etflow_binned_file = new TFile(etflow_fname);
    etflow_binned3 = (TH1D*) etflow_binned_file->Get("etflow_run2b3");
    etflow_binned4 = (TH1D*) etflow_binned_file->Get("etflow_run2b4");
    etflow_binned3->SetDirectory(0);
    etflow_binned4->SetDirectory(0);
    etflow_binned_file->Close();
  }


  // hard recoil library file
  if (getenv("HRLibraryRootPath") == NULL ) {
    std::cout << "ERROR:  HRLibraryRootPath is not defined" << std::endl;
    exit(0);
  }
 
  TString hrLibraryRootPath(getenv("HRLibraryRootPath"));
  TString model_filename = "";
  if(run3bool) model_filename = hrLibraryRootPath + '/' + parm.GetChar("HardRecoil_FileName"); 
  else{
    if (zbsetmodel) model_filename = hrLibraryRootPath + '/' + parm.GetChar("HardRecoil_FileName_run4"); 
    else model_filename = hrLibraryRootPath + '/' + parm.GetChar("HardRecoil_FileName"); //backwards compatibility
  }
  std::cout << model_filename << " will be used for hard recoil model" << std::endl;
  TFile* tf = new TFile(model_filename);
    
  for (Int_t j=0; j<ptnbins; j++) {
    
    if(! zbsetmodel){
      TH2D* HRHist = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_bin_%d", j));
      resp_pdf.push_back(new TH2rclsa(*HRHist));
      HRHist->Delete();
      resp_pdf[j]->SetDirectory(0);
      resp_pdf[j]->ComputeYIntegral();
      resp_pdf[j]->ComputeIntegral();  
     
    }else{ //we will assign histograms below to be resp_pdf and resp_zbset_pdf later in the code
      //dphi model is in true phi bins, other two in true zpt bins (and others)
     
      if(luminbins !=7 || dphinbins !=6) {
	std::cout<<"settings for number of lumi or dphi bins is not correct.  HardRecoil_Manager code must be altered for other binning."<<std::endl;
	exit(0);
      }

      TH2D* HRHist0 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi0_bin_%d", j)); //0th
      resp_pdf0.push_back(new TH2rclsa(*HRHist0));
      HRHist0->Delete();
      resp_pdf0[j]->SetDirectory(0);
      
      TH2D* HRHist1 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi1_bin_%d", j));
      resp_pdf1.push_back(new TH2rclsa(*HRHist1));
      HRHist1->Delete();
      resp_pdf1[j]->SetDirectory(0);
      
      TH2D* HRHist2 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi2_bin_%d", j));
      resp_pdf2.push_back(new TH2rclsa(*HRHist2));
      HRHist2->Delete();
      resp_pdf2[j]->SetDirectory(0);
       
      TH2D* HRHist3 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi3_bin_%d", j));
      resp_pdf3.push_back(new TH2rclsa(*HRHist3));
      HRHist3->Delete();
      resp_pdf3[j]->SetDirectory(0);
 
      TH2D* HRHist4 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi4_bin_%d", j));
      resp_pdf4.push_back(new TH2rclsa(*HRHist4));
      HRHist4->Delete();
      resp_pdf4[j]->SetDirectory(0);
        
      TH2D* HRHist5 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi5_bin_%d", j));
      resp_pdf5.push_back(new TH2rclsa(*HRHist5));
      HRHist5->Delete();
      resp_pdf5[j]->SetDirectory(0);
        
      TH2D* HRZBHist0 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin0_bin_%d", j));
      resp_zbset_pdf0.push_back(new TH2rclsa(*HRZBHist0));
      HRZBHist0->Delete();
      resp_zbset_pdf0[j]->SetDirectory(0);
            
      TH2D* HRZBHist1 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin1_bin_%d", j));
      resp_zbset_pdf1.push_back(new TH2rclsa(*HRZBHist1));
      HRZBHist1->Delete();
      resp_zbset_pdf1[j]->SetDirectory(0);
     
      TH2D* HRZBHist2 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin2_bin_%d", j));
      resp_zbset_pdf2.push_back(new TH2rclsa(*HRZBHist2));
      HRZBHist2->Delete();
      resp_zbset_pdf2[j]->SetDirectory(0);
        
      TH2D* HRZBHist3 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin3_bin_%d", j));
      resp_zbset_pdf3.push_back(new TH2rclsa(*HRZBHist3));
      HRZBHist3->Delete();
      resp_zbset_pdf3[j]->SetDirectory(0);
      
      TH2D* HRZBHist4 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin4_bin_%d", j));
      resp_zbset_pdf4.push_back(new TH2rclsa(*HRZBHist4));
      HRZBHist4->Delete();
      resp_zbset_pdf4[j]->SetDirectory(0);
      
      TH2D* HRZBHist5 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin5_bin_%d", j));
      resp_zbset_pdf5.push_back(new TH2rclsa(*HRZBHist5));
      HRZBHist5->Delete();
      resp_zbset_pdf5[j]->SetDirectory(0);

      TH2D* HRZBHist6 = (TH2D*) tf->Get(TString::Format("recoil_resp_zbset_hist_lumibin6_bin_%d", j));
      resp_zbset_pdf6.push_back(new TH2rclsa(*HRZBHist6));
      HRZBHist6->Delete();
      resp_zbset_pdf6[j]->SetDirectory(0);
    }//IF ZBSET MODEL
  }//PTBINS
  
  for (Int_t j=0; j<ptnbinsset; j++) {
    TH2D* SETHist = (TH2D*) tf->Get(TString::Format("set_ut_hist_bin_%d", j));
    set_ut_pdf.push_back(new TH2rclsa(*SETHist));
    SETHist->Delete();
    set_ut_pdf[j]->SetDirectory(0);
  }//PTBINS FOR SET
  
  if(!zbsetmodel){
    TH2D* PhiHist = (TH2D*) tf->Get("phi_hist");     
    phi_pdf = new TH2rclsa(*PhiHist);
    phi_pdf->SetDirectory(0);
    phi_pdf->ComputeYMaximum();
  }
  
  
  tf->Close();
  
  std::cout << "HardRecoil_Manager initialization: DONE" << std::endl;
  
}