CMS 3D CMS Logo

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

#include <PhysicsTools/FWLiteESRecordWriterAnalyzer/src/FWLiteESRecordWriterAnalyzer.cc>

Inheritance diagram for FWLiteESRecordWriterAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 FWLiteESRecordWriterAnalyzer (const edm::ParameterSet &)
 
 ~FWLiteESRecordWriterAnalyzer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob () override
 
void update (const edm::EventSetup &)
 

Private Attributes

TFile * m_file
 
std::vector< std::shared_ptr< RecordHandler > > m_handlers
 
std::map< std::string, std::vector< std::pair< std::string, std::string > > > m_recordToDataNames
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 151 of file FWLiteESRecordWriterAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 184 of file FWLiteESRecordWriterAnalyzer.cc.

References edm::errors::Configuration, data, Exception, edm::ParameterSet::getParameterNamesForType(), edm::ParameterSet::getUntrackedParameter(), label, names, and AlCaHLTBitMon_QueryRunRegistry::string.

185 {
186  std::vector<std::string> names = iConfig.getParameterNamesForType<std::vector<edm::ParameterSet> >(false);
187  if (names.empty()) {
188  throw edm::Exception(edm::errors::Configuration)<<"No VPSets were given in configuration";
189  }
190  for (std::vector<std::string>::const_iterator it = names.begin(), itEnd=names.end(); it != itEnd; ++it) {
191  const std::vector<edm::ParameterSet>& ps = iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >(*it);
192  std::vector<std::pair<std::string,std::string> >& data = m_recordToDataNames[*it];
193  for(std::vector<edm::ParameterSet>::const_iterator itPS = ps.begin(),itPSEnd = ps.end();
194  itPS != itPSEnd;
195  ++itPS){
196  std::string type = itPS->getUntrackedParameter<std::string>("type");
197  std::string label = itPS->getUntrackedParameter<std::string>("label",std::string());
198  data.push_back(std::make_pair(type,label) );
199  }
200  }
201 
202  m_file = TFile::Open(iConfig.getUntrackedParameter<std::string>("fileName").c_str(),"NEW");
203 }
type
Definition: HCALResponse.h:21
T getUntrackedParameter(std::string const &, T const &) const
const std::string names[nVars_]
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:169
char const * label
std::map< std::string, std::vector< std::pair< std::string, std::string > > > m_recordToDataNames
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
FWLiteESRecordWriterAnalyzer::~FWLiteESRecordWriterAnalyzer ( )
override

Definition at line 206 of file FWLiteESRecordWriterAnalyzer.cc.

207 {
208 
209  // do anything here that needs to be done at desctruction time
210  // (e.g. close files, deallocate resources etc.)
211  m_file->Close();
212  delete m_file;
213 }

Member Function Documentation

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

Definition at line 285 of file FWLiteESRecordWriterAnalyzer.cc.

References update.

286 {
287  update(iSetup);
288 }
void update(const edm::EventSetup &)
void FWLiteESRecordWriterAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 293 of file FWLiteESRecordWriterAnalyzer.cc.

294 {
295 }
void FWLiteESRecordWriterAnalyzer::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 308 of file FWLiteESRecordWriterAnalyzer.cc.

References DEFINE_FWK_MODULE, and update.

