create the main event TTree ...
now onto the business of deleting the chains ...
105 std::set<std::string> require_chains;
106 std::vector<std::string> rchains;
108 bool require =
false;
109 bool deleting =
false;
111 std::string
outfile =
"tree.root";
119 bool roi_filter =
false;
123 for (
int i=1 ;
i<
argc ;
i++ ) {
129 if (
arg.find(
'-')!=0 ) {
130 if ( !deleting &&
infile!=
"" ) {
132 require_chains.insert(
argv[
i]);
133 rchains.push_back(
argv[
i]);
139 std::cerr <<
"more than one file specified: " <<
arg << std::endl;
147 else if (
arg==
"-o" ||
arg==
"--output" ) {
149 else return usage(-1);
151 else if (
arg==
"-r" ||
arg==
"--require" ) {
153 std::cerr <<
"cannot require and delete chains" << std::endl;
158 else if (
arg==
"-d" ||
arg==
"--delete" ) {
160 std::cerr <<
"cannot require and delete chains" << std::endl;
165 else if (
arg==
"--pt" ) {
167 else return usage(-1);
171 else if (
arg==
"-f" ||
arg==
"--force" )
force =
true;
172 else if (
arg==
"--roi" ) {
force=
true; roi_filter =
true; }
175 std::cerr <<
"more than one file specified: " <<
arg << std::endl;
181 std::cout <<
"required chains " << require_chains << std::endl;
183 if ( require_chains.size()>0 ) require =
true;
185 if ( !
force && require_chains.size()==0 ) {
186 std::cout <<
"no chains requested - not doing anything" << std::endl;
190 std::cout <<
"chains: " << rchains << std::endl;
193 std::cout <<
"skim::start " <<
time_str() << std::endl;
196 if ( require ) std::cout <<
"require chains " << require_chains << std::endl;
197 if ( deleting ) std::cout <<
"delete chains " << require_chains << std::endl;
201 std::cerr <<
"no files specified" << std::endl;
205 std::cout <<
"reading from file: " <<
infile << std::endl;
206 std::cout <<
"writing to file: " <<
outfile << std::endl;
213 std::cout <<
"opening outfile: " <<
outfile << std::endl;
221 TTree *
tree =
new TTree(
"tree",
"tree");
223 tree->Branch(
"TIDA::Event",
"TIDA::Event", &
h, 6400, 1);
235 TFile finput(
infile.c_str() );
236 if (!finput.IsOpen()) {
237 std::cerr <<
"Error: could not open output file" << std::endl;
250 TTree*
data = (TTree*)finput.Get(
"tree");
254 data->SetBranchAddress(
"TIDA::Event",&track_iev);
260 std::cout <<
"input has " <<
entries <<
" events" << std::endl;
262 std::string cck =
"|/-\\";
268 std::cout <<
"processing ..." << std::endl;
270 for (
unsigned int i=0;
i<
data->GetEntries() ;
i++ ) {
272 if (
verbose ) std::cout <<
"event " <<
i;
284 double eventsps = 1000*
i/
t;
286 std::printf(
"\r%c %6.2lf %% time: %6.2lf s remaining %6.2lf s (%u at %5.2lf ps) ",
287 cck[ii%4], ((1000*(
i+1)/
entries)*0.1),
t*0.001, est*0.001,
i, eventsps );
303 *track_ev = *track_iev;
310 if (
verbose ) std::cout <<
"----------------------------------------\n\tN chains " << track_ev->
size() <<
" -> ";
320 for ( ; citr!=
chains.end() ; ++citr ) {
322 if ( citr->name().find(
"HLT")==std::string::npos )
continue;
325 for (
unsigned j=rchains.size() ; j-- ; ) {
326 if ( rchains[j].
find(
"HLT")==std::string::npos )
continue;
327 if ( citr->name().find(rchains[j])!=std::string::npos ) {
329 if (
verbose ) std::cout <<
"keepin' " << citr->name() <<
" " << rchains[j] << std::endl;
337 if (
skip )
continue;
345 std::vector<std::string> chainnames = track_ev->
chainnames();
347 for (
size_t ic=0 ;
ic<chainnames.size() ;
ic++ ) {
355 if (
verbose &&
matched ) std::cout <<
"chain: " << chainnames[
ic] <<
"\t :: reg " << *
it <<
"\tmatched: " <<
matched << std::endl;
362 if (
verbose ) std::cout << track_ev->
size() << std::endl;
365 if ( roi_filter ||
ptmin>0 ) {
369 std::vector<std::string> chainnames = track_ev->
chainnames();
373 for (
size_t ic=chainnames.size() ;
ic-- ; ) {
374 if ( chainnames[
ic] ==
"Offline" ) {
386 std::vector<std::pair<double,double> > philims;
388 for ( ; citr!=
chains.end() ; ++citr ) {
389 if ( citr->name().find(
"HLT_")!=std::string::npos ) {
390 for (
size_t ir=0 ;
ir<citr->size() ;
ir++ ) {
393 for (
size_t isub=0 ; isub<roi.
size() ; isub++ ) {
394 philims.push_back( std::pair<double,double>( roi[isub]->phiMinus(), roi[isub]->phiPlus() ) );
397 else philims.push_back( std::pair<double,double>( roi.
phiMinus(), roi.
phiPlus() ) );
404 for (
size_t iroi=0 ; iroi<
offline->size() ; iroi++ ) {
406 std::vector<TIDA::Track>& tracks =
offline->rois()[iroi].tracks();
411 if ( std::fabs(
it->pT())<
ptmin ) { inc=
false; tracks.erase(
it ); }
413 if ( inc && roi_filter ) {
414 bool remove_track =
true;
415 for (
size_t isub=0 ; isub<philims.size() ; isub++ ) {
417 if ( philims[isub].
first < philims[isub].
second ) {
418 if (
it->phi()>=philims[isub].first &&
it->phi()<=philims[isub].second ) {
419 remove_track =
false;
424 if (
it->phi()>=philims[isub].first ||
it->phi()<=philims[isub].second ) {
425 remove_track =
false;
430 if ( remove_track ) { inc=
false; tracks.erase(
it ); }
443 if (
verbose ) std::cout <<
"writing event:\n" << *track_ev << std::endl;
452 const std::vector<TIDA::Track>& tracks =
chains[
ic].rois()[0].tracks();
454 for (
unsigned it=0 ;
it<tracks.size() ;
it++ ) {
455 h->Fill( tracks[
it].
pT()*0.001 );
471 std::printf(
"\r%c %6.2lf %% time: %6.2lf s\n",
472 cck[ii%4], 100.,
t*0.001 );
479 std::cout <<
"skim::done " <<
time_str() << std::endl;
481 std::cout <<
"skim::events in: " << ev_in << std::endl;
482 std::cout <<
"skim::events out: " << ev_out << std::endl;