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 
20 // system include files
21 #include <memory>
22 #include <string>
23 
24 // user include files
27 
32 
34 
36 
38 
45 
48 
49 //
50 // class declaration
51 //
52 
53 template <class T>
54 class LargeEvents : public edm::EDFilter {
55  public:
56  explicit LargeEvents(const edm::ParameterSet&);
57  ~LargeEvents() override;
58 
59  private:
60  void beginJob() override ;
61  bool filter(edm::Event&, const edm::EventSetup&) override;
62  void endJob() override ;
63 
64  // ----------member data ---------------------------
65 
67  int _absthr;
68  int _modthr;
73 
74 };
75 
76 //
77 // constants, enums and typedefs
78 //
79 
80 //
81 // static data member definitions
82 //
83 
84 //
85 // constructors and destructor
86 //
87 template <class T>
89  _collectionToken(consumes<T>(iConfig.getParameter<edm::InputTag>("collectionName"))),
90  _absthr(iConfig.getUntrackedParameter<int>("absoluteThreshold")),
91  _modthr(iConfig.getUntrackedParameter<int>("moduleThreshold")),
92  _useQuality(iConfig.getUntrackedParameter<bool>("useQuality",false)),
93  _qualityLabel(iConfig.getUntrackedParameter<std::string>("qualityLabel",""))
94 {
95  //now do what ever initialization is needed
96 
97 
98 }
99 
100 template <class T>
102 {
103 
104  // do anything here that needs to be done at desctruction time
105  // (e.g. close files, deallocate resources etc.)
106 
107 }
108 
109 
110 //
111 // member functions
112 //
113 
114 // ------------ method called on each new Event ------------
115 template <class T>
116 bool
118 {
119  using namespace edm;
120 
121  if( _useQuality) {
122  if(_qualityWatcher.check(iSetup)) {
124  LogDebug("SiStripQualityUpdated") << "SiStripQuality has changed and it will be updated";
125  }
126  }
127 
128  Handle<T> digis;
129  iEvent.getByToken(_collectionToken,digis);
130 
131 
132  int ndigitot = 0;
133  for(typename T::const_iterator it = digis->begin();it!=digis->end();it++) {
134 
135  if(!_useQuality || !_qualityHandle->IsModuleBad(it->detId()) ) {
136  if(_modthr < 0 || int(it->size()) < _modthr ) {
137  ndigitot += it->size();
138  }
139  }
140  }
141 
142  if(ndigitot > _absthr) {
143  LogDebug("LargeEventSelected") << "event with " << ndigitot << " digi/cluster selected";
144  return true;
145  }
146 
147  return false;
148 }
149 
150 // ------------ method called once each job just before starting event loop ------------
151 template <class T>
152 void
154 {
155 }
156 
157 // ------------ method called once each job just after ending the event loop ------------
158 template <class T>
159 void
161 }
162 
163 //define this as a plug-in
167 
#define LogDebug(id)
void beginJob() override
Definition: LargeEvents.cc:153
LargeEvents< edm::DetSetVector< SiStripDigi > > LargeSiStripDigiEvents
Definition: LargeEvents.cc:164
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void endJob() override
Definition: LargeEvents.cc:160
LargeEvents(const edm::ParameterSet &)
Definition: LargeEvents.cc:88
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
LargeEvents< edmNew::DetSetVector< SiStripCluster > > LargeSiStripClusterEvents
Definition: LargeEvents.cc:165
int iEvent
Definition: GenABIO.cc:230
edm::ESWatcher< SiStripQualityRcd > _qualityWatcher
Definition: LargeEvents.cc:72
~LargeEvents() override
Definition: LargeEvents.cc:101
edm::ESHandle< SiStripQuality > _qualityHandle
Definition: LargeEvents.cc:71
bool IsModuleBad(const uint32_t &detid) const
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: LargeEvents.cc:117
std::string _qualityLabel
Definition: LargeEvents.cc:70
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
HLT enums.
T get() const
Definition: EventSetup.h:63
edm::EDGetTokenT< T > _collectionToken
Definition: LargeEvents.cc:66
LargeEvents< edmNew::DetSetVector< SiPixelCluster > > LargeSiPixelClusterEvents
Definition: LargeEvents.cc:166
long double T
bool _useQuality
Definition: LargeEvents.cc:69