Fork me on GitHub

Changeset 5c257a5 in git for readers/DelphesCMSFWLite.cpp


Ignore:
Timestamp:
Jul 2, 2021, 3:36:53 PM (3 years ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
1ad8eca
Parents:
910bd98 (diff), 0799cd1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Michele Selvaggi <michele.selvaggi@…> (07/02/21 15:36:53)
git-committer:
GitHub <noreply@…> (07/02/21 15:36:53)
Message:

Merge pull request #100 from jmhogan/master

Implement max/skipEvents in CMSFWLite reader

File:
1 edited

Legend:

Unmodified
Added
Removed
  • readers/DelphesCMSFWLite.cpp

    r910bd98 r5c257a5  
    311311  DelphesFactory *factory = 0;
    312312  TObjArray *allParticleOutputArray = 0, *stableParticleOutputArray = 0, *partonOutputArray = 0;
    313   Int_t i;
     313  Int_t i, maxEvents, skipEvents;
    314314  Long64_t eventCounter, numberOfEvents;
    315315  Bool_t firstEvent = kTRUE;
     
    353353    confReader = new ExRootConfReader;
    354354    confReader->ReadFile(argv[1]);
     355   
     356    maxEvents = confReader->GetInt("::MaxEvents", 0);
     357    skipEvents = confReader->GetInt("::SkipEvents", 0);
     358   
     359    if(maxEvents < 0)
     360    {
     361      throw runtime_error("MaxEvents must be zero or positive");
     362    }
     363   
     364    if(skipEvents < 0)
     365    {
     366      throw runtime_error("SkipEvents must be zero or positive");
     367    }
    355368
    356369    modularDelphes = new Delphes("Delphes");
     
    391404      treeWriter->Clear();
    392405
    393       for(event.toBegin(); !event.atEnd() && !interrupted; ++event)
     406      for(event.toBegin(); !event.atEnd() && !interrupted && (maxEvents <= 0 || eventCounter-skipEvents < maxEvents); ++event)
    394407      {
    395         ConvertInput(event, eventCounter, branchEvent, branchWeight, factory,
    396           allParticleOutputArray, stableParticleOutputArray, partonOutputArray, firstEvent);
    397         modularDelphes->ProcessTask();
    398 
    399         firstEvent = kFALSE;
    400 
    401         treeWriter->Fill();
    402 
    403         modularDelphes->Clear();
    404         treeWriter->Clear();
     408        if(eventCounter > skipEvents){
     409          ConvertInput(event, eventCounter, branchEvent, branchWeight, factory,
     410            allParticleOutputArray, stableParticleOutputArray, partonOutputArray, firstEvent);
     411          modularDelphes->ProcessTask();
     412
     413          firstEvent = kFALSE;
     414
     415          treeWriter->Fill();
     416
     417          modularDelphes->Clear();
     418          treeWriter->Clear();
     419        }
    405420
    406421        progressBar.Update(eventCounter, eventCounter);
Note: See TracChangeset for help on using the changeset viewer.