121{
  124 
  127  string         selectFile;
  130 
  131  try { 
  132 
  133    JParser<> zap(
"Example program to select events from DST files.");
 
  134    
  136    zap[
'n'] = 
make_field(numberOfEvents)       = JLimit::max();
 
  138                          "<run>  <frame index>  <trigger counter>"\
  139                          " (one header line)") = "";
  142 
  143    zap(argc, argv);
  144  }
  145  catch(const exception &error) {
  146    FATAL(error.what() << endl);
 
  147  }
  148 
  149  gErrorIgnoreLevel = kFatal;
  150 
  151  inputFile = getFilenames(inputFile);
  152 
  154 
  155  if (selectFile != "") {
  156 
  157    ifstream in(selectFile.c_str());
  158 
  159    in.ignore(numeric_limits<streamsize>::max(), '\n');
  160    
  161    for (JTag tag; in >> tag; ) {
  162      selection.insert(tag);
  163    }
  164 
  165    in.close();
  166  }
  167 
  168  TFile* out = TFile::Open(
outputFile.c_str(), 
"CREATE");
 
  169  
  170  if (out == NULL || ! out->IsOpen()) {
  172  }
  173 
  176 
  177  for (vector<string>::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) {
  178    
  179    TFile* in = TFile::Open(file_name->c_str(), "EXISTS");
  180 
  181    if (in != NULL && in->IsOpen()) {
  182    
  183      TIter iter(in->GetListOfKeys(), kIterBackward);
  184 
  185      for (TKey* key; (
key = (TKey*) iter.Next()) != NULL; ) {
 
  186 
  187        TKey* p = dynamic_cast<TKey*>(in->GetListOfKeys()->Before(key));
  188 
  189        if (p == NULL || strcmp(
key->GetName(), p->GetName()) != 0) {                     
 
  190 
  191          TTree* t1 = 
dynamic_cast<TTree*
>(
key->ReadObj());
 
  192 
  193          if (t1 != NULL) {
  194 
  195            TChain* q = NULL;
  196            
  198 
  199              if (strcmp((*i)->GetName(), t1->GetName()) == 0) {
  200 
  201                q = *i;
  202 
  203                break;
  204              }
  205            }
  206 
  207            if (q == NULL) {
  208              input.push_back(q = new TChain(t1->GetName()));
  209            }
  210 
  211            q->Add(file_name->c_str());
  212          }
  213        }
  214      }
  215    }
  216  }
  217 
  218  
  219 
  220  TChain* tm = NULL;
  221 
  223 
  225 
  226      tm = *i;
  227 
  228      break;
  229    }
  230  }
  231 
  232  if (tm == NULL) {
  234  }
  235    
  237 
  238  tm->GetEntries();                                                  
  240      
  241  
  242      
  244    if (tm->GetEntries() == (*i)->GetEntries())
  245      ++i;
  246    else
  247      i = input.erase(i);
  248  }
  249      
  250  out->cd();
  251 
  253    output.push_back((*i)->GetTree()->CloneTree(0));
  254  }
  255 
  257 
  258    STATUS(
"event: " << setw(10) << i << 
'\r'); 
DEBUG(endl);
 
  259 
  260    tm->GetEntry(i);
  261 
  263 
  264    DEBUG(
"tag " << tag << 
' ' << (selection.empty() || selection.count(tag)) << endl);
 
  265    
  266    if (selection.empty() || selection.count(tag)) {
  267        
  268      for (size_t m = 0; m != input.size(); ++m) {
  269        input [m]->GetEntry(i);
  270        output[m]->Fill();
  271      }
  272    }
  273  }
  275 
  276  out->Write();
  277  out->Close();
  278}
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
Utility class to parse command line options.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
static const char *const TTREE_OFFLINE_EVENT
ROOT TTree name.
 
static const char *const TBRANCH_OFFLINE_EVENT
ROOT TBranch name.
 
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
 
int frame_index
from the raw data
 
int run_id
DAQ run identifier.
 
ULong64_t trigger_counter
trigger counter
 
Auxiliary class for defining the range of iterations of objects.