Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ShowerElementHolder.hh
Go to the documentation of this file.
1//###################################################################
2//### Name: ShowerElementHolder ###
3//### Author: Dominic Barker, Ed Tyley ###
4//### Date: 15.07.19 ###
5//### Description: Class to holder the standard shower property ###
6//### information. Used in LArPandoraModularShower ###
7//### and corresponding tools ###
8//###################################################################
9
10#ifndef ShowerElementHolder_HH
11#define ShowerElementHolder_HH
12
13//Framework includes
14#include "art/Framework/Principal/Handle.h"
15#include "canvas/Persistency/Common/FindManyP.h"
16#include "canvas/Persistency/Common/FindOneP.h"
17#include "cetlib_except/demangle.h"
18#include "cetlib_except/exception.h"
19#include "messagefacility/MessageLogger/MessageLogger.h"
20
21//C++ Inlcudes
22#include <iomanip>
23#include <iostream>
24#include <map>
25#include <memory>
26#include <string>
27
28namespace reco::shower {
29 class ShowerElementBase;
30 template <class T>
31 class ShowerElementAccessor;
32 template <class T>
33 class ShowerDataProduct;
34 template <class T>
35 class EventDataProduct;
36 template <class T, class T2>
37 class ShowerProperty;
38 class ShowerElementHolder;
39}
40
42
43public:
44 virtual ~ShowerElementBase() noexcept = default;
45
46 virtual bool CheckTag() const
47 {
48 throw cet::exception("ShowerElementHolder")
49 << "Trying to check an element that is not a product" << std::endl;
50 }
51 virtual void SetCheckTag(bool& check)
52 {
53 throw cet::exception("ShowerElementHolder")
54 << "Trying to set an element that is not a product" << std::endl;
55 }
56
57 virtual std::string GetType() const = 0;
58
59 //Check if the element has been set.
60 bool CheckShowerElement() const
61 {
62 if (elementPtr)
63 return true;
64 else
65 return false;
66 }
67
68 void Clear() { elementPtr = 0; }
69
70protected:
72};
73
74//This is a template class which holds a shower property. This holds any object e.g. std::vector<double>, double, TVector3
75//and holds various information which helps the showerproperty holder access the elements. A user should not require any part
76//of this class.
77template <class T>
79
80public:
81 ShowerElementAccessor(T& Element) : element(Element)
82 {
83 this->elementPtr = 1;
84 // this->element = Element;
85 }
86
87 //Set the element in the holder
88 void SetShowerElement(T& Element)
89 {
90 element = Element;
91 this->elementPtr = 1;
92 }
93
94 //Fill Element with the element that the holder holds.
95 int GetShowerElement(T& Element) const
96 {
97 if (this->elementPtr) {
98 Element = element;
99 return 0;
100 }
101 else {
102 return 1;
103 }
104 }
105
106 //Return a copy of the shower element.
108 {
109 if (!this->elementPtr) {
110 throw cet::exception("ShowerElementHolder")
111 << "The element that is being accessed is not set" << std::endl;
112 }
113 return element;
114 }
115
117 {
118 if (!this->elementPtr) {
119 throw cet::exception("ShowerElementHolder")
120 << "The element that is being accessed is not set" << std::endl;
121 }
122 return element;
123 }
124
125 //Return the type as a string.
126 std::string GetType() const override { return cet::demangle_symbol(typeid(element).name()); }
127
128protected:
130};
131
132//This class holds shower data products which have the potential to be saved in the art::Event e.g. recob::Track. Note the product itself must be store in the element holder as the object will be destoryed in the CalculateProperty Section otherwise. Associtations can be made during Calculate property tool stage.
133template <class T>
135
136public:
137 ShowerDataProduct(T& Element, bool Checktag) : reco::shower::ShowerElementAccessor<T>{Element}
138 {
139 checktag = Checktag;
140 }
141
142 void Clear()
143 {
144 this->element = T();
145 this->elementPtr = 0;
146 }
147
148 //Check if we should check the dataproduct in the end.
149 bool CheckTag() const { return checktag; }
150
151 //Set if we should check the data product in the end.
152 void SetCheckTag(bool& Checktag) { checktag = Checktag; }
153
154private:
156};
157
158// This class holds the things we want per event rather than per shower, e.g. FindManyP
159template <class T>
161
162public:
163 EventDataProduct(T& Element) : reco::shower::ShowerElementAccessor<T>{Element} {}
164
165 void Clear()
166 {
167 // this->element = T();
168 this->elementPtr = 0;
169 }
170};
171
172//This class holds shower properties e.g. ShowerDirection. The user must define the associated error
173template <class T, class T2>
175
176public:
177 ShowerProperty(T& Element, T2& ElementErr) : reco::shower::ShowerElementAccessor<T>{Element}
178 {
179 propertyErr = ElementErr;
180 }
181
182 //Fill the property error as long as it has been set.
183 int GetShowerPropertyError(T2& ElementErr) const
184 {
185 if (this->elementPtr) {
186 ElementErr = propertyErr;
187 return 0;
188 }
189 else {
190 return 1;
191 }
192 }
193
194 //Set the properties. Note you cannot set an property without an error.
195 void SetShowerProperty(T& Element, T2& ElementErr)
196 {
197 this->element = Element;
198 this->elementPtr = 1;
199 propertyErr = ElementErr;
200 }
201
202 void Clear()
203 {
204 this->element = T();
205 this->elementPtr = 0;
206 }
207
208private:
210};
211
212//Class to holder all the reco::shower::ShowerElement objects. This is essentially a map from a string the object so people can
213//add an object in a tool and get it back later.
215
216public:
217 //Getter function for accessing the shower property e..g the direction ShowerElementHolder.GetElement("MyShowerValue"); The name is used access the value and precise names are required for a complete shower in LArPandoraModularShowerCreation: ShowerStartPosition, ShowerDirection, ShowerEnergy ,ShowerdEdx.
218 template <class T>
219 int GetElement(const std::string& Name, T& Element) const
220 {
221 auto const showerPropertiesIt = showerproperties.find(Name);
222 if (showerPropertiesIt != showerproperties.end()) {
223 if (showerPropertiesIt->second->CheckShowerElement()) {
225 dynamic_cast<reco::shower::ShowerElementAccessor<T>*>(showerPropertiesIt->second.get());
226 if (showerprop == nullptr) {
227 throw cet::exception("ShowerElementHolder")
228 << "Trying to get Element: " << Name
229 << ". This element you are filling is not the correct type" << std::endl;
230 }
231 showerprop->GetShowerElement(Element);
232 return 0;
233 }
234 else {
235 mf::LogWarning("ShowerElementHolder")
236 << "Trying to get Element " << Name << ". This elment has not been filled" << std::endl;
237 return 1;
238 }
239 }
240
241 auto const showerDataProductsIt = showerdataproducts.find(Name);
242 if (showerDataProductsIt != showerdataproducts.end()) {
243 if (showerDataProductsIt->second->CheckShowerElement()) {
245 dynamic_cast<reco::shower::ShowerElementAccessor<T>*>(showerDataProductsIt->second.get());
246 if (showerprop == nullptr) {
247 throw cet::exception("ShowerElementHolder")
248 << "Trying to get Element: " << Name
249 << ". This element you are filling is not the correct type" << std::endl;
250 }
251 showerprop->GetShowerElement(Element);
252 return 0;
253 }
254 else {
255 mf::LogWarning("ShowerElementHolder")
256 << "Trying to get Element " << Name << ". This elment has not been filled" << std::endl;
257 return 1;
258 }
259 }
260
261 auto const eventDataProductsIt = eventdataproducts.find(Name);
262 if (eventDataProductsIt != eventdataproducts.end()) {
263 if (eventDataProductsIt->second->CheckShowerElement()) {
265 dynamic_cast<reco::shower::ShowerElementAccessor<T>*>(eventDataProductsIt->second.get());
266 if (eventprop == nullptr) {
267 throw cet::exception("ShowerElementHolder")
268 << "Trying to get Element: " << Name
269 << ". This element you are filling is not the correct type" << std::endl;
270 }
271 eventprop->GetShowerElement(Element);
272 return 0;
273 }
274 else {
275 mf::LogWarning("ShowerElementHolder")
276 << "Trying to get Element " << Name << ". This elment has not been filled" << std::endl;
277 return 1;
278 }
279 }
280 throw cet::exception("ShowerElementHolder")
281 << "Trying to get Element: " << Name << ". This element does not exist in the element holder"
282 << std::endl;
283 }
284
285 template <class T>
286 int GetEventElement(const std::string& Name, T& Element) const
287 {
288 auto const eventDataProductsIt = eventdataproducts.find(Name);
289 if (eventDataProductsIt != eventdataproducts.end()) {
290 if (eventDataProductsIt->second->CheckShowerElement()) {
292 dynamic_cast<reco::shower::ShowerElementAccessor<T>*>(eventDataProductsIt->second.get());
293 if (eventprop == nullptr) {
294 throw cet::exception("ShowerElementHolder")
295 << "Trying to get Element: " << Name
296 << ". This element you are filling is not the correct type" << std::endl;
297 }
298 eventprop->GetShowerElement(Element);
299 return 0;
300 }
301 else {
302 mf::LogWarning("ShowerElementHolder")
303 << "Trying to get Element " << Name << ". This elment has not been filled" << std::endl;
304 return 1;
305 }
306 }
307 throw cet::exception("ShowerElementHolder")
308 << "Trying to get Element: " << Name << ". This element does not exist in the element holder"
309 << std::endl;
310 }
311
312 //Alternative get function that returns the object. Not recommended.
313 template <class T>
314 const T& GetEventElement(std::string const& Name)
315 {
316 auto const eventDataProductsIt = eventdataproducts.find(Name);
317 if (eventDataProductsIt != eventdataproducts.end()) {
318 if (eventDataProductsIt->second->CheckShowerElement()) {
320 dynamic_cast<reco::shower::ShowerElementAccessor<T>*>(eventDataProductsIt->second.get());
321 if (eventprop == nullptr) {
322 throw cet::exception("ShowerElementHolder")
323 << "Trying to get Element: " << Name
324 << ". This element you are filling is not the correct type" << std::endl;
325 }
326 return eventprop->GetShowerElementRef();
327 }
328 }
329 throw cet::exception("ShowerElementHolder")
330 << "Trying to get Element: " << Name << ". This element does not exist in the element holder"
331 << std::endl;
332 }
333
334 //Alternative get function that returns the object. Not recommended.
335 template <class T>
336 T GetElement(const std::string& Name) const
337 {
338 auto const showerPropertiesIt = showerproperties.find(Name);
339 if (showerPropertiesIt != showerproperties.end()) {
340 if (showerPropertiesIt->second->CheckShowerElement()) {
342 dynamic_cast<reco::shower::ShowerElementAccessor<T>*>(showerPropertiesIt->second.get());
343 if (showerprop == nullptr) {
344 throw cet::exception("ShowerElementHolder")
345 << "Trying to get Element: " << Name
346 << ". This element you are filling is not the correct type" << std::endl;
347 }
348 return showerprop->GetShowerElement();
349 }
350 }
351
352 auto const showerDataProductsIt = showerdataproducts.find(Name);
353 if (showerDataProductsIt != showerdataproducts.end()) {
354 if (showerDataProductsIt->second->CheckShowerElement()) {
356 dynamic_cast<reco::shower::ShowerElementAccessor<T>*>(showerDataProductsIt->second.get());
357 if (showerprop == nullptr) {
358 throw cet::exception("ShowerElementHolder")
359 << "Trying to get Element: " << Name
360 << ". This element you are filling is not the correct type" << std::endl;
361 }
362 return showerprop->GetShowerElement();
363 }
364 }
365
366 auto const eventDataProductsIt = eventdataproducts.find(Name);
367 if (eventDataProductsIt != eventdataproducts.end()) {
368 if (eventDataProductsIt->second->CheckShowerElement()) {
370 dynamic_cast<reco::shower::ShowerElementAccessor<T>*>(eventDataProductsIt->second.get());
371 if (eventprop == nullptr) {
372 throw cet::exception("ShowerElementHolder")
373 << "Trying to get Element: " << Name
374 << ". This element you are filling is not the correct type" << std::endl;
375 }
376 return eventprop->GetShowerElement();
377 }
378 }
379 throw cet::exception("ShowerElementHolder")
380 << "Trying to get Element: " << Name << ". This element does not exist in the element holder"
381 << std::endl;
382 }
383
384 //Getter function for accessing the shower property error e.g the direction ShowerElementHolder.GetElement("MyShowerValue");
385 template <class T, class T2>
386 int GetElementAndError(const std::string& Name, T& Element, T2& ElementErr) const
387 {
388 auto const showerPropertiesIt = showerproperties.find(Name);
389 if (showerPropertiesIt == showerproperties.end()) {
390 mf::LogError("ShowerElementHolder")
391 << "Trying to get Element Error: " << Name
392 << ". This elment does not exist in the element holder" << std::endl;
393 return 1;
394 }
396 dynamic_cast<reco::shower::ShowerProperty<T, T2>*>(showerPropertiesIt->second.get());
397 showerprop->GetShowerElement(Element);
398 showerprop->GetShowerPropertyError(ElementErr);
399 return 0;
400 }
401
402 //This sets the value of the data product. Just give a name and a object
403 //e.g. TVector3 ShowerElementHolder.SetElement((TVector3) StartPosition, "StartPosition");
404 template <class T>
405 void SetElement(T& dataproduct, const std::string& Name, bool checktag = false)
406 {
407
408 auto const showerDataProductsIt = showerdataproducts.find(Name);
409 if (showerDataProductsIt != showerdataproducts.end()) {
410 reco::shower::ShowerDataProduct<T>* showerdataprod =
411 dynamic_cast<reco::shower::ShowerDataProduct<T>*>(showerDataProductsIt->second.get());
412 showerdataprod->SetShowerElement(dataproduct);
413 showerdataprod->SetCheckTag(checktag);
414 return;
415 }
416 else {
417 showerdataproducts[Name] = std::make_unique<ShowerDataProduct<T>>(dataproduct, checktag);
418 return;
419 }
420 }
421
422 //This sets the value of the property. Just give a name and a object
423 //e.g. TVector3 ShowerElementHolder.SetElement((art::Ptr<recob::Track>) track, "StartPosition", save);
424 template <class T, class T2>
425 void SetElement(T& propertyval, T2& propertyvalerror, const std::string& Name)
426 {
427
428 auto const showerPropertiesIt = showerproperties.find(Name);
429 if (showerPropertiesIt != showerproperties.end()) {
431 dynamic_cast<reco::shower::ShowerProperty<T, T2>*>(showerPropertiesIt->second.get());
432 showerprop->SetShowerProperty(propertyval, propertyvalerror);
433 return;
434 }
435 else {
436 showerproperties[Name] =
437 std::make_unique<ShowerProperty<T, T2>>(propertyval, propertyvalerror);
438 return;
439 }
440 }
441
442 //This sets the value of the event data product. Just give a name and a object
443 //e.g. TVector3 ShowerElementHolder.SetEventElement((TVector3) StartPosition, "StartPosition");
444 template <class T>
445 void SetEventElement(T& dataproduct, const std::string& Name)
446 {
447
448 auto const eventDataProductsIt = eventdataproducts.find(Name);
449 if (eventDataProductsIt != eventdataproducts.end()) {
450 reco::shower::EventDataProduct<T>* eventdataprod =
451 dynamic_cast<reco::shower::EventDataProduct<T>*>(eventDataProductsIt->second.get());
452 eventdataprod->SetShowerElement(dataproduct);
453 return;
454 }
455 else {
456 eventdataproducts[Name] = std::make_unique<EventDataProduct<T>>(dataproduct);
457 return;
458 }
459 }
460
461 bool CheckEventElement(const std::string& Name) const
462 {
463 auto const eventDataProductsIt = eventdataproducts.find(Name);
464 return eventDataProductsIt == eventdataproducts.end() ?
465 false :
466 eventDataProductsIt->second->CheckShowerElement();
467 }
468
469 //Check that a property is filled
470 bool CheckElement(const std::string& Name) const
471 {
472 auto const showerPropertiesIt = showerproperties.find(Name);
473 if (showerPropertiesIt != showerproperties.end()) {
474 return showerPropertiesIt->second->CheckShowerElement();
475 }
476 auto const showerDataProductsIt = showerdataproducts.find(Name);
477 if (showerDataProductsIt != showerdataproducts.end()) {
478 return showerDataProductsIt->second->CheckShowerElement();
479 }
480 auto const eventDataProductsIt = eventdataproducts.find(Name);
481 if (eventDataProductsIt != eventdataproducts.end()) {
482 return eventDataProductsIt->second->CheckShowerElement();
483 }
484 return false;
485 }
486
487 //Check All the properties
488 bool CheckAllElements() const
489 {
490 bool checked = true;
491 for (auto const& showerprop : showerproperties) {
492 checked = checked && showerprop.second->CheckShowerElement();
493 }
494 for (auto const& showerdataprod : showerdataproducts) {
495 checked = checked && showerdataprod.second->CheckShowerElement();
496 }
497 return checked;
498 }
499
500 //Clear Fucntion. This does not delete the element.
501 void ClearElement(const std::string& Name)
502 {
503 auto const showerPropertiesIt = showerproperties.find(Name);
504 if (showerPropertiesIt != showerproperties.end()) {
505 return showerPropertiesIt->second->Clear();
506 }
507 auto const showerDataProductsIt = showerdataproducts.find(Name);
508 if (showerDataProductsIt != showerdataproducts.end()) {
509 return showerDataProductsIt->second->Clear();
510 }
511 mf::LogError("ShowerElementHolder")
512 << "Trying to clear Element: " << Name
513 << ". This element does not exist in the element holder" << std::endl;
514 return;
515 }
516
517 //Clear all the shower properties. This does not delete the element.
519 {
520 for (auto const& showerprop : showerproperties) {
521 (showerprop.second)->Clear();
522 }
523 for (auto const& showerdataproduct : showerdataproducts) {
524 (showerdataproduct.second)->Clear();
525 }
526 }
527 //Clear all the shower properties. This does not delete the element.
529 {
530 for (auto const& eventdataproduct : eventdataproducts) {
531 (eventdataproduct.second)->Clear();
532 }
533 }
534 //Clear all the shower properties. This does not delete the element.
535 void ClearAll()
536 {
537 ClearShower();
538 ClearEvent();
539 }
540
541 //Find if the product is one what is being stored.
542 bool CheckElementTag(const std::string& Name) const
543 {
544 auto const showerDataProductsIt = showerdataproducts.find(Name);
545 if (showerDataProductsIt != showerdataproducts.end()) {
546 return showerDataProductsIt->second->CheckTag();
547 }
548 return false;
549 }
550
551 //Delete a product. I see no reason for it.
552 void DeleteElement(const std::string& Name)
553 {
554 auto const showerPropertiesIt = showerproperties.find(Name);
555 if (showerPropertiesIt != showerproperties.end()) {
556 return showerPropertiesIt->second.reset(nullptr);
557 }
558 auto const showerDataProductsIt = showerdataproducts.find(Name);
559 if (showerDataProductsIt != showerdataproducts.end()) {
560 return showerDataProductsIt->second.reset(nullptr);
561 }
562 mf::LogError("ShowerElementHolder")
563 << "Trying to delete Element: " << Name
564 << ". This element does not exist in the element holder" << std::endl;
565 return;
566 }
567
568 //Set the indicator saying if the shower is going to be stored.
569 void SetElementTag(const std::string& Name, bool checkelement)
570 {
571 auto const showerDataProductsIt = showerdataproducts.find(Name);
572 if (showerDataProductsIt != showerdataproducts.end()) {
573 return showerDataProductsIt->second->SetCheckTag(checkelement);
574 }
575 mf::LogError("ShowerElementHolder")
576 << "Trying set the checking of the data product: " << Name
577 << ". This data product does not exist in the element holder" << std::endl;
578 return;
579 }
580
582 {
583 bool checked = true;
584 for (auto const& showerdataproduct : showerdataproducts) {
585 bool check = showerdataproduct.second->CheckTag();
586 if (check) {
587 bool elementset = showerdataproduct.second->CheckShowerElement();
588 if (!elementset) {
589 mf::LogError("ShowerElementHolder")
590 << "The following element is not set and was asked to be checked: "
591 << showerdataproduct.first << std::endl;
592 checked = false;
593 }
594 }
595 }
596 return checked;
597 }
598
599 //Set the shower number. This is required the association making.
600 void SetShowerNumber(int& shower_iter) { showernumber = shower_iter; }
601
602 //Get the shower number.
603 int GetShowerNumber() const { return showernumber; }
604
605 //This function will print out all the elements and there types for the user to check.
606 void PrintElements() const
607 {
608
609 unsigned int maxname = 0;
610 for (auto const& showerprop : showerproperties) {
611 if (showerprop.first.size() > maxname) { maxname = showerprop.first.size(); }
612 }
613 for (auto const& showerdataprod : showerdataproducts) {
614 if (showerdataprod.first.size() > maxname) { maxname = showerdataprod.first.size(); }
615 }
616
617 std::map<std::string, std::string> Type_showerprops;
618 std::map<std::string, std::string> Type_showerdataprods;
619 for (auto const& showerprop : showerproperties) {
620 std::string Type = (showerprop.second)->GetType();
621 Type_showerprops[showerprop.first] = Type;
622 }
623 for (auto const& showerdataprod : showerdataproducts) {
624 std::string Type = (showerdataprod.second)->GetType();
625 Type_showerdataprods[showerdataprod.first] = Type;
626 }
627
628 unsigned int maxtype = 0;
629 for (auto const& Type_showerprop : Type_showerprops) {
630 if (Type_showerprop.second.size() > maxtype) { maxtype = Type_showerprop.second.size(); }
631 }
632 for (auto const& Type_showerdataprod : Type_showerdataprods) {
633 if (Type_showerdataprod.second.size() > maxtype) {
634 maxtype = Type_showerdataprod.second.size();
635 }
636 }
637
638 unsigned int n = maxname + maxtype + 33;
639 std::cout << std::left << std::setfill('*') << std::setw(n - 1) << "*" << std::endl;
640 std::cout << "Elements in the element holder" << std::endl;
641 std::cout << std::left << std::setfill('*') << std::setw(n - 1) << "*" << std::endl;
642 for (auto const& Type_showerprop : Type_showerprops) {
643 std::cout << std::left << std::setfill(' ') << std::setw(21)
644 << "* Property Name: " << std::setw(maxname) << Type_showerprop.first;
645 std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype)
646 << Type_showerprop.second << " * " << std::endl;
647 }
648 for (auto const& Type_showerdataprod : Type_showerdataprods) {
649 std::cout << std::left << std::setfill(' ') << std::setw(maxname) << std::setw(21)
650 << "* Data Product Name: " << std::setw(maxname) << Type_showerdataprod.first;
651 std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype)
652 << Type_showerdataprod.second << " *" << std::endl;
653 }
654 std::cout << std::left << std::setfill('*') << std::setw(n - 1) << "*" << std::endl;
655 std::cout << std::setfill(' ');
656 std::cout << std::setw(0);
657 return;
658 }
659
660 template <class T>
661 std::string getType(T object) const
662 {
663 return cet::demangle_symbol(typeid(object).name());
664 }
665
666 template <class T>
667 std::string getType() const
668 {
669 return cet::demangle_symbol(typeid(T).name());
670 }
671
672 template <class T1, class T2>
673 const art::FindManyP<T1>& GetFindManyP(const art::ValidHandle<std::vector<T2>>& handle,
674 const art::Event& evt,
675 const art::InputTag& moduleTag)
676 {
677
678 const std::string name("FMP_" + moduleTag.label() + "_" + getType<T1>() + "_" + getType<T2>());
679
680 if (CheckEventElement(name)) { return GetEventElement<art::FindManyP<T1>>(name); }
681 else {
682 art::FindManyP<T1> findManyP(handle, evt, moduleTag);
683 if (findManyP.isValid()) {
684 SetEventElement(findManyP, name);
685 return GetEventElement<art::FindManyP<T1>>(name);
686 }
687 else {
688 throw cet::exception("ShowerElementHolder")
689 << "FindManyP is not valid: " << name << std::endl;
690 }
691 }
692 }
693
694 template <class T1, class T2>
695 const art::FindOneP<T1>& GetFindOneP(const art::ValidHandle<std::vector<T2>>& handle,
696 const art::Event& evt,
697 const art::InputTag& moduleTag)
698 {
699
700 const std::string name("FOP_" + moduleTag.label() + "_" + getType<T1>() + "_" + getType<T2>());
701
702 if (CheckEventElement(name)) { return GetEventElement<art::FindOneP<T1>>(name); }
703 else {
704 art::FindOneP<T1> findOneP(handle, evt, moduleTag);
705 if (findOneP.isValid()) {
706 SetEventElement(findOneP, name);
707 return GetEventElement<art::FindOneP<T1>>(name);
708 }
709 else {
710 throw cet::exception("ShowerElementHolder")
711 << "FindOneP is not valid: " << name << std::endl;
712 }
713 }
714 }
715
716private:
717 //Storage for all the shower properties.
718 std::map<std::string, std::unique_ptr<reco::shower::ShowerElementBase>> showerproperties;
719
720 //Storage for all the data products
721 std::map<std::string, std::unique_ptr<reco::shower::ShowerElementBase>> showerdataproducts;
722
723 //Storage for all the data products
724 std::map<std::string, std::unique_ptr<reco::shower::ShowerElementBase>> eventdataproducts;
725
726 //Shower ID number. Use this to set ptr makers.
728};
729
730#endif
ShowerDataProduct(T &Element, bool Checktag)
std::string GetType() const override
virtual void SetCheckTag(bool &check)
virtual ~ShowerElementBase() noexcept=default
virtual std::string GetType() const =0
bool CheckEventElement(const std::string &Name) const
std::map< std::string, std::unique_ptr< reco::shower::ShowerElementBase > > showerproperties
void SetEventElement(T &dataproduct, const std::string &Name)
int GetElement(const std::string &Name, T &Element) const
void SetElementTag(const std::string &Name, bool checkelement)
const T & GetEventElement(std::string const &Name)
void DeleteElement(const std::string &Name)
bool CheckElementTag(const std::string &Name) const
std::map< std::string, std::unique_ptr< reco::shower::ShowerElementBase > > showerdataproducts
void ClearElement(const std::string &Name)
std::map< std::string, std::unique_ptr< reco::shower::ShowerElementBase > > eventdataproducts
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
void SetElement(T &propertyval, T2 &propertyvalerror, const std::string &Name)
T GetElement(const std::string &Name) const
int GetEventElement(const std::string &Name, T &Element) const
int GetElementAndError(const std::string &Name, T &Element, T2 &ElementErr) const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
std::string getType(T object) const
bool CheckElement(const std::string &Name) const
const art::FindOneP< T1 > & GetFindOneP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
int GetShowerPropertyError(T2 &ElementErr) const
ShowerProperty(T &Element, T2 &ElementErr)
void SetShowerProperty(T &Element, T2 &ElementErr)