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_cint()
0020 {
0021   // TFile f1("prodmerge.root");
0022   // fwlite::Event ev(&f1);
0023 
0024   std::vector<std::string> files;
0025   files.push_back(std::string("prodmerge.root"));
0026   fwlite::ChainEvent ev(files);
0027 
0028   fwlite::Handle<edm::TriggerResults> hTriggerResults;
0029   
0030   int iEvent = 0;
0031   for (ev.toBegin(); ! ev.atEnd(); ++ev) {
0032     ++iEvent;
0033     hTriggerResults.getByLabel(ev,"TriggerResults","","TEST");
0034     edm::TriggerNames const&  triggerNames = ev.triggerNames(*hTriggerResults);
0035 
0036     std::vector<std::string> const& names = triggerNames.triggerNames();
0037     for (unsigned i = 0; i < triggerNames.size(); ++i) {
0038       std::cout << names[i] << "  " << triggerNames.triggerName(i) << std::endl;
0039     }
0040     std::cout << "size = " << triggerNames.size() << std::endl;
0041     std::cout << "index for p = " << triggerNames.triggerIndex("p") << std::endl;
0042     std::cout << "index for p1 = " << triggerNames.triggerIndex("p1") << std::endl;
0043     std::cout << "index for p2 = " << triggerNames.triggerIndex("p2") << std::endl;
0044 
0045     if (iEvent == 1) {
0046       if (triggerNames.size() != 3U ||
0047           names[0] != "p" ||
0048           names[1] != "p1" ||
0049           names[2] != "p2" ||
0050           triggerNames.triggerName(0) != "p" ||
0051           triggerNames.triggerName(1) != "p1" ||
0052           triggerNames.triggerName(2) != "p2" ||
0053           triggerNames.triggerIndex("p") != 0 ||
0054           triggerNames.triggerIndex("p1") != 1 ||
0055           triggerNames.triggerIndex("p2") != 2) {
0056     std::cout << "Trigger names do match expected values\n";
0057     std::cout << "In script triggernames_cint.C\n";
0058         exit(1);
0059       }
0060     }
0061 
0062     /*
0063     // THIS DOES NOT WORK, I do not know why, but it's
0064     // probably something to do with dictionaries for the 
0065     // std::vector<std:string>::const_iterator subclass.
0066     // Or CINT just cannot handle such templated beasts.  I do not know.
0067     for (std::vector<std::string>::const_iterator iName = names.begin(),
0068        iEnd = names.end();
0069          iName != iEnd; ++iName) {
0070       std::cout << *iName << std::endl;
0071     }
0072     */
0073   }
0074 }