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>
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)) {
111  _qualityHandle = &iSetup.getData(_qualityToken);
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 
LargeEvents::endJob
void endJob() override
Definition: LargeEvents.cc:142
electrons_cff.bool
bool
Definition: electrons_cff.py:366
LargeEvents::LargeEvents
LargeEvents(const edm::ParameterSet &)
Definition: LargeEvents.cc:85
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
edm::ESWatcher< SiStripQualityRcd >
ESInputTag
LargeEvents::_collectionToken
edm::EDGetTokenT< T > _collectionToken
Definition: LargeEvents.cc:64
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
SiPixelCluster.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
EDFilter.h
LargeEvents::~LargeEvents
~LargeEvents() override
Definition: LargeEvents.cc:95
LargeEvents::_qualityHandle
const SiStripQuality * _qualityHandle
Definition: LargeEvents.cc:68
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
LargeEvents::beginJob
void beginJob() override
Definition: LargeEvents.cc:138
LargeEvents::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: LargeEvents.cc:106
LargeEvents::_absthr
int _absthr
Definition: LargeEvents.cc:65
LargeEvents::_qualityToken
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > _qualityToken
Definition: LargeEvents.cc:70
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiStripDigi.h
LargeSiPixelClusterEvents
LargeEvents< edmNew::DetSetVector< SiPixelCluster > > LargeSiPixelClusterEvents
Definition: LargeEvents.cc:147
LargeEvents::_modthr
int _modthr
Definition: LargeEvents.cc:66
LargeSiStripDigiEvents
LargeEvents< edm::DetSetVector< SiStripDigi > > LargeSiStripDigiEvents
Definition: LargeEvents.cc:145
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripCluster.h
Event.h
LargeEvents::_qualityWatcher
edm::ESWatcher< SiStripQualityRcd > _qualityWatcher
Definition: LargeEvents.cc:69
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
LargeEvents
Definition: LargeEvents.cc:52
edm::EDFilter
Definition: EDFilter.h:38
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< SiStripQuality, SiStripQualityRcd >
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
Frameworkfwd.h
ESWatcher.h
T
long double T
Definition: Basic3DVectorLD.h:48
SiStripQuality.h
SiStripQualityRcd.h
LargeEvents::_useQuality
bool _useQuality
Definition: LargeEvents.cc:67
DetSet.h
ParameterSet.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
LargeSiStripClusterEvents
LargeEvents< edmNew::DetSetVector< SiStripCluster > > LargeSiStripClusterEvents
Definition: LargeEvents.cc:146
DetSetVectorNew.h
SiStripQuality
Definition: SiStripQuality.h:32