Skip to content

Limiting the range of events for npanalysis

Currently you can specify the -L <arg> flag to npanalysis to limit the range of analyzed events from 0 -> <arg>. I am interested in also being able to specify the starting event too, i.e. allowing the analysis to start with some event other than event zero.

I've made a simple change to the NPOptionManager code (and npanalysis.cxx) adding a -F flag that specifies the beginning of the event loop (default is zero). Using this, the analysis goes from F -> F+L (with a check to not go past the end of the chain). This should fully maintain backward compatibility.

Before pushing I wanted to make sure it's an acceptable change to make, since it modifies the core parts of the package. Any thoughts?

I also changed the event loop variable to unsigned long, to minimize the chance that it overflows. It was unsigned int before, which is 32 bit on most systems (~4e9 event maximum), but could conceivably be 16 bit (~65k maximum).

Here's the relevant changes in case anyone wants to inspect.

  unsigned long first_entry = myOptionManager->GetFirstEntryToAnalyse(); // defaults to zero
  unsigned long nentries = Chain->GetEntries();
  if(nentries> myOptionManager->GetNumberOfEntryToAnalyse() && myOptionManager->GetNumberOfEntryToAnalyse()>0)
    nentries = myOptionManager->GetNumberOfEntryToAnalyse() ;
  if(nentries + first_entry > Chain->GetEntries()) {nentries = first_entry+Chain->GetEntries();}

(event loop):

 for (unsigned long i = first_entry ; i < nentries + first_entry; i++) {