Public Member Functions | Private Member Functions | Private Attributes | List of all members
reco::shower::ShowerProduedPtrsHolder Class Reference

#include <ShowerProduedPtrsHolder.hh>

Public Member Functions

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

Private Member Functions

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

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 301 of file ShowerProduedPtrsHolder.hh.

Member Function Documentation

void reco::shower::ShowerProduedPtrsHolder::AddDataProducts ( reco::shower::ShowerElementHolder selement_holder)
inline

Definition at line 375 of file ShowerProduedPtrsHolder.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::ShowerProduedPtrsHolder::AddSingle ( A a,
B b,
std::string  Name 
)
inline

Definition at line 421 of file ShowerProduedPtrsHolder.hh.

421  {
422  if(showerassnPtrs.find(Name) == showerassnPtrs.end()){
423  throw cet::exception("ShowerProduedPtrsHolder") << "Trying to get the association: " << Name << "Element does not exist" << std::endl;
424  return;
425  }
426  if(!is_assn<T>::value){
427  throw cet::exception("ShowerProduedPtrsHolder") << "Element type is not an assoication please only use this for assocations" << std::endl;
428  return;
429  }
431  if(assnptr == NULL){
432  throw cet::exception("ShowerProduedPtrsHolder") << "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 == NULL){
437  throw cet::exception("ShowerProduedPtrsHolder") << "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  }
AdcCodeMitigator::Name Name
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
bool reco::shower::ShowerProduedPtrsHolder::CheckAllProducedElements ( reco::shower::ShowerElementHolder selement_holder)
inline

Definition at line 391 of file ShowerProduedPtrsHolder.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
template<class T >
bool reco::shower::ShowerProduedPtrsHolder::CheckForMultipleTypes ( type< T >  ,
std::string  Name,
std::string  Instance 
)
inlineprivate

Definition at line 594 of file ShowerProduedPtrsHolder.hh.

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

Definition at line 608 of file ShowerProduedPtrsHolder.hh.

608  {
609 
610  //Check the a product of the same does not exist without a different instance name
611  for(auto const& product: showerproductPtrs){
613  if(prod != NULL){
614  if(prod->GetInstanceName() == Instance){return false;}
615  }
616  }
617  return true;
618  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
bool reco::shower::ShowerProduedPtrsHolder::CheckUniqueProduerPtr ( std::string  Name)
inline

Definition at line 352 of file ShowerProduedPtrsHolder.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
AdcCodeMitigator::Name Name
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
template<class T >
art::Ptr<T> reco::shower::ShowerProduedPtrsHolder::GetArtPtr ( std::string  Name,
int  iter 
)
inline

Definition at line 471 of file ShowerProduedPtrsHolder.hh.

471  {
472  if(showerPtrMakers.find(Name) == showerPtrMakers.end()){
473  throw cet::exception("ShowerProduedPtrsHolder") << "PtrMaker does not exist for " << Name << " Did you initialise this? " << std::endl;
474  }
475  else{
476  if(!showerPtrMakers[Name]->CheckPtrMaker()){
477  throw cet::exception("ShowerProduedPtrsHolder") << "PtrMaker is not set. This is an issue for the devlopment team me. Contact Dom Barker" << std::endl;
478  }
480  if(ptrmaker == NULL){
481  throw cet::exception("ShowerProduedPtrsHolder") << "Failed to cast back. Maybe you got the type wrong or you are accidently accessing a differently named product" << std::endl;
482  }
483  return ptrmaker->GetArtPtr(iter);
484  }
485  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerPtrMakerBase > > showerPtrMakers
AdcCodeMitigator::Name Name
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
template<class T >
T& reco::shower::ShowerProduedPtrsHolder::GetPtr ( std::string  Name)
inline

Definition at line 403 of file ShowerProduedPtrsHolder.hh.

403  {
404  if(showerproductPtrs.find(Name) != showerproductPtrs.end()){
406  return prod->GetPtr();
407  }
408  else if(showerassnPtrs.find(Name) != showerassnPtrs.end()){
410  return assn->GetPtr();
411  }
412  else{
413  throw cet::exception("ShowerProduedPtrsHolder") << "Trying to get Ptr for: " << Name << " but Element does not exist" << std::endl;
414  return T();
415  }
416  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
AdcCodeMitigator::Name Name
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
template<class T >
art::PtrMaker<T>& reco::shower::ShowerProduedPtrsHolder::GetPtrMaker ( std::string  Name)
inline

Definition at line 456 of file ShowerProduedPtrsHolder.hh.

456  {
457  if(showerPtrMakers.find(Name) == showerPtrMakers.end()){
458  throw cet::exception("ShowerProduedPtrsHolder") << "PtrMaker does not exist" << std::endl;
459  }
460  else{
461  if(!showerPtrMakers[Name]->CheckPtrMaker()){
462  throw cet::exception("ShowerProduedPtrsHolder") << "PtrMaker is not set" << std::endl;
463  }
465  return ptrmaker->GetPtrMaker();
466  }
467  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerPtrMakerBase > > showerPtrMakers
AdcCodeMitigator::Name Name
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
int reco::shower::ShowerProduedPtrsHolder::GetVectorPtrSize ( std::string  Name)
inline

Definition at line 495 of file ShowerProduedPtrsHolder.hh.

495  {
496  if(showerproductPtrs.find(Name) != showerproductPtrs.end()){
497  return showerproductPtrs[Name]->GetVectorPtrSize();
498  }
499  throw cet::exception("ShowerProduedPtrsHolder") << "Product: " << Name << " has not been set in the producers map" << std::endl;
500  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
AdcCodeMitigator::Name Name
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void reco::shower::ShowerProduedPtrsHolder::MoveAllToEvent ( art::Event evt)
inline

Definition at line 382 of file ShowerProduedPtrsHolder.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
void reco::shower::ShowerProduedPtrsHolder::PrintPtr ( std::string  Name)
inline

Definition at line 503 of file ShowerProduedPtrsHolder.hh.

503  {
504  if(showerproductPtrs.find(Name) != showerproductPtrs.end()){
505  std::string Type = showerproductPtrs[Name]->GetType();
506  std::string InstanceName = showerproductPtrs[Name]->GetInstanceName();
507  std::cout << "Element Name: " << Name << " Instance Name: " << InstanceName << " Type: " << Type << std::endl;
508  return;
509  }
510  if(showerassnPtrs.find(Name) != showerassnPtrs.end()){
511  std::string Type = showerassnPtrs[Name]->GetType();
512  std::string InstanceName = showerassnPtrs[Name]->GetInstanceName();
513  std::cout << "Element Name: " << Name << " Instance Name: " << InstanceName << " Type: " << Type << std::endl;
514  return;
515  }
516  mf::LogError("ShowerProduedPtrsHolder") << "Trying to print Element: " << Name << ". This element does not exist in the element holder" << std::endl;
517  return;
518  }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
AdcCodeMitigator::Name Name
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
Type
Type of JSON value.
Definition: rapidjson.h:618
QTextStream & endl(QTextStream &s)
void reco::shower::ShowerProduedPtrsHolder::PrintPtrs ( )
inline

Definition at line 522 of file ShowerProduedPtrsHolder.hh.

522  {
523 
524  unsigned int maxname = 0;
525  for(auto const& showerprodPtr: showerproductPtrs){
526  if(showerprodPtr.first.size() > maxname){
527  maxname = showerprodPtr.first.size();
528  }
529  }
530  for(auto const& showerassnPtr: showerassnPtrs){
531  if(showerassnPtr.first.size() > maxname){
532  maxname = showerassnPtr.first.size();
533  }
534  }
535 
536  std::map<std::string,std::pair<std::string,std::string> > Type_showerprodPtrs;
537  std::map<std::string,std::pair<std::string,std::string> > Type_showerassnPtrs;
538  for(auto const& showerprodPtr: showerproductPtrs){
539  std::string Type = (showerprodPtr.second)->GetType();
540  std::string InstanceName = (showerprodPtr.second)->GetInstanceName();
541  Type_showerprodPtrs[showerprodPtr.first] = std::make_pair(InstanceName,Type);
542  }
543  for(auto const& showerassnPtr: showerassnPtrs){
544  std::string Type = (showerassnPtr.second)->GetType();
545  std::string InstanceName = (showerassnPtr.second)->GetInstanceName();
546  Type_showerassnPtrs[showerassnPtr.first] = std::make_pair(InstanceName,Type);
547  }
548 
549  unsigned int maxtype = 0;
550  unsigned int maxinstname = 0;
551  for(auto const& Type_showerprodPtr: Type_showerprodPtrs){
552  if(Type_showerprodPtr.second.second.size() > maxtype){
553  maxtype = Type_showerprodPtr.second.second.size();
554  }
555  if(Type_showerprodPtr.second.first.size() > maxinstname){
556  maxinstname = Type_showerprodPtr.second.first.size();
557  }
558  }
559  for(auto const& Type_showerassnPtr: Type_showerassnPtrs){
560  if(Type_showerassnPtr.second.second.size() > maxtype){
561  maxtype = Type_showerassnPtr.second.second.size();
562  }
563  if(Type_showerassnPtr.second.first.size() > maxinstname){
564  maxinstname = Type_showerassnPtr.second.first.size();
565  }
566  }
567 
568  unsigned int n = maxname + maxtype + maxinstname + 51;
569  std::cout << std::left << std::setfill('*') << std::setw(n-1) << "**" <<std::endl;
570  std::cout << "Unique Ptrs that are added to the event" << std::endl;
571  std::cout << std::left << std::setfill('*') << std::setw(n-1) << "**" <<std::endl;
572  for(auto const& Type_showerprodPtr: Type_showerprodPtrs){
573  std::cout << std::left << std::setfill(' ') << std::setw(21) << "* Data Product Name: " << std::setw(maxname) << Type_showerprodPtr.first;
574  std::cout << std::left << std::setfill(' ') << " * Instance Name: " << std::setw(maxinstname) << Type_showerprodPtr.second.first;
575  std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype) << Type_showerprodPtr.second.second << " *" << std::endl;
576  }
577  for(auto const& Type_showerassnPtr: Type_showerassnPtrs){
578  std::cout << std::left << std::setfill(' ') << std::setw(maxname) << std::setw(21) << "* Association Name: " << std::setw(maxname) << Type_showerassnPtr.first;
579  std::cout << std::left << std::setfill(' ') << " * Instance Name: " << std::setw(maxinstname) << Type_showerassnPtr.second.first;
580  std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype) << Type_showerassnPtr.second.second<< " *" << std::endl;
581  }
582  std::cout << std::left << std::setfill('*') << std::setw(n-1) << "**" <<std::endl;
583  std::cout << std::setfill(' ');
584  std::cout << std::setw(0);
585  return;
586  }
std::string string
Definition: nybbler.cc:12
std::void_t< T > n
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
Type
Type of JSON value.
Definition: rapidjson.h:618
Q_EXPORT QTSManip setfill(int f)
Definition: qtextstream.h:337
QTextStream & endl(QTextStream &s)
void reco::shower::ShowerProduedPtrsHolder::reset ( void  )
inline

Definition at line 363 of file ShowerProduedPtrsHolder.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::ShowerProduedPtrsHolder::ResetPtrMakers ( )
inline

Definition at line 488 of file ShowerProduedPtrsHolder.hh.

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

Definition at line 445 of file ShowerProduedPtrsHolder.hh.

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

Definition at line 307 of file ShowerProduedPtrsHolder.hh.

307  {
308 
309  //Add to the assns
310  if(showerassnPtrs.find(Name) != showerassnPtrs.end()){
311  mf::LogWarning("ShowerProduedPtrsHolder") << "Trying to set Element: " << Name << ". This element has already been set. Please check." << std::endl;
312  return 1;
313  }
314 
315  //Check the same type has not already been set.
316  if(!CheckForMultipleTypes(type<T>(), Name, Instance)){
317  throw cet::exception("ShowerProduedPtrsHolder") << "Trying to set multiple objects with same type with no instance name or same instance name" << std::endl;
318  return 1;
319  }
320 
321  showerassnPtrs[Name] = std::unique_ptr<reco::shower::ShowerUniqueAssnPtr<T> >(new reco::shower::ShowerUniqueAssnPtr<T>(Instance));
322  return 0;
323  }
bool CheckForMultipleTypes(type< T >, std::string Name, std::string Instance)
AdcCodeMitigator::Name Name
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
template<class T >
int reco::shower::ShowerProduedPtrsHolder::SetShowerUniqueProduerPtr ( type< std::vector< T > >  ,
std::string  Name,
std::string  Instance = "" 
)
inline

Definition at line 327 of file ShowerProduedPtrsHolder.hh.

327  {
328 
329  //Then add the products
330  if(showerproductPtrs.find(Name) != showerproductPtrs.end()){
331  mf::LogWarning("ShowerProduedPtrsHolder") << "Trying to set Element: " << Name << ". This element has already been set. Please check." << std::endl;
332  return 1;
333  }
334 
335  //Check the same type has not already been set.
336  if(!CheckForMultipleTypes(type<std::vector<T> >(), Name, Instance)){
337  throw cet::exception("ShowerProduedPtrsHolder") << "Trying to set multiple objects with same type with no instance name or same instance name" << std::endl;
338  return 1;
339  }
340 
341  if(showerPtrMakers.find(Name) != showerPtrMakers.end()){
342  throw cet::exception("ShowerProduedPtrsHolder") << "PtrMaker already exist. It should not be set again" << std::endl;
343  return 1;
344  }
345  showerPtrMakers[Name] = std::unique_ptr<reco::shower::ShowerPtrMaker<T> >(new reco::shower::ShowerPtrMaker<T>(Instance));
346  showerproductPtrs[Name] = std::unique_ptr<reco::shower::ShowerUniqueProductPtr<std::vector<T > > >(new reco::shower::ShowerUniqueProductPtr<std::vector<T> >(Instance));
347  return 0;
348  }
std::map< std::string, std::unique_ptr< reco::shower::ShowerPtrMakerBase > > showerPtrMakers
bool CheckForMultipleTypes(type< T >, std::string Name, std::string Instance)
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
AdcCodeMitigator::Name Name
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)

Member Data Documentation

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

Definition at line 626 of file ShowerProduedPtrsHolder.hh.

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

Definition at line 623 of file ShowerProduedPtrsHolder.hh.

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

Definition at line 629 of file ShowerProduedPtrsHolder.hh.


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