All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
reco::shower::ShowerProducedPtrsHolder Class Reference

#include <ShowerProducedPtrsHolder.hh>

Public Member Functions

template<class T >
int SetShowerUniqueProduerPtr (type< T >, const std::string &Name, const std::string &Instance="")
 
template<class T >
int SetShowerUniqueProduerPtr (type< std::vector< T > >, const std::string &Name, const std::string &Instance="")
 
bool CheckUniqueProduerPtr (const std::string &Name) const
 
void reset ()
 
void AddDataProducts (const reco::shower::ShowerElementHolder &selement_holder)
 
void MoveAllToEvent (art::Event &evt)
 
bool CheckAllProducedElements (reco::shower::ShowerElementHolder &selement_holder) const
 
template<class T >
T & GetPtr (const std::string &Name)
 
template<class T , class A , class B >
void AddSingle (A &a, B &b, const std::string &Name)
 
void SetPtrMakers (art::Event &evt)
 
template<class T >
art::PtrMaker< T > & GetPtrMaker (const std::string &Name)
 
template<class T >
art::Ptr< T > GetArtPtr (const std::string &Name, const int &iter) const
 
void ResetPtrMakers ()
 
int GetVectorPtrSize (const std::string &Name) const
 
void PrintPtr (const std::string &Name) const
 
void PrintPtrs () const
 

Private Member Functions

template<class T >
bool CheckForMultipleTypes (type< T >, const std::string &Name, const std::string &Instance) const
 
template<class T >
bool CheckForMultipleTypes (type< std::vector< T > >, const std::string &Name, const std::string &Instance) const
 

Private Attributes

std::map< std::string,
std::unique_ptr
< reco::shower::ShowerUniqueProduerPtrBase > > 
showerproductPtrs
 
std::map< std::string,
std::unique_ptr
< reco::shower::ShowerUniqueProduerPtrBase > > 
showerassnPtrs
 
std::map< std::string,
std::unique_ptr
< reco::shower::ShowerPtrMakerBase > > 
showerPtrMakers
 

Detailed Description

Definition at line 304 of file ShowerProducedPtrsHolder.hh.

Member Function Documentation

void reco::shower::ShowerProducedPtrsHolder::AddDataProducts ( const reco::shower::ShowerElementHolder selement_holder)
inline

Definition at line 375 of file ShowerProducedPtrsHolder.hh.

