CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ECALActivity.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ECALActivity
4 // Class: ECALActivity
5 //
6 //
7 // Original Author: Luca Malgeri
8 
9 #include <memory>
10 #include <vector>
11 #include <map>
12 #include <set>
13 
14 // user include files
16 
29 
30 using namespace edm;
31 using namespace std;
32 
34 {
35  EBRecHitCollection_ = iConfig.getParameter<edm::InputTag>("ebrechitcollection");
36  EERecHitCollection_ = iConfig.getParameter<edm::InputTag>("ebrechitcollection");
37 
38  EBnum=iConfig.getUntrackedParameter<int>("EBnum");
39  EBthresh=iConfig.getUntrackedParameter<double>("EBthresh");
40  EEnum=iConfig.getUntrackedParameter<int>("EEnum");
41  EEthresh=iConfig.getUntrackedParameter<double>("EEthresh");
42  ETOTnum=iConfig.getUntrackedParameter<int>("ETOTnum");
43  ETOTthresh=iConfig.getUntrackedParameter<double>("ETOTthresh");
44  applyfilter = iConfig.getUntrackedParameter<bool>("applyfilter",true);
45 }
46 
48 {
49 }
50 
52 {
53  bool accepted = false;
54  bool eb= false;
55  bool ee= false;
56  bool etot= false;
57 
58  //int ievt = iEvent.id().event();
59  //int irun = iEvent.id().run();
60  //int ils = iEvent.luminosityBlock();
61 
62  int ebabovethresh=0;
63  int eeabovethresh=0;
64  int etotabovethresh=0;
65 
66 
69 
70  const EBRecHitCollection* EBRecHits = 0;
71  const EERecHitCollection* EERecHits = 0;
72 
73  if ( EBRecHitCollection_.label() != "" && EBRecHitCollection_.instance() != "" )
74  {
75  iEvent.getByLabel( EBRecHitCollection_, pEBRecHits);
76  if ( pEBRecHits.isValid() )
77  {
78  EBRecHits = pEBRecHits.product(); // get a ptr to the product
79  }
80  else
81  {
82  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EBRecHitCollection_.label() ;
83  }
84  }
85 
86  if ( EERecHitCollection_.label() != "" && EERecHitCollection_.instance() != "" )
87  {
88  iEvent.getByLabel( EERecHitCollection_, pEERecHits);
89 
90  if ( pEERecHits.isValid() )
91  {
92  EERecHits = pEERecHits.product(); // get a ptr to the product
93  }
94  else
95  {
96  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EERecHitCollection_.label() ;
97  }
98  }
99 
100 
101  // now loop over them
102  if (EBRecHits)
103  {
104  for(EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it)
105  {
106  if (it->energy()>EBthresh) ebabovethresh++;
107  if (it->energy()>ETOTthresh) etotabovethresh++;
108  }
109  }
110  if (EERecHits)
111  {
112  for(EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it)
113  {
114  if (it->energy()>EEthresh) eeabovethresh++;
115  if (it->energy()>ETOTthresh) etotabovethresh++;
116  }
117  }
118 
119  if(ebabovethresh>=EBnum) eb=true;
120  if(eeabovethresh>=EEnum) ee=true;
121  if(etotabovethresh>=ETOTnum) etot=true;
122 
123  accepted = eb|ee|etot;
124 
125  if (applyfilter)
126  return accepted;
127  else
128  return true;
129 
130 }
131 
132 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< EcalRecHit >::const_iterator const_iterator
DEFINE_FWK_MODULE(HiMixingModule)
int iEvent
Definition: GenABIO.cc:230
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
const_iterator end() const
virtual bool filter(edm::Event &, const edm::EventSetup &) override
Definition: ECALActivity.cc:51
T const * product() const
Definition: Handle.h:81
ECALActivity(const edm::ParameterSet &)
Definition: ECALActivity.cc:33
const_iterator begin() const