308  {
309  update(iSetup);
310 }
void update(const edm::EventSetup &)
void FWLiteESRecordWriterAnalyzer::beginRun ( edm::Run const &  ,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 304 of file FWLiteESRecordWriterAnalyzer.cc.

References update.

304  {
305  update(iSetup);
306 }
void update(const edm::EventSetup &)
void FWLiteESRecordWriterAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 299 of file FWLiteESRecordWriterAnalyzer.cc.

299  {
300  m_file->Write();
301 }
void FWLiteESRecordWriterAnalyzer::update ( const edm::EventSetup iSetup)
private

Definition at line 220 of file FWLiteESRecordWriterAnalyzer.cc.

References data, Exception, edm::EventSetup::find(), edm::typelookup::findType(), relativeConstraints::keys, genParticles_cff::map, AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::tt.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

221 {
223  if(m_handlers.empty()) {
224  //now we have access to the EventSetup so we can setup our data structure
225  for(std::map<std::string, std::vector<std::pair<std::string,std::string> > >::iterator it=m_recordToDataNames.begin(),
226  itEnd = m_recordToDataNames.end();
227  it != itEnd;
228  ++it) {
229  HCTypeTag tt = HCTypeTag::findType(it->first);
230  if(tt == HCTypeTag()) {
231  throw cms::Exception("UnknownESRecordType")<<"The name '"<<it->first<<"' is not associated with a known EventSetupRecord.\n"
232  "Please check spelling or load a module known to link with the package which declares that Record.";
233  }
235 
236  auto rec = iSetup.find(tt);
237  if(not rec) {
238  throw cms::Exception("UnknownESRecordType")<<"The name '"<<it->first<<"' is not associated with a type which is not an EventSetupRecord.\n"
239  "Please check your spelling.";
240  }
241 
242  //now figure out what data
243  std::vector<std::pair<std::string,std::string> >& data = it->second;
244  if(data.empty()) {
245  //get everything from the record
246  std::vector<edm::eventsetup::DataKey> keys;
247  rec->fillRegisteredDataKeys(keys);
248  for(std::vector<edm::eventsetup::DataKey>::iterator itKey = keys.begin(), itKeyEnd = keys.end();
249  itKey != itKeyEnd;
250  ++itKey) {
251  data.push_back(std::make_pair(std::string(itKey->type().name()),
252  std::string(itKey->name().value())));
253  }
254  }
255 
256  std::vector<DataInfo> dataInfos;
257  for (std::vector<std::pair<std::string,std::string> >::iterator itData = data.begin(), itDataEnd = data.end();
258  itData != itDataEnd;
259  ++itData) {
260  HCTypeTag tt = HCTypeTag::findType(itData->first);
261  if(tt == HCTypeTag()) {
262  throw cms::Exception("UnknownESDataType")<<"The name '"<<itData->first<<"' is not associated with a known type held in the "<<it->first<<" Record.\n"
263  "Please check spelling or load a module known to link with the package which declares that type.";
264  }
265  if(!bool(edm::TypeWithDict( tt.value() ))) {
266  throw cms::Exception("NoDictionary")<<"The type '"<<itData->first<<"' can not be retrieved from the Record "<<it->first<<" and stored \n"
267  "because no dictionary exists for the type.";
268  }
269  dataInfos.push_back(DataInfo(tt,itData->second));
270  }
271  m_handlers.push_back( std::make_shared<RecordHandler>(rKey,m_file,dataInfos) );
272  }
273  }
274 
275  for(std::vector<std::shared_ptr<RecordHandler> >::iterator it = m_handlers.begin(),itEnd = m_handlers.end();
276  it != itEnd;
277  ++it) {
278  (*it)->update(iSetup);
279  }
280 }
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &iKey) const
Definition: EventSetup.h:160
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:69
std::vector< std::shared_ptr< RecordHandler > > m_handlers
std::map< std::string, std::vector< std::pair< std::string, std::string > > > m_recordToDataNames
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Member Data Documentation

TFile* FWLiteESRecordWriterAnalyzer::m_file
private

Definition at line 170 of file FWLiteESRecordWriterAnalyzer.cc.

std::vector<std::shared_ptr<RecordHandler> > FWLiteESRecordWriterAnalyzer::m_handlers
private

Definition at line 167 of file FWLiteESRecordWriterAnalyzer.cc.

std::map<std::string, std::vector<std::pair<std::string,std::string> > > FWLiteESRecordWriterAnalyzer::m_recordToDataNames
private

Definition at line 169 of file FWLiteESRecordWriterAnalyzer.cc.