Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:16

0001 #include "HBHEDarkeningEP.h"
0002 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0004 #include "FWCore/ParameterSet/interface/FileInPath.h"
0005 #include "FWCore/Framework/interface/SourceFactory.h"
0006 
0007 #include <string>
0008 #include <vector>
0009 #include <map>
0010 
0011 HBHEDarkeningEP::HBHEDarkeningEP(const edm::ParameterSet& pset) : pset_(pset) {
0012   setWhatProduced(this);
0013   findingRecord<HBHEDarkeningRecord>();
0014 }
0015 
0016 HBHEDarkeningEP::~HBHEDarkeningEP() {}
0017 
0018 void HBHEDarkeningEP::setIntervalFor(const edm::eventsetup::EventSetupRecordKey& iKey,
0019                                      const edm::IOVSyncValue& iTime,
0020                                      edm::ValidityInterval& oInterval) {
0021   oInterval = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());  //infinite
0022 }
0023 
0024 void HBHEDarkeningEP::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0025   edm::ParameterSetDescription desc;
0026   desc.add<int>("ieta_shift");
0027   desc.add<double>("drdA");
0028   desc.add<double>("drdB");
0029   edm::ParameterSetDescription desc_dosemaps;
0030   desc_dosemaps.add<int>("energy");
0031   desc_dosemaps.add<edm::FileInPath>("file");
0032   std::vector<edm::ParameterSet> default_dosemap(1);
0033   desc.addVPSet("dosemaps", desc_dosemaps, default_dosemap);
0034   edm::ParameterSetDescription desc_years;
0035   desc_years.add<std::string>("year");
0036   desc_years.add<double>("intlumi");
0037   desc_years.add<double>("lumirate");
0038   desc_years.add<int>("energy");
0039   std::vector<edm::ParameterSet> default_year(1);
0040   desc.addVPSet("years", desc_years, default_year);
0041 
0042   descriptions.addDefault(desc);
0043 }
0044 
0045 // ------------ method called to produce the data  ------------
0046 HBHEDarkeningEP::ReturnType HBHEDarkeningEP::produce(const HBHEDarkeningRecord& iRecord) {
0047   //initialize dose maps
0048   std::vector<edm::ParameterSet> p_dosemaps = pset_.getParameter<std::vector<edm::ParameterSet>>("dosemaps");
0049   std::map<int, std::vector<std::vector<float>>> dosemaps;
0050   for (const auto& p_dosemap : p_dosemaps) {
0051     edm::FileInPath fp = p_dosemap.getParameter<edm::FileInPath>("file");
0052     int file_energy = p_dosemap.getParameter<int>("energy");
0053     dosemaps.emplace(file_energy, HBHEDarkening::readDoseMap(fp.fullPath()));
0054   }
0055 
0056   //initialize years
0057   std::vector<edm::ParameterSet> p_years = pset_.getParameter<std::vector<edm::ParameterSet>>("years");
0058   std::vector<HBHEDarkening::LumiYear> years;
0059   years.reserve(p_years.size());
0060   for (const auto& p_year : p_years) {
0061     years.emplace_back(p_year.getParameter<std::string>("year"),
0062                        p_year.getParameter<double>("intlumi"),
0063                        p_year.getParameter<double>("lumirate"),
0064                        p_year.getParameter<int>("energy"));
0065   }
0066 
0067   return std::make_unique<HBHEDarkening>(pset_.getParameter<int>("ieta_shift"),
0068                                          pset_.getParameter<double>("drdA"),
0069                                          pset_.getParameter<double>("drdB"),
0070                                          dosemaps,
0071                                          years);
0072 }
0073 
0074 DEFINE_FWK_EVENTSETUP_SOURCE(HBHEDarkeningEP);