CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
APVShotsFilter Class Reference

#include <DPGAnalysis/SiStripTools/src/APVShotsFilter.cc>

Inheritance diagram for APVShotsFilter:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 APVShotsFilter (const edm::ParameterSet &)
 
 ~APVShotsFilter () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Private Member Functions

void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 
void updateDetCabling (const edm::EventSetup &setup)
 

Private Attributes

uint32_t _cacheIdDet
 DB cache ID used to establish if the cabling has changed during the run. More...
 
const SiStripDetCabling_detCabling
 The cabling object. More...
 
int _nevents
 
bool _selectAPVshots
 
bool _useCabling
 
bool _zs
 
edm::EDGetTokenT< APVCyclePhaseCollectionapvphaseToken_
 
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > digisToken_
 
edm::EDGetTokenT< EventWithHistoryheToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 56 of file APVShotsFilter.cc.

Constructor & Destructor Documentation

APVShotsFilter::APVShotsFilter ( const edm::ParameterSet iConfig)
explicit

Definition at line 98 of file APVShotsFilter.cc.

References apvphaseToken_, digisToken_, edm::ParameterSet::getParameter(), and heToken_.

99  : _selectAPVshots (iConfig.getUntrackedParameter<bool>("selectAPVshots", true))
100  , _zs (iConfig.getUntrackedParameter<bool>("zeroSuppressed",true))
101  , _nevents(0)
102  , _useCabling (iConfig.getUntrackedParameter<bool>("useCabling",true))
103  , _cacheIdDet(0)
104  , _detCabling(nullptr)
105 
106 {
107  //now do what ever initialization is needed
108  edm::InputTag digicollection = iConfig.getParameter<edm::InputTag>("digiCollection");
109  edm::InputTag historyProduct = iConfig.getParameter<edm::InputTag>("historyProduct");
110  edm::InputTag apvphasecoll = iConfig.getParameter<edm::InputTag>("apvPhaseCollection");
111 
112  heToken_ = consumes<EventWithHistory> (historyProduct);
113  apvphaseToken_ = consumes<APVCyclePhaseCollection> (apvphasecoll);
114  digisToken_ = consumes<edm::DetSetVector<SiStripDigi> >(digicollection);
115 
116 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const SiStripDetCabling * _detCabling
The cabling object.
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > digisToken_
edm::EDGetTokenT< APVCyclePhaseCollection > apvphaseToken_
uint32_t _cacheIdDet
DB cache ID used to establish if the cabling has changed during the run.
edm::EDGetTokenT< EventWithHistory > heToken_
APVShotsFilter::~APVShotsFilter ( )
override

Definition at line 119 of file APVShotsFilter.cc.

References _detCabling.

120 {
121 
122  // do anything here that needs to be done at desctruction time
123  // (e.g. close files, deallocate resources etc.)
124  if ( _detCabling ) _detCabling = nullptr;
125 
126 }
const SiStripDetCabling * _detCabling
The cabling object.

Member Function Documentation

void APVShotsFilter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 237 of file APVShotsFilter.cc.

References _nevents.

237  {
238 
239  edm::LogInfo("APVShotsFilter") << _nevents << " analyzed events";
240 
241 }
void APVShotsFilter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 264 of file APVShotsFilter.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

264  {
265  //The following says we do not know what parameters are allowed so do no validation
266  // Please change this to state exactly what you do use, even if it is no parameters
268  desc.setUnknown();
269  descriptions.addDefault(desc);
270 }
void addDefault(ParameterSetDescription const &psetDescription)
bool APVShotsFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 135 of file APVShotsFilter.cc.

References _detCabling, _nevents, _selectAPVshots, _useCabling, _zs, apvphaseToken_, digisToken_, sistrip::FED_ID_MAX, FedChannelConnection::fedCh(), FedChannelConnection::fedId(), edm::Event::getByToken(), SiStripDetCabling::getConnection(), SiStripDetCabling::getConnections(), APVShotFinder::getShots(), hcalSimParameters_cfi::he, heToken_, FedChannelConnection::isConnected(), LogDebug, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, and updateDetCabling().

Referenced by Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filter(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setDataAccessor(), and Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView().

136 {
137  using namespace edm;
138 
139  if (_useCabling){
140  //retrieve cabling
141  updateDetCabling( iSetup );
142  }
143  _nevents++;
144 
146  iEvent.getByToken(heToken_,he);
147 
149  iEvent.getByToken(apvphaseToken_,apvphase);
150 
152  iEvent.getByToken(digisToken_,digis);
153 
154  // loop on detector with digis
155  int nshots = 0;
156  std::vector<int> nshotsperFed;
157 
158  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
159  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
160  const uint16_t lNumFeds = (siStripFedIdMax-siStripFedIdMin)+1;
161  if (_useCabling){
162  nshotsperFed.resize(lNumFeds,0);
163  }
164 
165  APVShotFinder apvsf(*digis,_zs);
166  const std::vector<APVShot>& shots = apvsf.getShots();
167 
168  for (std::vector<APVShot>::const_iterator shot=shots.begin(); shot!=shots.end(); ++shot) {
169  if ( !shot->isGenuine() ) continue;
170  ++nshots;
171 
172  //get the fedid from the detid
173  uint32_t det=shot->detId();
174  if (_useCabling){
175 
176  int apvPair = shot->apvNumber()/2;
177  LogDebug("APVShotsFilter") << apvPair;
178 
179  const FedChannelConnection& theConn = _detCabling->getConnection( det , apvPair);
180 
181  int lChannelId = -1;
182  int thelFEDId = -1;
183  if(theConn.isConnected()) {
184  lChannelId = theConn.fedCh();
185  thelFEDId = theConn.fedId();
186  }
187  else {
188  edm::LogWarning("APVShotsFilter") << "connection of det " << det << " APV pair " << apvPair << " not found";
189  }
190  LogDebug("APVShotsFilter") << thelFEDId << " " << lChannelId ;
191 
192  const std::vector<const FedChannelConnection *> & conns = _detCabling->getConnections( det );
193 
194  if (!(conns.size())) continue;
195  uint16_t lFedId = 0;
196  for (uint32_t ch = 0; ch<conns.size(); ch++) {
197  if(conns[ch] && conns[ch]->isConnected()) {
198  LogDebug("APVShotsFilter") << *(conns[ch]);
199  LogDebug("APVShotsFilter") << "Ready for FED id " << ch;
200  lFedId = conns[ch]->fedId();
201  LogDebug("APVShotsFilter") << "obtained FED id " << ch << " " << lFedId;
202  //uint16_t lFedCh = conns[ch]->fedCh();
203 
204  if (lFedId < sistrip::FED_ID_MIN || lFedId > sistrip::FED_ID_MAX){
205  edm::LogWarning("APVShotsFilter") << lFedId << " for detid " << det << " connection " << ch;
206  continue;
207  }
208  else break;
209  }
210  }
211  if (lFedId < sistrip::FED_ID_MIN || lFedId > sistrip::FED_ID_MAX){
212  edm::LogWarning("APVShotsFilter") << lFedId << "found for detid " << det;
213  continue;
214  }
215 
216  if(lFedId != thelFEDId) {
217  edm::LogWarning("APVShotsFilter") << " Mismatch in FED id for det " << det << " APV pair "
218  << apvPair << " : " << lFedId << " vs " << thelFEDId;
219  }
220 
221  // LogDebug("APVShotsFilter") << nshotsperfed.size() << " " << lFedId-sistrip::FED_ID_MIN;
222  // ++nshotsperFed[lFedId-FEDNumbering::MINSiStripFEDID];
223 
224  LogDebug("APVShotsFilter") << " ready to be filled with " << thelFEDId << " " << lChannelId;
225  LogDebug("APVShotsFilter") << " filled with " << thelFEDId << " " << lChannelId;
226 
227  }
228  }
229 
230  bool foundAPVshots = (nshots > 0);
231  bool pass = (_selectAPVshots ? foundAPVshots : !foundAPVshots);
232  return pass;
233 }
#define LogDebug(id)
const SiStripDetCabling * _detCabling
The cabling object.
const FedChannelConnection & getConnection(uint32_t det_id, unsigned short apv_pair) const
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > digisToken_
const uint16_t & fedCh() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< APVCyclePhaseCollection > apvphaseToken_
const uint16_t & fedId() const
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
void updateDetCabling(const edm::EventSetup &setup)
Class containning control, module, detector and connection information, at the level of a FED channel...
edm::EDGetTokenT< EventWithHistory > heToken_
HLT enums.
static const uint16_t FED_ID_MAX
void APVShotsFilter::updateDetCabling ( const edm::EventSetup setup)
private

Definition at line 245 of file APVShotsFilter.cc.

References _cacheIdDet, _detCabling, _useCabling, EnergyCorrector::c, edm::EventSetup::get(), and edm::ESHandle< T >::product().

Referenced by filter().

246 {
247  if (_useCabling){
248  uint32_t cache_id = setup.get<SiStripDetCablingRcd>().cacheIdentifier();//.get( cabling_ );
249 
250  if ( _cacheIdDet != cache_id ) { // If the cache ID has changed since the last update...
251  // Update the cabling object
253  setup.get<SiStripDetCablingRcd>().get( c );
254  _detCabling = c.product();
255  _cacheIdDet = cache_id;
256  } // end of new cache ID check
257  }
258 }
const SiStripDetCabling * _detCabling
The cabling object.
uint32_t _cacheIdDet
DB cache ID used to establish if the cabling has changed during the run.
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

uint32_t APVShotsFilter::_cacheIdDet
private

DB cache ID used to establish if the cabling has changed during the run.

Definition at line 82 of file APVShotsFilter.cc.

Referenced by updateDetCabling().

const SiStripDetCabling* APVShotsFilter::_detCabling
private

The cabling object.

Definition at line 83 of file APVShotsFilter.cc.

Referenced by filter(), updateDetCabling(), and ~APVShotsFilter().

int APVShotsFilter::_nevents
private

Definition at line 78 of file APVShotsFilter.cc.

Referenced by endJob(), and filter().

bool APVShotsFilter::_selectAPVshots
private

Definition at line 75 of file APVShotsFilter.cc.

Referenced by filter().

bool APVShotsFilter::_useCabling
private

Definition at line 81 of file APVShotsFilter.cc.

Referenced by filter(), and updateDetCabling().

bool APVShotsFilter::_zs
private

Definition at line 77 of file APVShotsFilter.cc.

Referenced by filter().

edm::EDGetTokenT<APVCyclePhaseCollection> APVShotsFilter::apvphaseToken_
private

Definition at line 72 of file APVShotsFilter.cc.

Referenced by APVShotsFilter(), and filter().

edm::EDGetTokenT<edm::DetSetVector<SiStripDigi> > APVShotsFilter::digisToken_
private

Definition at line 73 of file APVShotsFilter.cc.

Referenced by APVShotsFilter(), and filter().

edm::EDGetTokenT<EventWithHistory> APVShotsFilter::heToken_
private

Definition at line 71 of file APVShotsFilter.cc.

Referenced by APVShotsFilter(), and filter().