CMS 3D CMS Logo

SiStripDetWithSomething.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripTools
4 // Class: SiStripDetWithSomething
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Wed Oct 22 17:54:30 CEST 2008
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
30 
31 #include <vector>
32 
34 
36 
41 
42 //
43 // class declaration
44 //
45 
46 template <class T>
48 public:
50  ~SiStripDetWithSomething() override;
51 
52 private:
53  void beginJob() override;
54  bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
55  void endJob() override;
56 
57  // ----------member data ---------------------------
58 
60  std::vector<unsigned int> _wantedmod;
61 };
62 
63 //
64 // constants, enums and typedefs
65 //
66 
67 //
68 // static data member definitions
69 //
70 
71 //
72 // constructors and destructor
73 //
74 template <class T>
76  : _digicollectionToken(consumes<T>(iConfig.getParameter<edm::InputTag>("collectionName"))),
77  _wantedmod(iConfig.getUntrackedParameter<std::vector<unsigned int> >("selectedModules"))
78 
79 {
80  //now do what ever initialization is needed
81 
82  sort(_wantedmod.begin(), _wantedmod.end());
83 
84  edm::LogInfo("SelectedModules") << "Selected module list";
85  for (std::vector<unsigned int>::const_iterator mod = _wantedmod.begin(); mod != _wantedmod.end(); mod++) {
86  edm::LogVerbatim("SelectedModules") << *mod;
87  }
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  Handle<T> digis;
106  iEvent.getByToken(_digicollectionToken, digis);
107 
108  for (typename T::const_iterator it = digis->begin(); it != digis->end(); it++) {
109  for (std::vector<unsigned int>::const_iterator mod = _wantedmod.begin();
110  mod != _wantedmod.end() && it->detId() >= *mod;
111  mod++) {
112  if (*mod == it->detId()) {
113  edm::LogInfo("ModuleFound") << " module " << *mod << " found with " << it->size() << " digis/clusters";
114  return true;
115  }
116  }
117  }
118 
119  return false;
120 }
121 
122 // ------------ method called once each job just before starting event loop ------------
123 template <class T>
125 
126 // ------------ method called once each job just after ending the event loop ------------
127 template <class T>
129 
132 
133 //define this as a plug-in
Log< level::Info, true > LogVerbatim
SiStripDetWithSomething(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
SiStripDetWithSomething< edmNew::DetSetVector< SiStripCluster > > SiStripDetWithCluster
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< T > _digicollectionToken
Log< level::Info, false > LogInfo
SiStripDetWithSomething< edm::DetSetVector< SiStripDigi > > SiStripDetWithDigi
std::vector< unsigned int > _wantedmod
bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
HLT enums.
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4