not sure what this is really doing now .... was originally for consistency with the 30 GeV vtx tracking
131 bool allflag =
false;
133 std::vector<std::string>
keys;
138 std::vector<std::string> Keys;
141 std::vector<std::string>
veto;
143 std::string creturn =
"";
146 bool usecounts =
false;
147 bool excluded =
false;
151 std::string afile =
"";
152 std::string aslice =
"";
154 double userthreshold = 100;
160 for (
int i=1 ;
i<
argc ;
i++ ) {
162 if (
arg==
"-all" ) allflag =
true;
164 else if (
arg==
"-t" ||
arg==
"--threshold" ) {
168 else if (
arg==
"-cr" ) creturn =
"\n";
169 else if (
arg==
"-c" ||
arg==
"--counts" ) usecounts =
true;
170 else if (
arg==
"-k" ) {
180 else if (
arg==
"-K" ) {
186 Keys.push_back(
argv[
i]);
190 else if (
arg==
"--veto" ) {
194 else if (
arg==
"-n" ) {
199 else if (
arg==
"-x" ||
arg==
"--excluded" ) excluded =
true;
200 else if (
arg==
"-s" ||
arg==
"--sig" ) {
207 if ( afile==
"" ) afile=
arg;
208 else if ( aslice==
"" ) aslice=
arg;
215 std::ifstream
file( afile.c_str() );
217 std::vector<std::vector<std::string> > block(1,std::vector<std::string>() );
221 std::vector<int> position(1, 0);
225 std::string
slice =
"/" + aslice +
'/';
227 std::string rawslice = aslice;
229 std::map<std::string, std::string>
chains;
231 typedef std::map<std::string, std::string> chain_map;
232 chains.insert( chain_map::value_type(
"Electron",
"_e" ) );
233 chains.insert( chain_map::value_type(
"Egamma",
"_e" ) );
234 chains.insert( chain_map::value_type(
"Muon",
"_mu" ) );
235 chains.insert( chain_map::value_type(
"Tau",
"_tau" ) );
236 chains.insert( chain_map::value_type(
"Bjet",
"_j" ) );
237 chains.insert( chain_map::value_type(
"FTK",
"_FTK" ) );
238 chains.insert( chain_map::value_type(
"BjetVtx",
"" ) );
240 chains.insert( chain_map::value_type(
"EgammaPurity",
"_e" ) );
241 chains.insert( chain_map::value_type(
"MuonPurity",
"_mu" ) );
242 chains.insert( chain_map::value_type(
"TauPurity",
"_tau" ) );
243 chains.insert( chain_map::value_type(
"BjetPurity",
"_j" ) );
244 chains.insert( chain_map::value_type(
"FTKPurity",
"" ) );
248 chain_map::const_iterator itr =
chains.find( rawslice );
250 if ( itr==
chains.end() ) {
251 std::cerr <<
"can not process type " << rawslice << std::endl;
255 std::string
tag =
"";
256 if ( itr->second !=
"" ) {
261 std::vector<threshold> thresholds;
273 std::vector<std::string> expl =
split(
line );
277 unsigned expected_size = 0;
288 if ( expl[
index] ==
"IDMon" ) expected_size = 6-
diff;
289 else if ( expl[
index] ==
"TRIDT" ) {
290 if ( expl[
index+2] ==
"Expert" && !purity ) expected_size = 7-
diff;
291 else if ( expl[
index+2] ==
"Shifter" &&
contains(expl[3],
"etVtx") ) expected_size = 7-
diff;
292 else if ( expl[
index+3] ==
"Fullscan" && purity ) expected_size = 7-
diff;
293 else if ( expl[
index+2] ==
"Shifter" || purity ) expected_size = 6-
diff;
295 std::cerr <<
"unknown HIST type " << expl[
index+2] << std::endl;
300 std::cerr <<
"unknown HIST type " << expl[
index] <<
" (2)" << std::endl;
304 if ( expl.size() > expected_size ) {
306 int counts =
std::atof(expl[expected_size].c_str());
312 if ( counts >= userthreshold ) {
314 std::string
tmp = expl[expected_size-2];
316 if ( !
tag.empty() ) {
319 size_t pos =
tmp.find(
'_');
328 if ( Keys.size()>0 )
for (
size_t ik=Keys.size() ; ik-- ; )
condition &=
contains( expl[expected_size-2], Keys[ik] ) ||
contains( expl[expected_size-1], Keys[ik] );
339 int counts_var = counts;
342 counts_var =
int(thresh_var);
346 if ( expected_size >= 2 ) {
348 threshold t( thresh_var,
it++, expl[expected_size-2], expl[expected_size-1], counts_var );
356 thresholds.push_back(
t );
366 if ( usecounts )
sort( thresholds.rbegin(), thresholds.rend() );
367 else sort( thresholds.begin(), thresholds.end() );
380 for (
size_t i=0 ;
i<thresholds.size() ;
i++ )
id.push_back(
i);
383 else if ( usecounts ) {
387 for (
size_t i=0 ;
i<thresholds.size() &&
i<
n ;
i++ )
id.push_back(
i);
394 std::vector<unsigned> ind(
n,0);
396 if ( thresholds.size() == 0 ) {
397 std::cerr <<
"no valid thresholds found" << std::endl;
402 if ( rawslice==
"Bjet" ) {
403 for (
size_t i=0 ;
i<thresholds.size() ;
i++ ) {
407 if ( thresholds[
i].
thresh > 30 )
break;
411 for (
size_t i=thresholds.size() ;
i-- ; ) {
413 if ( thresholds[
i].counts > 0.05*thresholds[ind[0]].counts ) {
421 for (
unsigned it=1 ;
n>0 &&
it<
n-1 ;
it++ ) {
426 double f =
it*1.0/(
n-1);
432 ind[
it] =
int(
f*ind[
n-1]+(1-
f)*ind[0] );
436 double delta = cthresh - thresholds[ind[
it]].thresh;
438 double R2 = delta*delta;
440 for (
size_t i=ind[0]+1 ;
i<ind[
n-1]-1 ;
i++ ) {
441 double delta = cthresh - thresholds[
i].thresh;
443 double R2_ = delta*delta;
453 id.push_back( ind[0] );
456 for (
unsigned i=1 ;
i<
n ;
i++ ) {
457 if ( ind[
i]!=ind[
i-1] )
id.push_back( ind[
i] );
464 for (
size_t i=0 ;
i<
id.size() ;
i++ ) {
465 if (
verbose ) std::cout <<
" " <<
fullpath << thresholds[
id[
i]].chain <<
"/" << thresholds[
id[
i]].key << creturn;
466 else std::cout <<
" " << thresholds[
id[
i]].chain <<
"_" << thresholds[
id[
i]].key << creturn;