Exemple #1
0
int main(int argc, char *argv[])
{
  PICTURE *pic,*pic2;
  int opdim = 4;
  float lowthresh = 0.05f, highthresh = 0.9f;

  switch (argc) {
	case 6: highthresh = (float)atof(argv[5]); argc--;
	case 5: lowthresh = (float)atof(argv[4]); argc--;
	case 4: opdim = atoi(argv[3]); argc--;
	case 3: case 2: case 1: dofiles(argc,argv); 
		fprintf(stderr,"%s: operator side = %d\n", PROGNAME,opdim); 
		break;
	default: fprintf(stderr,
	"usage: %s [infile] [outfile] [side] [lowthresh] [highthresh]\n",
				PROGNAME);
		exit(1); }
  if ((pic = readpic(FILEIN)) == NULL) 
		{ fprintf(stderr,"%s: failed to read input file\n",PROGNAME); 
			exit(1); }
  if ((pic->fileid) != IMAGE_ID)
		{ fprintf(stderr,"%s: wrong type of input file\n",PROGNAME); 
			exit(1); }
  timex(); pic = grad(pic,opdim); timex();
  // pic = morphgrads(pic); /* optional thinning */
  pic = gradmag(pic);
  pic2  = ftoim(pic,lowthresh,highthresh,1); 
  freepic(pic); /* ftoim does not free pic */
  writepmpic(pic2,FILEOUT);
  exit(0);
}
void getmax()
{
	getch();
	clrscr();
	timex();
	printf("\n");
	printf("---------------------------Welcome----------------------------------\n");
	printf("------------------BHARAT SANCHAR NIGAM LIMITED----------------------\n");
	printf("----------------------Management System-----------------------------\n");
	printf("-Software Developed By:Jaipuneet Singh, Jaswinder Pathania ---------\n");
	printf("\n----------------------------------------------------------------\n\n");

}
Exemple #3
0
void gimlocInit(){

  static int rel_scan_count = -1;
  static int frame_number = -1; 
  static double REC[336];

  //	std::cout <<"\nin gimloc init\n";

  if(rel_scan_count != imagerDoc.rel_scan_count || frame_number != imagerDoc.frame_number) { 

    rel_scan_count = imagerDoc.rel_scan_count;
    frame_number = imagerDoc.frame_number;

    REC[0] = 0; 
    REC[1] = 0;
    REC[2] = 0;
    REC[3] = 0;
    REC[4] = (double)imagerDoc.ReferenceLongitude; /* 295 298*/
    REC[5] = (double)imagerDoc.ReferenceRadialDistance; /* 299 302*/
    REC[6] = (double)imagerDoc.ReferenceLatitude; /* 303 306*/
    REC[7] = (double)imagerDoc.ReferenceOrbitYaw; /* 307 310*/
    REC[8] = (double)imagerDoc.ReferenceAttitudeRoll; /* 311 314*/
    REC[9] = (double)imagerDoc.ReferenceAttitudePitch; /* 315 318*/
    REC[10] = (double)imagerDoc.ReferenceAttitudeYaw; /* 319 322*/

    REC[11] = (imagerDoc.EpochDate.year()* 10000 +
	       imagerDoc.EpochDate.day() * 10  +
	       (imagerDoc.EpochDate.hrs())/10 );
	    
    REC[12] = ( (imagerDoc.EpochDate.hrs()) % 10 * 10000000 +  
	       imagerDoc.EpochDate.min() * 100000 + 
	       imagerDoc.EpochDate.sec() * 10 +
	       imagerDoc.EpochDate.msec() );
  

    REC[13] = (double)imagerDoc.IMCenableFromEpoch; /* 331 334*/
    REC[14] = (double)imagerDoc.CompensationRoll; /* 335 338*/
    REC[15] = (double)imagerDoc.CompensationPitch; /* 339 342*/
    REC[16] = (double)imagerDoc.CompensationYaw; /* 343 346*/
    int i ;
    for(i=0; i<13; i++) 
      REC[i+17] = (double)imagerDoc.ChangeLongitude[i];/* 347 398*/

    for(i = 0; i<11; i++) 
      REC[i+30] = (double)imagerDoc.ChangeRadialDistance[i]; /* 399 442*/

    for(i = 0; i<9 ; i++) 
      REC[41+i] = (double)imagerDoc.SineGeocentricLatitude[i]; /* 443 478*/
    
    for(i = 0; i<9; i++) 
      REC[50+i] = (double)imagerDoc.SineOrbitYaw[i]; /* 479 514*/
  
    REC[59] = (double)imagerDoc.DailySolarRate; /* 515 518*/
    
    REC[60] = (double)imagerDoc.ExponentialStartFromEpoch; /* 519 522*/

    imagerDoc.RollAngle.toNoaaNavigation(REC+61);
    imagerDoc.PitchAngle.toNoaaNavigation(REC+116); /* 743 962*/
    imagerDoc.YawAngle.toNoaaNavigation(REC+171); /* 963 1182*/
    imagerDoc.RollMisalignment.toNoaaNavigation(REC+226); /*1183 1402*/
    imagerDoc.PitchMisalignment.toNoaaNavigation(REC+281); /*1403 1662*/
  
  
    
    double T, TU;
    int imc = 0; // imagerDoc.iscan.imcStatus() ; 
    double rlat, rlon;
    double sec;  

    sec = imagerDoc.EpochDate.sec() + imagerDoc.EpochDate.msec()/1000.0;

    timex(imagerDoc.EpochDate.year(),
          imagerDoc.EpochDate.day(),
          imagerDoc.EpochDate.hrs(),
          imagerDoc.EpochDate.min(),
          sec,
          TU  );
  
    sec = imagerDoc.T_sps_current.sec() + imagerDoc.T_sps_current.msec()/1000.0;

    timex(imagerDoc.T_sps_current.year(),
          imagerDoc.T_sps_current.day(),
          imagerDoc.T_sps_current.hrs(),
          imagerDoc.T_sps_current.min(),
          sec,
          T  );


    int INSTRUMENT = 1;
    int NS_NAD_CY =  imagerDoc.ns_cycles;
    int EW_NAD_CY =  imagerDoc.ew_cycles;

    int NS_NAD_INC = imagerDoc.ns_incr;
    int EW_NAD_INC = imagerDoc.ew_incr;

    setcon_(&INSTRUMENT,
	    &NS_NAD_CY,
	    &NS_NAD_INC,
	    &EW_NAD_CY,
	    &EW_NAD_INC);

    double pi = 4 * atan(1.0);

    /* ????? lmodel calculates rlat and rlon ????? */
    rlat = (double) imagerDoc.Subsat_Lat* pi/180.0;
    rlon = (double) imagerDoc.Subsat_Lon* pi/180.0;

    lmodel_(&T,
	    &TU,
	    &REC,
	    &imc, 
	    &rlat, 
	    &rlon);
  }
}
/*
 * execute command tree
 */
