test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CollHandle.h
Go to the documentation of this file.
1 /*
2  */
3 
4 #ifndef EcalDigis_CollHandle_h
5 #define EcalDigis_CollHandle_h
6 
11 
24 template<class T>
25 class CollHandle {
26  //constructor(s) and destructor(s)
27 public:
34  bool failIfNotFound = true,
35  bool notFoundWarn = true): tag_(tag),
36  token_(),
39  failIfNotFound_(failIfNotFound),
40  notFoundWarn_(notFoundWarn){}
41 
42  //method(s)
43 public:
44  /*
45  Receives the "ConsumesCollector" from the EDAnalyzer and declares the usage
46  of the collection, as well as storing the token for it.
47  */
48 
50  {
51  token_ = collector.consumes<T>(tag_);
52  }
53 
62  void read(const edm::Event& event){
63  // try{
64  edm::Handle<T> hColl;
65  event.getByToken(token_, hColl);
66 
67  //If we must be tolerant to product absence, then
68  //we must check validaty before calling Handle::operator*
69  //to prevent exception throw:
70  if(!failIfNotFound_ // product-not-found tolerant mode
71  && !hColl.isValid()){// and the product was not found
72  if(notFoundWarn_
73  && !notFoundAlreadyWarned_){//warning logged only once
74  edm::LogWarning("ProductNotFound") << tag_
75  << " product "
76  "of type '" << typeid(T).name() << "' was not found!";
78  }
80  } else {
81  currentColl_ = &(*hColl);
82  }
83  }
84 
85 
89  const T* operator->() const{ return currentColl_;}
90 
94  const T& operator*() const { return *currentColl_;}
95 
96  edm::InputTag tag() const { return tag_; }
97 
98 private:
99 
100  //attribute(s)
101 protected:
102 private:
106 
107  /* EDM "Token" that is used in the actual data retrieval */
109 
112  const T* currentColl_;
113 
117  const T emptyColl_;
118 
122 
126 
130 };
131 
132 #endif
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const T * operator->() const
Definition: CollHandle.h:89
edm::InputTag tag() const
Definition: CollHandle.h:96
const T * currentColl_
Definition: CollHandle.h:112
bool notFoundAlreadyWarned_
Definition: CollHandle.h:121
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:75
const T & operator*() const
Definition: CollHandle.h:94
void read(const edm::Event &event)
Definition: CollHandle.h:62
const edm::InputTag tag_
Definition: CollHandle.h:105
CollHandle(const edm::InputTag &tag, bool failIfNotFound=true, bool notFoundWarn=true)
Definition: CollHandle.h:33
bool notFoundWarn_
Definition: CollHandle.h:129
edm::EDGetTokenT< T > token_
Definition: CollHandle.h:108
void setToken(edm::ConsumesCollector &collector)
Definition: CollHandle.h:49
volatile std::atomic< bool > shutdown_flag false
const T emptyColl_
Definition: CollHandle.h:117
long double T
bool failIfNotFound_
Definition: CollHandle.h:125