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
 
- 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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_
 
bool generate_fake_valid_gbtlink_and_elinkid_
 
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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 86 of file DTCCablingMapProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 132 of file DTCCablingMapProducer.cc.

References edm::ParameterSet::getParameter(), and LoadModulesToDTCCablingMapFromCSV().

132  :
133  generate_fake_valid_gbtlink_and_elinkid_ (iConfig.getParameter<bool>("generate_fake_valid_gbtlink_and_elinkid")),
134  verbosity_ (iConfig.getParameter<int>("verbosity")),
135  csvFormat_ncolumns_ (iConfig.getParameter<unsigned>("csvFormat_ncolumns")),
136  csvFormat_idetid_ (iConfig.getParameter<unsigned>("csvFormat_idetid" )),
137  csvFormat_idtcid_ (iConfig.getParameter<unsigned>("csvFormat_idtcid" )),
138  iovBeginTime_ (iConfig.getParameter<long long unsigned int>("iovBeginTime")),
139  pCablingMap_ (std::make_unique<TrackerDetToDTCELinkCablingMap>()),
140  record_ (iConfig.getParameter<std::string>("record"))
141 {
142  LoadModulesToDTCCablingMapFromCSV(iConfig.getParameter<std::vector<std::string>>("modulesToDTCCablingCSVFileNames"));
143 }
T getParameter(std::string const &) const
std::unique_ptr< TrackerDetToDTCELinkCablingMap > pCablingMap_
virtual void LoadModulesToDTCCablingMapFromCSV(std::vector< std::string > const &)
DTCCablingMapProducer::~DTCCablingMapProducer ( )
override

Definition at line 307 of file DTCCablingMapProducer.cc.

References DEFINE_FWK_MODULE.

308 {
309 
310 }

Member Function Documentation

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

Definition at line 285 of file DTCCablingMapProducer.cc.

286 {
287 
288 }
void DTCCablingMapProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 145 of file DTCCablingMapProducer.cc.

146 {
147 
148 }
void DTCCablingMapProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 290 of file DTCCablingMapProducer.cc.

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

291 {
292 // using namespace edm;
293  using namespace std;
294 
296 
297  if( poolDbService.isAvailable() )
298  {
299  poolDbService->writeOne( pCablingMap_.release(), iovBeginTime_, record_ );
300  }
301  else
302  {
303  throw cms::Exception("PoolDBService required.");
304  }
305 }
bool isAvailable() const
Definition: Service.h:40
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
std::unique_ptr< TrackerDetToDTCELinkCablingMap > pCablingMap_
void DTCCablingMapProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 115 of file DTCCablingMapProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

116 {
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);
127  desc.add<std::string>("record","TrackerDTCCablingMapRcd");
128  desc.add<std::vector<std::string>>("modulesToDTCCablingCSVFileNames",std::vector<std::string>());
129  descriptions.add("DTCCablingMapProducer", desc);
130 }
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void DTCCablingMapProducer::LoadModulesToDTCCablingMapFromCSV ( std::vector< std::string > const &  modulesToDTCCablingCSVFileNames)
privatevirtual

Definition at line 150 of file DTCCablingMapProducer.cc.

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

Referenced by DTCCablingMapProducer().

