File indexing completed on 2023-03-17 11:03:44
0001 #include <iostream>
0002 #include <sstream>
0003 #include <string>
0004 #include <vector>
0005
0006
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 #include "FWCore/Services/src/JobReportService.h"
0009
0010 void work()
0011 {
0012
0013 edm::ParameterSet ps;
0014 edm::ActivityRegistry areg;
0015
0016 edm::service::JobReportService jrs(ps, areg);
0017 std::vector<edm::JobReport::Token> inputTokens;
0018 std::vector<edm::JobReport::Token> outputTokens;
0019
0020
0021 std::vector<std::string> branchnames;
0022 branchnames.push_back("branch_1_");
0023 branchnames.push_back("branch_2_");
0024
0025 for (int i = 0; i < 10; ++i) {
0026 std::ostringstream oss;
0027 oss << i;
0028 std::string seq_tag = oss.str();
0029 std::vector<std::string> localBranchNames(branchnames);
0030 localBranchNames[0] += seq_tag;
0031 localBranchNames[1] += seq_tag;
0032 edm::JobReport::Token t = jrs.inputFileOpened("phys" + seq_tag,
0033 "log" + seq_tag,
0034 "cat" + seq_tag,
0035 "class" + seq_tag,
0036 "label" + seq_tag,
0037 localBranchNames);
0038 inputTokens.push_back(t);
0039 }
0040
0041
0042 jrs.reportSkippedEvent(10001, 1002);
0043 jrs.reportSkippedEvent(10001, 1003);
0044 jrs.reportSkippedEvent(10001, 1004);
0045
0046 try {
0047 jrs.eventReadFromFile(24, 0, 0);
0048 assert( "Failed to throw required exception" == 0);
0049 }
0050 catch ( edm::Exception & x ) {
0051 assert( x.categoryCode() == edm::errors::LogicError );
0052 }
0053 catch ( ... ) {
0054 assert( "Threw unexpected exception type" == 0 );
0055 }
0056
0057
0058
0059 areg.postEndJobSignal_();
0060 }
0061
0062 void fail()
0063 {
0064
0065 edm::ParameterSet ps;
0066 edm::ActivityRegistry areg;
0067
0068 edm::service::JobReportService jrs(ps, areg);
0069 std::vector<edm::JobReport::Token> inputTokens;
0070 std::vector<edm::JobReport::Token> outputTokens;
0071
0072 areg.jobFailureSignal_();
0073 }
0074
0075 int main()
0076 {
0077 int rc = -1;
0078 try {
0079 work();
0080 fail();
0081 rc = 0;
0082 }
0083
0084 catch ( edm::Exception & x ) {
0085 std::cerr << x << '\n';
0086 rc = 1;
0087 }
0088 catch ( ... ) {
0089 std::cerr << "Unknown exception caught\n";
0090 rc = 2;
0091 }
0092 return rc;
0093 }