10 #ifndef ShowerElementHolder_HH 11 #define ShowerElementHolder_HH 14 #include "canvas/Persistency/Common/FindOneP.h" 15 #include "canvas/Persistency/Common/FindManyP.h" 24 #include "cetlib_except/demangle.h" 115 return cet::demangle_symbol(
typeid(element).
name());
172 template <
class T,
class T2>
179 propertyErr = ElementErr;
185 ElementErr = propertyErr;
195 this->element = Element;
197 propertyErr = ElementErr;
220 auto const showerPropertiesIt = showerproperties.find(Name);
221 if(showerPropertiesIt != showerproperties.end()){
222 if(showerPropertiesIt->second->CheckShowerElement()){
224 if(showerprop ==
nullptr){
225 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element you are filling is not the correct type" <<
std::endl;
231 mf::LogWarning(
"ShowerElementHolder") <<
"Trying to get Element " << Name <<
". This elment has not been filled" <<
std::endl;
236 auto const showerDataProductsIt = showerdataproducts.find(Name);
237 if(showerDataProductsIt != showerdataproducts.end()){
238 if(showerDataProductsIt->second->CheckShowerElement()){
240 if(showerprop ==
nullptr){
241 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element you are filling is not the correct type" <<
std::endl;
247 mf::LogWarning(
"ShowerElementHolder") <<
"Trying to get Element " << Name <<
". This elment has not been filled" <<
std::endl;
252 auto const eventDataProductsIt = eventdataproducts.find(Name);
253 if (eventDataProductsIt != eventdataproducts.end()){
254 if(eventDataProductsIt->second->CheckShowerElement()){
256 if(eventprop ==
nullptr){
257 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element you are filling is not the correct type" <<
std::endl;
262 mf::LogWarning(
"ShowerElementHolder") <<
"Trying to get Element " << Name <<
". This elment has not been filled" <<
std::endl;
266 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element does not exist in the element holder" <<
std::endl;
271 auto const eventDataProductsIt = eventdataproducts.find(Name);
272 if (eventDataProductsIt != eventdataproducts.end()){
273 if(eventDataProductsIt->second->CheckShowerElement()){
275 if(eventprop ==
nullptr){
276 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element you are filling is not the correct type" <<
std::endl;
281 mf::LogWarning(
"ShowerElementHolder") <<
"Trying to get Element " << Name <<
". This elment has not been filled" <<
std::endl;
285 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element does not exist in the element holder" <<
std::endl;
291 auto const eventDataProductsIt = eventdataproducts.find(Name);
292 if (eventDataProductsIt != eventdataproducts.end()){
293 if(eventDataProductsIt->second->CheckShowerElement()){
295 if(eventprop ==
nullptr){
296 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element you are filling is not the correct type" <<
std::endl;
301 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element does not exist in the element holder" <<
std::endl;
307 auto const showerPropertiesIt = showerproperties.find(Name);
308 if(showerPropertiesIt != showerproperties.end()){
309 if(showerPropertiesIt->second->CheckShowerElement()){
311 if(showerprop ==
nullptr){
312 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element you are filling is not the correct type" <<
std::endl;
318 auto const showerDataProductsIt = showerdataproducts.find(Name);
319 if(showerDataProductsIt != showerdataproducts.end()){
320 if(showerDataProductsIt->second->CheckShowerElement()){
322 if(showerprop ==
nullptr){
323 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element you are filling is not the correct type" <<
std::endl;
329 auto const eventDataProductsIt = eventdataproducts.find(Name);
330 if (eventDataProductsIt != eventdataproducts.end()){
331 if(eventDataProductsIt->second->CheckShowerElement()){
333 if(eventprop ==
nullptr){
334 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element you are filling is not the correct type" <<
std::endl;
339 throw cet::exception(
"ShowerElementHolder") <<
"Trying to get Element: " << Name <<
". This element does not exist in the element holder" <<
std::endl;
343 template <
class T,
class T2>
345 auto const showerPropertiesIt = showerproperties.find(Name);
346 if(showerPropertiesIt == showerproperties.end()){
347 mf::LogError(
"ShowerElementHolder") <<
"Trying to get Element Error: " << Name <<
". This elment does not exist in the element holder" <<
std::endl;
362 auto const showerDataProductsIt = showerdataproducts.find(Name);
363 if(showerDataProductsIt != showerdataproducts.end()){
370 showerdataproducts[
Name] = std::make_unique<ShowerDataProduct<T> >(dataproduct,checktag);
377 template <
class T,
class T2>
380 auto const showerPropertiesIt = showerproperties.find(Name);
381 if(showerPropertiesIt != showerproperties.end()){
387 showerproperties[
Name] = std::make_unique<ShowerProperty<T,T2> >(propertyval,propertyvalerror);
397 auto const eventDataProductsIt = eventdataproducts.find(Name);
398 if (eventDataProductsIt != eventdataproducts.end()){
404 eventdataproducts[
Name] = std::make_unique<EventDataProduct<T> >(dataproduct);
410 auto const eventDataProductsIt = eventdataproducts.find(Name);
411 return eventDataProductsIt == eventdataproducts.end() ?
false : eventDataProductsIt->second->CheckShowerElement();
416 auto const showerPropertiesIt = showerproperties.find(Name);
417 if(showerPropertiesIt != showerproperties.end()){
418 return showerPropertiesIt->second->CheckShowerElement();
420 auto const showerDataProductsIt = showerdataproducts.find(Name);
421 if(showerDataProductsIt != showerdataproducts.end()){
422 return showerDataProductsIt->second->CheckShowerElement();
424 auto const eventDataProductsIt = eventdataproducts.find(Name);
425 if(eventDataProductsIt!= eventdataproducts.end()){
426 return eventDataProductsIt->second->CheckShowerElement();
434 for(
auto const& showerprop: showerproperties){
435 checked *= showerprop.second->CheckShowerElement();
437 for(
auto const& showerdataprod: showerdataproducts){
438 checked *= showerdataprod.second->CheckShowerElement();
446 auto const showerPropertiesIt = showerproperties.find(Name);
447 if(showerPropertiesIt != showerproperties.end()){
448 return showerPropertiesIt->second->Clear();
450 auto const showerDataProductsIt = showerdataproducts.find(Name);
451 if(showerDataProductsIt != showerdataproducts.end()){
452 return showerDataProductsIt->second->Clear();
454 mf::LogError(
"ShowerElementHolder") <<
"Trying to clear Element: " << Name <<
". This element does not exist in the element holder" <<
std::endl;
460 for(
auto const& showerprop: showerproperties){
461 (showerprop.second)->
Clear();
463 for(
auto const& showerdataproduct: showerdataproducts){
464 (showerdataproduct.second)->
Clear();
469 for(
auto const& eventdataproduct: eventdataproducts){
470 (eventdataproduct.second)->
Clear();
481 auto const showerDataProductsIt = showerdataproducts.find(Name);
482 if(showerDataProductsIt != showerdataproducts.end()){
483 return showerDataProductsIt->second->CheckTag();
490 auto const showerPropertiesIt = showerproperties.find(Name);
491 if(showerPropertiesIt != showerproperties.end()){
492 return showerPropertiesIt->second.reset(
nullptr);
494 auto const showerDataProductsIt = showerdataproducts.find(Name);
495 if(showerDataProductsIt != showerdataproducts.end()){
496 return showerDataProductsIt->second.reset(
nullptr);
498 mf::LogError(
"ShowerElementHolder") <<
"Trying to delete Element: " << Name <<
". This element does not exist in the element holder" <<
std::endl;
504 auto const showerDataProductsIt = showerdataproducts.find(Name);
505 if(showerDataProductsIt != showerdataproducts.end()){
506 return showerDataProductsIt->second->SetCheckTag(checkelement);
508 mf::LogError(
"ShowerElementHolder") <<
"Trying set the checking of the data product: " << Name <<
". This data product does not exist in the element holder" <<
std::endl;
514 for(
auto const& showerdataproduct: showerdataproducts){
515 bool check = showerdataproduct.second->CheckTag();
517 bool elementset = showerdataproduct.second->CheckShowerElement();
519 mf::LogError(
"ShowerElementHolder") <<
"The following element is not set and was asked to be checked: " << showerdataproduct.first <<
std::endl;
529 showernumber = shower_iter;
540 unsigned int maxname = 0;
541 for(
auto const& showerprop: showerproperties){
542 if(showerprop.first.size() > maxname){
543 maxname = showerprop.first.size();
546 for(
auto const& showerdataprod: showerdataproducts){
547 if(showerdataprod.first.size() > maxname){
548 maxname = showerdataprod.first.size();
552 std::map<std::string,std::string> Type_showerprops;
553 std::map<std::string,std::string> Type_showerdataprods;
554 for(
auto const& showerprop: showerproperties){
556 Type_showerprops[showerprop.first] =
Type;
558 for(
auto const& showerdataprod: showerdataproducts){
560 Type_showerdataprods[showerdataprod.first] =
Type;
563 unsigned int maxtype = 0;
564 for(
auto const& Type_showerprop: Type_showerprops){
565 if(Type_showerprop.second.size() > maxtype){
566 maxtype = Type_showerprop.second.size();
569 for(
auto const& Type_showerdataprod: Type_showerdataprods){
570 if(Type_showerdataprod.second.size() > maxtype){
571 maxtype = Type_showerdataprod.second.size();
575 unsigned int n = maxname + maxtype + 33;
577 std::cout <<
"Elements in the element holder" <<
std::endl;
579 for(
auto const& Type_showerprop: Type_showerprops){
583 for(
auto const& Type_showerdataprod: Type_showerdataprods){
595 return cet::demangle_symbol(
typeid(
object).
name());
600 return cet::demangle_symbol(
typeid(
T).
name());
603 template <
class T1,
class T2>
609 if (CheckEventElement(
name)){
610 return GetEventElement<art::FindManyP<T1> >(
name);
612 art::FindManyP<T1> findManyP(handle, evt, moduleTag);
613 if (findManyP.isValid()){
614 SetEventElement(findManyP,
name);
615 return GetEventElement<art::FindManyP<T1> >(
name);
622 template <
class T1,
class T2>
628 if (CheckEventElement(
name)){
629 return GetEventElement<art::FindOneP<T1> >(
name);
631 art::FindOneP<T1> findOneP(handle, evt, moduleTag);
632 if (findOneP.isValid()){
633 SetEventElement(findOneP,
name);
634 return GetEventElement<art::FindOneP<T1> >(
name);
std::map< std::string, std::unique_ptr< reco::shower::ShowerElementBase > > showerdataproducts
void DeleteElement(const std::string &Name)
bool CheckShowerElement() const
virtual ~ShowerElementBase() noexcept=default
int GetShowerNumber() const
int GetShowerElement(T &Element) const
std::map< std::string, std::unique_ptr< reco::shower::ShowerElementBase > > showerproperties
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
virtual void SetCheckTag(bool &check)
void SetElementTag(const std::string &Name, bool checkelement)
ChannelGroupService::Name Name
virtual bool CheckTag() const
void SetEventElement(T &dataproduct, const std::string &Name)
const art::FindOneP< T1 > & GetFindOneP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
std::string GetType() const override
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
EventDataProduct(T &Element)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool check(const std::vector< std::vector< float > > &outputs)
const T & GetEventElement(std::string const &Name)
void SetElement(T &propertyval, T2 &propertyvalerror, const std::string &Name)
void SetCheckTag(bool &Checktag)
void PrintElements() const
ShowerProperty(T &Element, T2 &ElementErr)
bool CheckElement(const std::string &Name) const
std::map< std::string, std::unique_ptr< reco::shower::ShowerElementBase > > eventdataproducts
bool CheckElementTag(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
void SetShowerElement(T &Element)
bool CheckEventElement(const std::string &Name) const
T GetElement(const std::string &Name) const
Q_EXPORT QTSManip setw(int w)
ShowerDataProduct(T &Element, bool Checktag)
void SetShowerProperty(T &Element, T2 &ElementErr)
void SetShowerNumber(int &shower_iter)
T GetShowerElement() const
int GetEventElement(const std::string &Name, T &Element) const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
int GetShowerPropertyError(T2 &ElementErr) const
bool CheckAllElements() const
void ClearElement(const std::string &Name)
int GetElementAndError(const std::string &Name, T &Element, T2 &ElementErr) const
std::string getType(T object) const
T & GetShowerElementRef()
virtual std::string GetType() const =0
std::string getType() const
Q_EXPORT QTSManip setfill(int f)
bool CheckAllElementTags() const
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
ShowerElementAccessor(T &Element)