CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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 &)
 

Private Member Functions

virtual void beginJob ()
 
virtual bool beginLuminosityBlock (edm::LuminosityBlock &, edm::EventSetup const &)
 
virtual bool beginRun (edm::Run &, edm::EventSetup const &)
 
virtual void endJob ()
 
virtual bool endLuminosityBlock (edm::LuminosityBlock &, edm::EventSetup const &)
 
virtual bool endRun (edm::Run &, edm::EventSetup const &)
 
virtual bool filter (edm::Event &, const edm::EventSetup &)
 
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
< APVCyclePhaseCollection
apvphaseToken_
 
edm::EDGetTokenT
< edm::DetSetVector
< SiStripDigi > > 
digisToken_
 
edm::EDGetTokenT
< EventWithHistory
heToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
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 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 104 of file APVShotsFilter.cc.

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

105  : _selectAPVshots (iConfig.getUntrackedParameter<bool>("selectAPVshots", true))
106  , _zs (iConfig.getUntrackedParameter<bool>("zeroSuppressed",true))
107  , _nevents(0)
108  , _useCabling (iConfig.getUntrackedParameter<bool>("useCabling",true))
109  , _cacheIdDet(0)
110  , _detCabling(0)
111 
112 {
113  //now do what ever initialization is needed
114  edm::InputTag digicollection = iConfig.getParameter<edm::InputTag>("digiCollection");
115  edm::InputTag historyProduct = iConfig.getParameter<edm::InputTag>("historyProduct");
116  edm::InputTag apvphasecoll = iConfig.getParameter<edm::InputTag>("apvPhaseCollection");
117 
118  heToken_ = consumes<EventWithHistory> (historyProduct);
119  apvphaseToken_ = consumes<APVCyclePhaseCollection> (apvphasecoll);
120  digisToken_ = consumes<edm::DetSetVector<SiStripDigi> >(digicollection);
121 
122 }
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 ( )

Definition at line 125 of file APVShotsFilter.cc.

References _detCabling.

126 {
127 
128  // do anything here that needs to be done at desctruction time
129  // (e.g. close files, deallocate resources etc.)
130  if ( _detCabling ) _detCabling = 0;
131 
132 }
const SiStripDetCabling * _detCabling
The cabling object.

Member Function Documentation

void APVShotsFilter::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 243 of file APVShotsFilter.cc.

244 {
245 }
bool APVShotsFilter::beginLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 271 of file APVShotsFilter.cc.

272 {
273  return true;
274 }
bool APVShotsFilter::beginRun ( edm::Run iRun,
edm::EventSetup const &   
)
privatevirtual

Definition at line 257 of file APVShotsFilter.cc.

258 {
259  return true;
260 }
void APVShotsFilter::endJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 249 of file APVShotsFilter.cc.

References _nevents.

249  {
250 
251  edm::LogInfo("APVShotsFilter") << _nevents << " analyzed events";
252 
253 }
bool APVShotsFilter::endLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 278 of file APVShotsFilter.cc.