int
execute(struct op * volatile t,
    /* if XEXEC don't fork */
    volatile int flags,
    volatile int * volatile xerrok)
{
	int i;
	volatile int rv = 0, dummy = 0;
	int pv[2];
	const char ** volatile ap = NULL;
	char ** volatile up;
	const char *s, *ccp;
	struct ioword **iowp;
	struct tbl *tp = NULL;
	char *cp;

	if (t == NULL)
		return (0);

	/* Caller doesn't care if XERROK should propagate. */
	if (xerrok == NULL)
		xerrok = &dummy;

	if ((flags&XFORK) && !(flags&XEXEC) && t->type != TPIPE)
		/* run in sub-process */
		return (exchild(t, flags & ~XTIME, xerrok, -1));

	newenv(E_EXEC);
	if (trap)
		runtraps(0);

	/* we want to run an executable, do some variance checks */
	if (t->type == TCOM) {
		/* check if this is 'var=<<EOF' */
		if (
		    /* we have zero arguments, i.e. no programme to run */
		    t->args[0] == NULL &&
		    /* we have exactly one variable assignment */
		    t->vars[0] != NULL && t->vars[1] == NULL &&
		    /* we have exactly one I/O redirection */
		    t->ioact != NULL && t->ioact[0] != NULL &&
		    t->ioact[1] == NULL &&
		    /* of type "here document" (or "here string") */
		    (t->ioact[0]->flag & IOTYPE) == IOHERE &&
		    /* the variable assignment begins with a valid varname */
		    (ccp = skip_wdvarname(t->vars[0], true)) != t->vars[0] &&
		    /* and has no right-hand side (i.e. "varname=") */
		    ccp[0] == CHAR && ccp[1] == '=' && ccp[2] == EOS &&
		    /* plus we can have a here document content */
		    herein(t->ioact[0], &cp) == 0 && cp && *cp) {
			char *sp = cp, *dp;
			size_t n = ccp - t->vars[0] + 2, z;

			/* drop redirection (will be garbage collected) */
			t->ioact = NULL;

			/* set variable to its expanded value */
			z = strlen(cp) + 1;
			if (notoktomul(z, 2) || notoktoadd(z * 2, n))
				internal_errorf(Toomem, (unsigned long)-1);
			dp = alloc(z * 2 + n, ATEMP);
			memcpy(dp, t->vars[0], n);
			t->vars[0] = dp;
			dp += n;
			while (*sp) {
				*dp++ = QCHAR;
				*dp++ = *sp++;
			}
			*dp = EOS;
			/* free the expanded value */
			afree(cp, APERM);
		}

		/*
		 * Clear subst_exstat before argument expansion. Used by
		 * null commands (see comexec() and c_eval()) and by c_set().
		 */
		subst_exstat = 0;

		/* for $LINENO */
		current_lineno = t->lineno;

		/*
		 * POSIX says expand command words first, then redirections,
		 * and assignments last..
		 */
		up = eval(t->args, t->u.evalflags | DOBLANK | DOGLOB | DOTILDE);
		if (flags & XTIME)
			/* Allow option parsing (bizarre, but POSIX) */
			timex_hook(t, &up);
		ap = (const char **)up;
		if (Flag(FXTRACE) && ap[0]) {
			shf_puts(substitute(str_val(global("PS4")), 0),
			    shl_out);
			for (i = 0; ap[i]; i++)
				shf_fprintf(shl_out, "%s%c", ap[i],
				    ap[i + 1] ? ' ' : '\n');
			shf_flush(shl_out);
		}
		if (ap[0])
			tp = findcom(ap[0], FC_BI|FC_FUNC);
	}
	flags &= ~XTIME;

	if (t->ioact != NULL || t->type == TPIPE || t->type == TCOPROC) {
		e->savefd = alloc2(NUFILE, sizeof(short), ATEMP);
		/* initialise to not redirected */
		memset(e->savefd, 0, NUFILE * sizeof(short));
	}

	/* mark for replacement later (unless TPIPE) */
	vp_pipest->flag |= INT_L;

	/* do redirection, to be restored in quitenv() */
	if (t->ioact != NULL)
		for (iowp = t->ioact; *iowp != NULL; iowp++) {
			if (iosetup(*iowp, tp) < 0) {
				exstat = rv = 1;
				/*
				 * Redirection failures for special commands
				 * cause (non-interactive) shell to exit.
				 */
				if (tp && tp->type == CSHELL &&
				    (tp->flag & SPEC_BI))
					errorfz();
				/* Deal with FERREXIT, quitenv(), etc. */
				goto Break;
			}
		}

	switch (t->type) {
	case TCOM:
		rv = comexec(t, tp, (const char **)ap, flags, xerrok);
		break;

	case TPAREN:
		rv = execute(t->left, flags | XFORK, xerrok);
		break;

	case TPIPE:
		flags |= XFORK;
		flags &= ~XEXEC;
		e->savefd[0] = savefd(0);
		e->savefd[1] = savefd(1);
		while (t->type == TPIPE) {
			openpipe(pv);
			/* stdout of curr */
			ksh_dup2(pv[1], 1, false);
			/**
			 * Let exchild() close pv[0] in child
			 * (if this isn't done, commands like
			 *	(: ; cat /etc/termcap) | sleep 1
			 * will hang forever).
			 */
			exchild(t->left, flags | XPIPEO | XCCLOSE,
			    NULL, pv[0]);
			/* stdin of next */
			ksh_dup2(pv[0], 0, false);
			closepipe(pv);
			flags |= XPIPEI;
			t = t->right;
		}
		/* stdout of last */
		restfd(1, e->savefd[1]);
		/* no need to re-restore this */
		e->savefd[1] = 0;
		/* Let exchild() close 0 in parent, after fork, before wait */
		i = exchild(t, flags | XPCLOSE | XPIPEST, xerrok, 0);
		if (!(flags&XBGND) && !(flags&XXCOM))
			rv = i;
		break;

	case TLIST:
		while (t->type == TLIST) {
			execute(t->left, flags & XERROK, NULL);
			t = t->right;
		}
		rv = execute(t, flags & XERROK, xerrok);
		break;

	case TCOPROC: {
#ifndef MKSH_NOPROSPECTOFWORK
		sigset_t omask;

		/*
		 * Block sigchild as we are using things changed in the
		 * signal handler
		 */
		sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
		e->type = E_ERRH;
		if ((i = kshsetjmp(e->jbuf))) {
			sigprocmask(SIG_SETMASK, &omask, NULL);
			quitenv(NULL);
			unwind(i);
			/* NOTREACHED */
		}
#endif
		/* Already have a (live) co-process? */
		if (coproc.job && coproc.write >= 0)
			errorf("coprocess already exists");

		/* Can we re-use the existing co-process pipe? */
		coproc_cleanup(true);

		/* do this before opening pipes, in case these fail */
		e->savefd[0] = savefd(0);
		e->savefd[1] = savefd(1);

		openpipe(pv);
		if (pv[0] != 0) {
			ksh_dup2(pv[0], 0, false);
			close(pv[0]);
		}
		coproc.write = pv[1];
		coproc.job = NULL;

		if (coproc.readw >= 0)
			ksh_dup2(coproc.readw, 1, false);
		else {
			openpipe(pv);
			coproc.read = pv[0];
			ksh_dup2(pv[1], 1, false);
			/* closed before first read */
			coproc.readw = pv[1];
			coproc.njobs = 0;
			/* create new coprocess id */
			++coproc.id;
		}
#ifndef MKSH_NOPROSPECTOFWORK
		sigprocmask(SIG_SETMASK, &omask, NULL);
		/* no more need for error handler */
		e->type = E_EXEC;
#endif

		/*
		 * exchild() closes coproc.* in child after fork,
		 * will also increment coproc.njobs when the
		 * job is actually created.
		 */
		flags &= ~XEXEC;
		exchild(t->left, flags | XBGND | XFORK | XCOPROC | XCCLOSE,
		    NULL, coproc.readw);
		break;
	}

	case TASYNC:
		/*
		 * XXX non-optimal, I think - "(foo &)", forks for (),
		 * forks again for async... parent should optimise
		 * this to "foo &"...
		 */
		rv = execute(t->left, (flags&~XEXEC)|XBGND|XFORK, xerrok);
		break;

	case TOR:
	case TAND:
		rv = execute(t->left, XERROK, xerrok);
		if ((rv == 0) == (t->type == TAND))
			rv = execute(t->right, XERROK, xerrok);
		flags |= XERROK;
		if (xerrok)
			*xerrok = 1;
		break;

	case TBANG:
		rv = !execute(t->right, XERROK, xerrok);
		flags |= XERROK;
		if (xerrok)
			*xerrok = 1;
		break;

	case TDBRACKET: {
		Test_env te;

		te.flags = TEF_DBRACKET;
		te.pos.wp = t->args;
		te.isa = dbteste_isa;
		te.getopnd = dbteste_getopnd;
		te.eval = test_eval;
		te.error = dbteste_error;

		rv = test_parse(&te);
		break;
	}

	case TFOR:
	case TSELECT: {
		volatile bool is_first = true;
		ap = (t->vars == NULL) ? e->loc->argv + 1 :
		    (const char **)eval((const char **)t->vars,
		    DOBLANK | DOGLOB | DOTILDE);
		e->type = E_LOOP;
		while ((i = kshsetjmp(e->jbuf))) {
			if ((e->flags&EF_BRKCONT_PASS) ||
			    (i != LBREAK && i != LCONTIN)) {
				quitenv(NULL);
				unwind(i);
			} else if (i == LBREAK) {
				rv = 0;
				goto Break;
			}
		}
		/* in case of a continue */
		rv = 0;
		if (t->type == TFOR) {
			while (*ap != NULL) {
				setstr(global(t->str), *ap++, KSH_UNWIND_ERROR);
				rv = execute(t->left, flags & XERROK, xerrok);
			}
		} else {
			/* TSELECT */
			for (;;) {
				if (!(ccp = do_selectargs(ap, is_first))) {
					rv = 1;
					break;
				}
				is_first = false;
				setstr(global(t->str), ccp, KSH_UNWIND_ERROR);
				execute(t->left, flags & XERROK, xerrok);
			}
		}
		break;
	}

	case TWHILE:
	case TUNTIL:
		e->type = E_LOOP;
		while ((i = kshsetjmp(e->jbuf))) {
			if ((e->flags&EF_BRKCONT_PASS) ||
			    (i != LBREAK && i != LCONTIN)) {
				quitenv(NULL);
				unwind(i);
			} else if (i == LBREAK) {
				rv = 0;
				goto Break;
			}
		}
		/* in case of a continue */
		rv = 0;
		while ((execute(t->left, XERROK, NULL) == 0) ==
		    (t->type == TWHILE))
			rv = execute(t->right, flags & XERROK, xerrok);
		break;

	case TIF:
	case TELIF:
		if (t->right == NULL)
			/* should be error */
			break;
		rv = execute(t->left, XERROK, NULL) == 0 ?
		    execute(t->right->left, flags & XERROK, xerrok) :
		    execute(t->right->right, flags & XERROK, xerrok);
		break;

	case TCASE:
		i = 0;
		ccp = evalstr(t->str, DOTILDE);
		for (t = t->left; t != NULL && t->type == TPAT; t = t->right) {
			for (ap = (const char **)t->vars; *ap; ap++) {
				if (i || ((s = evalstr(*ap, DOTILDE|DOPAT)) &&
				    gmatchx(ccp, s, false))) {
					rv = execute(t->left, flags & XERROK,
					    xerrok);
					i = 0;
					switch (t->u.charflag) {
					case '&':
						i = 1;
						/* FALLTHROUGH */
					case '|':
						goto TCASE_next;
					}
					goto TCASE_out;
				}
			}
			i = 0;
 TCASE_next:
			/* empty */;
		}
 TCASE_out:
		break;

	case TBRACE:
		rv = execute(t->left, flags & XERROK, xerrok);
		break;

	case TFUNCT:
		rv = define(t->str, t);
		break;

	case TTIME:
		/*
		 * Clear XEXEC so nested execute() call doesn't exit
		 * (allows "ls -l | time grep foo").
		 */
		rv = timex(t, flags & ~XEXEC, xerrok);
		break;

	case TEXEC:
		/* an eval'd TCOM */
		s = t->args[0];
		up = makenv();
		restoresigs();
		cleanup_proc_env();
		{
			union mksh_ccphack cargs;

			cargs.ro = t->args;
			execve(t->str, cargs.rw, up);
			rv = errno;
		}
		if (rv == ENOEXEC)
			scriptexec(t, (const char **)up);
		else
			errorf("%s: %s", s, cstrerror(rv));
	}
 Break:
	exstat = rv & 0xFF;
	if (vp_pipest->flag & INT_L) {
		unset(vp_pipest, 1);
		vp_pipest->flag = DEFINED | ISSET | INTEGER | RDONLY |
		    ARRAY | INT_U;
		vp_pipest->val.i = rv;
	}

	/* restores IO */
	quitenv(NULL);
	if ((flags&XEXEC))
		/* exit child */
		unwind(LEXIT);
	if (rv != 0 && !(flags & XERROK) &&
	    (xerrok == NULL || !*xerrok)) {
		if (Flag(FERREXIT) & 0x80) {
			/* inside eval */
			Flag(FERREXIT) = 0;
		} else {
			trapsig(ksh_SIGERR);
			if (Flag(FERREXIT))
				unwind(LERROR);
		}
	}
	return (rv);
}
int cond::TestGTPerf::execute(){

  std::string gtag = getOptionValue<std::string>("globaltag");
  bool debug = hasDebug();
  std::string connect = getOptionValue<std::string>("connect");
  bool verbose = hasOptionValue("verbose");

  int nThrF = getOptionValue<int>("n_fetch");
  int nThrD = getOptionValue<int>("n_deser");
  std::cout << "\n++> going to use " << nThrF << " threads for loading, " << nThrD << " threads for deserialization. \n" << std::endl;

  std::string serType = "unknown";
  if ( connect.find("CMS_CONDITIONS") != -1 ) {
    serType = "ROOT-5";
  } else if (connect.find("CMS_TEST_CONDITIONS") != -1 ) {
    serType = "boost";
  }

  Time_t startRun= 150005;
  if(hasOptionValue("start_run")) startRun = getOptionValue<Time_t>("start_run");
  Time_t startTs= 5800013687234232320;
  if(hasOptionValue("start_ts")) startTs = getOptionValue<Time_t>("start_ts");
  Time_t startLumi= 908900979179966;
  if(hasOptionValue("start_lumi")) startLumi = getOptionValue<Time_t>("start_lumi");

  std::string authPath("");
  if( hasOptionValue("authPath")) authPath = getOptionValue<std::string>("authPath");

  initializePluginManager();

  Timer timex(serType);

  ConnectionPoolWrapper connPool( 1, authPath, hasDebug() );
  Session session = connPool.createSession( connect );
  session.transaction().start();
  
  std::cout <<"Loading Global Tag "<<gtag<<std::endl;
  GTProxy gt = session.readGlobalTag( gtag );

  session.transaction().commit();

  std::cout <<"Loading "<<gt.size()<<" tags..."<<std::endl;
  std::vector<UntypedPayloadProxy *> proxies;
  std::map<std::string,size_t> requests;
  size_t nt = 0;
  for( auto t: gt ){
    nt++;
    UntypedPayloadProxy * p = new UntypedPayloadProxy;
    p->init( session );
    try{
      p->load( t.tagName() );
      if (nThrF == 1) { // detailed info only needed in single-threaded mode to get the types/names
	p->setRecordInfo( t.recordName(), t.recordLabel() );
      }
      proxies.push_back( p );
      requests.insert( std::make_pair( t.tagName(), 0 ) );
    } catch ( const cond::Exception& e ){
      std::cout <<"ERROR: "<<e.what()<<std::endl;
    }
  }
  std::cout << proxies.size() << " tags successfully loaded." << std::endl;
  timex.interval("loading iovs");
  
  Time_t run = startRun;
  Time_t lumi = startLumi;
  Time_t ts = startTs;

  if (nThrF > 1) session.transaction().commit();

  tbb::task_scheduler_init init( nThrF );
  std::vector<std::shared_ptr<FetchWorker> > tasks;

  std::string payloadTypeName;
  for( auto p: proxies ){
      payloadTypeName = p->payloadType();
      // ignore problematic ones for now
      if ( (payloadTypeName == "SiPixelGainCalibrationOffline")  // 2 * 133 MB !!!
	   ) { 
	std::cout << "WARNING: Ignoring problematic payload of type " << payloadTypeName << std::endl;
	continue;
      }

      if (nThrF > 1) {
        auto fw = std::make_shared<FetchWorker>(connPool, connect, p, (std::map<std::string,size_t> *) &requests,
							    run, lumi, ts);
	tasks.push_back(fw);
      } else {
	bool loaded = false;
	time::TimeType ttype = p->timeType();
	auto r = requests.find( p->tag() );
	try{
	  if( ttype==runnumber ){
	    p->get( run, hasDebug() );	
	    r->second++;
	  } else if( ttype==lumiid ){
	    p->get( lumi, hasDebug() );
	    r->second++;
	  } else if( ttype==timestamp){
	    p->get( ts, hasDebug() );
	    r->second++;
	  } else {
	    std::cout <<"WARNING: iov request on tag "<<p->tag()<<" (timeType="<<time::timeTypeName(p->timeType())<<") has been skipped."<<std::endl;
	  }
	  timex.fetchInt(p->getBufferSize()); // keep track of time vs. size
	} catch ( const cond::Exception& e ){
	  std::cout <<"ERROR:"<<e.what()<<std::endl;
	}
      } // end else (single thread)
  }

  tbb::parallel_for_each(tasks.begin(),tasks.end(),invoker<std::shared_ptr<FetchWorker> >() );

  std::cout << "global counter : " << fooGlobal << std::endl;

  if (nThrF == 1) session.transaction().commit();
  // session.transaction().commit();

  timex.interval("loading payloads");

  size_t totBufSize = 0;
  for( auto p: proxies ){
      totBufSize += p->getBufferSize();
  }
  std::cout << "++> total buffer size used : " << totBufSize << std::endl;

  std::vector<std::shared_ptr<void> > payloads;
  payloads.resize(400); //-todo: check we don't have more payloads than that !!

  std::shared_ptr<void> payloadPtr;

  tbb::task_scheduler_init initD( nThrD );
  std::vector<std::shared_ptr<DeserialWorker> > tasksD;

  timex.interval("setup deserialization");

  int nEmpty = 0;
  int nBig = 0;
  int index = 0;
  for( auto p: proxies ){

///     if ( p->getBufferSize() == 0 ) { // nothing to do for these ... 
///       std::cout << "empty buffer found for " << p->payloadType() << std::endl;
///       nEmpty++;
///       continue;
///     }

    payloadTypeName = p->payloadType();

    // ignore problematic ones for now
    if ( (payloadTypeName == "SiPixelGainCalibrationForHLT")
	 or (payloadTypeName == "SiPixelGainCalibrationOffline")  // 2 * 133 MB !!!
	 or (payloadTypeName == "DTKeyedConfig") 
	 or (payloadTypeName == "std::vector<unsigned long long>") 
	 or (payloadTypeName == "  AlignmentSurfaceDeformations")
	 // only in root for now:
	 or (payloadTypeName == "PhysicsTools::Calibration::MVAComputerContainer")
	 or (payloadTypeName == "PhysicsTools::Calibration::MVAComputerContainer")
	 or (payloadTypeName == "PhysicsTools::Calibration::MVAComputerContainer")
	 or (payloadTypeName == "PhysicsTools::Calibration::MVAComputerContainer")
	 ) { 
      std::cout << "INFO: Ignoring payload of type " << payloadTypeName << std::endl;
      continue;
    }
    
    if (nThrD > 1) {
      auto dw = std::make_shared<DeserialWorker>(p, payloads[index]);
      tasksD.push_back(dw); 
    } else { // single tread only
       try {
	 std::pair<std::string, std::shared_ptr<void> > result = fetchOne( payloadTypeName, p->getBuffer(), p->getStreamerInfo(), payloadPtr);
           payloads.push_back(result.second);
       } catch ( const cond::Exception& e ){
           std::cout << "\nERROR (cond): " << e.what() << std::endl;
           std::cout << "for payload type name: " << payloadTypeName << std::endl;
       } catch ( const std::exception& e ){
           std::cout << "\nERROR (boost/std): " << e.what() << std::endl;
           std::cout << "for payload type name: " << payloadTypeName << std::endl;
       }
       timex.deserInt(p->getBufferSize()); // keep track of time vs. size
    } // single-thread
    index++; // increment index into payloads
  }
  std::cout << std::endl;

  tbb::parallel_for_each(tasksD.begin(),tasksD.end(),invoker<std::shared_ptr<DeserialWorker> >() );
 
  timex.interval("deserializing payloads");

  std::cout << "global counter : " << fooGlobal << std::endl;
  std::cout << "found   " << nEmpty << " empty payloads while deserialising " << std::endl;

  std::cout <<std::endl;
  std::cout <<"*** End of job."<<std::endl;
  std::cout <<"*** GT: "<<gtag<<" Tags:"<<gt.size()<<" Loaded:"<<proxies.size()<<std::endl;
  std::cout<<std::endl;
  for( auto p: proxies ){
    auto r = requests.find( p->tag() );
    if( verbose ){
      std::cout <<"*** Tag: "<<p->tag()<<" Requests processed:"<<r->second<<" Queries:"<< p->numberOfQueries() <<std::endl;
      const std::vector<std::string>& hist = p->history();
      for( auto e: p->history() ) std::cout <<"    "<<e<<std::endl;
    }
  }

  // only for igprof checking of live mem:
  // ::exit(0);

  timex.interval("postprocessing ... ");
  timex.showIntervals();
  
  if ( nThrF == 1) {
    std::ofstream ofs("fetchInfo.txt");
    timex.showFetchInfo(ofs);
    std::ofstream ofs2("sizeInfo.txt");
    for ( auto p: proxies ) {
      ofs2 << p->payloadType() << "[" << p->recName() << ":" << p->recLabel() << "]" << " : " << p->getBufferSize() << std::endl;
    }
  }
  if ( nThrD == 1) {
    std::ofstream ofs1("deserializeInfo.txt");
    timex.showDeserInfo(ofs1);
  }
  
  return 0;
}