CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DTCCablingMapProducer Class Reference

#include <CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc>

Inheritance diagram for DTCCablingMapProducer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 DTCCablingMapProducer (const edm::ParameterSet &)
 
 ~DTCCablingMapProducer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
virtual void LoadModulesToDTCCablingMapFromCSV (std::vector< std::string > const &)
 

Private Attributes

unsigned csvFormat_idetid_
 
unsigned csvFormat_idtcid_
 
unsigned csvFormat_ielinkid_
 
unsigned csvFormat_igbtlinkid_
 
unsigned csvFormat_ncolumns_
 
int dummy_fill_mode_
 
cond::Time_t iovBeginTime_
 
std::unique_ptr< TrackerDetToDTCELinkCablingMappCablingMap_
 
std::string record_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 72 of file DTCCablingMapProducer.cc.

Constructor & Destructor Documentation

◆ DTCCablingMapProducer()

DTCCablingMapProducer::DTCCablingMapProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 115 of file DTCCablingMapProducer.cc.

116  : verbosity_(iConfig.getParameter<int>("verbosity")),
117  csvFormat_ncolumns_(iConfig.getParameter<unsigned>("csvFormat_ncolumns")),
118  csvFormat_idetid_(iConfig.getParameter<unsigned>("csvFormat_idetid")),
119  csvFormat_idtcid_(iConfig.getParameter<unsigned>("csvFormat_idtcid")),
120  csvFormat_igbtlinkid_(iConfig.getParameter<unsigned>("csvFormat_igbtlinkid")),
121  csvFormat_ielinkid_(iConfig.getParameter<unsigned>("csvFormat_ielinkid")),
122  iovBeginTime_(iConfig.getParameter<long long unsigned int>("iovBeginTime")),
123  pCablingMap_(std::make_unique<TrackerDetToDTCELinkCablingMap>()),
124  record_(iConfig.getParameter<std::string>("record")) {
125  std::string const dummy_fill_mode_param = iConfig.getParameter<std::string>("dummy_fill_mode");
126 
127  // We pass from the easy to use string to an int representation for this mode flag, as it is more efficient in comparisons
128  if (dummy_fill_mode_param == "DUMMY_FILL_DISABLED")
130  else if (dummy_fill_mode_param == "DUMMY_FILL_ELINK_ID")
132  else if (dummy_fill_mode_param == "DUMMY_FILL_ELINK_ID_AND_GBT_ID")
134  else {
135  throw cms::Exception("InvalidDummyFillMode")
136  << "Parameter dummy_fill_mode with invalid value: " << dummy_fill_mode_param;
137  }
138 
139  LoadModulesToDTCCablingMapFromCSV(iConfig.getParameter<std::vector<std::string>>("modulesToDTCCablingCSVFileNames"));
140 }

