CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

std::auto_ptr
< SiStripRawProcessingAlgorithms
algorithms_
 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
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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
std::auto_ptr< SiStripRawProcessingAlgorithms > algorithms_
object for zero-suppression
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyReorderedDigisToken_
static std::auto_ptr< SiStripRawProcessingAlgorithms > create(const edm::ParameterSet &)
void initialise(const bool byModule)
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyVirginRawDigisToken_
sistrip::FEDEmulatorModule::~FEDEmulatorModule ( )

Definition at line 132 of file SiStripFEDEmulatorModule.cc.

133  {
134  }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 138 of file SiStripFEDEmulatorModule.cc.

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

Member Data Documentation

std::auto_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().