CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
sistrip::FEDEmulatorModule Class Reference
Inheritance diagram for sistrip::FEDEmulatorModule:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 FEDEmulatorModule (const edm::ParameterSet &)
 
 ~FEDEmulatorModule () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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
 
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)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::unique_ptr< SiStripRawProcessingAlgorithmsalgorithms_
 object for zero-suppression More...
 
bool byModule_
 
sistrip::FEDEmulator fedEmulator_
 
edm::InputTag spyReorderedDigisTag_
 
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyReorderedDigisToken_
 
edm::InputTag spyVirginRawDigisTag_
 
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyVirginRawDigisToken_
 
SpyUtilities utility_
 

Static Private Attributes

static const char * messageLabel_ = "SiStripFEDEmulatorModule"
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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

Definition at line 58 of file SiStripFEDEmulatorModule.cc.

Constructor & Destructor Documentation

sistrip::FEDEmulatorModule::FEDEmulatorModule ( const edm::ParameterSet iConfig)
explicit

Definition at line 101 of file SiStripFEDEmulatorModule.cc.

References byModule_, fedEmulator_, sistrip::FEDEmulator::initialise(), spyReorderedDigisTag_, spyReorderedDigisToken_, spyVirginRawDigisTag_, and spyVirginRawDigisToken_.

101  :
102  spyReorderedDigisTag_(iConfig.getParameter<edm::InputTag>("SpyReorderedDigisTag")),
103  spyVirginRawDigisTag_(iConfig.getParameter<edm::InputTag>("SpyVirginRawDigisTag")),
104  byModule_(iConfig.getParameter<bool>("ByModule")),
106  {
107 
108  spyReorderedDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyReorderedDigisTag_);
109  spyVirginRawDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyVirginRawDigisTag_);
110 
112 
113  if (!byModule_) { //if not by module
114  //the medians will be produced by fed id/channel
115  produces<std::map<uint32_t,std::vector<uint32_t> > >("Medians");
116  produces<edm::DetSetVector<SiStripRawDigi> >("PedestalsOrdered");
117  produces<edm::DetSetVector<SiStripProcessedRawDigi> >("NoisesOrdered");
118  produces<edm::DetSetVector<SiStripRawDigi> >("PedSubtrDigisOrdered");
119  produces<edm::DetSetVector<SiStripRawDigi> >("CMSubtrDigisOrdered");
120  }
121  else { //by module
122  produces<edm::DetSetVector<SiStripRawDigi> >("ModulePedestals");
123  produces<edm::DetSetVector<SiStripProcessedRawDigi> >("ModuleNoises");
124  produces<edm::DetSetVector<SiStripRawDigi> >("PedSubtrModuleDigis");
125  produces<std::map<uint32_t,std::vector<uint32_t> > >("ModuleMedians");
126  produces<edm::DetSetVector<SiStripRawDigi> >("CMSubtrModuleDigis");
127  produces<edm::DetSetVector<SiStripDigi> >("ZSModuleDigis");
128  }//end of by module check
129 
130  }//end of FEDEmulatorModule constructor
T getParameter(std::string const &) const
static std::unique_ptr< SiStripRawProcessingAlgorithms > create(const edm::ParameterSet &)
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyReorderedDigisToken_
void initialise(const bool byModule)
std::unique_ptr< SiStripRawProcessingAlgorithms > algorithms_
object for zero-suppression
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyVirginRawDigisToken_
sistrip::FEDEmulatorModule::~FEDEmulatorModule ( )
override

Definition at line 132 of file SiStripFEDEmulatorModule.cc.

133  {
134  }

Member Function Documentation

void sistrip::FEDEmulatorModule::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 138 of file SiStripFEDEmulatorModule.cc.