References DUMMY_FILL_DISABLED, DUMMY_FILL_ELINK_ID, DUMMY_FILL_ELINK_ID_AND_GBT_ID, dummy_fill_mode_, Exception, edm::ParameterSet::getParameter(), LoadModulesToDTCCablingMapFromCSV(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~DTCCablingMapProducer()

DTCCablingMapProducer::~DTCCablingMapProducer ( )
override

Definition at line 278 of file DTCCablingMapProducer.cc.

278 {}

Member Function Documentation

◆ analyze()

void DTCCablingMapProducer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 263 of file DTCCablingMapProducer.cc.

263 {}

◆ beginJob()

void DTCCablingMapProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 142 of file DTCCablingMapProducer.cc.

142 {}

◆ endJob()

void DTCCablingMapProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 265 of file DTCCablingMapProducer.cc.

265  {
266  // using namespace edm;
267  using namespace std;
268 
270 
271  if (poolDbService.isAvailable()) {
272  poolDbService->writeOne(pCablingMap_.release(), iovBeginTime_, record_);
273  } else {
274  throw cms::Exception("PoolDBServiceNotFound") << "A running PoolDBService instance is required.";
275  }
276 }

References Exception, iovBeginTime_, edm::Service< T >::isAvailable(), pCablingMap_, record_, and cond::service::PoolDBOutputService::writeOne().

◆ fillDescriptions()

void DTCCablingMapProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 99 of file DTCCablingMapProducer.cc.

99  {
101  desc.setComment("Stores a TrackerDetToDTCELinkCablingMap object into the database from a CSV file.");
102  desc.add<std::string>("dummy_fill_mode", "DUMMY_FILL_DISABLED");
103  desc.add<int>("verbosity", 0);
104  desc.add<unsigned>("csvFormat_ncolumns", 15);
105  desc.add<unsigned>("csvFormat_idetid", 0);
106  desc.add<unsigned>("csvFormat_idtcid", 0);
107  desc.add<unsigned>("csvFormat_igbtlinkid", 0);
108  desc.add<unsigned>("csvFormat_ielinkid", 0);
109  desc.add<long long unsigned int>("iovBeginTime", 1);
110  desc.add<std::string>("record", "TrackerDTCCablingMapRcd");
111  desc.add<std::vector<std::string>>("modulesToDTCCablingCSVFileNames", std::vector<std::string>());
112  descriptions.add("DTCCablingMapProducer", desc);
113 }

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ LoadModulesToDTCCablingMapFromCSV()

void DTCCablingMapProducer::LoadModulesToDTCCablingMapFromCSV ( std::vector< std::string > const &  modulesToDTCCablingCSVFileNames)
privatevirtual

Definition at line 144 of file DTCCablingMapProducer.cc.

145  {
146  using namespace std;
147 
148  for (std::string const& csvFileName : modulesToDTCCablingCSVFileNames) {
149  edm::FileInPath csvFilePath(csvFileName);
150 
151  ifstream csvFile;
152  csvFile.open(csvFilePath.fullPath().c_str());
153 
154  if (csvFile.is_open()) {
155  string csvLine;
156 
157  unsigned lineNumber = 0;
158 
159  while (std::getline(csvFile, csvLine)) {
160  if (verbosity_ >= 1) {
161  edm::LogInfo("CSVParser") << "Reading CSV file line: " << ++lineNumber << ": \"" << csvLine << "\"" << endl;
162  }
163 
164  istringstream csvStream(csvLine);
165  vector<string> csvColumn;
166  string csvElement;
167 
168  while (std::getline(csvStream, csvElement, ',')) {
169  trim(csvElement);
170  csvColumn.push_back(csvElement);
171  }
172 
173  if (verbosity_ >= 2) {
174  ostringstream splitted_line_info;
175 
176  splitted_line_info << "-- split line is: [";
177 
178  for (string const& s : csvColumn)
179  splitted_line_info << "\"" << s << "\", ";
180 
181  splitted_line_info << "]" << endl;
182 
183  edm::LogInfo("CSVParser") << splitted_line_info.str();
184  }
185 
186  if (csvColumn.size() == csvFormat_ncolumns_) {
187  // Skip the legend lines
188  if (0 == csvColumn[0].compare(std::string("Module DetId/U"))) {
189  if (verbosity_ >= 1) {
190  edm::LogInfo("CSVParser") << "-- skipping legend line" << endl;
191  }
192  continue;
193  }
194 
195  uint32_t detIdRaw;
196 
197  try {
198  detIdRaw = std::stoi(csvColumn.at(csvFormat_idetid_));
199  } catch (std::exception const& e) {
200  if (verbosity_ >= 0) {
201  edm::LogError("CSVParser") << "-- malformed DetId string in CSV file: \"" << csvLine << "\"" << endl;
202  }
203  throw e;
204  }
205 
206  unsigned const dtc_id = strtoul(csvColumn.at(csvFormat_idtcid_).c_str(), nullptr, 10);
207  unsigned gbt_id;
208  unsigned elink_id;
209 
210  switch (dummy_fill_mode_) {
211  default:
212  case DUMMY_FILL_DISABLED:
213  gbt_id = strtoul(csvColumn.at(csvFormat_igbtlinkid_).c_str(), nullptr, 10);
214  elink_id = strtoul(csvColumn.at(csvFormat_ielinkid_).c_str(), nullptr, 10);
215  break;
216  case DUMMY_FILL_ELINK_ID:
217  gbt_id = strtoul(csvColumn.at(csvFormat_igbtlinkid_).c_str(), nullptr, 10);
218  for (elink_id = elink_id_minvalue; elink_id < elink_id_maxvalue + 1u; ++elink_id) {
219  if (!(pCablingMap_->knowsDTCELinkId(DTCELinkId(dtc_id, gbt_id, elink_id))))
220  break;
221  }
222  break;
224  for (gbt_id = gbt_id_minvalue; gbt_id < gbt_id_maxvalue + 1u; ++gbt_id) {
225  for (elink_id = elink_id_minvalue; elink_id < elink_id_maxvalue + 1u; ++elink_id) {
226  if (!(pCablingMap_->knowsDTCELinkId(DTCELinkId(dtc_id, gbt_id, elink_id))))
227  goto gbtlink_and_elinkid_generator_end; //break out of this double loop, this is one of the few "proper" uses of goto
228  }
229  }
230  gbtlink_and_elinkid_generator_end:
231  ((void)0); // This is a NOP, it's here just to have a valid (although dummy) instruction after the goto tag
232  break;
233  }
234 
235  DTCELinkId dtcELinkId(dtc_id, gbt_id, elink_id);
236 
237  if (verbosity_ >= 3) {
238  edm::LogInfo("CSVParser") << "-- DetId = " << detIdRaw << " (dtc_id, gbt_id, elink_id) = (" << dtc_id << ","
239  << gbt_id << "," << elink_id << ")" << endl;
240  }
241 
242  if (pCablingMap_->knowsDTCELinkId(dtcELinkId)) {
243  throw cms::Exception("DuplicateDTCELinkIdInCSV")
244  << "Reading CSV file: CRITICAL ERROR, duplicate dtcELinkId entry about (dtc_id, gbt_id, elink_id) = ("
245  << dtc_id << "," << gbt_id << "," << elink_id << ")";
246  }
247 
248  pCablingMap_->insert(dtcELinkId, detIdRaw);
249  } else {
250  if (verbosity_ >= 3) {
251  edm::LogInfo("CSVParser") << "Reading CSV file: Skipped a short line: \"" << csvLine << "\"" << endl;
252  }
253  }
254  }
255  } else {
256  throw cms::Exception("CSVFileNotFound") << "Unable to open input CSV file" << csvFilePath << endl;
257  }
258 
259  csvFile.close();
260  }
261 }

References compare(), csvFormat_idetid_, csvFormat_idtcid_, csvFormat_ielinkid_, csvFormat_igbtlinkid_, csvFormat_ncolumns_, DUMMY_FILL_DISABLED, DUMMY_FILL_ELINK_ID, DUMMY_FILL_ELINK_ID_AND_GBT_ID, dummy_fill_mode_, MillePedeFileConverter_cfg::e, elink_id_maxvalue, elink_id_minvalue, cppFunctionSkipper::exception, Exception, edm::FileInPath::fullPath(), gbt_id_maxvalue, gbt_id_minvalue, pCablingMap_, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, trim(), verbosity_, and funct::void.

Referenced by DTCCablingMapProducer().

Member Data Documentation

◆ csvFormat_idetid_

unsigned DTCCablingMapProducer::csvFormat_idetid_
private

Definition at line 90 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

◆ csvFormat_idtcid_

unsigned DTCCablingMapProducer::csvFormat_idtcid_
private

Definition at line 91 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

◆ csvFormat_ielinkid_

unsigned DTCCablingMapProducer::csvFormat_ielinkid_
private

Definition at line 93 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

◆ csvFormat_igbtlinkid_

unsigned DTCCablingMapProducer::csvFormat_igbtlinkid_
private

Definition at line 92 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

◆ csvFormat_ncolumns_

unsigned DTCCablingMapProducer::csvFormat_ncolumns_
private

Definition at line 89 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

◆ dummy_fill_mode_

int DTCCablingMapProducer::dummy_fill_mode_
private

◆ iovBeginTime_

cond::Time_t DTCCablingMapProducer::iovBeginTime_
private

Definition at line 94 of file DTCCablingMapProducer.cc.

Referenced by endJob().

◆ pCablingMap_

std::unique_ptr<TrackerDetToDTCELinkCablingMap> DTCCablingMapProducer::pCablingMap_
private

Definition at line 95 of file DTCCablingMapProducer.cc.

Referenced by endJob(), and LoadModulesToDTCCablingMapFromCSV().

◆ record_

std::string DTCCablingMapProducer::record_
private

Definition at line 96 of file DTCCablingMapProducer.cc.

Referenced by endJob().

◆ verbosity_

int DTCCablingMapProducer::verbosity_
private

Definition at line 88 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

gbt_id_maxvalue
static constexpr const unsigned int gbt_id_maxvalue
Definition: DTCCablingMapProducer.cc:46
DTCCablingMapProducer::verbosity_
int verbosity_
Definition: DTCCablingMapProducer.cc:88
DTCELinkId
Definition: DTCELinkId.h:28
DTCCablingMapProducer::csvFormat_ncolumns_
unsigned csvFormat_ncolumns_
Definition: DTCCablingMapProducer.cc:89
DTCCablingMapProducer::pCablingMap_
std::unique_ptr< TrackerDetToDTCELinkCablingMap > pCablingMap_
Definition: DTCCablingMapProducer.cc:95
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
DTCCablingMapProducer::csvFormat_ielinkid_
unsigned csvFormat_ielinkid_
Definition: DTCCablingMapProducer.cc:93
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
DTCCablingMapProducer::csvFormat_idtcid_
unsigned csvFormat_idtcid_
Definition: DTCCablingMapProducer.cc:91
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
gbt_id_minvalue
static constexpr const unsigned int gbt_id_minvalue
Definition: DTCCablingMapProducer.cc:45
elink_id_maxvalue
static constexpr const unsigned int elink_id_maxvalue
Definition: DTCCablingMapProducer.cc:48
edm::FileInPath
Definition: FileInPath.h:64
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
DUMMY_FILL_ELINK_ID_AND_GBT_ID
Definition: DTCCablingMapProducer.cc:50
DUMMY_FILL_DISABLED
Definition: DTCCablingMapProducer.cc:50
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
DTCCablingMapProducer::csvFormat_idetid_
unsigned csvFormat_idetid_
Definition: DTCCablingMapProducer.cc:90
edm::Service< cond::service::PoolDBOutputService >
DUMMY_FILL_ELINK_ID
Definition: DTCCablingMapProducer.cc:50
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DTCCablingMapProducer::dummy_fill_mode_
int dummy_fill_mode_
Definition: DTCCablingMapProducer.cc:87
DTCCablingMapProducer::iovBeginTime_
cond::Time_t iovBeginTime_
Definition: DTCCablingMapProducer.cc:94
DTCCablingMapProducer::record_
std::string record_
Definition: DTCCablingMapProducer.cc:96
DTCCablingMapProducer::csvFormat_igbtlinkid_
unsigned csvFormat_igbtlinkid_
Definition: DTCCablingMapProducer.cc:92
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
elink_id_minvalue
static constexpr const unsigned int elink_id_minvalue
Definition: DTCCablingMapProducer.cc:47
Exception
Definition: hltDiff.cc:245
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DTCCablingMapProducer::LoadModulesToDTCCablingMapFromCSV
virtual void LoadModulesToDTCCablingMapFromCSV(std::vector< std::string > const &)
Definition: DTCCablingMapProducer.cc:144
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
compare
bool compare(const P &i, const P &j)
Definition: BDHadronTrackMonitoringAnalyzer.cc:203
trim
static void trim(std::string &s)
Definition: DTCCablingMapProducer.cc:67
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37