151 {
152  using namespace std;
153 
154  for (std::string const& csvFileName : modulesToDTCCablingCSVFileNames)
155  {
156  edm::FileInPath csvFilePath(csvFileName);
157 
158  ifstream csvFile;
159  csvFile.open(csvFilePath.fullPath().c_str());
160 
161  if (csvFile.is_open())
162  {
163  string csvLine;
164 
165  unsigned lineNumber = 0;
166 
167  while (std::getline(csvFile, csvLine))
168  {
169  if (verbosity_ >= 1)
170  {
171  edm::LogInfo("CSVParser") << "Reading CSV file line: " << ++lineNumber << ": \"" << csvLine << "\"" << endl;
172  }
173 
174  istringstream csvStream(csvLine);
175  vector<string> csvColumn;
176  string csvElement;
177 
178  while (std::getline(csvStream, csvElement, ','))
179  {
180  trim(csvElement);
181  csvColumn.push_back(csvElement);
182  }
183 
184  if (verbosity_ >= 2)
185  {
186  ostringstream splitted_line_info;
187 
188  splitted_line_info << "-- split line is: [";
189 
190  for (string const& s : csvColumn)
191  splitted_line_info << "\"" << s << "\", ";
192 
193  splitted_line_info << "]" << endl;
194 
195  edm::LogInfo("CSVParser") << splitted_line_info.str();
196  }
197 
198  if (csvColumn.size() == csvFormat_ncolumns_)
199  {
200  // Skip the legend lines
201  if (0 == csvColumn[0].compare(std::string("Module DetId/U")))
202  {
203  if (verbosity_ >= 1)
204  {
205  edm::LogInfo("CSVParser") << "-- skipping legend line" << endl;
206  }
207  continue;
208  }
209 
210  uint32_t detIdRaw;
211 
212  try
213  {
214  detIdRaw = std::stoi( csvColumn[csvFormat_idetid_] );
215  }
216  catch (std::exception const& e)
217  {
218  if (verbosity_ >= 0)
219  {
220  edm::LogError("CSVParser") << "-- malformed DetId string in CSV file: \"" << csvLine << "\"" << endl;
221  }
222  throw e;
223  }
224 
225  unsigned const dtc_id = strtoul(csvColumn[csvFormat_idtcid_].c_str(), nullptr, 10);
226  unsigned gbt_id;
227  unsigned elink_id;
228 
229 
231  {
232  for (gbt_id = gbt_id_minvalue; gbt_id < gbt_id_maxvalue + 1u; ++gbt_id)
233  {
234  for (elink_id = elink_id_minvalue; elink_id < elink_id_maxvalue + 1u; ++elink_id)
235  {
236  if ( !(pCablingMap_->knowsDTCELinkId( DTCELinkId(dtc_id, gbt_id, elink_id) )) )
237  goto gbtlink_and_elinkid_generator_end; //break out of this double loop
238  }
239  }
240  gbtlink_and_elinkid_generator_end:
241  ((void)0); // This is a NOP, it's here just to have a valid (although dummy) instruction after the goto tag
242  }
243  else
244  {
245  gbt_id = strtoul(csvColumn[csvFormat_igbtlinkid_].c_str(), nullptr, 10);
246  elink_id = strtoul(csvColumn[csvFormat_ielinkid_ ].c_str(), nullptr, 10);
247  }
248 
249 
250  DTCELinkId dtcELinkId( dtc_id, gbt_id, elink_id );
251 
252  if (verbosity_ >= 3)
253  {
254  edm::LogInfo("CSVParser") << "-- DetId = " << detIdRaw << " (dtc_id, gbt_id, elink_id) = (" << dtc_id << "," << gbt_id << "," << elink_id << ")" << endl;
255  }
256 
257  if (pCablingMap_->knowsDTCELinkId(dtcELinkId))
258  {
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 << ")";
261 
262  throw cms::Exception(message.str());
263  }
264 
265  pCablingMap_->insert(dtcELinkId, detIdRaw);
266  }
267  else
268  {
269  if (verbosity_ >= 3)
270  {
271  edm::LogInfo("CSVParser") << "Reading CSV file: Skipped a short line: \"" << csvLine << "\"" << endl;
272  }
273  }
274  }
275  }
276  else
277  {
278  throw cms::Exception("DTCCablingMapProducer: Unable to open input CSV file") << csvFilePath << endl;
279  }
280 
281  csvFile.close();
282  }
283 }
bool compare(const P &i, const P &j)
static const unsigned int gbt_id_minvalue
static void trim(std::string &s)
static const unsigned int elink_id_minvalue
static const unsigned int gbt_id_maxvalue
static const unsigned int elink_id_maxvalue
std::unique_ptr< TrackerDetToDTCELinkCablingMap > pCablingMap_

Member Data Documentation

unsigned DTCCablingMapProducer::csvFormat_idetid_
private

Definition at line 105 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

unsigned DTCCablingMapProducer::csvFormat_idtcid_
private

Definition at line 106 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

unsigned DTCCablingMapProducer::csvFormat_ielinkid_
private

Definition at line 108 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

unsigned DTCCablingMapProducer::csvFormat_igbtlinkid_
private

Definition at line 107 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

unsigned DTCCablingMapProducer::csvFormat_ncolumns_
private

Definition at line 104 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

bool DTCCablingMapProducer::generate_fake_valid_gbtlink_and_elinkid_
private

Definition at line 102 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().

cond::Time_t DTCCablingMapProducer::iovBeginTime_
private

Definition at line 109 of file DTCCablingMapProducer.cc.

Referenced by endJob().

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

Definition at line 110 of file DTCCablingMapProducer.cc.

Referenced by endJob(), and LoadModulesToDTCCablingMapFromCSV().

std::string DTCCablingMapProducer::record_
private

Definition at line 111 of file DTCCablingMapProducer.cc.

Referenced by endJob().

int DTCCablingMapProducer::verbosity_
private

Definition at line 103 of file DTCCablingMapProducer.cc.

Referenced by LoadModulesToDTCCablingMapFromCSV().