References algorithms_, FedChannelConnection::apvPairNumber(), edm::DetSetVector< T >::begin(), byModule_, gather_cfg::cout, FedChannelConnection::detId(), MillePedeFileConverter_cfg::e, edm::DetSet< T >::empty(), edm::DetSetVector< T >::end(), SiStripFedCabling::fedConnection(), fedEmulator_, sistrip::SpyUtilities::fedIndex(), edm::Event::getByToken(), sistrip::SpyUtilities::getCabling(), sistrip::SpyUtilities::getNoiseHandle(), sistrip::SpyUtilities::getPedestalHandle(), sistrip::FEDEmulator::initialiseModule(), genParticles_cff::map, eostools::move(), FedChannelConnection::nApvPairs(), edm::Handle< T >::product(), edm::Event::put(), sistrip::FEDEmulator::retrieveNoises(), sistrip::FEDEmulator::retrievePedestals(), edm::DetSetVector< T >::size(), spyReorderedDigisToken_, spyVirginRawDigisToken_, sistrip::STRIPS_PER_FEDCH, sistrip::FEDEmulator::subtractCM(), sistrip::FEDEmulator::subtractPedestals(), utility_, cms::Exception::what(), and sistrip::FEDEmulator::zeroSuppress().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

139  {
140  //update cabling and pedestals
141  const SiStripFedCabling* lCabling = utility_.getCabling( iSetup );
144 
145  //initialise the algorithms object for the zero suppression
146  algorithms_->initialize(iSetup);
147 
148  //retrieve the digis
150  try { //to get the digis from the event
151  if (!byModule_) {
152  iEvent.getByToken(spyReorderedDigisToken_, lDigisHandle);
153  }
154  else { //digis supplied by module
155  iEvent.getByToken(spyVirginRawDigisToken_, lDigisHandle);
156  }//end of by module check
157  } catch (const cms::Exception& e) {
158  std::cout << e.what() ;
159  return;
160  } //end of get digis try
161 
162  const edm::DetSetVector<SiStripRawDigi> * lInputDigis = lDigisHandle.product();
163 
164  unsigned int lNDigis = lInputDigis->size();
165 
166  //define output containers
167  //reserve space, will push_back elements
168  std::vector<edm::DetSetVector<SiStripRawDigi>::detset > pedsData;
169  pedsData.reserve(lNDigis);
170  std::vector<edm::DetSetVector<SiStripProcessedRawDigi>::detset > noiseData;
171  noiseData.reserve(lNDigis);
172  std::vector<edm::DetSetVector<SiStripRawDigi>::detset > pedSubtrData;
173  pedSubtrData.reserve(lNDigis);
174  std::vector<edm::DetSetVector<SiStripRawDigi>::detset > cmSubtrData;
175  cmSubtrData.reserve(lNDigis);
176  //zero suppressed contained - no fixed size (could be empty) so no need to reserve elements.
177  std::vector< edm::DetSet<SiStripDigi> > zsData;
178 
179  //this is a map: no reserve/resize
180  std::map<uint32_t,std::vector<uint32_t> > medsData;
181 
182  edm::DetSetVector<SiStripRawDigi>::const_iterator inputChannel = lInputDigis->begin();
183 
184  for ( ; inputChannel!=lInputDigis->end(); ++inputChannel){//loop on input channels
185  uint32_t lDetId = inputChannel->detId(); //either fedIndex or detId
186 
187  pedsData.push_back( edm::DetSetVector<SiStripRawDigi>::detset(lDetId) );
188  noiseData.push_back( edm::DetSetVector<SiStripProcessedRawDigi>::detset(lDetId) );
189  pedSubtrData.push_back(edm::DetSetVector<SiStripRawDigi>::detset(lDetId) );
190  cmSubtrData.push_back( edm::DetSetVector<SiStripRawDigi>::detset(lDetId) );
191 
192  unsigned int lNStrips = inputChannel->size();
193 
194  //define output digi containers
195  std::vector<SiStripRawDigi>& pedsDetSetData = pedsData.back().data;
196  pedsDetSetData.reserve(lNStrips);
197  std::vector<SiStripProcessedRawDigi>& noiseDetSetData = noiseData.back().data;
198  noiseDetSetData.reserve(lNStrips);
199  std::vector<SiStripRawDigi>& pedSubtrDetSetData = pedSubtrData.back().data;
200  pedSubtrDetSetData.reserve(lNStrips);
201  std::vector<SiStripRawDigi>& cmSubtrDetSetData = cmSubtrData.back().data;
202  cmSubtrDetSetData.reserve(lNStrips);
203  //zero suppressed - slightly different procedure as not fixed size
204  edm::DetSet<SiStripDigi> zsDetSetData(lDetId);
205 
206  //determine the number of APV pairs in the channel
207  uint32_t lNPairs = static_cast<uint32_t>(lNStrips*1./sistrip::STRIPS_PER_FEDCH);
208  uint32_t lPair = 0;
209 
210  std::vector<uint32_t> medsDetSetData;
211  medsDetSetData.reserve(lNPairs*2); //2*number of pairs per module. If not by module, lNPairs = 1...
212 
213  if (!byModule_) { //the input is not stored by module
214  //need to retrieve the proper detId from cabling
215  uint16_t lFedId = 0;
216  uint16_t lFedChannel = 0;
217  sistrip::SpyUtilities::fedIndex(lDetId, lFedId, lFedChannel);
218 
219  const FedChannelConnection & lConnection = lCabling->fedConnection(lFedId,lFedChannel);
220  lDetId = lConnection.detId();
221  lNPairs = lConnection.nApvPairs();
222  lPair = lConnection.apvPairNumber();
223  }//end of by module check
224 
225  fedEmulator_.initialiseModule(lDetId,lNPairs,lPair);
226 
227  //get the pedestal values
228  //stored by module in the database
229  fedEmulator_.retrievePedestals(lPedsHandle);
230  fedEmulator_.retrieveNoises(lNoiseHandle);
231 
232  //last option: fill medians from these ped subtr data
233  //if want something else, need to call a method to fill
234  //the data member medians_ of the class fedEmulator.
235  fedEmulator_.subtractPedestals(inputChannel,
236  pedsDetSetData,
237  noiseDetSetData,
238  pedSubtrDetSetData,
239  medsDetSetData,
240  true);
241 
242  fedEmulator_.subtractCM(pedSubtrDetSetData,cmSubtrDetSetData);
243 
244  //fill the median map
245  medsData[inputChannel->detId()] = medsDetSetData;
246 
247  //zero suppress the digis
248  fedEmulator_.zeroSuppress(cmSubtrDetSetData, zsDetSetData, algorithms_);
249  if (!zsDetSetData.empty()) zsData.push_back( zsDetSetData );
250 
251  }//loop on input channels
252 
253 
254  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > lPeds(new edm::DetSetVector<SiStripRawDigi>(pedsData,true));
255  std::unique_ptr<edm::DetSetVector<SiStripProcessedRawDigi> > lNoises(new edm::DetSetVector<SiStripProcessedRawDigi>(noiseData,true));
256 
257  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > lOutputPedSubtr(new edm::DetSetVector<SiStripRawDigi>(pedSubtrData,true));
258 
259  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > lOutputCMSubtr(new edm::DetSetVector<SiStripRawDigi>(cmSubtrData,true));
260 
261  std::unique_ptr<std::map<uint32_t,std::vector<uint32_t> > > lMedians(new std::map<uint32_t,std::vector<uint32_t> >(medsData));
262 
263  //zero suppressed digis
264  std::unique_ptr< edm::DetSetVector<SiStripDigi> > lOutputZS(new edm::DetSetVector<SiStripDigi>(zsData));
265 
266  if (!byModule_) {
267  iEvent.put(std::move(lMedians),"Medians");
268  iEvent.put(std::move(lPeds),"PedestalsOrdered");
269  iEvent.put(std::move(lNoises),"NoisesOrdered");
270  iEvent.put(std::move(lOutputPedSubtr),"PedSubtrDigisOrdered");
271  iEvent.put(std::move(lOutputCMSubtr),"CMSubtrDigisOrdered");
272  }
273  else {
274  iEvent.put(std::move(lPeds),"ModulePedestals");
275  iEvent.put(std::move(lNoises),"ModuleNoises");
276  iEvent.put(std::move(lOutputPedSubtr),"PedSubtrModuleDigis");
277  iEvent.put(std::move(lMedians),"ModuleMedians");
278  iEvent.put(std::move(lOutputCMSubtr),"CMSubtrModuleDigis");
279  iEvent.put(std::move(lOutputZS),"ZSModuleDigis");
280  }
281 
282  }//produce method
static void fedIndex(uint32_t aFedIndex, uint16_t &aFedId, uint16_t &aFedChannel)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
void subtractPedestals(const edm::DetSetVector< SiStripRawDigi >::const_iterator &inputChannel, std::vector< SiStripRawDigi > &pedsDetSetData, std::vector< SiStripProcessedRawDigi > &noiseDetSetData, std::vector< SiStripRawDigi > &pedSubtrDetSetData, std::vector< uint32_t > &medsDetSetData, const bool fillApvsForCM)
edm::ESHandle< SiStripNoises > getNoiseHandle(const edm::EventSetup &eventSetup)
uint16_t apvPairNumber() const
edm::ESHandle< SiStripPedestals > getPedestalHandle(const edm::EventSetup &eventSetup)
char const * what() const override
Definition: Exception.cc:141
void retrieveNoises(const edm::ESHandle< SiStripNoises > &aHandle)
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyReorderedDigisToken_
const uint32_t & detId() const
Class containning control, module, detector and connection information, at the level of a FED channel...
void initialiseModule(const uint32_t aDetId, const uint32_t aNPairs, const uint32_t aPair)
void subtractCM(const std::vector< SiStripRawDigi > &pedSubtrDetSetData, std::vector< SiStripRawDigi > &cmSubtrDetSetData)
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
size_type size() const
Return the number of contained DetSets.
Definition: DetSetVector.h:283
static const uint16_t STRIPS_PER_FEDCH
T const * product() const
Definition: Handle.h:81
std::unique_ptr< SiStripRawProcessingAlgorithms > algorithms_
object for zero-suppression
void zeroSuppress(const std::vector< SiStripRawDigi > &cmSubtrDetSetData, edm::DetSet< SiStripDigi > &zsDetSetData, const std::unique_ptr< SiStripRawProcessingAlgorithms > &algorithms)
const SiStripFedCabling * getCabling(const edm::EventSetup &)
Updates the cabling object from the DB.
const uint16_t & nApvPairs() const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
void retrievePedestals(const edm::ESHandle< SiStripPedestals > &aHandle)
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyVirginRawDigisToken_

