/************************************************ // Name : Test Module for EffInfo // Created : Thu Oct 27 15:30:41 CDT 2005 // Author : Venkat // Modified: *************************************************/ #include "eff_utils/EffInfo.hpp" #include #include #include using namespace eff_utils; using namespace std; int main() { // Testing the Set methods in EffInfo class EffInfo myspec; // Default object with no attributes // EffInfo cout << "Testing EffInfo set methods\n"; myspec.EffType("Binned"); cout << " EffType : Binned\n"; myspec.EffName("PtvsEta"); cout << " EffName : PtvsEta\n"; myspec.EffVersion(2); cout << " EffVersion : 2\n"; // create a vector of strings to test EffVarNames method vector test_var; test_var.push_back("pt"); test_var.push_back("eta"); test_var.push_back("phi"); myspec.EffVarNames(test_var); cout << " EffVarNames : "; for(int j=0 ; j<3; j++) cout << test_var[j] << ", "; cout << endl; // Obj Info cout << "\nTesting ObjInfo set methods\n"; myspec.ObjType("Electron"); cout << " ObjType : Electron\n"; myspec.ObjQuality("Loose"); cout << " ObjQuality : Loose\n"; myspec.ObjVersion(3); cout << " ObjVersion : 3\n"; // Meta data cout << "\nTesting Metadata set methods\n"; myspec.D0NoteID(3456); cout << " D0NoteID : 3456\n"; myspec.RunRangeLow(123456); cout << " RunRangeLow : 123456\n"; myspec.RunRangeHigh(12345); cout << " RunRangeHigh : 12345\n"; // SetEntry method vector user_var; user_var.push_back("my"); user_var.push_back("own"); user_var.push_back("entry"); cout << "\nTesting setEntry method\n"; myspec.setEntry("UserEntry",user_var); cout << "UserEntry: my own entry \n"; // Testing the get methods in EffInfo class cout << "\nTesting EffInfo get methods\n"; cout << " EffType : " << myspec.EffType() << endl; cout << " EffName : " << myspec.EffName() << endl; cout << " EffVersion : " << myspec.EffVersion() << endl; cout << "\nTesting ObjInfo get methods\n"; cout << " ObjType : " << myspec.ObjType() << endl; cout << " ObjQuality : " << myspec.ObjQuality() << endl; cout << " ObjVersion : " << myspec.ObjVersion() << endl; cout << "\nTesting Metadata get methods\n"; cout << " D0NoteID : " << myspec.D0NoteID() << endl; cout << " RunRangeLow : " << myspec.RunRangeLow() << endl; cout << " RunRangeHigh : " << myspec.RunRangeHigh() << endl; // GetEntry method cout << "\n Testing getEntry method with keyword \"UserEntry\" -- "; vector user_entry; bool itest = myspec.getEntry("UserEntry",user_entry); cout << (itest == true ? " success \n" : " failed \n"); if(itest) { cout << " \"UserEntry\" keyword found -- " ; copy(user_entry.begin(), user_entry.end(), ostream_iterator(cout, " ")); cout << endl; } else { cout << " \"UserEntry\" keyword not found \n" ; } vector dummy_entry; cout << "\n Case senstive getEntry test with keyword \"userEntry\" -- "; itest = myspec.getEntry("userEntry",dummy_entry); cout << (itest == true ? " success \n" : " failed \n"); if(!itest) cout << " \"userEntry\" keyword not found \n" ; // Testing file name creator cout << "\nTesting Filename creator \n"; cout << myspec.MakeFileName() << endl; // Testing "<< operator to dump EffInfo object cout << "\n Testing << operator to dump EffInfo object\n"; cout << myspec << endl; // Testing addToEntry method cout << "\n Testing addToEntry method \n"; cout << myspec << endl; cout << "\nAdding more to \"UserEntry\" -- \"added these extra words\" \n"; myspec.addToEntry("UserEntry","added these extra words"); vector extra_entry; itest = myspec.getEntry("UserEntry",extra_entry); cout << (itest == true ? " success \n" : " failed \n"); if(itest) { cout << " \"UserEntry\" keyword found -- " ; copy(extra_entry.begin(), extra_entry.end(), ostream_iterator(cout, " ")); cout << endl; } else { cout << " \"UserEntry\" keyword not found \n" ; } return 0; }