Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-21 05:46:28

0001 #if defined(__CINT__) && !defined(__MAKECINT__)
0002 class loadFWLite {
0003 public:
0004   loadFWLite() {
0005     gSystem->Load("libFWCoreFWLite");
0006     FWLiteEnabler::enable();
0007   }
0008 };
0009 
0010 static loadFWLite lfw;
0011 #endif
0012 
0013 #include "DataFormats/FWLite/interface/Handle.h"
0014 
0015 #include <string>
0016 #include <vector>
0017 #include <iostream>
0018 
0019 int triggernames_cint() {
0020   // TFile f1("prodmerge.root");
0021   // fwlite::Event ev(&f1);
0022 
0023   std::vector<std::string> files;
0024   files.push_back(std::string("prodmerge.root"));
0025   fwlite::ChainEvent ev(files);
0026 
0027   fwlite::Handle<edm::TriggerResults> hTriggerResults;
0028 
0029   int iEvent = 0;
0030   for (ev.toBegin(); !ev.atEnd(); ++ev) {
0031     ++iEvent;
0032     hTriggerResults.getByLabel(ev, "TriggerResults", "", "TEST");
0033     edm::TriggerNames const& triggerNames = ev.triggerNames(*hTriggerResults);
0034 
0035     std::vector<std::string> const& names = triggerNames.triggerNames();
0036     for (unsigned i = 0; i < triggerNames.size(); ++i) {
0037       std::cout << names[i] << "  " << triggerNames.triggerName(i) << std::endl;
0038     }
0039     std::cout << "size = " << triggerNames.size() << std::endl;
0040     std::cout << "index for p = " << triggerNames.triggerIndex("p") << std::endl;
0041     std::cout << "index for p1 = " << triggerNames.triggerIndex("p1") << std::endl;
0042     std::cout << "index for p2 = " << triggerNames.triggerIndex("p2") << std::endl;
0043 
0044     if (iEvent == 1) {
0045       if (triggerNames.size() != 3U || names[0] != "p" || names[1] != "p1" || names[2] != "p2" ||
0046           triggerNames.triggerName(0) != "p" || triggerNames.triggerName(1) != "p1" ||
0047           triggerNames.triggerName(2) != "p2" || triggerNames.triggerIndex("p") != 0 ||
0048           triggerNames.triggerIndex("p1") != 1 || triggerNames.triggerIndex("p2") != 2) {
0049         std::cout << "Trigger names do match expected values\n";
0050         std::cout << "In script triggernames_cint.C\n";
0051         return 1;
0052       }
0053     }
0054 
0055     /*
0056     // THIS DOES NOT WORK, I do not know why, but it's
0057     // probably something to do with dictionaries for the 
0058     // std::vector<std:string>::const_iterator subclass.
0059     // Or CINT just cannot handle such templated beasts.  I do not know.
0060     for (std::vector<std::string>::const_iterator iName = names.begin(),
0061        iEnd = names.end();
0062          iName != iEnd; ++iName) {
0063       std::cout << *iName << std::endl;
0064     }
0065     */
0066   }
0067   return 0;
0068 }