Member Data Documentation

std::unique_ptr<SiStripRawProcessingAlgorithms> sistrip::FEDEmulatorModule::algorithms_
private

object for zero-suppression

Definition at line 84 of file SiStripFEDEmulatorModule.cc.

Referenced by produce().

bool sistrip::FEDEmulatorModule::byModule_
private

Definition at line 78 of file SiStripFEDEmulatorModule.cc.

Referenced by FEDEmulatorModule(), and produce().

sistrip::FEDEmulator sistrip::FEDEmulatorModule::fedEmulator_
private

Definition at line 80 of file SiStripFEDEmulatorModule.cc.

Referenced by FEDEmulatorModule(), and produce().

const char * sistrip::FEDEmulatorModule::messageLabel_ = "SiStripFEDEmulatorModule"
staticprivate

Definition at line 82 of file SiStripFEDEmulatorModule.cc.

edm::InputTag sistrip::FEDEmulatorModule::spyReorderedDigisTag_
private

Definition at line 71 of file SiStripFEDEmulatorModule.cc.

Referenced by FEDEmulatorModule().

edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > sistrip::FEDEmulatorModule::spyReorderedDigisToken_
private

Definition at line 73 of file SiStripFEDEmulatorModule.cc.

Referenced by FEDEmulatorModule(), and produce().

edm::InputTag sistrip::FEDEmulatorModule::spyVirginRawDigisTag_
private

Definition at line 72 of file SiStripFEDEmulatorModule.cc.

Referenced by FEDEmulatorModule().

edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > sistrip::FEDEmulatorModule::spyVirginRawDigisToken_
private

Definition at line 74 of file SiStripFEDEmulatorModule.cc.

Referenced by FEDEmulatorModule(), and produce().

SpyUtilities sistrip::FEDEmulatorModule::utility_
private

Definition at line 87 of file SiStripFEDEmulatorModule.cc.

Referenced by produce().