279 {
280  return true;
281 }
bool APVShotsFilter::endRun ( edm::Run ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 264 of file APVShotsFilter.cc.

265 {
266  return true;
267 }
void APVShotsFilter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 304 of file APVShotsFilter.cc.

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

304  {
305  //The following says we do not know what parameters are allowed so do no validation
306  // Please change this to state exactly what you do use, even if it is no parameters
308  desc.setUnknown();
309  descriptions.addDefault(desc);
310 }
void addDefault(ParameterSetDescription const &psetDescription)
bool APVShotsFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDFilter.

Definition at line 141 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(), 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().

142 {
143  using namespace edm;
144 
145  if (_useCabling){
146  //retrieve cabling
147  updateDetCabling( iSetup );
148  }
149  _nevents++;
150 
152  iEvent.getByToken(heToken_,he);
153 
155  iEvent.getByToken(apvphaseToken_,apvphase);
156 
158  iEvent.getByToken(digisToken_,digis);
159 
160  // loop on detector with digis
161  int nshots = 0;
162  std::vector<int> nshotsperFed;
163 
164  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
165  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
166  const uint16_t lNumFeds = (siStripFedIdMax-siStripFedIdMin)+1;
167  if (_useCabling){
168  nshotsperFed.resize(lNumFeds,0);
169  }
170 
171  APVShotFinder apvsf(*digis,_zs);
172  const std::vector<APVShot>& shots = apvsf.getShots();
173 
174  for (std::vector<APVShot>::const_iterator shot=shots.begin(); shot!=shots.end(); ++shot) {
175  if ( !shot->isGenuine() ) continue;
176  ++nshots;
177 
178  //get the fedid from the detid
179  uint32_t det=shot->detId();
180  if (_useCabling){
181 
182  int apvPair = shot->apvNumber()/2;
183  LogDebug("APVShotsFilter") << apvPair;
184 
185  const FedChannelConnection& theConn = _detCabling->getConnection( det , apvPair);
186 
187  int lChannelId = -1;
188  int thelFEDId = -1;
189  if(theConn.isConnected()) {
190  lChannelId = theConn.fedCh();
191  thelFEDId = theConn.fedId();
192  }
193  else {
194  edm::LogWarning("APVShotsFilter") << "connection of det " << det << " APV pair " << apvPair << " not found";
195  }
196  LogDebug("APVShotsFilter") << thelFEDId << " " << lChannelId ;
197 
198  const std::vector<const FedChannelConnection *> & conns = _detCabling->getConnections( det );
199 
200  if (!(conns.size())) continue;
201  uint16_t lFedId = 0;
202  for (uint32_t ch = 0; ch<conns.size(); ch++) {
203  if(conns[ch] && conns[ch]->isConnected()) {
204  LogDebug("APVShotsFilter") << *(conns[ch]);
205  LogDebug("APVShotsFilter") << "Ready for FED id " << ch;
206  lFedId = conns[ch]->fedId();
207  LogDebug("APVShotsFilter") << "obtained FED id " << ch << " " << lFedId;
208  //uint16_t lFedCh = conns[ch]->fedCh();
209 
210  if (lFedId < sistrip::FED_ID_MIN || lFedId > sistrip::FED_ID_MAX){
211  edm::LogWarning("APVShotsFilter") << lFedId << " for detid " << det << " connection " << ch;
212  continue;
213  }
214  else break;
215  }
216  }
217  if (lFedId < sistrip::FED_ID_MIN || lFedId > sistrip::FED_ID_MAX){
218  edm::LogWarning("APVShotsFilter") << lFedId << "found for detid " << det;
219  continue;
220  }
221 
222  if(lFedId != thelFEDId) {
223  edm::LogWarning("APVShotsFilter") << " Mismatch in FED id for det " << det << " APV pair "
224  << apvPair << " : " << lFedId << " vs " << thelFEDId;
225  }
226 
227  // LogDebug("APVShotsFilter") << nshotsperfed.size() << " " << lFedId-sistrip::FED_ID_MIN;
228  // ++nshotsperFed[lFedId-FEDNumbering::MINSiStripFEDID];
229 
230  LogDebug("APVShotsFilter") << " ready to be filled with " << thelFEDId << " " << lChannelId;
231  LogDebug("APVShotsFilter") << " filled with " << thelFEDId << " " << lChannelId;
232 
233  }
234  }
235 
236  bool foundAPVshots = (nshots > 0);
237  bool pass = (_selectAPVshots ? foundAPVshots : !foundAPVshots);
238  return pass;
239 }
#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:464
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_
static const uint16_t FED_ID_MAX
void APVShotsFilter::updateDetCabling ( const edm::EventSetup setup)
private

Definition at line 285 of file APVShotsFilter.cc.

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

Referenced by filter().

286 {
287  if (_useCabling){
288  uint32_t cache_id = setup.get<SiStripDetCablingRcd>().cacheIdentifier();//.get( cabling_ );
289 
290  if ( _cacheIdDet != cache_id ) { // If the cache ID has changed since the last update...
291  // Update the cabling object
293  setup.get<SiStripDetCablingRcd>().get( c );
294  _detCabling = c.product();
295  _cacheIdDet = cache_id;
296  } // end of new cache ID check
297  }
298 }
const SiStripDetCabling * _detCabling
The cabling object.
uint32_t _cacheIdDet
DB cache ID used to establish if the cabling has changed during the run.
const T & get() const
Definition: EventSetup.h:56
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 88 of file APVShotsFilter.cc.

Referenced by updateDetCabling().

const SiStripDetCabling* APVShotsFilter::_detCabling
private

The cabling object.

Definition at line 89 of file APVShotsFilter.cc.

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

int APVShotsFilter::_nevents
private

Definition at line 84 of file APVShotsFilter.cc.

Referenced by endJob(), and filter().

bool APVShotsFilter::_selectAPVshots
private

Definition at line 81 of file APVShotsFilter.cc.

Referenced by filter().

bool APVShotsFilter::_useCabling
private

Definition at line 87 of file APVShotsFilter.cc.

Referenced by filter(), and updateDetCabling().

bool APVShotsFilter::_zs
private

Definition at line 83 of file APVShotsFilter.cc.

Referenced by filter().

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

Definition at line 78 of file APVShotsFilter.cc.

Referenced by APVShotsFilter(), and filter().

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

Definition at line 79 of file APVShotsFilter.cc.

Referenced by APVShotsFilter(), and filter().

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

Definition at line 77 of file APVShotsFilter.cc.

Referenced by APVShotsFilter(), and filter().