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::ProductRegistryHelper

Public Member Functions

 FEDEmulatorModule (const edm::ParameterSet &)
 
 ~FEDEmulatorModule ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

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

Private Attributes

std::auto_ptr
< SiStripRawProcessingAlgorithms
algorithms_
 object for zero-suppression More...
 
bool byModule_
 
sistrip::FEDEmulator fedEmulator_
 
edm::InputTag spyReorderedDigisTag_
 
edm::InputTag spyVirginRawDigisTag_
 
SpyUtilities utility_
 

Static Private Attributes

static const char * messageLabel_ = "SiStripFEDEmulatorModule"
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 58 of file SiStripFEDEmulatorModule.cc.

Constructor & Destructor Documentation

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

Definition at line 99 of file SiStripFEDEmulatorModule.cc.

References byModule_, fedEmulator_, and sistrip::FEDEmulator::initialise().

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

Definition at line 127 of file SiStripFEDEmulatorModule.cc.

128  {
129  }

Member Function Documentation

void sistrip::FEDEmulatorModule::beginRun ( edm::Run ,
const edm::EventSetup  
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 281 of file SiStripFEDEmulatorModule.cc.

282  {
283 
284  }
void sistrip::FEDEmulatorModule::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 133 of file SiStripFEDEmulatorModule.cc.

References algorithms_, FedChannelConnection::apvPairNumber(), edm::DetSetVector< T >::begin(), byModule_, SiStripFedCabling::connection(), gather_cfg::cout, FedChannelConnection::detId(), edm::DetSetVector< T >::end(), fedEmulator_, sistrip::SpyUtilities::fedIndex(), edm::Event::getByLabel(), 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(), spyReorderedDigisTag_, spyVirginRawDigisTag_, sistrip::STRIPS_PER_FEDCH, sistrip::FEDEmulator::subtractCM(), sistrip::FEDEmulator::subtractPedestals(), utility_, cms::Exception::what(), and sistrip::FEDEmulator::zeroSuppress().

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

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

Member Data Documentation

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

object for zero-suppression

Definition at line 82 of file SiStripFEDEmulatorModule.cc.

Referenced by produce().

bool sistrip::FEDEmulatorModule::byModule_
private

Definition at line 76 of file SiStripFEDEmulatorModule.cc.

Referenced by FEDEmulatorModule(), and produce().

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

Definition at line 78 of file SiStripFEDEmulatorModule.cc.

Referenced by FEDEmulatorModule(), and produce().

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

Definition at line 80 of file SiStripFEDEmulatorModule.cc.

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

Definition at line 72 of file SiStripFEDEmulatorModule.cc.

Referenced by produce().

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

Definition at line 73 of file SiStripFEDEmulatorModule.cc.

Referenced by produce().

SpyUtilities sistrip::FEDEmulatorModule::utility_
private

Definition at line 85 of file SiStripFEDEmulatorModule.cc.

Referenced by produce().