21 #include <unordered_map> 62 s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](
int ch)
64 return !std::isspace(ch);
71 s.erase(std::find_if(s.rbegin(), s.rend(), [](
int ch)
73 return !std::isspace(ch);
118 desc.
setComment(
"Stores a TrackerDetToDTCELinkCablingMap object into the database from a CSV file.");
119 desc.
add<
bool>(
"generate_fake_valid_gbtlink_and_elinkid",
false);
120 desc.
add<
int>(
"verbosity", 0);
121 desc.
add<
unsigned>(
"csvFormat_idetid" , 0);
122 desc.
add<
unsigned>(
"csvFormat_ncolumns" , 15);
123 desc.
add<
unsigned>(
"csvFormat_idtcid" , 10);
124 desc.
add<
unsigned>(
"csvFormat_igbtlinkid" , 11);
125 desc.
add<
unsigned>(
"csvFormat_ielinkid" , 12);
126 desc.
add<
long long unsigned int>(
"iovBeginTime" , 1);
128 desc.
add<std::vector<std::string>>(
"modulesToDTCCablingCSVFileNames",std::vector<std::string>());
129 descriptions.
add(
"DTCCablingMapProducer", desc);
138 iovBeginTime_ (iConfig.getParameter<long long unsigned
int>(
"iovBeginTime")),
154 for (
std::string const& csvFileName : modulesToDTCCablingCSVFileNames)
159 csvFile.open(csvFilePath.
fullPath().c_str());
161 if (csvFile.is_open())
165 unsigned lineNumber = 0;
167 while (std::getline(csvFile, csvLine))
171 edm::LogInfo(
"CSVParser") <<
"Reading CSV file line: " << ++lineNumber <<
": \"" << csvLine <<
"\"" << endl;
174 istringstream csvStream(csvLine);
175 vector<string> csvColumn;
178 while (std::getline(csvStream, csvElement,
','))
181 csvColumn.push_back(csvElement);
186 ostringstream splitted_line_info;
188 splitted_line_info <<
"-- split line is: [";
190 for (
string const&
s : csvColumn)
191 splitted_line_info <<
"\"" <<
s <<
"\", ";
193 splitted_line_info <<
"]" << endl;
205 edm::LogInfo(
"CSVParser") <<
"-- skipping legend line" << endl;
220 edm::LogError(
"CSVParser") <<
"-- malformed DetId string in CSV file: \"" << csvLine <<
"\"" << endl;
225 unsigned const dtc_id = strtoul(csvColumn[
csvFormat_idtcid_].c_str(),
nullptr, 10);
237 goto gbtlink_and_elinkid_generator_end;
240 gbtlink_and_elinkid_generator_end:
250 DTCELinkId dtcELinkId( dtc_id, gbt_id, elink_id );
254 edm::LogInfo(
"CSVParser") <<
"-- DetId = " << detIdRaw <<
" (dtc_id, gbt_id, elink_id) = (" << dtc_id <<
"," << gbt_id <<
"," << elink_id <<
")" << endl;
259 ostringstream message;
260 message <<
"Reading CSV file: CRITICAL ERROR, duplicated dtcELinkId entry about (dtc_id, gbt_id, elink_id) = (" << dtc_id <<
"," << gbt_id <<
"," << elink_id <<
")";
271 edm::LogInfo(
"CSVParser") <<
"Reading CSV file: Skipped a short line: \"" << csvLine <<
"\"" << endl;
278 throw cms::Exception(
"DTCCablingMapProducer: Unable to open input CSV file") << csvFilePath << endl;
T getParameter(std::string const &) const
bool compare(const P &i, const P &j)
DTCCablingMapProducer(const edm::ParameterSet &)
static const unsigned int gbt_id_minvalue
unsigned csvFormat_idetid_
static void trim(std::string &s)
unsigned csvFormat_idtcid_
unsigned csvFormat_ncolumns_
bool generate_fake_valid_gbtlink_and_elinkid_
static void ltrim(std::string &s)
static const unsigned int elink_id_minvalue
unsigned csvFormat_igbtlinkid_
void setComment(std::string const &value)
#define DEFINE_FWK_MODULE(type)
unsigned long long Time_t
static const unsigned int gbt_id_maxvalue
unsigned csvFormat_ielinkid_
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
base
Make Sure CMSSW is Setup ##.
static const unsigned int elink_id_maxvalue
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void rtrim(std::string &s)
void analyze(const edm::Event &, const edm::EventSetup &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
cond::Time_t iovBeginTime_
std::string fullPath() const
~DTCCablingMapProducer() override
std::unique_ptr< TrackerDetToDTCELinkCablingMap > pCablingMap_
virtual void LoadModulesToDTCCablingMapFromCSV(std::vector< std::string > const &)