Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-25 08:29:08

0001 #ifndef MACRO_GETENTRIES_C
0002 #define MACRO_GETENTRIES_C
0003 
0004 #include <frog/FROG.h>
0005 #include <ffaobjects/SyncObjectv1.h>
0006 
0007 R__LOAD_LIBRARY(libFROG.so)
0008 R__LOAD_LIBRARY(libffaobjects.so)
0009 
0010 void GetEntriesAndEventNr(const std::string &file)
0011 {
0012   gSystem->Load("libFROG.so");
0013   gSystem->Load("libg4dst.so");
0014   // prevent root to start gdb-backtrace.sh
0015   // in case of crashes, it hangs the condor job
0016   for (int i = 0; i < kMAXSIGNALS; i++)
0017   {
0018      gSystem->IgnoreSignal((ESignals)i);
0019   }
0020   FROG *fr = new FROG();
0021   TFile *f = TFile::Open(fr->location(file));
0022   cout << "Getting events for " << file << endl;
0023   TTree *T = (TTree *) f->Get("T");
0024   if (! T)
0025   {
0026     cout << "Number of Entries: -2" << endl;
0027   }
0028   else
0029   {
0030     cout << "Number of Entries: " <<  T->GetEntries() << endl;
0031   }
0032   long lastEvent = -1;
0033   long firstEvent = -1;
0034   if (T) // this makes only sense if we have a T TTree
0035   {
0036     SyncObjectv1 *sync {nullptr};
0037     T->SetBranchAddress("DST#Sync",&sync);
0038     T->GetEntry(0);
0039     if (sync)
0040     {
0041       firstEvent=sync->EventNumber();
0042     }
0043     T->GetEntry(T->GetEntries()-1);
0044     if (sync)
0045     {
0046       lastEvent=sync->EventNumber();
0047     }
0048   }
0049   cout << "First event number: " << firstEvent << endl;
0050   cout << "Last event number: " << lastEvent << endl;
0051 }
0052 #endif