Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 void triggernames_multi_cint()
0020 {
0021   std::vector<std::string> files1;
0022   files1.push_back(std::string("prodmerge.root"));
0023 
0024   std::vector<std::string> files2;
0025   files2.push_back(std::string("prod1.root"));
0026   files2.push_back(std::string("prod2.root"));
0027 
0028   fwlite::MultiChainEvent ev(files1, files2);
0029   fwlite::Handle<edm::TriggerResults> hTriggerResults;
0030   
0031   int iEvent = 0;
0032   for (ev.toBegin(); ! ev.atEnd(); ++ev) {
0033     ++iEvent;
0034     hTriggerResults.getByLabel(ev,"TriggerResults","","TEST");
0035     edm::TriggerNames const&  triggerNames = ev.triggerNames(*hTriggerResults);
0036 
0037     std::vector<std::string> const& names = triggerNames.triggerNames();
0038     for (unsigned i = 0; i < triggerNames.size(); ++i) {
0039       std::cout << names[i] << "  " << triggerNames.triggerName(i) << std::endl;
0040     }
0041     std::cout << "size = " << triggerNames.size() << std::endl;
0042     std::cout << "index for p = " << triggerNames.triggerIndex("p") << std::endl;
0043     std::cout << "index for p1 = " << triggerNames.triggerIndex("p1") << std::endl;
0044     std::cout << "index for p2 = " << triggerNames.triggerIndex("p2") << std::endl;
0045 
0046     if (iEvent == 1) {
0047       if (triggerNames.size() != 3U ||
0048           names[0] != "p" ||
0049           names[1] != "p1" ||
0050           names[2] != "p2" ||
0051           triggerNames.triggerName(0) != "p" ||
0052           triggerNames.triggerName(1) != "p1" ||
0053           triggerNames.triggerName(2) != "p2" ||
0054           triggerNames.triggerIndex("p") != 0 ||
0055           triggerNames.triggerIndex("p1") != 1 ||
0056           triggerNames.triggerIndex("p2") != 2) {
0057     std::cout << "Trigger names do match expected values\n";
0058     std::cout << "In script triggernames_multi_cint.C\n";
0059         exit(1);
0060       }
0061     }
0062   }
0063 }