CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LargeEvents.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripTools
4 // Class: LargeEvents
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Tue Oct 21 20:55:22 CEST 2008
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <string>
22 
23 // user include files
26 
30 
32 
34 
36 
43 
46 
47 //
48 // class declaration
49 //
50 
51 template <class T>
52 class LargeEvents : public edm::EDFilter {
53 public:
54  explicit LargeEvents(const edm::ParameterSet&);
55  ~LargeEvents() override;
56 
57 private:
58  void beginJob() override;
59  bool filter(edm::Event&, const edm::EventSetup&) override;
60  void endJob() override;
61 
62  // ----------member data ---------------------------
63 
65  int _absthr;
66  int _modthr;
68  const SiStripQuality* _qualityHandle = nullptr;
71 };
72 
73 //
74 // constants, enums and typedefs
75 //
76 
77 //
78 // static data member definitions
79 //
80 
81 //
82 // constructors and destructor
83 //
84 template <class T>
86  : _collectionToken(consumes<T>(iConfig.getParameter<edm::InputTag>("collectionName"))),
87  _absthr(iConfig.getUntrackedParameter<int>("absoluteThreshold")),
88  _modthr(iConfig.getUntrackedParameter<int>("moduleThreshold")),
89  _useQuality(iConfig.getUntrackedParameter<bool>("useQuality", false)),
90  _qualityToken(esConsumes(edm::ESInputTag{"", iConfig.getUntrackedParameter<std::string>("qualityLabel", "")})) {
91  //now do what ever initialization is needed
92 }
93 
94 template <class T>
96  // do anything here that needs to be done at desctruction time
97  // (e.g. close files, deallocate resources etc.)
98 }
99 
100 //
101 // member functions
102 //
103 
104 // ------------ method called on each new Event ------------
105 template <class T>
107  using namespace edm;
108 
109  if (_useQuality) {
110  if (_qualityWatcher.check(iSetup)) {
112  LogDebug("SiStripQualityUpdated") << "SiStripQuality has changed and it will be updated";
113  }
114  }
115 
116  Handle<T> digis;
117  iEvent.getByToken(_collectionToken, digis);
118 
119  int ndigitot = 0;
120  for (typename T::const_iterator it = digis->begin(); it != digis->end(); it++) {
121  if (!_useQuality || !_qualityHandle->IsModuleBad(it->detId())) {
122  if (_modthr < 0 || int(it->size()) < _modthr) {
123  ndigitot += it->size();
124  }
125  }
126  }
127 
128  if (ndigitot > _absthr) {
129  LogDebug("LargeEventSelected") << "event with " << ndigitot << " digi/cluster selected";
130  return true;
131  }
132 
133  return false;
134 }
135 
136 // ------------ method called once each job just before starting event loop ------------
137 template <class T>
139 
140 // ------------ method called once each job just after ending the event loop ------------
141 template <class T>
143 
144 //define this as a plug-in
148 
149 DEFINE_FWK_MODULE(LargeSiStripDigiEvents);
150 DEFINE_FWK_MODULE(LargeSiStripClusterEvents);
151 DEFINE_FWK_MODULE(LargeSiPixelClusterEvents);
void beginJob() override
Definition: LargeEvents.cc:138
T getUntrackedParameter(std::string const &, T const &) const
LargeEvents< edm::DetSetVector< SiStripDigi > > LargeSiStripDigiEvents
Definition: LargeEvents.cc:145
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > _qualityToken
Definition: LargeEvents.cc:70
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void endJob() override
Definition: LargeEvents.cc:142
LargeEvents(const edm::ParameterSet &)
Definition: LargeEvents.cc:85
bool getData(T &iHolder) const
Definition: EventSetup.h:128
LargeEvents< edmNew::DetSetVector< SiStripCluster > > LargeSiStripClusterEvents
Definition: LargeEvents.cc:146
int iEvent
Definition: GenABIO.cc:224
edm::ESWatcher< SiStripQualityRcd > _qualityWatcher
Definition: LargeEvents.cc:69
~LargeEvents() override
Definition: LargeEvents.cc:95
const SiStripQuality * _qualityHandle
Definition: LargeEvents.cc:68
bool IsModuleBad(const uint32_t &detid) const
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: LargeEvents.cc:106
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::EDGetTokenT< T > _collectionToken
Definition: LargeEvents.cc:64
LargeEvents< edmNew::DetSetVector< SiPixelCluster > > LargeSiPixelClusterEvents
Definition: LargeEvents.cc:147
long double T
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
bool _useQuality
Definition: LargeEvents.cc:67
#define LogDebug(id)