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::Event&, const edm::EventSetup&) 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
SiStripDetWithSomething::endJob
void endJob() override
Definition: SiStripDetWithSomething.cc:128
MessageLogger.h
SiStripDetWithSomething::SiStripDetWithSomething
SiStripDetWithSomething(const edm::ParameterSet &)
Definition: SiStripDetWithSomething.cc:75
SiStripDetWithSomething
Definition: SiStripDetWithSomething.cc:47
SiStripDetWithSomething::~SiStripDetWithSomething
~SiStripDetWithSomething() override
Definition: SiStripDetWithSomething.cc:91
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
edm::LogInfo
Definition: MessageLogger.h:254
SiStripDetWithDigi
SiStripDetWithSomething< edm::DetSetVector< SiStripDigi > > SiStripDetWithDigi
Definition: SiStripDetWithSomething.cc:130
EDFilter.h
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiStripDigi.h
SiStripDetWithSomething::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: SiStripDetWithSomething.cc:102
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
SiStripCluster.h
Event.h
SiStripDetWithSomething::_digicollectionToken
edm::EDGetTokenT< T > _digicollectionToken
Definition: SiStripDetWithSomething.cc:59
SiStripDetWithSomething::_wantedmod
std::vector< unsigned int > _wantedmod
Definition: SiStripDetWithSomething.cc:60
createfilelist.int
int
Definition: createfilelist.py:10
SiStripDetWithSomething::beginJob
void beginJob() override
Definition: SiStripDetWithSomething.cc:124
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EDFilter
Definition: EDFilter.h:39
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
InputTag.h
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
ParameterSet.h
edm::Event
Definition: Event.h:73
DetSetVectorNew.h
SiStripDetWithCluster
SiStripDetWithSomething< edmNew::DetSetVector< SiStripCluster > > SiStripDetWithCluster
Definition: SiStripDetWithSomething.cc:131