Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#include <vector>
#include <TFile.h>
using namespace std;

#if defined(__CINT__) && !defined(__MAKECINT__)
class loadFWLite {
public:
  loadFWLite() {
    gSystem->Load("libFWCoreFWLite");
    FWLiteEnabler::enable();
  }
};

static loadFWLite lfw;
#endif

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/FWLite/interface/Event.h"
#include "FWCore/Utilities/interface/InputTag.h"

#if !defined(__CINT__) && !defined(__MAKECINT__)
#include "DataFormats/TestObjects/interface/ThingCollection.h"
#endif

int event_looping_consumes_cint() {
  TFile f("good_a.root");
  fwlite::Event e(&f);

  auto token = e.consumes<std::vector<edmtest::Thing>>(edm::InputTag("Thing"));

  int i = 0;
  int returnValue = 0;
  for (; e.isValid(); ++e, ++i) {
    edm::Handle<vector<edmtest::Thing>> pThing;
    e.getByToken(token, pThing);

    for (int i = 0; i != pThing->size(); ++i) {
      cout << pThing->at(i).a << " ";
    }
    cout << endl;
  }
  if (i == 0) {
    cout << "First loop failed!" << endl;
    returnValue = 1;
  }
  return returnValue;
}