375  {
376  for(auto const& showerproductPtr: showerproductPtrs){
377  (showerproductPtr.second)->AddDataProduct(selement_holder, showerproductPtr.first);
378  }
379  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
template<class T , class A , class B >
void reco::shower::ShowerProducedPtrsHolder::AddSingle ( A &  a,
B &  b,
const std::string &  Name 
)
inline

Definition at line 422 of file ShowerProducedPtrsHolder.hh.

422  {
423  auto const showerassnPtrsIt = showerassnPtrs.find(Name);
424  if(showerassnPtrsIt == showerassnPtrs.end()){
425  throw cet::exception("ShowerProducedPtrsHolder") << "Trying to get the association: " << Name << "Element does not exist" << std::endl;
426  }
427  if(!is_assn<T>::value){
428  throw cet::exception("ShowerProducedPtrsHolder") << "Element type is not an assoication please only use this for assocations" << std::endl;
429  }
430  reco::shower::ShowerUniqueAssnPtr<T>* assnptr = dynamic_cast<reco::shower::ShowerUniqueAssnPtr<T> *>(showerassnPtrsIt->second.get());
431  if(assnptr == nullptr){
432  throw cet::exception("ShowerProducedPtrsHolder") << "Failed to cast back. Maybe you got the type wrong or you are accidently accessing a differently named product" << std::endl;
433  }
434 
435  T* assn = dynamic_cast<T*>(assnptr->GetPtr().get());
436  if(assn == nullptr){
437  throw cet::exception("ShowerProducedPtrsHolder") << "Something went wrong trying to cast tothe assn. Maybe the name: " << Name << " exists but its not an assn" << std::endl;
438  }
439 
440  assn->addSingle(a,b);
441  return;
442  }
process_name gaushit a
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
BEGIN_PROLOG vertical distance to the surface Name
bool reco::shower::ShowerProducedPtrsHolder::CheckAllProducedElements ( reco::shower::ShowerElementHolder selement_holder) const
inline

Definition at line 391 of file ShowerProducedPtrsHolder.hh.

391  {
392  bool checked = true;
393  for(auto const& showerproductPtr: showerproductPtrs){
394  if(showerproductPtr.first == "shower"){continue;}
395  checked *= selement_holder.CheckElement(showerproductPtr.first);
396  }
397  return checked;
398  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
bool CheckElement(const std::string &Name) const
template<class T >
bool reco::shower::ShowerProducedPtrsHolder::CheckForMultipleTypes ( type< T >  ,
const std::string &  Name,
const std::string &  Instance 
) const
inlineprivate

Definition at line 599 of file ShowerProducedPtrsHolder.hh.

599  {
600 
601  //Check the a product of the same does not exist without a different instance name
602  for(auto const& assn: showerassnPtrs){
603  reco::shower::ShowerUniqueAssnPtr<T>* assnptr = dynamic_cast<reco::shower::ShowerUniqueAssnPtr<T> *>(assn.second.get());
604  if(assnptr != nullptr){
605  if(assnptr->GetInstanceName() == Instance){return false;}
606  }
607  }
608  return true;
609  }
std::string GetInstanceName() const override
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
template<class T >
bool reco::shower::ShowerProducedPtrsHolder::CheckForMultipleTypes ( type< std::vector< T > >  ,
const std::string &  Name,
const std::string &  Instance 
) const
inlineprivate

Definition at line 613 of file ShowerProducedPtrsHolder.hh.

613  {
614 
615  //Check the a product of the same does not exist without a different instance name
616  for(auto const& product: showerproductPtrs){
618  if(prod != nullptr){
619  if(prod->GetInstanceName() == Instance){return false;}
620  }
621  }
622  return true;
623  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
bool reco::shower::ShowerProducedPtrsHolder::CheckUniqueProduerPtr ( const std::string &  Name) const
inline

Definition at line 352 of file ShowerProducedPtrsHolder.hh.

352  {
353  if(showerproductPtrs.find(Name) != showerproductPtrs.end()){
354  return true;
355  }
356  if(showerassnPtrs.find(Name) != showerassnPtrs.end()){
357  return true;
358  }
359  return false;
360  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
BEGIN_PROLOG vertical distance to the surface Name
template<class T >
art::Ptr<T> reco::shower::ShowerProducedPtrsHolder::GetArtPtr ( const std::string &  Name,
const int &  iter 
) const
inline

Definition at line 472 of file ShowerProducedPtrsHolder.hh.

472  {
473  auto const showerPtrMakersIt = showerPtrMakers.find(Name);
474  if(showerPtrMakersIt == showerPtrMakers.end()){
475  throw cet::exception("ShowerProducedPtrsHolder") << "PtrMaker does not exist for " << Name << " Did you initialise this? " << std::endl;
476  }
477  else{
478  if(!showerPtrMakersIt->second->CheckPtrMaker()){
479  throw cet::exception("ShowerProducedPtrsHolder") << "PtrMaker is not set. This is an issue for the devlopment team me. Contact Dom Barker" << std::endl;
480  }
481  reco::shower::ShowerPtrMaker<T>* ptrmaker = dynamic_cast<reco::shower::ShowerPtrMaker<T> *>(showerPtrMakersIt->second.get());
482  if(ptrmaker == nullptr){
483  throw cet::exception("ShowerProducedPtrsHolder") << "Failed to cast back. Maybe you got the type wrong or you are accidently accessing a differently named product" << std::endl;
484  }
485  return ptrmaker->GetArtPtr(iter);
486  }
487  }
art::Ptr< T > GetArtPtr(int iter) const
BEGIN_PROLOG vertical distance to the surface Name
std::map< std::string, std::unique_ptr< reco::shower::ShowerPtrMakerBase > > showerPtrMakers
template<class T >
T& reco::shower::ShowerProducedPtrsHolder::GetPtr ( const std::string &  Name)
inline

Definition at line 403 of file ShowerProducedPtrsHolder.hh.

403  {
404  auto const showerproductPtrsIt = showerproductPtrs.find(Name);
405  if(showerproductPtrsIt != showerproductPtrs.end()){
406  reco::shower::ShowerUniqueProductPtr<T>* prod = dynamic_cast<reco::shower::ShowerUniqueProductPtr<T> *>(showerproductPtrsIt->second.get());
407  return prod->GetPtr();
408  }
409 
410  auto const showerassnPtrsIt = showerassnPtrs.find(Name);
411  if(showerassnPtrsIt != showerassnPtrs.end()){
412  reco::shower::ShowerUniqueAssnPtr<T>* assn = dynamic_cast<reco::shower::ShowerUniqueAssnPtr<T> *>(showerassnPtrsIt->second.get());
413  return assn->GetPtr();
414  }
415 
416  throw cet::exception("ShowerProducedPtrsHolder") << "Trying to get Ptr for: " << Name << " but Element does not exist" << std::endl;
417  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
BEGIN_PROLOG vertical distance to the surface Name
template<class T >
art::PtrMaker<T>& reco::shower::ShowerProducedPtrsHolder::GetPtrMaker ( const std::string &  Name)
inline

Definition at line 456 of file ShowerProducedPtrsHolder.hh.

456  {
457  auto const showerPtrMakersIt = showerPtrMakers.find(Name);
458  if(showerPtrMakersIt == showerPtrMakers.end()){
459  throw cet::exception("ShowerProducedPtrsHolder") << "PtrMaker does not exist" << std::endl;
460  }
461  else{
462  if(!showerPtrMakersIt->second->CheckPtrMaker()){
463  throw cet::exception("ShowerProducedPtrsHolder") << "PtrMaker is not set" << std::endl;
464  }
466  return ptrmaker->GetPtrMaker();
467  }
468  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
BEGIN_PROLOG vertical distance to the surface Name
std::map< std::string, std::unique_ptr< reco::shower::ShowerPtrMakerBase > > showerPtrMakers
int reco::shower::ShowerProducedPtrsHolder::GetVectorPtrSize ( const std::string &  Name) const
inline

Definition at line 497 of file ShowerProducedPtrsHolder.hh.

497  {
498  auto const showerproductPtrsIt = showerproductPtrs.find(Name);
499  if(showerproductPtrsIt != showerproductPtrs.end()){
500  return showerproductPtrsIt->second->GetVectorPtrSize();
501  }
502  throw cet::exception("ShowerProducedPtrsHolder") << "Product: " << Name << " has not been set in the producers map" << std::endl;
503  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
BEGIN_PROLOG vertical distance to the surface Name
void reco::shower::ShowerProducedPtrsHolder::MoveAllToEvent ( art::Event &  evt)
inline

Definition at line 382 of file ShowerProducedPtrsHolder.hh.

382  {
383  for(auto const& showerproductPtr: showerproductPtrs){
384  (showerproductPtr.second)->MoveToEvent(evt);
385  }
386  for(auto const& showerassnPtr: showerassnPtrs){
387  (showerassnPtr.second)->MoveToEvent(evt);
388  }
389  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
TCEvent evt
Definition: DataStructs.cxx:8
void reco::shower::ShowerProducedPtrsHolder::PrintPtr ( const std::string &  Name) const
inline

Definition at line 506 of file ShowerProducedPtrsHolder.hh.

506  {
507  auto const showerproductPtrsIt = showerproductPtrs.find(Name);
508  if(showerproductPtrsIt != showerproductPtrs.end()){
509  const std::string Type = showerproductPtrsIt->second->GetType();
510  const std::string InstanceName = showerproductPtrsIt->second->GetInstanceName();
511  std::cout << "Element Name: " << Name << " Instance Name: " << InstanceName << " Type: " << Type << std::endl;
512  return;
513  }
514  auto const showerassnPtrsIt = showerassnPtrs.find(Name);
515  if(showerassnPtrsIt != showerassnPtrs.end()){
516  const std::string Type = showerassnPtrsIt->second->GetType();
517  const std::string InstanceName = showerassnPtrsIt->second->GetInstanceName();
518  std::cout << "Element Name: " << Name << " Instance Name: " << InstanceName << " Type: " << Type << std::endl;
519  return;
520  }
521  mf::LogError("ShowerProducedPtrsHolder") << "Trying to print Element: " << Name << ". This element does not exist in the element holder" << std::endl;
522  return;
523  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
BEGIN_PROLOG vertical distance to the surface Name
decoded decode D Type
BEGIN_PROLOG could also be cout
void reco::shower::ShowerProducedPtrsHolder::PrintPtrs ( ) const
inline

Definition at line 527 of file ShowerProducedPtrsHolder.hh.

527  {
528 
529  unsigned int maxname = 0;
530  for(auto const& showerprodPtr: showerproductPtrs){
531  if(showerprodPtr.first.size() > maxname){
532  maxname = showerprodPtr.first.size();
533  }
534  }
535  for(auto const& showerassnPtr: showerassnPtrs){
536  if(showerassnPtr.first.size() > maxname){
537  maxname = showerassnPtr.first.size();
538  }
539  }
540 
541  std::map<std::string,std::pair<std::string,std::string> > Type_showerprodPtrs;
542  std::map<std::string,std::pair<std::string,std::string> > Type_showerassnPtrs;
543  for(auto const& showerprodPtr: showerproductPtrs){
544  const std::string Type = (showerprodPtr.second)->GetType();
545  const std::string InstanceName = (showerprodPtr.second)->GetInstanceName();
546  Type_showerprodPtrs[showerprodPtr.first] = std::make_pair(InstanceName,Type);
547  }
548  for(auto const& showerassnPtr: showerassnPtrs){
549  const std::string Type = (showerassnPtr.second)->GetType();
550  const std::string InstanceName = (showerassnPtr.second)->GetInstanceName();
551  Type_showerassnPtrs[showerassnPtr.first] = std::make_pair(InstanceName,Type);
552  }
553 
554  unsigned int maxtype = 0;
555  unsigned int maxinstname = 0;
556  for(auto const& Type_showerprodPtr: Type_showerprodPtrs){
557  if(Type_showerprodPtr.second.second.size() > maxtype){
558  maxtype = Type_showerprodPtr.second.second.size();
559  }
560  if(Type_showerprodPtr.second.first.size() > maxinstname){
561  maxinstname = Type_showerprodPtr.second.first.size();
562  }
563  }
564  for(auto const& Type_showerassnPtr: Type_showerassnPtrs){
565  if(Type_showerassnPtr.second.second.size() > maxtype){
566  maxtype = Type_showerassnPtr.second.second.size();
567  }
568  if(Type_showerassnPtr.second.first.size() > maxinstname){
569  maxinstname = Type_showerassnPtr.second.first.size();
570  }
571  }
572 
573  unsigned int n = maxname + maxtype + maxinstname + 51;
574  std::cout << std::left << std::setfill('*') << std::setw(n-1) << "**" <<std::endl;
575  std::cout << "Unique Ptrs that are added to the event" << std::endl;
576  std::cout << std::left << std::setfill('*') << std::setw(n-1) << "**" <<std::endl;
577  for(auto const& Type_showerprodPtr: Type_showerprodPtrs){
578  std::cout << std::left << std::setfill(' ') << std::setw(21) << "* Data Product Name: " << std::setw(maxname) << Type_showerprodPtr.first;
579  std::cout << std::left << std::setfill(' ') << " * Instance Name: " << std::setw(maxinstname) << Type_showerprodPtr.second.first;
580  std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype) << Type_showerprodPtr.second.second << " *" << std::endl;
581  }
582  for(auto const& Type_showerassnPtr: Type_showerassnPtrs){
583  std::cout << std::left << std::setfill(' ') << std::setw(maxname) << std::setw(21) << "* Association Name: " << std::setw(maxname) << Type_showerassnPtr.first;
584  std::cout << std::left << std::setfill(' ') << " * Instance Name: " << std::setw(maxinstname) << Type_showerassnPtr.second.first;
585  std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype) << Type_showerassnPtr.second.second<< " *" << std::endl;
586  }
587  std::cout << std::left << std::setfill('*') << std::setw(n-1) << "**" <<std::endl;
588  std::cout << std::setfill(' ');
589  std::cout << std::setw(0);
590  return;
591  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
walls no left
Definition: selectors.fcl:105
decoded decode D Type
BEGIN_PROLOG could also be cout
void reco::shower::ShowerProducedPtrsHolder::reset ( )
inline

Definition at line 363 of file ShowerProducedPtrsHolder.hh.

363  {
364  for(auto const& showerptr: showerproductPtrs){
365  (showerptr.second)->reset();
366  }
367  for(auto const& showerptr: showerassnPtrs){
368  (showerptr.second)->reset();
369  }
370  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
void reco::shower::ShowerProducedPtrsHolder::ResetPtrMakers ( )
inline

Definition at line 490 of file ShowerProducedPtrsHolder.hh.

490  {
491  for(auto const& showerPtrMaker: showerPtrMakers){
492  (showerPtrMaker.second)->Reset();
493  }
494  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerPtrMakerBase > > showerPtrMakers
void reco::shower::ShowerProducedPtrsHolder::SetPtrMakers ( art::Event &  evt)
inline

Definition at line 445 of file ShowerProducedPtrsHolder.hh.

445  {
446  for(auto const& showerPtrMaker: showerPtrMakers){
447  if(showerPtrMakers.find(showerPtrMaker.first) == showerPtrMakers.end()){
448  throw cet::exception("ShowerProducedPtrsHolder") << "PtrMaker was empty. This is concerning" << std::endl;
449  }
450  showerPtrMakers[showerPtrMaker.first]->SetPtrMaker(evt);
451  }
452  }
TCEvent evt
Definition: DataStructs.cxx:8
std::map< std::string, std::unique_ptr< reco::shower::ShowerPtrMakerBase > > showerPtrMakers
template<class T >
int reco::shower::ShowerProducedPtrsHolder::SetShowerUniqueProduerPtr ( type< T >  ,
const std::string &  Name,
const std::string &  Instance = "" 
)
inline

Definition at line 310 of file ShowerProducedPtrsHolder.hh.

310  {
311 
312  //Add to the assns
313  if(showerassnPtrs.find(Name) != showerassnPtrs.end()){
314  mf::LogWarning("ShowerProducedPtrsHolder") << "Trying to set Element: " << Name << ". This element has already been set. Please check." << std::endl;
315  return 1;
316  }
317 
318  //Check the same type has not already been set.
319  if(!CheckForMultipleTypes(type<T>(), Name, Instance)){
320  throw cet::exception("ShowerProducedPtrsHolder") << "Trying to set multiple objects with same type with no instance name or same instance name" << std::endl;
321  }
322 
323  showerassnPtrs[Name] = std::make_unique<ShowerUniqueAssnPtr<T> >(Instance);
324  return 0;
325  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
BEGIN_PROLOG vertical distance to the surface Name
bool CheckForMultipleTypes(type< T >, const std::string &Name, const std::string &Instance) const
template<class T >
int reco::shower::ShowerProducedPtrsHolder::SetShowerUniqueProduerPtr ( type< std::vector< T > >  ,
const std::string &  Name,
const std::string &  Instance = "" 
)
inline

Definition at line 329 of file ShowerProducedPtrsHolder.hh.

329  {
330 
331  //Then add the products
332  if(showerproductPtrs.find(Name) != showerproductPtrs.end()){
333  mf::LogWarning("ShowerProducedPtrsHolder") << "Trying to set Element: " << Name << ". This element has already been set. Please check." << std::endl;
334  return 1;
335  }
336 
337  //Check the same type has not already been set.
338  if(!CheckForMultipleTypes(type<std::vector<T> >(), Name, Instance)){
339  throw cet::exception("ShowerProducedPtrsHolder") << "Trying to set multiple objects with same type with no instance name or same instance name" << std::endl;
340  }
341 
342  if(showerPtrMakers.find(Name) != showerPtrMakers.end()){
343  throw cet::exception("ShowerProducedPtrsHolder") << "PtrMaker already exist. It should not be set again" << std::endl;
344  }
345  showerPtrMakers[Name] = std::make_unique<ShowerPtrMaker<T> >(Instance);
346  showerproductPtrs[Name] = std::make_unique<ShowerUniqueProductPtr<std::vector<T > > >(Instance);
347  return 0;
348  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
BEGIN_PROLOG vertical distance to the surface Name
std::map< std::string, std::unique_ptr< reco::shower::ShowerPtrMakerBase > > showerPtrMakers
bool CheckForMultipleTypes(type< T >, const std::string &Name, const std::string &Instance) const

Member Data Documentation

std::map<std::string,std::unique_ptr<reco::shower::ShowerUniqueProduerPtrBase > > reco::shower::ShowerProducedPtrsHolder::showerassnPtrs
private

Definition at line 631 of file ShowerProducedPtrsHolder.hh.

std::map<std::string,std::unique_ptr<reco::shower::ShowerUniqueProduerPtrBase > > reco::shower::ShowerProducedPtrsHolder::showerproductPtrs
private

Definition at line 628 of file ShowerProducedPtrsHolder.hh.

std::map<std::string,std::unique_ptr<reco::shower::ShowerPtrMakerBase> > reco::shower::ShowerProducedPtrsHolder::showerPtrMakers
private

Definition at line 634 of file ShowerProducedPtrsHolder.hh.


The documentation for this class was generated from the following file: