Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:46

0001 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
0002 #include "CondCore/CondDB/interface/Exception.h"
0003 
0004 #include "CondCore/Utilities/interface/Utilities.h"
0005 #include <iostream>
0006 
0007 namespace cond {
0008   class ToLumiIdUtilities : public Utilities {
0009   public:
0010     ToLumiIdUtilities();
0011     ~ToLumiIdUtilities() override;
0012     int execute() override;
0013   };
0014 }  // namespace cond
0015 
0016 cond::ToLumiIdUtilities::ToLumiIdUtilities() : Utilities("cmscond_to_lumiid") {
0017   addOption<unsigned int>("runnumber", "r", "run number(required)");
0018   addOption<unsigned int>("lumiblocknumber", "l", "lumi block number(required)");
0019 }
0020 
0021 cond::ToLumiIdUtilities::~ToLumiIdUtilities() {}
0022 
0023 int cond::ToLumiIdUtilities::execute() {
0024   if (!hasOptionValue("runnumber")) {
0025     std::cout << "ERROR: Missing mandatory option \"runnumber\"." << std::endl;
0026     return 1;
0027   }
0028   unsigned int runnumber = getOptionValue<unsigned int>("runnumber");
0029   if (!hasOptionValue("lumiblocknumber")) {
0030     std::cout << "ERROR: Missing mandatory option \"lumiblocknumber\"." << std::endl;
0031     return 1;
0032   }
0033   unsigned int lumiblockid = getOptionValue<unsigned int>("lumiblocknumber");
0034   bool debug = hasDebug();
0035 
0036   edm::LuminosityBlockID lumiid(runnumber, lumiblockid);
0037 
0038   if (lumiid.value() < edm::LuminosityBlockID::firstValidLuminosityBlock().value()) {
0039     std::cout << "ERROR: Invalid Input " << lumiid << std::endl;
0040     std::cout << "firstValidLuminosityBlockID:\t" << edm::LuminosityBlockID::firstValidLuminosityBlock().value()
0041               << std::endl;
0042     return -1;
0043   }
0044   std::cout << lumiid << std::endl;
0045   std::cout << "LuminosityBlockID:\t" << lumiid.value() << std::endl;
0046   if (debug) {
0047     std::cout << "firstValidLuminosityBlockID:\t" << edm::LuminosityBlockID::firstValidLuminosityBlock().value()
0048               << std::endl;
0049     std::cout << "maxRunNumber:\t" << edm::RunID::maxRunNumber() << std::endl;
0050     std::cout << "maxLuminosityBlockNumber:\t" << edm::LuminosityBlockID::maxLuminosityBlockNumber() << std::endl;
0051     std::cout << "maxLuminosityBlockID:\t"
0052               << edm::LuminosityBlockID(edm::RunID::maxRunNumber(), edm::LuminosityBlockID::maxLuminosityBlockNumber())
0053                      .value()
0054               << std::endl;
0055   }
0056   return 0;
0057 }
0058 
0059 int main(int argc, char** argv) {
0060   cond::ToLumiIdUtilities utilities;
0061   return utilities.run(argc, argv);
0062 }