Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:49

0001 #include "TChain.h"
0002 #include "TTreeFormula.h"
0003 #include "TTreeCache.h"
0004 #include "vector"
0005 #include "iostream"
0006 
0007 void GetEntriesMulti(TChain *events, const char* selection, Int_t ncandscut, std::vector<Long64_t>& pass) {
0008   Long64_t rows = 0;
0009   Long64_t entry = 0;
0010   Int_t cands = 0;
0011   Int_t ndata = 0;
0012   Int_t j = 0;
0013   Int_t currentTree = 0;
0014   vector<Long64_t> entries;
0015   Long64_t nentries = events->GetEntries();
0016   TTreeFormula *selFormula= new TTreeFormula("Selection", selection, events);
0017   for (entry = 0; entry < nentries; entry++) {
0018     events->LoadTree(entry);
0019     selFormula->UpdateFormulaLeaves();
0020     selFormula->ResetDimensions();
0021     if (currentTree < events->GetTreeNumber() && entry != 0) {
0022       cout<<rows<<endl;
0023       pass.push_back(rows);
0024       rows = 0;
0025       currentTree = events->GetTreeNumber();
0026     }
0027     ndata = selFormula->GetNdata();
0028     cands = 0;
0029     if (selFormula) {
0030       // Always call EvalInstance(0) to insure the loading
0031       // of the branches.
0032       if (ndata == 0) selFormula->EvalInstance(0);
0033       else {
0034     j = 0;
0035     for (j = 0; j < ndata; j++) {
0036       if (selFormula->EvalInstance(j)) {
0037         ++cands;
0038       }
0039     }
0040       }
0041     }
0042     if (cands >= ncandscut) {
0043       ++rows;
0044     }
0045   }
0046   cout<<rows<<endl<<endl;
0047   pass.push_back(rows);
0048   delete selFormula;
0049 }