Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:27

0001 #include <vector>
0002 #include <TFile.h>
0003 using namespace std;
0004 
0005 #if defined(__CINT__) && !defined(__MAKECINT__)
0006 class loadFWLite {
0007    public:
0008       loadFWLite() {
0009          gSystem->Load("libFWCoreFWLite");
0010          FWLiteEnabler::enable();
0011       }
0012 };
0013 
0014 static loadFWLite lfw;
0015 #endif
0016 
0017 #include "DataFormats/FWLite/interface/Handle.h"
0018 
0019 #if !defined(__CINT__) && !defined(__MAKECINT__)
0020 #include "DataFormats/TestObjects/interface/ThingCollection.h"
0021 #endif
0022 
0023 void event_looping_cint()
0024 {
0025 TFile f("good_a.root");
0026 fwlite::Event e(&f);
0027 
0028 int i =0;
0029 int returnValue = 0;
0030 for( ;e.isValid();++e,++i) {
0031   fwlite::Handle<vector<edmtest::Thing> > pThing;
0032   //pThing.getByLabel(e,"Thing","","TEST"); //WORKS
0033   pThing.getByLabel(e,"Thing");
0034   
0035   for(int i=0; i!=pThing.ref().size();++i) {
0036     cout <<pThing.ref().at(i).a<< " ";
0037   }
0038   cout << endl;
0039 }  
0040 if (i==0) {
0041   cout <<"First loop failed!"<<endl;
0042   returnValue = 1;
0043 }
0044 e.toBegin();
0045 
0046 i=0;
0047 for( ;e;++e,++i) { 
0048 }
0049 
0050 if (i==0) {
0051   cout <<"Second loop failed!"<<endl;
0052   returnValue = 1;
0053 }
0054 
0055 i=0;
0056 for(e.toBegin(); !e.atEnd();++e,++i) {
0057    fwlite::Handle<vector<edmtest::Thing> > pThing;
0058    //pThing.getByLabel(e,"Thing","","TEST"); //WORKS
0059    pThing.getByLabel(e,"Thing");
0060    
0061    for(int i=0; i!=pThing.ref().size();++i) {
0062       cout <<pThing.ref().at(i).a<<" ";
0063    }
0064    cout << endl;
0065 
0066    //DOES NOT WORK
0067    //for(vector<edmtest::Thing>::const_iterator it = pThing.data()->begin(); it != pThing.data()->end();++it) {
0068    //   cout <<(*it).a<<endl;
0069    //}
0070 }
0071 if (i==0) {
0072   cout <<"Third loop failed!"<<endl;
0073   returnValue = 1;
0074 }
0075 exit(returnValue);
0076 }