CMS 3D CMS Logo

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>
53 public:
54  explicit LargeEvents(const edm::ParameterSet&);
55  ~LargeEvents() override;
56 
57 private:
58  bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
59 
60  // ----------member data ---------------------------
61 
63  const int _absthr;
64  const int _modthr;
65  const bool _useQuality;
67 };
68 
69 //
70 // constants, enums and typedefs
71 //
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
80 template <class T>
82  : _collectionToken(consumes<T>(iConfig.getParameter<edm::InputTag>("collectionName"))),
83  _absthr(iConfig.getUntrackedParameter<int>("absoluteThreshold")),
84  _modthr(iConfig.getUntrackedParameter<int>("moduleThreshold")),
85  _useQuality(iConfig.getUntrackedParameter<bool>("useQuality", false)),
86  _qualityToken(esConsumes(edm::ESInputTag{"", iConfig.getUntrackedParameter<std::string>("qualityLabel", "")})) {
87  //now do what ever initialization is needed
88 }
89 
90 template <class T>
92  // do anything here that needs to be done at desctruction time
93  // (e.g. close files, deallocate resources etc.)
94 }
95 
96 //
97 // member functions
98 //
99 
100 // ------------ method called on each new Event ------------
101 template <class T>
103  using namespace edm;
104 
105  const SiStripQuality* _qualityHandle = nullptr;
106 
107  if (_useQuality) {
108  _qualityHandle = &iSetup.getData(_qualityToken);
109  LogDebug("SiStripQualityUpdated") << "SiStripQuality has changed and it will be updated";
110  }
111 
112  Handle<T> digis;
113  iEvent.getByToken(_collectionToken, digis);
114 
115  int ndigitot = 0;
116  for (typename T::const_iterator it = digis->begin(); it != digis->end(); it++) {
117  if (!_useQuality || !_qualityHandle->IsModuleBad(it->detId())) {
118  if (_modthr < 0 || int(it->size()) < _modthr) {
119  ndigitot += it->size();
120  }
121  }
122  }
123 
124  if (ndigitot > _absthr) {
125  LogDebug("LargeEventSelected") << "event with " << ndigitot << " digi/cluster selected";
126  return true;
127  }
128 
129  return false;
130 }
131 
132 //define this as a plug-in
136 
LargeEvents< edm::DetSetVector< SiStripDigi > > LargeSiStripDigiEvents
Definition: LargeEvents.cc:133
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
bool IsModuleBad(uint32_t detid) const
LargeEvents(const edm::ParameterSet &)
Definition: LargeEvents.cc:81
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > _qualityToken
Definition: LargeEvents.cc:66
T getUntrackedParameter(std::string const &, T const &) const
LargeEvents< edmNew::DetSetVector< SiStripCluster > > LargeSiStripClusterEvents
Definition: LargeEvents.cc:134
bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: LargeEvents.cc:102
int iEvent
Definition: GenABIO.cc:224
~LargeEvents() override
Definition: LargeEvents.cc:91
const edm::EDGetTokenT< T > _collectionToken
Definition: LargeEvents.cc:62
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const int _modthr
Definition: LargeEvents.cc:64
const bool _useQuality
Definition: LargeEvents.cc:65
HLT enums.
LargeEvents< edmNew::DetSetVector< SiPixelCluster > > LargeSiPixelClusterEvents
Definition: LargeEvents.cc:135
const int _absthr
Definition: LargeEvents.cc:63
long double T
#define LogDebug(id)